package.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view class="container-view">
  3. <view class="top-bg">
  4. <Navigation :scroll='scrollTop'></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. <view v-if="item.package_type == 1" class="package-item">
  51. <view class="item-title">{{ $t('免费换电数') }}</view>
  52. <!-- <view style="color: #060809;" class="item-info">{{item.last_num}}{{ $t('次') }}</view> -->
  53. <view style="color: #060809;" class="item-info">{{ $t('不限次数') }}</view>
  54. </view>
  55. <view v-if="item.package_type == 2" class="package-item">
  56. <view class="item-title">{{ $t('免费换电数') }}</view>
  57. <view class="item-info">{{item.last_num}} <text style="color: #9FA7B7;">/{{item.num}}{{ $t('次') }}</text></view>
  58. </view>
  59. <view v-if="item.package_type == 3" class="package-item">
  60. <view class="item-title">{{ $t('免费换电数') }}</view>
  61. <view style="color: #060809;" class="item-info">{{item.total_day}}{{ $t('天') }}/{{item.last_num}}{{ $t('次') }}</view>
  62. </view>
  63. </view>
  64. </view>
  65. <view style="height: 200rpx;"></view>
  66. <view @click='srcFn' class="packageBtn">{{ $t('前往购买套餐') }}</view>
  67. </view>
  68. </template>
  69. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  70. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  71. <script>
  72. var config = require('../../common/config_gyq.js');
  73. var common = require('../../common/common.js');
  74. var http = require('../../common/request.js');
  75. var storage = require('../../common/storage.js');
  76. const dayjs = require('dayjs');
  77. import {
  78. getRemainingTime
  79. } from '../../utils/util.js';
  80. export default {
  81. components: {
  82. },
  83. onPageScroll(e) {
  84. this.scrollTop = e.scrollTop
  85. },
  86. data() {
  87. return {
  88. hireOrderList: [],
  89. page: 1,
  90. limit: 100,
  91. car_info: {},
  92. // statusBarHeight: 0,
  93. // navabarHeight: 0,
  94. packageList: []
  95. };
  96. },
  97. /**
  98. * 生命周期函数--监听页面加载
  99. */
  100. onLoad: function(options) {
  101. },
  102. /**
  103. * 生命周期函数--监听页面显示
  104. */
  105. onShow: function() {
  106. this.car_info = uni.getStorageSync('car_info') || {};
  107. this.listFn()
  108. },
  109. methods: {
  110. calculateRemainingDays(expirationDate) {
  111. // // 获取当前时间
  112. // const now = dayjs();
  113. // // 解析到期时间
  114. // const endDate = dayjs(expirationDate * 1000);
  115. // // 计算剩余天数
  116. // const remainingDays = endDate.diff(now, 'day');
  117. // return remainingDays || 1;
  118. return common.formatTimeDifference(expirationDate * 1000)
  119. },
  120. srcFn() {
  121. uni.navigateTo({
  122. url: `/pages/batteryPackage/batteryPackage`
  123. })
  124. },
  125. validDurationFn(start, end) {
  126. return getRemainingTime(start, end)
  127. },
  128. async listFn() {
  129. let {
  130. data
  131. } = await http.postApi(config.API_FLK_EXCHANGE_PACKAGE_ORDER_LIST, {
  132. page: this.page,
  133. pay_status: 2,
  134. car_sn: this.car_info.car_sn,
  135. limit: this.limit,
  136. })
  137. if (data.code == 200) {
  138. this.hireOrderList = data.data.list
  139. } else {
  140. common.simpleToast(resp.data.msg)
  141. }
  142. },
  143. bindReturnView() {
  144. uni.navigateBack({
  145. delta: 1,
  146. }) // 返回上一页
  147. },
  148. }
  149. };
  150. </script>
  151. <style>
  152. @import './package.css';
  153. .packageBtn {
  154. width: 686rpx;
  155. height: 80rpx;
  156. background: #060809;
  157. border-radius: 40rpx;
  158. font-family: PingFangSC, PingFang SC;
  159. font-weight: 500;
  160. font-size: 32rpx;
  161. color: #FFFFFF;
  162. display: flex;
  163. align-items: center;
  164. justify-content: center;
  165. position: fixed;
  166. left: 0;
  167. right: 0;
  168. margin: auto;
  169. bottom: 60rpx;
  170. }
  171. </style>