本文共 2449 字,大约阅读时间需要 8 分钟。
num,并调用cartEdit方法执行数据库更新。num降至1的情况,同样调用cartEdit。changeChecked方法,根据当前状态切换选中状态,并执行数据库更新。changeAllChecked事件,根据开关状态修改所有购物车项的选中状态,并执行数据库更新。参数:
id:购物车编号(必填)num:商品数量checked:选中状态(0/1)authorization:后台验证所需的token接口:
const _cartEdit = (header, data) => { let option = { url: "/api/cartedit", header, data }; return http(option);} 代码示例:
async cartEdit(index) { const { id, num, checked } = this.cartLists[index]; const header = { authorization: uni.getStorageSync('userInfo').token }; const res = await this.$api._cartEdit(header, { id, num, checked }); console.log(res);} 接口:
const _cartDelete = (header, data) => { let option = { url: "/api/cartdelete", header, data }; return http(option);} 代码示例:
async cartDelete(index) { const { id } = this.cartLists[index]; const header = { authorization: uni.getStorageSync('userInfo').token }; const res = await this.$api._cartDelete(header, { id }); console.log(res); this.cartLists.splice(index);} 参数:
uid:会员IDusername:收货人姓名userphone:收货人电话address:收货地址countmoney:订单总金额countnumber:订单商品数量addtime:订单时间戳idstr:购物车商品ID字符串接口:
const _orderAdd = (header, data) => { let option = { url: "/api/orderadd", header, data }; return http(option);} 代码示例:
async orderAdd() { const { uid, token } = uni.getStorageSync('userInfo'); const params = { uid, username: this.information.name, userphone: this.information.phone, address: this.information.address, countmoney: this.totalPrice, countnumber: this.totalNum, addtime: new Date().getTime() }; const idstr = this.cartLists.map(item => item.id).join(','); const header = { authorization: token }; const data = { params, idstr }; const res = await this.$api._orderAdd(header, data); console.log(res); if (res.data.code === 200) { uni.showToast({ title: res.data.msg }); setTimeout(() => { uni.redirectTo({ url: "../order/order" }); }, 1000); }} H5发布:配置网站标题和域名,发布至指定路径。
小程序审核:完成合法域名设置,提交审核后上线。
App打包:注意证书管理和权限设置,确保包络正确。
转载地址:http://qase.baihongyu.com/