package.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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 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: 10,
  90. car_info: {},
  91. // statusBarHeight: 0,
  92. // navabarHeight: 0,
  93. packageList: [{
  94. ctime: '2024-04-04 16:15',
  95. total_duration: 30,
  96. efficient_day: 24,
  97. change_rate: 6,
  98. total_times: 10,
  99. status: 1
  100. },
  101. {
  102. ctime: '2024-04-04 16:15',
  103. total_duration: 30,
  104. efficient_day: 24,
  105. change_rate: 6,
  106. total_times: 10,
  107. status: 2
  108. },
  109. ]
  110. };
  111. },
  112. /**
  113. * 生命周期函数--监听页面加载
  114. */
  115. onLoad: function(options) {
  116. this.car_info = uni.getStorageSync('car_info') || {};
  117. // const clientRect = uni.getMenuButtonBoundingClientRect()
  118. // const sysinfo = uni.getSystemInfoSync()
  119. // let GAP = 8
  120. // // #ifdef MP-ALIPAY
  121. // GAP = 0
  122. // // #endif
  123. // const navabarHeight = (clientRect.bottom - sysinfo.statusBarHeight) + (clientRect.top - sysinfo.statusBarHeight) + GAP
  124. // this.navabarHeight = navabarHeight
  125. // this.statusBarHeight = sysinfo.statusBarHeight
  126. this.mapCtx = uni.createMapContext('myMap');
  127. this.listFn()
  128. },
  129. /**
  130. * 生命周期函数--监听页面显示
  131. */
  132. onShow: function() {
  133. },
  134. methods: {
  135. calculateRemainingDays(expirationDate) {
  136. // 获取当前时间
  137. const now = dayjs();
  138. // 解析到期时间
  139. const endDate = dayjs(expirationDate * 1000);
  140. // 计算剩余天数
  141. const remainingDays = endDate.diff(now, 'day');
  142. return remainingDays || 1;
  143. },
  144. srcFn() {
  145. uni.navigateTo({
  146. url: `/pages/batteryPackage/batteryPackage`
  147. })
  148. },
  149. validDurationFn(start, end) {
  150. return getRemainingTime(start, end)
  151. },
  152. async listFn() {
  153. let {
  154. data
  155. } = await http.postApi(config.API_FLK_EXCHANGE_PACKAGE_ORDER_LIST, {
  156. page: this.page,
  157. pay_status: 2,
  158. car_sn: this.car_info.car_sn,
  159. limit: this.limit,
  160. })
  161. if (data.code == 200) {
  162. this.hireOrderList.push.apply(this.hireOrderList, data.data.list)
  163. } else {
  164. common.simpleToast(resp.data.msg)
  165. }
  166. },
  167. bindReturnView() {
  168. uni.navigateBack({
  169. delta: 1,
  170. }) // 返回上一页
  171. },
  172. }
  173. };
  174. </script>
  175. <style>
  176. @import './package.css';
  177. .packageBtn {
  178. width: 686rpx;
  179. height: 80rpx;
  180. background: #060809;
  181. border-radius: 40rpx;
  182. font-family: PingFangSC, PingFang SC;
  183. font-weight: 500;
  184. font-size: 32rpx;
  185. color: #FFFFFF;
  186. display: flex;
  187. align-items: center;
  188. justify-content: center;
  189. position: fixed;
  190. left: 0;
  191. right: 0;
  192. margin: auto;
  193. bottom: 60rpx;
  194. }
  195. </style>