|
|
@@ -16,6 +16,7 @@ export default {
|
|
|
user_phone:'',
|
|
|
user_headUrl:'',
|
|
|
globalAuth:false,
|
|
|
+ isAuth : false,
|
|
|
session_key: '',
|
|
|
contact_name:'',
|
|
|
company_name:'',
|
|
|
@@ -102,9 +103,8 @@ export default {
|
|
|
return str;
|
|
|
},
|
|
|
loginRequest(codeRes){
|
|
|
- let md5Sign = md5("method="+'user'+"×tamp="+getApp().globalData.globalTimestamp+"&secret="+getApp().globalData.secret)
|
|
|
- let url = getApp().globalData.shareUrl+'api/api.php'+'?method=user&source=user&action=login×tamp='+getApp().globalData.globalTimestamp +'&sign='+md5Sign
|
|
|
- uni.request({
|
|
|
+ let url = getApp().makeApiUrl("user",'user','login');
|
|
|
+ uni.request({
|
|
|
url:url,
|
|
|
method: 'POST',
|
|
|
header: {
|
|
|
@@ -121,6 +121,13 @@ export default {
|
|
|
getApp().globalData.user_status = res.data.data.status;
|
|
|
getApp().globalData.user_phone = res.data.data.phone;
|
|
|
getApp().globalData.nowTime = this.getNowTime();
|
|
|
+ if (res.data.data.phone === ''){
|
|
|
+ //必须有手机号才算登录成功,系统才可用。
|
|
|
+ getApp().globalData.isAuth = false;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ getApp().globalData.isAuth = true;
|
|
|
+ }
|
|
|
uni.setStorageSync('openId', res.data.data.openid);
|
|
|
// uni.hideLoading()
|
|
|
}
|
|
|
@@ -130,7 +137,43 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
+ getPhoneNumber(e){
|
|
|
+ if (e.detail.errMsg == 'getPhoneNumber:ok') { //允许授权执行跳转
|
|
|
+ console.log(e.detail);
|
|
|
+ getApp().phoneRequest(e.detail.iv, e.detail.encryptedData, getApp().globalData.session_key);
|
|
|
+ return true;
|
|
|
+ } else { //
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ phoneRequest(myIv,myEncryptedData,sKey){
|
|
|
+ let url = getApp().makeApiUrl('user','user','phone');
|
|
|
+ uni.request({
|
|
|
+ url:url,
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ iv:myIv,
|
|
|
+ sessionKey:sKey,
|
|
|
+ encryptedData:myEncryptedData,
|
|
|
+ openId:getApp().globalData.open_id
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log(res)
|
|
|
+ if(res.data.code === 200){
|
|
|
+ getApp().globalData.user_phone = res.data.data;
|
|
|
+ if (res.data.data != ""){
|
|
|
+ getApp().globalData.isAuth = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ console.log("连接失败");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
}
|
|
|
};
|
|
|
</script>
|