提交 7e4d083c 编写于 作者: DCloud_JSON's avatar DCloud_JSON

新增微信小程序登陆

上级 c292898a
......@@ -25,13 +25,10 @@ module.exports = {
"/uni_modules/uni-news-favorite/pages/uni-news-favorite/list",
"/pages/ucenter/userinfo/uploadCutImageToUnicloud"
],
"login": [ "smsCode","uniVerify", "username", "weixin", "apple"],
/*
"login": ["smsCode","uniVerify", "username", "weixin", "apple"],
/*
根据数组的第0项,决定登陆方式的第一优先级。
未列举到的,或设备环境不支持的选项,将被隐藏。
快捷登陆按钮,在任意一页面都存在。
所以只有三种情况:
一键登录(uniVerify)、账号(username)、验证码登陆(其他值为第一项都为验证码登陆)
如果你需要在不同平台有不同的配置,直接用条件编译即可
*/
},
......
......@@ -55,8 +55,6 @@ export default function() {
e.url += "univerify_first=true"
} else if (login[0] == 'username') {
e.url = "/pages/ucenter/login-page/pwd-login/pwd-login"
} else {
//默认即是
}
}
return true
......
......@@ -3,7 +3,7 @@
<text>登陆即表示同意</text>
<template v-for="(agreement,index) in agreements">
<text class="agreement" @click="navigateTo(agreement)">{{agreement.title}}</text>
<text class="hint" v-if="agreements.length-1>index"></text>
<text class="hint" v-if="hasAnd(agreements,index)"></text>
</template>
</view>
</template>
......@@ -13,7 +13,7 @@
name:"uni-agreements",
computed:{
agreements(){
return getApp().globalData.config.about.agreements
return getApp().globalData.config.about.agreements||[]
}
},
methods:{
......@@ -24,6 +24,9 @@
fail: () => {},
complete: () => {}
});
},
hasAnd(agreements,index){
return agreements.length-1>index
}
},
data() {
......
......@@ -5,6 +5,9 @@
<image class="logo" :src="item.logo" mode="widthFix"></image>
<text class="login-title">{{item.text}}</text>
</view>
<!-- #ifdef MP -->
<!-- #endif -->
</view>
</template>
<script>
......@@ -15,19 +18,27 @@
//前一个窗口的页面地址。控制点击切换快捷登陆方式是创建还是返回
import loginSuccess from '@/pages/ucenter/login-page/common/loginSuccess.js';
export default {
computed: {
loginConfig() {
return getApp().globalData.config.router.login
}
},
data() {
return {
servicesList: [{
"id": "username",
"text": "账号登陆",
"logo": "/static/uni-quick-login/user.png",
"path": "/pages/ucenter/login-page/pwd-login/pwd-login"
},
{
"id": "smsCode",
"text": "短信验证码",
"logo": "/static/uni-quick-login/sms.png",
"path": "/pages/ucenter/login-page/index/index"
}
]
],
oauthServices: []
}
},
props: {
......@@ -79,6 +90,8 @@
},
},
created() {
console.log('loginConfig', this.loginConfig);
console.log('this.getRoute(1)', this.getRoute(1));
let servicesList = this.servicesList
//去掉当前页面对应的登陆选项
for (var i = 0; i < servicesList.length; i++) {
......@@ -86,6 +99,14 @@
servicesList.splice(i, 1)
}
}
//去掉配置项中不存在的项
for (var i = 0; i < servicesList.length; i++) {
if (!this.loginConfig.includes(servicesList[i].id)) {
console.log(servicesList[i].id);
servicesList.splice(i, 1)
}
}
console.log('servicesList', servicesList);
},
mounted() {
//获取当前环境能用的快捷登陆方式
......@@ -113,6 +134,15 @@
console.error('获取服务供应商失败:' + JSON.stringify(err));
})
// #endif
// #ifdef MP-WEIXIN
let id = 'weixin'
if (this.loginConfig.includes(id)) {
this.servicesList.push({
...this.config[id],
id
})
}
// #endif
},
methods: {
...mapMutations({
......@@ -138,7 +168,6 @@
},
login_before(type, navigateBack = true) {
console.log(arguments);
console.log('services', services);
let oauthService = this.oauthServices.find((service) => service.id == type)
console.log(type);
......@@ -163,6 +192,9 @@
uni.login({
"provider": type,
"univerifyStyle": this.univerifyStyle,
complete: (e) => {
console.log(9527, e);
},
success: async e => {
console.log(e);
if (type == 'apple') {
......@@ -171,6 +203,13 @@
})
Object.assign(e.authResult, res.userInfo)
}
// #ifdef MP-WEIXIN
if (type == 'weixin') {
return this.login({
code: e.code
}, type)
}
// #endif
this.login(e.authResult, type)
},
fail: (err) => {
......@@ -210,7 +249,10 @@
})
},
login(params, type) { //联网验证登陆
console.log(params, type);
console.log({
params,
type
});
this.request('user-center/login_by_' + type, params, result => {
console.log(result);
if (result.code === 0) {
......@@ -251,9 +293,9 @@
.quick-login-box {
flex-direction: row;
width: 750rpx;
justify-content: space-around;
position: fixed;
bottom: 10rpx;
justify-content: space-around;
position: fixed;
bottom: 10rpx;
left: 0;
}
......@@ -269,7 +311,7 @@
height: 60rpx;
}
.login-title {
.login-title {
margin-top: 4px;
font-size: 26rpx;
}
......
......@@ -205,7 +205,7 @@
"path": "pages/ucenter/settings/settings"
}
],
"current": 0
"current": 1
},
"tabBar": {
"color": "#7A7E83",
......
<template>
<view class="content">
<!-- 功能列表 -->
<uni-list class="mt10">
<uni-list class="mt10" :border="false">
<uni-list-item title="个人资料" to="/pages/ucenter/userinfo/userinfo" link="navigateTo"></uni-list-item>
<uni-list-item v-if="userInfo.mobile" title="修改密码" :to="'/pages/ucenter/login-page/pwd-retrieve/pwd-retrieve?phoneNumber='+ userInfo.mobile" link="navigateTo"></uni-list-item>
</uni-list>
<!-- #ifndef H5 -->
<uni-list class="mt10">
<uni-list class="mt10" :border="false">
<!-- #ifdef APP-PLUS -->
<!-- 检查push过程未结束不显示,push设置项 -->
<uni-list-item title="清理缓存" @click="clearTmp" link></uni-list-item>
......
......@@ -23,8 +23,8 @@
"mp-weixin": {
"oauth": {
"weixin": {
"appid": "wx999bf02c8e05dfc9",
"appsecret": "b5f608afd332b2c0ded7e6b98ca4ccd3"
"appid": "wx81dbb061d2258234",
"appsecret": "73be6e8b8b31b7b0783fe448cc1fe820"
}
}
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册