diff --git a/template.h5.html b/template.h5.html index 8b54dea0bd5254d2e7863659c9220a11bdae4d91..a9de5dbfba99b08e9696ad271ee49adb7238c8dd 100644 --- a/template.h5.html +++ b/template.h5.html @@ -40,6 +40,7 @@ document.querySelector('#gg').addEventListener('click',e=>{ console.log(e); alert(12) + window.location.href = "https://m3w.cn/uniapp" }) },1000) diff --git a/uni_modules/opendb-feedback/uniCloud/database/opendb-feedback.schema.json b/uni_modules/opendb-feedback/uniCloud/database/opendb-feedback.schema.json deleted file mode 100644 index 0decc34aab2a31cb95a10fc2665f98a437493e3c..0000000000000000000000000000000000000000 --- a/uni_modules/opendb-feedback/uniCloud/database/opendb-feedback.schema.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "bsonType": "object", - "permission": { - "read": "doc.is_reply == false", - "create": true, - "update": false, - "delete": false - }, - "properties": { - "_id": { - "description": "ID,系统自动生æˆ" - }, - "user_id": { - "bsonType": "string", - "description": "留言å馈用户ID\/回å¤ç•™è¨€ç”¨æˆ·ID,å‚考uni-id-users表", - "foreignKey": "uni-id-users._id", - "forceDefaultValue": { - "$env": "uid" - } - }, - "title": { - "description": "åé¦ˆæ ‡é¢˜ï¼ˆç”¨äºŽåˆ—è¡¨å±•ç¤ºï¼‰" - }, - "ip": { - "forceDefaultValue": { - "$env": "clientIP" - } - }, - "create_date": { - "bsonType": "timestamp", - "description": "留言时间\/回å¤ç•™è¨€æ—¶é—´", - "forceDefaultValue": { - "$env": "now" - } - }, - "content": { - "bsonType": "string", - "description": "留言内容\/回å¤å†…容", - "trim": "right" - }, - "imgs": { - "bsonType": "array", - "description": "图片列表" - }, - "is_reply": { - "bsonType": "bool", - "description": "是å¦æ˜¯å›žå¤ç±»åž‹" - }, - "feedback_id": { - "bsonType": "string", - "description": "被回å¤ç•™è¨€ID" - }, - "contact": { - "bsonType": "string", - "description": "è”系人", - "trim": "both" - }, - "mobile": { - "bsonType": "string", - "description": "è”系电è¯", - "trim": "both" - }, - "reply_count": { - "bsonType": "int", - "description": "被回å¤æ¡æ•°" - } - } -} diff --git a/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user-center/index.js b/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user-center/index.js deleted file mode 100644 index 250f4b182042bdc84f984a4144ef4e7568095e87..0000000000000000000000000000000000000000 --- a/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user-center/index.js +++ /dev/null @@ -1,224 +0,0 @@ -'use strict'; -let uniID = require('uni-id') -const uniCaptcha = require('uni-captcha') -const db = uniCloud.database() -const dbCmd = db.command -exports.main = async (event, context) => { - /** - * UNI_WYQ:这里的uniIDæ¢æˆæ–°çš„,ä¿è¯å¤šäººè®¿é—®ä¸ä¼šå†²çª - */ - uniID = uniID.createInstance({ - context - }) - //eventä¸ºå®¢æˆ·ç«¯ä¸Šä¼ çš„å‚æ•° - console.log('event : ' + JSON.stringify(event)) - let params = event.params || {} - - //防æ¢é»‘客æ¶æ„ç ´è§£ç™»é™†ï¼Œè¿žç»ç™»é™†å¤±è´¥ä¸€å®šæ¬¡æ•°åŽï¼Œéœ€è¦ç”¨æˆ·æ供验è¯ç - const getNeedCaptcha = async () => { - //当用户最近“2å°æ—¶å†…(recordDate)â€ç™»é™†å¤±è´¥è¾¾åˆ°2次(recordSize)时。è¦æ±‚用户æ交验è¯ç - const now = Date.now(), - recordDate = 120 * 60 * 1000, - recordSize = 2; - const uniIdLogCollection = db.collection('uni-id-log') - let recentRecord = await uniIdLogCollection.where({ - deviceId: params.deviceId || context.DEVICEID, - create_date: dbCmd.gt(now - recordDate), - type: 'login' - }) - .orderBy('create_date', 'desc') - .limit(recordSize) - .get(); - return recentRecord.data.filter(item => item.state === 0).length === recordSize; - } - - //设置æŸäº›æ¨¡å—ä¸éœ€è¦token(也就是登陆æˆåŠŸåŽï¼‰æ‰èƒ½æ“作,如果需è¦token就获å–当å‰æ“作账户的uid - let noCheckAction = [ - 'register', 'checkToken','login', 'logout', 'sendSmsCode', - 'createCaptcha', 'verifyCaptcha','refreshCaptcha', 'inviteLogin', - 'login_by_weixin','login_by_univerify','login_by_apple','loginBySms' - ] - let payload; - console.log(event.action); - if (!noCheckAction.includes(event.action)) { - if (!event.uniIdToken) { - return { - code: 403, - msg: '缺少token' - } - } - payload = await uniID.checkToken(event.uniIdToken) - if (payload.code && payload.code > 0) { - return payload - } - params.uid = payload.uid - } - - - //记录æˆåŠŸç™»é™†çš„日志 - const loginLog = async (res = {}, type = 'login') => { - const now = Date.now() - const uniIdLogCollection = db.collection('uni-id-log') - let logData = { - deviceId: params.deviceId || context.DEVICEID, - ip: params.ip || context.CLIENTIP, - type, - ua: context.CLIENTUA, - create_date: now - }; - - Object.assign(logData, - res.code === 0 ? { - user_id: res.uid, - state: 1 - } : { - state: 0 - }) - - return uniIdLogCollection.add(logData) - } - - - - let res = {} - switch (event.action) { - case 'register': - res = await uniID.register(params); - break; - case 'login': - let passed = false; - let needCaptcha = await getNeedCaptcha(); - - if (needCaptcha) { - res = await uniCaptcha.verify(params) - if (res.code === 0) passed = true; - } - - if (!needCaptcha || passed) { - res = await uniID.login({ - ...params, - queryField: ['username', 'email', 'mobile'] - }); - await loginLog(res); - needCaptcha = await getNeedCaptcha(); - } - - res.needCaptcha = needCaptcha; - break; - case 'login_by_weixin': - res = await uniID.loginByWeixin(params); - await uniID.updateUser({ - uid: params.uid, - username:"微信用户" - }); - res.userInfo.username = "微信用户" - loginLog(res) - break; - case 'login_by_univerify': - res = await uniID.loginByUniverify(params) - break; - case 'login_by_apple': - res = await uniID.loginByApple(params) - loginLog(res) - break; - case 'checkToken': - res = await uniID.checkToken(event.uniIdToken); - break; - case 'logout': - res = await uniID.logout(event.uniIdToken) - break; - case 'sendSmsCode': - // 简å•é™åˆ¶ä¸€ä¸‹å®¢æˆ·ç«¯è°ƒç”¨é¢‘率 - const ipLimit = await db.collection('uni-verify').where({ - ip: context.CLIENTIP, - created_at: dbCmd.gt(Date.now() - 60000) - }).get() - if (ipLimit.data.length > 0) { - return { - code: 429, - msg: '请求过于频ç¹' - } - } - const templateId = '11753' // 替æ¢ä¸ºè‡ªå·±ç”³è¯·çš„模æ¿id - if (!templateId) { - return { - code: 500, - msg: 'sendSmsCode需è¦ä¼ 入自己的templateId,å‚考https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=sendsmscode' - } - } - const randomStr = '00000' + Math.floor(Math.random() * 1000000) - const code = randomStr.substring(randomStr.length - 6) - res = await uniID.sendSmsCode({ - mobile: params.mobile, - code, - type: params.type, - templateId - }) - break; - case 'loginBySms': - if (!params.code) { - return { - code: 500, - msg: '请填写验è¯ç ' - } - } - if (!/^1\d{10}$/.test(params.mobile)) { - return { - code: 500, - msg: '手机å·ç 填写错误' - } - } - res = await uniID.loginBySms(params) - loginLog(res) - break; - case 'inviteLogin': - if (!params.code) { - return { - code: 500, - msg: '请填写验è¯ç ' - } - } - res = await uniID.loginBySms({ - ...params, - type: 'register' - }) - break; - case 'getInviteCode': - res = await uniID.getUserInfo({ - uid: params.uid, - field: ['my_invite_code'] - }) - if (res.code === 0) { - res.myInviteCode = res.userInfo.my_invite_code - delete res.userInfo - } - break; - case 'getInvitedUser': - res = await uniID.getInvitedUser(params) - break; - case 'updatePwd': - res = await uniID.updatePwd({ - uid: params.uid, - ...params - }) - break; - case 'createCaptcha': - res = await uniCaptcha.create(params) - break; - case 'refreshCaptcha': - res = await uniCaptcha.refresh(params) - break; - case 'resetPwd': - res = await uniID.resetPwd({...params,"uid":payload.uid}) - break; - default: - res = { - code: 403, - msg: 'éžæ³•è®¿é—®' - } - break; - } - - //返回数æ®ç»™å®¢æˆ·ç«¯ - return res -}; diff --git a/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user-center/package-lock.json b/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user-center/package-lock.json deleted file mode 100644 index 19af4cbc10b520fbd82b542d018043b149a39798..0000000000000000000000000000000000000000 --- a/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user-center/package-lock.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "user-center", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "uni-captcha": { - "version": "file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha" - }, - "uni-config-center": { - "version": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center" - }, - "uni-id": { - "version": "file:../../../../uni-id/uniCloud/cloudfunctions/common/uni-id", - "requires": { - "uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center" - }, - "dependencies": { - "uni-config-center": { - "version": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center" - } - } - } - } -} diff --git a/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user-center/package.json b/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user-center/package.json deleted file mode 100644 index 0d50d88175e3e3b187d207dea4f3380a851e72af..0000000000000000000000000000000000000000 --- a/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user-center/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "user-center", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "dependencies": { - "uni-captcha": "file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha", - "uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center", - "uni-id": "file:../../../../uni-id/uniCloud/cloudfunctions/common/uni-id" - } -} diff --git a/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/index.js b/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/index.js deleted file mode 100644 index f52b2416b5a418af55ccd4a4ffe9eee4e6637cc8..0000000000000000000000000000000000000000 --- a/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/index.js +++ /dev/null @@ -1,82 +0,0 @@ -'use strict'; -const uniID = require('uni-id') -const uniCaptcha = require('uni-captcha') -const db = uniCloud.database() -const dbCmd = db.command -let params,context,res; -class User { - async quickLogin(){ - let {access_token,openid,type} = params - switch (type){ - case 'weixin': - let userinfo_res = await uniCloud.httpclient.request('https://api.weixin.qq.com/sns/userinfo', - { - method: 'GET', - dataType:"json", - data:{ access_token,openid} - }); - return userinfo_res.data//æ ¹æ®access_token,openid得到userinfo - //检查是å¦å·²ç»æ³¨å†Œ... - break; - case 'univerify': - return uniID.loginByUniverify({access_token,openid}) - break; - case 'apple': - return await uniID.loginByApple(params) - break; - default: - return {"code":100,"msg":"æš‚ä¸æä¾›"+type+"登陆的云端接å£æ¼”示"} - break; - } - } - async sendSmsCode(){ - // 简å•é™åˆ¶ä¸€ä¸‹å®¢æˆ·ç«¯è°ƒç”¨é¢‘率 - const ipLimit = await db.collection('uni-verify').where({ - ip: context.CLIENTIP, - created_at: dbCmd.gt(Date.now() - 60000) - }).get() - if (ipLimit.data.length > 0) { - return { - code: 429, - msg: '请求过于频ç¹' - } - } - const templateId = '11753' // 替æ¢ä¸ºè‡ªå·±ç”³è¯·çš„模æ¿id - if (!templateId) { - return { - code: 500, - msg: 'sendSmsCode需è¦ä¼ 入自己的templateId,å‚考https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=sendsmscode' - } - } - const randomStr = '00000' + Math.floor(Math.random() * 1000000) - const code = randomStr.substring(randomStr.length - 6) - return await uniID.sendSmsCode({ - mobile: params.mobile, - code, - type: params.type, - templateId - }) - } -} -const userClass = new User(); -exports.main = async (event, ctx) => { - [{params},context] = [event,ctx] - //1.判æ–需è¦tokençš„action是å¦æœ‰token - /*let noCheckAction = ['register', 'loginByWeixin', 'checkToken','login', 'logout', 'sendSmsCode','loginBySms', 'inviteLogin', 'loginByUniverify','loginByApple', 'createCaptcha', 'verifyCaptcha','refreshCaptcha'] - if(!noCheckAction.includes(event.action)) { - if (!event.uniIdToken) { - return {"code":403,"msg":"缺少token"} - } - let payload = {} - payload = await uniID.checkToken(event.uniIdToken) - if (payload.code && payload.code > 0) { - return payload - } - params.uid = payload.uid - }*/ - try{ - return await userClass[event.action]()||res; - }catch(err){ - return {"code":404,"msg":err} - } -} \ No newline at end of file diff --git a/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/package-lock.json b/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/package-lock.json deleted file mode 100644 index 1409abcb14d28a497bbe175252bddae01557d41d..0000000000000000000000000000000000000000 --- a/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/package-lock.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "user", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "uni-captcha": { - "version": "file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha" - }, - "uni-config-center": { - "version": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center" - }, - "uni-id": { - "version": "file:../../../../uni-id/uniCloud/cloudfunctions/common/uni-id", - "requires": { - "uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center" - }, - "dependencies": { - "uni-config-center": { - "version": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center" - } - } - } - } -} diff --git a/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/package.json b/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/package.json deleted file mode 100644 index 965bf274cb22107b31b692a78c0e33eaee48e095..0000000000000000000000000000000000000000 --- a/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "user", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "dependencies": { - "uni-captcha": "file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha", - "uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center", - "uni-id": "file:../../../../uni-id/uniCloud/cloudfunctions/common/uni-id" - } -} diff --git a/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/user.param.json b/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/user.param.json deleted file mode 100644 index f0ec7f1310f9e40c0fcd8e1ea8297d311e08d999..0000000000000000000000000000000000000000 --- a/uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/user.param.json +++ /dev/null @@ -1,8 +0,0 @@ -// 本文件ä¸çš„json内容将在云函数ã€è¿è¡Œã€‘时作为å‚æ•°ä¼ ç»™äº‘å‡½æ•°ã€‚ -// é…置教程å‚考:https://uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam -{ - "action": "sendSmsCode", - "params": { - "phone":"17769516081" - } -}