carPlan.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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;"><img style="width: 160rpx;height: 160rpx;border-radius: 16rpx;" :src="params.image" alt=""></view>
  6. <view class="car-model-detail flex-row">
  7. <!-- <priceTool :price="58" :font_size="40"/> -->
  8. <allPrice :amount="(price/100)"/>
  9. <view v-if="duration_unit!=100" class="car-model-price-view">
  10. <text style="margin-right: 12rpx;">已选择</text>
  11. <text>{{leaseUnitsResult}}</text>
  12. <text>时长 {{count}}
  13. <text v-if="selectType==1">日</text>
  14. <text v-if="selectType==2">月</text>
  15. <text v-if="selectType==3">年</text>
  16. </text>
  17. <text>共计{{tools.countToDay(count,selectType)}}天</text>
  18. </view>
  19. <view class="car-model-tip">现车 随时可到店提车</view>
  20. </view>
  21. <view class="close-img">
  22. <image style="width: 24rpx;height: 24rpx;" @tap="closeShowMore"
  23. src="https://qiniu.bms16.com/FoWVlo-Nmx6wTDpsL2Rf9_BamU7L" />
  24. </view>
  25. </view>
  26. <view class="car-plan-view">
  27. <view class="car-plan-title">用车方案</view>
  28. <view class="car-plan-list-view flex-row">
  29. <view v-for="(item,index) in params.rental_setting" :key="index" @tap="tapSelectType" :class="['flex-row' , (selectType == item.hire_duration_unit ? 'car-plan-list-i' : 'car-plan-list')] "
  30. :data-price="item.hire_price"
  31. :data-select_type="item.hire_duration_unit">
  32. <view :class="(selectType == item.hire_duration_unit ? 'car-plan-unit-i' : 'car-plan-unit') ">
  33. <text v-if="item.hire_duration_unit==1">日租</text>
  34. <text v-if="item.hire_duration_unit==2">月租</text>
  35. <text v-if="item.hire_duration_unit==3">年租</text>
  36. </view>
  37. <view :class="(selectType == 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>
  38. </view>
  39. <view @tap="tapSelectType" :class="['flex-row' , (selectType == 100 ? 'car-plan-list-i' : 'car-plan-list') ]"
  40. :data-price="params.sell_price"
  41. :data-select_type="100">
  42. <view :class="(selectType == 100 ? 'car-plan-unit-i' : 'car-plan-unit') ">购买</view>
  43. <view :class="(selectType == 100 ? 'car-plan-price-i' : 'car-plan-price') ">$<text style="font-size: 48rpx;margin-left: 6rpx;">{{params.sell_price/100}}</text></view>
  44. </view>
  45. </view>
  46. <!-- 暂时未安排开发 -->
  47. <!-- <view class="free-num-block">
  48. <view class="flex-row flex-between" style="margin-bottom: 24rpx;">
  49. <view class="free-num-left">
  50. <img style="width: 40rpx;height: 40rpx;" src="https://qiniu.bms16.com/Fj_ifr41AqH2PijZBdOBa3SCxADg" alt="">
  51. <text style="margin-left: 16rpx;">免费换电次数</text>
  52. </view>
  53. <view class="free-num">共60次</view>
  54. </view>
  55. <view class="flex-row free-num-tip">本单可享60次免费换电数,超出后需要单独支付换电费用</view>
  56. <view class="flex-row free-num-tip">自费换电:$1/次</view>
  57. </view> -->
  58. <view v-if="selectType!=100" class="plan-time flex-row flex-between">
  59. <view>租车时长</view>
  60. <view class="quantity-count flex-row flex-between">
  61. <view class="total-time flex-row">
  62. <view style="font-weight: 600;margin: 0 10rpx;">{{tools.countToDay(count,selectType)}}</view>
  63. <!-- <view style="font-weight: 600;margin: 0 10rpx;">{{tools.countToDay(count,isSelectStatus)}}</view> -->
  64. <text>天</text>
  65. </view>
  66. <!-- <view class="count-btn fbtn" @tap.stop.prevent="bindMinus">-</view> -->
  67. <view @tap.stop.prevent="bindMinus"><img class="count-btn fbtn"
  68. src="https://qiniu.bms16.com/Fm-SCbzVeVHgQK920bmWNvnJnL32" /></view>
  69. <input @input="bindInput" @blur="bindBlur" type="number" :value="count" />
  70. <!-- <view class="count-btn sbtn" @tap.stop.prevent="bindAdd">+</view> -->
  71. <view @tap.stop.prevent="bindAdd"><img class="count-btn sbtn"
  72. src="https://qiniu.bms16.com/FsO-2adBjkUkmk4ENuQco-aK7IyY" /></view>
  73. </view>
  74. </view>
  75. <!-- <view class="car-color-view">
  76. <view>车辆颜色</view>
  77. <view class="flex-row">
  78. <view class="car-color-list car-color-s">白色</view>
  79. <view class="car-color-list car-color-i">白色</view>
  80. <view class="car-color-list car-color-i">白色</view>
  81. <view class="car-color-list car-color-i">白色</view>
  82. </view>
  83. </view> -->
  84. </view>
  85. <view class="lift-btn-view">
  86. <view @tap="checkOrder" class="lift-btn">确认</view>
  87. </view>
  88. </view>
  89. </view>
  90. </template>
  91. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  92. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  93. <script>
  94. import allPrice from '@/component/allPrice/allPrice';
  95. import {
  96. MAX_LIMITS,LEASE_TYPE_ARR
  97. } from '@/common/constant.js'
  98. import common from '../../common/common';
  99. export default {
  100. data() {
  101. return {
  102. count:1,
  103. price:0,
  104. duration_unit:''
  105. };
  106. },
  107. computed: {
  108. leaseUnitsResult() {
  109. const result = LEASE_TYPE_ARR.find(v => v.value == this.params.rentalType);
  110. return result ? result.label : '';
  111. }
  112. },
  113. /**
  114. * 组件的属性列表
  115. */
  116. props: {
  117. params:{
  118. type:Object,
  119. default:{}
  120. },
  121. selectType:{
  122. type:String,
  123. default:''
  124. },
  125. },
  126. components: {
  127. allPrice,
  128. },
  129. created: function () {
  130. console.log(this.params,'this.params');
  131. this.setData({
  132. price:this.params.price*100,
  133. })
  134. },
  135. /**
  136. * 组件的方法列表
  137. */
  138. methods: {
  139. tapSelectType(e){
  140. const {select_type,price} = e.currentTarget.dataset
  141. console.log(e,select_type,price,'selectType,price');
  142. this.$emit('changeSelectType',select_type,price)
  143. this.setData({
  144. price,
  145. count:1
  146. })
  147. },
  148. closeShowMore(){
  149. this.$emit('closeShowMore')
  150. },
  151. bindMinus() {
  152. if (this.count > 1) {
  153. this.setData({
  154. count: this.count - 1
  155. });
  156. }
  157. this.bindDuration()
  158. },
  159. bindInput(e) {
  160. const num = Number(e.detail.value)
  161. this.bindTipCount(num)
  162. this.bindDuration()
  163. },
  164. bindBlur(e) {
  165. const count = e.detail.value
  166. this.bindTipCount(count)
  167. if (count < 1) {
  168. this.setData({
  169. count: 1
  170. })
  171. }
  172. this.bindDuration()
  173. },
  174. bindAdd() {
  175. const num = this.count - 0 + 1
  176. this.bindTipCount(num)
  177. this.bindDuration()
  178. },
  179. bindTipCount(num) {
  180. const limit = MAX_LIMITS[this.isSelectStatus];
  181. if (limit && num > limit.max) {
  182. common.simpleToast(limit.message);
  183. this.setData({
  184. count: limit.max
  185. })
  186. this.blurHandle()
  187. } else {
  188. this.setData({
  189. count: num
  190. })
  191. }
  192. },
  193. blurHandle() {
  194. this.showInput = false
  195. this.$nextTick(() => {
  196. this.showInput = true
  197. })
  198. },
  199. //计算价格
  200. bindDuration() {
  201. const me = this
  202. //未有显示总价钱的地方
  203. // var new_price=0
  204. // if(me.selectType == 100){
  205. // new_price=me.params.sell_price
  206. // }else{
  207. // new_price=me.price*me.count
  208. // }
  209. // console.log(me.count,me.price,new_price,'new_price');
  210. // this.setData({
  211. // price:new_price
  212. // })
  213. },
  214. checkOrder(){
  215. const params={
  216. ...this.params,
  217. selectType:this.selectType,
  218. count:this.count,
  219. totalPrice:this.price,
  220. selectUnit:LEASE_TYPE_ARR.find(v => v.value == this.selectType)?.label
  221. }
  222. uni.navigateTo({
  223. url: `/pages/purchaseOrder/purchaseOrder?params=${encodeURIComponent(JSON.stringify(params))}`,
  224. })
  225. },
  226. }
  227. };
  228. </script>
  229. <style scoped>
  230. @import './carPlan.css';
  231. </style>