index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <view class="zs-login" @touchmove.stop.prevent="clear">
  3. <!-- 注册认证 -->
  4. <u-popup :show="value" v-show="value" closeable :closeOnClickOverlay="false" mode="center" round="24"
  5. @close="close">
  6. <view class="modal">
  7. <view class="title">
  8. 身份认证
  9. </view>
  10. <u--form id="uForm" labelPosition="left" :model="userInfo" :rules="rules" ref="uForm">
  11. <u-form-item label="姓名" prop="name" ref="item1" labelWidth="100">
  12. <u--input placeholder="请输入姓名" v-model="userInfo.name" border="none"></u--input>
  13. </u-form-item>
  14. <u-form-item label="身份证" prop="idCardNum" ref="item1" labelWidth="100">
  15. <u--input type="idcard" placeholder="请输入身份证号" maxlength="18" v-model="userInfo.idCardNum"
  16. border="none"></u--input>
  17. </u-form-item>
  18. <u-form-item label="手机号" class="code" prop="phoneNum" ref="item1" labelWidth="100">
  19. <u--input type="digit" placeholder="请输入手机号" maxlength="11" v-model="userInfo.phoneNum"
  20. border="none"></u--input>
  21. <button size="mini" :loading="loading" plain open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"
  22. class="phone-btn" slot="right">一键填入</button>
  23. </u-form-item>
  24. <u-form-item label="验证码" prop="code" ref="item1" labelWidth="100">
  25. <u--input type="idcard" placeholder="请输入验证码" v-model="userInfo.code" border="none"></u--input>
  26. <view class="code-btn" slot="right" @click="sendCode">
  27. {{codeText}}
  28. </view>
  29. </u-form-item>
  30. <u-form-item class="none" prop="check" ref="item1" labelWidth="0">
  31. <u-checkbox-group v-model="userInfo.check">
  32. <u-checkbox size="32" shape="circle">
  33. </u-checkbox>
  34. <view @click="handleProtocol">已阅读并同意用户协议</view>
  35. </u-checkbox-group>
  36. </u-form-item>
  37. </u--form>
  38. <button class="save-btn" type="default" @click="submit">进行验证</button>
  39. <view class="jump-btn" @click="goLogin">已有账号?去登录</view>
  40. </view>
  41. </u-popup>
  42. <u-popup :show="show1" closeable :closeOnClickOverlay="false" mode="center" round="8" @close="close1">
  43. <view class="modal">
  44. <view class="title">
  45. 相关协议
  46. </view>
  47. <view class="protocol">
  48. 协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议协议
  49. </view>
  50. <view class="btn-group">
  51. <button class="btn refuse" type="default" @click="handleRefuse">拒绝</button>
  52. <button class="btn agree" type="default" @click="handleAgree">同意</button>
  53. </view>
  54. </view>
  55. </u-popup>
  56. </view>
  57. </template>
  58. <script>
  59. import {
  60. register,
  61. getPhoneNum,
  62. sendVerifyCode
  63. } from '@/api/common.js'
  64. export default {
  65. options: { styleIsolation: 'shared' },
  66. props: {
  67. value: {
  68. type: Boolean,
  69. default: false
  70. },
  71. },
  72. data() {
  73. return {
  74. // show: false,
  75. show1: false,
  76. userInfo: {
  77. name: '',
  78. idCardNum: '',
  79. code: '',
  80. phoneNum: '',
  81. check: []
  82. },
  83. rules: {
  84. 'name': {
  85. type: 'string',
  86. required: true,
  87. message: '请填写姓名',
  88. trigger: ['blur', 'change']
  89. },
  90. 'phoneNum': {
  91. type: 'number',
  92. required: true,
  93. message: '请填写手机号',
  94. trigger: ['blur', 'change']
  95. },
  96. 'code': {
  97. type: 'number',
  98. required: true,
  99. message: '请填写验证码',
  100. trigger: ['blur', 'change']
  101. },
  102. 'idCardNum': {
  103. type: 'string',
  104. max: 18,
  105. required: true,
  106. message: '请输入身份证号',
  107. trigger: ['blur', 'change']
  108. },
  109. 'check': {
  110. type: 'array',
  111. min: 1,
  112. required: true,
  113. message: '请勾选协议',
  114. trigger: ['change']
  115. },
  116. },
  117. isSend: false,
  118. seconds: 60,
  119. codeText: '获取验证码', //按钮文字
  120. isLogin: 0,
  121. loading:false,
  122. }
  123. },
  124. watch: {
  125. show(val) {
  126. console.log(val);
  127. }
  128. },
  129. onShow() {
  130. },
  131. onLoad() {
  132. this.$nextTick(() => {
  133. this.$refs.uForm.setRules(this.rules)
  134. })
  135. },
  136. methods: {
  137. clear(e) {
  138. },
  139. // 关闭登录窗口
  140. close() {
  141. this.$emit('input', false)
  142. },
  143. close1() {
  144. this.show1 = false
  145. },
  146. submit() {
  147. this.$refs.uForm.validate().then(r => {
  148. let {
  149. name,
  150. idCardNum,
  151. code,
  152. phoneNum
  153. } = this.userInfo
  154. let obj = {name,
  155. idCardNum,
  156. code,
  157. phoneNum}
  158. uni.showLoading({
  159. title:'登录中'
  160. })
  161. register(obj).then(res => {
  162. uni.hideLoading()
  163. if(res.msg == '成功'){
  164. uni.setStorageSync('register', 1)
  165. uni.navigateTo({
  166. url: '../../verify/index'
  167. })
  168. // uni.showModal({
  169. // title: '短信已发送至您的手机,请注意查收',
  170. // success: (r) => {
  171. // if (r.confirm) {
  172. // uni.navigateTo({
  173. // url: '../../login/login/login'
  174. // })
  175. // }
  176. // }
  177. // })
  178. }
  179. })
  180. }).catch(e => {
  181. })
  182. // uni.navigateTo({
  183. // url:'../../login/login/veriFace'
  184. // })
  185. },
  186. goLogin() {
  187. uni.navigateTo({
  188. url: '../../login/login/login'
  189. })
  190. },
  191. //获取微信绑定手机号
  192. getPhoneNumber(val) {
  193. if(!val.detail.hasOwnProperty('encryptedData')) return
  194. this.loading = true
  195. getPhoneNum({code:val.detail.code}).then(res=>{
  196. this.loading = false
  197. this.userInfo.phoneNum = res.content
  198. })
  199. },
  200. // 获取验证码
  201. sendCode() {
  202. if(this.userInfo.phoneNum === ''){
  203. return uni.showToast({
  204. icon:'error',
  205. title:'手机号为空'
  206. })
  207. }
  208. if (this.isSend) return
  209. this.isSend = true
  210. sendVerifyCode({phoneNum:this.userInfo.phoneNum,appName:'user',templateId:1}).then(res=>{
  211. })
  212. this.timer = setInterval(() => {
  213. if (this.seconds <= 0) {
  214. this.codeText = '获取验证码'
  215. this.seconds = 60
  216. this.isSend = false
  217. clearInterval(this.timer)
  218. } else {
  219. this.codeText = this.seconds + 's后获取'
  220. }
  221. this.seconds--
  222. }, 1000)
  223. },
  224. // 点击协议
  225. handleProtocol() {
  226. this.show1 = true
  227. },
  228. handleRefuse(){
  229. this.show1 = false;
  230. this.userInfo.check = []
  231. },
  232. handleAgree() {
  233. this.show1 = false;
  234. this.userInfo.check = ['']
  235. },
  236. },
  237. }
  238. </script>
  239. <style lang="scss" >
  240. .zs-login{
  241. // 弹出框关闭按钮
  242. .u-popup__content__close--top-right{
  243. top: 46rpx!important;
  244. .u-icon__icon{
  245. font-size: 30rpx!important;
  246. }
  247. }
  248. .u-form-item{
  249. height: 96rpx;
  250. line-height: 96rpx;
  251. border-radius: 24rpx;
  252. background: #F5F7F9;
  253. margin-top: 28rpx;
  254. .u-form-item__body{
  255. padding: 0 30rpx;
  256. }
  257. // 错误提示
  258. .u-form-item__body__right__message{
  259. margin-left: 130rpx!important;
  260. }
  261. }
  262. .u-form .u-form-item:last-child{
  263. background: none !important;
  264. height: 60rpx;
  265. line-height: 60rpx;
  266. margin-top: 10rpx;
  267. .u-form-item__body__right__message{
  268. margin-left: 70rpx!important;
  269. }
  270. }
  271. .modal {
  272. width: 680rpx;
  273. box-sizing: border-box;
  274. padding: 30rpx;
  275. .title {
  276. text-align: center;
  277. font-size: 38rpx;
  278. font-weight: bold;
  279. margin-top: 30rpx;
  280. margin-bottom: 50rpx;
  281. }
  282. .code {
  283. position: relative;
  284. }
  285. .phone-btn {
  286. color: $uni-text-primary;
  287. border: none;
  288. font-size: 28rpx;
  289. padding: 0;
  290. }
  291. .code-btn {
  292. color: $uni-text-primary;
  293. font-size: 28rpx;
  294. }
  295. .save-btn {
  296. width: 432rpx;
  297. height: 92rpx;
  298. line-height: 92rpx;
  299. border-radius: 46rpx;
  300. font-size: 32rpx;
  301. font-weight: bold;
  302. background: $uni-color-primary;
  303. color: #fff;
  304. margin-top: 52rpx;
  305. }
  306. .jump-btn {
  307. text-align: center;
  308. color: royalblue;
  309. font-size: 30rpx;
  310. margin-top: 30rpx;
  311. }
  312. }
  313. .protocol {
  314. margin: 30rpx;
  315. padding: 10rpx;
  316. border: 1px solid #ccc;
  317. height: 750rpx;
  318. overflow: auto;
  319. border-radius: 4px;
  320. color: #666;
  321. }
  322. .btn-group {
  323. display: flex;
  324. align-items: center;
  325. .btn {
  326. border-radius: 4px;
  327. width: 250rpx;
  328. color: #fff;
  329. }
  330. .refuse {
  331. background-color: rgb(191, 191, 191);
  332. }
  333. .agree {
  334. background: $uni-color-primary;
  335. }
  336. }
  337. }
  338. </style>