order.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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-order_sn="item.order_sn"
  22. class="order-card">
  23. <view class="card-top flex-row">
  24. <view>{{ item.car_model }}</view>
  25. <view v-if="item.pay_status==2">
  26. <view class="card card-k" v-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 ">订单已支付,已取消</view>
  34. <view class="card card-k" v-else-if=" item.order_status == 9">订单未支付,已取消</view>
  35. </view>
  36. <view v-if="item.pay_status!=2">
  37. <view class="card card-k" v-if="item.pay_status == 0">待支付</view>
  38. <view class="card card-k" v-else-if="item.pay_status == 1">支付中</view>
  39. <view class="card card-r" v-else-if="item.pay_status == 3">支付失败</view>
  40. <view class="card card-k" v-else-if="item.pay_status == 4">支付取消</view>
  41. <view class="card card-b" v-else-if="item.pay_status == 5">线下待审核</view>
  42. <view class="card card-k" v-else-if="item.pay_status == 6">线下审核拒绝</view>
  43. </view>
  44. </view>
  45. <view class="card-border"></view>
  46. <view class="card-bottom">
  47. <view class="bottom-item">
  48. <view class="item-label-view flex-row">
  49. <view class="item-label">下单时间</view>
  50. <view class="item-value">{{ tools.formatTime(item.pay_time) }}</view>
  51. </view>
  52. <view class="item-label-view flex-row">
  53. <view class="item-label">有效期至</view>
  54. <view class="item-value">{{ tools.formatTime(item.hire_end_time) }}</view>
  55. </view>
  56. <view class="item-label-view flex-row">
  57. <view class="item-label">有效时长</view>
  58. <view class="item-value"><view>
  59. {{ item.hire_duration_time.day > 0 ? item.hire_duration_time.day : '' }}<text
  60. v-if="item.hire_duration_time.day > 0">日</text>{{ item.hire_duration_time.hour > 0 ?
  61. item.hire_duration_time.hour : '' }}<text
  62. v-if="item.hire_duration_time.hour > 0">小时</text>{{ item.hire_duration_time.minute > 0 ?
  63. item.hire_duration_time.minute : '' }}<text
  64. v-if="item.hire_duration_time.minute > 0">分</text>
  65. </view></view>
  66. </view>
  67. <view v-if="selectOrderType==1" class="item-label-view flex-row">
  68. <view class="item-label">订单类型</view>
  69. <view class="item-value">{{ item.order_type==3?'购车':'租车' }}</view>
  70. </view>
  71. <view v-if="selectOrderType==0" class="item-label-view flex-row">
  72. <view class="item-label">免费换电数</view>
  73. <view class="item-value">{{ tools.formatTime(item.settle_date) }}</view>
  74. </view>
  75. <view v-if="selectOrderType==0" class="flex-row button-config-view">
  76. <view class="return-money">已退款</view>
  77. <view class="item-value">套餐金额$ <text class="money-style">5.0</text></view>
  78. </view>
  79. <view v-if="selectOrderType==1" class="flex-row button-config-view">
  80. <view class="order-money">订单金额 $ 5.0</view>
  81. <view @tap="activateCar" :data-sub_sn="item.sub_sn" class="activation-btn">激活车辆</view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </template>
  88. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  89. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  90. <script>
  91. var config = require('../../common/config.js');
  92. var common = require('../../common/common.js');
  93. var http = require('../../common/http.js');
  94. var storage = require('../../common/storage.js');
  95. export default {
  96. data() {
  97. return {
  98. selectOrderType:1,
  99. orderTypes: [
  100. { value: 0, text: '换电套餐' },
  101. { value: 1, text: '租车购车' }
  102. ],
  103. page: 1,
  104. limit: 10,
  105. status: '-1',
  106. sort_time: 0,
  107. sort_num: 0,
  108. hireOrderList: [],
  109. order_sn: '',
  110. myLocation: {
  111. latitude: null,
  112. longitude: null
  113. },
  114. orderInfoTime: {},
  115. nowTime: 0
  116. };
  117. }
  118. /**
  119. * 生命周期函数--监听页面加载
  120. */
  121. ,
  122. onLoad: function(options) {
  123. const locationStr = uni.getStorageSync('user_current_location');
  124. if (locationStr) {
  125. this.myLocation = locationStr;
  126. }
  127. let timestamp = Date.now();
  128. this.nowTime = Math.floor(timestamp / 1000);
  129. },
  130. /**
  131. * 生命周期函数--监听页面显示
  132. */
  133. onShow: function() {
  134. this.hireOrderList = []
  135. this.bindHireOrderList()
  136. },
  137. // 分享给好友
  138. onShareAppMessage: function(res) { //发送给朋友
  139. return {
  140. title: this.appConfig.app_name,
  141. path: 'pages/order/order',
  142. }
  143. },
  144. /**
  145. * 页面上拉触底事件的处理函数
  146. */
  147. onReachBottom: function() {
  148. this.page++
  149. this.bindHireOrderList()
  150. },
  151. /**
  152. * 页面下拉触底事件的处理函数
  153. */
  154. onPullDownRefresh() {
  155. this.page = 1
  156. this.bindHireOrderList()
  157. },
  158. methods: {
  159. bindHireOrderList() {
  160. const me = this
  161. http.postApi(config.API_FLK_ORDER_LIST, {
  162. page: me.page,
  163. limit: me.limit,
  164. // status: me.status,
  165. // sort_time: me.sort_time,
  166. // sort_num: me.sort_num
  167. }, (resp) => {
  168. if (resp.data.code === 200) {
  169. me.hireOrderList.push.apply(me.hireOrderList, resp.data.data.list)
  170. if (me.hireOrderList.length > 0) {
  171. me.sort_time = me.hireOrderList[me.hireOrderList.length - 1].ctime;
  172. me.sort_num = me.hireOrderList[me.hireOrderList.length - 1].sort_num;
  173. me.hireOrderList = me.hireOrderList.map(item => {
  174. item.order_time = common.getTimeToDay(Math.ceil(item.hire_end_time - me.nowTime)/60)
  175. item.hire_duration_time = common.getTimeToDay(Math.ceil(item.hire_end_time - item.hire_begin_time)/60)
  176. return item
  177. })
  178. }
  179. } else {
  180. common.simpleToast(resp.data.msg)
  181. }
  182. })
  183. },
  184. checkOrderType(e){
  185. const type = e.currentTarget.dataset.type;
  186. this.setData({
  187. selectOrderType:type
  188. })
  189. },
  190. navToPage(e) {
  191. const url = e.currentTarget.dataset.url;
  192. if (!url) {
  193. return;
  194. }
  195. uni.navigateTo({
  196. url: url
  197. });
  198. },
  199. loadToNav(e) {
  200. this.order_sn = e.currentTarget.dataset.order_sn
  201. const isJumpReturn = false
  202. uni.navigateTo({
  203. url: '/pages/orderStatus/orderStatus?order_sn=' + this.order_sn + '&longitude=' + this
  204. .myLocation.longitude + '&latitude=' + this.myLocation.latitude +'&isJumpReturn=' + isJumpReturn,
  205. success: function(res) {},
  206. fail: function(res) {},
  207. complete: function(res) {},
  208. })
  209. },
  210. activateCar(e){
  211. const sub_sn = e.currentTarget.dataset.sub_sn
  212. uni.navigateTo({
  213. url: '/pages/activation/activation?order_sn=' + sub_sn
  214. })
  215. // uni.scanCode({
  216. // onlyFromCamera: true,
  217. // success: function (res) {
  218. // uni.navigateTo({
  219. // url: '/pages/activation/activation?order_sn=' + sub_sn
  220. // })
  221. // },
  222. // fail: function (res) { },
  223. // complete: function (res) { },
  224. // })
  225. }
  226. }
  227. };
  228. </script>
  229. <style>
  230. @import './order.css';
  231. </style>