diff --git a/App.vue b/App.vue index 4ad52c3..5182421 100644 --- a/App.vue +++ b/App.vue @@ -4,9 +4,9 @@ globalData: { im: {} }, - computed: { - ...mapState(["hasLogin"]) - }, + computed: { + ...mapState(["hasLogin"]) + }, onLaunch() { getApp().globalData.im = this.imService // 缓存token @@ -16,23 +16,23 @@ this.loginIn(res.data); } }) - // 刷新token - if (this.hasLogin) { - this.refreshToken_function(); - } + // 刷新token + if (this.hasLogin) { + this.refreshToken_function(); + } }, methods: { ...mapMutations(['loginIn']), - // 刷新token - refreshToken_function(){ - this.$u.api.refreshToken({}).then((res) => { - // console.log(res); - if (res.errCode == 0) { - let token = res.data.token; - uni.setStorageSync('token', token);//存储toke值 - } - }) - }, + // 刷新token + refreshToken_function(){ + this.$u.api.refreshToken({}).then((res) => { + // console.log(res); + if (res.errCode == 0) { + let token = res.data.token; + uni.setStorageSync('token', token);//存储toke值 + } + }) + }, } } diff --git a/common/http.interceptor.js b/common/http.interceptor.js index df8471e..b813783 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -47,6 +47,10 @@ const install = (Vue, vm) => { // 假设201为token失效,这里跳转登录 // vm.$u.toast('您还没有登录哦,请先去登录!'); if (res.data.data.action != "memberinfo") { + uni.showToast({ + title: "您还没有登录,请先去登录哦!", + icon: "none" + }) setTimeout(() => { // 此为uView的方法,详见路由相关文档 uni.navigateTo({ diff --git a/pageA/bindinges/bindinges.vue b/pageA/bindinges/bindinges.vue index 70d9d25..549e2c5 100644 --- a/pageA/bindinges/bindinges.vue +++ b/pageA/bindinges/bindinges.vue @@ -3,32 +3,28 @@ - 手机登录 + 请绑定手机号 - 手机号 - + - - 请输入验证码 - - 获取验证码 + + + - + + + 我已详细阅读并同意 - 《用户协议》 - 《隐私协议》 - 《使用协议》 - - - + + {{ item }} + - {{login}} - + + @@ -36,81 +32,151 @@ export default { data() { return { - list: [{ - checked: false, - disabled: false - }], - value: '', - login: '注册', - show: true + phone: "", + sms_code: "", + login: '绑定', + show: true, + checked: false, + // 时间 + timer: null, + is_sendcode: false, // 60s + time_count: 60, + pactList: [ "《用户协议》", "《隐私协议》", "《使用协议》" ], }; }, methods: { - // 选中某个复选框时,由checkbox时触发 - checkboxChange(e) { - //console.log(e); - }, - // 选中任一checkbox时,由checkbox-group触发 - checkboxGroupChange(e) { - // console.log(e); - }, - mask_u(){ - this.show = !this.show - }, + // 勾选协议 + change(e) { + this.checked = !this.checked; + console.log(this.checked); + }, + // 获取验证码 + getCode() { + if (this.$u.test.isEmpty(this.phone)) { + this.$refs.uToast.show({ + title: '手机号格式不能为空!', + type: 'error', + }) + return; + } + if(!(/^1[3456789]\d{9}$/.test(this.phone))){ + this.$refs.uToast.show({ + title: '手机号格式不正确!', + type: 'warning', + }) + return; + } + this.$u.api.sendSmsCode({ + member_mobile: this.phone, + smslog_type: 4, + }).then(res => { + if (res.errCode == 0) { + console.log(res); + this.$refs.uToast.show({ + title: res.message, + type: 'success', + }) + // 发送验证码 + this.getSendCode(); + } else { + this.$refs.uToast.show({ + title: res.message, + type: 'warning', + }) + } + }) + }, + // 绑定手机号 + bindPhone() { + if (this.$u.test.isEmpty(this.phone)) { + this.$refs.uToast.show({ + title: '手机号不能为空!', + type: 'error', + }) + return; + } + if(!(/^1[3456789]\d{9}$/.test(this.phone))){ + this.$refs.uToast.show({ + title: '手机号格式不正确!', + type: 'warning', + }) + return; + } + if(this.$u.test.isEmpty(this.sms_code)){ + this.$refs.uToast.show({ + title: '验证码不能为空!', + type: 'warning', + }) + return; + } + if(this.sms_code.length == 0){ + this.$refs.uToast.show({ + title: '验证码有误!', + type: 'warning', + }) + return; + } + if(!this.checked){ + this.$refs.uToast.show({ + title: '请同意协议!', + type: 'warning', + }) + return; + } + this.$u.api.mobileBind({ + member_mobile: this.phone, + sms_code: this.sms_code, + }).then(res => { + console.log(res); + if (res.errCode == 0) { + this.$refs.uToast.show({ + title: res.message, + type: 'success', + }) + uni.switchTab({ + url: '/pages/index/index' + }); + } else { + this.$refs.uToast.show({ + title: res.message, + type: 'warning', + }) + } + }) + }, + // 协议详情 + infoPact(index) { + // console.log(index); + uni.navigateTo({ + url: '/pageA/pactList/pactList?index=' + index + }); + }, + // 60s + getSendCode() { + const TIME_COUNT = 60; + if (!this.timer) { + this.time_count = TIME_COUNT; + this.is_sendcode = true; + this.timer = setInterval(() => { + if (this.time_count > 0 && this.time_count <= TIME_COUNT) { + this.time_count--; + } else { + this.is_sendcode = false; + clearInterval(this.timer); + this.timer = null; + } + }, 1000); + } + }, } }; diff --git a/pageA/login/login.vue b/pageA/login/login.vue index 97f75df..834699b 100644 --- a/pageA/login/login.vue +++ b/pageA/login/login.vue @@ -226,14 +226,20 @@ member_nickname: data.userInfo.nickName, member_avatar: data.userInfo.avatarUrl, }).then(res => { - console.log(res.errCode); if (res.errCode == 0) { this.loginIn(res.data.token); - uni.setStorageSync('user_info',res.data); + uni.setStorageSync('user_info',res.data); this.show = false; - uni.switchTab({ - url: "../../pages/index/index" - }) + console.log(res.data.member.member_mobilebind); + if(res.data.member.member_mobilebind) { + uni.switchTab({ + url: "/pages/index/index" + }); + } else { + uni.navigateTo({ + url: '/pageA/bindinges/bindinges' + }); + } } }) } @@ -247,11 +253,11 @@ uni.login({ provider: 'weixin', success: (wxres) => { - console.log(wxres); + // console.log(wxres); uni.getUserInfo({ provider: 'weixin', success: (data) => { - console.log(data); + // console.log(data); this.$u.api.wechatLogin({ member_wxopenid: data.userInfo.openId, member_nickname: data.userInfo.nickName, @@ -260,11 +266,18 @@ console.log(res); if (res.errCode == 0) { this.loginIn(res.data.token); - uni.setStorageSync('user_info',res.data); + uni.setStorageSync('user_info',res.data); this.show = false; - uni.switchTab({ - url: "../../pages/index/index" - }) + console.log(res.data.member.member_mobilebind); + if(res.data.member.member_mobilebind) { + uni.switchTab({ + url: "/pages/index/index" + }); + } else { + uni.navigateTo({ + url: '/pageA/bindinges/bindinges' + }); + } } }) } @@ -301,11 +314,11 @@ tochange() { }, - goIndex() { - uni.switchTab({ - url: "/pages/index/index" - }) - } + goIndex() { + uni.switchTab({ + url: "/pages/index/index" + }) + } }, components: { identifying diff --git a/pageA/pactList/pactList.vue b/pageA/pactList/pactList.vue index a2c407e..53f53a3 100644 --- a/pageA/pactList/pactList.vue +++ b/pageA/pactList/pactList.vue @@ -29,9 +29,9 @@ export default { document_code: 'agreement' }).then((res)=>{ // console.log(res.data.document_title); - uni.setNavigationBarTitle({ - title: res.data.document_title - }) + uni.setNavigationBarTitle({ + title: res.data.document_title + }) let data = common.unescapeHTML(res.data.document_content); this.document_content = data; }) @@ -41,9 +41,9 @@ export default { document_code: 'privacy' }).then((res)=>{ // console.log(res.data.document_title); - uni.setNavigationBarTitle({ - title: res.data.document_title - }) + uni.setNavigationBarTitle({ + title: res.data.document_title + }) let data = common.unescapeHTML(res.data.document_content); this.document_content = data }) @@ -53,9 +53,9 @@ export default { document_code: 'use' }).then((res)=>{ // console.log(res.data.document_title); - uni.setNavigationBarTitle({ - title: res.data.document_title - }) + uni.setNavigationBarTitle({ + title: res.data.document_title + }) let data = common.unescapeHTML(res.data.document_content); this.document_content = data }) @@ -69,7 +69,6 @@ export default {