bind.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view style="height: 100%;">
  3. <image mode="widthFix" src="/pages2/static/login_bg.jpg" class="full_img"></image>
  4. <u-navbar title="关联学员身份" :border-bottom="false" background="{ background: '#ffffff',opacity:0.4; }" title-color="#ffffff" back-icon-color="#ffffff"></u-navbar>
  5. <view style="padding: 30rpx;">
  6. <view class="login_box">
  7. <u-form :model="form" ref="uForm" >
  8. <u-form-item ><u-input v-model="form.realname" placeholder="学员姓名"/></u-form-item>
  9. <u-form-item ><u-input v-model="form.idCard" type="idcard" placeholder="学员身份证号"/></u-form-item>
  10. </u-form>
  11. </view>
  12. <button :disabled="isUse" class="loginBtn" @click="jumpBind">
  13. 确定
  14. </button>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. code: '',
  23. form:{
  24. realname:'',
  25. idCard:''
  26. },
  27. codeTips: '',
  28. read:'',
  29. scanCode: '', // 获取扫码的路径最后面的6位标识码
  30. };
  31. },
  32. mounted() {},
  33. methods: {
  34. jumpBind(){
  35. let that = this
  36. if(!this.form.realname.trim()){
  37. this.$u.toast('请输入学员姓名');
  38. return
  39. }
  40. if(!this.form.idCard.trim()){
  41. this.$u.toast('请输入身份证卡号');
  42. return
  43. }
  44. let IDRe18 = /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
  45. let IDre15 = /^([1-6][1-9]|50)\d{4}\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}$/
  46. if( !IDRe18.test( this.form.idCard ) && !IDre15.test( this.form.idCard ) ) {
  47. this.$u.toast('请输入格式正确的身份证卡号');
  48. console.log(' 验证未通过 ')
  49. return
  50. }
  51. this.$set(this.form,'realname',this.form.realname.trim()) //去除姓名两头空格
  52. that.isUse = true
  53. // 绑定身份证号信息 /app/user/bind_idcard
  54. that.$api.bindId(this.form).then(
  55. res => {
  56. that.isUse = false
  57. if (res.data.code == 200) {
  58. uni.setStorageSync('user_account',uni.getStorageSync('user_account_temp'));
  59. uni.setStorageSync('token',uni.getStorageSync('token_temp'));
  60. uni.removeStorageSync('user_account_temp') //移除临时账号
  61. uni.removeStorageSync('token_temp') //移除临时token
  62. if (this.scanCode) { // pc扫码注册成功后提交/跳转
  63. this.$api.scanLoginCheck({
  64. scanCode: this.scanCode
  65. }).then((res) => {
  66. if (res.data.code == 200) {
  67. uni.navigateTo({
  68. url: '/pages4/login/pcLoginSuccess'
  69. })
  70. }
  71. })
  72. } else { // 跳转到首页是原来的逻辑
  73. uni.reLaunch({
  74. url:'/pages/index/index'
  75. })
  76. }
  77. this.$method.setUuid(new Date().valueOf() + "")
  78. that.$api.getInfo().then(resdata => {
  79. if(resdata.data.code == 200){
  80. that.$store.state.userInfo = resdata.data.data;
  81. }
  82. });
  83. } else {
  84. that.$u.toast(res.data.msg);
  85. }
  86. },
  87. err => {
  88. that.isUse = false
  89. }
  90. );
  91. },
  92. },
  93. onLoad(option) {
  94. console.log('注册:', option.scanCode)
  95. let that = this;
  96. option.scanCode && (this.scanCode = option.scanCode)
  97. uni.removeStorageSync('user_account') //移除临时账号
  98. uni.removeStorageSync('token')
  99. uni.login({
  100. provider: 'weixin',
  101. success: function(loginRes) {
  102. that.code = loginRes.code;
  103. }
  104. });
  105. }
  106. };
  107. </script>
  108. <style scoped>
  109. .wxBtn{
  110. position: fixed;
  111. bottom: 10%;
  112. width: 100%;
  113. left: 0;
  114. }
  115. /deep/ .wxBtn button::after{
  116. border: none;
  117. }
  118. .loginBtn{
  119. width: 526rpx;
  120. height: 80rpx;
  121. background: linear-gradient(90deg, #015EEA, #00C0FA);
  122. box-shadow: 0rpx 10rpx 16rpx 4rpx rgba(1, 99, 235, 0.04);
  123. opacity: 0.6;
  124. border-radius: 40rpx;
  125. color: #FFFFFF;
  126. text-align: center;
  127. line-height: 80rpx;
  128. margin: 40rpx auto;
  129. }
  130. .wxloginBtn{
  131. background: url("/static/loginBtn.png") no-repeat;
  132. background-size:100% 100%;
  133. border:none;
  134. width: 100rpx;
  135. height: 100rpx;
  136. }
  137. /deep/page {
  138. background-color: #FFFFFF;
  139. height: 100%;
  140. width: 100%;
  141. }
  142. .login_box{
  143. width: 100%;
  144. height: 360rpx;
  145. background: #FFFFFF;
  146. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(1, 99, 235, 0.1);
  147. border-radius: 24rpx;
  148. margin-top: 30rpx;
  149. padding:40rpx 35rpx;
  150. }
  151. /deep/ .u-item-bg{
  152. border-radius: 32px !important;
  153. }
  154. /deep/ .u-subsection{
  155. border-radius: 32px !important;
  156. }
  157. .full_img {
  158. position: absolute;
  159. left: 0;
  160. display: block;
  161. width: 100%;
  162. z-index: -999;
  163. top: 0;
  164. }
  165. .head {
  166. height: 96rpx;
  167. width: 100%;
  168. line-height: 96rpx;
  169. margin-top: 40rpx;
  170. text-align: center;
  171. display: flex;
  172. position: relative;
  173. justify-content: center;
  174. }
  175. .icon {
  176. position: absolute;
  177. left: 30rpx;
  178. }
  179. </style>