增加:强制绑定手机号功能

This commit is contained in:
wuhui_zzw 2024-05-31 10:19:09 +08:00
parent 0dbfd12c82
commit f393e8aba4
3 changed files with 48 additions and 22 deletions

14
App.vue
View File

@ -135,7 +135,7 @@
}) })
} }
},1500) },1500)
// #endif // #endif
}, },
methods: { methods: {
// //
@ -203,8 +203,16 @@
// #ifdef H5 // #ifdef H5
this.setOpenShare(res.data); this.setOpenShare(res.data);
// #endif // #endif
//
if(this.globalData.is_phone_login == 1 && checkLogin()) {
this.$util.isBindPhone();
}
}).catch(err => {}); }).catch(err => {});
} },
}, },
onHide: function() { onHide: function() {
//console.log('App Hide') //console.log('App Hide')
@ -219,7 +227,7 @@
}).then(() => {}); }).then(() => {});
} }
}, },
} },
} }
</script> </script>
<style lang="scss"> <style lang="scss">

View File

@ -41,10 +41,6 @@
<view class="text1">昵称</view> <view class="text1">昵称</view>
<input type="nickname" class="weui-input" :value="nickname" placeholder="请输入昵称" @change="changeNickname"/> <input type="nickname" class="weui-input" :value="nickname" placeholder="请输入昵称" @change="changeNickname"/>
</view> </view>
</view> </view>
</view> </view>
<!--#endif--> <!--#endif-->
@ -134,6 +130,8 @@
// //
avatar: '', avatar: '',
nickname: '', nickname: '',
is_trigger: true,
} }
}, },
computed: { computed: {
@ -142,7 +140,8 @@
}, },
watch: { watch: {
isLogin(n) { isLogin(n) {
n === true && this.$emit('onLoadFun', this.userInfo); // n === true && this.$emit('onLoadFun', this.userInfo);
n === true && this.runOnLoadFun(this.userInfo);
}, },
isShowAuth(n) { isShowAuth(n) {
this.getCode(this.isShowAuth) this.getCode(this.isShowAuth)
@ -179,7 +178,9 @@
self.$store.commit('SETUID', res.data.result.user.uid); self.$store.commit('SETUID', res.data.result.user.uid);
Cache.set(EXPIRES_TIME,res.data.result.expires_time,time); Cache.set(EXPIRES_TIME,res.data.result.expires_time,time);
Cache.set(USER_INFO,res.data.result.user,time); Cache.set(USER_INFO,res.data.result.user,time);
self.$emit('onLoadFun', res.data.result.user);
self.runOnLoadFun(res.data.result.user);
// self.$emit('onLoadFun', res.data.result.user);
if(res.data.result.user.isNew && self.mp_is_new && self.first_avatar_switch==1 && self.wechat_phone_switch == 1){ if(res.data.result.user.isNew && self.mp_is_new && self.first_avatar_switch==1 && self.wechat_phone_switch == 1){
self.editModal = true; self.editModal = true;
} }
@ -206,7 +207,8 @@
// #ifdef MP // #ifdef MP
editSuccess() { editSuccess() {
this.editModal = false this.editModal = false
this.$emit('onLoadFun', this.userInfo); // this.$emit('onLoadFun', this.userInfo);
this.runOnLoadFun(this.userInfo);
}, },
closeEdit() { closeEdit() {
this.editModal = false this.editModal = false
@ -215,8 +217,8 @@
setAuthStatus() { setAuthStatus() {
//#ifdef MP //#ifdef MP
Routine.authorize().then(res => { Routine.authorize().then(res => {
if (res.islogin === false) if (res.islogin === false) this.runOnLoadFun(this.userInfo);
this.$emit('onLoadFun', this.userInfo); // this.$emit('onLoadFun', this.userInfo);
}).catch(res => { }).catch(res => {
if (this.isAuto) if (this.isAuto)
this.$emit('authColse', true); this.$emit('authColse', true);
@ -288,8 +290,6 @@
// this.$emit('authColse', false); // this.$emit('authColse', false);
// } // }
}, },
// //
onChooseAvatar(e) { onChooseAvatar(e) {
const {avatarUrl} = e.detail const {avatarUrl} = e.detail
@ -301,6 +301,14 @@
}, },
changeNickname(e){ changeNickname(e){
this.nickname = e.detail.value || e.target.value; this.nickname = e.detail.value || e.target.value;
},
//
runOnLoadFun(userInfo){
if(this.isLogin && app.globalData.is_phone_login == 1 && this.is_trigger) {
this.is_trigger = false;
this.$util.isBindPhone();
}
this.$emit('onLoadFun', userInfo);
} }
} }

View File

@ -1,15 +1,13 @@
import { import {TOKENNAME, HTTP_REQUEST_URL} from '../config/app.js';
TOKENNAME,
HTTP_REQUEST_URL
} from '../config/app.js';
import store from '../store'; import store from '../store';
import { import { pathToBase64 } from '@/plugin/image-tools/index.js';
pathToBase64
} from '@/plugin/image-tools/index.js';
// #ifdef APP-PLUS // #ifdef APP-PLUS
import permision from "./permission.js" import permision from "./permission.js"
// #endif // #endif
import {getUserInfo} from '@/api/user.js';
export default { export default {
/** /**
* 字符串截取 * 字符串截取
@ -1055,8 +1053,20 @@ export default {
}; };
return typeList[is_sys] || '门店'; return typeList[is_sys] || '门店';
},
// 判断:用户是否需要绑定手机号
isBindPhone(){
let _this = this;
getUserInfo().then(res => {
let data = res.data || {};
let phone = data.phone || '';
if(phone.length <= 0){
uni.navigateTo({
url: '/pages/users/user_phone/index'
})
}
});
} }
} }