order.vue 13 KB

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