monthly.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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 || monthlyItem.parkName}}</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 class="tool-btn pay-btn" v-if="monthlyItem.feeStatus=='0'"
  41. @click="goMonthPay(monthlyItem)">重新支付</view>
  42. </view>
  43. <view v-else-if="monthlyItem.feeStatus == 1 && monthlyItem.surplusDays > 2"
  44. class="button-wrap u-flex u-row-right">
  45. <view class="tool-btn">已缴费</view>
  46. </view>
  47. <view v-else-if="monthlyItem.feeStatus == 1 && monthlyItem.surplusDays < 3"
  48. class="button-wrap u-flex u-row-right">
  49. <view class="tool-btn" @click="goRenewal(monthlyItem)">去续费</view>
  50. </view>
  51. </view>
  52. </view>
  53. </z-paging>
  54. <u-modal v-model="cancelShow" content="确认取消该订单?" @confirm="confirm" :show-cancel-button="true"></u-modal>
  55. <u-toast ref="uToast" />
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. tabList: [{
  63. name: '路段',
  64. value: 'road'
  65. }, {
  66. name: '停车场',
  67. value: 'park'
  68. }],
  69. current: 0,
  70. currentValue: 'road',
  71. id: '', // 当前选中的条目id
  72. cancelShow: false,
  73. dataList: [],
  74. pageSize: 10,
  75. pageNo: 1
  76. }
  77. },
  78. onLoad(page) {
  79. const obj = {
  80. road: 0,
  81. park: 1
  82. }
  83. if (page.type) {
  84. this.current = obj[page.type]
  85. }
  86. },
  87. onShow() {
  88. this.$nextTick(() => {
  89. this.$refs.paging.reload()
  90. })
  91. },
  92. onBackPress(options) {
  93. this.$u.route({
  94. type: 'switchTab',
  95. url: 'pages/center/index'
  96. });
  97. return true;
  98. },
  99. methods: {
  100. //tabs通知swiper切换
  101. tabChange(index) {
  102. this.current = index;
  103. this.currentValue = this.tabList[index].value
  104. this.$refs.paging.reload()
  105. },
  106. // 下拉刷新操作
  107. queryList(pageNo, pageSize) {
  108. const tabObj = {
  109. road: 'getMonthList',
  110. park: 'getParkMonthList'
  111. }
  112. this.$u.api[tabObj[this.currentValue]]({
  113. pageSize: pageSize,
  114. pageNum: pageNo,
  115. ifPark: this.current
  116. })
  117. .then(res => {
  118. if (res.code === 200) {
  119. this.pageNo = pageNo
  120. this.pageSize = pageSize
  121. this.$refs.paging.complete(res.data.rows);
  122. } else {
  123. this.$refs.uToast.show({
  124. title: res.msg,
  125. type: 'error',
  126. });
  127. }
  128. })
  129. },
  130. // 取消订单
  131. cancelMonth(monthId) {
  132. this.id = monthId;
  133. this.cancelShow = true;
  134. },
  135. // 重新支付
  136. goMonthPay(item) {
  137. const params = {
  138. vehicleNo: item.vehicleNo,
  139. monthId: item.monthId
  140. }
  141. if (this.current === 0) {
  142. params.roadNo = item.roadNo
  143. } else {
  144. params.parkNo = item.parkNo
  145. }
  146. this.$u.route({
  147. url: 'pages/handleMonthly/handleMonthly',
  148. params
  149. })
  150. },
  151. // 确认取消订单
  152. confirm() {
  153. this.$u.api.cancelMonth({
  154. monthId: this.id,
  155. })
  156. .then(res => {
  157. if (res.code === 200) {
  158. this.$refs.uToast.show({
  159. title: res.msg,
  160. type: 'success',
  161. });
  162. this.queryList(this.pageNo, this.pageSize)
  163. } else {
  164. this.$refs.uToast.show({
  165. title: res.msg,
  166. type: 'error',
  167. });
  168. }
  169. }).catch(err => {
  170. this.$refs.uToast.show({
  171. title: '操作失败',
  172. type: 'error',
  173. });
  174. })
  175. },
  176. /**
  177. * 去续费
  178. * */
  179. goRenewal(item) {
  180. const params = {
  181. vehicleNo: item.vehicleNo
  182. }
  183. if (this.current === 0) {
  184. params.roadNo = item.roadNo
  185. } else {
  186. params.parkNo = item.parkNo
  187. }
  188. this.$u.route({
  189. url: 'pages/handleMonthly/handleMonthly',
  190. params
  191. })
  192. }
  193. }
  194. }
  195. </script>
  196. <style lang="scss" scoped>
  197. @import './monthly.scss';
  198. </style>