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'
              })
            }
          }
        })
      },
  • 相关阅读:
    【转】测试人员职业规划
    phantomjs处理alert、confirm弹窗
    linux搭建phantomjs+webdriver+testng+ant自动化工程
    linux搭建apache服务并修改默认路径
    linux环境vnc部署过程详解
    mongodb集群+分片部署(二)
    mongodb部署单节点(一)
    java javaScript实现遮罩层 动态加载
    感受
    JavaScript之中Array用法的一些技巧总结
  • 原文地址:https://www.cnblogs.com/xiaoxiaoxun/p/12498056.html
Copyright © 2011-2022 走看看