|
@@ -25,7 +25,7 @@
|
|
</view>
|
|
</view>
|
|
<view class="login-form clearfix">
|
|
<view class="login-form clearfix">
|
|
<view class="login-input code">
|
|
<view class="login-input code">
|
|
- <input type="number"
|
|
|
|
|
|
+ <input type="text"
|
|
v-model="imageCode"
|
|
v-model="imageCode"
|
|
maxlength="6"
|
|
maxlength="6"
|
|
class="input"
|
|
class="input"
|
|
@@ -51,27 +51,17 @@
|
|
placeholder="请输入短信验证码"
|
|
placeholder="请输入短信验证码"
|
|
/>
|
|
/>
|
|
</view>
|
|
</view>
|
|
- <view class="login-input btn" :class="[isMobileDisabled ? 'disabled' : '']" @click.stop="getMobileCodeFn">
|
|
|
|
|
|
+ <view class="login-input btn" :class="[isMobileDisabled ? 'disabled' : '']" >
|
|
<button type="button"
|
|
<button type="button"
|
|
|
|
+ @click.stop="getMobileCodeFn"
|
|
:disabled="isMobileDisabled"
|
|
:disabled="isMobileDisabled"
|
|
- class="input"
|
|
|
|
- >{{ mobileCodeText }}</button>
|
|
|
|
|
|
+ class="input">
|
|
|
|
+ {{ mobileCodeText }}
|
|
|
|
+ </button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="login-form clearfix">
|
|
<view class="login-form clearfix">
|
|
- <view class="login-btn" @click="bindWechatInfo">绑定</view>
|
|
|
|
- </view>
|
|
|
|
- <!-- 授权按钮 -->
|
|
|
|
- <view class="model-warp" :class="[isUserInfo ? 'show':'none']">
|
|
|
|
- <view class="model-alert">
|
|
|
|
- <view class="alert-content">
|
|
|
|
- <view class="t-p">采美采购商城需要获取您的微信授权才能正常提供服务</view>
|
|
|
|
- </view>
|
|
|
|
- <view class="alert-btn">
|
|
|
|
- <view class="btn btn-cancel" @click="hideModel">取消</view>
|
|
|
|
- <button type="primary" size="small" open-type="getUserInfo" lang="zh_CN" @getuserinfo="getuserinfo" class="btn btn-confirm">授权</button>
|
|
|
|
- </view>
|
|
|
|
- </view>
|
|
|
|
|
|
+ <view class="login-btn" @click="bindWechatInfo">绑定并登录</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
@@ -93,7 +83,6 @@
|
|
imageCodeUrl:'', //图形验证码地址
|
|
imageCodeUrl:'', //图形验证码地址
|
|
imageCodetoken:'', //图形校验token
|
|
imageCodetoken:'', //图形校验token
|
|
isMobileDisabled:false, //获取手机短信按钮
|
|
isMobileDisabled:false, //获取手机短信按钮
|
|
- isUserInfo:false, //控制显示授权弹窗
|
|
|
|
count: '', //倒计时
|
|
count: '', //倒计时
|
|
mobileCodeText: '获取验证码',
|
|
mobileCodeText: '获取验证码',
|
|
codeTime: null,
|
|
codeTime: null,
|
|
@@ -141,16 +130,7 @@
|
|
this.$util.msg('验证码格式不正确',2000)
|
|
this.$util.msg('验证码格式不正确',2000)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- //查看此微信用户是否已经授权过
|
|
|
|
- authorize.getSetting().then(res =>{
|
|
|
|
- // console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
|
|
|
|
- if(res == 2){
|
|
|
|
- this.isUserInfo = true
|
|
|
|
- }else{
|
|
|
|
- this.isUserInfo = false
|
|
|
|
- this.wxGetUserInfo()
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ this.bindingWechatLogin()
|
|
},
|
|
},
|
|
getVerificationCode(){//图形验证
|
|
getVerificationCode(){//图形验证
|
|
getImageCode().then(res => {
|
|
getImageCode().then(res => {
|
|
@@ -159,6 +139,18 @@
|
|
})
|
|
})
|
|
},
|
|
},
|
|
getMobileCodeFn(){//获取手机验证码
|
|
getMobileCodeFn(){//获取手机验证码
|
|
|
|
+ if( this.bindLinkPhone == ''){
|
|
|
|
+ this.$util.msg('请输入手机号',2000);
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if(!this.$reg.isMobile(this.bindLinkPhone)){
|
|
|
|
+ this.$util.msg('请输入正确的手机号',2000);
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if( this.imageCode == ''){
|
|
|
|
+ this.$util.msg('请输入图形验证码',2000);
|
|
|
|
+ return
|
|
|
|
+ }
|
|
let params = {
|
|
let params = {
|
|
mobile:this.bindLinkPhone,
|
|
mobile:this.bindLinkPhone,
|
|
mobileOrEmail:this.bindMobile,
|
|
mobileOrEmail:this.bindMobile,
|
|
@@ -166,6 +158,7 @@
|
|
imgCode:this.imageCode,
|
|
imgCode:this.imageCode,
|
|
token:this.imageCodetoken,
|
|
token:this.imageCodetoken,
|
|
}
|
|
}
|
|
|
|
+ this.isMobileDisabled = true;
|
|
getbindWechatCode(params).then(res =>{
|
|
getbindWechatCode(params).then(res =>{
|
|
const TIME_COUNT = 60;
|
|
const TIME_COUNT = 60;
|
|
this.$util.msg('验证短信已发送',2000)
|
|
this.$util.msg('验证短信已发送',2000)
|
|
@@ -186,57 +179,32 @@
|
|
}
|
|
}
|
|
}).catch( res =>{
|
|
}).catch( res =>{
|
|
this.$util.msg(res.msg,2000)
|
|
this.$util.msg(res.msg,2000)
|
|
|
|
+ this.isMobileDisabled = false;
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- getuserinfo: function (e) {//微信授权登录
|
|
|
|
- if (e.detail.userInfo) {
|
|
|
|
- this.wxGetUserInfo()
|
|
|
|
- }else{
|
|
|
|
- //用户按了拒绝按钮
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '获取用户信息失败,请允许授权后才能继续使用小程序哦~',
|
|
|
|
- showCancel: false,
|
|
|
|
- confirmText: '授权',
|
|
|
|
- success: function (res) {
|
|
|
|
- if (res.confirm) {
|
|
|
|
- uni.openSetting({
|
|
|
|
- success: res => {
|
|
|
|
- // console.log(res.authSetting)
|
|
|
|
- },
|
|
|
|
- fail: res => {
|
|
|
|
- // console.log(res)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- wxGetUserInfo(){
|
|
|
|
- authorize.getCode('weixin').then(wechatcode =>{
|
|
|
|
- wx.getUserInfo({
|
|
|
|
- success: res => {
|
|
|
|
- console.log('useInfo:',res.userInfo)
|
|
|
|
- this.isUserInfo = false;
|
|
|
|
- this.userInfo = res.userInfo;
|
|
|
|
- let params ={
|
|
|
|
- userID:this.userID,
|
|
|
|
- mobile:this.bindLinkPhone,
|
|
|
|
- linkName:this.bindLinkName,
|
|
|
|
- verificationCode:this.mobildeCode,
|
|
|
|
- nickName:res.userInfo.nickName,
|
|
|
|
- headimgurl:res.userInfo.avatarUrl,
|
|
|
|
- }
|
|
|
|
- bindingWechat(params).then(response =>{
|
|
|
|
- // this.login(response.data);
|
|
|
|
- uni.switchTab({
|
|
|
|
- url:'/pages/tabBar/user/user'
|
|
|
|
- })
|
|
|
|
- }).catch(response =>{
|
|
|
|
- this.$util.msg(response.msg,2000)
|
|
|
|
- })
|
|
|
|
|
|
+ bindingWechatLogin(){//获取用户基本信息登录
|
|
|
|
+ wx.getUserInfo({
|
|
|
|
+ success: res => {
|
|
|
|
+ console.log('useInfo:',res.userInfo)
|
|
|
|
+ this.isUserInfo = false;
|
|
|
|
+ this.userInfo = res.userInfo;
|
|
|
|
+ let params ={
|
|
|
|
+ userID:this.userID,
|
|
|
|
+ mobile:this.bindLinkPhone,
|
|
|
|
+ linkName:this.bindLinkName,
|
|
|
|
+ verificationCode:this.mobildeCode,
|
|
|
|
+ nickName:res.userInfo.nickName,
|
|
|
|
+ headimgurl:res.userInfo.avatarUrl,
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ bindingWechat(params).then(response =>{
|
|
|
|
+ // this.login(response.data);
|
|
|
|
+ uni.switchTab({
|
|
|
|
+ url:'/pages/tabBar/user/user'
|
|
|
|
+ })
|
|
|
|
+ }).catch(response =>{
|
|
|
|
+ this.$util.msg(response.msg,2000)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
})
|
|
})
|
|
},
|
|
},
|
|
goUserLogininit(){
|
|
goUserLogininit(){
|
|
@@ -318,12 +286,20 @@
|
|
margin-right: 20rpx;
|
|
margin-right: 20rpx;
|
|
}
|
|
}
|
|
&.btn{
|
|
&.btn{
|
|
- width: 210rpx;
|
|
|
|
|
|
+ width: 258rpx;
|
|
|
|
+ height: 88rpx;
|
|
|
|
+ padding: 0;
|
|
float: left;
|
|
float: left;
|
|
background: $btn-confirm;
|
|
background: $btn-confirm;
|
|
.input{
|
|
.input{
|
|
|
|
+ width: 258rpx;
|
|
|
|
+ height: 88rpx;
|
|
|
|
+ line-height: 88rpx;
|
|
|
|
+ padding: 0;
|
|
|
|
+ border-radius: 14rpx;
|
|
color: #FFFFFF;
|
|
color: #FFFFFF;
|
|
background: $btn-confirm;
|
|
background: $btn-confirm;
|
|
|
|
+
|
|
}
|
|
}
|
|
&.disabled{
|
|
&.disabled{
|
|
background: #F7F7F7;
|
|
background: #F7F7F7;
|