提交 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",
......
<template> <template>
<view class="pages"> <view class="pages">
<!-- #ifndef H5 --> <!-- #ifndef H5 -->
<statusBar></statusBar> <statusBar></statusBar>
<!-- #endif --> <!-- #endif -->
<!-- 搜索功能 --> <!-- 搜索功能 -->
<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"
...@@ -21,16 +20,16 @@ ...@@ -21,16 +20,16 @@
<template v-slot:header> <template v-slot:header>
<image class="avatar" :src="item.avatar" mode="aspectFill"></image> <image class="avatar" :src="item.avatar" mode="aspectFill"></image>
</template> </template>
<!-- 通过body插槽定义布局 --> <!-- 通过body插槽定义布局 -->
<template v-slot:body> <template v-slot:body>
<view class="main"> <view class="main">
<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>
</uni-list-item> </uni-list-item>
<uni-list-item> <uni-list-item>
...@@ -46,23 +45,23 @@ ...@@ -46,23 +45,23 @@
<script> <script>
var cdbRef, currentWebview; var cdbRef, currentWebview;
import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar"; import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar";
import Gps from '@/uni_modules/json-gps/js_sdk/gps.js'; import Gps from '@/uni_modules/json-gps/js_sdk/gps.js';
const gps = new Gps() const gps = new Gps()
export default { export default {
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 '请输入搜索内容'
} }
} }
}, },
data() { data() {
return { return {
...@@ -72,9 +71,9 @@ ...@@ -72,9 +71,9 @@
listHight: 0, listHight: 0,
dataList:[] dataList:[]
} }
}, },
watch: { watch: {
keyword(keyword, oldValue) { keyword(keyword, oldValue) {
let where = '"article_status" == 1 ' let where = '"article_status" == 1 '
if (keyword) { if (keyword) {
this.where = where + `&& /${keyword}/.test(title)`; this.where = where + `&& /${keyword}/.test(title)`;
...@@ -83,7 +82,7 @@ ...@@ -83,7 +82,7 @@
} }
} }
}, },
async onReady() { async onReady() {
// #ifdef APP-NVUE // #ifdef APP-NVUE
this.listHight = uni.getSystemInfoSync().windowHeight - 96 + 'px' this.listHight = uni.getSystemInfoSync().windowHeight - 96 + 'px'
// #endif // #endif
...@@ -91,25 +90,25 @@ ...@@ -91,25 +90,25 @@
this.listHight = 'auto' this.listHight = 'auto'
// #endif // #endif
cdbRef = this.$refs.udb cdbRef = this.$refs.udb
}, },
async onShow() { async onShow() {
this.keyword = getApp().globalData.searchText this.keyword = getApp().globalData.searchText
getApp().globalData.searchText = '' getApp().globalData.searchText = ''
//这里仅演示如何,在onShow生命周期获取设备位置,并在设备或者应用没有权限时自动引导。设置完毕自动重新获取。 //这里仅演示如何,在onShow生命周期获取设备位置,并在设备或者应用没有权限时自动引导。设置完毕自动重新获取。
//你可以基于他做自己的业务,比如:根据距离由近到远排序列表数据等 //你可以基于他做自己的业务,比如:根据距离由近到远排序列表数据等
// uni.showLoading({ // uni.showLoading({
// title:"获取定位中" // title:"获取定位中"
// }); // });
//默认h5端不获取定位 //默认h5端不获取定位
// let location = await gps.getLocation({geocode:true}) // let location = await gps.getLocation({geocode:true})
// console.log(location); // console.log(location);
// if(location){ // if(location){
// uni.showToast({ // uni.showToast({
// title: JSON.stringify(location), // title: JSON.stringify(location),
// icon: 'none' // icon: 'none'
// }); // });
// } // }
// uni.hideLoading() // uni.hideLoading()
}, },
methods: { methods: {
...@@ -128,8 +127,8 @@ ...@@ -128,8 +127,8 @@
retry() { retry() {
this.refresh() this.refresh()
}, },
refresh() { refresh() {
console.log('----platform----'); console.log('----platform----');
console.log(JSON.stringify(process.env.VUE_APP_PLATFORM)); console.log(JSON.stringify(process.env.VUE_APP_PLATFORM));
cdbRef.loadData({ cdbRef.loadData({
clear: true clear: true
...@@ -137,10 +136,10 @@ ...@@ -137,10 +136,10 @@
uni.stopPullDownRefresh() uni.stopPullDownRefresh()
}) })
console.log('refresh'); console.log('refresh');
}, },
onqueryerror(e){ onqueryerror(e) {
console.log(e); console.log(e);
} }
}, },
onPullDownRefresh() { onPullDownRefresh() {
this.refresh() this.refresh()
...@@ -153,13 +152,14 @@ ...@@ -153,13 +152,14 @@
} }
</script> </script>
<style scoped> <style scoped>
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
view { view {
display: flex; display: flex;
box-sizing: border-box; box-sizing: border-box;
flex-direction: column; flex-direction: column;
} }
/* #endif */ /* #endif */
.pages { .pages {
background-color: #FFFFFF; background-color: #FFFFFF;
...@@ -210,9 +210,9 @@ ...@@ -210,9 +210,9 @@
left: 0; left: 0;
/* #ifndef APP-PLUS */ /* #ifndef APP-PLUS */
z-index: 9; z-index: 9;
/* #endif */ /* #endif */
/* #ifdef MP-WEIXIN */ /* #ifdef MP-WEIXIN */
width: 580rpx; width: 580rpx;
/* #endif */ /* #endif */
} }
...@@ -244,14 +244,15 @@ ...@@ -244,14 +244,15 @@
.f1 { .f1 {
flex: 1; flex: 1;
}
.cover-search-bar{
height: 50px;
position: relative;
top: -50px;
margin-bottom: -50px;
/* #ifndef APP-NVUE */
z-index:999;
/* #endif */
} }
</style>
\ No newline at end of file .cover-search-bar {
height: 50px;
position: relative;
top: -50px;
margin-bottom: -50px;
/* #ifndef APP-NVUE */
z-index: 999;
/* #endif */
}
</style>
...@@ -12,14 +12,15 @@ ...@@ -12,14 +12,15 @@
</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">
<uni-popup-dialog mode="input" :value="userInfo.nickname" @confirm="setNickname" :title="$t('userinfo.setNickname')" <uni-popup-dialog mode="input" :value="userInfo.nickname" @confirm="setNickname" :title="$t('userinfo.setNickname')"
: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>
...@@ -67,7 +68,7 @@ ...@@ -67,7 +68,7 @@
methods: { methods: {
...mapMutations({ ...mapMutations({
setUserInfo: 'user/login' setUserInfo: 'user/login'
}), }),
bindMobile() { bindMobile() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
uni.preLogin({ uni.preLogin({
...@@ -79,10 +80,15 @@ ...@@ -79,10 +80,15 @@
this.bindMobileBySmsCode() this.bindMobileBySmsCode()
} }
}) })
// #endif // #endif
// #ifndef APP-PLUS
// #ifdef MP-WEIXIN
this.$refs['uni-bindMobileByMpWeixin'].open()
// #endif
// #ifdef H5
//...去用验证码绑定
this.bindMobileBySmsCode() this.bindMobileBySmsCode()
//...去用验证码绑定
// #endif // #endif
}, },
univerify() { univerify() {
...@@ -126,7 +132,7 @@ ...@@ -126,7 +132,7 @@
} }
}) })
}, },
bindMobileBySmsCode() { bindMobileBySmsCode() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/ucenter/userinfo/bind-mobile/bind-mobile' url: '/pages/ucenter/userinfo/bind-mobile/bind-mobile'
}) })
......
{ {
"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
...@@ -126,7 +126,43 @@ exports.main = async (event, context) => { ...@@ -126,7 +126,43 @@ 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
...@@ -268,7 +304,16 @@ exports.main = async (event, context) => { ...@@ -268,7 +304,16 @@ exports.main = async (event, context) => {
}else{ }else{
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.5(2021-08-10) ## 3.3.6(2021-09-08)
- 修复版本号错误 - 修复 邀请码可能重复的Bug
## 3.3.4(2021-08-10) ## 3.3.5(2021-08-10)
- 微信、QQ、支付宝登录新增type参数用于指定当前是登录还是注册 - 修复版本号错误
## 3.3.3(2021-08-04) ## 3.3.4(2021-08-10)
- 修复使用数组形式的配置文件报错的Bug - 微信、QQ、支付宝登录新增type参数用于指定当前是登录还是注册
## 3.3.2(2021-08-03) ## 3.3.3(2021-08-04)
- 修复上3.3.0版本引出的createInstance接口传入配置不生效的Bug 感谢[hmh](https://gitee.com/hmh) - 修复使用数组形式的配置文件报错的Bug
## 3.3.1(2021-07-30) ## 3.3.2(2021-08-03)
- 修复 将设置用户允许登录的应用列表时传入空数组报错的Bug - 修复上3.3.0版本引出的createInstance接口传入配置不生效的Bug 感谢[hmh](https://gitee.com/hmh)
## 3.3.0(2021-07-30) ## 3.3.1(2021-07-30)
- 新增 不同端应用配置隔离 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=isolate-config) - 修复 将设置用户允许登录的应用列表时传入空数组报错的Bug
- 新增 不同端用户隔离 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=isolate-user) ## 3.3.0(2021-07-30)
+ 此版本升级需要开发者处理一下用户数据,请参考 [补齐用户dcloud_appid字段](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=makeup-dcloud-appid) - 新增 不同端应用配置隔离 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=isolate-config)
- 新增 QQ登录、注册相关功能 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=qq) - 新增 不同端用户隔离 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=isolate-user)
- 调整 不再支持绑定手机、邮箱时不填验证码直接绑定 + 此版本升级需要开发者处理一下用户数据,请参考 [补齐用户dcloud_appid字段](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=makeup-dcloud-appid)
- 新增 QQ登录、注册相关功能 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=qq)
- 调整 不再支持绑定手机、邮箱时不填验证码直接绑定
## 3.2.1(2021-07-09) ## 3.2.1(2021-07-09)
- 撤销3.2.0版本所做的调整 - 撤销3.2.0版本所做的调整
## 3.2.0(2021-07-09) ## 3.2.0(2021-07-09)
......
{ {
"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",
...@@ -13,4 +13,4 @@ ...@@ -13,4 +13,4 @@
"dependencies": { "dependencies": {
"uni-config-center": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center" "uni-config-center": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
} }
} }
\ No newline at end of file
...@@ -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.
先完成此消息的编辑!
想要评论请 注册