package.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="container-view">
  3. <view class="top-bg">
  4. <navigation whiteColor="true" type="true" :scroll='scrollTop' :name="$t('我的套餐')"></navigation>
  5. <!-- <view :style="{height: `calc(${statusBarHeight}px + 100px)`}"></view> -->
  6. <view class="package-card flex-row flex-between">
  7. <view class="flex-row flex-column" style="align-items: flex-start;">
  8. <view @click="$srcFn(`/pages/carList/carList`)" class="left-first flex-row">
  9. <view>{{car_info.car_name}}</view>
  10. <img class="left-img" src="https://qiniu.bms16.com/Fpf25Lkkrx05pvLw08mksVQKAQWf" />
  11. </view>
  12. <view class="left-second flex-row">
  13. <view style="margin-right: 32rpx;">{{ $t('适用电池') }}:<text>{{car_info.battery_tag_info.main_tag_name ? (car_info.battery_tag_info.main_tag_name) : ''}}{{car_info.battery_tag_info.child_tag_name ? '/' + car_info.battery_tag_info.child_tag_name : ''}}</text></view>
  14. <!-- <view>{{ $t('押金') }}:<text>$5.0</text></view> -->
  15. </view>
  16. <view class="left-third">
  17. <view>{{ $t('车辆编号') }}:<text>{{car_info.car_sn}}</text></view>
  18. </view>
  19. </view>
  20. <img class="card-right" src="https://qiniu.bms16.com/FuOJQxzypa-NginyHGdsWlzwnB8z" />
  21. </view>
  22. </view>
  23. <view class="box-view">
  24. <view class="package-view" v-for="item in hireOrderList">
  25. <view class="top-view flex-row flex-between">
  26. <view class="top-title" v-if="item.package_type == 1">
  27. {{item.total_day}}{{ $t('天') }}
  28. </view>
  29. <view class="top-title" v-if="item.package_type == 2">
  30. {{item.num}}{{ $t('次') }}
  31. </view>
  32. <view class="top-title" v-if="item.package_type == 3">
  33. {{item.total_day}}{{ $t('天') }}{{item.num}}{{ $t('次') }}
  34. </view>
  35. <view v-if="item.package_status==1" class="card-text card-b">{{ $t('生效中') }}</view>
  36. <view v-if="item.package_status==0" class="card-text card-o">{{ $t('待生效') }}</view>
  37. <view v-if="item.package_status==2" class="card-text card-o">{{ $t('已结束') }}</view>
  38. </view>
  39. <view class="package-item" style="margin-bottom: 32rpx;">
  40. <view v-if="item.expire_time != 0" class="item-title">{{ $t('有效期至') }}</view>
  41. <view class="item-info">{{tools.formatTime(item.expire_time)}}</view>
  42. </view>
  43. <view v-if="item.package_type != 2" class="package-item" style="margin-bottom: 32rpx;">
  44. <view class="item-title">{{ $t('有效时长') }}</view>
  45. <view class="item-info">
  46. {{ item.expire_time != 0 ? calculateRemainingDays(item.expire_time) : item.total_day }}<text
  47. style="color: #9FA7B7;">/{{item.total_day}}{{ $t('天') }}</text>
  48. </view>
  49. </view>
  50. <!-- 套餐类型 1 天卡 2 次卡 3 天次卡 -->
  51. <view v-if="item.package_type == 1" class="package-item">
  52. <view class="item-title">{{ $t('免费换电数') }}</view>
  53. <!-- <view style="color: #060809;" class="item-info">{{item.last_num}}{{ $t('次') }}</view> -->
  54. <view style="color: #060809;" class="item-info">{{ $t('不限次数') }}</view>
  55. </view>
  56. <view v-if="item.package_type == 2" class="package-item">
  57. <view class="item-title">{{ $t('免费换电数') }}</view>
  58. <view class="item-info">{{item.last_num}} <text style="color: #9FA7B7;">/{{item.num}}{{ $t('次') }}</text></view>
  59. </view>
  60. <view v-if="item.package_type == 3" class="package-item">
  61. <view class="item-title">{{ $t('免费换电数') }}</view>
  62. <view style="color: #060809;" class="item-info">{{item.last_num}}/{{item.num}}{{ $t('次') }}</view>
  63. </view>
  64. </view>
  65. </view>
  66. <view style="height: 200rpx;"></view>
  67. <view @click='srcFn' class="packageBtn">{{ $t('前往购买套餐') }}</view>
  68. </view>
  69. </template>
  70. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  71. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  72. <script>
  73. var config = require('../../common/config_gyq.js');
  74. var common = require('../../common/common.js');
  75. var http = require('../../common/request.js');
  76. var storage = require('../../common/storage.js');
  77. const dayjs = require('dayjs');
  78. import {
  79. getRemainingTime
  80. } from '../../utils/util.js';
  81. export default {
  82. components: {
  83. },
  84. onPageScroll(e) {
  85. this.scrollTop = e.scrollTop
  86. },
  87. data() {
  88. return {
  89. hireOrderList: [],
  90. page: 1,
  91. limit: 100,
  92. car_info: {},
  93. // statusBarHeight: 0,
  94. // navabarHeight: 0,
  95. packageList: []
  96. };
  97. },
  98. /**
  99. * 生命周期函数--监听页面加载
  100. */
  101. onLoad: function(options) {
  102. },
  103. /**
  104. * 生命周期函数--监听页面显示
  105. */
  106. onShow: function() {
  107. this.car_info = uni.getStorageSync('car_info') || {};
  108. this.listFn()
  109. },
  110. methods: {
  111. calculateRemainingDays(expirationDate) {
  112. // // 获取当前时间
  113. // const now = dayjs();
  114. // // 解析到期时间
  115. // const endDate = dayjs(expirationDate * 1000);
  116. // // 计算剩余天数
  117. // const remainingDays = endDate.diff(now, 'day');
  118. // return remainingDays || 1;
  119. return common.formatTimeDifference(expirationDate * 1000)
  120. },
  121. srcFn() {
  122. uni.navigateTo({
  123. url: `/pages/batteryPackage/batteryPackage`
  124. })
  125. },
  126. validDurationFn(start, end) {
  127. return getRemainingTime(start, end)
  128. },
  129. async listFn() {
  130. let {
  131. data
  132. } = await http.postApi(config.API_FLK_EXCHANGE_PACKAGE_ORDER_LIST, {
  133. page: this.page,
  134. pay_status: 2,
  135. car_sn: this.car_info.car_sn,
  136. limit: this.limit,
  137. })
  138. if (data.code == 200) {
  139. this.hireOrderList = data.data.list
  140. } else {
  141. common.simpleToast(resp.data.msg)
  142. }
  143. },
  144. bindReturnView() {
  145. uni.navigateBack({
  146. delta: 1,
  147. }) // 返回上一页
  148. },
  149. }
  150. };
  151. </script>
  152. <style>
  153. @import './package.css';
  154. .packageBtn {
  155. width: 686rpx;
  156. height: 80rpx;
  157. background: #060809;
  158. border-radius: 40rpx;
  159. font-family: PingFangSC, PingFang SC;
  160. font-weight: 500;
  161. font-size: 32rpx;
  162. color: #FFFFFF;
  163. display: flex;
  164. align-items: center;
  165. justify-content: center;
  166. position: fixed;
  167. left: 0;
  168. right: 0;
  169. margin: auto;
  170. bottom: 60rpx;
  171. }
  172. </style>