purchaseOrder.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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}}</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">明细
  66. <image class="img" src="https://qiniu.bms16.com/Fvl1d-AWRvwY_ehNrw7bMZOK6LBZ" mode=""></image>
  67. </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 style="margin-right: 20rpx;">支付金额</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 style="margin-right: 20rpx;" class="bottom-left flex-row">
  102. <allPrice :amount="totalPrice"></allPrice>
  103. <view @tap="isShowDetail = false" class="all-money">明细
  104. <image class="img" src="https://qiniu.bms16.com/FkzZI0r5jO-c2JRahNkZW2pHb9dR" mode=""></image>
  105. </view>
  106. </view>
  107. <view @tap="navToPage">确认下单</view>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. <calendar ref="calendar" :showPopup.sync="isShowCalendar" @valuesUpdated="handleValuesUpdated"
  113. @close="() => isShowCalendar = false" />
  114. <view v-if="isShowReturnCar" class="return-box">
  115. <view class="return-item">
  116. <view class="return-title flex-row flex-between">
  117. <view>还车到门店</view>
  118. <view @tap="isShowReturnCar = false" class="close-view"><img style="width: 24rpx;height: 24rpx;"
  119. src="https://qiniu.bms16.com/FoWVlo-Nmx6wTDpsL2Rf9_BamU7L" alt=""></view>
  120. </view>
  121. <view class="return-text">系统会根据您的定位判断您是否已到还车位置,如您已经到达门店,请点击「我已到店」按钮,待门店确认还车后,即可还车成功。</view>
  122. <view class="return-btn flex-row">
  123. <view @tap="toRurnCarPage">导航到店</view>
  124. <view @tap="toNearbyStorePage">我已到店</view>
  125. </view>
  126. </view>
  127. </view>
  128. <view v-if="isShowCheckOrder" class="return-box">
  129. <view class="return-item">
  130. <view style="text-align: center;margin-bottom: 120rpx;">
  131. <img style="width: 88rpx;height: 88rpx;" src="https://qiniu.bms16.com/Fqb-i2uJWlZOg8EvUXHr_1qhlndf"
  132. alt="">
  133. <view class="check-order-text">租车订单已提交</view>
  134. <view>请于 <text class="get-car-time">{{takeCar}}</text> 到 <text
  135. class="get-car-name">{{modelInfo.shop_name}}</text> 取车</view>
  136. </view>
  137. <view class="return-btn flex-row">
  138. <view @tap="toIndexPage">我知道了</view>
  139. <view @tap="toOrderInfo">订单详情</view>
  140. </view>
  141. </view>
  142. </view>
  143. <PayTypeModel @closeShow="closeShow" @payToOrder="payToOrder" :free_price="Number(totalPrice) * 100"
  144. :isShowToBuy="isShowToBuy" />
  145. </view>
  146. </template>
  147. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  148. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  149. <script>
  150. var config = require('../../common/config.js');
  151. var config_gyq = require('../../common/config_gyq.js');
  152. var common = require('../../common/common.js');
  153. var http = require('../../common/http.js');
  154. var request = require('../../common/request.js');
  155. var storage = require('../../common/storage.js');
  156. var user = require('../../common/user.js');
  157. import allPrice from '@/component/allPrice/allPrice';
  158. import calendar from '@/component/smartCalendar';
  159. import PayTypeModel from '@/component/payTypeModel/payTypeModel';
  160. import {
  161. MAX_LIMITS,
  162. LEASE_TYPE_ARR
  163. } from '@/common/constant.js';
  164. export default {
  165. components: {
  166. allPrice,
  167. calendar,
  168. PayTypeModel
  169. },
  170. data() {
  171. return {
  172. isShowReturnCar:false,
  173. isShowCheckOrder:false,
  174. sub_sn: "",
  175. service_list: [],
  176. isShowCalendar: false, //选择预约订单时间
  177. price: 0,
  178. modelInfo: {},
  179. isShowDetail: false,
  180. unitPrice: 0, //单价
  181. isShowToBuy: false,
  182. order_sn: '', //租赁订单号
  183. totalPrice: 0, //结算总金额
  184. };
  185. }
  186. /**
  187. * 生命周期函数--监听页面加载
  188. */
  189. ,
  190. onLoad: function(options) {
  191. if (options && options.params) {
  192. const model_info = JSON.parse(decodeURIComponent(options.params)) || {}
  193. console.log(model_info, 'model_info');
  194. this.setData({
  195. modelInfo: model_info,
  196. unitPrice: model_info.rental_setting.find(v => v.hire_duration_unit == model_info
  197. .selectType)?.hire_price,
  198. service_list: model_info.service_list || [],
  199. price: model_info.totalPrice / 100,
  200. totalPrice: model_info.select_type != 100 ? ((model_info.totalPrice + model_info.deposit) / 100).toFixed(2) : ((model_info.sell_price) / 100).toFixed(2)
  201. })
  202. }
  203. this.pick_up_time = Math.floor(new Date().getTime() / 1000)
  204. this.setData({
  205. takeCar: common.getFormattedTime()
  206. })
  207. },
  208. /**
  209. * 生命周期函数--监听页面显示
  210. */
  211. onShow: function() {},
  212. computed: {
  213. leaseUnitsResult() {
  214. const result = LEASE_TYPE_ARR.find(v => v.value == this.modelInfo.selectType);
  215. return result ? result.label : '';
  216. },
  217. leaseUnits() {
  218. const result = LEASE_TYPE_ARR.find(v => v.value == this.modelInfo.selectType);
  219. return result ? result.unit : '';
  220. },
  221. },
  222. methods: {
  223. handleValuesUpdated(e) {
  224. this.isShowCalendar = false;
  225. const timeStr = new Date(e.startDate)
  226. this.pick_up_time = Math.floor(new Date(e.startDate).getTime() / 1000)
  227. this.setData({
  228. takeCar: common.getFormattedTime(timeStr)
  229. })
  230. console.log(e, 'eeee');
  231. },
  232. tapSelectTime() {
  233. this.setData({
  234. isShowCalendar: true
  235. })
  236. },
  237. navAddress() {
  238. const {
  239. address,
  240. latitude,
  241. longitude,
  242. shop_name
  243. } = this.modelInfo
  244. uni.openLocation({
  245. latitude: latitude - 0,
  246. longitude: longitude - 0,
  247. scale: 15,
  248. name: shop_name,
  249. address: address,
  250. success: function(res) {},
  251. })
  252. },
  253. bindDetail() {
  254. this.isShowDetail = true
  255. },
  256. navToPage() {
  257. this.setData({
  258. isShowToBuy: true
  259. })
  260. },
  261. closeShow() {
  262. this.setData({
  263. isShowToBuy: false
  264. })
  265. },
  266. payToOrder(type) {
  267. const pay_type = type
  268. var from = ''
  269. if (pay_type == 1) {
  270. from = 'wx'
  271. } else if (pay_type == 2) {
  272. from = 'ali'
  273. }
  274. const hire_duration = this.modelInfo.rental_setting.find(v => v.hire_duration_unit == this.modelInfo
  275. .selectType)?.hire_duration
  276. console.log(this.modelInfo, 'test');
  277. const pData = {
  278. pay_type,
  279. car_model_id: this.modelInfo.model_id,
  280. hire_cycle: this.modelInfo.count,
  281. hire_duration_unit: this.modelInfo.selectType,
  282. hire_duration,
  283. price: this.totalPrice * 100,
  284. pick_up_time: this.pick_up_time,
  285. address: this.modelInfo.address,
  286. currency_code: 'CNY'
  287. }
  288. common.loading();
  289. if (this.modelInfo.selectType == 100) {
  290. this.loadPayBuy(pData)
  291. return
  292. }
  293. this.loadPayMethod(pData)
  294. },
  295. async loadPayBuy(pData) {
  296. let {
  297. data
  298. } = await request.postApi(config_gyq.API_FLK_ORDER_RESERVE, {
  299. pay_type: pData.pay_type,
  300. car_model_id: pData.car_model_id,
  301. price: this.modelInfo.sell_price,
  302. pick_up_time: pData.pick_up_time,
  303. currency_code: 'CNY',
  304. })
  305. uni.hideLoading();
  306. if (data.code == 200) {
  307. if (!data.data.need_pay) {
  308. common.simpleToast(this.$t('支付成功'));
  309. this.order_sn = data.data.order_sn;
  310. this.sub_sn = data.data.sub_sn;
  311. this.setData({
  312. isShowToBuy: false,
  313. isShowCheckOrder: true
  314. })
  315. }
  316. } else {
  317. common.simpleToast(data.msg);
  318. }
  319. },
  320. loadPayMethod(pData) {
  321. const me = this;
  322. http.postApi(config.API_FLK_ORDER_HIRE_MODEL, pData, function(resp) {
  323. uni.hideLoading();
  324. if (resp.data.code === 200) {
  325. if (!resp.data.data.need_pay) {
  326. common.simpleToast(me, me.$t('支付成功'));
  327. me.order_sn = resp.data.data.order_sn;
  328. me.sub_sn = resp.data.data.sub_sn;
  329. me.setData({
  330. isShowToBuy: false,
  331. isShowCheckOrder: true
  332. })
  333. }
  334. } else {
  335. common.simpleToast(me, resp.data.msg);
  336. }
  337. });
  338. },
  339. toIndexPage() {
  340. uni.switchTab({
  341. url: '/pages/index/index'
  342. })
  343. },
  344. toOrderInfo() {
  345. uni.navigateTo({
  346. url: '/pages/orderStatus/orderStatus?sub_sn=' + this.sub_sn
  347. })
  348. }
  349. }
  350. };
  351. </script>
  352. <style>
  353. @import './purchaseOrder.css';
  354. </style>