purchaseOrder.vue 10 KB

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