|
@@ -62,7 +62,7 @@
|
|
|
<view class="login-btn" @click="bindWechatInfo">绑定</view>
|
|
|
</view>
|
|
|
<!-- 授权按钮 -->
|
|
|
- <view class="model-warp" :class="[isUserInfo===false ? 'none':'show']">
|
|
|
+ <view class="model-warp" :class="[isUserInfo ? 'show':'none']">
|
|
|
<view class="model-alert">
|
|
|
<view class="alert-content">
|
|
|
<view class="t-p">采美采购商城需要获取您的微信授权才能正常提供服务</view>
|
|
@@ -81,7 +81,6 @@
|
|
|
import authorize from '@/common/config/authorize.js'
|
|
|
import { bindingWechat } from "@/api/use.js"
|
|
|
import { getImageCode, getbindWechatCode } from "@/api/utils.js"
|
|
|
- var self;
|
|
|
export default{
|
|
|
data() {
|
|
|
return{
|
|
@@ -94,7 +93,7 @@
|
|
|
imageCodeUrl:'', //图形验证码地址
|
|
|
imageCodetoken:'', //图形校验token
|
|
|
isMobileDisabled:false, //获取手机短信按钮
|
|
|
- isUserInfo:false, //控制显示授权弹窗
|
|
|
+ isUserInfo:false, //控制显示授权弹窗
|
|
|
count: '', //倒计时
|
|
|
mobileCodeText: '获取验证码',
|
|
|
codeTime: null,
|
|
@@ -123,23 +122,23 @@
|
|
|
...mapMutations(['login']),
|
|
|
bindWechatInfo(){
|
|
|
if( this.bindLinkName == ''){
|
|
|
- uni.showToast({title: '请输入姓名',duration: 2000,mask:true, icon:'none'})
|
|
|
+ this.$util.msg('请输入姓名',2000)
|
|
|
return
|
|
|
}
|
|
|
if( this.bindLinkPhone == ''){
|
|
|
- uni.showToast({title: '请输入手机号',duration: 2000,mask:true,icon:'none'})
|
|
|
+ this.$util.msg('请输入手机号',2000)
|
|
|
return
|
|
|
}
|
|
|
- if(this.$reg.isMobile(this.bindLinkPhone)){
|
|
|
- uni.showToast({title: '请输入正确的手机号',duration: 2000,mask:true,icon:'none'})
|
|
|
+ if(!this.$reg.isMobile(this.bindLinkPhone)){
|
|
|
+ this.$util.msg('请输入正确的手机号',2000)
|
|
|
return
|
|
|
}
|
|
|
if( this.mobildeCode == ''){
|
|
|
- uni.showToast({title: '请输入手机验证码',duration: 2000,mask:true,icon:'none'})
|
|
|
+ this.$util.msg('请输入手机验证码',2000)
|
|
|
return
|
|
|
}
|
|
|
- if(this.$reg.isMobileCode(this.mobildeCode)){
|
|
|
- uni.showToast({title: '验证码格式不正确',duration: 2000,mask:true,icon:'none'})
|
|
|
+ if(!this.$reg.isMobileCode(this.mobildeCode)){
|
|
|
+ this.$util.msg('验证码格式不正确',2000)
|
|
|
return
|
|
|
}
|
|
|
//查看此微信用户是否已经授权过
|
|
@@ -189,31 +188,9 @@
|
|
|
this.$util.msg(res.msg,2000)
|
|
|
})
|
|
|
},
|
|
|
- goUserLogininit(){
|
|
|
- let url;
|
|
|
- if(this.loginType) {
|
|
|
- if(this.loginType=='detilType'){
|
|
|
- this.$api.redirectTo(`/pages/goods/product?id=${this.id}&page=2`);
|
|
|
- }else if(this.loginType=='search'){
|
|
|
- this.$api.redirectTo('/pages/search/search');
|
|
|
- }else if(this.loginType == 1){
|
|
|
- url ='/pages/tabBar/cart/cart'
|
|
|
- }else if(this.loginType == 4){
|
|
|
- url ='/pages/tabBar/user/user'
|
|
|
- }else {
|
|
|
- url ='/pages/tabBar/home/home'
|
|
|
- }
|
|
|
- uni.switchTab({
|
|
|
- url
|
|
|
- })
|
|
|
- } else if(this.listType) {
|
|
|
- this.$api.navToListPage({type:this.listType,value:this.listVal,lType:'4'});
|
|
|
- }
|
|
|
- },
|
|
|
- //授权登录
|
|
|
- getuserinfo: function (e) {
|
|
|
+ getuserinfo: function (e) {//微信授权登录
|
|
|
if (e.detail.userInfo) {
|
|
|
- self.wxGetUserInfo()
|
|
|
+ this.wxGetUserInfo()
|
|
|
}else{
|
|
|
//用户按了拒绝按钮
|
|
|
uni.showModal({
|
|
@@ -236,10 +213,11 @@
|
|
|
}
|
|
|
},
|
|
|
wxGetUserInfo(){
|
|
|
+ let self = this
|
|
|
authorize.getCode('weixin').then(wechatcode =>{
|
|
|
wx.getUserInfo({
|
|
|
success: res => {
|
|
|
- // console.log('useInfo:',res.userInfo)
|
|
|
+ console.log('useInfo:',res.userInfo)
|
|
|
self.userInfo = res.userInfo;
|
|
|
let params ={
|
|
|
userID:this.userID,
|
|
@@ -247,9 +225,10 @@
|
|
|
linkName:this.bindLinkName,
|
|
|
verificationCode:this.mobildeCode,
|
|
|
nickName:res.userInfo.nickName,
|
|
|
- headimgurl:res.userInfo.headimgurl,
|
|
|
+ headimgurl:res.userInfo.avatarUrl,
|
|
|
}
|
|
|
bindingWechat(params).then(res =>{
|
|
|
+ this.isUserInfo = false;
|
|
|
this.goUserLogininit()
|
|
|
}).catch(res =>{
|
|
|
this.$util.msg(res.msg,2000)
|
|
@@ -257,6 +236,31 @@
|
|
|
}
|
|
|
});
|
|
|
})
|
|
|
+ },
|
|
|
+ goUserLogininit(){
|
|
|
+ let url;
|
|
|
+ if(this.loginType) {
|
|
|
+ if(this.loginType=='detilType'){
|
|
|
+ this.$api.redirectTo(`/pages/goods/product?id=${this.id}&page=2`);
|
|
|
+ }else if(this.loginType=='search'){
|
|
|
+ this.$api.redirectTo('/pages/search/search');
|
|
|
+ }else if(this.loginType == 1){
|
|
|
+ url ='/pages/tabBar/cart/cart'
|
|
|
+ }else if(this.loginType == 4){
|
|
|
+ url ='/pages/tabBar/user/user'
|
|
|
+ }else {
|
|
|
+ url ='/pages/tabBar/home/home'
|
|
|
+ }
|
|
|
+ uni.switchTab({
|
|
|
+ url
|
|
|
+ })
|
|
|
+ } else if(this.listType) {
|
|
|
+ this.$api.navToListPage({type:this.listType,value:this.listVal,lType:'4'});
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //关闭未授权用户授权提示弹窗
|
|
|
+ hideModel(){
|
|
|
+ this.isUserInfo = false;
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|