package.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view class="container-view">
  3. <view class="top-bg" >
  4. <navBar name="我的套餐" bgColor="transparent"></navBar>
  5. <!-- <view class="flex-row" :style="'height:'+navabarHeight+'px;'">
  6. <view class="flex-row" @tap="bindReturnView"><img class="return-view" src="https://qiniu.bms16.com/FnHXbzly7aXi8zLghrTU5BZdwH5_" /></view>
  7. <text class="top-text">我的套餐</text>
  8. </view> -->
  9. <view class="package-card flex-row flex-between">
  10. <view class="flex-row flex-column" style="align-items: flex-start;">
  11. <view class="left-first flex-row">
  12. <view>{{car_info.car_name}}</view>
  13. <img class="left-img" src="https://qiniu.bms16.com/Fpf25Lkkrx05pvLw08mksVQKAQWf" />
  14. </view>
  15. <view class="left-second flex-row">
  16. <view style="margin-right: 32rpx;">适用电池:<text>48v20Ah</text></view>
  17. <!-- <view>押金:<text>$5.0</text></view> -->
  18. </view>
  19. <view class="left-third">
  20. <view>车辆编号:<text>{{car_info.car_sn}}</text></view>
  21. </view>
  22. </view>
  23. <img class="card-right" src="https://qiniu.bms16.com/FuOJQxzypa-NginyHGdsWlzwnB8z" />
  24. </view>
  25. </view>
  26. <view class="box-view">
  27. <!-- <view class="package-card flex-row flex-between">
  28. <view class="flex-row flex-column" style="align-items: flex-start;">
  29. <view class="left-first flex-row">
  30. <view>小米 Su7</view>
  31. <img class="left-img" src="https://qiniu.bms16.com/Fpf25Lkkrx05pvLw08mksVQKAQWf" />
  32. </view>
  33. <view class="left-second flex-row">
  34. <view style="margin-right: 32rpx;">适用电池:<text>48v20Ah</text></view>
  35. <view>押金:<text>$5.0</text></view>
  36. </view>
  37. <view class="left-third">
  38. <view>卡号:<text>2024110202578</text></view>
  39. </view>
  40. </view>
  41. <img class="card-right" src="https://qiniu.bms16.com/FuOJQxzypa-NginyHGdsWlzwnB8z" />
  42. </view> -->
  43. <view class="package-view" v-for="item in hireOrderList">
  44. <view class="top-view flex-row flex-between">
  45. <view class="top-title" v-if="item.package_type == 1">
  46. {{item.total_day}}天
  47. </view>
  48. <view class="top-title" v-if="item.package_type == 2">
  49. {{item.num}}次
  50. </view>
  51. <view class="top-title" v-if="item.package_type == 3">
  52. {{item.total_day}}天{{item.num}}次
  53. </view>
  54. <view v-if="item.package_status==1" class="card-text card-b">生效中</view>
  55. <view v-if="item.package_status==0" class="card-text card-o">待生效</view>
  56. <view v-if="item.package_status==2" class="card-text card-o">已结束</view>
  57. </view>
  58. <view class="package-item" style="margin-bottom: 32rpx;">
  59. <view class="item-title">有效期至</view>
  60. <view class="item-info">{{tools.formatTime(item.expire_time)}}</view>
  61. </view>
  62. <view v-if="item.package_type != 2" class="package-item" style="margin-bottom: 32rpx;">
  63. <view class="item-title">有效时长</view>
  64. <view class="item-info">
  65. {{calculateRemainingDays(item.expire_time)}}<text style="color: #9FA7B7;">/{{item.total_day}}天</text>
  66. </view>
  67. </view>
  68. <view v-if="item.package_type == 1" class="package-item">
  69. <view class="item-title">免费换电数</view>
  70. <view style="color: #060809;" class="item-info">{{item.last_num}}次</view>
  71. </view>
  72. <view v-if="item.package_type == 2" class="package-item">
  73. <view class="item-title">免费换电数</view>
  74. <view class="item-info">{{item.last_num}} <text style="color: #9FA7B7;">/{{item.num}}次</text></view>
  75. </view>
  76. <view v-if="item.package_type == 3" class="package-item">
  77. <view class="item-title">免费换电数</view>
  78. <view style="color: #060809;" class="item-info">{{item.total_day}}天/{{item.last_num}}次</view>
  79. </view>
  80. </view>
  81. </view>
  82. <view style="height: 200rpx;"></view>
  83. <view @click='srcFn' class="packageBtn">前往购买套餐</view>
  84. </view>
  85. </template>
  86. <script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
  87. <script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
  88. <script>
  89. var config = require('../../common/config_gyq.js');
  90. var common = require('../../common/common.js');
  91. var http = require('../../common/request.js');
  92. var storage = require('../../common/storage.js');
  93. const dayjs = require('dayjs');
  94. import { getRemainingTime } from '../../utils/util.js';
  95. export default {
  96. components: {
  97. },
  98. data() {
  99. return {
  100. hireOrderList:[],
  101. page: 1,
  102. limit: 10,
  103. car_info:{},
  104. // statusBarHeight: 0,
  105. // navabarHeight: 0,
  106. packageList: [
  107. {ctime: '2024-04-04 16:15',total_duration: 30,efficient_day: 24,change_rate: 6,total_times: 10,status:1},
  108. {ctime: '2024-04-04 16:15',total_duration: 30,efficient_day: 24,change_rate: 6,total_times: 10,status:2},
  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);
  140. // 计算剩余天数
  141. const remainingDays = endDate.diff(now, 'day');
  142. return remainingDays || 0;
  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>