新增微信授权登录
This commit is contained in:
parent
6db2890d6e
commit
b54845aba6
@ -2,8 +2,8 @@
|
|||||||
"name" : "惠农生活",
|
"name" : "惠农生活",
|
||||||
"appid" : "__UNI__3A527D1",
|
"appid" : "__UNI__3A527D1",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "1.9.7",
|
"versionName" : "1.9.8",
|
||||||
"versionCode" : 197,
|
"versionCode" : 198,
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
/* 5+App特有相关 */
|
/* 5+App特有相关 */
|
||||||
"app-plus" : {
|
"app-plus" : {
|
||||||
|
@ -13,14 +13,16 @@
|
|||||||
<u-icon name="weixin-fill" color="#fff" size="30"></u-icon> 微信一键登录
|
<u-icon name="weixin-fill" color="#fff" size="30"></u-icon> 微信一键登录
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<checkbox-group class="checkgroup" @change='isAgree=!isAgree'>
|
<div class="protocol acea-row row-between-wrapper">
|
||||||
<checkbox class="checkbox" :checked="isAgree ? true : false" />
|
<checkbox-group class="checkgroup" @change='isAgree=!isAgree'>
|
||||||
<text class="protocol_text">我已同意<text @click="userAgree"
|
<checkbox class="checkbox" :checked="isAgree ? true : false" />
|
||||||
class="font_pro">《用户协议》</text>与<text @click="userPrivacyAgree"
|
<text class="protocol_text">我已同意<text @click="userAgree"
|
||||||
class="font_pro">《隐私政策》</text></text>
|
class="font_pro">《用户协议》</text>与<text @click="userPrivacyAgree"
|
||||||
</checkbox-group>
|
class="font_pro">《隐私政策》</text></text>
|
||||||
|
</checkbox-group>
|
||||||
|
</div>
|
||||||
</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="title acea-row row-center-wrapper">
|
||||||
<div class="item" :class="current === index ? 'on' : ''" v-for="(item, index) in navList"
|
<div class="item" :class="current === index ? 'on' : ''" v-for="(item, index) in navList"
|
||||||
@click="navTap(index)" :key="index">
|
@click="navTap(index)" :key="index">
|
||||||
@ -96,7 +98,6 @@
|
|||||||
class="font_pro">《隐私政策》</text></text>
|
class="font_pro">《隐私政策》</text></text>
|
||||||
</checkbox-group>
|
</checkbox-group>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="whiteBg" v-else>
|
<div class="whiteBg" v-else>
|
||||||
<div class="title">注册账号</div>
|
<div class="title">注册账号</div>
|
||||||
@ -166,9 +167,20 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</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>
|
</div>
|
||||||
<form report-submit='true' v-if="auth_token">
|
<form report-submit='true' v-if="auth_token">
|
||||||
<view class="ChangePassword">
|
<view class="ChangePassword">
|
||||||
|
<view class="title">
|
||||||
|
<view>首次登录</view>
|
||||||
|
<view style="font-size: 36rpx;">需要绑定手机号码</view>
|
||||||
|
</view>
|
||||||
<view class="list">
|
<view class="list">
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<input type='number' placeholder='填写手机号码' placeholder-class='placeholder'
|
<input type='number' placeholder='填写手机号码' placeholder-class='placeholder'
|
||||||
@ -287,7 +299,12 @@ import { Toast } from "../../../libs/uniApi";
|
|||||||
account: "",
|
account: "",
|
||||||
password: "",
|
password: "",
|
||||||
captcha: "",
|
captcha: "",
|
||||||
formItem: 1,
|
// #ifdef APP-PLUS
|
||||||
|
formItem: 0,
|
||||||
|
// #endif
|
||||||
|
// #ifndef APP-PLUS
|
||||||
|
formItem: 1,
|
||||||
|
// #endif
|
||||||
type: "login",
|
type: "login",
|
||||||
keyCode: "",
|
keyCode: "",
|
||||||
codeUrl: "",
|
codeUrl: "",
|
||||||
@ -318,10 +335,14 @@ import { Toast } from "../../../libs/uniApi";
|
|||||||
} else {
|
} else {
|
||||||
this.type = 'register'
|
this.type = 'register'
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
isAgree: function(n, o){
|
||||||
|
uni.setStorageSync('isAgree', n);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
let self = this
|
let self = this
|
||||||
|
this.isAgree = uni.getStorageSync('isAgree')
|
||||||
uni.getSystemInfo({
|
uni.getSystemInfo({
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
if (res.platform.toLowerCase() == 'ios' && self.getSystem(res.system) >= 13) {
|
if (res.platform.toLowerCase() == 'ios' && self.getSystem(res.system) >= 13) {
|
||||||
@ -538,8 +559,9 @@ import { Toast } from "../../../libs/uniApi";
|
|||||||
onlyAuthorize: true,
|
onlyAuthorize: true,
|
||||||
success: function(loginRes) {
|
success: function(loginRes) {
|
||||||
console.log(loginRes);
|
console.log(loginRes);
|
||||||
|
uni.hideLoading()
|
||||||
self.appUserInfo = loginRes;
|
self.appUserInfo = loginRes;
|
||||||
self.wxLoginApi()
|
self.weixinLoginApi()
|
||||||
},
|
},
|
||||||
fail(error) {
|
fail(error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
@ -563,11 +585,6 @@ import { Toast } from "../../../libs/uniApi";
|
|||||||
commonAuth({
|
commonAuth({
|
||||||
auth: {
|
auth: {
|
||||||
type: 'app_wechat',
|
type: 'app_wechat',
|
||||||
// auth: {
|
|
||||||
// code: that.appUserInfo.authResult.access_token,
|
|
||||||
// openid: that.appUserInfo.authResult.openid,
|
|
||||||
// phone: this.account,
|
|
||||||
// }
|
|
||||||
auth: {
|
auth: {
|
||||||
code: that.appUserInfo.authResult.access_token,
|
code: that.appUserInfo.authResult.access_token,
|
||||||
openid: that.appUserInfo.authResult.openid,
|
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() {
|
getAgreement() {
|
||||||
let that = this
|
let that = this
|
||||||
getAgreementApi('sys_user_agree').then(res => {
|
getAgreementApi('sys_user_agree').then(res => {
|
||||||
@ -773,7 +846,10 @@ import { Toast } from "../../../libs/uniApi";
|
|||||||
method = 'navigateTo'
|
method = 'navigateTo'
|
||||||
}
|
}
|
||||||
uni[method]({
|
uni[method]({
|
||||||
url: backUrl
|
url: backUrl,
|
||||||
|
success:()=>{
|
||||||
|
this.auth_token = ''
|
||||||
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(res => {
|
.catch(res => {
|
||||||
@ -980,6 +1056,15 @@ import { Toast } from "../../../libs/uniApi";
|
|||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ChangePassword{
|
||||||
|
.title{
|
||||||
|
width: 580rpx;
|
||||||
|
margin: 180rpx auto 0 auto;
|
||||||
|
font-size: 46rpx;
|
||||||
|
color: #7f7f7f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.ChangePassword .phone {
|
.ChangePassword .phone {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@ -1280,6 +1365,7 @@ import { Toast } from "../../../libs/uniApi";
|
|||||||
|
|
||||||
.whiteBg {
|
.whiteBg {
|
||||||
margin-top: 100rpx;
|
margin-top: 100rpx;
|
||||||
|
transition: 300ms;
|
||||||
|
|
||||||
.list {
|
.list {
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user