博客
关于我
购物车列表、提交订单、多端运行、多端发行
阅读量: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 | 深入理解Python并发编程中的GIL限制与解决方案
查看>>
Python | 爬虫实战——亚马逊搜索页监控(附详细源码)
查看>>
python | 高效使用Python工具自动生成模块文档的秘诀
查看>>
python 一个list去除另一个list中的值
查看>>
python 三大框架的 介绍。
查看>>
Python 下载的 11 种姿势,一种比一种高级!
查看>>
python读取一个文件夹下所有图片_初学Python-找出文件夹下的所有图片
查看>>
Python 中 3 个不可思议的返回功能
查看>>
python 中 dict 的另一种用法
查看>>
Python 中 PIL 读取图片出现异常旋转的解决方法
查看>>
python 中os.path.join 双斜杠的解决办法
查看>>
Python 中Semaphore 信号量对象、Event事件、Condition
查看>>
python 中with的使用及样例
查看>>
Python 中内置的最大堆 API
查看>>
Python 中只有一个 True 和一个 False 对象吗?
查看>>
python读取mtcars数据集并实现以下操作_关于数据处理。。,Python交流,技术交流区,鱼C论坛 - Powered by Discuz!...
查看>>
Python 中多线程与多处理之间的区别
查看>>
Python 中如何使用 lambda 函数
查看>>
Python 中如何创建多行字符串?
查看>>
Python 中如何处理异常?
查看>>