purchaseOrder.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <view class="container-view">
  3. <view class="select-time-view">
  4. <view class="flex-row">选择取车时间</view>
  5. <view @tap="tapSelectTime" class="flex-row align-center" style="margin-bottom:20rpx ;">
  6. <text class="select-time-text">{{takeCar}}</text>
  7. <img style="width: 28rpx;height: 28rpx;" src="https://qiniu.bms16.com/FpbKGisSPfL9r8a7QkZCYXolhu1Y"
  8. alt="">
  9. </view>
  10. </view>
  11. <view class="car-info-view">
  12. <view class="flex-row align-center">
  13. <img style="width: 160rpx;height: 160rpx;border-radius: 16rpx;" :src="modelInfo.image" alt="">
  14. <view class="flex-row car-info-grow">
  15. <view class="flex-row align-center">
  16. <view class="car-name">{{modelInfo.car_model_name}}</view>
  17. <img style="width: 28rpx;height: 28rpx;"
  18. src="https://qiniu.bms16.com/FlMiRsUF-KZyevFCZDP9DwffOlag" alt="">
  19. </view>
  20. <view class="car-information">{{leaseUnitsResult}}
  21. 共计{{tools.countToDay(modelInfo.count,modelInfo.selectType)}}天</view>
  22. <allPrice v-if="modelInfo.selectType == 100" :amount="modelInfo.sell_price / 100"></allPrice>
  23. <allPrice v-else :amount="price"></allPrice>
  24. </view>
  25. </view>
  26. <view class="config-list-view">
  27. <view :class="service_list.length>4?'config-list-view-1 flex-row':'flex-row'">
  28. <view class="service_name-tab" v-for=" (item,indexs) in service_list" :key="indexs">
  29. {{item.service_name}}
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view v-if="modelInfo.selectType != 100" class="deposit-info">
  35. <view class="deposit-info-title flex-row flex-between">
  36. <text>车辆押金</text>
  37. <text>${{modelInfo.deposit/100}}</text>
  38. </view>
  39. <view class="deposit-info-text">需要支付{{modelInfo.deposit/100}}元押金,诺无车损、违章及逾期,还车后可退</view>
  40. </view>
  41. <view class="method-info">
  42. <view class="flex-row flex-between" style="margin-bottom: 40rpx;">
  43. <view class="font_32">前往门店取还</view>
  44. <view class="font_32">门店距您 <text class="distance-num">{{modelInfo.distance}}m</text></view>
  45. </view>
  46. <view @tap="navAddress" class="shop-bg flex-row flex-between">
  47. <view class="shop-name-view">
  48. <!-- <view class="shop-name">{{shopInfo.shop_name}}</view>
  49. <view class="shop-address">{{shopInfo.address}}</view> -->
  50. <view class="shop-name">{{modelInfo.shop_name}}</view>
  51. <view class="shop-address">{{modelInfo.address}}</view>
  52. </view>
  53. <view class="nav-btn flex-row">
  54. <img style="width: 48rpx;height: 48rpx;" src="https://zxappfile.bms16.com/zx_admin/cab_nav.png"
  55. alt="">
  56. <view style="margin-top: 12rpx;font-size: 24rpx;">导航</view>
  57. </view>
  58. </view>
  59. </view>
  60. <view style="height: 224rpx;"></view>
  61. <view v-if="!isShowDetail" class="payment-info">
  62. <view class="payment-bottom flex-row flex-between">
  63. <view style="margin-right: 20rpx;" class="bottom-left flex-row">
  64. <allPrice :amount="totalPrice"></allPrice>
  65. <view v-if="modelInfo.selectType != 100" @tap="bindDetail" class="all-money">明细<img
  66. src="https://qiniu.bms16.com/Fvl1d-AWRvwY_ehNrw7bMZOK6LBZ" /></view>
  67. </view>
  68. <view @tap="navToPage">确认下单</view>
  69. </view>
  70. </view>
  71. <view v-else class="show-detail">
  72. <view class="detail-info">
  73. <view class="pay-money">
  74. <view class="flex-row flex-between" style="margin-bottom: 46rpx;">
  75. <view>价格明细</view>
  76. <view>
  77. <image style="width: 32rpx;height: 32rpx;" @tap="isShowDetail = false"
  78. src="https://qiniu.bms16.com/FtoTEHOJiUf_gjPCJGGHMsAtHI5M" />
  79. </view>
  80. </view>
  81. <view class="flex-row flex-between" style="margin-bottom: 44rpx;">
  82. <view>车辆租金</view>
  83. <view>
  84. <!-- ¥{{(leaseTime * price_list[0].hire_price) /100}} -->
  85. ¥{{price+'x'+modelInfo.count}}
  86. <text>{{leaseUnits}}</text>
  87. </view>
  88. </view>
  89. <view class="flex-row flex-between" style="margin-bottom: 44rpx;">
  90. <view>车辆押金</view>
  91. <view>¥{{modelInfo.deposit /100}}</view>
  92. </view>
  93. <view class="detail-money flex-row" style="padding-bottom: 44rpx;">
  94. <view>支付金额</view>
  95. <allPrice :amount="totalPrice"></allPrice>
  96. </view>
  97. </view>
  98. <view class="second">
  99. <view class="payment-bottom flex-row flex-between">
  100. <view class="bottom-left flex-row">
  101. <allPrice :amount="totalPrice"></allPrice>
  102. <view @tap="isShowDetail = false" class="all-money">明细<img
  103. src="https://qiniu.bms16.com/FkzZI0r5jO-c2JRahNkZW2pHb9dR" /></view>
  104. </view>
  105. <view @tap="navToPage">确认下单</view>
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. <calendar ref="calendar" :showPopup.sync="isShowCalendar" @valuesUpdated="handleValuesUpdated"
  111. @close="() => isShowCalendar = false" />
  112. <view v-if="isShowReturnCar" class="return-box">
  113. <view class="return-item">
  114. <view class="return-title flex-row flex-between">
  115. <view>还车到门店</view>
  116. <view @tap="isShowReturnCar = false" class="close-view"><img style="width: 24rpx;height: 24rpx;"
  117. src="https://qiniu.bms16.com/FoWVlo-Nmx6wTDpsL2Rf9_BamU7L" alt=""></view>
  118. </view>
  119. <view class="return-text">系统会根据您的定位判断您是否已到还车位置,如您已经到达门店,请点击「我已到店」按钮,待门店确认还车后,即可还车成功。</view>
  120. <view class="return-btn flex-row">
  121. <view @tap="toRurnCarPage">导航到店</view>
  122. <view @tap="toNearbyStorePage">我已到店</view>
  123. </view>
  124. </view>
  125. </view>
  126. <view v-if="isShowCheckOrder" class="return-box">
  127. <view class="return-item">
  128. <view style="text-align: center;margin-bottom: 120rpx;">
  129. <img style="width: 88rpx;height: 88rpx;" src="https://qiniu.bms16.com/Fqb-i2uJWlZOg8EvUXHr_1qhlndf"
  130. alt="">
  131. <view class="check-order-text">租车订单已提交</view>
  132. <view>请于 <text class="get-car-time">{{takeCar}}</text> 到 <text
  133. class="get-car-name">{{modelInfo.shop_name}}</text> 取车</view>
  134. </view>
  135. <view class="return-btn flex-row">
  136. <view @tap="toIndexPage">我知道了</view>
  137. <view @tap="toOrderInfo">订单详情</view>
  138. </view>
  139. </view>
  140. </view>
  141. <PayTypeModel @closeShow="closeShow" @payToOrder="payToOrder" :free_price="Number(totalPrice)"
  142. :isShowToBuy="isShowToBuy" />
  143. </view>
  144. </template>
  145. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  146. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  147. <script>
  148. var config = require('../../common/config.js');
  149. var config_gyq = require('../../common/config_gyq.js');
  150. var common = require('../../common/common.js');
  151. var http = require('../../common/http.js');
  152. var request = require('../../common/request.js');
  153. var storage = require('../../common/storage.js');
  154. var user = require('../../common/user.js');
  155. import allPrice from '@/component/allPrice/allPrice';
  156. import calendar from '@/component/smartCalendar';
  157. import PayTypeModel from '@/component/payTypeModel/payTypeModel';
  158. import {
  159. MAX_LIMITS,
  160. LEASE_TYPE_ARR
  161. } from '@/common/constant.js';
  162. export default {
  163. components: {
  164. allPrice,
  165. calendar,
  166. PayTypeModel
  167. },
  168. data() {
  169. return {
  170. isShowReturnCar:false,
  171. isShowCheckOrder:false,
  172. sub_sn: "",
  173. service_list: [],
  174. isShowCalendar: false, //选择预约订单时间
  175. price: 0,
  176. modelInfo: {},
  177. isShowDetail: false,
  178. unitPrice: 0, //单价
  179. isShowToBuy: false,
  180. order_sn: '', //租赁订单号
  181. totalPrice: 0, //结算总金额
  182. };
  183. }
  184. /**
  185. * 生命周期函数--监听页面加载
  186. */
  187. ,
  188. onLoad: function(options) {
  189. if (options && options.params) {
  190. const model_info = JSON.parse(decodeURIComponent(options.params)) || {}
  191. console.log(model_info, 'model_info');
  192. this.setData({
  193. modelInfo: model_info,
  194. unitPrice: model_info.rental_setting.find(v => v.hire_duration_unit == model_info
  195. .selectType)?.hire_price,
  196. service_list: model_info.service_list || [],
  197. price: model_info.totalPrice / 100,
  198. totalPrice: model_info.select_type != 100 ? ((model_info.totalPrice + model_info.deposit) / 100).toFixed(2) : ((model_info.sell_price) / 100).toFixed(2)
  199. })
  200. }
  201. this.pick_up_time = Math.floor(new Date().getTime() / 1000)
  202. this.setData({
  203. takeCar: common.getFormattedTime()
  204. })
  205. },
  206. /**
  207. * 生命周期函数--监听页面显示
  208. */
  209. onShow: function() {},
  210. computed: {
  211. leaseUnitsResult() {
  212. const result = LEASE_TYPE_ARR.find(v => v.value == this.modelInfo.selectType);
  213. return result ? result.label : '';
  214. },
  215. leaseUnits() {
  216. const result = LEASE_TYPE_ARR.find(v => v.value == this.modelInfo.selectType);
  217. return result ? result.unit : '';
  218. },
  219. },
  220. methods: {
  221. handleValuesUpdated(e) {
  222. this.isShowCalendar = false;
  223. const timeStr = new Date(e.startDate)
  224. this.pick_up_time = Math.floor(new Date(e.startDate).getTime() / 1000)
  225. this.setData({
  226. takeCar: common.getFormattedTime(timeStr)
  227. })
  228. console.log(e, 'eeee');
  229. },
  230. tapSelectTime() {
  231. this.setData({
  232. isShowCalendar: true
  233. })
  234. },
  235. navAddress() {
  236. const {
  237. address,
  238. latitude,
  239. longitude,
  240. shop_name
  241. } = this.modelInfo
  242. uni.openLocation({
  243. latitude: latitude - 0,
  244. longitude: longitude - 0,
  245. scale: 15,
  246. name: shop_name,
  247. address: address,
  248. success: function(res) {},
  249. })
  250. },
  251. bindDetail() {
  252. this.isShowDetail = true
  253. },
  254. navToPage() {
  255. this.setData({
  256. isShowToBuy: true
  257. })
  258. },
  259. closeShow() {
  260. this.setData({
  261. isShowToBuy: false
  262. })
  263. },
  264. payToOrder(type) {
  265. const pay_type = type
  266. var from = ''
  267. if (pay_type == 1) {
  268. from = 'wx'
  269. } else if (pay_type == 2) {
  270. from = 'ali'
  271. }
  272. const hire_duration = this.modelInfo.rental_setting.find(v => v.hire_duration_unit == this.modelInfo
  273. .selectType)?.hire_duration
  274. console.log(this.modelInfo, 'test');
  275. const pData = {
  276. pay_type,
  277. car_model_id: this.modelInfo.model_id,
  278. hire_cycle: this.modelInfo.count,
  279. hire_duration_unit: this.modelInfo.selectType,
  280. hire_duration,
  281. price: this.totalPrice * 100,
  282. pick_up_time: this.pick_up_time,
  283. address: this.modelInfo.address,
  284. currency_code: 'CNY'
  285. }
  286. common.loading();
  287. if (this.modelInfo.selectType == 100) {
  288. this.loadPayBuy(pData)
  289. return
  290. }
  291. this.loadPayMethod(pData)
  292. },
  293. async loadPayBuy(pData) {
  294. let {
  295. data
  296. } = await request.postApi(config_gyq.API_FLK_ORDER_RESERVE, {
  297. pay_type: pData.pay_type,
  298. car_model_id: pData.car_model_id,
  299. price: this.modelInfo.sell_price,
  300. pick_up_time: pData.pick_up_time,
  301. currency_code: 'CNY',
  302. })
  303. uni.hideLoading();
  304. if (data.code == 200) {
  305. if (!data.data.need_pay) {
  306. common.simpleToast(this.$t('支付成功'));
  307. this.order_sn = data.data.order_sn;
  308. this.sub_sn = data.data.sub_sn;
  309. this.setData({
  310. isShowToBuy: false,
  311. isShowCheckOrder: true
  312. })
  313. }
  314. } else {
  315. common.simpleToast(data.msg);
  316. }
  317. },
  318. loadPayMethod(pData) {
  319. const me = this;
  320. http.postApi(config.API_FLK_ORDER_HIRE_MODEL, pData, function(resp) {
  321. uni.hideLoading();
  322. if (resp.data.code === 200) {
  323. if (!resp.data.data.need_pay) {
  324. common.simpleToast(me, me.$t('支付成功'));
  325. me.order_sn = resp.data.data.order_sn;
  326. me.sub_sn = resp.data.data.sub_sn;
  327. me.setData({
  328. isShowToBuy: false,
  329. isShowCheckOrder: true
  330. })
  331. }
  332. } else {
  333. common.simpleToast(me, resp.data.msg);
  334. }
  335. });
  336. },
  337. toIndexPage() {
  338. uni.switchTab({
  339. url: '/pages/index/index'
  340. })
  341. },
  342. toOrderInfo() {
  343. uni.navigateTo({
  344. url: '/pages/orderStatus/orderStatus?sub_sn=' + this.sub_sn
  345. })
  346. }
  347. }
  348. };
  349. </script>
  350. <style>
  351. @import './purchaseOrder.css';
  352. </style>