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

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

1. 通过微信小程序登陆自动保存到表 2. 我的-设置-个人资料 点击绑定手机号码,完善账号信息支持以下三种策略: 	- APP端,(如果支持)使用通过运营商一键获取手机号码 	- 微信小程序端,支持一键获取微信绑定的手机号 	- 其他端,通过手机验证码
上级 371241cb
## 1.1.14(2021-09-30)
1. 通过微信小程序登陆自动保存`sessionKey``uni-id-users`
2. 我的-设置-个人资料 点击绑定手机号码,完善账号信息支持以下三种策略:
- APP端,(如果支持)使用"通过运营商一键获取手机号码"
- 微信小程序端,支持"一键获取微信绑定的手机号"
- 其他端,通过手机验证码
## 1.1.13(2021-09-29)
修复search页面因多语言国际化导致白屏问题
修复search页面因多语言国际化导致白屏问题
## 1.1.12(2021-09-28)
1. 改造微信登陆逻辑,直接使用`uni.login`参数`"onlyAuthorize":true`实现
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",
"displayName": "uni-starter",
"version": "1.1.13",
"version": "1.1.14",
"description": "云端一体应用快速开发基本项目模版",
"keywords": [
"login",
......
<template>
<view class="pages">
<view class="pages">
<!-- #ifndef H5 -->
<statusBar></statusBar>
<statusBar></statusBar>
<!-- #endif -->
<!-- 搜索功能 -->
<uni-search-bar @click="searchClick" class="uni-search-box" v-model="keyword" ref="searchBar" radius="100"
cancelButton="none" disabled :placeholder="inputPlaceholder" />
<view class="cover-search-bar" @click="searchClick"></view>
<!-- 搜索功能 -->
<uni-search-bar @click="searchClick" class="uni-search-box" v-model="keyword" ref="searchBar" radius="100"
cancelButton="none" disabled :placeholder="inputPlaceholder" />
<view class="cover-search-bar" @click="searchClick"></view>
<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"
field="avatar,title,last_modify_date,user_id.username">
......@@ -20,16 +19,16 @@
<template v-slot:header>
<image class="avatar" :src="item.avatar" mode="aspectFill"></image>
</template>
<!-- 通过body插槽定义布局 -->
<template v-slot:body>
<view class="main">
<text class="title">{{item.title}}</text>
<view class="info">
<text class="author">{{item.user_id[0].username}}</text>
<uni-dateformat class="last_modify_date" :date="item.last_modify_date" format="yyyy-MM-dd"
:threshold="[60000, 2592000000]" />
</view>
</view>
<!-- 通过body插槽定义布局 -->
<template v-slot:body>
<view class="main">
<text class="title">{{item.title}}</text>
<view class="info">
<text class="author">{{item.user_id[0].username}}</text>
<uni-dateformat class="last_modify_date" :date="item.last_modify_date"
format="yyyy-MM-dd" :threshold="[60000, 2592000000]" />
</view>
</view>
</template>
</uni-list-item>
<uni-list-item>
......@@ -45,23 +44,23 @@
<script>
var cdbRef, currentWebview;
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';
const gps = new Gps()
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';
const gps = new Gps()
export default {
components: {
statusBar
},
computed:{
inputPlaceholder(e){
if(uni.getStorageSync('CURRENT_LANG') == "en"){
return 'Please enter the search content'
}else{
return '请输入搜索内容'
}
}
},
computed: {
inputPlaceholder(e) {
if (uni.getStorageSync('CURRENT_LANG') == "en") {
return 'Please enter the search content'
} else {
return '请输入搜索内容'
}
}
},
data() {
return {
......@@ -70,9 +69,9 @@
refreshState: 0,
listHight: 0
}
},
},
watch: {
keyword(keyword, oldValue) {
keyword(keyword, oldValue) {
let where = '"article_status" == 1 '
if (keyword) {
this.where = where + `/${keyword}/.test(title)`;
......@@ -81,7 +80,7 @@
}
}
},
async onReady() {
async onReady() {
// #ifdef APP-NVUE
this.listHight = uni.getSystemInfoSync().windowHeight - 96 + 'px'
// #endif
......@@ -90,25 +89,27 @@
// #endif
cdbRef = this.$refs.udb
},
async onShow() {
async onShow() {
this.keyword = getApp().globalData.searchText
getApp().globalData.searchText = ''
//这里仅演示如何,在onShow生命周期获取设备位置,并在设备或者应用没有权限时自动引导。设置完毕自动重新获取。
//你可以基于他做自己的业务,比如:根据距离由近到远排序列表数据等
// uni.showLoading({
// title:"获取定位中"
// });
//默认h5端不获取定位
// #ifndef H5
let location = await gps.getLocation({geocode:true})
console.log(location);
// #endif
// if(location){
// uni.showToast({
// title: JSON.stringify(location),
// icon: 'none'
// });
// }
//这里仅演示如何,在onShow生命周期获取设备位置,并在设备或者应用没有权限时自动引导。设置完毕自动重新获取。
//你可以基于他做自己的业务,比如:根据距离由近到远排序列表数据等
// uni.showLoading({
// title:"获取定位中"
// });
//默认h5端不获取定位
// #ifndef H5
let location = await gps.getLocation({
geocode: true
})
console.log(location);
// #endif
// if(location){
// uni.showToast({
// title: JSON.stringify(location),
// icon: 'none'
// });
// }
// uni.hideLoading()
},
methods: {
......@@ -122,8 +123,8 @@
retry() {
this.refresh()
},
refresh() {
console.log('----platform----');
refresh() {
console.log('----platform----');
console.log(JSON.stringify(process.env.VUE_APP_PLATFORM));
cdbRef.loadData({
clear: true
......@@ -131,10 +132,10 @@
uni.stopPullDownRefresh()
})
console.log('refresh');
},
onqueryerror(e){
console.log(e);
}
},
onqueryerror(e) {
console.log(e);
}
},
onPullDownRefresh() {
this.refresh()
......@@ -147,13 +148,14 @@
}
</script>
<style scoped>
/* #ifndef APP-NVUE */
view {
display: flex;
box-sizing: border-box;
flex-direction: column;
}
<style scoped>
/* #ifndef APP-NVUE */
view {
display: flex;
box-sizing: border-box;
flex-direction: column;
}
/* #endif */
.pages {
background-color: #FFFFFF;
......@@ -204,9 +206,9 @@
left: 0;
/* #ifndef APP-PLUS */
z-index: 9;
/* #endif */
/* #ifdef MP-WEIXIN */
width: 580rpx;
/* #endif */
/* #ifdef MP-WEIXIN */
width: 580rpx;
/* #endif */
}
......@@ -238,14 +240,15 @@
.f1 {
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 @@
</uni-list-item>
<uni-list-item class="item" @click="setNickname('')" :title="$t('userinfo.nickname')" :rightText="userInfo.nickname||$t('userinfo.notSet')" link>
</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>
</uni-list>
<uni-popup ref="dialog" type="dialog">
<uni-popup-dialog mode="input" :value="userInfo.nickname" @confirm="setNickname" :title="$t('userinfo.setNickname')"
:placeholder="$t('userinfo.setNicknamePlaceholder')">
</uni-popup-dialog>
</uni-popup>
</uni-popup>
<uni-bindMobileByMpWeixin ref="uni-bindMobileByMpWeixin"></uni-bindMobileByMpWeixin>
</view>
</template>
<script>
......@@ -63,7 +64,7 @@
methods: {
...mapMutations({
setUserInfo: 'user/login'
}),
}),
bindMobile() {
// #ifdef APP-PLUS
uni.preLogin({
......@@ -75,10 +76,15 @@
this.bindMobileBySmsCode()
}
})
// #endif
// #ifndef APP-PLUS
// #endif
// #ifdef MP-WEIXIN
this.$refs['uni-bindMobileByMpWeixin'].open()
// #endif
// #ifdef H5
//...去用验证码绑定
this.bindMobileBySmsCode()
//...去用验证码绑定
// #endif
},
univerify() {
......@@ -122,7 +128,7 @@
}
})
},
bindMobileBySmsCode() {
bindMobileBySmsCode() {
uni.navigateTo({
url: '/pages/ucenter/userinfo/bind-mobile/bind-mobile'
})
......
{
"name" : "uni-config-center",
"version" : "0.0.2",
"description" : "配置中心",
"main" : "index.js",
"keywords" : [],
"author" : "DCloud",
"license" : "Apache-2.0",
"dependencies" : null
}
"name": "uni-config-center",
"version": "0.0.2",
"description": "配置中心",
"main": "index.js",
"keywords": [],
"author": "DCloud",
"license": "Apache-2.0"
}
\ No newline at end of file
......@@ -126,7 +126,43 @@ exports.main = async (event, context) => {
}
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':
let {
appid, apiKey, apiSecret
......@@ -268,7 +304,16 @@ exports.main = async (event, context) => {
}else{
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.refreshToken
}
......
## 3.3.5(2021-08-10)
- 修复版本号错误
## 3.3.4(2021-08-10)
- 微信、QQ、支付宝登录新增type参数用于指定当前是登录还是注册
## 3.3.3(2021-08-04)
- 修复使用数组形式的配置文件报错的Bug
## 3.3.2(2021-08-03)
- 修复上3.3.0版本引出的createInstance接口传入配置不生效的Bug 感谢[hmh](https://gitee.com/hmh)
## 3.3.1(2021-07-30)
- 修复 将设置用户允许登录的应用列表时传入空数组报错的Bug
## 3.3.0(2021-07-30)
- 新增 不同端应用配置隔离 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=isolate-config)
- 新增 不同端用户隔离 [详情](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.3.6(2021-09-08)
- 修复 邀请码可能重复的Bug
## 3.3.5(2021-08-10)
- 修复版本号错误
## 3.3.4(2021-08-10)
- 微信、QQ、支付宝登录新增type参数用于指定当前是登录还是注册
## 3.3.3(2021-08-04)
- 修复使用数组形式的配置文件报错的Bug
## 3.3.2(2021-08-03)
- 修复上3.3.0版本引出的createInstance接口传入配置不生效的Bug 感谢[hmh](https://gitee.com/hmh)
## 3.3.1(2021-07-30)
- 修复 将设置用户允许登录的应用列表时传入空数组报错的Bug
## 3.3.0(2021-07-30)
- 新增 不同端应用配置隔离 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=isolate-config)
- 新增 不同端用户隔离 [详情](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.0版本所做的调整
## 3.2.0(2021-07-09)
......
{
"id": "uni-id",
"displayName": "uni-id",
"version": "3.3.5",
"version": "3.3.6",
"description": "简单、统一、可扩展的用户中心",
"keywords": [
"uniid",
......
{
"name": "uni-id",
"version": "3.3.5",
"version": "3.3.6",
"description": "uni-id for uniCloud",
"main": "index.js",
"homepage": "https://uniapp.dcloud.io/uniCloud/uni-id",
......@@ -13,4 +13,4 @@
"dependencies": {
"uni-config-center": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
}
}
\ No newline at end of file
......@@ -160,7 +160,7 @@
},
"quickapp" : {},
"mp-weixin" : {
"appid" : "",
"appid" : "wxec5319bef3a0d8fb",
"setting" : {
"urlCheck" : false,
"es6" : false
......
......@@ -23,8 +23,8 @@
"mp-weixin": {
"oauth": {
"weixin": {
"appid": "wx81dbb061d2258234",
"appsecret": "51977820eb14cd71377d4048a1b4754e"
"appid": "wxec5319bef3a0d8fb",
"appsecret": "68bf2402a70d50c3b53097be4712c914"
}
}
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册