Merge branch 'develop' of https://bdgit.educoder.net/pgpoiyf9w/clothesProject into guoxuanyu_branch

# Conflicts:
#	app.js
#	app.json
#	pages/navigation/index/add/add.js
#	pages/navigation/index/add/add.wxml
#	pages/navigation/index/add/camera/camera.js
#	pages/navigation/index/add/camera/camera.json
#	pages/navigation/index/add/camera/camera.wxml
#	pages/navigation/index/delete/delete.js
#	pages/navigation/index/delete/delete.wxml
#	pages/navigation/index/index.js
#	pages/navigation/index/index.wxml
#	pages/navigation/index/recommand/recommand.wxml
#	project.config.json
guoxuanyu_branch
郭炫宇 2 years ago
commit 3c7ac6aefb

@ -1,17 +1,44 @@
// app.js
App({
onLaunch: function () {
if (!wx.cloud) {
console.error('请使用 2.2.3 或以上的基础库以使用云能力');
} else {
wx.cloud.init({
//env:"apeach-wtz62"
env:'cloud1-5ggzbo3kcd4ea4e2'
})
// env 参数说明:
// env 参数决定接下来小程序发起的云开发调用wx.cloud.xxx会默认请求到哪个云环境的资源
// 此处请填入环境 ID, 环境 ID 可打开云控制台查看
// 如不填则使用默认环境(第一个创建的环境)
// env: 'my-env-id',
env: 'cloud1-5ggzbo3kcd4ea4e2',
traceUser: true,
});
}
},
//全局变量
globalData: {
url: null
},
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",
@ -558,4 +585,5 @@ App({
},
})

@ -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",

@ -0,0 +1,6 @@
{
"permissions": {
"openapi": [
]
}
}

@ -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,
}
})
}

@ -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"
}
}

@ -0,0 +1,7 @@
{
"permissions": {
"openapi": [
"wxacode.get"
]
}
}

@ -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'
};
}
};

@ -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;
};

@ -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,
};
};

@ -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);
}
};

@ -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"
}
}

@ -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();
};

@ -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();
};

@ -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
};
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 834 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 940 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

@ -1,12 +1,11 @@
// pages/navigation/index/add/add.js
let app=getApp();
import Toast from './@vant/weapp/toast/toast';
Page({
/**
* 页面的初始数据
*/
 
data: {
name:"",
pattern:"",
@ -17,14 +16,9 @@ Page({
thickness:"",
season:"" ,
url:""
},
cancel()
{
this.setData({ name:"",
pattern:"",
kind:"",
@ -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);
}
@ -80,7 +73,6 @@ Page({
console.log("数据123",this.data,app.globalData.clothes)
this.cancel();
},
/**
* 生命周期函数--监听页面加载
*/
@ -88,10 +80,6 @@ Page({
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
@ -137,11 +125,8 @@ Page({
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
 onShareAppMessage() {
  },
  
})

@ -1,8 +1,6 @@
<!--pages/navigation/index/add/add.wxml-->
<van-toast id="van-toast" />
<view style="padding:80rpx;">
<van-cell-group>

@ -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
  /**
   * 页面的初始数据
   */
  
  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() {
  }
})
},
gotoPage: function (options) {
wx.navigateTo({
//url: '../add/add',//要跳转到的页面路径
url:'../add',
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
  

@ -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() {
}
})

@ -31,7 +31,7 @@
<view>
{{item.kind}}
</view>
<van-icon color="red" name="close" bindtap="clear" data-index='{{index}}' data-id='{{}}'/>
<van-icon color="red" name="close" bindtap="clear" data-index='{{index}}' />
</view>
<van-divider />
</view>

@ -55,15 +55,13 @@ 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)
@ -76,6 +74,13 @@ tabbar_change(event) {
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;
@ -102,6 +107,7 @@ tabbar_change(event) {
}
},
/**
* 生命周期函数--监听页面加载
*/

@ -1,7 +1,7 @@
<!--pages/navigation/index/index.wxml-->
<van-toast id="van-toast" />
<view >
<image class="beijing2" src="../../img/背景.png"></image>
<view style="padding:40rpx;">
<view style=" display: -webkit-flex;display: flex;border-radius: 30rpx;background-color:white;">
<van-icon custom-style="margin-left:50rpx;"name="search" />

@ -1,6 +1,5 @@
<!--pages/navigation/index/recommand/recommand.wxml-->
<van-toast id="van-toast" />
<view >
<image class="beijing2" src="../../../img/背景.png"></image>

@ -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/"
}
Loading…
Cancel
Save