carPlan.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <view class="show-more">
  3. <view class="more-info">
  4. <view class="flex-row model-title">
  5. <view style="margin-right: 24rpx;">
  6. <image style="width: 160rpx;height: 160rpx;border-radius: 16rpx;" :src="image" mode="aspectFit"</image>
  7. </view>
  8. <view class="car-model-detail flex-row">
  9. <!-- <priceTool :price="58" :font_size="40"/> -->
  10. <allPrice :amount="((price || 0)/100)"/>
  11. <view v-if="params.overdueData && params.overdueData.money" style="align-items: baseline;" class="flex-row">
  12. <text>{{ $t('逾期金额')}}:</text>
  13. <allPrice :amount="(params.overdueData.money || 0/100)"/>
  14. </view>
  15. <view v-if="type!=100" class="car-model-price-view">
  16. <text style="margin-right: 12rpx;">{{ $t('已选择') }}</text>
  17. <text>{{leaseUnitsResult}}</text>
  18. <text style="margin-left: 12rpx;">{{ $t('时长') }} {{count}}
  19. <text>{{leaseUnits}}</text>
  20. </text>
  21. <!-- <text>共计{{tools.countToDay(count,type)}}天</text> -->
  22. </view>
  23. <view style="margin-top: 10rpx;" class="car-model-tip">{{ $t('现车') }}-{{ $t('随时可到店提车') }}</view>
  24. </view>
  25. <view class="close-img">
  26. <image style="width: 24rpx;height: 24rpx;" @tap="closeShowMore"
  27. src="https://qiniu.bms16.com/FoWVlo-Nmx6wTDpsL2Rf9_BamU7L" />
  28. </view>
  29. </view>
  30. <view class="car-plan-view">
  31. <view class="car-plan-title">{{ $t('用车方案') }}</view>
  32. <view class="car-plan-list-view flex-row">
  33. <view v-for="(item,index) in params.rental_setting" :key="index" @click="tapSelectType(item)" :class="['flex-row' , (type == item.hire_duration_unit ? 'car-plan-list-i' : 'car-plan-list')] "
  34. >
  35. <view :class="(type == item.hire_duration_unit ? 'car-plan-unit-i' : 'car-plan-unit') ">
  36. <text v-if="item.hire_duration_unit==1">{{ $t('日租') }}</text>
  37. <text v-if="item.hire_duration_unit==2">{{ $t('月租') }}</text>
  38. <text v-if="item.hire_duration_unit==3">{{ $t('年租') }}</text>
  39. <text v-if="item.hire_duration_unit==4">{{ $t('时租') }}</text>
  40. <text v-if="item.hire_duration_unit==5">{{ $t('分租') }}</text>
  41. <text v-if="item.hire_duration_unit==6">{{ $t('周租') }}</text>
  42. <text v-if="item.hire_duration_unit==7">{{ $t('季租') }}</text>
  43. </view>
  44. <view :class="(type == item.hire_duration_unit ? 'car-plan-price-i' : 'car-plan-price') ">$<text style="font-size: 48rpx;margin-left: 6rpx;">{{item.hire_price/100}}</text></view>
  45. </view>
  46. <view v-if="params.sell_price != 0 && isBuy" @click="tapSelectType({hire_duration_unit:100,hire_price:params.sell_price})" :class="['flex-row' , (type == 100 ? 'car-plan-list-i' : 'car-plan-list') ]" style="padding: 0rpx 20rpx; min-width: auto; " >
  47. <view :class="(type == 100 ? 'car-plan-unit-i' : 'car-plan-unit') ">{{ $t('购买') }}</view>
  48. <view :class="(type == 100 ? 'car-plan-price-i' : 'car-plan-price') ">$<text style="font-size: 48rpx;margin-left: 6rpx;">{{params.sell_price/100}}</text></view>
  49. </view>
  50. </view>
  51. <!-- 暂时未安排开发 -->
  52. <!-- <view class="free-num-block">
  53. <view class="flex-row flex-between" style="margin-bottom: 24rpx;">
  54. <view class="free-num-left">
  55. <img style="width: 40rpx;height: 40rpx;" src="https://qiniu.bms16.com/Fj_ifr41AqH2PijZBdOBa3SCxADg" alt="">
  56. <text style="margin-left: 16rpx;">免费换电次数</text>
  57. </view>
  58. <view class="free-num">共60次</view>
  59. </view>
  60. <view class="flex-row free-num-tip">本单可享60次免费换电数,超出后需要单独支付换电费用</view>
  61. <view class="flex-row free-num-tip">自费换电:$1/次</view>
  62. </view> -->
  63. <view v-if="type!=100" class="plan-time flex-row flex-between">
  64. <view>{{ $t('租车时长') }}</view>
  65. <view class="quantity-count flex-row flex-between">
  66. <view class="total-time flex-row">
  67. {{ $t('共') }}
  68. <view style="font-weight: 600;margin: 0 10rpx;">{{count}}</view>
  69. <!-- <view style="font-weight: 600;margin: 0 10rpx;">{{tools.countToDay(count,isSelectStatus)}}</view> -->
  70. <text>{{leaseUnits}}</text>
  71. </view>
  72. <!-- <view class="count-btn fbtn" @tap.stop.prevent="bindMinus">-</view> -->
  73. <view @tap.stop.prevent="bindMinus"><img class="count-btn fbtn"
  74. src="https://qiniu.bms16.com/Fm-SCbzVeVHgQK920bmWNvnJnL32" /></view>
  75. <input @input="bindInput" @blur="bindBlur" type="number" :value="count" />
  76. <!-- <view class="count-btn sbtn" @tap.stop.prevent="bindAdd">+</view> -->
  77. <view @tap.stop.prevent="bindAdd"><img class="count-btn sbtn"
  78. src="https://qiniu.bms16.com/FsO-2adBjkUkmk4ENuQco-aK7IyY" /></view>
  79. </view>
  80. </view>
  81. <!-- <view class="car-color-view">
  82. <view>车辆颜色</view>
  83. <view class="flex-row">
  84. <view class="car-color-list car-color-s">白色</view>
  85. <view class="car-color-list car-color-i">白色</view>
  86. <view class="car-color-list car-color-i">白色</view>
  87. <view class="car-color-list car-color-i">白色</view>
  88. </view>
  89. </view> -->
  90. </view>
  91. <view class="lift-btn-view">
  92. <view @tap="checkOrder" class="lift-btn">{{ $t('确认') }}</view>
  93. </view>
  94. </view>
  95. <PayTypeModel @closeShow="isShowToBuy = false" @payToOrder="payToOrder" :free_price="Number(priceAll) + (Number(params.overdueData ? params.overdueData.money : 0) || 0)" :isShowToBuy="isShowToBuy"/>
  96. </view>
  97. </template>
  98. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  99. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  100. <script>
  101. import allPrice from '@/component/allPrice/allPrice';
  102. import {
  103. MAX_LIMITS,LEASE_TYPE_ARR
  104. } from '@/common/constant.js'
  105. import common from '../../common/common';
  106. var config_gyq = require('../../common/config_gyq.js');
  107. var request = require('../../common/request');
  108. import PayTypeModel from '@/component/payTypeModel/payTypeModel';
  109. export default {
  110. data() {
  111. return {
  112. image:'',
  113. orderInfo:{},
  114. isShowToBuy:false,
  115. priceAll:0,
  116. count:1,
  117. price:0,
  118. duration_unit:'',
  119. type:'',
  120. };
  121. },
  122. computed: {
  123. leaseUnitsResult() {
  124. const result = LEASE_TYPE_ARR.find(v => v.value == this.type);
  125. return result ? result.label : '';
  126. },
  127. leaseUnits(){
  128. const result = LEASE_TYPE_ARR.find(v => v.value == this.type);
  129. return result ? result.unit : '';
  130. }
  131. },
  132. /**
  133. * 组件的属性列表
  134. */
  135. props: {
  136. isBuy:{
  137. type: Boolean,
  138. default: true
  139. },
  140. params:{
  141. type:Object,
  142. default:{}
  143. },
  144. selectType:{
  145. type:Number,
  146. default:1
  147. },
  148. },
  149. components: {
  150. allPrice,
  151. PayTypeModel,
  152. },
  153. mounted() {
  154. this.params.image = this.params.model_images[0]
  155. this.image = this.params.image ? this.params.image : this.params?.model_images[0] ? this.params.model_images[0] : ""
  156. this.type = this.selectType
  157. this.tapSelectType({hire_duration_unit:this.selectType,hire_price:this.params.price*100})
  158. },
  159. // created: function () {
  160. // console.log(this.params,'this.params');
  161. // this.setData({
  162. // price:this.params.price*100,
  163. // })
  164. // },
  165. /**
  166. * 组件的方法列表
  167. */
  168. methods: {
  169. async payToOrder(type){
  170. const pay_type = type
  171. var from=''
  172. if(pay_type == 1){
  173. from = 'wx'
  174. }else if(pay_type == 2){
  175. from = 'ali'
  176. }
  177. let {data} = await request.postApi(config_gyq.API_FLK_ORDER_RENEW,{
  178. ...this.orderInfo,
  179. pay_type,
  180. from
  181. })
  182. if(data.code == 200){
  183. common.simpleToast('成功!')
  184. this.isShowToBuy = false
  185. setTimeout(function() {
  186. uni.navigateBack({
  187. delta: 1
  188. });
  189. }, 800);
  190. }else{
  191. common.simpleToast(data.msg)
  192. }
  193. },
  194. tapSelectType(e){
  195. const {hire_duration_unit,hire_price} = e
  196. this.type = hire_duration_unit
  197. this.priceAll = hire_price
  198. this.price = hire_price
  199. this.count = 1
  200. },
  201. closeShowMore(){
  202. this.$emit('closeShowMore')
  203. },
  204. bindMinus() {
  205. if (this.count > 1) {
  206. this.setData({
  207. count: this.count - 1
  208. });
  209. }
  210. this.bindDuration()
  211. },
  212. bindInput(e) {
  213. const num = Number(e.detail.value)
  214. this.bindTipCount(num)
  215. this.bindDuration()
  216. },
  217. bindBlur(e) {
  218. const count = e.detail.value
  219. this.bindTipCount(count)
  220. if (count < 1) {
  221. this.setData({
  222. count: 1
  223. })
  224. }
  225. this.bindDuration()
  226. },
  227. bindAdd() {
  228. const num = this.count - 0 + 1
  229. this.bindTipCount(num)
  230. this.bindDuration()
  231. },
  232. bindTipCount(num) {
  233. const limit = MAX_LIMITS[this.isSelectStatus];
  234. if (limit && num > limit.max) {
  235. common.simpleToast(limit.message);
  236. this.setData({
  237. count: limit.max
  238. })
  239. this.blurHandle()
  240. } else {
  241. this.setData({
  242. count: num
  243. })
  244. }
  245. },
  246. blurHandle() {
  247. this.showInput = false
  248. this.$nextTick(() => {
  249. this.showInput = true
  250. })
  251. },
  252. //计算价格
  253. bindDuration() {
  254. const me = this
  255. //未有显示总价钱的地方
  256. var new_price=0
  257. console.log(me.price)
  258. if(me.type == 100){
  259. new_price=me.params.sell_price
  260. }else{
  261. new_price=Number(me.price)*Number(me.count)
  262. }
  263. this.setData({
  264. priceAll:new_price
  265. })
  266. },
  267. async orderRenewFn(){
  268. // this.overdueData
  269. console.log(this.params)
  270. let current_time = this.params.overdueData.time ? this.params.overdueData.time:parseInt(new Date().getTime() / 1000);
  271. let money = 0
  272. if(this.params.overdueData.time){
  273. money = this.params.overdueData.money ? Number(this.params.overdueData.money) : 0
  274. }
  275. let hire_duration = 0
  276. this.params.rental_setting.map(item=>{
  277. if(item.hire_duration_unit == this.type){
  278. hire_duration = item.hire_duration
  279. }
  280. })
  281. this.orderInfo={
  282. order_sn:this.params.order_sn,
  283. hire_duration,
  284. hire_cycle:this.count,
  285. hire_duration_unit:this.type,
  286. price:this.priceAll + money,
  287. current_time,
  288. currency_code:'CNY'
  289. }
  290. this.isShowToBuy = true
  291. },
  292. checkOrder(){
  293. const params={
  294. ...this.params,
  295. selectType:this.type,
  296. count:this.count,
  297. totalPrice:this.priceAll,
  298. selectUnit:this.type
  299. }
  300. if(this.params.order_sn){
  301. this.orderRenewFn()
  302. }else{
  303. uni.navigateTo({
  304. url: `/pages/purchaseOrder/purchaseOrder?params=${encodeURIComponent(JSON.stringify(params))}`,
  305. })
  306. }
  307. },
  308. }
  309. };
  310. </script>
  311. <style scoped>
  312. @import './carPlan.css';
  313. </style>