微信小程序开发之快递服务专栏(快递运力查询、寄快递、取消订单)

今天小编给大家展示自己的第一个小程序

1.新建工程

1.右键项目——新建项目打开如下图所示:
其中项目名自己起,工程目录自己选择一个,AppID笔者使用的是注册号,您可以申请一个。
在这里插入图片描述

2.获取api

快递的API笔者选择的是:贵州诚数科技有限公司的下单api
点击:快递寄件
在这里插入图片描述
这个api有三个功能:分别是快递寄件、快递运力查询、快递订单取消
在这里插入图片描述
然后在此页面的右上角找到买家中心点进去如下图:
在这里插入图片描述
点击订单号后进入下图,图中标出来的就是你要使用的api
在这里插入图片描述

【网页上可以调试,也有示例代码】

在这里插入图片描述

3.界面

【快递运力查询】
<view class="container1">
    <br style="font-size:20px" > 查询某地快递运力\n</br>    
     <input placeholder="最大输入长度为10" bindinput="input" /> 
     <button type="primary" bindtap = "btnClick"style="position:relative;right:10%; padding:5%;width:100%;height:10%;font-size:80%;background-color:#07c160;color:white;margin-bottom:10%;">查询</button>
              <scroll-view scroll-y="true" style="height:300px;">
              【{{expressInfo.message}}】
                  <view wx:for="{{expressInfo.data.details}}" > 
                      {{item.comCode}}【{{item.type}}】
                  </view>
              </scroll-view>           
</view>
【寄快递】
   <br style="font-size:20px" >寄件</br>
          <text>\n</text>
            收件人完整地址 <input placeholder="收件人完整地址,包含省、市、区、街道等" bindinput="input1" /> 
            订单信息回调地址  <input placeholder="订单信息回调地址" bindinput="input2" /> 
            随机数  <input placeholder="随机数" bindinput="input3" /> 
            预约时间    <input placeholder="预约起始时间(HH:mm),例如:09:00" bindinput="input4" /> 
            预约截止时间    <input placeholder="预约截止时间(HH:mm),例如:10:00" bindinput="input5" /> 
            寄件人所在完整地址     <input placeholder="寄件人所在完整地址,包含省、市、区、街道等" bindinput="input6" /> 
            物品总重量     <input placeholder="物品总重量KG,例:1.5,单位kg" bindinput="input7" /> 
            备注      <input placeholder="备注" bindinput="input8" /> 
            收件人手机号  <input placeholder="收件人的手机号,手机号和电话号二者其一必填" bindinput="input9" /> 
            预约日期  <input placeholder="预约日期,例如:今天/明天/后天" bindinput="input10" /> 
            寄件人姓名 <input placeholder="寄件人姓名" bindinput="inpu11" /> 
            收件人姓名<input placeholder="收件人姓名" bindinput="input12" /> 
            支付方式<input placeholder="支付方式,SHIPPER: 寄付(默认),CONSIGNEE: 到付" bindinput="input13" /> 
            快递公司编码<input placeholder="快递公司的编码,一律用小写字母" bindinput="input14" /> 
            物品种类    <input placeholder="物品名称,例:文件(公司编码为jd时,cargo必填)" bindinput="input15" /> 
            寄件人手机号   <input placeholder="寄件人的手机号,手机号和电话号二者其一必填" bindinput="input16" /> 
            <button type="primary" bindtap = "btnClick1"style="position:relative;right:10%; padding:5%;width:100%;height:10%;font-size:80%;background-color:#07c160;color:white;margin-bottom:10%;">寄件</button>
              <scroll-view scroll-y="true" style="height:300px;">
                  <view>
                    [taskId:   {{expressInfo1.data.detail.taskId}} ] [orderId:{{expressInfo1.data.detail.orderId}}][messages:{{expressInfo1.message}}]
                  </view>
              </scroll-view>   
【取消订单】
    <br style="font-size:20px" > 快递订单取消</br>        
     <text>\n</text>
     cancelMsg:  <input placeholder="取消原因" bindinput="input17" /> 
     orderId:   <input placeholder="订单ID" bindinput="input18" /> 
     taskID:        <input placeholder="任务ID" bindinput="input19" /> 
    <button type="primary" bindtap = "btnClick2"style="position:relative;right:10%; padding:5%;width:100%;height:10%;font-size:80%;background-color:#07c160;color:white;margin-bottom:10%;">确定</button>
              <scroll-view scroll-y="true" style="height:300px;">
                  <view > 
                      {{expressInfo2.data.result}}【{{expressInfo2.data.description}}】
                  </view>
              </scroll-view>    

4.调用api

【重点来了!!!】
这部分是最重要的部分参数一定要写对,不然读取不到
url填写所用的api的地址,后面的参数根据每个api的参数来写:
快递运力查询 只有一个参数:address,如下图:
请求方式为GET,调用地址也给出了。

在这里插入图片描述
示例:

 getExpressInfo:function(address,cb){
    wx.request({
      url: 'http://gwgp-wat4svkuskr.n.bdcloudapi.com/kdyl/get?address='+address, //仅为示例,并非真实的接口地址
      data: {
        x: '',
        y: ''
      }, 
      header: {
        'Content-Type': 'application/json;charset=UTF-8' ,// 默认值
        'X-Bce-Signature':'AppCode/8a6b23ce2a194b689c7afd96ae539bb8'
      },
      success (res) {
        cb(res.data)
      //  console.log(res.data)
      }
    })
  },

5.运行结果图

【快递运力查询】

在这里插入图片描述

【快递下单】

在这里插入图片描述

【下单失败】

在这里插入图片描述

【下单成功,返回订单号】

在这里插入图片描述

【取消订单】

在这里插入图片描述

【输入订单号和任务号】

在这里插入图片描述

【关于url的地址各位朋友一定要注意】
【笔者反反复复的发送失败,查不出原因整个人都不好了】
【另外就是请求方式的问题:post、get要注意!!!,不然请求不到】

6.获取资源

【获取资源】

1.资源链接:资源获取
2.微信后台回复:快递小程序
3.源代码 点击

【关注微信公众号一起来交流】
  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sf9090

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值