diff --git a/app.js b/app.js index 1443456..5a07f0a 100644 --- a/app.js +++ b/app.js @@ -1,561 +1,589 @@ // app.js App({ - onLaunch:function(){ - wx.cloud.init({ - //env:"apeach-wtz62" - env:'cloud1-5ggzbo3kcd4ea4e2' - }) - }, - // 全局变量 - globalData: { - url: null - }, - - globalData:{ - clothes:[{ - name:"t-shirt1", - pattern:"up", - kind:"t-shirt", - style:"leisure", - colour:"white", - T:-5, - thickness:"thin", - season:"summer" - },{ - name:"t-shirt2", - pattern:"up", - kind:"t-shirt", - style:"leisure", - colour:"red", - T:-5, - thickness:"thin", - season:"summer" - },{ - name:"t-shirt3", - pattern:"up", - kind:"t-shirt", - style:"leisure", - colour:"orange", - T:-5, - thickness:"thin", - season:"summer" - },{ - name:"t-shirt4", - pattern:"up", - kind:"t-shirt", - style:"leisure", - colour:"black", - T:-5, - thickness:"thin", - season:"summer" - },{ - name:"t-shirt5", - pattern:"up", - kind:"t-shirt", - style:"leisure", - colour:"red", - T:-5, - thickness:"thin", - season:"summer" - },{ - name:"t-shirt6", - pattern:"up", - kind:"t-shirt", - style:"leisure", - colour:"purple", - T:-5, - thickness:"thin", - season:"summer" - },{ - name:"t-shirt7", - pattern:"up", - kind:"t-shirt", - style:"leisure", - colour:"green", - T:-5, - thickness:"thin", - season:"summer" - },{ - name:"t-shirt8", - pattern:"up", - kind:"t-shirt", - style:"sports", - colour:"white", - T:-5, - thickness:"thin", - season:"summer" - },{ - name:"t-shirt9", - pattern:"up", - kind:"t-shirt", - style:"sports", - colour:"black", - T:-4, - thickness:"thin", - season:"summer" - },{ - name:"t-shirt10", - pattern:"up", - kind:"t-shirt", - style:"leisure", - colour:"blue", - T:-5, - thickness:"thin", - season:"summer" - },{ - name:"hoodie1", - pattern:"up", - kind:"hoodie", - style:"leisure", - colour:"white", - T:2, - thickness:"thin", - season:"spring" - },{ - name:"hoodie2", - pattern:"up", - kind:"hoodie", - style:"leisure", - colour:"brown", - T:5, - thickness:"thin", - season:"winter" - },{ - name:"hoodie3", - pattern:"up", - kind:"hoodie", - style:"leisure", - colour:"white", - T:5, - thickness:"thin", - season:"winter" - },{ - name:"hoodie4", - pattern:"up", - kind:"hoodie", - style:"leisure", - colour:"black", - T:3, - thickness:"proper", - season:"autumn" - },{ - name:"hoodie5", - pattern:"up", - kind:"hoodie", - style:"sports", - colour:"yellow", - T:3, - thickness:"proper", - season:"spring" - },{ - name:"hoodie6", - pattern:"up", - kind:"hoodie", - style:"leisure", - colour:"black", - T:4, - thickness:"proper", - season:"spring" - },{ - name:"hoodie7", - pattern:"up", - kind:"hoodie", - style:"leisure", - colour:"white", - T:3, - thickness:"proper", - season:"autumn" - },{ - name:"hoodie8", - pattern:"up", - kind:"hoodie", - style:"sports", - colour:"white", - T:3, - thickness:"proper", - season:"autumn" - },{ - name:"hoodie9", - pattern:"up", - kind:"hoodie", - style:"sports", - colour:"pink", - T:5, - thickness:"thick", - season:"winter" - },{ - name:"hoodie10", - pattern:"up", - kind:"hoodie", - style:"sports", - colour:"green", - T:4, - thickness:"proper", - season:"spring" - },{ - name:"skirt1", - pattern:"down", - kind:"skirt", - style:"leisure", - colour:"blue", - T:-5, - thickness:"thin", - season:"summer" - },{ - name:"skirt2", - pattern:"down", - kind:"skirt", - style:"business", - colour:"brown", - T:3, - thickness:"thin", - season:"winter" - },{ - name:"skirt3", - pattern:"down", - kind:"skirt", - style:"sport", - colour:"white", - T:-5, - thickness:"thin", - season:"summer" - },{ - name:"skirt4", - pattern:"down", - kind:"skirt", - style:"leisure", - colour:"brown", - T:2, - thickness:"proper", - season:"autumn" - },{ - name:"skirt5", - pattern:"all", - kind:"skirt", - style:"leisure", - colour:"red", - T:-10, - thickness:"thin", - season:"summer" - },{ - name:"skirt6", - pattern:"all", - kind:"skirt", - style:"business", - colour:"white", - T:-10, - thickness:"thin", - season:"summer" - },{ - name:"skirt7", - pattern:"all", - kind:"skirt", - style:"leisure", - colour:"black", - T:5, - thickness:"proper", - season:"autumn" - },{ - name:"skirt8", - pattern:"down", - kind:"skirt", - style:"business", - colour:"black", - T:-5, - thickness:"thin", - season:"autumn" - },{ - name:"skirt9", - pattern:"down", - kind:"skirt", - style:"leisure", - colour:"pink", - T:1, - thickness:"proper", - season:"spring" - },{ - name:"skirt10", - pattern:"all", - kind:"skirt", - style:"leisure", - colour:"white", - T:-10, - thickness:"thin", - season:"summer" - },{ - name:"coat1", - pattern:"up", - kind:"coat", - style:"leisure", - colour:"black", - T:5, - thickness:"proper", - season:"autumn" - },{ - name:"coat2", - pattern:"up", - kind:"coat", - style:"leisure", - colour:"white", - T:4, - thickness:"proper", - season:"autumn" - },{ - name:"coat3", - pattern:"up", - kind:"coat", - style:"business", - colour:"white", - T:2, - thickness:"thin", - season:"spring" - },{ - name:"coat4", - pattern:"up", - kind:"coat", - style:"business", - colour:"red", - T:5, - thickness:"thick", - season:"winter" - },{ - name:"coat5", - pattern:"up", - kind:"coat", - style:"leisure", - colour:"white", - T:1, - thickness:"thin", - season:"summer" - },{ - name:"coat6", - pattern:"up", - kind:"coat", - style:"leisure", - colour:"black", - T:9, - thickness:"thick", - season:"winter" - },{ - name:"coat7", - pattern:"up", - kind:"coat", - style:"sports", - colour:"black", - T:3, - thickness:"thin", - season:"spring" - },{ - name:"coat8", - pattern:"up", - kind:"coat", - style:"leisure", - colour:"pink", - T:5, - thickness:"proper", - season:"autumn" - },{ - name:"coat9", - pattern:"up", - kind:"coat", - style:"leisure", - colour:"white", - T:10, - thickness:"thick", - season:"winter" - },{ - name:"coat10", - pattern:"up", - kind:"coat", - style:"leisure", - colour:"khaki", - T:3, - thickness:"thin", - season:"autumn" - },{ - name:"sweater1", - pattern:"up", - kind:"sweater", - style:"leisure", - colour:"white", - T:3, - thickness:"thin", - season:"autumn" - },{ - name:"sweater2", - pattern:"up", - kind:"sweater", - style:"leisure", - colour:"black", - T:4, - thickness:"thick", - season:"winter" - },{ - name:"sweater3", - pattern:"up", - kind:"sweater", - style:"leisure", - colour:"blue", - T:4, - thickness:"thick", - season:"winter" - },{ - name:"sweater4", - pattern:"up", - kind:"sweater", - style:"leisure", - colour:"blue", - T:4, - thickness:"thick", - season:"winter" - },{ - name:"sweater5", - pattern:"up", - kind:"sweater", - style:"leisure", - colour:"gray", - T:3, - thickness:"thin", - season:"autumn" - },{ - name:"sweater6", - pattern:"up", - kind:"sweater", - style:"leisure", - colour:"yellow", - T:3, - thickness:"thin", - season:"autumn" - },{ - name:"sweater7", - pattern:"up", - kind:"sweater", - style:"leisure", - colour:"yellow", - T:4, - thickness:"thick", - season:"winter" - },{ - name:"sweater8", - pattern:"up", - kind:"sweater", - style:"leisure", - colour:"brown", - T:3, - thickness:"thin", - season:"autumn" - },{ - name:"sweater9", - pattern:"up", - kind:"sweater", - style:"leisure", - colour:"white", - T:4, - thickness:"thick", - season:"winter" - },{ - name:"sweater10", - pattern:"up", - kind:"sweater", - style:"leisure", - colour:"yellow", - T:3, - thickness:"thin", - season:"autumn" - },{ - name:"pants1", - pattern:"down", - kind:"long", - style:"leisure", - colour:"black", - T:1, - thickness:"thin", - season:"spring" - },{ - name:"pants2", - pattern:"down", - kind:"long", - style:"sports", - colour:"white", - T:3, - thickness:"proper", - season:"autumn" - },{ - name:"pants3", - pattern:"down", - kind:"long", - style:"sports", - colour:"purple", - T:1, - thickness:"thin", - season:"summer" - },{ - name:"pants4", - pattern:"down", - kind:"long", - style:"leisure", - colour:"blue", - T:5, - thickness:"thick", - season:"winter" - },{ - name:"pants5", - pattern:"down", - kind:"long", - style:"business", - colour:"gray", - T:3, - thickness:"proper", - season:"autumn" - },{ - name:"pants6", - pattern:"down", - kind:"short", - style:"leisure", - colour:"black", - T:3, - thickness:"proper", - season:"winter" - },{ - name:"pants7", - pattern:"down", - kind:"short", - style:"leisure", - colour:"black", - T:3, - thickness:"proper", - season:"winter" - },{ - name:"pants8", - pattern:"down", - kind:"short", - style:"sports", - colour:"white", - T:-5, - thickness:"thin", - season:"summer" - },{ - name:"pants9", - pattern:"down", - kind:"short", - style:"leisure", - colour:"black", - T:-5, - thickness:"thin", - season:"summer" - },{ - name:"pants10", - pattern:"down", - kind:"short", - style:"business", - colour:"brown", - T:-5, - thickness:"thin", - season:"summer" - } - ] - }, + onLaunch: function () { + if (!wx.cloud) { + console.error('请使用 2.2.3 或以上的基础库以使用云能力'); + } else { + wx.cloud.init({ + // env 参数说明: + // env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源 + // 此处请填入环境 ID, 环境 ID 可打开云控制台查看 + // 如不填则使用默认环境(第一个创建的环境) + // env: 'my-env-id', + env: 'cloud1-5ggzbo3kcd4ea4e2', + traceUser: true, + }); + } +}, +//全局变量 +globalData: { +     url: null +   }, + //wx.cloud.callFunction({ + //name:'get', + // data:{ + // name:"", + // pattern:"", + // kind:"", + // style:"", + // colour:"", + // T:"", + // thickness:"", + // season:"" + // }, + // success:res=>{ + // this.globalData.openid=res.result.openid + // }, + // fail:err=>{ + // console.error('[云函数] [login] 调用失败',err) + // } + //}) +globalData:{ + clothes:[{ + name:"t-shirt1", + pattern:"up", + kind:"t-shirt", + style:"leisure", + colour:"white", + T:-5, + thickness:"thin", + season:"summer" + },{ + name:"t-shirt2", + pattern:"up", + kind:"t-shirt", + style:"leisure", + colour:"red", + T:-5, + thickness:"thin", + season:"summer" + },{ + name:"t-shirt3", + pattern:"up", + kind:"t-shirt", + style:"leisure", + colour:"orange", + T:-5, + thickness:"thin", + season:"summer" + },{ + name:"t-shirt4", + pattern:"up", + kind:"t-shirt", + style:"leisure", + colour:"black", + T:-5, + thickness:"thin", + season:"summer" + },{ + name:"t-shirt5", + pattern:"up", + kind:"t-shirt", + style:"leisure", + colour:"red", + T:-5, + thickness:"thin", + season:"summer" + },{ + name:"t-shirt6", + pattern:"up", + kind:"t-shirt", + style:"leisure", + colour:"purple", + T:-5, + thickness:"thin", + season:"summer" + },{ + name:"t-shirt7", + pattern:"up", + kind:"t-shirt", + style:"leisure", + colour:"green", + T:-5, + thickness:"thin", + season:"summer" + },{ + name:"t-shirt8", + pattern:"up", + kind:"t-shirt", + style:"sports", + colour:"white", + T:-5, + thickness:"thin", + season:"summer" + },{ + name:"t-shirt9", + pattern:"up", + kind:"t-shirt", + style:"sports", + colour:"black", + T:-4, + thickness:"thin", + season:"summer" + },{ + name:"t-shirt10", + pattern:"up", + kind:"t-shirt", + style:"leisure", + colour:"blue", + T:-5, + thickness:"thin", + season:"summer" + },{ + name:"hoodie1", + pattern:"up", + kind:"hoodie", + style:"leisure", + colour:"white", + T:2, + thickness:"thin", + season:"spring" + },{ + name:"hoodie2", + pattern:"up", + kind:"hoodie", + style:"leisure", + colour:"brown", + T:5, + thickness:"thin", + season:"winter" + },{ + name:"hoodie3", + pattern:"up", + kind:"hoodie", + style:"leisure", + colour:"white", + T:5, + thickness:"thin", + season:"winter" + },{ + name:"hoodie4", + pattern:"up", + kind:"hoodie", + style:"leisure", + colour:"black", + T:3, + thickness:"proper", + season:"autumn" + },{ + name:"hoodie5", + pattern:"up", + kind:"hoodie", + style:"sports", + colour:"yellow", + T:3, + thickness:"proper", + season:"spring" + },{ + name:"hoodie6", + pattern:"up", + kind:"hoodie", + style:"leisure", + colour:"black", + T:4, + thickness:"proper", + season:"spring" + },{ + name:"hoodie7", + pattern:"up", + kind:"hoodie", + style:"leisure", + colour:"white", + T:3, + thickness:"proper", + season:"autumn" + },{ + name:"hoodie8", + pattern:"up", + kind:"hoodie", + style:"sports", + colour:"white", + T:3, + thickness:"proper", + season:"autumn" + },{ + name:"hoodie9", + pattern:"up", + kind:"hoodie", + style:"sports", + colour:"pink", + T:5, + thickness:"thick", + season:"winter" + },{ + name:"hoodie10", + pattern:"up", + kind:"hoodie", + style:"sports", + colour:"green", + T:4, + thickness:"proper", + season:"spring" + },{ + name:"skirt1", + pattern:"down", + kind:"skirt", + style:"leisure", + colour:"blue", + T:-5, + thickness:"thin", + season:"summer" + },{ + name:"skirt2", + pattern:"down", + kind:"skirt", + style:"business", + colour:"brown", + T:3, + thickness:"thin", + season:"winter" + },{ + name:"skirt3", + pattern:"down", + kind:"skirt", + style:"sport", + colour:"white", + T:-5, + thickness:"thin", + season:"summer" + },{ + name:"skirt4", + pattern:"down", + kind:"skirt", + style:"leisure", + colour:"brown", + T:2, + thickness:"proper", + season:"autumn" + },{ + name:"skirt5", + pattern:"all", + kind:"skirt", + style:"leisure", + colour:"red", + T:-10, + thickness:"thin", + season:"summer" + },{ + name:"skirt6", + pattern:"all", + kind:"skirt", + style:"business", + colour:"white", + T:-10, + thickness:"thin", + season:"summer" + },{ + name:"skirt7", + pattern:"all", + kind:"skirt", + style:"leisure", + colour:"black", + T:5, + thickness:"proper", + season:"autumn" + },{ + name:"skirt8", + pattern:"down", + kind:"skirt", + style:"business", + colour:"black", + T:-5, + thickness:"thin", + season:"autumn" + },{ + name:"skirt9", + pattern:"down", + kind:"skirt", + style:"leisure", + colour:"pink", + T:1, + thickness:"proper", + season:"spring" + },{ + name:"skirt10", + pattern:"all", + kind:"skirt", + style:"leisure", + colour:"white", + T:-10, + thickness:"thin", + season:"summer" + },{ + name:"coat1", + pattern:"up", + kind:"coat", + style:"leisure", + colour:"black", + T:5, + thickness:"proper", + season:"autumn" + },{ + name:"coat2", + pattern:"up", + kind:"coat", + style:"leisure", + colour:"white", + T:4, + thickness:"proper", + season:"autumn" + },{ + name:"coat3", + pattern:"up", + kind:"coat", + style:"business", + colour:"white", + T:2, + thickness:"thin", + season:"spring" + },{ + name:"coat4", + pattern:"up", + kind:"coat", + style:"business", + colour:"red", + T:5, + thickness:"thick", + season:"winter" + },{ + name:"coat5", + pattern:"up", + kind:"coat", + style:"leisure", + colour:"white", + T:1, + thickness:"thin", + season:"summer" + },{ + name:"coat6", + pattern:"up", + kind:"coat", + style:"leisure", + colour:"black", + T:9, + thickness:"thick", + season:"winter" + },{ + name:"coat7", + pattern:"up", + kind:"coat", + style:"sports", + colour:"black", + T:3, + thickness:"thin", + season:"spring" + },{ + name:"coat8", + pattern:"up", + kind:"coat", + style:"leisure", + colour:"pink", + T:5, + thickness:"proper", + season:"autumn" + },{ + name:"coat9", + pattern:"up", + kind:"coat", + style:"leisure", + colour:"white", + T:10, + thickness:"thick", + season:"winter" + },{ + name:"coat10", + pattern:"up", + kind:"coat", + style:"leisure", + colour:"khaki", + T:3, + thickness:"thin", + season:"autumn" + },{ + name:"sweater1", + pattern:"up", + kind:"sweater", + style:"leisure", + colour:"white", + T:3, + thickness:"thin", + season:"autumn" + },{ + name:"sweater2", + pattern:"up", + kind:"sweater", + style:"leisure", + colour:"black", + T:4, + thickness:"thick", + season:"winter" + },{ + name:"sweater3", + pattern:"up", + kind:"sweater", + style:"leisure", + colour:"blue", + T:4, + thickness:"thick", + season:"winter" + },{ + name:"sweater4", + pattern:"up", + kind:"sweater", + style:"leisure", + colour:"blue", + T:4, + thickness:"thick", + season:"winter" + },{ + name:"sweater5", + pattern:"up", + kind:"sweater", + style:"leisure", + colour:"gray", + T:3, + thickness:"thin", + season:"autumn" + },{ + name:"sweater6", + pattern:"up", + kind:"sweater", + style:"leisure", + colour:"yellow", + T:3, + thickness:"thin", + season:"autumn" + },{ + name:"sweater7", + pattern:"up", + kind:"sweater", + style:"leisure", + colour:"yellow", + T:4, + thickness:"thick", + season:"winter" + },{ + name:"sweater8", + pattern:"up", + kind:"sweater", + style:"leisure", + colour:"brown", + T:3, + thickness:"thin", + season:"autumn" + },{ + name:"sweater9", + pattern:"up", + kind:"sweater", + style:"leisure", + colour:"white", + T:4, + thickness:"thick", + season:"winter" + },{ + name:"sweater10", + pattern:"up", + kind:"sweater", + style:"leisure", + colour:"yellow", + T:3, + thickness:"thin", + season:"autumn" + },{ + name:"pants1", + pattern:"down", + kind:"long", + style:"leisure", + colour:"black", + T:1, + thickness:"thin", + season:"spring" + },{ + name:"pants2", + pattern:"down", + kind:"long", + style:"sports", + colour:"white", + T:3, + thickness:"proper", + season:"autumn" + },{ + name:"pants3", + pattern:"down", + kind:"long", + style:"sports", + colour:"purple", + T:1, + thickness:"thin", + season:"summer" + },{ + name:"pants4", + pattern:"down", + kind:"long", + style:"leisure", + colour:"blue", + T:5, + thickness:"thick", + season:"winter" + },{ + name:"pants5", + pattern:"down", + kind:"long", + style:"business", + colour:"gray", + T:3, + thickness:"proper", + season:"autumn" + },{ + name:"pants6", + pattern:"down", + kind:"short", + style:"leisure", + colour:"black", + T:3, + thickness:"proper", + season:"winter" + },{ + name:"pants7", + pattern:"down", + kind:"short", + style:"leisure", + colour:"black", + T:3, + thickness:"proper", + season:"winter" + },{ + name:"pants8", + pattern:"down", + kind:"short", + style:"sports", + colour:"white", + T:-5, + thickness:"thin", + season:"summer" + },{ + name:"pants9", + pattern:"down", + kind:"short", + style:"leisure", + colour:"black", + T:-5, + thickness:"thin", + season:"summer" + },{ + name:"pants10", + pattern:"down", + kind:"short", + style:"business", + colour:"brown", + T:-5, + thickness:"thin", + season:"summer" + } +] +}, + }) diff --git a/app.json b/app.json index 95c2f12..a8e255b 100644 --- a/app.json +++ b/app.json @@ -1,17 +1,17 @@ { + "cloud": true, "pages": [ "pages/index/index", "pages/navigation/index/index", "pages/navigation/index/show_clothes/show_clothes", "pages/navigation/index/add/add", - "pages/navigation/index/add/camera/camera", "pages/navigation/index/delete/delete", "pages/navigation/self/self", "pages/navigation/userinform/userinform", "pages/navigation/safety/safety", "pages/navigation/shezhi/shezhi", - "pages/navigation/index/recommand/recommand" - + "pages/navigation/index/recommand/recommand", + "pages/navigation/index/add/camera/camera" ], "window": { "backgroundTextStyle": "light", diff --git a/cloudfunctions/get/config.json b/cloudfunctions/get/config.json new file mode 100644 index 0000000..5ecc33e --- /dev/null +++ b/cloudfunctions/get/config.json @@ -0,0 +1,6 @@ +{ + "permissions": { + "openapi": [ + ] + } +} \ No newline at end of file diff --git a/cloudfunctions/get/index.js b/cloudfunctions/get/index.js new file mode 100644 index 0000000..c77edbb --- /dev/null +++ b/cloudfunctions/get/index.js @@ -0,0 +1,32 @@ +// 云函数入口文件 +const cloud = require('wx-server-sdk') + +cloud.init() // 使用当前云环境 +const db=cloud.database() +const MAX_LIMIT=100 +// 云函数入口函数 +exports.main = async (event, context) => { + const wxContext = cloud.getWXContext() + //先取出集合记录总数 + const countResult=await db.collection('cloth').count() + const total=countResult.total + //计算分几次取 + const batchTimes = Math.ceil(total / 100) + // 承载所有读操作的 promise 的数组 + const tasks = [] + for (let i = 0; i < batchTimes; i++) { + const promise = db.collection('cloth').skip(i * MAX_LIMIT).limit(MAX_LIMIT).get() + tasks.push(promise) + } + // 等待所有 + return (await Promise.all(tasks)).reduce((acc, cur) => { + return { + event, + openid: wxContext.OPENID, + appid: wxContext.APPID, + unionid: wxContext.UNIONID, + data: acc.data.concat(cur.data), + errMsg: acc.errMsg, + } + }) +} \ No newline at end of file diff --git a/cloudfunctions/get/package.json b/cloudfunctions/get/package.json new file mode 100644 index 0000000..e7978fe --- /dev/null +++ b/cloudfunctions/get/package.json @@ -0,0 +1,14 @@ +{ + "name": "get", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "wx-server-sdk": "~2.6.3" + } +} \ No newline at end of file diff --git a/cloudfunctions/quickstartFunctions/config.json b/cloudfunctions/quickstartFunctions/config.json new file mode 100644 index 0000000..41a485c --- /dev/null +++ b/cloudfunctions/quickstartFunctions/config.json @@ -0,0 +1,7 @@ +{ + "permissions": { + "openapi": [ + "wxacode.get" + ] + } +} \ No newline at end of file diff --git a/cloudfunctions/quickstartFunctions/createCollection/index.js b/cloudfunctions/quickstartFunctions/createCollection/index.js new file mode 100644 index 0000000..75a40b9 --- /dev/null +++ b/cloudfunctions/quickstartFunctions/createCollection/index.js @@ -0,0 +1,56 @@ +const cloud = require('wx-server-sdk'); + +cloud.init({ + env: cloud.DYNAMIC_CURRENT_ENV +}); + +const db = cloud.database(); + +// 创建集合云函数入口函数 +exports.main = async (event, context) => { + try { + // 创建集合 + await db.createCollection('sales'); + await db.collection('sales').add({ + // data 字段表示需新增的 JSON 数据 + data: { + region: '华东', + city: '上海', + sales: 11 + } + }); + await db.collection('sales').add({ + // data 字段表示需新增的 JSON 数据 + data: { + region: '华东', + city: '南京', + sales: 11 + } + }); + await db.collection('sales').add({ + // data 字段表示需新增的 JSON 数据 + data: { + region: '华南', + city: '广州', + sales: 22 + } + }); + await db.collection('sales').add({ + // data 字段表示需新增的 JSON 数据 + data: { + region: '华南', + city: '深圳', + sales: 22 + } + }); + return { + success: true + }; + } catch (e) { + // 这里catch到的是该collection已经存在,从业务逻辑上来说是运行成功的,所以catch返回success给前端,避免工具在前端抛出异常 + return { + success: true, + data: 'create collection success' + }; + } +}; diff --git a/cloudfunctions/quickstartFunctions/getMiniProgramCode/index.js b/cloudfunctions/quickstartFunctions/getMiniProgramCode/index.js new file mode 100644 index 0000000..08e1a82 --- /dev/null +++ b/cloudfunctions/quickstartFunctions/getMiniProgramCode/index.js @@ -0,0 +1,20 @@ +const cloud = require('wx-server-sdk'); + +cloud.init({ + env: cloud.DYNAMIC_CURRENT_ENV +}); + +// 获取小程序二维码云函数入口函数 +exports.main = async (event, context) => { + // 获取小程序二维码的buffer + const resp = await cloud.openapi.wxacode.get({ + path: 'pages/index/index' + }); + const { buffer } = resp; + // 将图片上传云存储空间 + const upload = await cloud.uploadFile({ + cloudPath: 'code.png', + fileContent: buffer + }); + return upload.fileID; +}; diff --git a/cloudfunctions/quickstartFunctions/getOpenId/index.js b/cloudfunctions/quickstartFunctions/getOpenId/index.js new file mode 100644 index 0000000..94b7b94 --- /dev/null +++ b/cloudfunctions/quickstartFunctions/getOpenId/index.js @@ -0,0 +1,17 @@ +const cloud = require('wx-server-sdk'); + +cloud.init({ + env: cloud.DYNAMIC_CURRENT_ENV +}); + +// 获取openId云函数入口函数 +exports.main = async (event, context) => { + // 获取基础信息 + const wxContext = cloud.getWXContext(); + + return { + openid: wxContext.OPENID, + appid: wxContext.APPID, + unionid: wxContext.UNIONID, + }; +}; diff --git a/cloudfunctions/quickstartFunctions/index.js b/cloudfunctions/quickstartFunctions/index.js new file mode 100644 index 0000000..d137f69 --- /dev/null +++ b/cloudfunctions/quickstartFunctions/index.js @@ -0,0 +1,25 @@ +const getOpenId = require('./getOpenId/index'); +const getMiniProgramCode = require('./getMiniProgramCode/index'); +const createCollection = require('./createCollection/index'); +const selectRecord = require('./selectRecord/index'); +const updateRecord = require('./updateRecord/index'); +const sumRecord = require('./sumRecord/index'); + + +// 云函数入口函数 +exports.main = async (event, context) => { + switch (event.type) { + case 'getOpenId': + return await getOpenId.main(event, context); + case 'getMiniProgramCode': + return await getMiniProgramCode.main(event, context); + case 'createCollection': + return await createCollection.main(event, context); + case 'selectRecord': + return await selectRecord.main(event, context); + case 'updateRecord': + return await updateRecord.main(event, context); + case 'sumRecord': + return await sumRecord.main(event, context); + } +}; diff --git a/cloudfunctions/quickstartFunctions/package.json b/cloudfunctions/quickstartFunctions/package.json new file mode 100644 index 0000000..4350dbb --- /dev/null +++ b/cloudfunctions/quickstartFunctions/package.json @@ -0,0 +1,14 @@ +{ + "name": "quickstartFunctions", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "wx-server-sdk": "~2.4.0" + } +} diff --git a/cloudfunctions/quickstartFunctions/selectRecord/index.js b/cloudfunctions/quickstartFunctions/selectRecord/index.js new file mode 100644 index 0000000..c7848a7 --- /dev/null +++ b/cloudfunctions/quickstartFunctions/selectRecord/index.js @@ -0,0 +1,12 @@ +const cloud = require('wx-server-sdk'); + +cloud.init({ + env: cloud.DYNAMIC_CURRENT_ENV +}); +const db = cloud.database(); + +// 查询数据库集合云函数入口函数 +exports.main = async (event, context) => { + // 返回数据库查询结果 + return await db.collection('sales').get(); +}; diff --git a/cloudfunctions/quickstartFunctions/sumRecord/index.js b/cloudfunctions/quickstartFunctions/sumRecord/index.js new file mode 100644 index 0000000..dfdc293 --- /dev/null +++ b/cloudfunctions/quickstartFunctions/sumRecord/index.js @@ -0,0 +1,18 @@ +const cloud = require('wx-server-sdk'); + +cloud.init({ + env: cloud.DYNAMIC_CURRENT_ENV +}); +const db = cloud.database(); +const $ = db.command.aggregate; + +// 聚合记录云函数入口函数 +exports.main = async (event, context) => { + // 返回数据库聚合结果 + return db.collection('sales').aggregate() + .group({ + _id: '$region', + sum: $.sum('$sales') + }) + .end(); +}; diff --git a/cloudfunctions/quickstartFunctions/updateRecord/index.js b/cloudfunctions/quickstartFunctions/updateRecord/index.js new file mode 100644 index 0000000..2ce3ad0 --- /dev/null +++ b/cloudfunctions/quickstartFunctions/updateRecord/index.js @@ -0,0 +1,32 @@ +const cloud = require('wx-server-sdk'); + +cloud.init({ + env: cloud.DYNAMIC_CURRENT_ENV +}); +const db = cloud.database(); + +// 修改数据库信息云函数入口函数 +exports.main = async (event, context) => { + try { + // 遍历修改数据库信息 + for (let i = 0; i < event.data.length; i++) { + await db.collection('sales').where({ + _id: event.data[i]._id + }) + .update({ + data: { + sales: event.data[i].sales + }, + }); + } + return { + success: true, + data: event.data + }; + } catch (e) { + return { + success: false, + errMsg: e + }; + } +}; diff --git a/pages/img/衣服/coat1.jpg b/pages/img/衣服/coat1.jpg new file mode 100644 index 0000000..e7881a2 Binary files /dev/null and b/pages/img/衣服/coat1.jpg differ diff --git a/pages/img/衣服/coat10.jpg b/pages/img/衣服/coat10.jpg new file mode 100644 index 0000000..4f36829 Binary files /dev/null and b/pages/img/衣服/coat10.jpg differ diff --git a/pages/img/衣服/coat2.jpg b/pages/img/衣服/coat2.jpg new file mode 100644 index 0000000..154e0d6 Binary files /dev/null and b/pages/img/衣服/coat2.jpg differ diff --git a/pages/img/衣服/coat3.jpg b/pages/img/衣服/coat3.jpg new file mode 100644 index 0000000..f64001d Binary files /dev/null and b/pages/img/衣服/coat3.jpg differ diff --git a/pages/img/衣服/coat4.jpg b/pages/img/衣服/coat4.jpg new file mode 100644 index 0000000..ff23ed4 Binary files /dev/null and b/pages/img/衣服/coat4.jpg differ diff --git a/pages/img/衣服/coat5.jpg b/pages/img/衣服/coat5.jpg new file mode 100644 index 0000000..1895483 Binary files /dev/null and b/pages/img/衣服/coat5.jpg differ diff --git a/pages/img/衣服/coat6.jpg b/pages/img/衣服/coat6.jpg new file mode 100644 index 0000000..367fe1a Binary files /dev/null and b/pages/img/衣服/coat6.jpg differ diff --git a/pages/img/衣服/coat7.jpg b/pages/img/衣服/coat7.jpg new file mode 100644 index 0000000..9217310 Binary files /dev/null and b/pages/img/衣服/coat7.jpg differ diff --git a/pages/img/衣服/coat8.jpg b/pages/img/衣服/coat8.jpg new file mode 100644 index 0000000..a1aab53 Binary files /dev/null and b/pages/img/衣服/coat8.jpg differ diff --git a/pages/img/衣服/coat9.jpg b/pages/img/衣服/coat9.jpg new file mode 100644 index 0000000..2b7ac52 Binary files /dev/null and b/pages/img/衣服/coat9.jpg differ diff --git a/pages/img/衣服/hoodie1.jpg b/pages/img/衣服/hoodie1.jpg new file mode 100644 index 0000000..b2459c1 Binary files /dev/null and b/pages/img/衣服/hoodie1.jpg differ diff --git a/pages/img/衣服/hoodie10.jpg b/pages/img/衣服/hoodie10.jpg new file mode 100644 index 0000000..ef83084 Binary files /dev/null and b/pages/img/衣服/hoodie10.jpg differ diff --git a/pages/img/衣服/hoodie2.jpg b/pages/img/衣服/hoodie2.jpg new file mode 100644 index 0000000..e567fa8 Binary files /dev/null and b/pages/img/衣服/hoodie2.jpg differ diff --git a/pages/img/衣服/hoodie3.jpg b/pages/img/衣服/hoodie3.jpg new file mode 100644 index 0000000..3cfd760 Binary files /dev/null and b/pages/img/衣服/hoodie3.jpg differ diff --git a/pages/img/衣服/hoodie4.jpg b/pages/img/衣服/hoodie4.jpg new file mode 100644 index 0000000..80e203a Binary files /dev/null and b/pages/img/衣服/hoodie4.jpg differ diff --git a/pages/img/衣服/hoodie5.jpg b/pages/img/衣服/hoodie5.jpg new file mode 100644 index 0000000..25bfb82 Binary files /dev/null and b/pages/img/衣服/hoodie5.jpg differ diff --git a/pages/img/衣服/hoodie6.jpg b/pages/img/衣服/hoodie6.jpg new file mode 100644 index 0000000..17fda0f Binary files /dev/null and b/pages/img/衣服/hoodie6.jpg differ diff --git a/pages/img/衣服/hoodie7.jpg b/pages/img/衣服/hoodie7.jpg new file mode 100644 index 0000000..b8e1f2e Binary files /dev/null and b/pages/img/衣服/hoodie7.jpg differ diff --git a/pages/img/衣服/hoodie8.jpg b/pages/img/衣服/hoodie8.jpg new file mode 100644 index 0000000..9277003 Binary files /dev/null and b/pages/img/衣服/hoodie8.jpg differ diff --git a/pages/img/衣服/hoodie9.jpg b/pages/img/衣服/hoodie9.jpg new file mode 100644 index 0000000..2d24bd1 Binary files /dev/null and b/pages/img/衣服/hoodie9.jpg differ diff --git a/pages/img/衣服/pants1.jpg b/pages/img/衣服/pants1.jpg new file mode 100644 index 0000000..8053d68 Binary files /dev/null and b/pages/img/衣服/pants1.jpg differ diff --git a/pages/img/衣服/pants10.jpg b/pages/img/衣服/pants10.jpg new file mode 100644 index 0000000..4eec756 Binary files /dev/null and b/pages/img/衣服/pants10.jpg differ diff --git a/pages/img/衣服/pants2.jpg b/pages/img/衣服/pants2.jpg new file mode 100644 index 0000000..f3fc522 Binary files /dev/null and b/pages/img/衣服/pants2.jpg differ diff --git a/pages/img/衣服/pants3.jpg b/pages/img/衣服/pants3.jpg new file mode 100644 index 0000000..d78bbf7 Binary files /dev/null and b/pages/img/衣服/pants3.jpg differ diff --git a/pages/img/衣服/pants4.jpg b/pages/img/衣服/pants4.jpg new file mode 100644 index 0000000..43fdcac Binary files /dev/null and b/pages/img/衣服/pants4.jpg differ diff --git a/pages/img/衣服/pants5.jpg b/pages/img/衣服/pants5.jpg new file mode 100644 index 0000000..14bd9d8 Binary files /dev/null and b/pages/img/衣服/pants5.jpg differ diff --git a/pages/img/衣服/pants6.jpg b/pages/img/衣服/pants6.jpg new file mode 100644 index 0000000..588b2e6 Binary files /dev/null and b/pages/img/衣服/pants6.jpg differ diff --git a/pages/img/衣服/pants7.jpg b/pages/img/衣服/pants7.jpg new file mode 100644 index 0000000..2844d17 Binary files /dev/null and b/pages/img/衣服/pants7.jpg differ diff --git a/pages/img/衣服/pants8.jpg b/pages/img/衣服/pants8.jpg new file mode 100644 index 0000000..fd138b5 Binary files /dev/null and b/pages/img/衣服/pants8.jpg differ diff --git a/pages/img/衣服/pants9.jpg b/pages/img/衣服/pants9.jpg new file mode 100644 index 0000000..84cfa7c Binary files /dev/null and b/pages/img/衣服/pants9.jpg differ diff --git a/pages/img/衣服/skirt1.jpg b/pages/img/衣服/skirt1.jpg new file mode 100644 index 0000000..f380f32 Binary files /dev/null and b/pages/img/衣服/skirt1.jpg differ diff --git a/pages/img/衣服/skirt10.jpg b/pages/img/衣服/skirt10.jpg new file mode 100644 index 0000000..abf2fee Binary files /dev/null and b/pages/img/衣服/skirt10.jpg differ diff --git a/pages/img/衣服/skirt2.jpg b/pages/img/衣服/skirt2.jpg new file mode 100644 index 0000000..960a745 Binary files /dev/null and b/pages/img/衣服/skirt2.jpg differ diff --git a/pages/img/衣服/skirt3.jpg b/pages/img/衣服/skirt3.jpg new file mode 100644 index 0000000..dcc7320 Binary files /dev/null and b/pages/img/衣服/skirt3.jpg differ diff --git a/pages/img/衣服/skirt4.jpg b/pages/img/衣服/skirt4.jpg new file mode 100644 index 0000000..39789b0 Binary files /dev/null and b/pages/img/衣服/skirt4.jpg differ diff --git a/pages/img/衣服/skirt5.jpg b/pages/img/衣服/skirt5.jpg new file mode 100644 index 0000000..12a9a32 Binary files /dev/null and b/pages/img/衣服/skirt5.jpg differ diff --git a/pages/img/衣服/skirt6.jpg b/pages/img/衣服/skirt6.jpg new file mode 100644 index 0000000..b4434d8 Binary files /dev/null and b/pages/img/衣服/skirt6.jpg differ diff --git a/pages/img/衣服/skirt7.jpg b/pages/img/衣服/skirt7.jpg new file mode 100644 index 0000000..d6e3f63 Binary files /dev/null and b/pages/img/衣服/skirt7.jpg differ diff --git a/pages/img/衣服/skirt8.jpg b/pages/img/衣服/skirt8.jpg new file mode 100644 index 0000000..6dfea14 Binary files /dev/null and b/pages/img/衣服/skirt8.jpg differ diff --git a/pages/img/衣服/skirt9.jpg b/pages/img/衣服/skirt9.jpg new file mode 100644 index 0000000..3778390 Binary files /dev/null and b/pages/img/衣服/skirt9.jpg differ diff --git a/pages/img/衣服/sweater1.jpg b/pages/img/衣服/sweater1.jpg new file mode 100644 index 0000000..c313645 Binary files /dev/null and b/pages/img/衣服/sweater1.jpg differ diff --git a/pages/img/衣服/sweater10.jpg b/pages/img/衣服/sweater10.jpg new file mode 100644 index 0000000..8005a14 Binary files /dev/null and b/pages/img/衣服/sweater10.jpg differ diff --git a/pages/img/衣服/sweater2.jpg b/pages/img/衣服/sweater2.jpg new file mode 100644 index 0000000..96758b0 Binary files /dev/null and b/pages/img/衣服/sweater2.jpg differ diff --git a/pages/img/衣服/sweater3.jpg b/pages/img/衣服/sweater3.jpg new file mode 100644 index 0000000..f9783dd Binary files /dev/null and b/pages/img/衣服/sweater3.jpg differ diff --git a/pages/img/衣服/sweater4.jpg b/pages/img/衣服/sweater4.jpg new file mode 100644 index 0000000..451cc6b Binary files /dev/null and b/pages/img/衣服/sweater4.jpg differ diff --git a/pages/img/衣服/sweater5.jpg b/pages/img/衣服/sweater5.jpg new file mode 100644 index 0000000..67fa097 Binary files /dev/null and b/pages/img/衣服/sweater5.jpg differ diff --git a/pages/img/衣服/sweater6.jpg b/pages/img/衣服/sweater6.jpg new file mode 100644 index 0000000..8b1ee10 Binary files /dev/null and b/pages/img/衣服/sweater6.jpg differ diff --git a/pages/img/衣服/sweater7.jpg b/pages/img/衣服/sweater7.jpg new file mode 100644 index 0000000..367ceff Binary files /dev/null and b/pages/img/衣服/sweater7.jpg differ diff --git a/pages/img/衣服/sweater8.jpg b/pages/img/衣服/sweater8.jpg new file mode 100644 index 0000000..2c58762 Binary files /dev/null and b/pages/img/衣服/sweater8.jpg differ diff --git a/pages/img/衣服/sweater9.jpg b/pages/img/衣服/sweater9.jpg new file mode 100644 index 0000000..a933d82 Binary files /dev/null and b/pages/img/衣服/sweater9.jpg differ diff --git a/pages/img/衣服/t-shirt1.jpg b/pages/img/衣服/t-shirt1.jpg new file mode 100644 index 0000000..620e451 Binary files /dev/null and b/pages/img/衣服/t-shirt1.jpg differ diff --git a/pages/img/衣服/t-shirt10.jpg b/pages/img/衣服/t-shirt10.jpg new file mode 100644 index 0000000..fd914d9 Binary files /dev/null and b/pages/img/衣服/t-shirt10.jpg differ diff --git a/pages/img/衣服/t-shirt2.jpg b/pages/img/衣服/t-shirt2.jpg new file mode 100644 index 0000000..c1f56ae Binary files /dev/null and b/pages/img/衣服/t-shirt2.jpg differ diff --git a/pages/img/衣服/t-shirt3.jpg b/pages/img/衣服/t-shirt3.jpg new file mode 100644 index 0000000..6bf0906 Binary files /dev/null and b/pages/img/衣服/t-shirt3.jpg differ diff --git a/pages/img/衣服/t-shirt4.jpg b/pages/img/衣服/t-shirt4.jpg new file mode 100644 index 0000000..f01f1a4 Binary files /dev/null and b/pages/img/衣服/t-shirt4.jpg differ diff --git a/pages/img/衣服/t-shirt5.jpg b/pages/img/衣服/t-shirt5.jpg new file mode 100644 index 0000000..b86203a Binary files /dev/null and b/pages/img/衣服/t-shirt5.jpg differ diff --git a/pages/img/衣服/t-shirt6.jpg b/pages/img/衣服/t-shirt6.jpg new file mode 100644 index 0000000..6c1b7b4 Binary files /dev/null and b/pages/img/衣服/t-shirt6.jpg differ diff --git a/pages/img/衣服/t-shirt7.jpg b/pages/img/衣服/t-shirt7.jpg new file mode 100644 index 0000000..fe03755 Binary files /dev/null and b/pages/img/衣服/t-shirt7.jpg differ diff --git a/pages/img/衣服/t-shirt8.jpg b/pages/img/衣服/t-shirt8.jpg new file mode 100644 index 0000000..02d19a1 Binary files /dev/null and b/pages/img/衣服/t-shirt8.jpg differ diff --git a/pages/img/衣服/t-shirt9.jpg b/pages/img/衣服/t-shirt9.jpg new file mode 100644 index 0000000..fb47e9b Binary files /dev/null and b/pages/img/衣服/t-shirt9.jpg differ diff --git a/pages/navigation/index/add/add.js b/pages/navigation/index/add/add.js index ef400cc..a9a1f4a 100644 --- a/pages/navigation/index/add/add.js +++ b/pages/navigation/index/add/add.js @@ -1,30 +1,24 @@ // pages/navigation/index/add/add.js let app=getApp(); - import Toast from './@vant/weapp/toast/toast'; Page({ /** * 页面的初始数据 */ - +   data: { - name:"", - pattern:"", - kind:"", - style:"", - colour:"", - T:"", - thickness:"", - season:"", + name:"", + pattern:"", + kind:"", + style:"", + colour:"", + T:"", + thickness:"", + season:"" , url:"" - - - - }, + }, cancel() { - - this.setData({ name:"", pattern:"", kind:"", @@ -32,8 +26,8 @@ Page({ colour:"", T:"", thickness:"", - season:"", - url:""}); + season:"" , + url:""}); }, //提交 submit() @@ -53,9 +47,9 @@ Page({ wx.cloud.init({ env:'cloud1-5ggzbo3kcd4ea4e2' }); - //初始化数据库 const db=wx.cloud.database(); + let clothes=this.data.clothes; db.collection('cloth').add({ data: { name:this.data.name, @@ -68,7 +62,6 @@ Page({ season:this.data.season, url:app.globalData.url }, - sucess:function(res){ console.log(res); } @@ -79,8 +72,7 @@ Page({ console.log("数据123",this.data,app.globalData.clothes) this.cancel(); - }, - + }, /** * 生命周期函数--监听页面加载 */ @@ -88,10 +80,6 @@ Page({ }, - - - - /** * 生命周期函数--监听页面初次渲染完成 */ @@ -137,11 +125,8 @@ Page({ /** * 用户点击右上角分享 */ - onShareAppMessage() { - - }, - - +  onShareAppMessage() { - -}) \ No newline at end of file +   }, +    +}) diff --git a/pages/navigation/index/add/add.wxml b/pages/navigation/index/add/add.wxml index b03db50..74a7aa9 100644 --- a/pages/navigation/index/add/add.wxml +++ b/pages/navigation/index/add/add.wxml @@ -1,8 +1,6 @@ - - diff --git a/pages/navigation/index/add/camera/camera.js b/pages/navigation/index/add/camera/camera.js index 2f72d62..be96645 100644 --- a/pages/navigation/index/add/camera/camera.js +++ b/pages/navigation/index/add/camera/camera.js @@ -1,138 +1,137 @@ -// pages/navigation/index/add/camera/camera.js +// pages/navigation/index/add/camera/camera.js Page({ - /** - * 页面的初始数据 - */ - - data: { - src:null - }, - takePhoto() { - const ctx = wx.createCameraContext() - ctx.takePhoto({ - quality: 'high', - success: (res) => { - this.setData({ - src: res.tempImagePath - - - }) - console.log(this.data.src) - var app = getApp(); - app.globalData.url = this.data.src; - } - }) - - },error(e) { - console.log(e.detail) - }, - - see:function(e){ - var current = e.currentTarget.dataset.src; - console.log(current); - - wx.previewImage({ - current: current, // 当前显示图片的http链接 - urls: [this.data.src], - - }) - }, - // 获取图片上传后的url路径 - // addImagePath(fileId) { - // console.log("diaoyongla") - // console.log(fileId) - // wx.cloud.getTempFileURL({ - // fileList: [fileId], - // success: res => { - // app.globalData.url = res.fileList[0].tempFileURL - // }, - // fail: console.error - // }) - //}, - - upload:function(e){ - wx.cloud.uploadFile({ - cloudPath: 'photo/one.jpg', // 上传至云端的路径 - - filePath: this.data.src, // 小程序临时文件路径 - success: res => { - // 返回文件 ID - console.log(res.fileID) - wx.showToast({ - title: '上传成功', - icon:'success', - - }) - //获取图片的http路径 - //that.addImagePath(res.fileID) - }, - fail: console.error - }) - }, - gotoPage: function (options) { - wx.navigateTo({ - //url: '../add/add',//要跳转到的页面路径 - url:'../add', - }) - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - - } -}) - - \ No newline at end of file +   /** +    * 页面的初始数据 +    */ +    +   data: { +     src:null +   }, +   takePhoto() { +     const ctx = wx.createCameraContext() +     ctx.takePhoto({ +       quality: 'high', +       success: (res) => { +         this.setData({ +            src: res.tempImagePath +           +          +         }) +         console.log(this.data.src) +         var app = getApp(); +         app.globalData.url = this.data.src; +       } +     }) +      +   },error(e) { +    console.log(e.detail) +   }, + +   see:function(e){ +     var current = e.currentTarget.dataset.src; +     console.log(current); +      +     wx.previewImage({ +       current: current, // 当前显示图片的http链接 +       urls: [this.data.src], +        +     }) +    }, +    // 获取图片上传后的url路径 +   // addImagePath(fileId) { +   //   console.log("diaoyongla") +   //   console.log(fileId) +   //   wx.cloud.getTempFileURL({ +   //     fileList: [fileId], +   //     success: res => { +   //       app.globalData.url = res.fileList[0].tempFileURL +   //     }, +   //     fail: console.error +   //   }) +  //}, + +    upload:function(e){ +     wx.cloud.uploadFile({ +       cloudPath: 'photo/one.jpg', // 上传至云端的路径 +        +       filePath: this.data.src, // 小程序临时文件路径 +       success: res => { +         // 返回文件 ID +         console.log(res.fileID) +         wx.showToast({ +           title: '上传成功', +           icon:'success', +           +         }) +         //获取图片的http路径 +         //that.addImagePath(res.fileID) +       }, +       fail: console.error +     }) +    }, +    gotoPage: function (options) { +     wx.navigateTo({ +           //url: '../add/add',//要跳转到的页面路径 +           url:'../add', +  })   +  }, +   /** +    * 生命周期函数--监听页面加载 +    */ +   onLoad(options) { + +   }, + +   /** +    * 生命周期函数--监听页面初次渲染完成 +    */ +   onReady() { + +   }, + +   /** +    * 生命周期函数--监听页面显示 +    */ +   onShow() { + +   }, + +   /** +    * 生命周期函数--监听页面隐藏 +    */ +   onHide() { + +   }, + +   /** +    * 生命周期函数--监听页面卸载 +    */ +   onUnload() { + +   }, + +   /** +    * 页面相关事件处理函数--监听用户下拉动作 +    */ +   onPullDownRefresh() { + +   }, + +   /** +    * 页面上拉触底事件的处理函数 +    */ +   onReachBottom() { + +   }, + +   /** +    * 用户点击右上角分享 +    */ +   onShareAppMessage() { + +   } + }) + +    diff --git a/pages/navigation/index/delete/delete.js b/pages/navigation/index/delete/delete.js index 922dec0..68fdf63 100644 --- a/pages/navigation/index/delete/delete.js +++ b/pages/navigation/index/delete/delete.js @@ -1,5 +1,8 @@ // pages/navigation/index/delete/delete.js +const db=wx.cloud.database(); + let app=getApp(); + Page({ /** * 页面的初始数据 @@ -10,29 +13,63 @@ Page({ //定义按钮的事件处理函数 clear(e) { + var clothes=this.data.clothes + console.log(clothes) + let index=e.currentTarget.dataset.index + console.log(index) + let id=clothes[index]._id + console.log(id) + //界面数据删除 this.data.clothes.splice(e.currentTarget.dataset.index,1); this.setData({ clothes: this.data.clothes }); console.log('删除成功'); - //删除数据库中记录 + //初始化云 wx.cloud.init({ env:'cloud1-5ggzbo3kcd4ea4e2' }); - const db=wx.cloud.database() - db.doc(e.detail.value).remove({ - success(res){ - console.log("删除数据库数据成功",res) - }, - fail(res){ - console.log("删除数据库数据失败",res) + wx.cloud.callFunction({ + name:'get', + complete:res=>{ + console.log('云函数获取openid:',res.result.openid); + wx.setStorageSync('openid',res.result.openid); + console.log(res); + } + }), + //删除数据库中记录 + db.collection('cloth').where({ + '_id':id + }).remove({ + success: function(res) { + console.log(res.data) + wx.showToast({ + title: '删除成功', + }) + console.log('数据库删除成功') } }) + db.collection('cloth').where({ + '_id':id + }).get({ + success: res =>{ + console.log(res.data); + } + }) + }, + /** * 生命周期函数--监听页面加载 */ onLoad(options) { - this.setData({ clothes: app.globalData.clothes }); + db.collection('cloth').get({ + success: res =>{ + console.log(res.data); + this.setData({ + clothes:res.data + }) + } + }) }, /** @@ -83,4 +120,5 @@ Page({ onShareAppMessage() { } + }) \ No newline at end of file diff --git a/pages/navigation/index/delete/delete.wxml b/pages/navigation/index/delete/delete.wxml index d953bd9..87a237a 100644 --- a/pages/navigation/index/delete/delete.wxml +++ b/pages/navigation/index/delete/delete.wxml @@ -20,7 +20,7 @@ - + {{item.name}} @@ -31,7 +31,7 @@ {{item.kind}} - + diff --git a/pages/navigation/index/index.js b/pages/navigation/index/index.js index 16679e2..4f88b97 100644 --- a/pages/navigation/index/index.js +++ b/pages/navigation/index/index.js @@ -55,53 +55,59 @@ tabbar_change(event) { this.setData({ show_recommend:[],show_match_clothes:[]}); }, + // 搜索 + onChange(event) { + // event.detail 为当前输入的值 + console.log(event.detail); + + let s=26-event.detail,t=0; + let a=event.detail,r=0; + console.log("温度",s); + this.data.show_clothes=[]; + for(let n in app.globalData.clothes) + { + if(app.globalData.clothes[n].T==s) + { + + this.data.show_clothes[t]=app.globalData.clothes[n]; + this.data.show_clothes[t].img="/pages/img/衣服/"+app.globalData.clothes[n].name+".jpg"; + t++; + + } + else if(app.globalData.clothes[n].kind==a||app.globalData.clothes[n].pattern==a||app.globalData.clothes[n].style==a||app.globalData.clothes[n].colour==a||app.globalData.clothes[n].thickness==a||app.globalData.clothes[n].season==a) + { + this.data.show_clothes[r]=app.globalData.clothes[n]; + this.data.show_clothes[r].img="/pages/img/衣服/"+app.globalData.clothes[n].name+".jpg"; + r++; + } + + } + console.log("衣服",this.data.show_clothes); + let g_this=this; + if(this.data.show_clothes.length>0) + { + console.log("可以跳转") + wx.navigateTo({ + url: './show_clothes/show_clothes', + events: { + // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据 + acceptDataFromOpenedPage: function(data) { + console.log(data) + }, + someEvent: function(data) { + console.log(data) + } + + }, + success: function(res) { + // 通过 eventChannel 向被打开页面传送数据 + res.eventChannel.emit('show_clothes', { data: g_this.data.show_clothes }) + } + }) + } + +}, - - - // - onChange(event) { - // event.detail 为当前输入的值 - console.log(event.detail); - - let s=26-event.detail,t=0; - console.log("温度",s); - this.data.show_clothes=[]; - for(let n in app.globalData.clothes) - { - if(app.globalData.clothes[n].T==s) - { - - this.data.show_clothes[t]=app.globalData.clothes[n]; - this.data.show_clothes[t].img="/pages/img/衣服/"+app.globalData.clothes[n].name+".jpg"; - t++; - - } - } - console.log("衣服",this.data.show_clothes); - let g_this=this; - if(this.data.show_clothes.length>0) - { - console.log("可以跳转") - wx.navigateTo({ - url: './show_clothes/show_clothes', - events: { - // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据 - acceptDataFromOpenedPage: function(data) { - console.log(data) - }, - someEvent: function(data) { - console.log(data) - } - - }, - success: function(res) { - // 通过 eventChannel 向被打开页面传送数据 - res.eventChannel.emit('show_clothes', { data: g_this.data.show_clothes }) - } - }) - } - - }, /** * 生命周期函数--监听页面加载 */ diff --git a/pages/navigation/index/index.wxml b/pages/navigation/index/index.wxml index 59a657a..8391d2f 100644 --- a/pages/navigation/index/index.wxml +++ b/pages/navigation/index/index.wxml @@ -1,7 +1,7 @@ - + diff --git a/pages/navigation/index/recommand/recommand.wxml b/pages/navigation/index/recommand/recommand.wxml index 606dfb3..e8e5277 100644 --- a/pages/navigation/index/recommand/recommand.wxml +++ b/pages/navigation/index/recommand/recommand.wxml @@ -1,6 +1,5 @@ - diff --git a/project.config.json b/project.config.json index 42d9b07..52cb98e 100644 --- a/project.config.json +++ b/project.config.json @@ -1,4 +1,5 @@ { + "cloudfunctionRoot": "cloudfunctions/", "appid": "wx12b2fc1f01d3220c", "compileType": "miniprogram", "libVersion": "2.27.0", @@ -40,5 +41,7 @@ "tabIndent": "insertSpaces", "tabSize": 2 }, - "description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html" + "description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "miniprogram-1(1)", + "srcMiniprogramRoot": "miniprogram/" } \ No newline at end of file