提交 af79f313 编写于 作者: C chenruilong

1.0.25

上级 a74b4df2
## 1.0.25(2022-10-14)
- uni-id-co 增加 微信授权手机号登录方式 [文档](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#login-by-weixin-mobile)
- uni-id-co 增加 解绑第三方平台账号 [文档](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-third-account)
- uni-id-co 微信绑定手机号支持通过`getPhoneNumber`事件回调的`code`绑定 [文档](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#bind-mobile-by-mp-weixin)
- 修复 sendSmsCode 接口未在参数内传递 templateId 时 未能从配置文件读取 templateId 的Bug
## 1.0.24(2022-10-08) ## 1.0.24(2022-10-08)
- 修复 报uni-id-users表schema内错误的bug - 修复 报uni-id-users表schema内错误的bug
## 1.0.23(2022-10-08) ## 1.0.23(2022-10-08)
......
import pagesJson from '@/pages.json' import pagesJson from '@/pages.json'
const uniIdCo = uniCloud.importObject("uni-id-co") const uniIdCo = uniCloud.importObject("uni-id-co")
const db = uniCloud.database(); const db = uniCloud.database();
const usersTable = db.collection('uni-id-users') const usersTable = db.collection('uni-id-users')
let hostUserInfo = uni.getStorageSync('uni-id-pages-userInfo')||{}
console.log( hostUserInfo); let hostUserInfo = uni.getStorageSync('uni-id-pages-userInfo')||{}
const data = { console.log( hostUserInfo);
userInfo: hostUserInfo, const data = {
hasLogin: Object.keys(hostUserInfo).length != 0 userInfo: hostUserInfo,
} hasLogin: Object.keys(hostUserInfo).length != 0
}
console.log('data', data);
// 定义 mutations, 修改属性 console.log('data', data);
export const mutations = { // 定义 mutations, 修改属性
// data不为空,表示传递要更新的值(注意不是覆盖是合并),什么也不传时,直接查库获取更新 export const mutations = {
async updateUserInfo(data = false) { // data不为空,表示传递要更新的值(注意不是覆盖是合并),什么也不传时,直接查库获取更新
async updateUserInfo(data = false) {
if (data) { if (data) {
usersTable.where('_id==$env.uid').update(data).then(e => { usersTable.where('_id==$env.uid').update(data).then(e => {
console.log(e); console.log(e);
...@@ -32,32 +32,32 @@ export const mutations = { ...@@ -32,32 +32,32 @@ export const mutations = {
icon: 'none' icon: 'none'
}); });
} }
}) })
} else { } else {
try { try {
let res = await usersTable.where("'_id' == $cloudEnv_uid") let res = await usersTable.where("'_id' == $cloudEnv_uid")
.field('mobile,nickname,username,email,avatar_file') .field('mobile,nickname,username,email,avatar_file')
.get() .get()
console.log('fromDbData',res.result.data); console.log('fromDbData',res.result.data);
this.setUserInfo(res.result.data[0]) this.setUserInfo(res.result.data[0])
} catch (e) { } catch (e) {
this.setUserInfo({},{cover:true}) this.setUserInfo({},{cover:true})
console.error(e.message, e.errCode); console.error(e.message, e.errCode);
} }
} }
}, },
async setUserInfo(data, {cover}={cover:false}) { async setUserInfo(data, {cover}={cover:false}) {
console.log('set-userInfo', data); console.log('set-userInfo', data);
let userInfo = cover?data:Object.assign(store.userInfo,data) let userInfo = cover?data:Object.assign(store.userInfo,data)
store.userInfo = Object.assign({},userInfo) store.userInfo = Object.assign({},userInfo)
store.hasLogin = Object.keys(store.userInfo).length != 0 store.hasLogin = Object.keys(store.userInfo).length != 0
console.log('store.userInfo', store.userInfo); console.log('store.userInfo', store.userInfo);
uni.setStorage({ uni.setStorage({
key: "uni-id-pages-userInfo", key: "uni-id-pages-userInfo",
data:store.userInfo data:store.userInfo
}) })
return data return data
}, },
async logout() { async logout() {
await uniIdCo.logout() await uniIdCo.logout()
...@@ -69,7 +69,7 @@ export const mutations = { ...@@ -69,7 +69,7 @@ export const mutations = {
uni.$emit('uni-id-pages-logout') uni.$emit('uni-id-pages-logout')
this.setUserInfo({},{cover:true}) this.setUserInfo({},{cover:true})
}, },
loginSuccess(e){ loginSuccess(e = {}){
const { const {
showToast = true, toastText = '登录成功', autoBack = true, uniIdRedirectUrl = '' showToast = true, toastText = '登录成功', autoBack = true, uniIdRedirectUrl = ''
} = e } = e
...@@ -106,32 +106,32 @@ export const mutations = { ...@@ -106,32 +106,32 @@ export const mutations = {
return window.history.go(-3) return window.history.go(-3)
} }
// #endif // #endif
if (delta) { if (delta) {
const page = pagesJson.pages[0] const page = pagesJson.pages[0]
return uni.reLaunch({ return uni.reLaunch({
url: `/${page.path}` url: `/${page.path}`
}) })
} }
uni.navigateBack({ uni.navigateBack({
delta delta
}) })
} }
} }
} }
// #ifdef VUE2 // #ifdef VUE2
import Vue from 'vue' import Vue from 'vue'
// 通过Vue.observable创建一个可响应的对象 // 通过Vue.observable创建一个可响应的对象
export const store = Vue.observable(data) export const store = Vue.observable(data)
// #endif // #endif
// #ifdef VUE3 // #ifdef VUE3
import { import {
reactive reactive
} from 'vue' } from 'vue'
// 通过Vue.observable创建一个可响应的对象 // 通过Vue.observable创建一个可响应的对象
export const store = reactive(data) export const store = reactive(data)
// #endif // #endif
{ {
"id": "uni-id-pages", "id": "uni-id-pages",
"displayName": "uni-id-pages", "displayName": "uni-id-pages",
"version": "1.0.24", "version": "1.0.25",
"description": "云端一体简单、统一、可扩展的用户中心页面模版", "description": "云端一体简单、统一、可扩展的用户中心页面模版",
"keywords": [ "keywords": [
"用户管理", "用户管理",
......
...@@ -14,16 +14,6 @@ ...@@ -14,16 +14,6 @@
<uni-list-item v-if="hasPwd" class="item" @click="changePassword" title="修改密码" link> <uni-list-item v-if="hasPwd" class="item" @click="changePassword" title="修改密码" link>
</uni-list-item> </uni-list-item>
</uni-list> </uni-list>
<uni-list class="mt10">
<uni-list-item @click="bindThirdAccount('Weixin')" title="微信" link
:rightText="userInfo.wx_openid ? '已绑定': '未绑定' "></uni-list-item>
<uni-list-item @click="bindThirdAccount('QQ')" title="QQ" link
:rightText="userInfo.qq_openid ? '已绑定': '未绑定' "></uni-list-item>
<uni-list-item @click="bindThirdAccount('Alipay')" title="支付宝" link
:rightText="userInfo.ali_openid ? '已绑定': '未绑定' "></uni-list-item>
<uni-list-item @click="bindThirdAccount('Apple')" title="Apple" link
:rightText="userInfo.apple_openid ? '已绑定': '未绑定' "></uni-list-item>
</uni-list>
<uni-list class="mt10"> <uni-list class="mt10">
<uni-list-item @click="deactivate" title="注销账号" link="navigateTo"></uni-list-item> <uni-list-item @click="deactivate" title="注销账号" link="navigateTo"></uni-list-item>
</uni-list> </uni-list>
......
{ {
"name": "uni-id-co", "name": "uni-id-co",
"version": "1.0.22", "version": "1.0.25",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"keywords": [], "keywords": [],
...@@ -16,4 +16,4 @@ ...@@ -16,4 +16,4 @@
"extensions": { "extensions": {
"uni-cloud-sms": {} "uni-cloud-sms": {}
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册