purchaseOrder.vue 12 KB

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