register.vue 9.2KB

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