order.vue 13 KB

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