用mysql写外卖订单程序_小程序外卖订单界面的示例代码

本文展示了如何使用MySQL编写外卖订单程序,包括小程序的外卖订单界面示例代码。详细介绍了商品列表的加减功能,购物车同步更新,以及页面视图的动态变化。代码涵盖wxml、script和css部分,实现了商品选择、数量控制、价格计算等功能。
摘要由CSDN通过智能技术生成

1.效果界面

42a95a4d470c0c54c427b9b5703355d5.png

75336af752dd57ea7127cdc9e1e9dfe8.png

06d082e46676efb263fca6e1b8cd6f17.png

dae11dcceb501699f9aee8fe43b87c0d.png

2.涉及功能

*左侧商品类型、右侧商品可以相互控制;

*商品列表加减及购物车商品加减icon消失、显示;

*商品每一次加减,页面视图变化(数量、价格变化、购物车置灰);

3.贴上所有代码

1.wxml

{ {item.name}}

{ {item.name}}

{ {itm.title}}

{ {itm.info}}

¥{ {itm.price}}

{ {totalNum}}

¥{ {totalMoney}}

去结算

已选商品

清空

{ {item.name}}

¥{ {item.price}}

{ {goodDetail.title}}

¥{ {goodDetail.price}}

{ {goodDetail.info}}

2.script

createPage({

data: {

foodsList: [], // 商品数据

cartList: [], // 购物车数据

isShowCartMask: false,

totalNum: 0,

totalMoney: 0,

initView: 'item0', // 根据此变量的变化,控制左侧选中状态、右侧滑动

curId: 'item0',

isShowDetail: false,

goodDetail: {},

screenWidth: 0, // 手机屏幕宽度

heightArray: [0] // 右侧每一个类型的高度区间数组

},

onLoad() {

this.getGoodsData()

},

methods: {

async getGoodsData() {

const that = this

const res = await getGoodsInfo({})

this.foodsList = res

wx.getSystemInfo({

success: (ress) => {

that.screenWidth = ress.windowWidth

}

})

this.getHeightSection()

},

// 设置高度区间 所有单位转化为rpx

getHeightSection() {

const that = this

let hg = 0

for (let index = 0; index < that.foodsList.length - 1; index++) {

hg += 70 + that.foodsList[index].list.length * 212

that.heightArray.push(hg)

}

},

// 获取高度区间的下标

getHeightIndex(arr, hg) {

const that = this

arr.forEach((item, index) => {

if (hg >= item) {

that.setData({

curId: 'item' + index

})

}

})

},

// 左边菜单控制右边

scrollToViewFn(e) {

this.setData({

initView: e.target.dataset.id,

curId: e.target.dataset.id

})

},

// 右边滚动控制左边

onPageScroll(e) {

const that = this

let scrollTop = e.detail.scrollTop * 750 / that.screenWidth

this.getHeightIndex(that.heightArray, scrollTop)

},

// 商品列表的减号点击

reduceNum(index, ind, item) {

const that = this

let val = 'foodsList[' + index + '].list[' + ind &

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值