1. 程式人生 > >微信小程序訂單頁面

微信小程序訂單頁面

borde lse log stat XML 選項 clam size ref

技術分享圖片

說明:頭部有一個三種預約狀態的切換

wxml頁面:

  1. <!-- 切換欄 -->
  2. <view class="swiper-tab">
  3. <block wx:for="{{swipertab}}" wx:key="sptab">
  4. <view class="swiper-tab-list {{currtab == item.index ? ‘on‘ : ‘‘}}" data-current="{{item.index}}" bindtap="tabSwitch">{{item.name}}</view>
  5. </block>
  6. </view>
  7. <swiper current="{{currtab}}" class="swiper-box" duration="300" style="height:{{deviceH-31}}px" bindchange="tabChange">
  8. <!-- 完成 -->
  9. <swiper-item>
  10. <scroll-view class="hot-box" scroll-y="true">
  11. <view class="orderDetails" wx:for="{{alreadyOrder}}" wx:key=" ">
  12. <view class="orderListTitle">
  13. <text class="userName">{{item.name}}</text>
  14. <text class="orderStatus">{{item.state}}</text>
  15. </view>
  16. <view class="orderListDetails">
  17. <view class="productImg">
  18. <image src="{{item.url}}" background-size="cover"></image>
  19. </view>
  20. <view class="productInfo">
  21. <view class="productTitle">預定時間: {{item.time}}</view>
  22. <text class="productPrice">當前狀態:{{item.status}}</text>
  23. </view>
  24. </view>
  25. <view class="productCount">
  26. <view>
  27. <text>合計:¥{{item.money}}</text>
  28. </view>
  29. </view>
  30. </view>
  31. </scroll-view>
  32. </swiper-item>
  33. <!-- 待付款 -->
  34. <swiper-item>
  35. <scroll-view class="hot-box" scroll-y="true">
  36. <view class="orderDetails" wx:for="{{waitPayOrder}}" wx:key=" ">
  37. <view class="orderListTitle">
  38. <text class="userName">{{item.name}}</text>
  39. <text class="orderStatus">{{item.state}}</text>
  40. </view>
  41. <view class="orderListDetails">
  42. <view class="productImg">
  43. <image src="{{item.url}}" background-size="cover"></image>
  44. </view>
  45. <view class="productInfo">
  46. <view class="productTitle">預定時間: {{item.time}}</view>
  47. <text class="productPrice">當前狀態:{{item.status}}</text>
  48. </view>
  49. </view>
  50. <view class="productCount">
  51. <view>
  52. <text>合計:¥{{item.money}}</text>
  53. </view>
  54. </view>
  55. </view>
  56. </scroll-view>
  57. </swiper-item>
  58. <!-- 取消 -->
  59. <swiper-item>
  60. <scroll-view class="hot-box" scroll-y="true">
  61. <view class="orderDetails" wx:for="{{lostOrder}}" wx:key=" ">
  62. <view class="orderListTitle">
  63. <text class="userName">{{item.name}}</text>
  64. <text class="orderStatus">{{item.state}}</text>
  65. </view>
  66. <view class="orderListDetails">
  67. <view class="productImg">
  68. <image src="{{item.url}}" background-size="cover"></image>
  69. </view>
  70. <view class="productInfo">
  71. <view class="productTitle">預定時間: {{item.time}}</view>
  72. <text class="productPrice">當前狀態:{{item.status}}</text>
  73. </view>
  74. </view>
  75. <view class="productCount">
  76. <view>
  77. <text>合計:¥{{item.money}}</text>
  78. </view>
  79. </view>
  80. </view>
  81. </scroll-view>
  82. </swiper-item>
  83. </swiper>

wxss樣式:

  1. /*切換欄*/
  2. .swiper-tab {
  3. height: 40px;
  4. line-height: 40px;
  5. background: #3B3B3B;
  6. color:#fff ;
  7. display: flex;
  8. position: relative;
  9. z-index: 2;
  10. flex-direction: row;
  11. justify-content: center;
  12. align-items: center;
  13. border-bottom:1px solid black;
  14. }
  15. .swiper-tab-list {
  16. margin: 0 30px;
  17. padding: 0 4px;
  18. font-size: 15px;
  19. }
  20. .on {
  21. border-bottom:2px solid #fff;
  22. color: #f5f5f5;
  23. }
  24. .navTopList {
  25. display: flex;
  26. width: 100%;
  27. height: 70rpx;
  28. background: #fff;
  29. border-bottom: 1rpx solid #BEBEBE ;
  30. margin-top:5px;
  31. }
  32. .navTopList .order-info {
  33. text-align: center;
  34. }
  35. .navTopList .order-info view {
  36. width: 56rpx;
  37. height: 56rpx;
  38. margin-left: 31rpx;
  39. }
  40. .navTopList .order-info text {
  41. font-size: 34rpx;
  42. }
  43. .navTopList .order-info text.active {
  44. color: #ff6662;
  45. }
  46. .navTopList .ywc,.navTopList .dfk,.navTopList .yqx {
  47. flex: 1;
  48. }
  49. /*訂單列表*/
  50. .orderDetails {
  51. background: #fff;
  52. border-bottom: 20rpx solid #f5f5f5;
  53. }
  54. .orderListTitle {
  55. height: 100rpx;
  56. line-height: 100rpx;
  57. border-bottom: 1rpx solid #BEBEBE;
  58. }
  59. .orderListTitle .userName {
  60. padding-right: 50rpx;
  61. margin-left:10px;
  62. }
  63. .orderListTitle .orderStatus {
  64. float: right;
  65. margin-right: 20rpx;
  66. color: #2f7b27;
  67. font-size: 34rpx;
  68. }
  69. .orderListDetails {
  70. display: flex;
  71. height: 200rpx;
  72. border-bottom: 1rpx solid #f3f3f3;
  73. }
  74. .orderListDetails .productImg {
  75. flex: 1;
  76. height:180rpx;
  77. width:120px;
  78. margin-top: 20rpx;
  79. margin-left: 20rpx;
  80. }
  81. .orderListDetails .productImg image {
  82. width: 100px;
  83. height: 90%;
  84. }
  85. .orderListDetails .productInfo {
  86. flex: 4;
  87. margin: 40rpx 10px 20px 30rpx;
  88. font-size:15px;
  89. }
  90. .orderListDetails .productInfo .productTitle {
  91. font-size:15px;
  92. overflow: hidden;
  93. display: -webkit-box;
  94. -webkit-line-clamp: 2;
  95. -webkit-box-orient: vertical;
  96. margin-bottom:10px;
  97. }
  98. .productCount {
  99. height: 80rpx;
  100. line-height: 80rpx;
  101. border-bottom: 1rpx solid #f3f3f3;
  102. }
  103. .productCount>view {
  104. float: right;
  105. margin-right: 30rpx;
  106. }

js:主要是在data中給切換欄配置參數,和默認顯示第幾個欄;

  1. // pages/order/order.js
  2. Page({
  3. /**
  4. * 頁面的初始數據
  5. */
  6. data: {
  7. currtab: 0,
  8. swipertab: [{ name: ‘已完成‘, index: 0 }, { name: ‘待付款‘, index: 1 }, { name: ‘已取消‘, index: 2 }],
  9. },
  10. /**
  11. * 生命周期函數--監聽頁面加載
  12. */
  13. onLoad: function (options) {
  14. },
  15. /**
  16. * 生命周期函數--監聽頁面初次渲染完成
  17. */
  18. onReady: function () {
  19. // 頁面渲染完成
  20. this.getDeviceInfo()
  21. this.orderShow()
  22. },
  23. getDeviceInfo: function () {
  24. let that = this
  25. wx.getSystemInfo({
  26. success: function (res) {
  27. that.setData({
  28. deviceW: res.windowWidth,
  29. deviceH: res.windowHeight
  30. })
  31. }
  32. })
  33. },
  34. /**
  35. * @Explain:選項卡點擊切換
  36. */
  37. tabSwitch: function (e) {
  38. var that = this
  39. if (this.data.currtab === e.target.dataset.current) {
  40. return false
  41. } else {
  42. that.setData({
  43. currtab: e.target.dataset.current
  44. })
  45. }
  46. },
  47. tabChange: function (e) {
  48. this.setData({ currtab: e.detail.current })
  49. this.orderShow()
  50. },
  51. orderShow: function () {
  52. let that = this
  53. switch (this.data.currtab) {
  54. case 0:
  55. that.alreadyShow()
  56. break
  57. case 1:
  58. that.waitPayShow()
  59. break
  60. case 2:
  61. that.lostShow()
  62. break
  63. }
  64. },
  65. alreadyShow: function(){
  66. this.setData({
  67. alreadyOrder: [{ name: "躍動體育運動俱樂部(圓明園店)", state: "交易成功", time: "2018-09-30 14:00-16:00", status: "已結束", url: "../../images/bad0.png", money: "132" }, { name: "躍動體育運動俱樂部(圓明園店)", state: "交易成功", time: "2018-10-12 18:00-20:00", status: "未開始", url: "../../images/bad3.jpg", money: "205" }]
  68. })
  69. },
  70. waitPayShow:function(){
  71. this.setData({
  72. waitPayOrder: [{ name: "躍動體育運動俱樂部(圓明園店)", state: "待付款", time: "2018-10-14 14:00-16:00", status: "未開始", url: "../../images/bad1.jpg", money: "186" }],
  73. })
  74. },
  75. lostShow: function () {
  76. this.setData({
  77. lostOrder: [{ name: "躍動體育運動俱樂部(圓明園店)", state: "已取消", time: "2018-10-4 10:00-12:00", status: "未開始", url: "../../images/bad1.jpg", money: "122" }],
  78. })
  79. },
  80. /**
  81. * 生命周期函數--監聽頁面顯示
  82. */
  83. onShow: function () {
  84. },
  85. /**
  86. * 生命周期函數--監聽頁面隱藏
  87. */
  88. onHide: function () {
  89. },
  90. /**
  91. * 生命周期函數--監聽頁面卸載
  92. */
  93. onUnload: function () {
  94. },
  95. /**
  96. * 頁面相關事件處理函數--監聽用戶下拉動作
  97. */
  98. onPullDownRefresh: function () {
  99. },
  100. /**
  101. * 頁面上拉觸底事件的處理函數
  102. */
  103. onReachBottom: function () {
  104. },
  105. /**
  106. * 用戶點擊右上角分享
  107. */
  108. onShareAppMessage: function () {
  109. }
  110. })

微信小程序訂單頁面