register.vue 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view class="normal-login-container">
  3. <view class="logo-content align-center justify-center flex">
  4. <image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix">
  5. </image>
  6. <text class="title">仲裁系统注册</text>
  7. </view>
  8. <view class="login-form-content">
  9. <view class="input-item flex align-center" style="width: 60%;margin: 0px;">
  10. <!-- <view class="iconfont icon-user icon"></view> -->
  11. <input v-model="registerForm.phone" class="input" type="number" placeholder="请输入手机号" maxlength="30" />
  12. <view class="login-code">
  13. <button class="login-code-img" type="primary" :disabled="codeDisabled"
  14. @tap="getCodeNumber(registerForm.phone)">{{codeText}}</button>
  15. </view>
  16. </view>
  17. <view class="input-item flex align-center">
  18. <!-- <view class="iconfont icon-user icon"></view> -->
  19. <input v-model="registerForm.verifyCode" class="input" type="number" placeholder="请输入手机验证码"
  20. maxlength="30" />
  21. </view>
  22. <view class="input-item flex align-center">
  23. <!-- <view class="iconfont icon-user icon"></view> -->
  24. <input v-model="registerForm.identityNo" class="input" type="text" placeholder="请输入身份证号"
  25. maxlength="30" />
  26. </view>
  27. <view class="input-item flex align-center">
  28. <!-- <view class="iconfont icon-user icon"></view> -->
  29. <input v-model="registerForm.email" class="input" type="text" placeholder="请输入邮箱" maxlength="30" />
  30. </view>
  31. <view class="input-item flex align-center">
  32. <!-- <view class="iconfont icon-user icon"></view> -->
  33. <input v-model="registerForm.name" class="input" type="text" placeholder="请输入用户名" maxlength="30" />
  34. </view>
  35. <view class="input-item flex align-center">
  36. <!-- <view class="iconfont icon-user icon"></view> -->
  37. <input v-model="registerForm.userName" class="input" type="text" placeholder="请输入账号" maxlength="30" />
  38. </view>
  39. <view class="input-item flex align-center">
  40. <!-- <view class="iconfont icon-password icon"></view> -->
  41. <input v-model="registerForm.passWord" type="password" class="input" placeholder="请输入密码"
  42. maxlength="20" />
  43. </view>
  44. <view class="input-item flex align-center">
  45. <!-- <view class="iconfont icon-password icon"></view> -->
  46. <input v-model="registerForm.confirmPassword" type="password" class="input" placeholder="请输入重复密码"
  47. maxlength="20" />
  48. </view>
  49. <view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
  50. <!-- <view class="iconfont icon-code icon"></view> -->
  51. <input v-model="registerForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
  52. <view class="login-code">
  53. <image :src="codeUrl" @click="getCode" class="login-code-img"></image>
  54. </view>
  55. </view>
  56. <view class="action-btn">
  57. <button @click="handleRegister()" class="register-btn cu-btn block bg-blue lg round">注册</button>
  58. </view>
  59. </view>
  60. <view class="xieyi text-center">
  61. <text @click="handleUserLogin" class="text-blue">使用已有账号登录</text>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import {
  67. getCodeImg,
  68. register,
  69. sendCode,
  70. wxregister
  71. } from '@/api/login'
  72. export default {
  73. data() {
  74. return {
  75. codeUrl: "",
  76. captchaEnabled: true,
  77. globalConfig: getApp().globalData.config,
  78. codeText: "发送验证码",
  79. codeDisabled: false,
  80. registerForm: {
  81. userName: "",
  82. passWord: "",
  83. confirmPassword: "",
  84. code: "",
  85. uuid: '',
  86. name: '',
  87. identityNo: "",
  88. id: ""
  89. }
  90. }
  91. },
  92. created() {
  93. this.getCode()
  94. },
  95. onLoad(option) {
  96. let {
  97. params
  98. } = option
  99. // this.improvedetail = JSON.parse(improvedetail)
  100. let paramsObj = JSON.parse(params);
  101. this.registerForm.name = paramsObj.nickName;
  102. this.registerForm.identityNo = paramsObj.idCard
  103. this.registerForm.id = paramsObj.id
  104. },
  105. methods: {
  106. // 获取手机验证码
  107. getCodeNumber(data) {
  108. sendCode({
  109. phone: data
  110. }).then(res => {
  111. uni.showModal({
  112. title: "系统提示",
  113. content: res.msg,
  114. })
  115. if (res.code != 200) {
  116. return
  117. } else {
  118. let time = 60;
  119. let timer = setInterval(() => {
  120. time--;
  121. this.codeDisabled = true;
  122. this.codeText = time + 's重试'
  123. if (time == 0) {
  124. clearInterval(timer)
  125. this.codeText = '发送验证码'
  126. this.codeDisabled = false;
  127. }
  128. }, 1000)
  129. }
  130. })
  131. },
  132. // 用户登录
  133. handleUserLogin() {
  134. this.$tab.navigateTo(`/pages/login`)
  135. },
  136. // 获取图形验证码
  137. getCode() {
  138. getCodeImg().then(res => {
  139. this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
  140. if (this.captchaEnabled) {
  141. this.codeUrl = 'data:image/gif;base64,' + res.img
  142. this.registerForm.uuid = res.uuid
  143. }
  144. })
  145. },
  146. // 注册方法
  147. async handleRegister() {
  148. if (this.registerForm.userName === "") {
  149. this.$modal.msgError("请输入您的账号")
  150. } else if (this.registerForm.passWord === "") {
  151. this.$modal.msgError("请输入您的密码")
  152. } else if (this.registerForm.confirmPassword === "") {
  153. this.$modal.msgError("请再次输入您的密码")
  154. } else if (this.registerForm.passWord !== this.registerForm.confirmPassword) {
  155. this.$modal.msgError("两次输入的密码不一致")
  156. } else if (this.registerForm.code === "" && this.captchaEnabled) {
  157. this.$modal.msgError("请输入验证码")
  158. } else if (this.registerForm.idCard === "") {
  159. this.$modal.msgError("请输入身份证号码")
  160. } else if (this.registerForm.phone === "") {
  161. this.$modal.msgError("请输入手机号")
  162. } else if (this.registerForm.email === "") {
  163. this.$modal.msgError("请输入邮箱")
  164. } else {
  165. this.$modal.loading("注册中,请耐心等待...")
  166. this.register()
  167. }
  168. },
  169. // 用户注册
  170. async register() {
  171. wxregister(this.registerForm).then(res => {
  172. this.$modal.closeLoading()
  173. uni.showModal({
  174. title: "系统提示",
  175. content: "恭喜你,您的账号 " + this.registerForm.userName + " 注册成功!",
  176. success: function(res) {
  177. if (res.confirm) {
  178. uni.redirectTo({
  179. url: `/pages/login`
  180. });
  181. }
  182. }
  183. })
  184. }).catch(() => {
  185. if (this.captchaEnabled) {
  186. this.getCode()
  187. }
  188. })
  189. },
  190. // 注册成功后,处理函数
  191. registerSuccess(result) {
  192. // 设置用户信息
  193. this.$store.dispatch('GetInfo').then(res => {
  194. this.$tab.reLaunch('/pages/index')
  195. })
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="scss">
  201. page {
  202. background-color: #ffffff;
  203. }
  204. .normal-login-container {
  205. width: 100%;
  206. background-color: #ffffff;
  207. .logo-content {
  208. width: 100%;
  209. font-size: 21px;
  210. text-align: center;
  211. padding-top: 15%;
  212. image {
  213. border-radius: 4px;
  214. }
  215. .title {
  216. margin-left: 10px;
  217. }
  218. }
  219. .login-form-content {
  220. text-align: center;
  221. margin: 20px auto;
  222. margin-top: 15%;
  223. width: 80%;
  224. .input-item {
  225. margin: 20px auto;
  226. background-color: #f5f6f7;
  227. height: 45px;
  228. border-radius: 20px;
  229. .icon {
  230. font-size: 38rpx;
  231. margin-left: 10px;
  232. color: #999;
  233. }
  234. .input {
  235. width: 100%;
  236. font-size: 14px;
  237. line-height: 20px;
  238. text-align: left;
  239. padding-left: 15px;
  240. }
  241. }
  242. .register-btn {
  243. margin-top: 40px;
  244. height: 45px;
  245. }
  246. .xieyi {
  247. color: #333;
  248. margin-top: 20px;
  249. }
  250. .login-code {
  251. height: 38px;
  252. float: right;
  253. .login-code-img {
  254. height: 38px;
  255. position: absolute;
  256. margin-left: 10px;
  257. width: 200rpx;
  258. font-size: 28rpx;
  259. }
  260. }
  261. .mini-btn {
  262. height: 38px;
  263. }
  264. }
  265. }
  266. </style>