package.vue 6.6 KB

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