order.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template>
  2. <view class="container-view">
  3. <navBar :name="$t('我的订单')" ></navBar>
  4. <!-- <view v-if="selectOrderType == 0" class="order-type-view flex-row flex-between">
  5. <view v-if="car_info.car_sn && selectOrderType == 0" @click="srcFn(`/pages/carList/carList`)" class="car-model-list flex-row">
  6. <view class="car-model-text">{{car_info.car_name}}</view><img class="right-corner-icon"
  7. src="https://qiniu.bms16.com/Fqs6TrEmcdT7QNEdKWs9Hir2cacO" alt="">
  8. </view>
  9. <view v-else></view>
  10. <view class="order-package-type-view flex-row">
  11. <view v-for="(type, index) in orderTypes" :key="index" @tap="checkOrderType" :data-type="type.value"
  12. :class="['package-type-list', 'flex-row', {'package-type-list-i': selectOrderType === type.value}]"
  13. :style="{ marginRight: index === 0 ? '48rpx' : '' }">
  14. <view class="package-type-text">{{ type.text }}</view>
  15. <img v-if="selectOrderType === type.value" class="right-button-icon"
  16. src="https://qiniu.bms16.com/FmcoAVgWvyK44iPjK0phkDRU21i0" alt="">
  17. </view>
  18. </view>
  19. </view> -->
  20. <view class="order-type-view flex-row flex-between">
  21. <view style="justify-content: space-around;width: 100%;" class="order-package-type-view flex-row">
  22. <view style="width: 128rpx;" v-for="(type, index) in orderTypes" :key="index" @tap="checkOrderType" :data-type="type.value"
  23. :class="['package-type-list', 'flex-row', {'package-type-list-i': selectOrderType === type.value}]"
  24. >
  25. <view class="package-type-text">{{ type.text }}</view>
  26. <img v-if="selectOrderType === type.value" class="right-button-icon"
  27. src="https://qiniu.bms16.com/FmcoAVgWvyK44iPjK0phkDRU21i0" alt="">
  28. </view>
  29. </view>
  30. </view>
  31. <view v-for="(item, index) of hireOrderList" :key="index" @tap="loadToNav" :data-sub_sn="item.sub_sn"
  32. class="order-card">
  33. <view class="card-top flex-row">
  34. <view v-if="selectOrderType == 1">{{ item.car_name }}</view>
  35. <block v-if="selectOrderType == 0">
  36. <view v-if="item.package_type == 1">
  37. {{item.total_day}}{{ $t('天') }}
  38. </view>
  39. <view v-if="item.package_type == 2">
  40. {{item.num}}{{ $t('次') }}
  41. </view>
  42. <view v-if="item.package_type == 3">
  43. {{item.total_day}}{{ $t('天') }}{{item.num}}{{ $t('次') }}
  44. </view>
  45. </block>
  46. <view v-if="item.finally == 1 && selectOrderType == 1">
  47. <view class="card card-k" v-if="item.order_status == 0">{{ $t('待支付') }}</view>
  48. <view class="card card-k" v-if="item.order_status == 1">{{ $t('待取车') }}</view>
  49. <view class="card card-k" v-else-if="item.order_status == 2">{{ $t('待激活') }}</view>
  50. <view class="card card-b" v-else-if="item.order_status == 3">{{ $t('使用中') }}</view>
  51. <view class="card card-r" v-else-if="item.order_status == 4">{{ $t('已逾期') }}</view>
  52. <view class="card card-k" v-else-if="item.order_status == 5">{{ $t('还车申请中') }}</view>
  53. <view class="card card-k" v-else-if="item.order_status == 6">{{ $t('还车中') }}</view>
  54. <view class="card card-k" v-else-if="item.order_status == 7">{{ $t('车辆已归还') }}</view>
  55. <view class="card card-k" v-else-if="item.order_status == 8 ">{{ $t('订单已支付') }},{{ $t('已取消') }}</view>
  56. <view class="card card-k" v-else-if=" item.order_status == 9">{{ $t('订单未支付') }},{{ $t('已取消') }}</view>
  57. <view class="card card-k" v-else-if=" item.order_status == 10">{{ $t('已完结') }}</view>
  58. </view>
  59. <view v-if="item.finally != 1 && selectOrderType == 1">
  60. <view class="card card-k" v-if="item.pay_status == 0">{{ $t('待支付') }}</view>
  61. <view class="card card-k" v-else-if="item.pay_status == 1">{{ $t('支付中') }}</view>
  62. <view class="card card-k" v-else-if="item.pay_status == 2">{{ $t('支付成功') }}</view>
  63. <view class="card card-r" v-else-if="item.pay_status == 3">{{ $t('支付失败') }}</view>
  64. <view class="card card-k" v-else-if="item.pay_status == 4">{{ $t('支付取消') }}</view>
  65. <view class="card card-b" v-else-if="item.pay_status == 5">{{ $t('线下待审核') }}</view>
  66. <view class="card card-k" v-else-if="item.pay_status == 6">{{ $t('线下审核拒绝') }}</view>
  67. </view>
  68. <view v-if="selectOrderType == 0">
  69. <view class="card card-k" v-if="item.pay_status == 0">{{ $t('待支付') }}</view>
  70. <view class="card card-k" v-else-if="item.pay_status == 1">{{ $t('支付中') }}</view>
  71. <view class="card card-k" v-else-if="item.pay_status == 2">{{ $t('支付成功') }}</view>
  72. <view class="card card-r" v-else-if="item.pay_status == 3">{{ $t('支付失败') }}</view>
  73. <view class="card card-k" v-else-if="item.pay_status == 4">{{ $t('支付取消') }}</view>
  74. <view class="card card-b" v-else-if="item.pay_status == 5">{{ $t('线下待审核') }}</view>
  75. <view class="card card-k" v-else-if="item.pay_status == 6">{{ $t('线下审核拒绝') }}</view>
  76. </view>
  77. </view>
  78. <view class="card-border"></view>
  79. <view class="card-bottom">
  80. <view class="bottom-item">
  81. <block v-if="selectOrderType == 1">
  82. <view class="item-label-view flex-row">
  83. <view class="item-label">{{ $t('订单编号') }}</view>
  84. <view class="item-value">{{ item.sub_sn }}</view>
  85. </view>
  86. <view class="item-label-view flex-row">
  87. <view class="item-label">{{ $t('下单时间') }}</view>
  88. <view class="item-value">{{ tools.formatTime(item.ctime) }}</view>
  89. </view>
  90. <view v-if="item.hire_end_time && item.order_type != 3" class="item-label-view flex-row">
  91. <view class="item-label">{{ $t('有效期至') }}</view>
  92. <view class="item-value">{{ tools.formatTime(item.hire_end_time) }}</view>
  93. </view>
  94. <view v-if="item.hire_duration_time && item.order_type != 3" class="item-label-view flex-row">
  95. <view class="item-label">{{ $t('有效时长') }}</view>
  96. <view class="item-value">
  97. {{ item.hire_duration_time.day > 0 ? item.hire_duration_time.day : '' }}<text
  98. v-if="item.hire_duration_time.day > 0">{{ $t('日') }}</text>{{ item.hire_duration_time.hour > 0 ?
  99. item.hire_duration_time.hour : '' }}<text v-if="item.hire_duration_time.hour > 0">{{ $t('小时') }}</text>{{ item.hire_duration_time.minute > 0 ?
  100. item.hire_duration_time.minute : '' }}<text v-if="item.hire_duration_time.minute > 0">{{ $t('分') }}</text>
  101. </view>
  102. </view>
  103. </block>
  104. <block v-if="selectOrderType == 0">
  105. <view class="item-label-view flex-row">
  106. <view class="item-label">{{ $t('下单时间') }}</view>
  107. <view class="item-value">{{ tools.formatTime(item.ctime) }}</view>
  108. </view>
  109. <view v-if="item.expire_time" class="item-label-view flex-row">
  110. <view class="item-label">{{ $t('有效期至') }}</view>
  111. <view class="item-value">{{ tools.formatTime(item.expire_time) }}</view>
  112. </view>
  113. <view v-if="item.package_type != 2 && item.expire_time" class="item-label-view flex-row">
  114. <view class="item-label">{{ $t('有效时长') }}</view>
  115. <view class="item-value">
  116. {{calculateRemainingDays(item.expire_time)}}<text
  117. style="color: #9FA7B7;">/{{item.total_day}}{{ $t('天') }}</text>
  118. </view>
  119. </view>
  120. <view v-if="item.package_type == 1" class="item-label-view flex-row">
  121. <view class="item-label">{{ $t('免费换电数') }}</view>
  122. <!-- <view class="item-value">{{item.last_num}}{{ $t('次') }}</view> -->
  123. <view class="item-value">{{ $t('不限次数') }}</view>
  124. </view>
  125. <view v-if="item.package_type == 2" class="item-label-view flex-row">
  126. <view class="item-label">{{ $t('免费换电数') }}</view>
  127. <view class="item-value">{{item.last_num}}/{{item.num}}{{ $t('次') }}</view>
  128. </view>
  129. <view v-if="item.package_type == 3" class="item-label-view flex-row">
  130. <view class="item-label">{{ $t('免费换电数') }}</view>
  131. <view class="item-value">{{item.total_day}}{{ $t('天') }}/{{item.last_num}}{{ $t('次') }}</view>
  132. </view>
  133. </block>
  134. <view v-if="selectOrderType==1" class="item-label-view flex-row">
  135. <view class="item-label">{{ $t('订单类型') }}</view>
  136. <view class="item-value">{{ item.order_type==3?$t('购车'):$t('租车') }}</view>
  137. </view>
  138. <view v-if="selectOrderType==0" class="flex-row button-config-view">
  139. <view v-if="item.order_refund_status == 1" class="return-money">{{ $t('申请中') }}</view>
  140. <view v-if="item.order_refund_status == 2" class="return-money">{{ $t('审核失败') }}</view>
  141. <view v-if="item.order_refund_status == 3" class="return-money">{{ $t('退款失败') }}</view>
  142. <view v-if="item.order_refund_status == 4" class="return-money">{{ $t('已退款') }}</view>
  143. <view class="item-value">{{ $t('套餐金额') }}$ <text
  144. class="money-style">{{(item.package_money / 100).toFixed(2)}}</text></view>
  145. </view>
  146. <view v-if="selectOrderType==1" class="flex-row button-config-view">
  147. <view class="order-money">{{ $t('订单金额') }} $ {{(item.money / 100).toFixed(2)}}</view>
  148. <view v-if="item.order_status == 2" class="activation-btn">{{ $t('激活车辆') }}</view>
  149. </view>
  150. </view>
  151. </view>
  152. </view>
  153. </view>
  154. </template>
  155. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  156. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  157. <script>
  158. var config = require('../../common/config.js');
  159. var config_gyq = require('../../common/config_gyq.js');
  160. var common = require('../../common/common.js');
  161. var http = require('../../common/http.js');
  162. var request = require('../../common/request');
  163. var storage = require('../../common/storage.js');
  164. const dayjs = require('dayjs');
  165. import {
  166. getRemainingTime
  167. } from '../../utils/util.js';
  168. export default {
  169. data() {
  170. return {
  171. is_next: 0,
  172. car_info: {},
  173. selectOrderType: 1,
  174. orderTypes: [{
  175. value: 0,
  176. text: this.$t('换电套餐')
  177. },
  178. {
  179. value: 1,
  180. text: this.$t('租车购车')
  181. }
  182. ],
  183. start_id:0,
  184. page: 1,
  185. limit: 10,
  186. status: '-1',
  187. sort_time: 0,
  188. sort_num: 0,
  189. hireOrderList: [],
  190. order_sn: '',
  191. myLocation: {
  192. latitude: null,
  193. longitude: null
  194. },
  195. orderInfoTime: {},
  196. nowTime: 0
  197. };
  198. },
  199. /**
  200. * 生命周期函数--监听页面加载
  201. */
  202. onLoad: function(options) {
  203. this.selectOrderType = options.selectOrderType == 0 ? 0 : 1
  204. const locationStr = uni.getStorageSync('user_current_location');
  205. if (locationStr) {
  206. this.myLocation = locationStr;
  207. }
  208. let timestamp = Date.now();
  209. this.nowTime = Math.floor(timestamp / 1000);
  210. },
  211. /**
  212. * 生命周期函数--监听页面显示
  213. */
  214. onShow: function() {
  215. this.car_info = uni.getStorageSync('car_info') || {};
  216. this.page = 1
  217. this.start_id = 0
  218. this.hireOrderList = []
  219. setTimeout(()=> {
  220. if(this.selectOrderType == 1){
  221. this.bindHireOrderList()
  222. }else{
  223. this.bindExchangeOrderFn()
  224. }
  225. }, 300);
  226. },
  227. // 分享给好友
  228. onShareAppMessage: function(res) { //发送给朋友
  229. return {
  230. title: this.appConfig.app_name,
  231. path: 'pages/order/order',
  232. }
  233. },
  234. /**
  235. * 页面上拉触底事件的处理函数
  236. */
  237. onReachBottom: function() {
  238. if (!this.is_next) return
  239. this.page++
  240. if (this.selectOrderType == 0) {
  241. this.bindExchangeOrderFn()
  242. } else if (this.selectOrderType == 1) {
  243. this.bindHireOrderList()
  244. }
  245. },
  246. /**
  247. * 页面下拉触底事件的处理函数
  248. */
  249. onPullDownRefresh() {
  250. this.start_id
  251. if (this.selectOrderType == 0) {
  252. this.bindExchangeOrderFn()
  253. } else if (this.selectOrderType == 1) {
  254. this.bindHireOrderList()
  255. }
  256. },
  257. methods: {
  258. srcFn(url) {
  259. uni.navigateTo({
  260. url,
  261. })
  262. },
  263. calculateRemainingDays(expirationDate) {
  264. // 获取当前时间
  265. const now = dayjs();
  266. // 解析到期时间
  267. const endDate = dayjs(expirationDate * 1000);
  268. // 计算剩余天数
  269. const remainingDays = endDate.diff(now, 'day');
  270. return remainingDays || 1;
  271. },
  272. //dayjs
  273. validDurationFn(start, end) {
  274. return getRemainingTime(start, end)
  275. },
  276. async bindExchangeOrderFn() {
  277. let me = this
  278. let {
  279. data
  280. } = await request.postApi(config_gyq.API_FLK_EXCHANGE_PACKAGE_ORDER_LIST, {
  281. pay_status: -1,
  282. car_sn: '',
  283. start_id:me.start_id,
  284. page: this.page,
  285. limit: this.limit,
  286. })
  287. if (data.code == 200) {
  288. me.start_id = data.data.start_id
  289. this.hireOrderList.push.apply(this.hireOrderList, data.data.list)
  290. this.is_next = data.data.is_next
  291. } else {
  292. common.simpleToast(data.msg)
  293. }
  294. },
  295. bindHireOrderList() {
  296. const me = this
  297. http.postApi(config.API_FLK_ORDER_LIST, {
  298. page: me.page,
  299. limit: me.limit,
  300. start_id:me.start_id,
  301. // status: me.status,
  302. // sort_time: me.sort_time,
  303. // sort_num: me.sort_num
  304. }, (resp) => {
  305. if (resp.data.code === 200) {
  306. me.start_id = resp.data.data.start_id
  307. me.hireOrderList.push.apply(me.hireOrderList, resp.data.data.list)
  308. me.is_next = resp.data.data.is_next
  309. if (me.hireOrderList.length > 0) {
  310. me.sort_time = me.hireOrderList[me.hireOrderList.length - 1].ctime;
  311. me.sort_num = me.hireOrderList[me.hireOrderList.length - 1].sort_num;
  312. me.hireOrderList = me.hireOrderList.map(item => {
  313. item.order_time = common.getTimeToDay(Math.ceil(item.hire_end_time - me
  314. .nowTime) / 60)
  315. item.hire_duration_time = common.getTimeToDay(Math.ceil(item
  316. .hire_end_time - item.hire_begin_time) / 60)
  317. return item
  318. })
  319. }
  320. } else {
  321. common.simpleToast(resp.data.msg)
  322. }
  323. })
  324. },
  325. checkOrderType(e) {
  326. this.start_id = 0
  327. const type = e.currentTarget.dataset.type;
  328. this.setData({
  329. selectOrderType: type
  330. })
  331. this.hireOrderList = []
  332. if (type == 0) {
  333. this.page = 1
  334. this.bindExchangeOrderFn()
  335. } else if (type == 1) {
  336. this.page = 1
  337. this.bindHireOrderList()
  338. }
  339. },
  340. navToPage(e) {
  341. const url = e.currentTarget.dataset.url;
  342. if (!url) {
  343. return;
  344. }
  345. uni.navigateTo({
  346. url: url
  347. });
  348. },
  349. loadToNav(e) {
  350. if (this.selectOrderType == 0) {
  351. return
  352. }
  353. const sub_sn = e.currentTarget.dataset.sub_sn
  354. const isJumpReturn = false
  355. uni.navigateTo({
  356. url: '/pages/orderStatus/orderStatus?sub_sn=' + sub_sn,
  357. })
  358. },
  359. async activateCar(e) {
  360. let car_sn = e.currentTarget.dataset.car_sn || ''
  361. let model_id = e.currentTarget.dataset.model_id || ''
  362. if (!car_sn) {
  363. let res = await uni.scanCode({
  364. onlyFromCamera: true,
  365. scanType: [],
  366. });
  367. if (res[0]) return
  368. car_sn = res[1].result
  369. }
  370. uni.navigateTo({
  371. url: `/pages/activation/activation?model_id=${this.orderInfo.model_id}&sub_sn=${this.sub_sn}&car_sn=${car_sn}`
  372. })
  373. // uni.scanCode({
  374. // onlyFromCamera: true,
  375. // success: function (res) {
  376. // uni.navigateTo({
  377. // url: '/pages/activation/activation?sub_sn=' + sub_sn
  378. // })
  379. // },
  380. // fail: function (res) { },
  381. // complete: function (res) { },
  382. // })
  383. }
  384. }
  385. };
  386. </script>
  387. <style>
  388. @import './order.css';
  389. </style>