博客
关于我
购物车列表、提交订单、多端运行、多端发行
阅读量:344 次
发布时间:2019-03-04

本文共 2391 字,大约阅读时间需要 7 分钟。

购物车管理与订单处理技术文档

一、购物车列表功能

1. 总价钱、总数量及全选状态获取

  • 总数量:通过遍历购物车列表项,累加选中项的商品数量。
  • 总价钱:同理,累加选中项的商品总价。
  • 全选状态:检查所有购物车项,若全部选中则返回true,否则false。

2. 购物车信息修改

2.1 数量增减

  • 加法:直接修改项的num,并调用cartEdit方法执行数据库更新。
  • 减法:类似加法操作,但需处理num降至1的情况,同样调用cartEdit

2.2 单个状态切换

  • 通过changeChecked方法,根据当前状态切换选中状态,并执行数据库更新。

2.3 全选状态切换

  • 通过changeAllChecked事件,根据开关状态修改所有购物车项的选中状态,并执行数据库更新。

2.4 数据库修改操作

  • 参数

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

3. 购物车删除

  • 接口

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

4. 点击结算跳转

  • 逻辑:检查购物车中是否有至少一件商品,若无则提示,否则跳转至结算页面。

5. 提交订单

1. 获取购物车商品信息

  • 筛选选中商品:根据选中状态筛选出需要结算的商品列表。

2. 下单操作

  • 参数

    • uid:会员ID
    • username:收货人姓名
    • 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);  }}

6. 多端运行

  • 微信小程序:与支付宝小程序功能一致,仅需调整样式。
  • App开发:需配置Android和iOS的发布配置,注意证书签名和权限设置。

7. 多端发行

  • H5发布:配置网站标题和域名,发布至指定路径。

  • 小程序审核:完成合法域名设置,提交审核后上线。

  • App打包:注意证书管理和权限设置,确保包络正确。

转载地址:http://qase.baihongyu.com/

你可能感兴趣的文章
python可视化matplotlib_如何使用Python中最强大的可视化工具Matplotlib?
查看>>
python可维护性_使用这7大神器,让你的Python 代码更容易于维护
查看>>
Python只运行一次while循环
查看>>
python变量的详细教程_Python零基础入门教程之语法入门[变量](第二期)
查看>>
Python变量命名方法-ChatGPT4o作答
查看>>
Python变量与运算符
查看>>
Python变量/运算符/函数/模块/string
查看>>
python发送邮件的时候出现 error (535, b‘5.7.3 Authentication unsuccessful‘) 解决方法
查看>>
python系列【仅供参考】:python flask框架 debug功能
查看>>
python发送notes邮件_使用python在Lotus Notes中发送邮件
查看>>
Python双版本下创建一个Scrapy(西瓜皮)项目
查看>>
Python双版本下No module named 'requests'
查看>>
python及pycharm2018软件安装教程
查看>>
python去重txt文本_Python实现的txt文件去重功能示例
查看>>
python去掉列表的逗号,从Python列表项中删除标点符号
查看>>
Python卸载所有包
查看>>
python单线程下实现多个socket并发
查看>>
Python单元测试框架介绍(超详细~)
查看>>
Python单元测试框架
查看>>
python单元测试之unittest
查看>>