package.vue 5.2 KB

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