order.vue 11 KB

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