master
wbb 2 years ago
parent c9c3a20268
commit e88999738c

@ -179,6 +179,7 @@ let foodid=cartlistsee[index]._id
title: '温馨提示', title: '温馨提示',
content: '确定删除当前商品吗?', content: '确定删除当前商品吗?',
confirmColor: "#f00", confirmColor: "#f00",
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
cartlistsee.splice(index, 1); cartlistsee.splice(index, 1);

@ -2,7 +2,7 @@
<image src=" /images/logo.jpg" style="width:350px" class="in-select2" mode="widthFix"> <image src=" /images/logo.jpg" style="width:350px" class="in-select2" mode="widthFix">
</image> </image>
</view> </view>
<navigator class="imagesize"> <navigator class="imagesize" url="/pages/select1/select1">
<image src="/images/perfer.jpg" style="width:440px" class="in-select" mode="widthFix"></image> <image src="/images/perfer.jpg" style="width:440px" class="in-select" mode="widthFix"></image>
</navigator> </navigator>
<navigator class="imagesize"> <navigator class="imagesize">

@ -23,7 +23,7 @@ Page({
console.log(foodid) console.log(foodid)
wx.showModal({ wx.showModal({
title: '温馨提示', title: '温馨提示',
content: '确定删除当前商品吗?', content: '确定删除当前订单吗?',
confirmColor: "#f00", confirmColor: "#f00",
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
@ -55,7 +55,7 @@ Page({
) )
}} }}
}) })
this.getTotalPrice()
console.log(orderlist) console.log(orderlist)
}, },
/** /**

@ -0,0 +1,109 @@
// pages/select1/select1.js
Page({
data: {
foodlist:[],
tabs: ['主食','小吃'],
index:null,
current:'',
re:[],
selectlist:[]
},
tabSelect:function(e){
var foodlist=[]
var current = e.currentTarget.dataset.tab
this.setData({
current:current
})
const _ = wx.cloud.database().command
console.log(current)
wx.cloud.database().collection('food').where(_.or([
{
tab: wx.cloud.database().RegExp({
regexp: this.data.current,
options: 'i',
})
}
])
)
.get()
.then(res => {
this.setData({
foodlist: res.data,
})
wx.hideLoading({
})
wx.setStorageSync('foodlist', res.data)
let foodlist= wx.getStorageSync('foodlist')
console.log(foodlist)
}),
wx.navigateTo({
url: '/pages/select2/select2?info='+JSON.stringify(this.data.foodlist)
})
},
/**
* 页面的初始数据
*/
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

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

@ -0,0 +1,7 @@
<!--pages/select1/select1.wxml-->
<view >
<text class="title">选择您需要的食物类型</text>
</view>
<view wx:for="{{tabs}}">
<view class="button" hover-class="button_hover" bindtap="tabSelect" data-tab="{{item}}">{{item}}</view>
</view>

@ -0,0 +1,30 @@
/* pages/select1/select1.wxss */
.title{
font-family:fantasy;
font-size: larger;
font-style:italic;
text-align: center;
font: weight 700;
}
.button{
font-family:fantasy;
font-size: larger;
width: 80%;
height: 100rpx;
margin: 100rpx;
background-color: rgb(137, 186, 192);
color: rgb(57, 65, 71);
border-radius: 98rpx;
text-align: center;
vertical-align: center;
line-height: 100rpx;
margin: 0 auto;
font-weight: bolder;
}
.button_hover{
position: relative;
top: 3rpx;
box-shadow:0px 0px 8px #999 inset;
}

@ -0,0 +1,137 @@
// pages/select1/select1.js
Page({
data: {
foodlist:[],
tastes: ['香辣','香咸','酸甜','椒麻'],
index:null,
current:'',
re:[],
selectlist:[]
},
tasteSelect:function(e){
var taste=e.currentTarget.dataset.taste
console.log(taste)
var foodlist=this.data.foodlist
console.log(foodlist)
var foodlistselect=[]
console.log(foodlist[1].taste)
//对食物进行筛选
for(var i=0;i<foodlist.length;i++){
if(foodlist[i].taste==taste){
foodlistselect.push(foodlist[i])
continue;
}
else{
continue;
}
}
console.log(foodlistselect);
//确定食物
var select=Math.floor(Math.random()*foodlistselect.length-1 )
if(select<0){
select="0"
}
console.log(select)
var selection=foodlistselect[select]
console.log(selection)
var name=selection.food_name
console.log(selection.food_name)
var total=selection.price
selection.num="1"
selection.checks="false"
var selection2=[]
selection2.push(selection)
wx.showModal({
title:'提示',
content:'今天吃'+name,
confirmColor: "#f00",
complete: (res) => {
if (res.confirm) {
wx.navigateTo({
url: '/pages/paying/paying?info='+JSON.stringify(selection2)+'&totalprice='+total
})
}
}
})
},
// wx.navigateTo({
// url: '/pages/fuzzy/fuzzy?list='+JSON.stringify(list),
// })
/**
* 页面的初始数据
*/
/**
* 生命周期函数--监听页面加载
*/
onLoad:function(options) {
var foodlist=JSON.parse(options.info)
console.log(foodlist)
this.setData({
foodlist:foodlist
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

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

@ -0,0 +1,7 @@
<!--pages/select2/select2.wxml-->
<view class='choose'>
<view wx:for="{{tastes}}">
<view class="button" hover-class="button_hover">
<text bindtap="tasteSelect" data-taste="{{item}}">{{item}}</text>
</view></view>
</view>

@ -0,0 +1,22 @@
/* pages/select2/select2.wxss */
.button{
font-family:fantasy;
font-size: larger;
width: 80%;
height: 100rpx;
margin: 100rpx;
background-color: rgb(137, 186, 192);
color: rgb(57, 65, 71);
border-radius: 98rpx;
text-align: center;
vertical-align: center;
line-height: 100rpx;
margin: 0 auto;
font-weight: bolder;
}
.button_hover{
position: relative;
top: 3rpx;
box-shadow:0px 0px 8px #999 inset;
}

@ -38,7 +38,8 @@ Page({
wx.showModal({ wx.showModal({
title: '提示', title: '提示',
content: str, content: str,
success: function() { //点击确定后还原到0度 success(res) { //点击确定后还原到0度
if (res.confirm) {
let animation = wx.createAnimation({ let animation = wx.createAnimation({
duration: 100, duration: 100,
timingFunction: 'linear' timingFunction: 'linear'
@ -48,7 +49,7 @@ Page({
rotate: animation.export(), rotate: animation.export(),
turning: false turning: false
}) })
}
var Selection=[] var Selection=[]
var detailObj=_this.data.detailObj var detailObj=_this.data.detailObj
var total=detailObj.price var total=detailObj.price
@ -87,7 +88,6 @@ Page({
}, },
onLoad: function() { onLoad: function() {
const db=wx.cloud.database() const db=wx.cloud.database()
var that=this
db.collection("user") db.collection("user")
.where({ .where({
"_openid":userid "_openid":userid
@ -101,12 +101,12 @@ Page({
//随机在购物车里选择一件商品 //随机在购物车里选择一件商品
var p=Math.round(Math.random()*o) var p=Math.round(Math.random()*o)
console.log(p) console.log(p)
that.setData({ this.setData({
list:res.data[0].cartlist[p].food_name, list:res.data[0].cartlist[p].food_name,
detailObj:res.data[0].cartlist[p] detailObj:res.data[0].cartlist[p]
}) })
var detailObj=this.data.detailObj var detailObj=this.data.detailObj
console.log(detailObj) console.log("cartlist内容",detailObj)
// console.log('请求成功2',res.data[0].cartlist[p].food_name); // console.log('请求成功2',res.data[0].cartlist[p].food_name);
wx.setStorageSync('i', res.data[0].cartlist[p].food_name) wx.setStorageSync('i', res.data[0].cartlist[p].food_name)
}, },

Loading…
Cancel
Save