order.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <view class="container-view">
  3. <view class="order-type-view flex-row flex-between">
  4. <view class="car-model-list flex-row">
  5. <view class="car-model-text">小米Su5</view><img class="right-corner-icon" src="https://qiniu.bms16.com/Fqs6TrEmcdT7QNEdKWs9Hir2cacO" alt="">
  6. </view>
  7. <view class="order-package-type-view flex-row">
  8. <view
  9. v-for="(type, index) in orderTypes"
  10. :key="index"
  11. @tap="checkOrderType"
  12. :data-type="type.value"
  13. :class="['package-type-list', 'flex-row', {'package-type-list-i': selectOrderType === type.value}]"
  14. :style="{ marginRight: index === 0 ? '48rpx' : '' }"
  15. >
  16. <view class="package-type-text">{{ type.text }}</view>
  17. <img v-if="selectOrderType === type.value" class="right-button-icon" src="https://qiniu.bms16.com/FmcoAVgWvyK44iPjK0phkDRU21i0" alt="">
  18. </view>
  19. </view>
  20. </view>
  21. <view v-for="(item, index) in hireOrderList" :key="index" @tap="loadToNav" :data-orderSn="item.order_sn"
  22. class="order-card">
  23. <view class="card-top flex-row">
  24. <view>{{ item.car_model }}</view>
  25. <view class="card card-k" v-if="item.order_status == 0"></view>
  26. <view class="card card-k" v-else-if="item.order_status == 1">待取车</view>
  27. <view class="card card-k" v-else-if="item.order_status == 2">待激活</view>
  28. <view class="card card-b" v-else-if="item.order_status == 3">使用中</view>
  29. <view class="card card-r" v-else-if="item.order_status == 4">已逾期</view>
  30. <view class="card card-k" v-else-if="item.order_status == 5">还车申请中</view>
  31. <view class="card card-k" v-else-if="item.order_status == 6">还车中</view>
  32. <view class="card card-k" v-else-if="item.order_status == 7">车辆已归还</view>
  33. <view class="card card-k" v-else-if="item.order_status == 8 || item.order_status == 9">已取消</view>
  34. </view>
  35. <view class="card-border"></view>
  36. <view class="card-bottom">
  37. <view class="bottom-item">
  38. <view class="item-label-view flex-row">
  39. <view class="item-label">下单时间</view>
  40. <view class="item-value">{{ tools.formatTime(item.settle_date) }}</view>
  41. </view>
  42. <view class="item-label-view flex-row">
  43. <view class="item-label">有效期至</view>
  44. <view class="item-value"><view>
  45. {{ item.hire_duration_time.day > 0 ? item.hire_duration_time.day : '' }}<text
  46. v-if="item.hire_duration_time.day > 0">日</text>{{ item.hire_duration_time.hour > 0 ?
  47. item.hire_duration_time.hour : '' }}<text
  48. v-if="item.hire_duration_time.hour > 0">小时</text>{{ item.hire_duration_time.minute > 0 ?
  49. item.hire_duration_time.minute : '' }}<text
  50. v-if="item.hire_duration_time.minute > 0">分</text>
  51. </view></view>
  52. </view>
  53. <view class="item-label-view flex-row">
  54. <view class="item-label">有效时长</view>
  55. <view class="item-value">{{ tools.formatTime(item.settle_date) }}</view>
  56. </view>
  57. <view class="item-label-view flex-row">
  58. <view class="item-label">免费换电数</view>
  59. <view class="item-value">{{ tools.formatTime(item.settle_date) }}</view>
  60. </view>
  61. <view class="flex-row button-config-view">
  62. <view class="return-money">已退款</view>
  63. <view class="item-value">套餐金额$ <text class="money-style">5.0</text></view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </template>
  70. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  71. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  72. <script>
  73. var config = require('../../common/config.js');
  74. var common = require('../../common/common.js');
  75. var http = require('../../common/http.js');
  76. var storage = require('../../common/storage.js');
  77. export default {
  78. data() {
  79. return {
  80. selectOrderType:1,
  81. orderTypes: [
  82. { value: 0, text: '换电套餐' },
  83. { value: 1, text: '租车购车' }
  84. ],
  85. page: 1,
  86. limit: 10,
  87. status: '-1',
  88. sort_time: 0,
  89. sort_num: 0,
  90. hireOrderList: [],
  91. order_sn: '',
  92. myLocation: {
  93. latitude: null,
  94. longitude: null
  95. },
  96. orderInfoTime: {},
  97. nowTime: 0
  98. };
  99. }
  100. /**
  101. * 生命周期函数--监听页面加载
  102. */
  103. ,
  104. onLoad: function(options) {
  105. const locationStr = uni.getStorageSync('user_current_location');
  106. if (locationStr) {
  107. this.myLocation = locationStr;
  108. }
  109. let timestamp = Date.now();
  110. this.nowTime = Math.floor(timestamp / 1000);
  111. },
  112. /**
  113. * 生命周期函数--监听页面显示
  114. */
  115. onShow: function() {
  116. this.hireOrderList = []
  117. this.bindHireOrderList()
  118. },
  119. // 分享给好友
  120. onShareAppMessage: function(res) { //发送给朋友
  121. return {
  122. title: this.appConfig.app_name,
  123. path: 'pages/order/order',
  124. }
  125. },
  126. /**
  127. * 页面上拉触底事件的处理函数
  128. */
  129. onReachBottom: function() {
  130. this.page++
  131. this.bindHireOrderList()
  132. },
  133. /**
  134. * 页面下拉触底事件的处理函数
  135. */
  136. onPullDownRefresh() {
  137. this.page = 1
  138. this.bindHireOrderList()
  139. },
  140. methods: {
  141. bindHireOrderList() {
  142. const me = this
  143. http.postApi(config.API_FLK_ORDER_LIST, {
  144. page: me.page,
  145. limit: me.limit,
  146. // status: me.status,
  147. // sort_time: me.sort_time,
  148. // sort_num: me.sort_num
  149. }, (resp) => {
  150. if (resp.data.code === 200) {
  151. me.hireOrderList.push.apply(me.hireOrderList, resp.data.data.list)
  152. if (me.hireOrderList.length > 0) {
  153. me.sort_time = me.hireOrderList[me.hireOrderList.length - 1].ctime;
  154. me.sort_num = me.hireOrderList[me.hireOrderList.length - 1].sort_num;
  155. me.hireOrderList = me.hireOrderList.map(item => {
  156. item.order_time = common.getTimeToDay(Math.ceil(item.hire_end_time - me.nowTime)/60)
  157. item.hire_duration_time = common.getTimeToDay(Math.ceil(item.hire_end_time - item.hire_begin_time)/60)
  158. return item
  159. })
  160. }
  161. } else {
  162. common.simpleToast(resp.data.msg)
  163. }
  164. })
  165. },
  166. checkOrderType(e){
  167. const type = e.currentTarget.dataset.type;
  168. this.setData({
  169. selectOrderType:type
  170. })
  171. },
  172. navToPage(e) {
  173. const url = e.currentTarget.dataset.url;
  174. if (!url) {
  175. return;
  176. }
  177. uni.navigateTo({
  178. url: url
  179. });
  180. },
  181. loadToNav(e) {
  182. //#ifdef MP-ALIPAY
  183. this.order_sn = e.currentTarget.dataset.orderSn
  184. //#endif
  185. //#ifdef MP-WEIXIN
  186. this.order_sn = e.currentTarget.dataset.ordersn
  187. //#endif
  188. const isJumpReturn = false
  189. uni.navigateTo({
  190. url: '/pages/orderStatus/orderStatus?order_sn=' + this.order_sn + '&longitude=' + this
  191. .myLocation.longitude + '&latitude=' + this.myLocation.latitude +'&isJumpReturn=' + isJumpReturn,
  192. success: function(res) {},
  193. fail: function(res) {},
  194. complete: function(res) {},
  195. })
  196. },
  197. }
  198. };
  199. </script>
  200. <style>
  201. @import './order.css';
  202. </style>