register.vue 8.8KB

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