提交 1ef9c1f6 编写于 作者: DCloud_JSON's avatar DCloud_JSON 提交者: study夏羽

1. 通过微信小程序登陆自动保存到表 2. 我的-设置-个人资料 点击绑定手机号码,完善账号信息支持以下三种策略: -...

1. 通过微信小程序登陆自动保存到表 2. 我的-设置-个人资料 点击绑定手机号码,完善账号信息支持以下三种策略: 	- APP端,(如果支持)使用通过运营商一键获取手机号码 	- 微信小程序端,支持一键获取微信绑定的手机号 	- 其他端,通过手机验证码
上级 21b4a905
## 1.1.14(2021-09-30)
1. 通过微信小程序登陆自动保存`sessionKey``uni-id-users`
2. 我的-设置-个人资料 点击绑定手机号码,完善账号信息支持以下三种策略:
- APP端,(如果支持)使用"通过运营商一键获取手机号码"
- 微信小程序端,支持"一键获取微信绑定的手机号"
- 其他端,通过手机验证码
## 1.1.13(2021-09-29) ## 1.1.13(2021-09-29)
修复search页面因多语言国际化导致白屏问题 修复search页面因多语言国际化导致白屏问题
## 1.1.12(2021-09-28) ## 1.1.12(2021-09-28)
1. 改造微信登陆逻辑,直接使用`uni.login`参数`"onlyAuthorize":true`实现 1. 改造微信登陆逻辑,直接使用`uni.login`参数`"onlyAuthorize":true`实现
2. 修复,一键登录弹出层,已勾选“同意隐私政策协议”点击自定义登陆按钮,报“你未同意隐私政策协议”的bug 2. 修复,一键登录弹出层,已勾选“同意隐私政策协议”点击自定义登陆按钮,报“你未同意隐私政策协议”的bug
......
<template>
<uni-popup ref="popup" type="bottom">
<view class="box">
<text class="headBox">绑定资料</text>
<text class="tip">将一键获取你的手机号码绑定你的个人资料</text>
<view class="btnBox">
<text @click="closeMe" class="close">关闭</text>
<button class="agree" type="warn" @click="beforeGetphonenumber" open-type="getPhoneNumber"
@getphonenumber="bindMobileByMpWeixin">获取</button>
</view>
</view>
</uni-popup>
</template>
<script>
import {
mapMutations,
mapGetters
} from 'vuex';
const db = uniCloud.database();
const usersTable = db.collection('uni-id-users')
let userId = ''
export default {
emits: ['next'],
computed: {
...mapGetters({
userInfo: 'user/info',
login: 'user/hasLogin'
})
},
data() {
return {}
},
methods: {
...mapMutations({
setUserInfo: 'user/login'
}),
beforeGetphonenumber() {
uni.showLoading({
mask:true
})
wx.checkSession({
success() {
console.log('session_key 未过期');
uni.hideLoading()
},
fail() {
console.log('session_key 已经失效,正在执行更新');
wx.login({
success({code}) {
uniCloud.callFunction({
name: "uni-id-cf",
data: {
"action": "refreshSessionKey",
"params": {
code
}
},
complete: (e) => {
console.log(e);
uni.hideLoading()
}
})
},
fail: (err) => {
console.error(err);
}
})
}
})
},
bindMobileByMpWeixin(e) {
console.log(e.detail);
uniCloud.callFunction({
name: "uni-id-cf",
data: {
"action": "bindMobileByMpWeixin",
"params": e.detail
},
complete: (e) => {
console.log(e);
},
success: (e) => {
uni.showToast({
title: e.result.msg,
icon: 'none'
});
if(e.result.code === 0){
this.setUserInfo({
"mobile": e.result.mobile
})
}
this.closeMe()
}
})
},
async open(uid) {
userId = uid
this.$refs.popup.open()
this.beforeGetphonenumber()
},
closeMe(e) {
this.$refs.popup.close()
},
}
}
</script>
<style lang="scss" scoped>
view {
display: flex;
}
.box {
background-color: #FFFFFF;
height: 200px;
width: 750rpx;
flex-direction: column;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
}
.headBox {
padding: 20rpx;
height: 80rpx;
line-height: 80rpx;
text-align: left;
font-size: 32upx;
color: #333333;
margin-left: 15rpx;
}
.tip {
color: #666666;
text-align: left;
justify-content: center;
margin: 10rpx 30rpx;
font-size: 36rpx;
}
.btnBox {
margin-top: 45rpx;
justify-content: center;
flex-direction: row;
}
.close,
.agree {
text-align: center;
width: 200rpx;
height: 80upx;
line-height: 80upx;
border-radius: 50px;
margin: 0 20rpx;
font-size: 36rpx;
}
.close {
color: #999999;
border-color: #EEEEEE;
border-style: solid;
border-width: 1px;
background-color: #FFFFFF;
}
.close:active {
color: #989898;
background-color: #E2E2E2;
}
.agree {
background-color: #DD524D;
color: #FFFFFF;
}
/* #ifdef MP */
.agree::after {
border: none;
}
.agree {
background-color: #DD524D;
}
/* #endif */
.agree:active {
background-color: #F5F5F6;
}
</style>
{ {
"id": "uni-starter", "id": "uni-starter",
"displayName": "uni-starter", "displayName": "uni-starter",
"version": "1.1.13", "version": "1.1.14",
"description": "云端一体应用快速开发基本项目模版", "description": "云端一体应用快速开发基本项目模版",
"keywords": [ "keywords": [
"login", "login",
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
<uni-search-bar @click="searchClick" class="uni-search-box" v-model="keyword" ref="searchBar" radius="100" <uni-search-bar @click="searchClick" class="uni-search-box" v-model="keyword" ref="searchBar" radius="100"
cancelButton="none" disabled :placeholder="inputPlaceholder" /> cancelButton="none" disabled :placeholder="inputPlaceholder" />
<view class="cover-search-bar" @click="searchClick"></view> <view class="cover-search-bar" @click="searchClick"></view>
<unicloud-db ref='udb' v-slot:default="{data,pagination,hasMore, loading, error, options}" @error="onqueryerror" <unicloud-db ref='udb' v-slot:default="{data,pagination,hasMore, loading, error, options}" @error="onqueryerror"
:where="where" collection="opendb-news-articles,uni-id-users" :page-size="10" :where="where" collection="opendb-news-articles,uni-id-users" :page-size="10"
field="avatar,title,last_modify_date,user_id.username" @load="loadData" field="avatar,title,last_modify_date,user_id.username" @load="loadData"
...@@ -27,8 +26,8 @@ ...@@ -27,8 +26,8 @@
<text class="title">{{item.title}}</text> <text class="title">{{item.title}}</text>
<view class="info"> <view class="info">
<text class="author">{{item.user_id[0].username}}</text> <text class="author">{{item.user_id[0].username}}</text>
<uni-dateformat class="last_modify_date" :date="item.last_modify_date" format="yyyy-MM-dd" <uni-dateformat class="last_modify_date" :date="item.last_modify_date"
:threshold="[60000, 2592000000]" /> format="yyyy-MM-dd" :threshold="[60000, 2592000000]" />
</view> </view>
</view> </view>
</template> </template>
...@@ -55,11 +54,11 @@ ...@@ -55,11 +54,11 @@
components: { components: {
statusBar statusBar
}, },
computed:{ computed: {
inputPlaceholder(e){ inputPlaceholder(e) {
if(uni.getStorageSync('CURRENT_LANG') == "en"){ if (uni.getStorageSync('CURRENT_LANG') == "en") {
return 'Please enter the search content' return 'Please enter the search content'
}else{ } else {
return '请输入搜索内容' return '请输入搜索内容'
} }
} }
...@@ -138,7 +137,7 @@ ...@@ -138,7 +137,7 @@
}) })
console.log('refresh'); console.log('refresh');
}, },
onqueryerror(e){ onqueryerror(e) {
console.log(e); console.log(e);
} }
}, },
...@@ -160,6 +159,7 @@ ...@@ -160,6 +159,7 @@
box-sizing: border-box; box-sizing: border-box;
flex-direction: column; flex-direction: column;
} }
/* #endif */ /* #endif */
.pages { .pages {
background-color: #FFFFFF; background-color: #FFFFFF;
...@@ -245,13 +245,14 @@ ...@@ -245,13 +245,14 @@
.f1 { .f1 {
flex: 1; flex: 1;
} }
.cover-search-bar{
.cover-search-bar {
height: 50px; height: 50px;
position: relative; position: relative;
top: -50px; top: -50px;
margin-bottom: -50px; margin-bottom: -50px;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
z-index:999; z-index: 999;
/* #endif */ /* #endif */
} }
</style> </style>
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</uni-list-item> </uni-list-item>
<uni-list-item class="item" @click="setNickname('')" :title="$t('userinfo.nickname')" :rightText="userInfo.nickname||$t('userinfo.notSet')" link> <uni-list-item class="item" @click="setNickname('')" :title="$t('userinfo.nickname')" :rightText="userInfo.nickname||$t('userinfo.notSet')" link>
</uni-list-item> </uni-list-item>
<uni-list-item class="item" @click="bindMobileBySmsCode" :title="$t('userinfo.phoneNumber')" :rightText="userInfo.mobile||$t('userinfo.notSpecified')" link> <uni-list-item class="item" @click="bindMobile" :title="$t('userinfo.phoneNumber')" :rightText="userInfo.mobile||$t('userinfo.notSpecified')" link>
</uni-list-item> </uni-list-item>
</uni-list> </uni-list>
<uni-popup ref="dialog" type="dialog"> <uni-popup ref="dialog" type="dialog">
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
:placeholder="$t('userinfo.setNicknamePlaceholder')"> :placeholder="$t('userinfo.setNicknamePlaceholder')">
</uni-popup-dialog> </uni-popup-dialog>
</uni-popup> </uni-popup>
<uni-bindMobileByMpWeixin ref="uni-bindMobileByMpWeixin"></uni-bindMobileByMpWeixin>
</view> </view>
</template> </template>
<script> <script>
...@@ -80,9 +81,14 @@ ...@@ -80,9 +81,14 @@
} }
}) })
// #endif // #endif
// #ifndef APP-PLUS
this.bindMobileBySmsCode() // #ifdef MP-WEIXIN
this.$refs['uni-bindMobileByMpWeixin'].open()
// #endif
// #ifdef H5
//...去用验证码绑定 //...去用验证码绑定
this.bindMobileBySmsCode()
// #endif // #endif
}, },
univerify() { univerify() {
......
{ {
"name" : "uni-config-center", "name": "uni-config-center",
"version" : "0.0.2", "version": "0.0.2",
"description" : "配置中心", "description": "配置中心",
"main" : "index.js", "main": "index.js",
"keywords" : [], "keywords": [],
"author" : "DCloud", "author": "DCloud",
"license" : "Apache-2.0", "license": "Apache-2.0"
"dependencies" : null
} }
\ No newline at end of file
...@@ -127,6 +127,42 @@ exports.main = async (event, context) => { ...@@ -127,6 +127,42 @@ exports.main = async (event, context) => {
let res = {} let res = {}
switch (action) { //根据action的值执行对应的操作 switch (action) { //根据action的值执行对应的操作
case 'refreshSessionKey':
let getSessionKey = await uniID.code2SessionWeixin({code:params.code});
if(getSessionKey.code){
return getSessionKey
}
res = await uniID.updateUser({
uid: params.uid,
sessionKey:getSessionKey.sessionKey
})
console.log(res);
break;
case 'bindMobileByMpWeixin':
console.log(params);
let getSessionKeyRes = await uniID.getUserInfo({
uid: params.uid,
field: ['sessionKey']
})
if(getSessionKeyRes.code){
return getSessionKeyRes
}
let sessionKey = getSessionKeyRes.userInfo.sessionKey
console.log(getSessionKeyRes);
res = await uniID.wxBizDataCrypt({
...params,
sessionKey
})
console.log(res);
if(res.code){
return res
}
res = await uniID.bindMobile({
uid: params.uid,
mobile: res.purePhoneNumber
})
console.log(res);
break;
case 'bindMobileByUniverify': case 'bindMobileByUniverify':
let { let {
appid, apiKey, apiSecret appid, apiKey, apiSecret
...@@ -269,6 +305,15 @@ exports.main = async (event, context) => { ...@@ -269,6 +305,15 @@ exports.main = async (event, context) => {
return wxRes return wxRes
} }
} }
if(context.PLATFORM == "mp-weixin"){
let resUpdateUser = await uniID.updateUser({
uid: loginRes.uid,
sessionKey:loginRes.sessionKey
})
console.log(resUpdateUser);
}
delete loginRes.openid
delete loginRes.sessionKey
delete loginRes.accessToken delete loginRes.accessToken
delete loginRes.refreshToken delete loginRes.refreshToken
} }
......
## 3.3.6(2021-09-08)
- 修复 邀请码可能重复的Bug
## 3.3.5(2021-08-10) ## 3.3.5(2021-08-10)
- 修复版本号错误 - 修复版本号错误
## 3.3.4(2021-08-10) ## 3.3.4(2021-08-10)
......
{ {
"id": "uni-id", "id": "uni-id",
"displayName": "uni-id", "displayName": "uni-id",
"version": "3.3.5", "version": "3.3.6",
"description": "简单、统一、可扩展的用户中心", "description": "简单、统一、可扩展的用户中心",
"keywords": [ "keywords": [
"uniid", "uniid",
......
{ {
"name": "uni-id", "name": "uni-id",
"version": "3.3.5", "version": "3.3.6",
"description": "uni-id for uniCloud", "description": "uni-id for uniCloud",
"main": "index.js", "main": "index.js",
"homepage": "https://uniapp.dcloud.io/uniCloud/uni-id", "homepage": "https://uniapp.dcloud.io/uniCloud/uni-id",
......
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
}, },
"quickapp" : {}, "quickapp" : {},
"mp-weixin" : { "mp-weixin" : {
"appid" : "", "appid" : "wxec5319bef3a0d8fb",
"setting" : { "setting" : {
"urlCheck" : false, "urlCheck" : false,
"es6" : false "es6" : false
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
"mp-weixin": { "mp-weixin": {
"oauth": { "oauth": {
"weixin": { "weixin": {
"appid": "wx81dbb061d2258234", "appid": "wxec5319bef3a0d8fb",
"appsecret": "51977820eb14cd71377d4048a1b4754e" "appsecret": "68bf2402a70d50c3b53097be4712c914"
} }
} }
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册