batteryPackage.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view class="battery-package-main">
  3. <navigation :scroll='scrollTop' :type="true" :name="$t('换电套餐')" />
  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 {{ $t('秒换电,瞬间满电,畅享骑行新体验!') }}</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> {{ $t('天') }} <text
  10. class="package-num">{{(item.total_num || 0)=== 0 ? $t('不限次数') : item.total_num + $t('次')}}</text></view>
  11. <view class="flex-row flex-between align-baseline">
  12. <view v-if="item.tag.child_tag_name" class="apply-battery">{{ $t('适用电池:') }}<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">{{ $t('适用电池:') }}<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> {{ $t('天') }} <text
  26. class="package-num">10</text> {{ $t('次') }}</view>
  27. <view class="flex-row flex-between align-baseline">
  28. <view class="apply-battery">{{ $t('适用电池:') }}<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;">{{ $t('当前购买为虚拟') }}IC{{ $t('卡') }}</view>
  41. <view class="flex-row">{{ $t('如想要体验实体') }}IC{{ $t('卡功能,前往最近的门店领取') }}IC{{ $t('卡') }}</view>
  42. </view>
  43. <view style="height: 200rpx;">
  44. </view>
  45. <view v-if="form.package_code" @click="isShowToBuy = true" class="pay-btn">{{ $t('需到店支付') }}</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. onPageScroll(e) {
  57. this.scrollTop = e.scrollTop
  58. },
  59. data() {
  60. return {
  61. isShowToBuy:false,
  62. list:[],
  63. form:{
  64. pay_type:0,
  65. car_sn:"",
  66. package_code:"",
  67. price:""
  68. },
  69. };
  70. }
  71. /**
  72. * 生命周期函数--监听页面加载
  73. */
  74. ,
  75. onLoad: function(options) {
  76. this.listFn()
  77. },
  78. methods: {
  79. async submit(payType){
  80. this.form.pay_type = payType
  81. if(!this.form.car_sn){
  82. msg(this.$t('请先绑定车辆!'))
  83. return
  84. }
  85. uni.showLoading({
  86. mask:true,
  87. title:this.$t('提交中')+'...'
  88. })
  89. let {
  90. data
  91. } = await http.postApi(config.API_FLK_EXCHANGE_PACKAGE_PAY, this.form)
  92. uni.hideLoading()
  93. if(data.code == 200){
  94. uni.navigateTo({
  95. url:`/pages/order/order?selectOrderType=0`
  96. })
  97. }else{
  98. msg(data.msg)
  99. }
  100. this.isShowToBuy = false
  101. },
  102. selectItem(item){
  103. this.form.package_code = item.package_code
  104. this.form.price = item.money
  105. },
  106. async listFn() {
  107. let car_sn = uni.getStorageSync('car_info').car_sn || ''
  108. this.form.car_sn = car_sn
  109. let {
  110. data
  111. } = await http.postApi(config.API_FLK_EXCHANGE_PACKAGE_PACKAGE_LIST, {
  112. car_sn
  113. })
  114. if(data.code == 200){
  115. data.data.list.map(item=>{
  116. item.viewShowMoney = (item.show_money / 100).toFixed(2)
  117. item.viewMoney = (item.money / 100).toFixed(2)
  118. })
  119. if(data.data.list.length > 0){
  120. this.form.package_code = data.data.list[0].package_code
  121. this.form.price = data.data.list[0].money
  122. }
  123. this.list = data.data.list
  124. }
  125. },
  126. }
  127. };
  128. </script>
  129. <style>
  130. @import './batteryPackage.css';
  131. </style>