轻源码

  • QingYuanMa.com
  • 全球最大的互联网技术和资源下载平台
搜索
一起源码网 门户 微信小程序 查看主题

微信小程序案例-快递查询

发布者: lobbie | 发布时间: 2018-2-25 12:08| 查看数: 4647| 评论数: 1|帖子模式

作者:吹泡泡163,来自原文地址 
wxml

  1. <view class="container">
  2. <input placeholder="输入快递单号" placeholder-class="placeColor" bindinput="getText"/>
  3. <!--显示查得的快递信息-->
  4. <scroll-view scroll-y="true" class="scroll">
  5. <view class="info" wx:for="{{dataInfo}}">
  6. <view class="time">{{item.time}}</view>
  7. <view class="context">{{item.context}}</view>
  8. </view>
  9. </scroll-view>
  10. <view class="btngroup">
  11. <button type="primary" hover-class="none" bindtap="search">查询</button>
  12. <button type="primary" hover-class="none" bindtap="onBtnTap">{{expressChinese}}</button>
  13. </view>
  14. </view>

wxss

  1. /* index/index.wxss */
  2. page{
  3. background: #565656;
  4. }
  5. scroll-view{
  6. border: 2rpx solid #f60;
  7. }
  8. .container{
  9. display: flex;
  10. flex-direction: column;
  11. align-items: center;
  12. padding: 80rpx 0;
  13. }
  14. input{
  15. width: 550rpx;
  16. padding: 10rpx 0;
  17. text-align: center;
  18. border: 2px solid #f60;
  19. border-radius: 10rpx;
  20. color: #fff;
  21. }
  22. .placeColor{
  23. color: #fff;
  24. }
  25. .scroll{
  26. height: 600rpx;
  27. width: 100%;
  28. margin-top: 20rpx;
  29. }
  30. .info{
  31. padding: 30rpx;
  32. }
  33. .time{
  34. color: #fff;
  35. font-size: 14px;
  36. }
  37. .context{
  38. color: #fff;
  39. font-size: 16px;
  40. margin-top: 10rpx;
  41. }
  42. .btngroup{
  43. width: 100%;
  44. margin-top: 100rpx;
  45. }
  46. .btngroup button{
  47. width: 100%;
  48. background: #f60;
  49. color: #fff;
  50. margin-top: 5rpx;
  51. }
  52. .btngroup .default{
  53. background-color: #f60;
  54. }
  55. .btngroup .warn{
  56. background-color: red;
  57. }

js

  1. // index/index.js
  2. Page({
  3. data:{
  4. expressChinese:'快递公司选择'
  5. },
  6. onLoad:function(options){
  7. // 页面初始化 options为页面跳转所带来的参数
  8. var orderNum = this.data.orderNum;
  9. },
  10. search:function(){
  11. this.getExpressInfo(this.data.expressEnglish,this.data.orderNum);
  12. },
  13. //传入快递公司、快递单号获取快递信息
  14. getExpressInfo:function(param,orderNum){
  15. console.log(param,orderNum);
  16. var that = this;//由于函数里面又嵌套了一个函数,所以需要先保存this指向,方便后面将数据传递到data里面,
  17. //读取快递数据
  18. wx.request({
  19. //3323211723270
  20. url: '+param+'&postid='+orderNum+'',
  21. //数据读取成功
  22. success: function(res){
  23. var data = res.data.data;
  24. console.log("快递信息:"+data);
  25. //将数据传递给data
  26. that.setData({dataInfo:data});
  27. },
  28. //数据读取失败
  29. fail:function(){
  30. console.log('订单号有误')
  31. }
  32. })
  33. },
  34. //获得页面的快递单号
  35. getText:function(event){
  36. var orderNum = event.detail.value.trim();
  37. //将快递单号值传递给data
  38. this.setData({
  39. orderNum:orderNum
  40. })
  41. },
  42. //快递公司选择点击事件
  43. onBtnTap:function(){
  44. var that = this;//由于函数里面又嵌套了一个函数,所以需要先保存this指向,方便后面将数据传递到data里面,
  45. var expressChinese = ['韵达','中通','顺丰','汇通','申通'];
  46. var expressEnglish = ['yunda','zhongtong','shunfeng','huitong','shentong'];
  47. wx.showActionSheet({
  48. itemList:expressChinese,
  49. success:function(res){
  50. //点击谁,返回谁对应的itemList的数组内的下标编号
  51. var valueEnglish = expressEnglish[res.tapIndex];
  52. var valueChinese = expressChinese[res.tapIndex];
  53. that.setData({
  54. expressEnglish:valueEnglish,
  55. expressChinese:valueChinese
  56. })
  57. }
  58. })
  59. }
  60. })

最新评论

三3230 发表于 2022-5-24 23:30
Python程序设计pdf

轻源码让程序更轻更快

QingYuanMa.com

工作时间 周一至周六 8:00-17:30

侵权处理

客服QQ点击咨询

关注抖音号

定期抽VIP

Copyright © 2016-2021 https://www.171739.xyz/ 滇ICP备13200218号

快速回复 返回顶部 返回列表