bind.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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" maxlength="18" 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. } else {
  71. this.$u.toast(res.data.msg)
  72. }
  73. })
  74. } else { // 跳转到首页是原来的逻辑
  75. uni.reLaunch({
  76. url:'/pages/index/index'
  77. })
  78. }
  79. this.$method.setUuid(new Date().valueOf() + "")
  80. that.$api.getInfo({ fromPlat: 1 }).then(resdata => {
  81. if(resdata.data.code == 200){
  82. that.$store.state.userInfo = resdata.data.data;
  83. }
  84. });
  85. } else {
  86. that.$u.toast(res.data.msg);
  87. }
  88. },
  89. err => {
  90. that.isUse = false
  91. }
  92. );
  93. },
  94. },
  95. onLoad(option) {
  96. console.log('注册:', option.scanCode)
  97. let that = this;
  98. option.scanCode && (this.scanCode = option.scanCode)
  99. uni.removeStorageSync('user_account') //移除临时账号
  100. uni.removeStorageSync('token')
  101. uni.login({
  102. provider: 'weixin',
  103. success: function(loginRes) {
  104. that.code = loginRes.code;
  105. }
  106. });
  107. }
  108. };
  109. </script>
  110. <style scoped>
  111. .wxBtn{
  112. position: fixed;
  113. bottom: 10%;
  114. width: 100%;
  115. left: 0;
  116. }
  117. /deep/ .wxBtn button::after{
  118. border: none;
  119. }
  120. .loginBtn{
  121. width: 526rpx;
  122. height: 80rpx;
  123. background: linear-gradient(90deg, #015EEA, #00C0FA);
  124. box-shadow: 0rpx 10rpx 16rpx 4rpx rgba(1, 99, 235, 0.04);
  125. opacity: 0.6;
  126. border-radius: 40rpx;
  127. color: #FFFFFF;
  128. text-align: center;
  129. line-height: 80rpx;
  130. margin: 40rpx auto;
  131. }
  132. .wxloginBtn{
  133. background: url("/static/loginBtn.png") no-repeat;
  134. background-size:100% 100%;
  135. border:none;
  136. width: 100rpx;
  137. height: 100rpx;
  138. }
  139. /deep/page {
  140. background-color: #FFFFFF;
  141. height: 100%;
  142. width: 100%;
  143. }
  144. .login_box{
  145. width: 100%;
  146. height: 360rpx;
  147. background: #FFFFFF;
  148. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(1, 99, 235, 0.1);
  149. border-radius: 24rpx;
  150. margin-top: 30rpx;
  151. padding:40rpx 35rpx;
  152. }
  153. /deep/ .u-item-bg{
  154. border-radius: 32px !important;
  155. }
  156. /deep/ .u-subsection{
  157. border-radius: 32px !important;
  158. }
  159. .full_img {
  160. position: absolute;
  161. left: 0;
  162. display: block;
  163. width: 100%;
  164. z-index: -999;
  165. top: 0;
  166. }
  167. .head {
  168. height: 96rpx;
  169. width: 100%;
  170. line-height: 96rpx;
  171. margin-top: 40rpx;
  172. text-align: center;
  173. display: flex;
  174. position: relative;
  175. justify-content: center;
  176. }
  177. .icon {
  178. position: absolute;
  179. left: 30rpx;
  180. }
  181. </style>