提交 54831c95 编写于 作者: A Anne_LXM

Merge branch 'jest-branch' of https://gitcode.net/dcloud/uni-starter into jest-branch

<template>
<view @click="onClick" :style="{width,height}" style="justify-content: center;">
<image v-if="cSrc" :style="{width,height}" :src="cSrc" :mode="mode"></image>
</view>
</template>
<script>
/**
* cloud-image
* @description 兼容普通资源和unicloud图片资源渲染的组件
* @property {String} mode 图片裁剪、缩放的模式。默认为widthFix,支持所有image组件的mode值
* @property {String} src 资源完了链接或uniCloud云存储资源的fileid
* @property {String} width 图片的宽,默认为:100rpx
* @property {String} height 图片的高,默认为:100rpx
* @event {Function} click 点击 cloud-image 触发事件
*/
export default {
name: "cloud-image",
emits:['click'],
props: {
mode: {
type:String,
default () {
return 'widthFix'
}
},
src: {
// type:String,
default () {
return ""
}
},
width: {
type:String,
default () {
return '100rpx'
}
},
height: {
type:String,
default () {
return '100rpx'
}
}
},
watch: {
src:{
handler(src) {
if (src&&src.substring(0, 8) == "cloud://") {
uniCloud.getTempFileURL({
fileList: [src]
}).then(res=>{
this.cSrc = res.fileList[0].tempFileURL
})
}else{
this.cSrc = src
}
},
immediate: true
}
},
methods:{
onClick(){
this.$emit('click')
}
},
data() {
return {
cSrc:false
};
}
}
</script>
\ No newline at end of file
......@@ -43,29 +43,32 @@
}
}
}
}
}
},
"quickapp" : {},
"mp-weixin" : {
"appid" : "",
"setting" : {
"urlCheck" : false
"quickapp": {
},
"usingComponents" : true,
"optimization" : {
"subPackages" : true
"mp-weixin": {
"appid": "",
"setting": {
"urlCheck": false
},
"usingComponents": true,
"optimization": {
"subPackages": true
}
},
"mp-alipay" : {
"usingComponents" : true
"mp-alipay": {
"usingComponents": true
},
"mp-baidu" : {
"usingComponents" : true
"mp-baidu": {
"usingComponents": true
},
"mp-toutiao" : {
"usingComponents" : true
"mp-toutiao": {
"usingComponents": true
},
"uniStatistics" : {
"enable" : false
"uniStatistics": {
"enable": false
},
"vueVersion" : "2"
"vueVersion": "2"
}
\ No newline at end of file
// 在本文件中可配置云数据库初始化,数据格式见:https://uniapp.dcloud.io/uniCloud/hellodb?id=db-init
// 编写完毕后对本文件点右键,可按配置规则创建表和添加数据
{
"uni-id-users": {
"data": [{
"_id": "_uni_starter_test_user_id",
"username": "uni-starter预置用户名",
"nickname": "测试用户昵称",
"avatar": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png",
"avatar": "https://unicloud.dcloud.net.cn/assets/logo.dca09351.png",
"mobile": "18888888888",
"mobile_confirmed": 1
}]
},
"uni-id-roles": {
"data": [{
"role_id": "admin",
"role_name": "超级管理员",
"permission": [],
"comment": "超级管理员拥有所有权限",
"create_date": 0
}]
},
"opendb-banner": {
"data": [{
"status": true,
......@@ -18,14 +29,13 @@
"name": "094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg",
"extname": "jpg",
"fileType": "image",
"url": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e/b88a7e17-35f0-4d0d-bc32-93f8909baf03.jpg",
"url": "https://web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg",
"size": 70880,
"image": {
"width": 500,
"height": 333,
"location": "blob:http://localhost:8081/a3bfaab4-7ee6-44d5-a171-dc8225d83598"
"height": 333
},
"path": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e/b88a7e17-35f0-4d0d-bc32-93f8909baf03.jpg"
"path": "https://web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg"
},
"open_url": "https://www.dcloud.io/",
"title": "测试",
......@@ -39,14 +49,13 @@
"name": "094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg",
"extname": "jpg",
"fileType": "image",
"url": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e/9db94cb4-a5e0-4ed9-b356-b42a392b3112.jpg",
"url": "https://web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg",
"size": 70880,
"image": {
"width": 500,
"height": 333,
"location": "blob:http://localhost:8081/1a6f718a-4012-476a-9172-590fef2cc518"
"height": 333
},
"path": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e/9db94cb4-a5e0-4ed9-b356-b42a392b3112.jpg"
"path": "https://web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg"
},
"open_url": "https://www.dcloud.io/",
"title": "",
......@@ -59,8 +68,8 @@
"data": [{
"title": "阿里小程序IDE官方内嵌uni-app,为开发者提供多端开发服务",
"excerpt": "阿里小程序IDE官方内嵌uni-app,为开发者提供多端开发服务",
"content": "<p>随着微信、阿里、百度、头条、QQ纷纷推出小程序,开发者的开发维护成本持续上升,负担过重。这点已经成为共识,现在连小程序平台厂商也充分意识到了。</p>\n<p>阿里小程序团队,为了减轻开发者的负担,在官方的小程序开发者工具中整合了多端框架。</p>\n<p>经过阿里团队仔细评估,uni-app 在产品完成度、跨平台支持度、开发者社区、可持续发展等多方面优势明显,最终选定 uni-app内置于阿里小程序开发工具中,为开发者提供多端开发解决方案。</p>\n<p>经过之前1个月的公测,10月10日,阿里小程序正式发布0.70版开发者工具,通过 uni-app 实现多端开发,成为本次版本更新的亮点功能!</p>\n<p>如下图,在阿里小程序工具左侧主导航选择 uni-app,创建项目,即可开发。</p>\n<div class=\"aw-comment-upload-img-list active\"><img class=\"img-polaroid\" width=\"100%\" src=\"https://vkceyugu.cdn.bspapp.com/VKCEYUGU-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e/b698232a-e608-4b2d-8019-8dc6bbf343a8.png\" /></div>\n<p><br />阿里小程序开发工具更新说明详见:https://docs.alipay.com/mini/ide/0.70-stable</p>\n<p>&nbsp;</p>\n<p>集成uni-app,这对于阿里团队而言,并不是一个容易做出的决定。毕竟 uni-app 是一个三方产品,要经过复杂的评审流程。</p>\n<p>这一方面突显出阿里团队以开发者需求为本的优秀价值观,另一方面也证明 uni-app的产品确实过硬。</p>\n<p>很多开发者都有多端需求,但又没有足够精力去了解、评估 uni-app,而处于观望态度。现在大家可以更放心的使用 uni-app 了,它没有让阿里失望,也不会让你失望。</p>\n<p>自从uni-app推出以来,DCloud也取得了高速的发展,目前拥有370万开发者,框架运行在4.6亿手机用户设备上,月活达到1.35亿(仅包括部分接入DCloud统计平台的数据)。并且数据仍在高速增长中,在市场占有率上处于遥遥领先的位置。</p>\n<p>本次阿里小程序工具集成 uni-app,会让 uni-app 继续快速爆发,取得更大的成功。</p>\n<p>后续DCloud还将深化与阿里的合作,在serverless等领域给开发者提供更多优质服务。</p>\n<p>使用多端框架开发各端应用,是多赢的模式。开发者减轻了负担,获得了更多新流量。而小程序平台厂商,也能保证自己平台上的各种应用可以被及时的更新。</p>\n<p>DCloud欢迎更多小程序平台厂商,与我们一起合作,为开发者、平台、用户的多赢而努力。</p>\n<p>进一步了解uni-app,详见:https://uniapp.dcloud.io</p>\n<p>欢迎扫码关注DCloud公众号,转发消息到朋友圈。<br /><img src=\"https://vkceyugu.cdn.bspapp.com/VKCEYUGU-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e/27302ea5-e369-4e6c-89b1-431408497b3d.jpg\" width=\"80%\" /></p>",
"avatar": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-aliyun-gacrhzeynhss7c6d04/249516a0-3941-11eb-899d-733ae62bed2f.jpg",
"content": "<p>随着微信、阿里、百度、头条、QQ纷纷推出小程序,开发者的开发维护成本持续上升,负担过重。这点已经成为共识,现在连小程序平台厂商也充分意识到了。</p>\n<p>阿里小程序团队,为了减轻开发者的负担,在官方的小程序开发者工具中整合了多端框架。</p>\n<p>经过阿里团队仔细评估,uni-app 在产品完成度、跨平台支持度、开发者社区、可持续发展等多方面优势明显,最终选定 uni-app内置于阿里小程序开发工具中,为开发者提供多端开发解决方案。</p>\n<p>经过之前1个月的公测,10月10日,阿里小程序正式发布0.70版开发者工具,通过 uni-app 实现多端开发,成为本次版本更新的亮点功能!</p>\n<p>如下图,在阿里小程序工具左侧主导航选择 uni-app,创建项目,即可开发。</p>\n<div class=\"aw-comment-upload-img-list active\"><img class=\"img-polaroid\" width=\"100%\" src=\"https://ask.dcloud.net.cn/uploads/article/20191014/56f7dc1bd5f265e824649f7cb4f78d5b.png\" /></div>\n<p><br />阿里小程序开发工具更新说明详见:https://docs.alipay.com/mini/ide/0.70-stable</p>\n<p>&nbsp;</p>\n<p>集成uni-app,这对于阿里团队而言,并不是一个容易做出的决定。毕竟 uni-app 是一个三方产品,要经过复杂的评审流程。</p>\n<p>这一方面突显出阿里团队以开发者需求为本的优秀价值观,另一方面也证明 uni-app的产品确实过硬。</p>\n<p>很多开发者都有多端需求,但又没有足够精力去了解、评估 uni-app,而处于观望态度。现在大家可以更放心的使用 uni-app 了,它没有让阿里失望,也不会让你失望。</p>\n<p>自从uni-app推出以来,DCloud也取得了高速的发展,目前拥有370万开发者,框架运行在4.6亿手机用户设备上,月活达到1.35亿(仅包括部分接入DCloud统计平台的数据)。并且数据仍在高速增长中,在市场占有率上处于遥遥领先的位置。</p>\n<p>本次阿里小程序工具集成 uni-app,会让 uni-app 继续快速爆发,取得更大的成功。</p>\n<p>后续DCloud还将深化与阿里的合作,在serverless等领域给开发者提供更多优质服务。</p>\n<p>使用多端框架开发各端应用,是多赢的模式。开发者减轻了负担,获得了更多新流量。而小程序平台厂商,也能保证自己平台上的各种应用可以被及时的更新。</p>\n<p>DCloud欢迎更多小程序平台厂商,与我们一起合作,为开发者、平台、用户的多赢而努力。</p>\n<p>进一步了解uni-app,详见:https://uniapp.dcloud.io</p>\n<p>欢迎扫码关注DCloud公众号,转发消息到朋友圈。<br /><img src=\"https://web-assets.dcloud.net.cn/unidoc/zh/weixin.jpg\" width=\"80%\" /></p>",
"avatar": "https://ask.dcloud.net.cn/uploads/article/20191014/56f7dc1bd5f265e824649f7cb4f78d5b.png",
"type": 0,
"user_id": "_uni_starter_test_user_id",
"comment_count": 0,
......@@ -69,98 +78,9 @@
"article_status": 1,
"publish_date": 1616092287006,
"last_modify_date": 1616092303031,
"create_time": "2021-03-19T08:25:06.109Z"
"create_date": 1616092287006
}]
},
"opendb-app-versions": {
"data": [{
"is_silently": false,
"is_mandatory": false,
"appid": "__UNI__03B096E",
"name": "uni-starter",
"title": "新增升级中心",
"contents": "新增升级中心",
"platform": [
"Android"
],
"version": "1.0.1",
"url": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-3469aac7-a663-4c5d-8ee8-94275f8c09ab/3128d010-01c5-4121-a1d6-f3f919944a23.apk",
"stable_publish": false,
"type": "native_app",
"create_date": 1616771628150
}],
"index": [{
"IndexName": "appid",
"MgoKeySchema": {
"MgoIndexKeys": [{
"Name": "appid",
"Direction": "1"
}, {
"Name": "uni_platform",
"Direction": "1"
}, {
"Name": "create_env",
"Direction": "1"
}],
"MgoIsUnique": false
}
}, {
"IndexName": "查找上线发行应用",
"MgoKeySchema": {
"MgoIndexKeys": [{
"Name": "appid",
"Direction": "1"
}, {
"Name": "platform",
"Direction": "1"
}, {
"Name": "stable_publish",
"Direction": "1"
}, {
"Name": "uni_platform",
"Direction": "1"
}, {
"Name": "create_env",
"Direction": "1"
}],
"MgoIsUnique": false
}
}]
},
"opendb-verify-codes": {
"data": []
},
"opendb-app-list": {
"data": [],
"index": [{
"IndexName": "appid",
"MgoKeySchema": {
"MgoIndexKeys": [{
"Name": "appid",
"Direction": "1"
}],
"MgoIsUnique": true
}
}, {
"IndexName": "name",
"MgoKeySchema": {
"MgoIndexKeys": [{
"Name": "name",
"Direction": "1"
}],
"MgoIsUnique": false
}
}]
},
"uni-id-roles": {
"data": []
},
"uni-id-permissions": {
"data": []
},
"uni-id-log": {
"data": []
},
"opendb-admin-menus": {
"data": [{
"menu_id": "index",
......@@ -579,8 +499,14 @@
}
]
},
"uni-id-permissions": {},
"uni-id-log": {},
"uni-id-tag": {},
"uni-id-device": {},
"uni-id-scores": {},
"opendb-verify-codes": {},
"opendb-app-list": {},
"opendb-app-versions": {},
"opendb-device": {},
"opendb-department": {},
"opendb-sms-task": {},
......@@ -595,6 +521,7 @@
"uni-stat-app-platforms": {},
"uni-stat-error-logs": {},
"uni-stat-error-result": {},
"uni-stat-error-source-map": {},
"uni-stat-event-logs": {},
"uni-stat-event-result": {},
"uni-stat-events": {},
......@@ -608,8 +535,8 @@
"uni-stat-session-logs": {},
"uni-stat-share-logs": {},
"uni-stat-user-session-logs": {},
"uni-pay-orders": {},
"uni-stat-pay-result": {},
"uni-pay-orders": {},
"opendb-tempdata": {},
"opendb-feedback": {},
"opendb-news-categories": {},
......@@ -618,6 +545,5 @@
"opendb-search-hot": {},
"opendb-search-log": {},
"opendb-sign-in": {},
"read-news-log": {},
"uni-id-scores": {}
"read-news-log": {}
}
module.exports = {
trigger: {
// 监听 - 删除前
beforeDelete: async function(obj = {}) {
let {
collection,
operation,
where,
field
} = obj;
// 删除表记录前先删除云存储内的文件
const db = uniCloud.database();
const _ = db.command;
let getRes = await db.collection("uni-stat-error-source-map").where(where).limit(1000).get();
let list = getRes.data;
if (list && list.length > 0) {
let fileList = list.map((item, index) => {
return item.file_id;
});
try {
let deleteFileRes = await uniCloud.deleteFile({
fileList
});
// console.log('deleteFileRes: ', deleteFileRes)
} catch (err) {}
}
}
}
}
{
"bsonType": "object",
"description": "存储sourceMap文件资源地址",
"required": [],
"permission": {
"read": "'READ_UNI_STAT_ERROR_RESULT' in auth.permission",
"create": "'READ_UNI_STAT_ERROR_RESULT' in auth.permission",
"update": "'READ_UNI_STAT_ERROR_RESULT' in auth.permission",
"delete": "'READ_UNI_STAT_ERROR_RESULT' in auth.permission"
},
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"appid": {
"bsonType": "string",
"description": "应用ID"
},
"uni_platform": {
"title": "应用平台",
"bsonType": "string",
"description": "uni客户端平台,如:web、mp-weixin、mp-alipay、app等",
"trim": "both"
},
"version": {
"bsonType": "string",
"description": "客户端上报的应用版本号"
},
"file_id": {
"bsonType": "string",
"description": "fileID"
},
"url": {
"bsonType": "string",
"description": "文件外网url路径"
},
"name": {
"bsonType": "string",
"description": "文件名"
},
"size": {
"bsonType": "int",
"description": "文件大小"
},
"cloud_path": {
"bsonType": "string",
"description": "云端路径,通过该值识别是否是同一个文件"
},
"base": {
"bsonType": "string",
"description": "基础路径"
},
"create_time": {
"bsonType": "timestamp",
"description": "上传时间",
"forceDefaultValue": {
"$env": "now"
}
}
}
}
## 1.1.13(2023-05-10)
- 修复 启用摇树优化 报错的问题
## 1.1.12(2023-05-05)
- uni-id-co 新增 调用 add-user 接口创建用户时允许触发 beforeRegister 钩子方法,beforeRegister 钩子[详见](https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#before-register)
- uni-id-co 新增 自无 unionid 到有 unionid 状态进行登录时为用户补充 unionid 字段
- uni-id-co 修复 i18n 在特定场景下报错的 bug
- uni-id-co 修复 跨平台解绑微信/QQ时无法解绑的 bug
- uni-id-co 修复 微信小程序等平台创建验证码时无法展示的 bug
- uni-id-co 修复 更新 push_clientid 时因 device_id 没有变化导致无法更新
## 1.1.11(2023-03-24)
- 修复 tabbar页面因为token无效而强制跳转至登录页面(url参数包含`uniIdRedirectUrl`)后无法返回的问题
## 1.1.10(2023-03-24)
- 修复 PC微信扫码登录跳转地址错误
- uni-id-co 新增 请求鉴权支持 uni-cloud-s2s 模块验证签名 [uni-cloud-s2s文档](https://uniapp.dcloud.net.cn/uniCloud/uni-cloud-s2s.html)
## 1.1.9(2023-03-24)
- 修复 跳转至登录页面的url参数包含`uniIdRedirectUrl`后无法返回的问题
## 1.1.8(2023-03-02)
- 修复 调试模式下没有对微信授权手机号登录方式进行配置检测
## 1.1.7(2023-02-27)
- 【重要】新增 实名认证功能 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#frv)
## 1.1.6(2023-02-24)
- uni-id-co 新增 注册用户时允许配置默认角色 [文档](https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#config-defult-role)
- uni-id-co 优化 `updateUserInfoByExternal`接口,允许修改头像、性别
- uni-id-co 修复 请求签名密钥字段 `requestAuthSecret` 缺少为空判断
- uni-id-co 修复 `externalRegister`接口头像未使用`avatar_file`字段保存
- 修复 web微信登录回调地址不正确
## 1.1.5(2023-02-23)
- 更新 微信小程序端 更新头像信息,如果是使用微信的头像则不再调用裁剪接口
## 1.1.4(2023-02-21)
- 修复 部分情况下 `uniIdRedirectUrl` 参数无效的问题
## 1.1.3(2023-02-20)
- 修复 非微信小程序端报`TypeError: uni.hideHomeButton is not a function`的问题
## 1.1.2(2023-02-10)
- 新增 微信小程序端 首页需强制登录时,隐藏返回首页按钮
- uni-id-co 新增 外部联登后修改用户信息接口(updateUserInfoByExternal) [文档](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#external-update-userinfo)
- uni-id-co 优化外部联登接口(登录、注册)逻辑
## 1.1.1(2023-02-02)
- 新增 微信小程序端 支持选择使用微信资料的“头像”和“昵称” 设置用户资料 [详情参考](https://wdoc-76491.picgzc.qpic.cn/MTY4ODg1MDUyNzQyMDUxNw_21263_rTNhg68FTngQGdvQ_1647431233?w=1280&h=695.7176470588236)
## 1.1.0(2023-01-31)
......
function checkIdCard (idCardNumber) {
export default function checkIdCard (idCardNumber) {
if (!idCardNumber || typeof idCardNumber !== 'string' || idCardNumber.length !== 18) return false
const coefficient = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
......@@ -12,5 +12,3 @@ function checkIdCard (idCardNumber) {
return checkCode[sum % 11].toString() === code.toLowerCase()
}
export default checkIdCard
......@@ -79,7 +79,7 @@ export const mutations = {
uni.removeStorageSync('uni_id_token');
uni.setStorageSync('uni_id_token_expired', 0)
uni.redirectTo({
url: `/${pagesJson.uniIdRouter && pagesJson.uniIdRouter.loginPage ? pagesJson.uniIdRouter.loginPage: 'uni_modules/uni-id-pages/pages/login/login-withoutpwd'}`,
url: `/${pagesJson.uniIdRouter && pagesJson.uniIdRouter.loginPage ? 'uni_modules/uni-id-pages/pages/login/login-withoutpwd': ''}`,
});
uni.$emit('uni-id-pages-logout')
this.setUserInfo({},{cover:true})
......
......@@ -71,31 +71,8 @@
let avatar_file = {
extname: avatarUrl.split('.')[avatarUrl.split('.').length - 1],
name:'',
url:avatarUrl
url:''
}
// 裁剪
let filePath = await new Promise((callback) => {
wx.cropImage({
src:avatarUrl,
cropScale:"1:1",
success: res => {
callback(res.tempFilePath)
},
fail(e){
console.error(e)
uni.showModal({
content: 'wx.cropImage ' + e.errMsg,
showCancel: false,
confirmText:"跳过裁剪",
complete() {
callback(avatarUrl)
}
});
}
})
})
//上传到服务器
let cloudPath = this.userInfo._id + '' + Date.now()
avatar_file.name = cloudPath
......@@ -107,7 +84,7 @@
let {
fileID
} = await uniCloud.uploadFile({
filePath,
filePath:avatarUrl,
cloudPath,
fileType: "image"
});
......@@ -116,20 +93,20 @@
}catch(e){
console.error(e);
}
console.log('avatar_file',avatar_file);
this.setAvatarFile(avatar_file)
},
uploadAvatarImg(res) {
// #ifdef MP-WEIXIN
return false // 微信小程序走 bindchooseavatar方法
// #endif
// #ifndef MP-WEIXIN
if(!this.hasLogin){
return uni.navigateTo({
url:'/uni_modules/uni-id-pages/pages/login/login-withoutpwd'
})
}
const crop = {
quality: 100,
width: 600,
......@@ -192,6 +169,7 @@
this.setAvatarFile(avatar_file)
}
})
// #endif
}
}
}
......
{
"id": "uni-id-pages",
"displayName": "uni-id-pages",
"version": "1.1.1",
"version": "1.1.13",
"description": "云端一体简单、统一、可扩展的用户中心页面模版",
"keywords": [
"用户管理",
......
......@@ -27,9 +27,9 @@
class="input-box" placeholder="再次输入密码" maxlength="20" type="password" v-model="formData.password2"
trim="both" />
</uni-forms-item>
<!-- <uni-forms-item>-->
<!-- <uni-captcha ref="captcha" scene="register" v-model="formData.captcha" />-->
<!-- </uni-forms-item>-->
<uni-forms-item>
<uni-captcha ref="captcha" scene="register" v-model="formData.captcha" />
</uni-forms-item>
<uni-id-pages-agreements scope="register" ref="agreements" ></uni-id-pages-agreements>
<button class="uni-btn" type="primary" @click="submit">注册</button>
<button @click="navigateBack" class="register-back">返回</button>
......@@ -85,14 +85,14 @@
*/
submit() {
this.$refs.form.validate().then((res) => {
// if(this.formData.captcha.length != 4){
// this.$refs.captcha.focusCaptchaInput = true
// return uni.showToast({
// title: '请输入验证码',
// icon: 'none',
// duration: 3000
// });
// }
if(this.formData.captcha.length != 4){
this.$refs.captcha.focusCaptchaInput = true
return uni.showToast({
title: '请输入验证码',
icon: 'none',
duration: 3000
});
}
if (this.needAgreements && !this.agree) {
return this.$refs.agreements.popup(()=>{
this.submitForm(res)
......
......@@ -41,15 +41,13 @@
}
},
onLoad(event) {},
onReady() {
this.uniToken = uni.getStorageSync('uni_id_token')
console.log("uniToken: ", this.uniToken);
},
onReady() {},
methods: {
/**
* 完成并提交
*/
async submit() {
submit() {
if(! /^1\d{10}$/.test(this.formData.mobile)){
this.focusMobile = true
return uni.showToast({
......@@ -68,7 +66,7 @@
}
const uniIdCo = uniCloud.importObject("uni-id-co")
return await uniIdCo.bindMobileBySms(this.formData).then(e => {
uniIdCo.bindMobileBySms(this.formData).then(e => {
uni.showToast({
title: e.errMsg,
icon: 'none',
......@@ -82,16 +80,13 @@
// #endif
mutations.setUserInfo(this.formData)
uni.navigateBack()
return e
}).catch(e => {
console.log(e);
if (e.errCode == 'uni-id-captcha-required') {
this.$refs.popup.open()
}
return e
}).finally(e => {
this.formData.captcha = ""
return e
})
}
}
......
......@@ -40,9 +40,8 @@
</template>
<script>
import checkIdCard from '@/uni_modules/uni-id-pages/common/check-id-card.js';
import checkIdCard from '@/uni_modules/uni-id-pages/common/check-id-card.js'
import mixin from '@/uni_modules/uni-id-pages/common/login-page.mixin.js';
import {
store,
mutations
......
......@@ -11,6 +11,11 @@
</uni-list-item>
<uni-list-item v-if="userInfo.email" class="item" title="电子邮箱" :rightText="userInfo.email">
</uni-list-item>
<!-- #ifdef APP -->
<!-- 如未开通实人认证服务,可以将实名认证入口注释 -->
<uni-list-item class="item" @click="realNameVerify" title="实名认证" :rightText="realNameStatus !== 2 ? '未认证': '已认证'" link>
</uni-list-item>
<!-- #endif -->
<uni-list-item v-if="hasPwd" class="item" @click="changePassword" title="修改密码" link>
</uni-list-item>
</uni-list>
......@@ -32,7 +37,7 @@
</view>
</template>
<script>
const uniIdCo = uniCloud.importObject("uni-id-co")
const uniIdCo = uniCloud.importObject("uni-id-co")
import {
store,
mutations
......@@ -41,6 +46,13 @@
computed: {
userInfo() {
return store.userInfo
},
realNameStatus () {
if (!this.userInfo.realNameAuth) {
return 0
}
return this.userInfo.realNameAuth.authStatus
}
},
data() {
......@@ -154,13 +166,12 @@
this.setNicknameIng = false
this.$refs.dialog.close()
} else {
this.setNicknameIng = true
this.$refs.dialog.open()
}
},
deactivate() {
deactivate(){
uni.navigateTo({
url: "/uni_modules/uni-id-pages/pages/userinfo/deactivate/deactivate"
url:"/uni_modules/uni-id-pages/pages/userinfo/deactivate/deactivate"
})
},
async bindThirdAccount(provider) {
......@@ -170,7 +181,7 @@
alipay: 'ali_openid',
apple: 'apple_openid',
qq: 'qq_openid'
} [provider.toLowerCase()]
}[provider.toLowerCase()]
if (this.userInfo[bindField]) {
await uniIdCo['unbind' + provider]()
......@@ -197,6 +208,11 @@
}
})
}
},
realNameVerify () {
uni.navigateTo({
url: "/uni_modules/uni-id-pages/pages/userinfo/realname-verify/realname-verify"
})
}
}
}
......
......@@ -198,6 +198,52 @@ function getRuleCategory(rule) {
}
}
function isMatchUnionType(val, rule) {
if (!rule.children || rule.children.length === 0) {
return true
}
const children = rule.children
for (let i = 0; i < children.length; i++) {
const child = children[i]
const category = getRuleCategory(child)
let pass = false
switch (category) {
case 'base':
pass = isMatchBaseType(val, child)
break
case 'array':
pass = isMatchArrayType(val, child)
break
default:
break
}
if (pass) {
return true
}
}
return false
}
function isMatchBaseType(val, rule) {
if (typeof baseValidator[rule.type] !== 'function') {
throw new Error(`invalid schema type: ${rule.type}`)
}
const validateRes = baseValidator[rule.type](val)
if (validateRes && validateRes.errCode) {
return false
}
return true
}
function isMatchArrayType(arr, rule) {
if (getType(arr) !== 'array') {
return false
}
if (rule.children && rule.children.length && arr.some(item => !isMatchUnionType(item, rule))) {
return false
}
return true
}
// 特殊符号 https://www.ibm.com/support/pages/password-strength-rules ~!@#$%^&*_-+=`|\(){}[]:;"'<>,.?/
// const specialChar = '~!@#$%^&*_-+=`|\(){}[]:;"\'<>,.?/'
......@@ -274,57 +320,7 @@ class Validator {
return this.customValidator[type] || this.baseValidator[type]
}
_isMatchUnionType(val, rule) {
if (!rule.children || rule.children.length === 0) {
return true
}
const children = rule.children
for (let i = 0; i < children.length; i++) {
const child = children[i]
const category = getRuleCategory(child)
let pass = false
switch (category) {
case 'base':
pass = this._isMatchBaseType(val, child)
break
case 'array':
pass = this._isMatchArrayType(val, child)
break
default:
break
}
if (pass) {
return true
}
}
return false
}
_isMatchBaseType(val, rule) {
const method = this.getRealBaseValidator(rule.type)
if (typeof method !== 'function') {
throw new Error(`invalid schema type: ${rule.type}`)
}
const validateRes = method(val)
if (validateRes && validateRes.errCode) {
return false
}
return true
}
_isMatchArrayType(arr, rule) {
if (getType(arr) !== 'array') {
return false
}
if (rule.children && rule.children.length && arr.some(item => !this._isMatchUnionType(item, rule))) {
return false
}
return true
}
get validator() {
const _this = this
return new Proxy({}, {
get: (_, prop) => {
if (typeof prop !== 'string') {
......@@ -336,7 +332,7 @@ class Validator {
}
const rule = parseValidatorName(prop)
return function (val) {
if (!_this._isMatchUnionType(val, rule)) {
if (!isMatchUnionType(val, rule)) {
return {
errCode: ERROR.INVALID_PARAM
}
......
......@@ -180,21 +180,21 @@ module.exports = {
// }
// })
// // 新增规则同样可以在数组验证规则中使用
// this.validator.validate({
// this.validator.valdate({
// timestamp: 123456789
// }, {
// timestamp: 'timestamp'
// })
// this.validator.validate({
// this.validator.valdate({
// timestampList: [123456789, 123123123123]
// }, {
// timestampList: 'array<timestamp>'
// })
// // 甚至更复杂的写法
// this.validator.validate({
// timestamp: [123456789123123123, 123123123123]
// this.validator.valdate({
// timestamp: [123456789, 123123123123]
// }, {
// timestamp: 'timestamp|array<timestamp|number>'
// timestamp: 'timestamp|array<timestamp>'
// })
// 挂载uni-captcha到this上,方便后续调用
......
......@@ -119,7 +119,6 @@ module.exports = async function (params = {}) {
accessToken,
openid
})
if (avatar) {
// eslint-disable-next-line n/no-deprecated-api
const extName = url.parse(avatar).pathname.split('.').pop()
const cloudPath = `user/avatar/${openid.slice(-8) + Date.now()}-avatar.${extName}`
......@@ -135,14 +134,13 @@ module.exports = async function (params = {}) {
cloudPath,
fileContent: getAvatarRes.data
})
extraData.nickname = nickname
extraData.avatar_file = {
name: cloudPath,
extname: extName,
url: fileID
}
}
extraData.nickname = nickname
}
await saveQQUserKey.call(this, {
openid,
sessionKey,
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册