王贤士

简易微信物流信息查询小程序开发
物流查询小程序(只用提供订单号即可查询) //逻辑代码 var app = getApp() Page({ ...
扫描右侧二维码阅读全文
31
2018/12

简易微信物流信息查询小程序开发

物流查询小程序(只用提供订单号即可查询)

QQ截图20181231230657.png

//逻辑代码

var app = getApp()

Page({
  data: {//数据初始化
    dataList: null,
    ydh:"",
  },
  //获取input输入的运单号
  getYdh:function(e){
    this.setData({
      ydh:e.detail.value
    })
  },
  search: function (no) {
    this.getYd(this.data.ydh)
  },
  getYd: function (no, search) {
    var that = this;//保存this
    wx.request({
      url: 'https://goexpress.market.alicloudapi.com/goexpress',
      data: {
        no: no,
      },
      header: {
        'content-type': 'application/json', // 默认值
        'Authorization': 'APPCODE 8f0dfa18e2254c859c49c4ef2f4a6aca'
      },
      success: function (res) {
        that.setData({
          dataList: res.data.list
        })
        console.log(res.data)
      }
    })
  }
})

//页面代码

    <!--index.wxml-->
<view class="container">
  <input class='btn' placeholder='请输入运单号' bindinput="getYdh" name='ydh'></input>
  <button type="primary" bindtap="search">
    查询
  </button>
  <scroll-view scroll-y style="height: 150px;" bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" scroll-into-view="{{toView}}" scroll-top="{{scrollTop}}">
    <view wx:for='{{dataList}}' wx:key='{{index}}'>
      {{item.time}}:{{item.content}}
    </view>
  </scroll-view>
</view>

代码:

Last modification:January 7th, 2019 at 12:04 pm
If you think my article is useful to you, please feel free to appreciate

2 comments

  1. 伯岱

    很有用,谢谢

    1. wise
      @伯岱

      阿里免费API 调用已达上限,附上阿里API申请的地址https://market.aliyun.com/products/?keywords=物流
      需要替换下请求的url和参数,和请求头部的Authorization

Leave a Comment