register.vue 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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;width: 200px;"
  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;width: 200px;"
  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. passportVal:{}
  119. }
  120. },
  121. created() {
  122. this.getCode()
  123. },
  124. onLoad(option) {
  125. this.sysType = uni.getStorageSync('sysType');
  126. // this.passportVal = option;
  127. if(option.valus==1){
  128. this.registerForm.idType =1
  129. this.registerForm.nationality =1
  130. }else{
  131. let {
  132. params
  133. } = option
  134. // this.improvedetail = JSON.parse(improvedetail)
  135. let paramsObj = JSON.parse(params);
  136. this.registerForm.name = paramsObj.nickName;
  137. this.registerForm.identityNo = paramsObj.idCard
  138. this.registerForm.id = paramsObj.id
  139. }
  140. },
  141. methods: {
  142. // 获取手机验证码
  143. getCodeNumber(data) {
  144. sendCode({
  145. phone: data
  146. }).then(res => {
  147. uni.showModal({
  148. title: "系统提示",
  149. content: res.msg,
  150. })
  151. if (res.code != 200) {
  152. return
  153. } else {
  154. let time = 60;
  155. let timer = setInterval(() => {
  156. time--;
  157. this.codeDisabled = true;
  158. this.codeText = time + 's重试'
  159. if (time == 0) {
  160. clearInterval(timer)
  161. this.codeText = '发送验证码'
  162. this.codeDisabled = false;
  163. }
  164. }, 1000)
  165. }
  166. })
  167. },
  168. // 用户登录
  169. handleUserLogin() {
  170. this.$tab.navigateTo(`/pages/login`)
  171. },
  172. // 获取图形验证码
  173. getCode() {
  174. getCodeImg().then(res => {
  175. this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
  176. if (this.captchaEnabled) {
  177. this.codeUrl = 'data:image/gif;base64,' + res.img
  178. this.registerForm.uuid = res.uuid
  179. }
  180. })
  181. },
  182. // 注册方法
  183. async handleRegister() {
  184. if (this.registerForm.userName === "") {
  185. this.$modal.msgError("请输入您的账号")
  186. } else if (this.registerForm.passWord === "") {
  187. this.$modal.msgError("请输入您的密码")
  188. } else if (this.registerForm.confirmPassword === "") {
  189. this.$modal.msgError("请再次输入您的密码")
  190. } else if (this.registerForm.passWord !== this.registerForm.confirmPassword) {
  191. this.$modal.msgError("两次输入的密码不一致")
  192. } else if (this.registerForm.code === "" && this.captchaEnabled) {
  193. this.$modal.msgError("请输入验证码")
  194. } else if (this.registerForm.idCard === "") {
  195. this.$modal.msgError("请输入身份证号码")
  196. } else if (this.registerForm.phone === "") {
  197. this.$modal.msgError("请输入手机号")
  198. } else if (this.registerForm.email === "") {
  199. this.$modal.msgError("请输入邮箱")
  200. } else {
  201. this.$modal.loading("注册中,请耐心等待...")
  202. this.register()
  203. }
  204. },
  205. // 用户注册
  206. async register() {
  207. wxregister(this.registerForm).then(res => {
  208. this.$modal.closeLoading()
  209. uni.showModal({
  210. title: "系统提示",
  211. content: "恭喜你,您的账号 " + this.registerForm.userName + " 注册成功!",
  212. success: function(res) {
  213. if (res.confirm) {
  214. uni.redirectTo({
  215. url: `/pages/login`
  216. });
  217. }
  218. }
  219. })
  220. }).catch(() => {
  221. if (this.captchaEnabled) {
  222. this.getCode()
  223. }
  224. })
  225. },
  226. // 注册成功后,处理函数
  227. registerSuccess(result) {
  228. // 设置用户信息
  229. this.$store.dispatch('GetInfo').then(res => {
  230. this.$tab.reLaunch('/pages/index')
  231. })
  232. },
  233. certificateValue(e){
  234. this.registerForm.idType = e
  235. }
  236. },
  237. }
  238. </script>
  239. <style lang="scss">
  240. page {
  241. background-color: #ffffff;
  242. }
  243. ::v-deep .uni-select[data-v-6b64008e]{
  244. border: none;
  245. }
  246. ::v-deep .uni-icons[data-v-a2e81f6e]{
  247. display: none;
  248. }
  249. .uni-icons{
  250. display: none;
  251. }
  252. // ::v-deep .uni-select{
  253. // border: none;
  254. // width: 200%;
  255. // }
  256. .normal-login-container {
  257. width: 100%;
  258. background-color: #ffffff;
  259. .logo-content {
  260. width: 100%;
  261. font-size: 21px;
  262. text-align: center;
  263. padding-top: 15%;
  264. image {
  265. border-radius: 4px;
  266. }
  267. .title {
  268. margin-left: 10px;
  269. }
  270. }
  271. .login-form-content {
  272. text-align: center;
  273. margin: 20px auto;
  274. margin-top: 15%;
  275. width: 80%;
  276. .input-item {
  277. margin: 20px auto;
  278. background-color: #f5f6f7;
  279. height: 45px;
  280. border-radius: 20px;
  281. .icon {
  282. font-size: 38rpx;
  283. margin-left: 10px;
  284. color: #999;
  285. }
  286. .input {
  287. width: 100%;
  288. font-size: 14px;
  289. line-height: 20px;
  290. text-align: left;
  291. padding-left: 15px;
  292. }
  293. }
  294. .register-btn {
  295. margin-top: 40px;
  296. height: 45px;
  297. }
  298. .xieyi {
  299. color: #333;
  300. margin-top: 20px;
  301. }
  302. .login-code {
  303. height: 38px;
  304. float: right;
  305. .login-code-img {
  306. height: 38px;
  307. position: absolute;
  308. margin-left: 10px;
  309. width: 200rpx;
  310. font-size: 28rpx;
  311. }
  312. }
  313. .mini-btn {
  314. height: 38px;
  315. }
  316. }
  317. }
  318. </style>