monthly.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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
  8. :list="tabList"
  9. :is-scroll="false"
  10. :current="current"
  11. @change="tabChange"
  12. bg-color="#fff"
  13. inactive-color="#000000"
  14. active-color="#008CFF"
  15. :bold="false"
  16. :active-item-style="{ color: '#008CFF' }"
  17. ></u-tabs>
  18. </view>
  19. <view class="monthly-list">
  20. <view class="monthly-list-item" v-for="(monthlyItem, index) in dataList" :key="index">
  21. <view class="monthly-list-item-top">
  22. <view class="mlit-left">
  23. <view>{{ monthlyItem.vehicleNo }}</view>
  24. <view>{{ monthlyItem.roadName || monthlyItem.parkName }}</view>
  25. </view>
  26. <view class="mlit-right u-flex">
  27. <view class="mlit-right-item fee-status" v-if="monthlyItem.feeStatus === 0">未缴费</view>
  28. <view class="mlit-right-item fee-status" v-if="monthlyItem.feeStatus === 1">已缴费</view>
  29. <view class="mlit-right-item" v-if="monthlyItem.energyType === 1">汽油车</view>
  30. <view class="mlit-right-item" v-if="monthlyItem.energyType === 2">新能源</view>
  31. </view>
  32. </view>
  33. <view class="monthly-list-item-bottom">
  34. <view class="mlib-item">
  35. <view>有效期限</view>:
  36. <view> {{ monthlyItem.beginTime.split('-').join('.') }}-{{ monthlyItem.endTime.split('-').join('.') }} </view>
  37. </view>
  38. <view class="mlib-item">
  39. <view>剩余天数</view>:
  40. <view>{{ monthlyItem.surplusDays }}天</view>
  41. </view>
  42. </view>
  43. <view v-if="monthlyItem.feeStatus == '0'" class="button-wrap u-flex u-row-right">
  44. <view
  45. class="tool-btn"
  46. :class="{ 'tool-btn-cancel': monthlyItem.feeStatus == '0' }"
  47. v-if="monthlyItem.feeStatus == '0'"
  48. @click="cancelMonth(monthlyItem.monthId)"
  49. >取消订单</view
  50. >
  51. <view class="tool-btn pay-btn" v-if="monthlyItem.feeStatus == '0'" @click="goMonthPay(monthlyItem)">重新支付</view>
  52. </view>
  53. <view v-else-if="monthlyItem.feeStatus == 1 && monthlyItem.surplusDays > 2" class="button-wrap u-flex u-row-right">
  54. <view class="tool-btn">已缴费</view>
  55. </view>
  56. <view v-else-if="monthlyItem.feeStatus == 1 && monthlyItem.surplusDays < 3" class="button-wrap u-flex u-row-right">
  57. <view class="tool-btn" @click="goRenewal(monthlyItem)">去续费</view>
  58. </view>
  59. </view>
  60. </view>
  61. </z-paging>
  62. <u-modal ref="uModal" v-model="cancelShow" content="确认取消该订单?" :async-close="true" @confirm="confirm" :show-cancel-button="true"></u-modal>
  63. <u-toast ref="uToast" />
  64. </view>
  65. </template>
  66. <script>
  67. export default {
  68. data() {
  69. return {
  70. tabList: [
  71. {
  72. name: '路段',
  73. value: 'road'
  74. },
  75. {
  76. name: '停车场',
  77. value: 'park'
  78. }
  79. ],
  80. current: 0,
  81. currentValue: 'road',
  82. id: '', // 当前选中的条目id
  83. cancelShow: false,
  84. dataList: [],
  85. pageSize: 10,
  86. pageNo: 1
  87. };
  88. },
  89. onLoad(page) {
  90. const obj = {
  91. road: 0,
  92. park: 1
  93. };
  94. if (page.type) {
  95. this.current = obj[page.type];
  96. }
  97. },
  98. onShow() {
  99. this.$nextTick(() => {
  100. this.$refs.paging.reload();
  101. });
  102. },
  103. onBackPress(options) {
  104. this.$u.route({
  105. type: 'switchTab',
  106. url: 'pages/center/index'
  107. });
  108. return true;
  109. },
  110. methods: {
  111. //tabs通知swiper切换
  112. tabChange(index) {
  113. this.current = index;
  114. this.currentValue = this.tabList[index].value;
  115. this.$refs.paging.reload();
  116. },
  117. // 下拉刷新操作
  118. queryList(pageNo, pageSize) {
  119. const tabObj = {
  120. road: 'getMonthList',
  121. park: 'getParkMonthList'
  122. };
  123. this.$u.api[tabObj[this.currentValue]]({
  124. pageSize: pageSize,
  125. pageNum: pageNo,
  126. ifPark: this.current
  127. }).then((res) => {
  128. if (res.code === 200) {
  129. this.pageNo = pageNo;
  130. this.pageSize = pageSize;
  131. this.$refs.paging.complete(res.data.rows);
  132. } else {
  133. this.$refs.uToast.show({
  134. title: res.msg,
  135. type: 'error'
  136. });
  137. }
  138. });
  139. },
  140. // 取消订单
  141. cancelMonth(monthId) {
  142. this.id = monthId;
  143. this.cancelShow = true;
  144. },
  145. // 重新支付
  146. goMonthPay(item) {
  147. const params = {
  148. vehicleNo: item.vehicleNo,
  149. monthId: item.monthId
  150. };
  151. if (this.current === 0) {
  152. params.roadNo = item.roadNo;
  153. } else {
  154. params.parkNo = item.parkNo;
  155. }
  156. this.$u.route({
  157. url: 'pages/handleMonthly/handleMonthly',
  158. params
  159. });
  160. },
  161. // 确认取消订单
  162. confirm() {
  163. this.$u.api
  164. .cancelMonth({
  165. monthId: this.id
  166. })
  167. .then((res) => {
  168. if (res.code === 200) {
  169. this.$refs.uToast.show({
  170. title: res.msg,
  171. type: 'success'
  172. });
  173. this.queryList(this.pageNo, this.pageSize);
  174. } else {
  175. this.$refs.uToast.show({
  176. title: res.msg,
  177. type: 'error'
  178. });
  179. }
  180. this.$refs['uModal'].clearLoading();
  181. this.cancelShow = false
  182. })
  183. .catch((err) => {
  184. this.$refs['uModal'].clearLoading();
  185. this.$refs.uToast.show({
  186. title: '操作失败',
  187. type: 'error'
  188. });
  189. });
  190. },
  191. /**
  192. * 去续费
  193. * */
  194. goRenewal(item) {
  195. const params = {
  196. vehicleNo: item.vehicleNo
  197. };
  198. if (this.current === 0) {
  199. params.roadNo = item.roadNo;
  200. } else {
  201. params.parkNo = item.parkNo;
  202. }
  203. this.$u.route({
  204. url: 'pages/handleMonthly/handleMonthly',
  205. params
  206. });
  207. }
  208. }
  209. };
  210. </script>
  211. <style lang="scss" scoped>
  212. @import './monthly.scss';
  213. </style>