batteryPackage.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="battery-package-main">
  3. <navBar bgColor="#fff" name="换电套餐" />
  4. <view class="package-icon-view flex-row">
  5. <img src="https://qiniu.bms16.com/FqF7erLOB8OutmFnre7-mbTkwpZr" alt="">
  6. <view class="package-icon-text flex-row">5秒换电,瞬间满电,畅享骑行新体验!</view>
  7. </view>
  8. <view v-for="(item,index) of list" @click="selectItem(item)" :key="index" class="package-list-view" :class="{'active' : item.package_code == form.package_code }">
  9. <view class="package-num-view flex-row"><text class="package-num">{{item.total_day || 0}}</text> 天 <text
  10. class="package-num">{{(item.total_num || 0)=== 0 ? '不限次数' : item.total_num + '次'}}</text></view>
  11. <view class="flex-row flex-between align-baseline">
  12. <view v-if="item.tag.child_tag_name" class="apply-battery">适用电池:<text class="apply-battery-num">{{ !!Number(item.tag.main_tag_name) ? item.tag.main_tag_name + "V" : item.tag.main_tag_name}}{{!!Number(item.tag.child_tag_name) ? item.tag.child_tag_name + "Ah" : item.tag.child_tag_name }}</text></view>
  13. <view v-else class="apply-battery">适用电池:<text class="apply-battery-num">{{ item.tag.main_tag_name }}</text></view>
  14. <view class="flex-row align-baseline">
  15. <!-- <text class="package-price">${{item.viewShowMoney || '0.00'}}</text> -->
  16. <text class="symbol-style">
  17. <text>$</text>
  18. <text style="font-size: 48rpx;">{{item.viewMoney || '0.00'}}</text>
  19. <!-- <text style="font-size: ;">.{{Math.floor((item.viewMoney - Math.floor(item.viewMoney))) || 0}}</text> -->
  20. </text>
  21. </view>
  22. </view>
  23. </view>
  24. <!-- <view class="package-list-view">
  25. <view class="package-num-view flex-row"><text class="package-num">10</text> 天 <text
  26. class="package-num">10</text> 次</view>
  27. <view class="flex-row flex-between align-baseline">
  28. <view class="apply-battery">适用电池:<text class="apply-battery-num">48v20Ah</text></view>
  29. <view class="flex-row align-baseline">
  30. <text class="package-price">$35.9</text>
  31. <text class="symbol-style">
  32. <text>$</text>
  33. <text style="font-size: 64rpx;">23</text>
  34. <text style="font-size: ;">.0</text>
  35. </text>
  36. </view>
  37. </view>
  38. </view> -->
  39. <view class="flex-row package-tip" style="flex-direction: column;">
  40. <view class="flex-row" style="margin-bottom: 16rpx;">当前购买为虚拟IC卡</view>
  41. <view class="flex-row">如想要体验实体IC卡功能,前往最近的门店领取IC卡</view>
  42. </view>
  43. <view style="height: 200rpx;">
  44. </view>
  45. <view v-if="form.package_code" @click="isShowToBuy = true" class="pay-btn">立即购买</view>
  46. <payTypeModel @closeShow='isShowToBuy = false' :free_price='form.price' :isShowToBuy='isShowToBuy' @payToOrder='submit'></payTypeModel>
  47. </view>
  48. </template>
  49. <script>
  50. import { fenToYuan, msg } from '../../utils/util.js';
  51. const http = require('../../common/request.js');
  52. const config = require('../../common/config_gyq.js');
  53. import payTypeModel from '@/component/payTypeModel/payTypeModel';
  54. export default {
  55. components:{payTypeModel},
  56. data() {
  57. return {
  58. isShowToBuy:false,
  59. list:[],
  60. form:{
  61. pay_type:0,
  62. car_sn:"",
  63. package_code:"",
  64. price:""
  65. },
  66. };
  67. }
  68. /**
  69. * 生命周期函数--监听页面加载
  70. */
  71. ,
  72. onLoad: function(options) {
  73. this.listFn()
  74. },
  75. methods: {
  76. async submit(payType){
  77. this.form.pay_type = payType
  78. if(!this.form.car_sn){
  79. msg('请先绑定车辆!')
  80. return
  81. }
  82. uni.showLoading({
  83. mask:true,
  84. title:'提交中...'
  85. })
  86. let {
  87. data
  88. } = await http.postApi(config.API_FLK_EXCHANGE_PACKAGE_PAY, this.form)
  89. uni.hideLoading()
  90. console.log(data)
  91. if(data.code == 200){
  92. uni.navigateTo({
  93. url:`/pages/order/order`
  94. })
  95. }else{
  96. msg(data.msg)
  97. }
  98. this.isShowToBuy = false
  99. },
  100. selectItem(item){
  101. this.form.package_code = item.package_code
  102. this.form.price = item.money
  103. },
  104. async listFn() {
  105. let car_sn = uni.getStorageSync('car_info').car_sn || ''
  106. this.form.car_sn = car_sn
  107. let {
  108. data
  109. } = await http.postApi(config.API_FLK_EXCHANGE_PACKAGE_PACKAGE_LIST, {
  110. car_sn
  111. })
  112. if(data.code == 200){
  113. data.data.list.map(item=>{
  114. item.viewShowMoney = (item.show_money / 100).toFixed(2)
  115. item.viewMoney = (item.money / 100).toFixed(2)
  116. })
  117. if(data.data.list.length > 0){
  118. this.form.package_code = data.data.list[0].package_code
  119. this.form.price = data.data.list[0].money
  120. }
  121. this.list = data.data.list
  122. }
  123. },
  124. }
  125. };
  126. </script>
  127. <style>
  128. @import './batteryPackage.css';
  129. </style>