2.3
发布于 3 年前 作者 qinqiang 4364 次浏览 来自 分享

1.express.wxml 找到清空和查询区域&分别绑定两个函数

<button bindtap="bindOnClear" class="btn-clear" type="primary" plain >清空</button>

<button bindtap="bindOnSearch" class="btn-search" type="primary" plain loading="{{loading}}">查询</button>


2.express.js

//选择快递公司函数

bindExpressChange: function(e){

console.log("e=", e.detail.value)

this.setData({

  index: e.detail.value

})

},

3.express.js

//清空函数

bindOnClear: function() {

    this.setData({

      index: 0,

      postId: '',

      jsonObj: {},

      loading: false

    })

},

4.查询函数

bindOnSearch: function() {

    this.setData({

      loading: !this.data.loading

    })

    var com = this.data.key[this.data.index]

    var arrJson = localJsonData.dataList[`${com}`] //假设六个订单的Json数据

    var idx = Math.floor(Math.random()*arrJson.length) //06

    setTimeout(this.myCallback, 3000, arrJson[idx]

},

5.回调函数

myCallback: function(orderJsonObj) {

    // 若获取订单数据成功,则将物流跟踪数据的数组逆序(不成功时json中无此数组)

    console.log("orderJsonObj=", orderJsonObj)

    orderJsonObj.result.list.reverse()

    // 拿到Json数据,切换正在加载的图标,并推送到视图渲染线程

    this.setData({

      loading: !this.data.loading,

      jsonObj: orderJsonObj

    })

  }






1 回复

真不错社区大佬真多

回到顶部