bind.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <view style="height: 100%;">
  3. <image mode="widthFix" src="/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. };
  30. },
  31. mounted() {},
  32. methods: {
  33. jumpBind(){
  34. let that = this
  35. if(!this.form.realname){
  36. this.$u.toast('请输入学员姓名');
  37. return
  38. }
  39. if(!this.form.idCard){
  40. this.$u.toast('请输入身份证卡号');
  41. return
  42. }
  43. that.isUse = true
  44. that.$api.bindId(this.form).then(
  45. res => {
  46. that.isUse = false
  47. if (res.data.code == 200) {
  48. uni.setStorageSync('user_account',uni.getStorageSync('user_account_temp'));
  49. uni.setStorageSync('token',uni.getStorageSync('token_temp'));
  50. uni.removeStorageSync('user_account_temp') //移除临时账号
  51. uni.removeStorageSync('token_temp') //移除临时token
  52. uni.switchTab({
  53. url:'/pages/index/index'
  54. })
  55. } else {
  56. that.$u.toast(res.data.msg);
  57. }
  58. },
  59. err => {
  60. that.isUse = false
  61. }
  62. );
  63. },
  64. radioGroupChange(e) {
  65. console.log(e);
  66. },
  67. codeChange(text) {
  68. this.codeTips = text;
  69. },
  70. // 获取验证码
  71. getCode() {
  72. if(this.$refs.uCode.canGetCode) {
  73. // 模拟向后端请求验证码
  74. uni.showLoading({
  75. title: '正在获取验证码',
  76. mask: true
  77. })
  78. setTimeout(() => {
  79. uni.hideLoading();
  80. // 这里此提示会被this.start()方法中的提示覆盖
  81. this.$u.toast('验证码已发送');
  82. // 通知验证码组件内部开始倒计时
  83. this.$refs.uCode.start();
  84. }, 2000);
  85. } else {
  86. this.$u.toast('倒计时结束后再发送');
  87. }
  88. },
  89. sectionChange(index) {
  90. this.current = index;
  91. },
  92. getPhoneNumber(e) {
  93. let that = this;
  94. uni.checkSession({
  95. success () {
  96. //session_key 未过期,并且在本生命周期一直有效
  97. that.putInfo(e)
  98. },
  99. fail () {
  100. // session_key 已经失效,需要重新执行登录流程
  101. uni.login({
  102. provider: 'weixin',
  103. success: function(loginRes) {
  104. that.code = loginRes.code;
  105. that.putInfo(e)
  106. }
  107. });
  108. }
  109. })
  110. },
  111. putInfo(e){
  112. let that = this;
  113. if (e.detail.encryptedData) {
  114. let inviteCode = uni.getStorageSync("inviteCode")
  115. //用户同意授权
  116. var datas = {
  117. iv: e.detail.iv,
  118. encryptedData: e.detail.encryptedData,
  119. code: that.code
  120. };
  121. if(inviteCode){
  122. datas.inviteCode = inviteCode
  123. }
  124. that.$api.login(datas).then(
  125. res => {
  126. if (res.data.code == 200) {
  127. uni.setStorageSync('union_id', res.data.data.union_id);
  128. uni.setStorageSync('token', res.data.data.token);
  129. that.$api.getInfo().then(resdata => {
  130. if(resdata.data.code == 200){
  131. uni.navigateBack();
  132. that.$store.state.userInfo = resdata.data.data;
  133. }
  134. });
  135. } else {
  136. uni.showModal({
  137. title: '提示',
  138. content: res.data.msg,
  139. showCancel: false
  140. });
  141. }
  142. },
  143. err => {
  144. console.log(err);
  145. }
  146. );
  147. }
  148. }
  149. },
  150. onLoad(option) {
  151. let that = this;
  152. this.from = option.from;
  153. uni.login({
  154. provider: 'weixin',
  155. success: function(loginRes) {
  156. that.code = loginRes.code;
  157. }
  158. });
  159. }
  160. };
  161. </script>
  162. <style scoped>
  163. .wxBtn{
  164. position: fixed;
  165. bottom: 10%;
  166. width: 100%;
  167. left: 0;
  168. }
  169. /deep/ .wxBtn button::after{
  170. border: none;
  171. }
  172. .loginBtn{
  173. width: 526rpx;
  174. height: 80rpx;
  175. background: linear-gradient(90deg, #015EEA, #00C0FA);
  176. box-shadow: 0rpx 10rpx 16rpx 4rpx rgba(1, 99, 235, 0.04);
  177. opacity: 0.6;
  178. border-radius: 40rpx;
  179. color: #FFFFFF;
  180. text-align: center;
  181. line-height: 80rpx;
  182. margin: 40rpx auto;
  183. }
  184. .wxloginBtn{
  185. background: url("/static/loginBtn.png") no-repeat;
  186. background-size:100% 100%;
  187. border:none;
  188. width: 100rpx;
  189. height: 100rpx;
  190. }
  191. /deep/page {
  192. background-color: #FFFFFF;
  193. height: 100%;
  194. width: 100%;
  195. }
  196. .login_box{
  197. width: 100%;
  198. height: 360rpx;
  199. background: #FFFFFF;
  200. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(1, 99, 235, 0.1);
  201. border-radius: 24rpx;
  202. margin-top: 30rpx;
  203. padding:40rpx 35rpx;
  204. }
  205. /deep/ .u-item-bg{
  206. border-radius: 32px !important;
  207. }
  208. /deep/ .u-subsection{
  209. border-radius: 32px !important;
  210. }
  211. .full_img {
  212. position: absolute;
  213. left: 0;
  214. display: block;
  215. width: 100%;
  216. z-index: -999;
  217. top: 0;
  218. }
  219. .head {
  220. height: 96rpx;
  221. width: 100%;
  222. line-height: 96rpx;
  223. margin-top: 40rpx;
  224. text-align: center;
  225. display: flex;
  226. position: relative;
  227. justify-content: center;
  228. }
  229. .icon {
  230. position: absolute;
  231. left: 30rpx;
  232. }
  233. </style>