zoukankan      html  css  js  c++  java
  • 确认收货逻辑 根据索引删除 和找到这一项数据 直接从本地进行删除数据(不通过调用接口刷新页面 本地刷新页面)

    // data-index='{{index}}' 把索引传递过去
     <view class='btn pay_now' data-index='{{index}}' data-orderid='{{item.order_id}}' bindtap='orderTakeDelivery'> 
                  确认收货
                </view>
      //确认收货
      orderTakeDelivery: function (e) {
        const that = this;
        let order_id = e.currentTarget.dataset.orderid;
        let idx = e.currentTarget.dataset.index; // 在这里拿到传递过来的索引
        let postData = {
          order_id: order_id,
        };
        let datainfo = requestSign.requestSign(postData);
        header.sign = datainfo;
        wx.request({
          url: api.get_orderTakeDelivery,
          data: postData,
          header: header,
          method: 'POST',
          dataType: 'json',
          responseType: 'text',
          success: (res) => {
            if (res.data.code == 1) {
              wx.showToast({
                title: res.data.message,
                icon: 'none'
              })
              // 全部   只有在order_status == -999全部的状态下点击确认收货按钮 
              if (that.order_status == -999) {
                //order_status = 4  把状态改为已收货状态  (根据索引idx找到当前这一项)
                that.data.orderList[idx].order_status = 4
                // 这个地方是赋值 是真正的同步页面数据
                that.setData({
                  ["orderList[" + idx + "]"]: that.data.orderList[idx]
                })
                // 转为完成状态 
              } else {
                // 因为只有全部 和 待收货状态下有确认收货按钮 所以在else里面 就是待收货状态 把当前这一项从数组里面删除
                that.data.orderList.splice(idx, 1) // =>根据索引删除当前这一项
                // 同时同步页面页数
                that.setData({
                  orderList: that.data.orderList
                })
              }
              that.getChannelOrderDetailList();
            } else {
              wx.showToast({
                title: res.data.message,
                icon: 'none'
              })
            }
          }
        })
      },
  • 相关阅读:
    LPC2478中断控制器以及串口详解
    有效三角形的个数
    小于K的两数之和
    和至少为K的最短子数组
    docker: 构建自己的镜像
    判断字符串是否是异位词
    找出字符串中的最长回文
    knuth洗牌算法
    使用adb命令控制anroid手机
    bitmap以及异或运算法
  • 原文地址:https://www.cnblogs.com/xiaoxiaoxun/p/12498056.html
Copyright © 2011-2022 走看看