新增微信授权登录
This commit is contained in:
parent
6db2890d6e
commit
b54845aba6
@ -2,8 +2,8 @@
|
||||
"name" : "惠农生活",
|
||||
"appid" : "__UNI__3A527D1",
|
||||
"description" : "",
|
||||
"versionName" : "1.9.7",
|
||||
"versionCode" : 197,
|
||||
"versionName" : "1.9.8",
|
||||
"versionCode" : 198,
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
"app-plus" : {
|
||||
|
@ -13,14 +13,16 @@
|
||||
<u-icon name="weixin-fill" color="#fff" size="30"></u-icon> 微信一键登录
|
||||
</div>
|
||||
|
||||
<checkbox-group class="checkgroup" @change='isAgree=!isAgree'>
|
||||
<checkbox class="checkbox" :checked="isAgree ? true : false" />
|
||||
<text class="protocol_text">我已同意<text @click="userAgree"
|
||||
class="font_pro">《用户协议》</text>与<text @click="userPrivacyAgree"
|
||||
class="font_pro">《隐私政策》</text></text>
|
||||
</checkbox-group>
|
||||
<div class="protocol acea-row row-between-wrapper">
|
||||
<checkbox-group class="checkgroup" @change='isAgree=!isAgree'>
|
||||
<checkbox class="checkbox" :checked="isAgree ? true : false" />
|
||||
<text class="protocol_text">我已同意<text @click="userAgree"
|
||||
class="font_pro">《用户协议》</text>与<text @click="userPrivacyAgree"
|
||||
class="font_pro">《隐私政策》</text></text>
|
||||
</checkbox-group>
|
||||
</div>
|
||||
</div>
|
||||
<div class="whiteBg" v-else-if="formItem === 1">
|
||||
<div class="whiteBg" v-else-if="formItem === 1" style="po">
|
||||
<div class="title acea-row row-center-wrapper">
|
||||
<div class="item" :class="current === index ? 'on' : ''" v-for="(item, index) in navList"
|
||||
@click="navTap(index)" :key="index">
|
||||
@ -96,7 +98,6 @@
|
||||
class="font_pro">《隐私政策》</text></text>
|
||||
</checkbox-group>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="whiteBg" v-else>
|
||||
<div class="title">注册账号</div>
|
||||
@ -166,9 +167,20 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- #ifdef APP-PLUS -->
|
||||
<div class="protocol acea-row row-between-wrapper" style="position: fixed; bottom: 160rpx;left: 50%;transform: translate(-50%);">
|
||||
<text class="protocol_text" v-if="formItem==0" @click="formItem = 1 ">其他方式登录</text>
|
||||
<text class="protocol_text" v-else @click="formItem = 0 ">微信快捷登录</text>
|
||||
</div>
|
||||
<!-- #endif -->
|
||||
</div>
|
||||
<form report-submit='true' v-if="auth_token">
|
||||
<view class="ChangePassword">
|
||||
<view class="title">
|
||||
<view>首次登录</view>
|
||||
<view style="font-size: 36rpx;">需要绑定手机号码</view>
|
||||
</view>
|
||||
<view class="list">
|
||||
<view class="item">
|
||||
<input type='number' placeholder='填写手机号码' placeholder-class='placeholder'
|
||||
@ -287,7 +299,12 @@ import { Toast } from "../../../libs/uniApi";
|
||||
account: "",
|
||||
password: "",
|
||||
captcha: "",
|
||||
formItem: 1,
|
||||
// #ifdef APP-PLUS
|
||||
formItem: 0,
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
formItem: 1,
|
||||
// #endif
|
||||
type: "login",
|
||||
keyCode: "",
|
||||
codeUrl: "",
|
||||
@ -318,10 +335,14 @@ import { Toast } from "../../../libs/uniApi";
|
||||
} else {
|
||||
this.type = 'register'
|
||||
}
|
||||
}
|
||||
},
|
||||
isAgree: function(n, o){
|
||||
uni.setStorageSync('isAgree', n);
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
let self = this
|
||||
this.isAgree = uni.getStorageSync('isAgree')
|
||||
uni.getSystemInfo({
|
||||
success: function(res) {
|
||||
if (res.platform.toLowerCase() == 'ios' && self.getSystem(res.system) >= 13) {
|
||||
@ -332,7 +353,7 @@ import { Toast } from "../../../libs/uniApi";
|
||||
this.getVersion();
|
||||
},
|
||||
mounted: function() {
|
||||
|
||||
|
||||
},
|
||||
onReady() {
|
||||
let that = this
|
||||
@ -538,8 +559,9 @@ import { Toast } from "../../../libs/uniApi";
|
||||
onlyAuthorize: true,
|
||||
success: function(loginRes) {
|
||||
console.log(loginRes);
|
||||
uni.hideLoading()
|
||||
self.appUserInfo = loginRes;
|
||||
self.wxLoginApi()
|
||||
self.weixinLoginApi()
|
||||
},
|
||||
fail(error) {
|
||||
console.log(error);
|
||||
@ -563,11 +585,6 @@ import { Toast } from "../../../libs/uniApi";
|
||||
commonAuth({
|
||||
auth: {
|
||||
type: 'app_wechat',
|
||||
// auth: {
|
||||
// code: that.appUserInfo.authResult.access_token,
|
||||
// openid: that.appUserInfo.authResult.openid,
|
||||
// phone: this.account,
|
||||
// }
|
||||
auth: {
|
||||
code: that.appUserInfo.authResult.access_token,
|
||||
openid: that.appUserInfo.authResult.openid,
|
||||
@ -620,6 +637,62 @@ import { Toast } from "../../../libs/uniApi";
|
||||
});
|
||||
});
|
||||
},
|
||||
weixinLoginApi() {
|
||||
const that = this
|
||||
commonAuth({
|
||||
auth: {
|
||||
type: 'app_wechat',
|
||||
auth: {
|
||||
code: that.appUserInfo.code
|
||||
}
|
||||
}
|
||||
}).then(res => {
|
||||
console.log('--', res);
|
||||
const data = res.data;
|
||||
if (res.data.status == 200) {
|
||||
const backUrl = that.$Cache.get('login_back_url_weixin') || that.$Cache.get(BACK_URL) || "/pages/index/index";
|
||||
that.$Cache.clear(BACK_URL);
|
||||
that.$Cache.clear('login_back_url_weixin');
|
||||
that.$store.commit("LOGIN", {
|
||||
'token': data.result.token,
|
||||
'time': data.result.exp
|
||||
});
|
||||
that.$store.commit("SETUID", data.result.user.uid);
|
||||
that.$store.commit('UPDATE_USERINFO', data.result.user);
|
||||
let method
|
||||
let indexPat = ['/pages/index/index', '/pages/order_addcart/order_addcart',
|
||||
'/pages/goods_cate/goods_cate',
|
||||
'/pages/user/index', '/pages/plant_grass/index'
|
||||
]
|
||||
if (indexPat.includes(this.getPath(backUrl))) {
|
||||
method = 'switchTab'
|
||||
} else {
|
||||
method = 'navigateTo'
|
||||
}
|
||||
if (this.getPath(backUrl) === '/pages/users/login/index') {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
return
|
||||
}
|
||||
uni[method]({
|
||||
url: backUrl
|
||||
});
|
||||
} else {
|
||||
that.auth_token = res.data.result.key;
|
||||
that.bindStatus = true;
|
||||
}
|
||||
uni.hideLoading();
|
||||
}).catch(res => {
|
||||
console.log( '错误', res);
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: res.message || res,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
},
|
||||
getAgreement() {
|
||||
let that = this
|
||||
getAgreementApi('sys_user_agree').then(res => {
|
||||
@ -773,7 +846,10 @@ import { Toast } from "../../../libs/uniApi";
|
||||
method = 'navigateTo'
|
||||
}
|
||||
uni[method]({
|
||||
url: backUrl
|
||||
url: backUrl,
|
||||
success:()=>{
|
||||
this.auth_token = ''
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(res => {
|
||||
@ -979,6 +1055,15 @@ import { Toast } from "../../../libs/uniApi";
|
||||
/deep/uni-checkbox .uni-checkbox-input {
|
||||
border-radius: 100%;
|
||||
}
|
||||
|
||||
.ChangePassword{
|
||||
.title{
|
||||
width: 580rpx;
|
||||
margin: 180rpx auto 0 auto;
|
||||
font-size: 46rpx;
|
||||
color: #7f7f7f;
|
||||
}
|
||||
}
|
||||
|
||||
.ChangePassword .phone {
|
||||
font-size: 32rpx;
|
||||
@ -1280,7 +1365,8 @@ import { Toast } from "../../../libs/uniApi";
|
||||
|
||||
.whiteBg {
|
||||
margin-top: 100rpx;
|
||||
|
||||
transition: 300ms;
|
||||
|
||||
.list {
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
|
Loading…
x
Reference in New Issue
Block a user