reservationList.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <app-layout>
  3. <view class="app-reservationList">
  4. <app-prompt-box v-if="hidden" :text="text" @click="confirmNegative"></app-prompt-box>
  5. <app-write-off-code :hidden="hiddenCode" :itemId="itemId" @hiden="hiddenCode = false"></app-write-off-code>
  6. <view class="app-nav">
  7. <app-head-navigation @click="classification"></app-head-navigation>
  8. </view>
  9. <view class="app-reservation">
  10. <app-reservation-form @click="funHandler" v-for="(item, index) in list" :key="index" :item="item"></app-reservation-form>
  11. </view>
  12. </view>
  13. </app-layout>
  14. </template>
  15. <script>
  16. import appHeadNavigation from '../components/app-head-navigation.vue';
  17. import appReservationForm from '../components/app-reservation-form.vue';
  18. import appPromptBox from '../../../components/basic-component/app-prompt-box/app-prompt-box.vue';
  19. import appWriteOffCode from '../components/app-write-off-code.vue';
  20. export default {
  21. name: 'reservationList',
  22. components: {
  23. 'app-head-navigation': appHeadNavigation,
  24. 'app-reservation-form': appReservationForm,
  25. 'app-prompt-box': appPromptBox,
  26. 'app-write-off-code': appWriteOffCode,
  27. },
  28. data() {
  29. return {
  30. list: [],
  31. page: 1,
  32. over: false,
  33. status: 0,
  34. hidden: false,
  35. text: '',
  36. confirm: false,
  37. back: '',
  38. item: null,
  39. file_path: '',
  40. hiddenCode: false,
  41. itemId: '-1'
  42. }
  43. },
  44. onLoad(options) { this.$commonLoad.onload(options);
  45. this.request(this.page, this.status);
  46. },
  47. methods: {
  48. classification(status) {
  49. this.list = [];
  50. this.status = status;
  51. this.over = false;
  52. this.page = 1;
  53. this.request(this.page, status);
  54. },
  55. request(page, status) {
  56. this.$request({
  57. url: this.$api.book.order_list,
  58. data: {
  59. page: page,
  60. status: status,
  61. }
  62. }).then(response => {
  63. if (response.code === 0) {
  64. if (response.data.list.length === 0) {
  65. this.over = true;
  66. } else {
  67. this.list = [...this.list, ...response.data.list];
  68. }
  69. }
  70. }).catch(() => {
  71. })
  72. },
  73. confirmNegative(data) {
  74. if (data) {
  75. this[this.back]();
  76. } else {
  77. this.hidden = false;
  78. }
  79. },
  80. funHandler(data, item) {
  81. this.back = data;
  82. this.item = item;
  83. if (data === 'refund') {
  84. this.text = '是否申请退款';
  85. this.hidden = true;
  86. } else if (data === 'cancel') {
  87. this.text = '是否申请取消订单';
  88. this.hidden = true;
  89. } else if (data === 'use') {
  90. this[this.back]();
  91. } else if (data === 'pay') {
  92. this.hidden = true;
  93. this.text = '申请支付';
  94. }
  95. },
  96. refund() {
  97. this.$request({
  98. url: this.$api.order.cancel,
  99. data: {
  100. id: this.item.id
  101. }
  102. }).then(response => {
  103. if (response.code === 0) {
  104. for (let i = 0; i < this.list.length; i++) {
  105. if (this.list[i].id === this.item.id) {
  106. this.$delete(this.list, i);
  107. }
  108. }
  109. this.hidden = false;
  110. }
  111. });
  112. },
  113. cancel() {
  114. this.$request({
  115. url: this.$api.order.cancel,
  116. data: {
  117. id: this.item.id,
  118. }
  119. }).then(response => {
  120. if (response.code === 0) {
  121. for (let i = 0; i < this.list.length; i++) {
  122. if (this.list[i].id === this.item.id) {
  123. this.$delete(this.list, i);
  124. }
  125. }
  126. this.hidden = false;
  127. }
  128. })
  129. },
  130. use() {
  131. this.itemId = this.item.id;
  132. this.hiddenCode = true;
  133. },
  134. pay() {
  135. this.hidden = false;
  136. this.$request({
  137. url: this.$api.order.list_pay_data,
  138. data: {
  139. id: this.item.id
  140. }
  141. }).then(response => {
  142. if (response.code === 0) {
  143. this.$payment.pay(response.data.id).then(() => {
  144. for (let i = 0; i < this.list.length; i++) {
  145. if (this.list[i].id === this.item.id) {
  146. this.$delete(this.list, i);
  147. }
  148. }
  149. }).catch(() => {
  150. });
  151. }
  152. })
  153. }
  154. },
  155. onReachBottom() {
  156. if (!this.over) {
  157. this.page+=1;
  158. this.request(this.page, this.status);
  159. }
  160. }
  161. }
  162. </script>
  163. <style scoped lang="scss">
  164. .app-reservationList {
  165. .app-nav {
  166. position: fixed;
  167. top: 0;
  168. z-index: 1500;
  169. }
  170. .app-reservation {
  171. margin-top:#{80rpx};
  172. background-color: #f7f7f7;
  173. }
  174. }
  175. </style>