master
wbb 2 years ago
parent ee98635253
commit 79dda39119

@ -0,0 +1,31 @@
/*
* Eslint config file
* Documentation: https://eslint.org/docs/user-guide/configuring/
* Install the Eslint extension before using this feature.
*/
module.exports = {
env: {
es6: true,
browser: true,
node: true,
},
ecmaFeatures: {
modules: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
globals: {
wx: true,
App: true,
Page: true,
getCurrentPages: true,
getApp: true,
Component: true,
requirePlugin: true,
requireMiniProgram: true,
},
// extends: 'eslint:recommended',
rules: {},
}

@ -0,0 +1,12 @@
# 云开发 quickstart
这是云开发的快速启动指引,其中演示了如何上手使用云开发的三大基础能力:
- 数据库:一个既可在小程序前端操作,也能在云函数中读写的 JSON 文档型数据库
- 文件存储:在小程序前端直接上传/下载云端文件,在云开发控制台可视化管理
- 云函数:在云端运行的代码,微信私有协议天然鉴权,开发者只需编写业务逻辑代码
## 参考文档
- [云开发文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html)

@ -0,0 +1,51 @@
// app.js
App({
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-8g5wmepxce8a3b8a",
traceUser: true,
});
}
this.globalData = {};
// 获取用户openid
wx.cloud.callFunction({
name: 'get',
data: {},
success: res => {
this.globalData.openid = res.result.openid
},
fail: err => {
console.error('[云函数] [login] 调用失败', err)
}
})
console.log(this.globalData)
},
getOpenid() {
let that = this;
wx.cloud.callFunction({
name: 'get',
complete: res => {
console.log('openid: ', res.result.openid)
console.log('appid: ', res.result.appid)
// var openid = res.result.openId;
// that.setData({
// openid: openid
// })
}
})
}
})

@ -0,0 +1,69 @@
{
"pages": [
"pages/login/login",
"pages/index/index",
"pages/fourm/fourm",
"pages/submit/submit",
"pages/cart/cart",
"pages/usercenter/usercenter",
"pages/detail/detail",
"pages/searchShow/searchShow",
"pages/change/change",
"pages/answer/answer",
"pages/paying/paying",
"pages/orderlist/orderlist",
"pages/address/address",
"pages/turning/turning",
"pages/addAddress/addAddress",
"pages/myorder/myorder",
"pages/orderdetail/orderdetail"
],
"tabBar": {
"custom": false,
"backgroundColor": "#ffffff",
"borderStyle": "black",
"list": [
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "/images/home.png",
"selectedIconPath": "/images/home-active.png"
},
{
"pagePath": "pages/fourm/fourm",
"text": "论坛",
"iconPath": "/images/message.png",
"selectedIconPath": "/images/message-active.png"
},
{
"pagePath": "pages/cart/cart",
"text": "购物车",
"iconPath": "/images/message.png",
"selectedIconPath": "/images/message-active.png"
},
{
"pagePath": "pages/usercenter/usercenter",
"text": "我的",
"iconPath": "/images/message.png",
"selectedIconPath": "/images/message-active.png"
}
]
},
"window": {
"backgroundColor": "#F6F6F6",
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#F6F6F6",
"navigationBarTitleText": "节时不节食",
"navigationBarTextStyle": "black",
"enablePullDownRefresh": true
},
"networkTimeout": {
"request": 10000,
"downloadFile": 10000
},
"debug": true,
"sitemapLocation": "sitemap.json",
"style": "v2"
}

@ -0,0 +1,160 @@
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
button {
background: initial;
}
button:focus{
outline: 0;
}
button::after{
border: none;
}
page {
background: #f6f6f6;
display: flex;
flex-direction: column;
justify-content: flex-start;
}
/**app.wxss**/
/* .container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
/*padding: 200rpx 0;*/
/* box-sizing: border-box;
background: #F0F4F3;
} */
.container.withtab{
margin: 105rpx 0 0 0;
/*top: 105rpx;*/
}
.flex-wrp{
display: flex;
}
.flex-tab{
flex-flow: row nowrap;
justify-content: space-around;
align-items: stretch;
}
.flex-item{
flex-grow: 1;
text-align: center;
}
.top-tab{
width: 750rpx;
height: 100rpx;
background: #298DE5;
color: #8CCEFD;
font-size: 28rpx;
line-height: 100rpx;
box-shadow: 0 2px 2px #bebebe;
margin: 0 0 8rpx 0;
position: fixed;
top: 0;
z-index: 9999;
}
.toptab.active{
color: #ffffff;
border-bottom: solid 2px #ffffff;
}
.container{
padding: 0;
font-size: 14rpx;
color: #000;
}
.container .feed-item{
width: 690rpx;
padding: 30rpx 30rpx 20rpx;
margin: 7rpx 0 6rpx 0;
background: #ffffff;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
box-shadow: 0 2px 5px #eeeeee;
}
.container .feed-item .feed-source{
width: 690rpx;
left: 0;
height: 50rpx;
}
.container .feed-item .feed-source .avatar{
position: relative;
display: inline-block;
}
.container .feed-item .feed-source a{
display: inline-block;
height: 40rpx;
}
.container .feed-item .feed-source .avatar image{
/*position: absolute;*/
display: inline-block;
width: 45rpx;
height: 45rpx;
border-radius: 45rpx;
top: 10rpx;
vertical-align: middle;
}
.container .feed-item .feed-source text{
/*position: absolute;*/
display: inline-block;
height: 40rpx;
line-height: 40rpx;
vertical-align: middle;
margin: 0 0 0 15rpx;
color: #a0acac;
font-size: 26rpx;
}
.container .feed-item .feed-source .item-more{
display: inline-block;
width: 40rpx;
height: 45rpx;
float: right;
}
.container .feed-item .feed-content{
padding: 10rpx 0 0 0;
}
.container .feed-item .feed-content .question text{
font-size: 28rpx;
font-weight: 600px;
line-height: 40rpx;
word-spacing: 5rpx;
}
.container .feed-item .feed-content .answer-body{
padding: 10rpx 0 0 0;
/*height: 10rpx;*/
font-size: 24rpx;
line-height: 28rpx;
color: #5b5b5b;
}
.container .feed-item .feed-content .answer-actions{
width: 690rpx;
padding: 10rpx 0 0;
color: #a0acac;
}
.container .feed-item .feed-content .answer-actions view{
display: inline-block;
vertical-align: text-bottom;
padding: 0 10rpx 0 0;
font-size: 24rpx;
}
.container .feed-item .feed-content .answer-actions .dot ::after{
content: "•";
}

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

@ -0,0 +1,16 @@
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
return {
event,
openid: wxContext.OPENID,
appid: wxContext.APPID,
unionid: wxContext.UNIONID,
}
}

@ -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: "cloud1-8g5wmepxce8a3b8a"
});
// 获取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
};
}
};

@ -0,0 +1,6 @@
const envList = [{"envId":"cloud1-8g5wmepxce8a3b8a","alias":"cloud1"}]
const isMac = false
module.exports = {
envList,
isMac
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

@ -0,0 +1,267 @@
var address=require('../../utils/mock.js');
const db = wx.cloud.database({});
const app=getApp();
const userid=app.globalData.openid;
Page({
/**
* 页面的初始数据
*/
data: {
animationAddressMenu: {},
addressMenuIsShow: false,
value: [0, 0, 0],
provinces: [],
citys: [],
areas: [],
consigneeName: "",
phone: "",
consigneeRegion: "",
detailedAddress: "",
labelList: ["家", "公司", "学校"], //标签
labelDefault: 0, // 标签默认,
addresslist:{}
},
consigneeNameInput: function(e) {
this.setData({
consigneeName: e.detail.value
})
},
phoneInput: function(e) {
this.setData({
phone: e.detail.value
})
},
consigneeRegionInput: function (e) {
this.setData({
consigneeRegion: e.detail.value
})
},
detailedAddressInput: function (e) {
this.setData({
detailedAddress: e.detail.value
})
},
chooseLabelSelect: function(e) {
var index = e.currentTarget.dataset.index;
this.setData({
labelDefault: index
})
},
submit: function() {
var consigneeName = this.data.consigneeName;
console.log(consigneeName)
var phone = this.data.phone;
console.log(phone)
var consigneeRegion = this.data.consigneeRegion;
console.log(consigneeRegion)
var detailedAddress = this.data.detailedAddress
console.log(detailedAddress)
if (consigneeName == "") {
wx: wx.showToast({
title: '请输入姓名',
})
return false
}
else if (phone == "") {
wx: wx.showToast({
title: '请输入手机号码'
})
return false
}
else if (consigneeRegion == "") {
wx: wx.showToast({
title: '请选择所在地区'
})
return false
}
else if (detailedAddress == "") {
wx: wx.showToast({
title: '请输入详细地址',
})
return false
}
else {
var check=false
var addresslist={}
addresslist.name=this.data.consigneeName
addresslist.phone=this.data.phone
addresslist.address=this.data.consigneeRegion
addresslist.detailedAddress=this.data.detailedAddress
addresslist.check=check
this.setData({
addresslist:addresslist
})
db.collection('user').where({
"_openid":userid
})
.update(
{
data:{
address:db.command.push(addresslist)
}
},
)
console.log(addresslist)
db.collection('user').where({
"_openid":userid
})
.get({
success: res => {
console.log(res.data)}
})
console.log(userid)
wx.navigateTo({
url: '/pages/address/address',
})
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// 默认联动显示北京
var id = address._provinces[0].id
console.log(address._provinces[0].id)
this.setData({
provinces: address._provinces,
citys: address._citys[id],
areas: address._areas[address._citys[id][0].id],
})
},
// 点击所在地区弹出选择框
select: function (e) {
// 如果已经显示,不在执行显示动画
if (this.data.addressMenuIsShow) {
return false
} else {
// 执行显示动画
this.startAddressAnimation(true)
}
},
// 执行动画
startAddressAnimation: function (isShow) {
if (isShow) {
// vh是用来表示尺寸的单位高度全屏是100vh
this.animation.translateY(0 + 'vh').step()
} else {
this.animation.translateY(40 + 'vh').step()
}
this.setData({
animationAddressMenu: this.animation.export(),
addressMenuIsShow: isShow,
})
},
// 点击地区选择取消按钮
cityCancel: function (e) {
this.startAddressAnimation(false)
},
// 点击地区选择确定按钮
citySure: function (e) {
var that = this
var city = that.data.city
var value = that.data.value
this.startAddressAnimation(false)
// 将选择的城市信息显示到输入框
var consigneeRegion = that.data.provinces[value[0]].name + '-' + that.data.citys[value[1]].name + '-' + that.data.areas[value[2]].name
that.setData({
consigneeRegion: consigneeRegion,
})
},
// 处理省市县联动逻辑
cityChange: function (e) {
var value = e.detail.value
var provinces = this.data.provinces
var citys = this.data.citys
var areas = this.data.areas
var provinceNum = value[0]
var cityNum = value[1]
var countyNum = value[2]
// 如果省份选择项和之前不一样,表示滑动了省份,此时市默认是省的第一组数据,
if (this.data.value[0] != provinceNum) {
var id = provinces[provinceNum].id
this.setData({
value: [provinceNum, 0, 0],
citys: _citys[id],
areas: _areas[_citys[id][0].id],
})
} else if (this.data.value[1] != cityNum) {
// 滑动选择了第二项数据,即市,此时区显示省市对应的第一组数据
var id = citys[cityNum].id
this.setData({
value: [provinceNum, cityNum, 0],
areas: _areas[citys[cityNum].id],
})
} else {
// 滑动选择了区
this.setData({
value: [provinceNum, cityNum, countyNum]
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
var animation = wx.createAnimation({
duration: 500,
timingFunction: 'linear',
})
this.animation = animation
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,4 @@
{
"usingComponents": {},
"initialRenderingCache": "dynamic"
}

@ -0,0 +1,81 @@
<!--pages/my/my-add-address/index.wxml-->
<view class="redact-address">
<view class="possess-layout">
<view class="mains">
<view class="address-msg">
<view class="item-msg">收货人</view>
<view class="section">
<input type="text" placeholder="请填写收货人姓名" value="{{consigneeName}}" bindblur="consigneeNameInput" placeholder-class="phcolor"></input>
</view>
<view class="address-right">
</view>
</view>
<view class="address-msg">
<view class="item-msg">手机号码</view>
<view class="section">
<input type="number" placeholder="请填写收货人手机号码" value="{{phone}}" maxlength="11" bindblur="phoneInput" placeholder-class="phcolor"></input>
</view>
</view>
<view class="address-msg">
<view class="item-msg">所在地区</view>
<view class="section" bindtap='select'>
<input disabled="disabled" placeholder="省市区县、乡镇等" value="{{consigneeRegion}}" bindblur="consigneeRegionInput" placeholder-class="phcolor"></input>
</view>
<view class="address-rights" bindtap='select'>
<view>定位</view>
</view>
</view>
<view class="address-msg">
<view class="item-msg">详细地址</view>
<view class="section">
<input type="text" placeholder="街道、楼牌号等" value="{{detailedAddress}}" bindblur="detailedAddressInput" placeholder-class="phcolor"></input>
</view>
</view>
<view class="label">
<view class="label-title">标签</view>
<view class="label-list">
<block wx:for="{{labelList}}" wx:key="index">
<view class="labels {{labelDefault==index? 'labels-active': ''}}" data-index="{{index}}" bindtap="chooseLabelSelect">{{item}}</view>
</block>
</view>
</view>
<view class="default-setting">
<view class="defaul-setting-left">
<view>设置默认地址</view>
<view>提醒:每次下单会默认推荐使用该地址</view>
</view>
</view>
</view>
</view>
</view>
<view class="btn" bindtap="submit">保存</view>
<view class="picker" animation="{{animationAddressMenu}}" style="visibility:{{addressMenuIsShow ? 'visible':'hidden'}}">
<view class="picker-view" animation="{{animationAddressMenu}}" style="visibility:{{addressMenuIsShow ? 'visible':'hidden'}}">
<!-- 确认取消按钮 -->
<view class='gangedBtn'>
<text class="city-cancel" catchtap="cityCancel">取消</text>
<text style="float: right" catchtap="citySure">确定</text>
</view>
<!-- 选择地址 -->
<picker-view class='cont' bindchange="cityChange" value="{{value}}" wx:key="">
<!-- 省 -->
<picker-view-column>
<view wx:for="{{provinces}}" class="picker-item" wx:key="index">{{item.name}}</view>
</picker-view-column>
<!-- 市 -->
<picker-view-column>
<view wx:for="{{citys}}" class="picker-item" wx:key="index">{{item.name}}</view>
</picker-view-column>
<!-- 区 -->
<picker-view-column>
<view wx:for="{{areas}}" class="picker-item" wx:key="index">{{item.name}}</view>
</picker-view-column>
</picker-view>
</view>
</view>

@ -0,0 +1,198 @@
/* pages/my/my-add-address/index.wxss */
.redact-address {
background: white;
margin-bottom: 20rpx;
}
.address-msg {
height: 128rpx;
display: flex;
align-items: center;
background: #FFFFFF;
border-top: 2rpx solid #efefef;
font-size: 28.68rpx;
color: #333333;
padding: 0 20rpx;
}
.address-right image {
width: 32rpx;
height: 32rpx;
}
.address-rights {
display: flex;
align-items: center;
}
.address-rights image {
width: 26rpx;
height: 32rpx;
margin-right: 13rpx;
}
.address-rights view {
font-size: 28.68rpx;
}
.address-msg:last-child {
border-bottom: none;
}
.section {
width: 58%;
}
.phcolor {
color: #999999;
}
.item-msg {
width: 25%;
margin-right: 25rpx;
}
.img {
width: 35rpx;
height: 35rpx;
align-self: center;
}
.address-right {
width: 100rpx;
display: flex;
flex-direction: row-reverse;
}
/* 标签 */
.label {
display: flex;
height: 128rpx;
align-items: center;
margin-top: 73rpx;
border-top: 1px solid #EEEEEE;
border-bottom: 1px solid #EEEEEE;
padding: 0 20rpx;
}
.label-title {
font-size: 28.68rpx;
color: #333333;
margin-right: 83rpx;
}
.label .label-list {
display: flex;
}
.label .label-list .labels{
height: 40rpx;
width: 96rpx;
border: 1px solid #EEEEEE;
margin-right: 37rpx;
text-align: center;
line-height: 40rpx;
font-size: 24rpx;
color: #000000;
border-radius: 20rpx;
}
.labels-active {
background: #F73C41 !important;
color: #FFFFFF !important;
}
/* 默认设置 */
.default-setting {
display: flex;
justify-content: space-between;
align-items: center;
height: 160rpx;
padding: 0 20rpx;
}
.defaul-setting-left view:nth-child(1){
font-size: 28.68rpx;
color: #333333;
margin-bottom: 25rpx;
}
.defaul-setting-left view:nth-child(2) {
font-size: 20rpx;
color: #333333;
}
.defaul-setting-right {
height: 64rpx;
width: 105rpx;
}
.btn {
width: 680rpx;
height: 88rpx;
background: #F73C41;
color: #FFFFFF;
position: fixed;
bottom: 55rpx;
left: 35rpx;
border-radius: 41.5rpx;
font-size: 36rpx;
text-align: center;
line-height: 88rpx;
}
/* 城市选择 */
.picker {
width: 100%;
height: 100%;
display: flex;
z-index: 12;
background-color: #fff;
background: rgba(0, 0, 0, 0.2);
flex-direction: column;
justify-content: center;
align-items: center;
position: fixed;
bottom: 0;
left: 0rpx;
}
.picker-view {
width: 100%;
display: flex;
z-index: 12;
background-color: #fff;
flex-direction: column;
justify-content: center;
align-items: center;
position: fixed;
bottom: 0;
left: 0rpx;
height: 40vh;
border-top-left-radius: 30rpx;
border-top-right-radius: 30rpx;
}
.gangedBtn {
border-top: 1px solid #efefef;
border-top-left-radius: 30rpx;
border-top-right-radius: 30rpx;
width: 100%;
height: 90rpx;
padding: 0 66rpx;
box-sizing: border-box;
line-height: 90rpx;
text-align: center;
color: black;
font-size: 0.8rem;
display: flex;
background: white;
justify-content: space-between;
}
.cont {
width: 100%;
height: 389rpx;
}
.picker-item {
line-height: 70rpx;
margin-left: 5rpx;
margin-right: 5rpx;
text-align: center;
}
.address {
width: 100%;
height: 90rpx;
line-height: 90rpx;
text-align: center;
border-bottom: 1rpx solid #f1f1f1;
}
.city-cancel {
color: gray;
}

@ -0,0 +1,123 @@
// pages/address/address.js
const db = wx.cloud.database({});
const app=getApp()
const userid=app.globalData.openid
Page({
/**
* 页面的初始数据
*/
data: {
addressList:[]
},
//增加地址
addAddress:function(){
wx.navigateTo({ url: '/pages/addAddress/addAddress' });
},
delAddress:function(event){
var that = this;
const index = event.currentTarget.id;
console.log(index)
let addressList = this.data. addressList;//购物车所有的商品数据
wx.showModal({
title: '温馨提示',
content: '确定删除当前地址吗?',
confirmColor: "#f00",
success: (res) => {
if (res.confirm) {
addressList.splice(index, 1);
this.setData({
addressList:addressList
})
db.collection('user')//回调回云数据库
.where({
"_openid":userid
})
.update(
{
data:{
['address']:this.data.addressList
}
}
)
}}
})
console.log(addressList)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
db.collection('user').
where({
"_openid":userid
}) //还需修改
.get({
success: res => {
console.log(res.data.address)
console.log(res.data)
//这一步很重要给ne赋值没有这一步的话前台就不会显示值
this.setData({
addressList: res.data[0].address
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "管理地址"
}

@ -0,0 +1,41 @@
<!--pages/address/address.wxml-->
<scroll-view class="scroll" scroll-y="true">
<view wx:for="{{addressList}}">
<view class="product-name-wrap">
<view class="ui-list-item-info">{{item.address}}
<text decode="{{true}}" space="{{true}}">&nbsp;&nbsp;</text> {{item.phone}}
</view>
<view class="ui-list-item-address">
<text>{{item.detailedAddress}}</text>
</view>
<view class="ui-list-item-time">
<p>{{item.name}}</p>
<p class="ui-list-item-del" data-id="{{index}}" bindtap="delAddress">删除</p>
</view>
<view class="separate"></view>
</view>
</view>
</scroll-view>
<view class="add-address" bindtap="addAddress">
<image class="add-img" src="/images/add.jpg"></image>新增地址
</view>

@ -0,0 +1,92 @@
/* pages/address/address.wxss */
page{
display: flex;
flex-direction: column;
height: 100%;
}
.product-name-wrap{
margin: 0px 10px;
font-size: 14px;
color: #404040;
}
.ui-list-item-info{
margin: 5px 0px;
}
.ui-list-item-address{
color: #585c64;
}
.ui-list-item-time{
margin: 5px 0px;
}
.ui-list-item-del{
position: absolute;
right: 10px;
color: #585c64;
}
/* 分割线 */
.separate {
margin: 5px 0px;
height: 2rpx;
background-color: #f2f2f2;
}
.add-address{
margin: 0 auto;
margin-top: 30px;
width: 150px;
height: 35px;
border: 1px #000 solid;
line-height: 35px;
text-align: center;
color: #000;
border-radius: 5rpx;
display: block;
}
.add-img{
margin-right: 15rpx;
width: 15px;
height: 15px;}

@ -0,0 +1,297 @@
//answer.js
let dianzan=false
var app = getApp()
Page({
data: {
motto: '知乎--微信小程序版',
userInfo: {},
feed: [],
//修改
pinglun:[], //评论数组
content:'',
detail: '',
dianzanUrl: "../../images/heart2.png",
comment_num:0
},
//事件处理函数
// toQuestion: function() {
// wx.navigateTo({
// url: '../question/question'
// })
// },
onLoad: function (options) {
var aid=options.aid
console.log(options);
console.log(options.aid);
console.log('onLoad')
wx.setStorageSync('aid', aid)
//修改
wx.cloud.database().collection("tiezi")
.doc(aid)
.get()
.then(res => {
console.log("详情页成功", res);
//将收藏添加到数据库
//shoucang = res.data.shoucang
//dianzan = res.data.dianzan
//console.log(shoucang, dianzan);
//再次显示数据
this.setData({
detail: res.data,
pinglun:res.data.pinglun
})
})
.catch(err => {
console.log("详情页失败", err);
})
var getId = options.aid;
// 让接收到的id值传递到data:{}里面
this.setData({
currentId: getId
});
// 读取所有的文章列表点赞缓存状态
var cache = wx.getStorageSync('cache_key');
// 如果缓存状态存在
if (cache) {
// 拿到所有缓存状态中的1个
var currentCache = cache[getId];
// 把拿到的缓存状态中的1个赋值给data中的collection如果当前文章没有缓存状态currentCache 的值就是 false如果当前文章的缓存存在那么 currentCache 就是有值的,有值的说明 currentCache 的值是 true
this.setData({
collection: currentCache
})
} else {
// 如果所有的缓存状态都不存在 就让不存在的缓存存在
var cache = {};
// 既然所有的缓存都不存在,那么当前这个文章点赞的缓存也不存在,我们可以把当前这个文章点赞的缓存值设置为 false
cache[getId] = false;
// 把设置的当前文章点赞放在整体的缓存中
wx.setStorageSync('cache_key',cache);
}
},
// 点击图片的点赞事件 这里使用的是同步的方式
toCollect: function(options) {
let aid= wx.getStorageSync ("aid")
console.log(aid);
// 获取所有的缓存
var cache = wx.getStorageSync('cache_key');
// 获取当前文章是否被点赞的缓存
var currentCache = cache[this.data.currentId];
// 取反,点赞的变成未点赞 未点赞的变成点赞
currentCache = !currentCache;
// 更新cache中的对应的1个的缓存值使其等于当前取反的缓存值
cache[this.data.currentId] = currentCache;
// 重新设置缓存
wx.setStorageSync('cache_key',cache);
// 更新数据绑定,从而切换图片
this.setData({
// collection 默认的是 false
collection: currentCache
});
// 交互反馈
wx.showToast({
title: currentCache?'点赞':'取消',
icon: 'success',
duration: 2000
});
if(currentCache==true){
wx.cloud.database().collection("tiezi")
.doc(aid)
.update({
data: {
// 前面为数据库字段,后面为修改之后的值
good_num: wx.cloud.database().command.inc(1),
}
})
.then(res => {
console.log("添加评论成功", res);
return res
})
.catch(err => {
console.log("添加评论失败", err);
return err
})
}
else{
wx.cloud.database().collection("tiezi")
.doc(aid)
.update({
data: {
// 前面为数据库字段,后面为修改之后的值
good_num: wx.cloud.database().command.inc(-1),
}
})
.then(res => {
console.log("成功", res);
return res
})
.catch(err => {
console.log("失败", err);
return err
})
}
},
/*
onLoad: function (options) {
},*/
tapName: function(event){
console.log(event)
},
//获取输入的值
getContent(event){
this.setData({
content:event.detail.value
})
},
//发表评论
fabiao(options){
let content=this.data.content
if(content.length<4){
wx.showLoading({
icon:"none",
title: '评论太短了',
})
return
}
let pinglunItem={}
pinglunItem.nickName=wx.getStorageSync ("nickName")
pinglunItem.avatarUrl=wx.getStorageSync ("avatarUrl")
pinglunItem.content=content
let pinglunArr=this.data.pinglun
pinglunArr.push(pinglunItem)
let l= pinglunArr.length
console.log("评论数",l)
console.log("添加后的评论数组",pinglunArr)
wx.showLoading({
title: '发表中',
})
wx.cloud.init({
env:"cloud1-8g5wmepxce8a3b8a",
})
let aid= wx.getStorageSync ("aid")
console.log(aid);
//异步操作
wx.cloud.database().collection("tiezi")
.doc(aid)
.update({
data: {
// 前面为数据库字段,后面为修改之后的值
pinglun: pinglunArr,
comment_num:pinglunArr.length
}
})
.then(res => {
console.log("添加评论成功", res);
return res
})
.catch(err => {
console.log("添加评论失败", err);
return err
})
let that = this;
wx.hideLoading({
success: (res) => {
that.setData({
pinglun:pinglunArr,
content:''
})
wx.showToast({
title: '发布成功',
})}})
},
//点赞切换
clickDianzan() {
this.setData({
dianzanUrl: dianzan ? "../../images/heart2.png" : "../../images/heart1.png"
})
dianzan = !dianzan
wx.setStorageSync ("dianzan",dianzan)
console.log("改变点赞状态", dianzan)
},
amend: function(e) {
let aid= wx.getStorageSync ("aid")
console.log(aid);
wx.showModal({
title: '编辑',
content: '确定要修改已发布的信息吗?',
success(res) {
if(res.confirm) {
wx.redirectTo({
url: '../change/change?aid='+aid,
})
console.log('用户点击了确定')
}else if(res.cancel) {
console.log('用户点击了取消')
}
}
})
},
delete(event){
let aid= wx.getStorageSync ("aid")
console.log(aid);
wx.cloud.database().collection('tiezi')
.doc(aid)
.remove()
.then(res => {
console.log(res);
}).catch(res => {
console.log(res);
})
wx.switchTab({
url: '../fourm/fourm'
})
},
delete_p: function(event) {
/*wx.navigateTo({
url: '../answer/answer'
})*/
let aid= wx.getStorageSync ("aid")
console.log(aid);
var aidc=event.currentTarget.dataset.aidc;
console.log(aidc)
//console.log("1")
wx.cloud.database().collection('tiezi')
.where({
'_id':aid,
'pinglun.content':aidc
})
.update({
data:{
pinglun:wx.cloud.database().command.pull({
content:aidc
}),
comment_num:wx.cloud.database().command.inc(-1)
}
})
.then(res => {
console.log(res);
console.log(res);
wx.showLoading({
title: '删除成功...',
})
wx.redirectTo({
url: '../answer/answer?aid='+aid,
})
wx.hideLoading()
}).catch(res => {
console.log(res);
})
}
})

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "回答"
}

@ -0,0 +1,93 @@
<!--answer.wxml-->
<!--<block wx:for="{{feed}}" wx:key="index">-->
<view class="mycontainer">
<view class="a" >
<view class="question" >
<text class="question-title">{{detail.title}}</text>
</view>
<view class="answerer-wrp">
<view class="bg-half"></view>
<view class="answerer flex-wrp">
<view class="avatar flex-item">
<image src="{{detail.feed_source_img}}"></image>
</view>
<view class="answerer-info flex-item">
<text class="answerer-name">{{detail.feed_source_name}}</text>
<text class="answerer-des">喜欢就点个赞吧~</text>
</view>
<!-- <view class="follow flex-item"> -->
<view class="follow flex-item">
<!-- 删除 -->
<image data-aid="{{detail._id}}" bindtap="delete" class="a3" src="/images/delete.png"></image>
<text>删除</text>
<!-- </view> -->
</view>
<view class="follow flex-item">
<!-- 修改 -->
<image data-aid="{{detail._id}}" bindtap="amend" class="image" src="/images/write.png"></image>
<text>编辑</text>
<!-- </view> -->
</view>
<view class="follow flex-item">
<image wx:if="{{collection}}" src="../../images/heart1.png" bindtap="toCollect"></image>
<image wx:else src="../../images/heart2.png" bindtap="toCollect"></image>
<text>点赞</text>
<!-- </view> -->
</view>
</view>
</view>
<view class="answer-content">
<text class="desc" style="white-space:pre-wrap;">{{detail.content}}</text>
<image webp wx:for="{{detail.url}}" mode='widthFix' src="{{item}}" ></image>
</view>
</view>
<!--</block>-->
<!-- 评论 -->
<block wx:for="{{pinglun}}" wx:key="index">
<view class="pinglunItem ">
<view>
<image class="a1" src="{{item.avatarUrl}} "></image>
</view>
<view >
<view class="desc" >{{item.nickName}}{{item.content}}</view>
</view>
<view>
<image data-aidc="{{item.content}}" bindtap="delete_p" class="a2" src="/images/delete.png"></image>
</view>
</view>
</block>
<view class="search flex-wrp">
<view class="search-left flex-item">
<input placeholder="请输入评论的内容" placeholder-class="search-placeholder" bindinput="getContent" value="{{content}}"/>
</view>
<view class="search-right flex-item" bindtap="fabiao">
<view class="desc">发表</view>
</view>
</view>
<view class="standView"></view>
</view>

@ -0,0 +1,300 @@
/**answer.wxss**/
.mycontainer{
margin-bottom: 200rpx;
}
.a {
padding: 0;
font-size: 14rpx;
background: #F0F4F3;
color: #000;
}
.question {
position: relative;
width: 650rpx;
padding: 40rpx 50rpx 30rpx;
background: #298DE5;
color: #fff;
font-size: 38rpx;
line-height: 48rpx;
}
.answerer-wrp{
position: relative;
width: 750rpx;
height: 150rpx;
background: #fff;
}
.answerer-wrp .bg-half{
position: absolute;
top: 0;
width: 750rpx;
height: 75rpx;
background: #298DE5;
}
.answerer {
position: relative;
margin: 0 auto;
width: 630rpx;
height: 90rpx;
padding: 30rpx;
background: #fff;
border: solid 1px #ebebeb;
border-radius: 3px;
box-shadow: 0 1px 2px #bebebe;
}
.answerer .avatar {
flex: 1;
width: 90rpx;
height: 90rpx;
}
.answerer .avatar image {
display: inline-block;
width: 90rpx;
height: 90rpx;
border-radius: 90rpx;
}
.answerer .answerer-info{
flex: 5;
text-align: left;
padding: 10rpx 20rpx;
line-height: 38rpx;
}
.answerer .answerer-info text{
display: block;
}
.answerer .answerer-info .answerer-name{
font-size: 32rpx;
}
.answerer .answerer-info .answerer-des{
font-size: 22rpx;
color: #808080;
line-height: 28rpx;
}
.answerer .follow image{
/* flex: 2;
padding: 15rpx 0;
font-size: 22rpx; */
display: block;
margin: 0 auto;
width: 40rpx;
height: 40rpx;
}
.answerer .follow text{
/* display: inline-block;
padding: 15rpx 20rpx;
color: #40bcd0;
border: solid 2px #40bcd0;
border-radius: 6rpx; */
display: block;
font-size: 14rpx;
color: #bebebe;
}
.answerer .follow .a3{
/* flex: 2;
padding: 15rpx 0;
font-size: 22rpx; */
display: block;
margin: 0 auto;
width: 30rpx;
height: 35rpx;
margin-top: 9rpx;
}
.answer-content{
padding: 30rpx 40rpx;
background: #ffffff;
}
.answer-content text{
font-size: 32rpx;
color: #454545;
line-height: 44rpx;
word-break: break-all;
}
.answer-content image{
width: 100%;
margin: 20rpx 0;
}
.answer-footer{
width: 750rpx;
height: 70rpx;
font-size: 28rpx;
box-shadow: 0 100px 7px #bebebe;
margin: 0 200rpx 0 0;
position: sticky ;
bottom: 0;
z-index: 9999;
}
.answer-footer{
position: fixed;
bottom: 0;
height: 70rpx;
border-top: solid 1px #ebebeb;
background: #ffffff;
width: 670rpx;
padding: 20rpx 40rpx;
}
.answer-footer .good{
flex: 1;
/*display: inline-block;*/
height: 40rpx;
border: solid 1px #d1d1d1;
border-radius: 3px;
padding: 10rpx 8rpx;
margin: 10rpx 0;
}
.answer-footer .good .good-bad{
display: inline-block;
}
.answer-footer .good image{
display: inline-block;
width: 38rpx;
height: 38rpx;
vertical-align: middle;
}
.answer-footer .good .good-num{
display: inline-block;
padding: 10rpx 4rpx;
/*font-size: 24rpx;*/
}
.answer-footer .operation-wrp{
flex: 5;
}
.answer-footer .operation{
justify-content: space-between;
padding: 0 0 0 60rpx;
}
.answer-footer .operation-btn{
flex: 1;
text-align: center;
}
.answer-footer .operation image{
display: block;
margin: 0 auto;
width: 50rpx;
height: 50rpx;
}
.answer-footer .operation-btn text{
display: block;
font-size: 14rpx;
color: #bebebe;
}
/* .tip{
position: relative;
width: 650rpx;
padding: 30rpx 50rpx 30rpx;
/*background: #298DE5;*/
/* color: rgb(0, 0, 0);
font-size: 38rpx;
line-height: 48rpx;
} */
.input{
display:block;
border:2px solid gainsboro;
margin-top: 60rpx;
margin-bottom: 60rpx;
}
.pinglunItem{
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
border-top: 2px solid gainsboro;
margin-left: 0rpx;
margin-top: 0rpx;
}
.pinglunItem .a1{
margin-left: 30rpx;
margin-right: 30rpx;
margin-top: 20rpx;
margin-bottom: 20rpx;
width: 60rpx;
height: 60rpx;
border-radius: 90rpx;
}
.pinglunItem .desc{
font-size: 30rpx;
height: 40rpx;
}
.pinglunItem .a2 {
margin-left: 100rpx;
margin-right: 30rpx;
margin-top: -20rpx;
width: 30rpx;
height: 35rpx;
position: absolute; /* 要约束所在位置的子元素的位置要设置成绝对 */
right: 0;
}
.search{
position: fixed;
bottom: 0;
width: 735rpx;
height: 65rpx;
padding: 12.5rpx 0 12.5rpx 15rpx;
background: #2A8CE5;
}
.search-left{
flex: 8;
background: #4EA3E7;
text-align: left;
}
.search-left input{
display: inline-block;
height: 65rpx;
font-size: 26rpx;
}
.search-placeholder{
color: #8CCEFD;
line-height: 20rpx;
}
.search .search-left image{
display: inline-block;
width: 35rpx;
height: 35rpx;
padding: 15rpx 15rpx 15rpx 20rpx;
}
.search .search-right{
flex: 1;
}
.search .search-right .desc{
font-size: 25rpx;
color: #ffffff;
margin:15rpx
}
/* 解决底部导航栏遮挡的占位view的样式 */
.standView{
width: 100%;
height: 100rpx; /* 自定义一下需要的高度 */
/* background-color: black; */
}

@ -0,0 +1,310 @@
// pages/cart/cart.js
const db = wx.cloud.database({});
const app=getApp()
const userid=app.globalData.openid
Page({
/**
* 页面的初始数据
*/
data: {
cartlistsee:[], //该用户购物车的数组
total_all_price:0, //商品的总价格
all_shop: 0, //所选商品的id
shop_num: 0, //所选商品的数量
good_one: [], //单个商品的数据
checked: false, //是否为全选
is_shop: false, //是否有商品
shopData: null,
Selection:{}
},
/**点击单个多选框 */
allCheckbox: function(tap) {
var a = 0 //设置初始总价格
var index = tap.currentTarget.dataset.index
console.log(index)//获取索引值
let good = this.data.cartlistsee //获取购物车列表
const checks = good[index].checks; //获取当前商品的选中状态
good[index].checks = !checks //改变当前商品的状态
console.log(checks)
var all_shop_1 = parseInt(good[index]._id) //获取商品的购物车id
var shop_num_1 = good[index].num //获取商品的数量
this.setData({
cartlistsee: good
});
this.getTotalPrice() //重新获取总价格
/*设置全选 */
},
/**点击全选 */
setChecked: function() {
let checked = this.data.checked; //是否为全选状态
checked = !checked; //改变状态
let cartlistsee = this.data.cartlistsee;
for (let i = 0; i < cartlistsee.length; i++) {
cartlistsee[i].checks = checked; // 改变所有商品状态
}
this.setData({
checked: checked, //更新全选状态
cartlistsee: cartlistsee //更新所有商品的状态
});
this.getTotalPrice(); //重新获取总价格
},
//计算商品总价格
getTotalPrice() {
let good = this.data.cartlistsee; // 获取购物车列表
let total = 0;
for (let i = 0; i < good.length; i++) { // 循环列表得到每个数据
if (good[i].checks) { // 判断选中才会计算价格
total += good[i].num * good[i].price; // 所有价格加起来
}
}
this.setData({ // 最后赋值到data中渲染到页面
good: good,
total_all_price: total.toFixed(2),
});
},
//点击结算订单
toBuy: function(tap) {
var that = this;
let good = this.data.cartlistsee; //所有商品数据
let user_info = wx.getStorageSync('user_data')
if (that.data.total_all_price == 0) { //判断是否选择了商品,这里我是判断总价格
wx.showToast({
title: '请选择商品',
})
} else {
this.data.good_one = []; //重置数组
for (var i = 0; i < this.data.cartlistsee.length; i++) { //循环购物车中的商品
if (good[i].checks == true) {
var Selection=[]
var good_one1 = {}
good_one1._id=good[i]._id
good_one1.url=good[i].url
good_one1.food_name=good[i].food_name
good_one1.food_shop=good[i].food_shop
good_one1.price=good[i].price
good_one1.num=good[i].num
var all=this.data.total_all_price
Selection.push(good_one1)
this.setData({
Selection:Selection
})
//将数据添加到数组里边
this.getTotalPrice()
wx.navigateTo({
url:'/pages/paying/paying?info='+JSON.stringify(Selection)+'&totalprice='+this.data.total_all_price
})
}
}}},
topay: function(){
},
// 添加按钮被点击
addButtonClick: function(event) {
var that = this;
const index = event.currentTarget.id;
console.log(index)//获取缓存里面的用户信息
let cartlistsee = this.data.cartlistsee;//购物车所有的商品数据
console.log(cartlistsee)
console.log(cartlistsee[index])
let num =cartlistsee[index].num//获取购买数量
num=num+1
cartlistsee[index].num= num;
that.setData({
cartlistsee:cartlistsee //更新商品数据
})
console.log(cartlistsee)
db.collection('user').
where({
"_openid":userid
}) //还需修改
.update(
{
data:{
['cartlist.'+[index]]:{num}
}
}
)
this.getTotalPrice()
},
reduceButtonClick: function(event) {
var that = this;
const index = event.currentTarget.id;
console.log(index)//获取缓存里面的用户信息
let cartlistsee = this.data.cartlistsee;//购物车所有的商品数据
console.log(cartlistsee)
console.log(cartlistsee[index])
let num =cartlistsee[index].num//获取购买数量
if(num == 1){
wx.showModal({
title: '提示',
content: '已是最后一件商品',
})
}
else{//如果商品数量不等于 1
num=num-1
cartlistsee[index].num= num;
that.setData({
cartlistsee:cartlistsee //更新商品数据
})
console.log(cartlistsee)
db.collection('user')//回调回云数据库
.where({
"_openid":userid
}) //还需修改
.update(
{
data:{
['cartlist.'+[index]]:{num}
}
}
)
this.getTotalPrice()
}
},
//删除单个商品
deleteGoods(event) {
var that = this;
const index = event.currentTarget.id;
console.log(index)
let cartlistsee = this.data.cartlistsee;//购物车所有的商品数据
let foodid=cartlistsee[index]._id
console.log(foodid)
wx.showModal({
title: '温馨提示',
content: '确定删除当前商品吗?',
confirmColor: "#f00",
success: (res) => {
if (res.confirm) {
cartlistsee.splice(index, 1);
this.setData({
cartlistsee:cartlistsee
})
db.collection('user')//回调回云数据库
. where({
"_openid":userid
})
.update(
{
data:{
['cartlist.'+[index]]:db.command.remove(),
}
})
db.collection('user')//回调回云数据库
.where({
"_openid":userid
})
.update(
{
data:{
['cartlist']:this.data.cartlistsee
}
}
)
}}
})
this.getTotalPrice()
console.log(cartlistsee)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad:function(options) {
const db = wx.cloud.database({
//这个是环境ID不是环境名称
env: 'cloud1-8g5wmepxce8a3b8a'
})
//2、开始查询数据了 news对应的是集合的名称
db.collection("user")
.where({
"_openid":userid
})
.get()
.then(res => {
console.log("列表页", res.data);
console.log(res.data[0].cartlist)
//再次显示数据
this.setData({
cartlistsee:res.data[0].cartlist,
total_all_price: 0,
checked: false
})
})
.catch(err => {
console.log("加载失败", err);
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
this.onRefresh();
},
onRefresh:function(){
//导航条加载动画
wx.showNavigationBarLoading({
title:'loading'
})
;
setTimeout(function () {
wx.hideNavigationBarLoading();
//停止下拉刷新
wx.stopPullDownRefresh();
}, 2000);
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
console.log("上拉加载....");
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,47 @@
<!--pages/cart/cart.wxml-->
<view>
<scroll-view class="scrol_view_style" scroll-x="{{false}}" scroll-y="{{true}}">
<view style="height: 10rpx;"></view>
<view wx:for-items="{{cartlistsee}}" class="list_item_style" wx:key="{{ index }}">
<checkbox-group bindchange="checkboxChange" style="height:100%" data-index="{{index}}" data-checks="{{item.checks}}">
<view class="carts_box">
<checkbox value="{{item.cart_id}}" checked="{{item.checks}}" class="checkbox_one" data-index="{{index}}" bindtap="allCheckbox" />
<image src="{{item.url}}" class="good_main_image" style="border-radius: 20px;"></image>
<view class="cart_content_right">
<text class="item_good_title">{{item.food_name}}</text>
<view class="price_back_view">
<text class="right_list_item_price">¥{{item.price}}</text>
</view>
<view class="cart_content_bottom">
<view class='btn_wrap'>
<!-- <image src="/images/reduce.png" class = "reduce_image_style" id = "{{index}}" bindtap = "reduceButtonClick"></image> -->
<input type='text' value='-' disabled='true' id="{{index}}" bindtap="reduceButtonClick"></input>
<input type='text' value="{{item.num}}" />
<!-- <image src="/images/add.png" class = "add_image_style" id = "{{index}}" bindtap = "addButtonClick"></image> -->
<input type='text' value='+' disabled='true' id="{{index}}" bindtap="addButtonClick"></input>
</view>
<view class="delete" bindtap="deleteGoods" id="{{index}}">删除</view>
</view>
</view>
</view>
</checkbox-group>
</view>
<view class='buy_shop'>
<view class="select_allbox">
<checkbox value="{{item.food_name}}" checked="{{checked}}" style='margin-left:20rpx;' bindtap='setChecked' />
<text>全选</text>
</view>
<view class='heji'>
<text class='price'>合计:</text>
<text class='all_shop_price'>¥{{total_all_price}}</text>
</view>
<view class='jiesuan' bindtap="toBuy">
<text>结算</text>
</view>
</view>
<view style="height:10px;background-color:#F5F5F5;width:100%"></view>
<view class='no_shop' wx:if="{{is_shop}}">
<text>购物车中没有商品</text>
</view>
</scroll-view>
</view>

@ -0,0 +1,243 @@
/* pages/cart/cart.wxss */
/*list样式*/
.scrol_view_style {
background: #f5f5f5;
}
.carts_box {
display: flex;
align-items: center;
height: 100%;
}
/*item*/
.list_item_style {
height: 180rpx;
background: white;
padding-bottom: 20rpx;
padding-left: 20rpx;
padding-right: 20rpx;
}
/*商品主图*/
.good_main_image {
width: 180rpx;
height: 180rpx;
margin-left: 10rpx;
border: 1rpx solid #bbb;
}
/*商品名称*/
.item_good_title {
text-align: left;
font-size: 32rpx;
height: auto;
white-space: nowrap;
word-break: keep-all;
overflow: hidden;
text-overflow: ellipsis;
width: 90%;
}
.cart_content_right {
display: flex;
flex-direction: column;
height: 100%;
margin-left: 20rpx;
}
.btn_wrap {
display: flex;
flex-direction: row;
align-items: center;
width: 200rpx;
}
.btn_wrap input {
background: #f8f8f8;
color: #666;
font-size: 26rpx;
right: 10rpx;
width: 50rpx;
text-align: center;
}
.btn_wrap input:nth-child(2) {
margin: 0 10rpx;
}
/*+号按钮*/
.add_image_style {
width: 20rpx;
height: 20rpx;
position: relative;
top: 60rpx;
right: 10rpx;
float: right;
}
/*——号按钮*/
.reduce_image_style {
width: 20rpx;
height: 20rpx;
position: relative;
top: 60rpx;
right: 10rpx;
float: right;
}
/*购买数量*/
.good_buy_number {
height: 25rpx;
position: relative;
top: 57rpx;
background: #f8f8f8;
color: #666;
font-size: 22rpx;
right: 10rpx;
width: 50rpx;
text-align: center;
float: right;
margin-right: 5rpx;
margin-left: 5rpx;
border-radius: 5rpx;
}
/*价钱的背景试图*/
.price_back_view {
display: flex;
align-items: center;
justify-content: space-between;
width: 460rpx;
padding-top: 20rpx;
}
.cart_content_bottom {
display: flex;
align-items: center;
justify-content: space-between;
width: 460rpx;
padding-top: 25rpx;
}
.cart_content_bottom .delete {
font-size: 28rpx;
}
/*售价*/
.right_list_item_price {
color: #ff5d08;
font-size: 32rpx;
}
/* 没有商品时的购物车样式 */
.no_shop {
text-align: center;
font-size: 50rpx;
color: #bbb;
margin-top: 100px;
}
/*规格的样式*/
.guige {
font-size: 28rpx;
}
/* 未选中的 背景样式 */
checkbox .wx-checkbox-input {
border-radius: 50%; /* 圆角 */
width: 35rpx; /* 背景的宽 */
height: 35rpx; /* 背景的高 */
}
/* 选中后的 背景样式 (红色背景 无边框 可根据UI需求自己修改 */
checkbox .wx-checkbox-input.wx-checkbox-input-checked {
border-color: red;
background: red;
}
/* 选中后的 对勾样式 (白色对勾 可根据UI需求自己修改 */
checkbox .wx-checkbox-input.wx-checkbox-input-checked::before {
border-radius: 50%; /* 圆角 */
width: 35rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
height: 35rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
line-height: 35rpx;
text-align: center;
font-size: 25rpx; /* 对勾大小 30rpx */
color: #fff; /* 对勾颜色 白色 */
background: transparent;
transform: translate(-50%, -50%) scale(1);
-webkit-transform: translate(-50%, -50%) scale(1);
}
/*合计样式*/
.heji {
/* margin-left: 140px; */
/* float: right;
margin-right: 75px;
display: inline; */
flex-flow: row;
justify-content: flex-start;
display: flex;
}
/*合计价格的样式*/
.all_shop_price {
color: #ff6261;
}
/*结算的样式*/
.jiesuan {
position: absolute;
height: 100%;
border-radius: 5rpx;
line-height: 80rpx;
padding: 0 30rpx;
color: white;
font-size: 28rpx;
background: #ff5d08;
bottom: 0rpx;
right: 0rpx;
}
/*全选的样式*/
.buy_shop {
width: 100%;
height: 80rpx;
background-color: white;
line-height: 80rpx;
position: fixed;
bottom: 0;
font-size: 28rpx;
z-index: 999;
box-shadow: 0 0 10rpx rgba(155, 143, 143, 0.6);
display: flex;
align-items: center;
}
.select_allbox{
display: flex;
align-items: center;
width: 57%;
}
.select_allbox text{
padding-left: 10rpx;
}

@ -0,0 +1,241 @@
// pages/change/change.js
var app = getApp()
Page({
data: {
feed: [],
change1: '',
change2: '',
tempFilePaths: [],
t:'',
c:'',
nowCount:0,//当前的图片上传个数
index:0,
url:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this
var aid=options.aid
console.log(options);
console.log(options.aid);
wx.cloud.database().collection('tiezi')
.doc(aid)
.get({
success(res) {
console.log("请求成功", res.data)
console.log("请求成功", res.data.url.length)
// 将查询返回的结果赋值给本地数组
that.setData({
feed: res.data,
nowCount:res.data.url.length,
tempFilePaths: res.data.url,
url:res.data.url,
t:res.data.title,
c:res.data.content
})
},
fail(res) {
console.log("请求失败", res)
}
})
},
// 获取修改后的内容
change1: function(e) {
this.setData({
change1: e.detail.value
})
},
change: function(e) {
this.setData({
change2: e.detail.value
})
},
//图片的上传
chooseImage:function(e){
let that = this;
wx.chooseImage({
count: 3, // 默认最多3张图片可自行更改
sizeType: ['original', 'compressed'],// 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: res => {
wx.showToast({
title: '正在上传...',
icon: 'loading',
mask: true,
duration: 1000
})
// 返回选定照片的本地文件路径列表tempFilePath可以作为img标签的src属性显示图片
let tempFilePath = res.tempFilePaths;
console.log(tempFilePath);
let nowCount = that.data.nowCount;
let tempFilePaths = that.data.tempFilePaths;
if(that.data.nowCount + tempFilePath.length >=3){
let i = 0;
while(nowCount<3){//还可以继续上传图片
tempFilePaths.push(tempFilePath[i]);
i++;
nowCount++;
}
that.setData({
nowCount:3,
tempFilePaths:tempFilePaths
})
}else{
let i = 0;
while(i<tempFilePath.length){
tempFilePaths.push(tempFilePath[i]);
i++;
}
that.setData({
nowCount:that.data.nowCount + tempFilePath.length,
tempFilePaths:tempFilePaths
})
}
console.log(that.data.nowCount,that.data.tempFilePaths);
}
})
},
//长按删除图片
DeleteImg: function (e) {
let that = this;
let tempFilePaths = that.data.tempFilePaths;
let index = e.currentTarget.dataset.index;//获取当前长按图片下标
wx.showModal({
title: '提示',
content: '确定要删除此图片吗?',
success: function (res) {
if (res.confirm) {
//console.log('点击确定了');
let nowCount = that.data.nowCount;
that.setData({
nowCount:nowCount-1
})
tempFilePaths.splice(index, 1);
} else if (res.cancel) {
//console.log('点击取消了');
return false;
}
that.setData({
tempFilePaths:tempFilePaths
});
}
})
},
// 提交修改
sure: function(event) {
var that = this
let content1
let content
// if(this.data.change1==''){console.log("1")}
// if(this.data.change2==''){console.log("2")}
if(this.data.change1==''){
content1=this.data.t
}else{
content1=this.data.change1
}
if(this.data.change2==''){
content=this.data.c
}else{
content=this.data.change2
}
console.log(content1,"1",content,"1")
//图片修改
let i;
let count=0;
let url=this.data.url
let l=url.length
console.log(l)
if(that.data.nowCount==0){
wx.cloud.init({
env:"cloud1-8g5wmepxce8a3b8a",
})
let aid=wx.getStorageSync ("aid")
console.log(aid);
wx.cloud.database().collection('tiezi')
.doc(aid)
.update({
data:{
title:content1,
content: content,
}
}).then(res=>{
console.log(res);
wx.showLoading({
title: '修改成功...',
})
wx.redirectTo({
url: '../answer/answer?aid='+aid,
})
wx.hideLoading()
}).catch(res=>{
console.log(res);
})
}else{
//将所有的内容上传到云端去
for(i=l;i<that.data.nowCount;i++){
console.log(1);
let extName = that.data.tempFilePaths[i].split(".").pop();
let cloudPath = "love/" + new Date().getTime() + "." + extName;
wx.cloud.uploadFile({
cloudPath: cloudPath,
filePath: that.data.tempFilePaths[i], // 文件路径
success: res => {
count++;
url.push(res.fileID);
console.log('上传图片');
console.log(i,url);
if(count==that.data.nowCount){
console.log(url);
}
},fail:res=>{
console.log(res);
}
})
}
wx.cloud.init({
env:"cloud1-8g5wmepxce8a3b8a",
})
let aid=wx.getStorageSync ("aid")
console.log(aid);
wx.cloud.database().collection('tiezi')
.doc(aid)
.update({
data:{
title:content1,
content: content,
url:url
}
}).then(res=>{
console.log(res);
wx.showLoading({
title: '修改成功...',
})
wx.redirectTo({
url: '../answer/answer?aid='+aid,
})
wx.hideLoading()
}).catch(res=>{
console.log(res);
})
}
},
})

@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

@ -0,0 +1,25 @@
<!--pages/change/change.wxml-->
<!-- 用户自行修改数据的页面 -->
<view class="wall-item">
<!-- 内容 -->
<textarea class="title" bindinput="change1"placeholder="{{change1}}" decode="{{true}}" value="{{feed.title}}" style="height: 25px;"></textarea>
<textarea bindinput="change" style="white-space:pre-wrap;" value="{{feed.content}}" placeholder="{{change}}" data-aid="{{feed._id}}" class="content"></textarea>
<!--帖子的图片-->
<view class="img_box">
<view class="imgs" wx:for="{{tempFilePaths}}" wx:key="index">
<image src='{{item}}' bindlongpress="DeleteImg" bindtap="listenerButtonPreviewImage" data-index="{{index}}" mode='widthFix' />
</view>
<view class="imgs" wx:if="{{feed.url.length<3}}">
<view class="images" bindtap="chooseImage">
<image src='../../images/upload.png' mode='widthFix' />
</view>
</view>
</view>
</view>
<!-- 确认修改 -->
<button class="publish" bindtap="sure">确认修改</button>

@ -0,0 +1,73 @@
/* pages/change/change.wxss */
.title{
font-size: 38rpx;
display: flex;
margin-top: 25rpx;
padding: 13px 0;
margin-bottom: 30rpx;
border-bottom: 1px solid #ccc;
}
.content{
margin-bottom: 30rpx;
border-bottom: 1px solid #ccc;
padding-right: 50rpx;
margin-top: 30rpx;
display: block;
width: 100%;
height: 550rpx !important;
box-sizing: border-box;
font-size: 32rpx;
color: #454545;
line-height: 44rpx;
/*word-break: break-all;*/
}
.picker{
display: flex;
padding: 13px 0;
margin-bottom: 35rpx;
border-bottom: 1px solid #ccc;
}
.img_box{
position:relative;
display: flex;
flex-wrap: wrap;
margin:0 auto;
}
.imgs{
width:33.33333333%;
display: flex;
justify-content: center;
margin-bottom:20rpx;
}
.imgs image{
width:90%;
max-height:212rpx;
border:1px solid rgba(214, 212, 212, 0.1);
/* box-shadow: 5rpx 5rpx 1rpx 3rpx #e2e0e0; */
}
.imgs .images{
position:relative;
}
.images button{
width:100%;
height:100%;
position:absolute;
top:0;
left:0;
}
.img_box .images{
width:90%;
height: 212rpx;
border:1px solid #E8E8E8;
border-radius:4rpx;
display: flex;
align-items: center;
justify-content: center;
}
.img_box .images>image{
width:60rpx;
height:60rpx;
}

@ -0,0 +1,141 @@
// pages/detail/detail.js
const db = wx.cloud.database({});
const cont = db.collection('food');
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
detailObj: {},
list:[],
clockresult:[],
userid:null,
num:null
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let foodid =options.id
var userid=app.globalData.openid
console.log('1111w ');
console.log(userid)
this.setData({
userid:userid
})
cont.doc(foodid).get({
success: res => {
console.log(res.data)
//这一步很重要给ne赋值没有这一步的话前台就不会显示值
this.setData({
detailObj: res.data,
})
}
})
},
// 渲染数据
async addCar(event) {
let detailObj= event.currentTarget.dataset.item;
let num=this.data.num
num=num+1
const checks=false
console.log(num)
detailObj.num=num
detailObj.checks=checks
console.log(detailObj)
var userid=app.globalData.openid
db.collection('user').where({
"_openid":userid
}).update({
data:{
cartlist:db.command.push(detailObj)
},
})
db.collection('user').where({
"_openid":userid
}).get({
success: res => {
console.log(res.data)}
})
wx.showToast({
title: '加入购物车成功',
icon: 'success',
duration: 2000
})
},
async immeBuy(event){
var index = event.currentTarget.dataset.item;
console.log(index);
var detailObj=this.data.detailObj
var Selection=[]
var num=1
detailObj.num=num
Selection.push(detailObj)
var total=detailObj.price
wx.navigateTo({
url:'/pages/paying/paying?info='+JSON.stringify(Selection)+'&totalprice='+total
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,27 @@
<view class="container" >
<image src="{{detailObj.url}}"></image>
<view class="detail" >
<text class="title">{{detailObj.food_name}}</text>
<text class="shop">{{detailObj.food_shop}}</text>
<text class="price">¥{{detailObj.price}}</text>
</view>
</view>
<view class="separate"></view>
<!-- sku选择 -->
<view class="a">
<text bindtap="toggleDialog" >请选择购买数量</text>
<view class="separate"></view>
<text class="separate" decode="{{true}}">&emsp;</text>
<view class="separate"></view>
<text>商品评价:东西还可以,好评~</text>
<view class="separate"></view>
</view>
<view class="separate"></view>
<view class="detail-nav" >
<button class="button-green" catchtap="addCar" formType="submit" data-item="{{detailObj}}" data-userid="{userid}">加入购物车</button>
<button class="button-red" bindtap="immeBuy" data-item="{{detailObj._id}}" formType="submit">立即购买</button>
</view>

@ -0,0 +1,40 @@
/* pages/detail/detail.wxss */
page {
display: flex;
flex-direction: column;
height: 100%;
}
.detail {
display: flex;
flex-direction: column;
margin-top: 15rpx;
margin-bottom: 15rpx;
}
.detail .title {
font-size: 40rpx;
margin: 10rpx;
color: black;
text-align: center;
}
.detail .shop {
font-size: 40rpx;
margin: 10rpx;
color: black;
text-align: center;
}
.detail .price {
color: red;
font-size: 40rpx;
margin: 10rpx;
text-align: center;
}
.a {
border-bottom: 1px solid #ccc;
font-size: 30rpx;
margin: 10rpx;
color: black;
text-align: center;
border-top: 1px solid #ccc;
}

@ -0,0 +1,252 @@
//index.js
let currentPage = 0 // 当前第几页,0代表第一页
let pageSize = 6
var util = require('../../utils/util.js')
var app = getApp()
Page({
data: {
search:'',
re:[],
feed: [],
feed_length: 0,
loadMore: false, //"上拉加载"的变量默认false隐藏
loadAll: false //“没有数据”的变量默认false隐藏
//imgList:[]
},
//事件处理函数
bindItemTap: function(event) {
/*wx.navigateTo({
url: '../answer/answer'
})*/
var aid=event.currentTarget.dataset.aid;
console.log(aid)
//console.log("1")
wx.navigateTo({
url: '../answer/answer?aid='+aid,//要跳转到的页面路径
})
},
onLoad: function () {
console.log('onLoad')
this.clearCache();
let that = this
//调用应用实例的方法获取全局数据
this.getData();
this.refresh()
},
onShow: function (){
console.log('onshow')
this.upper()
},
upper: function () {//下滑刷新
wx.showNavigationBarLoading()
this.refresh();
console.log("upper");
setTimeout(function(){wx.hideNavigationBarLoading();wx.stopPullDownRefresh();}, 1000);
},
lower: function (e) {//触底加载
wx.showNavigationBarLoading();
var that = this;
setTimeout(function(){wx.hideNavigationBarLoading();that.nextLoad();}, 1000);
console.log("lower")
},
scroll: function (e) {
console.log("scroll")
},
//网络请求数据, 实现首页刷新
refresh0: function(){
this.getData;
/*var index_api = '';
util.getData(index_api)
.then(function(data){
//this.setData({
//
//});
console.log(data);
});*/
},
//使用本地 fake 数据实现刷新效果
getData() {
let that = this;
//第一次加载数据
if (currentPage == 1) {
this.setData({
loadMore: true, //把"上拉加载"的变量设为true显示
loadAll: false //把“没有数据”设为false隐藏
})
}
//云数据的请求
wx.cloud.database().collection("tiezi")
.orderBy('createTime', 'desc') //按发布视频排序
.skip(currentPage * pageSize) //从第几个数据开始
.limit(pageSize)
.get({
success(res) {
if (res.data && res.data.length > 0) {
console.log("请求成功", res.data)
currentPage++
//把新请求到的数据添加到dataList里
let list = that.data.feed.concat(res.data)
that.setData({
feed: list, //获取数据数组
loadMore: false //把"上拉加载"的变量设为false显示
});
if (res.data.length < pageSize) {
that.setData({
loadMore: false, //隐藏加载中。。
loadAll: true //所有数据都加载完了
});
}
} else {
that.setData({
loadAll: true, //把“没有数据”设为true显示
loadMore: false //把"上拉加载"的变量设为false隐藏
});
}
},
fail(res) {
console.log("请求失败", res)
that.setData({
loadAll: false,
loadMore: false
});
}
})
},
refresh: function(){
this.clearCache();
this.getData()
let that = this
if (!that.data.loadMore) {
that.setData({
loadMore: true, //加载中
loadAll: false //是否加载完所有数据
});}
},
//使用本地 fake 数据实现继续加载效果
nextLoad: function(){
console.log("上拉触底事件")
let that = this
if (!that.data.loadMore) {
that.setData({
loadMore: true, //加载中
loadAll: false //是否加载完所有数据
});
//加载更多,这里做下延时加载
setTimeout(function() {
that.getData()
}, 500)
}
},
goto(){
wx.navigateTo({
url: '../submit/submit',//要跳转到的页面路径
})
},
// 清缓存
clearCache:function(){
currentPage = 0;//分页标识归零
this.setData({
feed: [] //文章列表数组清空
});
},
GetSearchInput: function(e) {
this.setData({
search: e.detail.value
})
},
ToSearch: function(e) {
//let search = e.detail.value;
var that = this;
if(this.data.search == '') {
wx.showToast({
title: '请输入',
icon: 'none'
})
return
}
wx.showLoading({
title: '搜索中',
})
const _ = wx.cloud.database().command
wx.cloud.database().collection('tiezi').where(_.or([
{
content: wx.cloud.database().RegExp({
regexp: this.data.search,
options: 'i',
}),
},
{
title: wx.cloud.database().RegExp({
regexp: this.data.search,
options: 'i',
}),
}
]))
// wx.cloud.database().collection('tiezi').where({
// content: wx.cloud.database().RegExp({
// regexp: this.data.search,
// options: 'i',
// }),
// })
.get()
.then(res => {
if (res.data.length != 0) {
this.setData({
re: res.data,
})
wx.setStorageSync('re', res.data)
let re= wx.getStorageSync('re')
console.log(re)
let that = this;
wx.hideLoading({
success: (res) => {
that.setData({
search: '',
})
}})
wx.navigateTo({
url: '../searchShow/searchShow?re='+JSON.stringify(re),//要跳转到的页面路径
})
} else {
wx.showToast({
title: '未找到',
icon: 'none'
})
}
console.log(res.data)
})
.catch(res => {
console.log("查询失败",res)
})
},
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,72 @@
<!--pages/fourm/fourm.wxml-->
<scroll-view scroll-y="true" class="container" bindscrolltoupper="upper" upper-threshold="10" lower-threshold="5" bindscrolltolower="lower" scroll-into-view="{{toView}}" scroll-top="{{scrollTop}}">
<view class="search flex-wrp">
<view class="search-left flex-item">
<input placeholder="点击右侧闪电发帖" placeholder-class="search-placeholder"/>
</view>
<view class="search-right flex-item" bindtap="goto">
<image src="../../images/lighting.png"></image>
</view>
</view>
<view class="sousuokuang">
<view class="sousuo">
<view class="shurukuang">
<input placeholder="搜索" value="{{inputValue}}" bindinput="GetSearchInput"></input>
</view>
<view class="sousuo_anniu" bindtap="ToSearch">
<text>搜索</text>
<icon type="search" size="20"></icon>
</view>
</view>
</view>
<block wx:for="{{feed}}" wx:for-index="idx" wx:for-item="item" data-idx="{{idx}}">
<view class="feed-item">
<view class="feed-source">
<a class="">
<view class="avatar">
<image src="{{item.feed_source_img}}"></image>
<!--<open-data type="userAvatarUrl"></open-data>-->
</view>
<text>{{item.feed_source_name}}</text>
<!-- <open-data type="userNickName"></open-data>-->
</a>
<image class="item-more" mode="aspectFit" bindtap="delete_p" data-aid="{{item._id}}" src="../../images/more.png"></image>
</view>
<view class="feed-content">
<view class="question" bindtap="bindItemTap" data-aid="{{item._id}}">
<a class="question-link">
<text>{{item.title}}</text>
</a>
</view>
<view class="answer-body">
<view >
<text class="answer-txt" bindtap="bindItemTap" data-aid="{{item._id}}">{{item.content}}</text>
</view>
<view class="answer-actions" bindtap="bindItemTap">
<view class="like dot">
<a>{{item.good_num}} 赞同 </a>
</view>
<view class="follow-it">
<text decode="{{true}}">&emsp;&emsp;</text>
</view>
<view class="comments dot">
<a>{{item.comment_num}} 评论 </a>
</view>
</view>
</view>
</view>
</view>
</block>
<view class="loading" hidden="{{!loadMore}}">正在载入更多...</view>
<view class="loading" hidden="{{!loadAll}}">已加载全部</view>
</scroll-view>

@ -0,0 +1,110 @@
/* pages/fourm/fourm.wxss */
/**index.wxss**/
.container{
height: 1500rpx;
}
.container .search{
width: 735rpx;
height: 65rpx;
padding: 12.5rpx 0 12.5rpx 15rpx;
background: #2A8CE5;
}
.container .search-left{
flex: 8;
background: #4EA3E7;
text-align: left;
}
.container .search-left input{
display: inline-block;
height: 65rpx;
font-size: 26rpx;
}
.search-placeholder{
color: #8CCEFD;
line-height: 20rpx;
}
.container .search .search-left image{
display: inline-block;
width: 35rpx;
height: 35rpx;
padding: 15rpx 15rpx 15rpx 20rpx;
}
.container .search .search-right{
flex: 1;
}
.container .search .search-right image{
width: 45rpx;
height: 45rpx;
padding: 10rpx;
}
.container{
padding: 0;
font-size: 14rpx;
background: #F0F4F3;
color: #000;
}
/*feed-item part is in app.wxss for multiplexing*/
.answer-txt{
width:700rpx;
height:49rpx;
font-size:25rpx;
overflow:hidden;
text-overflow: ellipsis;
display:-webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.loading {
font-size: 32rpx;
position: relative;
bottom: 5rpx;
padding: 10rpx;
text-align: center;
}
.sousuokuang {
width: 100%;
height: 100rpx;
display: flex;
flex-direction: column;
align-items: center;
background-color: white;
}
.sousuo {
width: 92%;
height: 100rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-items: center;
}
.shurukuang {
width: 80%;
height: 64rpx;
border-radius: 32rpx;
display: flex;
align-items: center;
justify-content: center;
background-color: #f6f6f6;
}
.shurukuang input {
width: 90%;
height: 100%;
font-size: 32rpx;
}
.sousuo_anniu {
width: 20%;
height: 64rpx;
display: flex;
align-items: center;
justify-content: center;
}
.sousuo_anniu text {
font-size: 30rpx;
}

@ -0,0 +1,125 @@
const db = wx.cloud.database({});
const cont = db.collection('food');
const $ = db.command.aggregate
Page({
/**
* 页面的初始数据
*/
data: {
foodlist:[],
tabs: ['主食', '甜品', '小吃','吃得快','辣味','甜味','清淡'],
cateList:[],
index:null
},
tabSelect:function(e){
var current = e.currentTarget.dataset.id
this.setData({
current:current
})
},
//分类
geCateListe(){
db.collection('food').aggregate()
.group({
_id: '$tab'
})
.end()
.then(res => {
console.log('食物列表', res)
this.setData({
foodList: res.list
})
})
},
//跳转详情页
toDetail: function (event) {
// 获取 event 事件对象
// 获取点击对应的下标
var index = event.currentTarget.dataset.foodid;
console.log(index);
//抓取id进行赋
//wx.navigateTo 会触发页面隐藏onHide
console.log('11111')
wx.navigateTo({
url:'/pages/detail/detail?id='+ index,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var _this = this;
const db = wx.cloud.database({
//这个是环境ID不是环境名称
env: 'cloud1-8g5wmepxce8a3b8a'
})
//2、开始查询数据了 news对应的是集合的名称
db.collection('food').get({
//如果查询成功的话
success: res => {
console.log(res.data)
//这一步很重要给ne赋值没有这一步的话前台就不会显示值
this.setData({
foodlist: res.data
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
toturning: function(){
wx.navigateTo({
url:'/pages/turning/turning',
})
}
})

@ -0,0 +1,5 @@
{
"usingComponents": {
}
}

@ -0,0 +1,38 @@
<view class="imagesize">
<image src=" /images/logo.jpg" style="width:350px" class="in-select2" mode="widthFix">
</image>
</view>
<navigator class="imagesize">
<image src="/images/perfer.jpg" style="width:440px" class="in-select" mode="widthFix"></image>
</navigator>
<navigator class="imagesize">
<image src="/images/zhuanpang.jpg" style="width:440px" class="in-select" mode="widthFix" bindtap="toturning"></image>
</navigator>
<view class="divLine"></view>
<!-- 导航栏 -->
<scroll-view class="navbar" scroll-x="true" scroll-left="{{tabs}}" >
<view class="nav-item" wx:for="{{tabs}}" wx:key="id" bindtap="tabSelect" >
<view class="nav-text {{item==tabCur?'tab-on':''}}">{{item}}</view>
</view>
</scroll-view>
<view class="foodlist">
<view class='a' wx:for="{{foodlist}}"><!--wx:for是微信数据绑定的一种方式该数组有多少数据就显示多少个view-->
<!--item就相当于数组名+下标的结合体,适用于调用数组所有数据-->
<view catchtap="toDetail" data-foodid="{{item._id}}">
<view class='img'>
<image src="{{item.url}}" style="border-radius:20px;"></image>
</view>
<view class='info'>
<view class='title'>{{item.food_name}}</view>
<view class='price'>{{item.price}}</view>
<view class='num'>{{item.food_shop}}</view>
</view>
</view>
<view class='clear'></view>
</view>
</view>

@ -0,0 +1,163 @@
page {
background: #ffffff;
width: 100%;
height: 100%;
}
/*分割线样式*/
.divLine{
background: #E0E3DA;
width: 100%;
height: 5rpx;
}
.navbar {
width: 800rpx;
height: 90rpx;
/* 文本不换行 */
white-space: nowrap;
display: flex;
box-sizing: border-box;
border-bottom: 1rpx solid #eee;
background: #fff;
align-items: center;
/* 固定在顶部 */
}
.nav-item {
line-height: 60rpx;
background-color: #f7f7f7;
padding-left: 25rpx;
padding-right: 25rpx;
height: 100%;
display: inline-table;
/* 普通文字大小 */
font-size: 28rpx;
}
.nav-text {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
letter-spacing: 4rpx;
box-sizing: border-box;
}
.tab-on {
color: #000080;
/* 选中放大 */
font-size: 38rpx !important;
font-weight: 600;
border-bottom: 4rpx solid #000080 !important;
}
.P_input {
position: relative;
}
.P_input input {
background: white;
border-radius: 40rpx;
width: 90%;
padding: 10rpx 0;
padding-left: 40rpx;
margin: 40rpx 0 5% 20rpx;
}
.P_input image {
position: absolute;
z-index: 999999;
width: 36rpx;
height: 36rpx;
padding: 6rpx 20rpx;
right: 20rpx;
top: 12rpx;
}
.imagesize {
display: flex;
justify-content: center;
align-items: center;
width: 650rpx;
margin-left: 50rpx;
margin-right: 50rpx;
}
.imagesize select {
height: 50rpx;
width: 350rpx;
}
.imagesize select2 {
height: 180rpx;
width: 350rpx;
}
.foodist{
margin-top:10px;
}
.foodlist .a .img{
float:left;
width:40%;
height:100%;
}
.foodlist .a .img image{
width:200rpx;
height:200rpx;
}
.foodlist .a .info{
width:59%;
float:right;
height:100px;
position:relative;
}
.foodlist .a .info .title{
color:#333;
margin-left:10px;
font-size: 15px;
}
.foodlist .a .info .price{
color:#FF2727;
margin-left:10px;
margin-top:10px;
font-size:15px;
}
.foodlist .a .info .num{
position: absolute;
left:0px;
bottom:10px;
color:#747474;
margin-left:10px;
font-size:15px;
}
.clear{
clear: both;
overflow: hidden;
}
navigator{
display:inline;
}
.nav {
position: fixed;
background: white;
color: #353535;
z-index: 999999;
max-height: 94rpx;
width: 100%;
}
.scroll-view-containner{
display: flex;
text-align: center;
}

@ -0,0 +1,66 @@
// pages/login/login.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,2 @@
<!--pages/login/login.wxml-->
<text>pages/login/login.wxml</text>

@ -0,0 +1,66 @@
// pages/myorder/myorder.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,2 @@
<!--pages/myorder/myorder.wxml-->
<text>pages/myorder/myorder.wxml</text>

@ -0,0 +1 @@
/* pages/myorder/myorder.wxss */

@ -0,0 +1,70 @@
// pages/orderdetail/orderdetail.js
Page({
/**
* 页面的初始数据
*/
data: {
addresslist:{}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log(options.info)
this.setData({
orderlist:options.info
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,2 @@
<!--pages/orderdetail/orderdetail.wxml-->
<text>{{orderlist.address}}</text>

@ -0,0 +1,110 @@
/* pages/orderdetail/orderdetail.wxss */
.scrol_view_style {
background: #f5f5f5;
}
.carts_box {
display: flex;
align-items: center;
height: 100%;
}
/*item*/
.list_item_style {
height: 180rpx;
background: white;
padding-bottom: 20rpx;
padding-left: 20rpx;
padding-right: 20rpx;
}
/*商品主图*/
.good_main_image {
width: 180rpx;
height: 180rpx;
margin-left: 10rpx;
border: 1rpx solid #bbb;
}
/*商品名称*/
.item_good_title {
text-align: left;
font-size: 32rpx;
height: auto;
white-space: nowrap;
word-break: keep-all;
overflow: hidden;
text-overflow: ellipsis;
width: 90%;
}
.cart_content_right {
display: flex;
flex-direction: column;
height: 100%;
margin-left: 20rpx;
}
.btn_wrap {
display: flex;
flex-direction: row;
align-items: center;
width: 200rpx;
}
.btn_wrap input {
background: #f8f8f8;
color: #666;
font-size: 26rpx;
right: 10rpx;
width: 50rpx;
text-align: center;
}
.btn_wrap input:nth-child(2) {
margin: 0 10rpx;
}
.price_back_view {
display: flex;
align-items: center;
justify-content: space-between;
width: 460rpx;
padding-top: 20rpx;
}
.cart_content_bottom {
display: flex;
align-items: center;
justify-content: space-between;
width: 460rpx;
padding-top: 25rpx;
}
.cart_content_bottom .delete {
font-size: 28rpx;
}
/*售价*/
.right_list_item_price {
color: #ff5d08;
font-size: 32rpx;
}
/* 没有商品时的购物车样式 */
.no_shop {
text-align: center;
font-size: 50rpx;
color: #bbb;
margin-top: 100px;
}
/*规格的样式*/
.guige {
font-size: 28rpx;
}

@ -0,0 +1,133 @@
// pages/orderlist/orderlist.js
const db = wx.cloud.database({});
const app=getApp()
const userid=app.globalData.openid
Page({
/**
* 页面的初始数据
*/
data: {
orderlist:[]
},
/**
* 点击删除订单
*/
deleteGoods(event) {
var that = this;
const index = event.currentTarget.id;
console.log(index)
let orderlist = this.data.orderlist;//购物车所有的商品数据
let foodid=orderlist[index]._id
console.log(foodid)
wx.showModal({
title: '温馨提示',
content: '确定删除当前商品吗?',
confirmColor: "#f00",
success: (res) => {
if (res.confirm) {
orderlist.splice(index, 1);
this.setData({
orderlist:orderlist
})
db.collection('user')//回调回云数据库
. where({
"_openid":userid
})
.update(
{
data:{
['cartlist.'+[index]]:db.command.remove(),
}
})
db.collection('user')//回调回云数据库
.where({
"_openid":userid
})
.update(
{
data:{
['Orderlist']:this.data.orderlist
}
}
)
}}
})
this.getTotalPrice()
console.log(orderlist)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
db.collection("user")
.where({
"_openid":userid
})
.get()
.then(res => {
console.log("列表页", res.data);
console.log(res.data[0].Orderlist)
//再次显示数据
this.setData({
orderlist:res.data[0].Orderlist.reverse(),
})
})
.catch(err => {
console.log("加载失败", err);
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,28 @@
<!--pages/orderlist/orderlist.wxml-->
<view>
<scroll-view class="scrol_view_style" scroll-x="{{false}}" scroll-y="{{true}}">
<view style="height: 10rpx;"></view>
<view wx:for-items="{{orderlist}}" class="list_item_style" wx:key="{{ index }}">
<view class="carts_box">
<image src="{{item.url}}" class="good_main_image" style="border-radius: 20px;"></image>
<view class="cart_content_right">
<text class="item_good_title">{{item.food_name}}</text>
<view class="price_back_view">
<text class="right_list_item_price">总计:¥{{item.price}}</text>
<text>时间:{{item.time}}</text>
</view>
<view class="cart_content_bottom">
<view class='btn_wrap'>
<!-- <image src="/images/reduce.png" class = "reduce_image_style" id = "{{index}}" bindtap = "reduceButtonClick"></image> -->
<input type='text' value="*{{item.num}}" />
<!-- <image src="/images/add.png" class = "add_image_style" id = "{{index}}" bindtap = "addButtonClick"></image> -->
</view>
<view class="delete" bindtap="deleteGoods" id="{{index}}">删除</view>
</view>
</view>
</view>
</view>
</scroll-view>
</view>

@ -0,0 +1 @@
/* pages/orderlist/orderlist.wxss */

@ -0,0 +1,192 @@
// pages/paying/paying.js
const db = wx.cloud.database({});
const app=getApp()
const userid=app.globalData.openid
Page({
/**
* 页面的初始数据
*/
data: {
showPayPwdInput: false, //是否展示密码输入层
pwdVal: '', //输入的密码
payFocus: true, //文本框焦点
addresslist:[],
buylist:[],
orderlist:{},
totalprice:0,
Selection_address:[]
},
allCheckbox: function(tap) {
var a = 0 //设置初始总价格
var index = tap.currentTarget.dataset.index
console.log(index)//获取索引值
let address = this.data.addresslist //获取地址列表
const check = address[index].check; //获取当前地址的选中状态
address[index].check = !check //改变当前商品的状态
console.log(check)
this.setData({
addresslist: address
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log(options.totalprice)
console.log(JSON.parse(options.info))
var buylist=JSON.parse(options.info)
this.setData({
buylist:buylist,
totalprice:options.totalprice
})
console.log(buylist)
db.collection("user")
.where({
"_openid":userid
})
.get()
.then(res => {
console.log("地址", res.data);
console.log(res.data[0].address)
//再次显示数据
this.setData({
addresslist:res.data[0].address
})
})
},
/**
* 显示支付密码输入层
*/
showInputLayer(){
this.setData({ showPayPwdInput: true, payFocus: true });
},
/**
* 隐藏支付密码输入层
*/
hidePayLayer(){
/**获取输入的密码**/
var val = this.data.pwdVal;
/**在这调用支付接口**/
this.setData({ showPayPwdInput: false, payFocus: false, pwdVal: '' }, );
},
/**
* 获取焦点
*/
getFocus(){
this.setData({ payFocus: true });
},
/**
* 输入密码监听
*/
inputPwd(e){
this.setData({ pwdVal: e.detail.value });
if (e.detail.value.length >= 6){
this.hidePayLayer();
wx.showModal({
title:'支付成功',
success: (res) => {
var addresslist=this.data.addresslist
console.log(addresslist)
var addresslist_one1 = {}
var buylist=this.data.buylist
addresslist_one1.food_name=buylist[0].food_name
addresslist_one1.food_shop=buylist[0].food_shop
addresslist_one1.num=buylist[0].num
addresslist_one1.price=this.data.totalprice
addresslist_one1.url=buylist[0].url
for (var i = 0; i < this.data.addresslist.length; i++) { //循环地址列表中的地址
if (addresslist[i].check == true) {
var Selection_address=[]
addresslist_one1.address=addresslist[i].address
addresslist_one1.detailedAddress=addresslist[i].detailedAddress
addresslist_one1.name=addresslist[i].name
addresslist_one1.phone=addresslist[i].phone
console.log(addresslist_one1)
}
}
var time=new Date().toJSON().substring(0, 10) + ' ' + new Date().toTimeString().substring(0,8)
addresslist_one1.time=time
console.log(time)
db.collection('user').where({
"_openid":userid
}).update({
data:{
Orderlist:db.command.push(addresslist_one1)
},
})
if (res.confirm) {
wx.navigateTo({
url:'/pages/orderlist/orderlist?info='+JSON.stringify(addresslist_one1)
})}
}
})
}},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,80 @@
<template is="navigationBar" data="{{...item}}"></template>
<view class="order_address" bindtap="bindaddress">
<view class="select_address"><text class="iconfont icon-map_line-"></text>点击去选择地址</view>
<view><text class="iconfont icon-arrowright"></text></view>
</view>
<view class="Receiving_address" bindtap="bindaddress">
<view wx:for="{{addresslist}}" class="container1">
<view class="text-content">
<checkbox checked="{{item.check}}" class="checkbox_one" data-index="{{index}}" bindtap="allCheckbox" />
<text>{{item.address}}\n</text>
<text>{{item.detailedAddress}}\n</text>
<text>收货人:{{item.name}}\n</text>
<text>电话:{{item.phone}}</text>
</view>
</view>
<view><text class="iconfont icon-arrowright"></text></view>
</view>
<view>
<!-- 取餐时间 -->
<view class="top-bar">
<label class="top-left-label">请确认您的订单</label>
</view>
<!-- 订单详情 -->
<view class="order-info">
<view class="order-info-title">订单详情</view>
<view class="cart-list-box" wx:for="{{buylist}}" wx:for-item="item" wx:key="list">
<view class="list-info">
<image src="{{item.url}}"></image>
<view>{{item.food_name}}</view>
</view>
<view style="width:50%;padding:10px;">
<view style="float:right">
<view style="color:#A3A3A3">x {{item.num}}</view>
<view>¥ {{item.price}}</view>
</view>
</view>
</view>
<view class="order-sum">
<label>总计 </label>
<label class="order-sum-number activity-color">¥ {{totalprice}}</label>
</view>
</view>
<!-- 备注 -->
<view class="note">
<label style="font-size:13px;color:#A3A3A3">备注</label>
<textarea maxlength="{{max}}" placeholder="如有其他要求,请输入备注" bindinput="listenerTextarea" class="note-text">{{note}}</textarea>
</view>
<!-- 去支付 -->
</view>
<!-- 支付操作 -->
<view catchtap='showInputLayer' class="btn_pay">立即支付</view>
<!-- 密码输入框 -->
<view wx:if='{{showPayPwdInput}}'>
<view class='bg_layer'></view>
<view class='input_main'>
<view class='input_title'>
<view class='input_back' catchtap='hidePayLayer'><text></text></view>
<text>输入支付密码</text>
</view>
<view class='input_tip'><text>使用会员卡余额支付需要验证身份,验证通过后才可进行支付。</text></view>
<view class='input_row' catchtap='getFocus'>
<view class='pwd_item' wx:for='{{6}}' wx:key='item' wx:for-index='i'>
<text wx:if='{{pwdVal.length>i}}'></text>
</view>
</view>
<view class='forget_pwd' catchtap='hidePayLayer'>忘记密码</view>
<input class='input_control' password type='number' focus='{{payFocus}}' bindinput='inputPwd' maxlength='6'/>
</view>
</view>

@ -0,0 +1,127 @@
/* pages/paying/paying.wxss */
/* pages/category/index.wxss */.btn_pay{
margin: 100rpx auto; width: 600rpx; height: 100rpx; line-height: 100rpx; border-radius: 100rpx;
background-color: #d3a95a; color: #fff; font-size: 36rpx; text-align: center;
}
/* 支付密码css start */
.bg_layer{
position: fixed; left: 0; top: 0; bottom: 0; right: 0;
background-color: rgba(0, 0, 0, 0.6); z-index: 9998;
}
.input_main{
position: fixed; left: 0; bottom: 500rpx; width: 100%; height: 394rpx;
background-color: #fff; z-index: 9999;
}
.input_title{
width: 100%; height: 90rpx; line-height: 90rpx; text-align: center;
font-size: 32rpx; border-bottom: 1rpx solid #e2e2e2;
}
.input_back{
position: absolute; left: 0; top: 0;
width: 80rpx; height: 90rpx; display: flex; justify-content: center; align-items: center;
}
.input_back text{
width: 20rpx;
height: 20rpx;
background-color: white;
border: 1rpx solid #aaa;
border-width: 5rpx 0 0 5rpx;
transform: rotate(-45deg);
}
.input_tip{ margin: 30rpx; font-size: 24rpx; color: #888; }
/* 密码掩码模拟 */
.input_row{
width: 690rpx; margin: 0 auto; height: 98rpx; position: relative;
display: flex; align-items: center; border: 1rpx solid #e2e2e2; border-radius: 20rpx;
}
.input_row .pwd_item{
flex: 1; display: flex; align-items: center; justify-content: center;
height: 100%; border-right: 1rpx solid #e2e2e2; position: relative;
}
.pwd_item:nth-last-of-type(1) { border-right: 0; }
.pwd_item text {
width: 30rpx; height: 30rpx; border-radius: 30rpx; background-color: #555;
}
.forget_pwd{
float: right; margin: 30rpx; width: 100rpx; text-align: right; font-size: 24rpx; color: #ff7800;
}
/* 文本输入框位置: 设置到左边隐藏 */
.input_control {
position: relative; left: -300rpx; bottom: 0; width: 100rpx; height: 100rpx;
}
/* 备注 */
.note{
padding:5px 15px;
background:white;
margin-top:10px
}
.note-text{
width:95%;
font-size:12px;
background:#F2F2F2;
padding:10px;
height:80px;
}
/* 取餐时间区域 */
.top-bar {
height: 30px;
line-height: 30px;
font-size: 14px;
background: white;
padding:0 5px;
}
.top-left-label {
float: left;
}
/* 底部操作菜单样式 */
.bottom-operate-menu {
z-index: 1001;
position: fixed;
bottom: 0px;
height: 55px;
width: 100%;
display: flex;
}
.shopping-cart {
width: 75%;
background: #353535;
height: 100%;
}
.submit-btn-label {
color: white;
font-size: 15px;
margin: auto;
}
.submit-btn {
height: 100%;
background: #f7f7f7;
width: 25%;
display: flex;
}
.activity-color-bg {
background: #ff9c35;
}
/*选择的样式*/
checkbox .wx-checkbox-input {
border-radius: 50%; /* 圆角 */
width: 35rpx; /* 背景的宽 */
height: 35rpx; /* 背景的高 */
}
/*选择地址的样式的样式*/
.container{
padding: 10px 20px;
align-content: center;
}
.text-content{
padding: 10px;
align-content: center;
border-bottom: 1rpx solid #F5F5F5;
background-color: #FFFFFF
}

@ -0,0 +1,33 @@
// pages/searchShow/searchShow.js
Page({
/**
* 组件的初始数据
*/
data: {
},
onLoad: function(options) {
console.log("1")
console.log(JSON.parse(options.re),"1")
let re = JSON.parse(options.re);
let that = this
that.setData({
re: re
})
console.log(re)
},
bindItemTap: function(event) {
/*wx.navigateTo({
url: '../answer/answer'
})*/
var aid=event.currentTarget.dataset.aid;
console.log(aid)
//console.log("1")
wx.navigateTo({
url: '../answer/answer?aid='+aid,//要跳转到的页面路径
})
}
})

@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

@ -0,0 +1,45 @@
<!--pages/searchShow/searchShow.wxml-->
<scroll-view scroll-y="true" class="container" bindscrolltoupper="upper" upper-threshold="10" lower-threshold="5" bindscrolltolower="lower" scroll-into-view="{{toView}}" scroll-top="{{scrollTop}}">
<!-- 搜索结果展示 -->
<block wx:for="{{re}}" wx:for-index="idx" wx:for-item="item" data-idx="{{idx}}">
<view class="feed-item">
<view class="feed-source">
<a class="">
<view class="avatar">
<image src="{{item.feed_source_img}}"></image>
<!--<open-data type="userAvatarUrl"></open-data>-->
</view>
<text>{{item.feed_source_name}}</text>
<!-- <open-data type="userNickName"></open-data>-->
</a>
<image class="item-more" mode="aspectFit" src="../../images/more.png"></image>
</view>
<view class="feed-content">
<view class="question" bindtap="bindItemTap" data-aid="{{item._id}}">
<a class="question-link">
<text>{{item.title}}</text>
</a>
</view>
<view class="answer-body">
<view >
<text class="answer-txt" bindtap="bindItemTap" data-aid="{{item._id}}">{{item.content}}</text>
</view>
<view class="answer-actions" bindtap="bindItemTap">
<view class="like dot">
<a>{{item.good_num}} 赞同 </a>
</view>
<view class="follow-it">
<text decode="{{true}}">&emsp;&emsp;</text>
</view>
<view class="comments dot">
<a>{{item.comment_num}} 评论 </a>
</view>
</view>
</view>
</view>
</view>
</block>
</scroll-view>

@ -0,0 +1,10 @@
.answer-txt{
width:700rpx;
height:49rpx;
font-size:25rpx;
overflow:hidden;
text-overflow: ellipsis;
display:-webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}

@ -0,0 +1,412 @@
Page({
/**
* 页面的初始数据
*/
//分类1
data: {
title: '',
content: '',
question_id:'',
feed_source_img:'',
feed_source_name:'',
tempFilePaths: [],
nowCount:0,//当前的图片上传个数
index:0,
nickName:"",
avatarUrl:"",
feed:[],
pinglun:[],
comment_num:0,
good_num:0
},
bindPickerChange:function(e){
console.log(e)
this.setData({
index:e.detail.value
})
},
//图片的上传
chooseImage:function(e){
let that = this;
wx.chooseImage({
count: 3, // 默认最多3张图片可自行更改
sizeType: ['original', 'compressed'],// 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: res => {
wx.showToast({
title: '正在上传...',
icon: 'loading',
mask: true,
duration: 1000
})
// 返回选定照片的本地文件路径列表tempFilePath可以作为img标签的src属性显示图片
let tempFilePath = res.tempFilePaths;
console.log(tempFilePath);
let nowCount = that.data.nowCount;
let tempFilePaths = that.data.tempFilePaths;
if(that.data.nowCount + tempFilePath.length >=3){
let i = 0;
while(nowCount<3){//还可以继续上传图片
tempFilePaths.push(tempFilePath[i]);
i++;
nowCount++;
}
that.setData({
nowCount:3,
tempFilePaths:tempFilePaths
})
}else{
let i = 0;
while(i<tempFilePath.length){
tempFilePaths.push(tempFilePath[i]);
i++;
}
that.setData({
nowCount:that.data.nowCount + tempFilePath.length,
tempFilePaths:tempFilePaths
})
}
console.log(that.data.nowCount,that.data.tempFilePaths);
}
})
},
//长按删除图片
DeleteImg: function (e) {
let that = this;
let tempFilePaths = that.data.tempFilePaths;
let index = e.currentTarget.dataset.index;//获取当前长按图片下标
wx.showModal({
title: '提示',
content: '确定要删除此图片吗?',
success: function (res) {
if (res.confirm) {
//console.log('点击确定了');
let nowCount = that.data.nowCount;
that.setData({
nowCount:nowCount-1
})
tempFilePaths.splice(index, 1);
} else if (res.cancel) {
//console.log('点击取消了');
return false;
}
that.setData({
tempFilePaths:tempFilePaths
});
}
})
},
//上传文件到云端
submit:function(e){
let i;
let count=0;
let that = this;
let url = [];
let pl=[];
console.log(e);
let title = e.detail.value.name;
let content = e.detail.value.content;
if(title.length<3){
wx.showToast({
title: '标题少于3个字',
icon:"none"
})
return false
}
if(content.length<5){
wx.showToast({
title: '内容少于5个字',
icon:"none"
})
return false
}
wx.showLoading({
title: '发布中',
})
if(that.data.nowCount==0){
/*wx.cloud.callFunction({
name:'love_upload',
data:{
title:title,
content:content,
openid:that.data.openid,
url:[],
},success:function(e){
console.log(e);
wx.hideLoading({
success: (res) => {
that.setData({
value1:'',
value2:'',
tempFilePaths:[],
nowCount:0
})
wx.showToast({
title: '发布成功',
})
},
})
},fail:function(e){
wx.hideLoading({
success: (res) => {
wx.showToast({
title: '网络异常',
})
that.setData({
value1:'',
value2:'',
tempFilePaths:[],
nowCount:0
})
},
})
console.log(e);
}
})*/
let a=wx.getStorageSync ("nickName")
let b=wx.getStorageSync ("avatarUrl")
wx.cloud.database().collection('tiezi').add({
data: {
title:title,
content:content,
openid:that.data.openid,
url:url,
createTime: wx.cloud.database().serverDate(),
feed_source_img:b,
feed_source_name:a,
pinglun:pl,
comment_num:0,
good_num:0
}
})
wx.hideLoading({
success: (res) => {
that.setData({
value1:'',
value2:'',
tempFilePaths:[],
nowCount:0
})
wx.showToast({
title: '发布成功',
})}})
}else{
//将所有的内容上传到云端去
for(i=0;i<that.data.nowCount;i++){
console.log(1);
let extName = that.data.tempFilePaths[i].split(".").pop();
let cloudPath = "love/" + new Date().getTime() + "." + extName;
wx.cloud.uploadFile({
cloudPath: cloudPath,
filePath: that.data.tempFilePaths[i], // 文件路径
success: res => {
count++;
url.push(res.fileID);
console.log('上传图片');
console.log(i,url);
if(count==that.data.nowCount){
console.log(url);
/*
wx.cloud.callFunction({
name:'love_upload',
data:{
title:title,
content:content,
openid:that.data.openid,
url:url,
type:parseInt(that.data.index)+1
},success:function(e){
console.log(e);
wx.hideLoading({
success: (res) => {
that.setData({
value1:'',
value2:'',
tempFilePaths:[],
nowCount:0
})
wx.showToast({
title: '发布成功',
})
},
})
},fail:function(e){
wx.hideLoading({
success: (res) => {
wx.showToast({
title: '网络异常',
})
that.setData({
value1:'',
value2:'',
tempFilePaths:[],
nowCount:0
})
},
})
console.log(e);
}
})*/
let a=wx.getStorageSync ("nickName")
let b=wx.getStorageSync ("avatarUrl")
let pl=[];
wx.cloud.database().collection('tiezi').add({
data: {
title:title,
content:content,
openid:that.data.openid,
url:url,
createTime: wx.cloud.database().serverDate(),
feed_source_img:b,
feed_source_name:a,
pinglun:pl,
comment_num:0,
good_num:0
}
})
wx.hideLoading({
success: (res) => {
that.setData({
value1:'',
value2:'',
tempFilePaths:[],
nowCount:0
})
wx.showToast({
title: '发布成功',
})}})
}
},fail:res=>{
console.log(res);
}
})
}
}
wx.switchTab({
url: '../forum/forum',
})
},
blur:function(e){
console.log(e);
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let loveSort = wx.getStorageSync('loveSort')
console.log(loveSort)
this.setData({
loveSort:loveSort
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
onAdd_s: function () {
wx.cloud.init({
env: 'cloud1-8g5wmepxce8a3b8a'
});
const db = wx.cloud.database()
db.collection('tiezi').add({
data: {
title:title,
content:content,
openid:that.data.openid,
url:[],
},
success: res => {
// 在返回结果中会包含新创建的记录的 _id
this.setData({
counterId: res._id,
count: 1
})
wx.showToast({
title: '成功扔进树洞~',
})
console.log('[数据库] [留言] 成功,记录 _id: ', res._id)
},
fail: err => {
wx.showToast({
icon: 'none',
title: '种种原因树洞拒绝了~'
})
console.error('[数据库] [新增记录] 失败:', err)
}
})
}
})

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save