From fd754af33417fa03b0ad77e92e67e34974a3ce48 Mon Sep 17 00:00:00 2001 From: VK <370725567@qq.com> Date: Mon, 21 Sep 2020 17:14:24 +0800 Subject: [PATCH] 1.3.6 --- README.md | 4 +- README/1.3.6.md | 37 +++++++++++++++++++ .../router/package-lock.json | 6 +-- cloudfunctions-aliyun/router/package.json | 2 +- .../router/service/user/kh/acceptInvite.js | 13 +++---- .../router/service/user/kh/bindAlipay.js | 13 +++---- .../router/service/user/kh/bindEmail.js | 13 +++---- .../router/service/user/kh/bindMobile.js | 13 +++---- .../router/service/user/kh/bindWeixin.js | 13 +++---- .../router/service/user/kh/getInvitedUser.js | 15 ++++---- .../router/service/user/kh/resetPwd.js | 13 +++---- .../router/service/user/kh/setAvatar.js | 13 +++---- .../service/user/kh/setUserInviteCode.js | 13 +++---- .../router/service/user/kh/unbindAlipay.js | 13 +++---- .../router/service/user/kh/unbindEmail.js | 13 +++---- .../router/service/user/kh/unbindMobile.js | 13 +++---- .../router/service/user/kh/unbindWeixin.js | 15 ++++---- .../router/service/user/kh/updatePwd.js | 15 ++++---- .../router/service/user/kh/updateUser.js | 15 ++++---- .../router/service/user/pub/checkToken.js | 29 +++++++-------- .../service/user/pub/code2SessionAlipay.js | 19 +++++----- .../service/user/pub/code2SessionWeixin.js | 19 +++++----- .../router/service/user/pub/encryptPwd.js | 13 +++---- .../router/service/user/pub/login.js | 28 +++++++------- .../router/service/user/pub/loginByAlipay.js | 11 +++--- .../router/service/user/pub/loginByEmail.js | 11 +++--- .../router/service/user/pub/loginBySms.js | 11 +++--- .../router/service/user/pub/loginByWeixin.js | 11 +++--- .../router/service/user/pub/logout.js | 15 ++++---- .../router/service/user/pub/register.js | 11 +++--- .../router/service/user/pub/sendEmailCode.js | 2 +- .../router/service/user/pub/sendSmsCode.js | 12 +++--- .../router/service/user/pub/setVerifyCode.js | 13 +++---- .../router/service/user/sys/test1.js | 15 ++++---- .../router/service/user/util/login_log.js | 33 ++++++++--------- package-lock.json | 14 +++---- package.json | 2 +- 37 files changed, 265 insertions(+), 256 deletions(-) create mode 100644 README/1.3.6.md diff --git a/README.md b/README.md index e753d9a..d231321 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ### uniCloud云函数路由框架研究Q群:22466457 如有问题或建议可以在群内讨论。 ### 插件名称:`vk-unicloud-router` ### 作者:VK -### 更新时间:2020-09-16 +### 更新时间:2020-09-21 ## 主要功能 以及 对开发者的价值 @@ -57,7 +57,7 @@ this.vk.callFunction({ #### 6、【1.2.2 新增】 `vk.baseDao`数据库工具包,使小白也能轻松上手对数据库的调用。 -#### 7、【1.2.7 新增】 集成`uview-ui` UI框架 版本:1.6.5(感谢`uview-ui`作者)。 +#### 7、【1.2.7 新增】 集成`uview-ui` UI框架(感谢`uview-ui`作者)。 #### 8、【1.2.9 新增】 前后端一体动态数据组件 diff --git a/README/1.3.6.md b/README/1.3.6.md new file mode 100644 index 0000000..3cff2dd --- /dev/null +++ b/README/1.3.6.md @@ -0,0 +1,37 @@ +### uniCloud 云函数路由研究群:22466457 如有问题或建议可以在群内讨论。 +##### gitee公共仓库地址:https://gitee.com/vk-uni/vk-uni-cloud-router.git +### 更新内容 +#### 1、【新增】10个实用的js函数(前后端均可用以下方式调用) +``` +// 自动根据字符串路径获取对象中的值支持.和[] , 且任意一个值为undefined时,不会报错,会直接返回undefined +vk.pubfn.getData(dataObj,"a.b.c[1]"); + +// 自动根据字符串路径设置对象中的值 支持.和[] +vk.pubfn.setData(dataObj, "a.b.c[1]", "aa"); + +// 检测参数是否有值 其中 undefined、null、{}、[]、"" 均为false +vk.pubfn.isNull(value); + +// 检测参数是否无值 结果与 vk.pubfn.isNull 相反 +vk.pubfn.isNotNull(value); + +// 检测所有参数 - 是否至少有一个为空 +vk.pubfn.isNullOne(value1,value2,value3,...); + +// 检测所有参数 - 是否全部为空 +vk.pubfn.isNullAll(value1,value2,value3,...); + +// 检测所有参数 - 是否全部都不为空 +vk.pubfn.isNotNullAll(value1,value2,value3,...); + +// 获取对象数组中的某一个item,根据指定的键值 +vk.pubfn.getListItem(list, key, value); + +// 产生指定位数的随机数(支持任意字符,默认纯数字) +vk.pubfn.random(6); +vk.pubfn.random(6,"abcdefghijklmnopqrstuvwxyz0123456789"); + +// 日期对象转字符串 两种格式 2020-09-19 10:10:10 和 20200919101010 +vk.pubfn.getFullTime(date); +``` +### 你也可以在评论区发布留言交流心得。 \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/package-lock.json b/cloudfunctions-aliyun/router/package-lock.json index fe5fe87..6b5934c 100644 --- a/cloudfunctions-aliyun/router/package-lock.json +++ b/cloudfunctions-aliyun/router/package-lock.json @@ -88,9 +88,9 @@ "version": "file:../common/uni-id" }, "vk-unicloud": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/vk-unicloud/-/vk-unicloud-1.2.4.tgz", - "integrity": "sha512-EOaZqusnqad2tUhkl7RYJlKcA5mAYJVuu5wmiyuWWHeoTEQSJU+PnOm3vqgNKXxRFVu48lxVgUXOeuwB0wMtcQ==" + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/vk-unicloud/-/vk-unicloud-1.3.3.tgz", + "integrity": "sha512-fjXgdzUHRXrIn5ODJS7jX+1E85OYGRbBrKsKHKlC8lzDbpF1rktPsi34RKuu2w78eY1yak6NQn9S2ssD0md6uw==" }, "xml2js": { "version": "0.4.23", diff --git a/cloudfunctions-aliyun/router/package.json b/cloudfunctions-aliyun/router/package.json index 53a2e61..777596c 100644 --- a/cloudfunctions-aliyun/router/package.json +++ b/cloudfunctions-aliyun/router/package.json @@ -14,7 +14,7 @@ "config": "file:../common/config", "nodemailer": "^6.4.11", "uni-id": "file:../common/uni-id", - "vk-unicloud": "^1.2.4" + "vk-unicloud": "^1.3.3" }, "private": true } diff --git a/cloudfunctions-aliyun/router/service/user/kh/acceptInvite.js b/cloudfunctions-aliyun/router/service/user/kh/acceptInvite.js index 12fb0a1..02341a2 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/acceptInvite.js +++ b/cloudfunctions-aliyun/router/service/user/kh/acceptInvite.js @@ -14,18 +14,17 @@ module.exports = { * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 */ - main: async (event) => { + main: async (event) => { let { data = {}, util, originalParam } = event; let { uniID } = util; let { uid, inviteCode = "" } = data; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- res = await uniID.acceptInvite({ uid:uid, inviteCode:inviteCode }); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/kh/bindAlipay.js b/cloudfunctions-aliyun/router/service/user/kh/bindAlipay.js index 6b47489..a068961 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/bindAlipay.js +++ b/cloudfunctions-aliyun/router/service/user/kh/bindAlipay.js @@ -13,13 +13,12 @@ module.exports = { * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 */ - main: async (event) => { + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- res = await uniID.bindAlipay(event.data); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/kh/bindEmail.js b/cloudfunctions-aliyun/router/service/user/kh/bindEmail.js index c656289..cf27739 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/bindEmail.js +++ b/cloudfunctions-aliyun/router/service/user/kh/bindEmail.js @@ -12,14 +12,13 @@ module.exports = { * res 返回参数说明 * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 - */ - main: async (event) => { + */ + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- res = await uniID.bindEmail(event.data); // 业务逻辑结束----------------------------------------------------------- - return res; - } - + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/kh/bindMobile.js b/cloudfunctions-aliyun/router/service/user/kh/bindMobile.js index 496137c..4570bc1 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/bindMobile.js +++ b/cloudfunctions-aliyun/router/service/user/kh/bindMobile.js @@ -13,14 +13,13 @@ module.exports = { * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 */ - main: async (event) => { + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- // 绑定手机号 res = await uniID.bindMobile(event.data); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/kh/bindWeixin.js b/cloudfunctions-aliyun/router/service/user/kh/bindWeixin.js index 7c069df..c35fe0e 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/bindWeixin.js +++ b/cloudfunctions-aliyun/router/service/user/kh/bindWeixin.js @@ -12,14 +12,13 @@ module.exports = { * res 返回参数说明 * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 - */ - main: async (event) => { + */ + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- res = await uniID.bindWeixin(event.data); // 业务逻辑结束----------------------------------------------------------- - return res; - } - + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/kh/getInvitedUser.js b/cloudfunctions-aliyun/router/service/user/kh/getInvitedUser.js index 28ec788..b29c07c 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/getInvitedUser.js +++ b/cloudfunctions-aliyun/router/service/user/kh/getInvitedUser.js @@ -22,21 +22,20 @@ module.exports = { * @params {String} mobile 被邀请者手机号 * @params {String} invite_time 被邀请者注册时间,以时间戳形式返回 * - */ - main: async (event) => { + */ + main: async (event) => { let { data = {}, util, originalParam } = event; let { uniID } = util; let { uid, limit, offset, needTotal } = data; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- res = await uniID.getInvitedUser({ uid:uid, limit:limit, offset:offset, needTotal:needTotal }); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/kh/resetPwd.js b/cloudfunctions-aliyun/router/service/user/kh/resetPwd.js index 25c618f..44d35c8 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/resetPwd.js +++ b/cloudfunctions-aliyun/router/service/user/kh/resetPwd.js @@ -13,16 +13,15 @@ module.exports = { * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 */ - main: async (event) => { + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- res = await uniID.resetPwd({ uid: event.data.uid, password: '123456' }); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/kh/setAvatar.js b/cloudfunctions-aliyun/router/service/user/kh/setAvatar.js index e3721ec..5ba5541 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/setAvatar.js +++ b/cloudfunctions-aliyun/router/service/user/kh/setAvatar.js @@ -13,13 +13,12 @@ module.exports = { * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 */ - main: async (event) => { + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- res = await uniID.setAvatar(event.data); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/kh/setUserInviteCode.js b/cloudfunctions-aliyun/router/service/user/kh/setUserInviteCode.js index f8c4608..087cb5a 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/setUserInviteCode.js +++ b/cloudfunctions-aliyun/router/service/user/kh/setUserInviteCode.js @@ -14,12 +14,12 @@ module.exports = { * @params {String} msg 详细信息 * @params {String} myInviteCode 最终设置的邀请码 */ - main: async (event) => { + main: async (event) => { let { data = {},userInfo, util, originalParam } = event; let { uniID } = util; let { uid } = data; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- // 判断下如果已经生成,则不再重新生成 if(userInfo.my_invite_code){ res = { @@ -32,8 +32,7 @@ module.exports = { uid:uid }); } - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/kh/unbindAlipay.js b/cloudfunctions-aliyun/router/service/user/kh/unbindAlipay.js index 469b3b3..0fe6c70 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/unbindAlipay.js +++ b/cloudfunctions-aliyun/router/service/user/kh/unbindAlipay.js @@ -12,13 +12,12 @@ module.exports = { * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 */ - main: async (event) => { + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- res = await uniID.unbindAlipay(event.data); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/kh/unbindEmail.js b/cloudfunctions-aliyun/router/service/user/kh/unbindEmail.js index 12dc4ea..d359511 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/unbindEmail.js +++ b/cloudfunctions-aliyun/router/service/user/kh/unbindEmail.js @@ -13,13 +13,12 @@ module.exports = { * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 */ - main: async (event) => { + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- res = await uniID.unbindEmail(event.data); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/kh/unbindMobile.js b/cloudfunctions-aliyun/router/service/user/kh/unbindMobile.js index d1864d6..bc7ecb4 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/unbindMobile.js +++ b/cloudfunctions-aliyun/router/service/user/kh/unbindMobile.js @@ -13,13 +13,12 @@ module.exports = { * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 */ - main: async (event) => { + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- res = await uniID.unbindMobile(event.data); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/kh/unbindWeixin.js b/cloudfunctions-aliyun/router/service/user/kh/unbindWeixin.js index df2469e..092f186 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/unbindWeixin.js +++ b/cloudfunctions-aliyun/router/service/user/kh/unbindWeixin.js @@ -11,14 +11,13 @@ module.exports = { * res 返回参数说明 * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 - */ - main: async (event) => { + */ + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- res = await uniID.unbindWeixin(event.data.uid); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/kh/updatePwd.js b/cloudfunctions-aliyun/router/service/user/kh/updatePwd.js index 28f95ac..3822533 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/updatePwd.js +++ b/cloudfunctions-aliyun/router/service/user/kh/updatePwd.js @@ -14,14 +14,13 @@ module.exports = { * res 返回参数说明 * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 - */ - main: async (event) => { + */ + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- res = await uniID.updatePwd(event.data); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/kh/updateUser.js b/cloudfunctions-aliyun/router/service/user/kh/updateUser.js index 1e5f23d..c377f70 100644 --- a/cloudfunctions-aliyun/router/service/user/kh/updateUser.js +++ b/cloudfunctions-aliyun/router/service/user/kh/updateUser.js @@ -15,13 +15,13 @@ module.exports = { * res 返回参数说明 * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 - */ - main: async (event) => { + */ + main: async (event) => { let { data = {}, util, originalParam } = event; let { uniID } = util; let { uid } = data; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- let updateKeys = ["nickname","avatar","gender"]; let dataJson = {}; for(let i in updateKeys){ @@ -30,8 +30,7 @@ module.exports = { } dataJson.uid = uid; res = await uniID.updateUser(dataJson); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/pub/checkToken.js b/cloudfunctions-aliyun/router/service/user/pub/checkToken.js index 49a8627..c7fd5e1 100644 --- a/cloudfunctions-aliyun/router/service/user/pub/checkToken.js +++ b/cloudfunctions-aliyun/router/service/user/pub/checkToken.js @@ -1,25 +1,24 @@ module.exports = { - /** - * 验证token是否有效 - * @url user/pub/checkToken 前端调用的url参数地址 - * @description 验证token是否有效(会返回uid) - * @params {Object} data 请求参数 - * @params {String} uniIdToken 用户token - * @params {Object} util 公共工具包 + /** + * 验证token是否有效 + * @url user/pub/checkToken 前端调用的url参数地址 + * @description 验证token是否有效(会返回uid) + * @params {Object} data 请求参数 + * @params {String} uniIdToken 用户token + * @params {Object} util 公共工具包 * res 返回参数说明 * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 * @params {String} uid 当前token对应的用户uid * @params {String} iat 当前token创建时间 * @params {String} exp 当前token过期时间 - */ - main: async (event) => { + */ + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- res = await uniID.checkToken(event.uniIdToken); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/pub/code2SessionAlipay.js b/cloudfunctions-aliyun/router/service/user/pub/code2SessionAlipay.js index d84ea5d..05ff32a 100644 --- a/cloudfunctions-aliyun/router/service/user/pub/code2SessionAlipay.js +++ b/cloudfunctions-aliyun/router/service/user/pub/code2SessionAlipay.js @@ -17,16 +17,15 @@ module.exports = { * @params {String} refreshToken 客户端为APP时返回,用于刷新accessToken * @params {String} reExpiresIn refreshToken超时时间,单位(秒) */ - main: async (event) => { + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- // 用户登录(账号+密码) - res = await uniID.code2SessionAlipay({ - code: event.data.code - }); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + res = await uniID.code2SessionAlipay({ + code: event.data.code + }); + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/pub/code2SessionWeixin.js b/cloudfunctions-aliyun/router/service/user/pub/code2SessionWeixin.js index d10b6c0..be96f3f 100644 --- a/cloudfunctions-aliyun/router/service/user/pub/code2SessionWeixin.js +++ b/cloudfunctions-aliyun/router/service/user/pub/code2SessionWeixin.js @@ -18,16 +18,15 @@ module.exports = { * @params {String} expiresIn 客户端为APP时返回,accessToken 接口调用凭证超时时间,单位(秒) * @params {String} refreshToken 客户端为APP时返回,用于刷新accessToken */ - main: async (event) => { + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- // 用户登录(账号+密码) - res = await uniID.code2SessionWeixin({ - code: event.data.code - }); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + res = await uniID.code2SessionWeixin({ + code: event.data.code + }); + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/pub/encryptPwd.js b/cloudfunctions-aliyun/router/service/user/pub/encryptPwd.js index 9ae9e32..2720ae0 100644 --- a/cloudfunctions-aliyun/router/service/user/pub/encryptPwd.js +++ b/cloudfunctions-aliyun/router/service/user/pub/encryptPwd.js @@ -11,10 +11,10 @@ module.exports = { * @params {String} msg 详细信息 * @params {String} password 加密后的字符串 */ - main: async (event) => { + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- // 验证token是否有效(会返回uid) const password = await uniID.encryptPwd('123456'); res = { @@ -22,8 +22,7 @@ module.exports = { msg: '密码加密完成', password } - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/pub/login.js b/cloudfunctions-aliyun/router/service/user/pub/login.js index 3e5e812..1ccbe7e 100644 --- a/cloudfunctions-aliyun/router/service/user/pub/login.js +++ b/cloudfunctions-aliyun/router/service/user/pub/login.js @@ -1,11 +1,11 @@ module.exports = { - /** - * 用户登录(账号+密码) - * @url user/pub/login 前端调用的url参数地址 - * @description 用户登录(账号+密码) - * @params {Object} data 请求参数 - * @params {String} uniIdToken 用户token - * @params {Object} util 公共工具包 + /** + * 用户登录(账号+密码) + * @url user/pub/login 前端调用的url参数地址 + * @description 用户登录(账号+密码) + * @params {Object} data 请求参数 + * @params {String} uniIdToken 用户token + * @params {Object} util 公共工具包 * data 请求参数 说明 * @params {String} username 用户名 * @params {String} password 密码 @@ -14,13 +14,13 @@ module.exports = { * @params {String} msg 详细信息 * @params {String} token 登录成功之后返回的token信息 * @params {String} tokenExpired token过期时间 - */ - main: async (event) => { + */ + main: async (event) => { let { data = {}, util, originalParam } = event; let { uniID, config, pubFun, vk , db, _ } = util; let { uid } = data; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- // 用户登录(账号+密码) res = await uniID.login({ ...event.data, @@ -41,8 +41,8 @@ module.exports = { "platform": originalParam.context.PLATFORM },event.util); } - // 业务逻辑结束----------------------------------------------------------- - return res; - } + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/pub/loginByAlipay.js b/cloudfunctions-aliyun/router/service/user/pub/loginByAlipay.js index 33ae7a8..345852e 100644 --- a/cloudfunctions-aliyun/router/service/user/pub/loginByAlipay.js +++ b/cloudfunctions-aliyun/router/service/user/pub/loginByAlipay.js @@ -14,12 +14,12 @@ module.exports = { * @params {String} token 登录成功之后返回的token信息 * @params {String} tokenExpired token过期时间 */ - main: async (event) => { + main: async (event) => { let { data = {}, util, originalParam } = event; let { uniID, config, pubFun, vk , db, _ } = util; let { uid } = data; let res = {}; - // 业务逻辑开始----------------------------------------------------------- + // 业务逻辑开始----------------------------------------------------------- res = await uniID.loginByAlipay(event.data.code); if(res.token){ // 日志服务 @@ -35,8 +35,7 @@ module.exports = { "platform": originalParam.context.PLATFORM },event.util); } - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/pub/loginByEmail.js b/cloudfunctions-aliyun/router/service/user/pub/loginByEmail.js index e52f585..cdab025 100644 --- a/cloudfunctions-aliyun/router/service/user/pub/loginByEmail.js +++ b/cloudfunctions-aliyun/router/service/user/pub/loginByEmail.js @@ -15,12 +15,12 @@ module.exports = { * @params {String} token 登录成功之后返回的token信息 * @params {String} tokenExpired token过期时间 */ - main: async (event) => { + main: async (event) => { let { data = {}, util, originalParam } = event; let { uniID, config, pubFun, vk , db, _ } = util; let { uid } = data; let res = {}; - // 业务逻辑开始----------------------------------------------------------- + // 业务逻辑开始----------------------------------------------------------- res = await uniID.loginByEmail(event.data); if(res.token){ // 日志服务 @@ -36,8 +36,7 @@ module.exports = { "platform": originalParam.context.PLATFORM },event.util); } - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/pub/loginBySms.js b/cloudfunctions-aliyun/router/service/user/pub/loginBySms.js index 6546474..f9f04ef 100644 --- a/cloudfunctions-aliyun/router/service/user/pub/loginBySms.js +++ b/cloudfunctions-aliyun/router/service/user/pub/loginBySms.js @@ -15,12 +15,12 @@ module.exports = { * @params {String} token 登录成功之后返回的token信息 * @params {String} tokenExpired token过期时间 */ - main: async (event) => { + main: async (event) => { let { data = {}, util, originalParam } = event; let { uniID, config, pubFun, vk , db, _ } = util; let { uid } = data; let res = {}; - // 业务逻辑开始----------------------------------------------------------- + // 业务逻辑开始----------------------------------------------------------- res = await uniID.loginBySms(event.data); // 修改用户昵称为:手机尾号xxxx用户 if(res.token){ @@ -50,8 +50,7 @@ module.exports = { "platform": originalParam.context.PLATFORM },event.util); } - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/pub/loginByWeixin.js b/cloudfunctions-aliyun/router/service/user/pub/loginByWeixin.js index 7bb98fc..cb8970a 100644 --- a/cloudfunctions-aliyun/router/service/user/pub/loginByWeixin.js +++ b/cloudfunctions-aliyun/router/service/user/pub/loginByWeixin.js @@ -14,12 +14,12 @@ module.exports = { * @params {String} token 登录成功之后返回的token信息 * @params {String} tokenExpired token过期时间 */ - main: async (event) => { + main: async (event) => { let { data = {}, util, originalParam } = event; let { uniID, config, pubFun, vk , db, _ } = util; let { uid } = data; let res = {}; - // 业务逻辑开始----------------------------------------------------------- + // 业务逻辑开始----------------------------------------------------------- // 微信登录(未绑定任何账号时,会新建账号) res = await uniID.loginByWeixin(event.data.code); if(res.token){ @@ -36,8 +36,7 @@ module.exports = { "platform": originalParam.context.PLATFORM },event.util); } - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/pub/logout.js b/cloudfunctions-aliyun/router/service/user/pub/logout.js index 8a36710..9a9f1b9 100644 --- a/cloudfunctions-aliyun/router/service/user/pub/logout.js +++ b/cloudfunctions-aliyun/router/service/user/pub/logout.js @@ -9,14 +9,13 @@ module.exports = { * res 返回参数说明 * @params {Number} code 错误码,0表示成功 * @params {String} msg 详细信息 - */ - main: async (event) => { + */ + main: async (event) => { let {uniID} = event.util; - let res = {}; - // 业务逻辑开始----------------------------------------------------------- + let res = {}; + // 业务逻辑开始----------------------------------------------------------- res = await uniID.logout(event.uniIdToken); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/pub/register.js b/cloudfunctions-aliyun/router/service/user/pub/register.js index 939efe7..a3f08f5 100644 --- a/cloudfunctions-aliyun/router/service/user/pub/register.js +++ b/cloudfunctions-aliyun/router/service/user/pub/register.js @@ -15,12 +15,12 @@ module.exports = { * @params {String} token 注册完成自动登录之后返回的token信息 * @params {String} tokenExpired token过期时间 */ - main: async (event) => { + main: async (event) => { let { data = {}, userInfo, util, originalParam } = event; let { uniID, config, pubFun, vk , db, _ } = util; let { uid, username, password } = data; let res = { code : -1, msg : '' }; - // 业务逻辑开始----------------------------------------------------------- + // 业务逻辑开始----------------------------------------------------------- // username必须以字母开头,长度在6~18之间,只能包含字母、数字和下划线 if(!vk.pubfn.checkStr(username,"username")){ return { @@ -36,8 +36,7 @@ module.exports = { }; } res = await uniID.register(event.data); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/pub/sendEmailCode.js b/cloudfunctions-aliyun/router/service/user/pub/sendEmailCode.js index d02024f..e20e90b 100644 --- a/cloudfunctions-aliyun/router/service/user/pub/sendEmailCode.js +++ b/cloudfunctions-aliyun/router/service/user/pub/sendEmailCode.js @@ -59,5 +59,5 @@ module.exports = { } // 业务逻辑结束----------------------------------------------------------- return res; - } + } } diff --git a/cloudfunctions-aliyun/router/service/user/pub/sendSmsCode.js b/cloudfunctions-aliyun/router/service/user/pub/sendSmsCode.js index 82a10fd..8dce4bc 100644 --- a/cloudfunctions-aliyun/router/service/user/pub/sendSmsCode.js +++ b/cloudfunctions-aliyun/router/service/user/pub/sendSmsCode.js @@ -14,13 +14,13 @@ module.exports = { * @params {String} msg 详细信息 * @params {String} mobile 手机号 * @params {String} verifyCode 验证码 - */ - main: async (event) => { + */ + main: async (event) => { let { data = {}, userInfo, util, originalParam } = event; let { uniID, config, pubFun, vk , db, _ } = util; let { uid } = data; let res = { code : 0, msg : '' }; - // 业务逻辑开始----------------------------------------------------------- + // 业务逻辑开始----------------------------------------------------------- let { mobile, type } = data; const randomStr = '00000' + Math.floor(Math.random() * 1000000); let code = randomStr.substring(randomStr.length - 6); @@ -48,7 +48,7 @@ module.exports = { // 使用uni-短信 res = await uniID.sendSmsCode(param); } - // 业务逻辑结束----------------------------------------------------------- - return res; - } + // 业务逻辑结束----------------------------------------------------------- + return res; + } } diff --git a/cloudfunctions-aliyun/router/service/user/pub/setVerifyCode.js b/cloudfunctions-aliyun/router/service/user/pub/setVerifyCode.js index 45d7648..5a80330 100644 --- a/cloudfunctions-aliyun/router/service/user/pub/setVerifyCode.js +++ b/cloudfunctions-aliyun/router/service/user/pub/setVerifyCode.js @@ -16,16 +16,15 @@ module.exports = { * @params {String} email 邮箱 * @params {String} mobile 手机号 * @params {String} verifyCode 验证码(uni 1.1.2开始不再返回verifyCode) - */ - main: async (event) => { + */ + main: async (event) => { let { data = {}, util } = event; let { uniID } = util; let { email, mobile, code, type } = data; let res = {code : -1, msg : ''}; - // 业务逻辑开始----------------------------------------------------------- + // 业务逻辑开始----------------------------------------------------------- res = await uniID.setVerifyCode(data); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/sys/test1.js b/cloudfunctions-aliyun/router/service/user/sys/test1.js index c4ec9b7..4c633dc 100644 --- a/cloudfunctions-aliyun/router/service/user/sys/test1.js +++ b/cloudfunctions-aliyun/router/service/user/sys/test1.js @@ -14,14 +14,13 @@ module.exports = { * @params {String} msg 详细信息 * @params {String} token 注册完成自动登录之后返回的token信息 * @params {String} tokenExpired token过期时间 - */ - main: async (event) => { + */ + main: async (event) => { let {uniID} = event.util; - let res = {code :-1, msg : ''}; - // 业务逻辑开始----------------------------------------------------------- + let res = {code :-1, msg : ''}; + // 业务逻辑开始----------------------------------------------------------- // res = await uniID.loginByAlipay(event.data.code); - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/cloudfunctions-aliyun/router/service/user/util/login_log.js b/cloudfunctions-aliyun/router/service/user/util/login_log.js index f87551f..a3abfc8 100644 --- a/cloudfunctions-aliyun/router/service/user/util/login_log.js +++ b/cloudfunctions-aliyun/router/service/user/util/login_log.js @@ -1,34 +1,33 @@ module.exports = { - /** - * 登录日志 - */ - add: async (event,util) => { + /** + * 登录日志 + */ + add: async (event,util) => { let { uniID, config, pubFun, vk , db, _ } = util; - let res = { code : 0, msg : '' }; - // 业务逻辑开始----------------------------------------------------------- + let res = { code : 0, msg : '' }; + // 业务逻辑开始----------------------------------------------------------- if(vk.pubfn.getData(config, "vk.service.log.login.status")){ // 增加登录日志 try { - await vk.baseDao.add({ - dbName:"uni-id-log", - dataJson:{ + await vk.baseDao.add({ + dbName:"uni-id-log", + dataJson:{ "type": event.type, "login_type": event.login_type, "user_id": event.uid, - "ip": event.ip, - "ua": event.ua, + "ip": event.ip, + "ua": event.ua, "os": event.os, "platform": event.platform - } - },util); + } + },util); }catch(err){ console.log("日志写入错误"); } }else{ console.log("已关闭登录日志"); } - // 业务逻辑结束----------------------------------------------------------- - return res; - } - + // 业务逻辑结束----------------------------------------------------------- + return res; + } } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 7879439..63ed938 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "uview-ui": { - "version": "1.6.9", - "resolved": "https://registry.npmjs.org/uview-ui/-/uview-ui-1.6.9.tgz", - "integrity": "sha512-YTfhAgUO+OXrNmib+SXP6KOxzFEyJu1rloKb0tgL0herkmeQ/6KfsmGnsMGz7z/nC9/mkrZ68iQ8IMcykryYhg==" + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/uview-ui/-/uview-ui-1.7.1.tgz", + "integrity": "sha512-e2s7F7omTHxzdrE8kPtiaEof5LC4ADeY4m6i6ROqLoA0VCEqC2Y4SNGXZKW3y9D04z2EKX239w1l3H1jtdLTow==" }, "vk-unicloud-dynamic-components": { "version": "1.0.6", @@ -15,11 +15,11 @@ "integrity": "sha512-lvlkpkW/d0VaFFOd91EbJF954KDKCbCmexGo3o1FEiclSwToVgX/p39eVOAiFskPBr2kkqPEckfX42h8kHIeXQ==" }, "vk-unicloud-page": { - "version": "1.4.6", - "resolved": "https://registry.npmjs.org/vk-unicloud-page/-/vk-unicloud-page-1.4.6.tgz", - "integrity": "sha512-FmFwwkhaMWPsWRZQVcADjrvJX76Fx3r4H1W2scpmcF425RjYQaZYLMY46JymdsfCHyqIcRbSkghVy6WEUZhzUg==", + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/vk-unicloud-page/-/vk-unicloud-page-1.6.2.tgz", + "integrity": "sha512-+EoTLPfTjRNBx4EupSwcif6bM3UmHAchGzHPfqe92rQATmmN81TpZSbGRP0eXMeQkiBLfyaG1T3ZklJR7kwdsQ==", "requires": { - "uview-ui": "~1.6.9", + "uview-ui": "~1.7.1", "vk-unicloud-dynamic-components": "~1.0.6" } } diff --git a/package.json b/package.json index e0a398c..01a2037 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "【开箱即用】vk-uniCloud-router - 云函数路由模式 - uniCloud开发框架 - 已集成uni-id", "main": "main.js", "dependencies": { - "vk-unicloud-page": "^1.4.6" + "vk-unicloud-page": "^1.6.2" }, "devDependencies": {}, "scripts": { -- GitLab