monthly.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <!-- 包月 -->
  3. <view class="monthly">
  4. <z-paging class="paging" ref="paging" v-model="dataList" @query="queryList">
  5. <!-- 选项卡 -->
  6. <view class="monthly-tab" slot="top">
  7. <u-tabs :list="tabList" :is-scroll="false" :current="current" @change="tabChange" bg-color="#fff"
  8. inactive-color="#000000" active-color="#008CFF" :bold="false"
  9. :active-item-style="{color: '#008CFF'}"></u-tabs>
  10. </view>
  11. <view class="monthly-list">
  12. <view class="monthly-list-item" v-for="(monthlyItem, index) in dataList" :key="monthlyItem.id">
  13. <view class="monthly-list-item-top">
  14. <view class="mlit-left">
  15. <view>{{monthlyItem.vehicleNo}}</view>
  16. <view>{{monthlyItem.roadName}}</view>
  17. </view>
  18. <view class="mlit-right u-flex">
  19. <view class="mlit-right-item fee-status" v-if="monthlyItem.feeStatus === 0">未缴费</view>
  20. <view class="mlit-right-item fee-status" v-if="monthlyItem.feeStatus === 1">已缴费</view>
  21. <view class="mlit-right-item" v-if="monthlyItem.energyType === 1">汽油车</view>
  22. <view class="mlit-right-item" v-if="monthlyItem.energyType === 2">新能源</view>
  23. </view>
  24. </view>
  25. <view class="monthly-list-item-bottom">
  26. <view class="mlib-item">
  27. <view>有效期限</view>:
  28. <view>
  29. {{(monthlyItem.beginTime.split('-')).join('.')}}-{{(monthlyItem.endTime.split('-')).join('.')}}
  30. </view>
  31. </view>
  32. <view class="mlib-item">
  33. <view>剩余天数</view>:
  34. <view>{{monthlyItem.surplusDays}}天</view>
  35. </view>
  36. </view>
  37. <view v-if="monthlyItem.feeStatus=='0'" class="button-wrap u-flex u-row-right">
  38. <view class="tool-btn" :class="{'tool-btn-cancel': monthlyItem.feeStatus=='0'}"
  39. v-if="monthlyItem.feeStatus=='0'" @click="cancelMonth(monthlyItem.monthId)">取消订单</view>
  40. </view>
  41. <view v-else-if="monthlyItem.feeStatus == 1 && monthlyItem.surplusDays > 2"
  42. class="button-wrap u-flex u-row-right">
  43. <view class="tool-btn">已缴费</view>
  44. </view>
  45. <view v-else-if="monthlyItem.feeStatus == 1 && monthlyItem.surplusDays < 3"
  46. class="button-wrap u-flex u-row-right">
  47. <view class="tool-btn" @click="goRenewal(monthlyItem)">去续费</view>
  48. </view>
  49. </view>
  50. </view>
  51. </z-paging>
  52. <u-modal v-model="cancelShow" content="确认取消该订单?" @confirm="confirm" :show-cancel-button="true"></u-modal>
  53. <u-toast ref="uToast" />
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. tabList: [{
  61. name: '路段',
  62. value: 'road'
  63. }, {
  64. name: '停车场',
  65. value: 'park'
  66. }],
  67. current: 0,
  68. currentValue: 'road',
  69. id: '', // 当前选中的条目id
  70. cancelShow: false,
  71. dataList: [],
  72. pageSize: 10,
  73. pageNo: 1
  74. }
  75. },
  76. methods: {
  77. //tabs通知swiper切换
  78. tabChange(index) {
  79. this.current = index;
  80. this.currentValue = this.tabList[index].value
  81. this.$refs.paging.reload()
  82. },
  83. customBack() {
  84. this.$u.route({
  85. type: 'switchTab',
  86. url: 'pages/center/index'
  87. });
  88. },
  89. // 下拉刷新操作
  90. queryList(pageNo, pageSize) {
  91. const tabObj = {
  92. road: 'getMonthList',
  93. park: 'getParkMonthList'
  94. }
  95. this.$u.api[tabObj[this.currentValue]]({
  96. pageSize: pageSize,
  97. pageNum: pageNo,
  98. })
  99. .then(res => {
  100. if (res.code === 200) {
  101. this.pageNo = pageNo
  102. this.pageSize = pageSize
  103. this.$refs.paging.complete(res.data.rows);
  104. } else {
  105. this.$refs.uToast.show({
  106. title: res.msg,
  107. type: 'error',
  108. });
  109. }
  110. })
  111. },
  112. // 取消订单
  113. cancelMonth(monthId) {
  114. this.id = monthId;
  115. this.cancelShow = true;
  116. },
  117. // 确认取消订单
  118. confirm() {
  119. this.$u.api.cancelMonth({
  120. monthId: this.id,
  121. })
  122. .then(res => {
  123. if (res.code === 200) {
  124. this.$refs.uToast.show({
  125. title: res.msg,
  126. type: 'success',
  127. });
  128. this.queryList(this.pageNo, this.pageSize)
  129. } else {
  130. this.$refs.uToast.show({
  131. title: res.msg,
  132. type: 'error',
  133. });
  134. }
  135. }).catch(err => {
  136. this.$refs.uToast.show({
  137. title: '操作失败',
  138. type: 'error',
  139. });
  140. })
  141. },
  142. /**
  143. * 去续费
  144. * */
  145. goRenewal(item) {
  146. this.$u.route({
  147. url: 'pages/handleMonthly/handleMonthly',
  148. params: {
  149. roadNo: item.roadNo,
  150. vehicleNo: item.vehicleNo
  151. }
  152. })
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. @import './monthly.scss';
  159. </style>