order.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <app-layout>
  3. <view class="order">
  4. <view class="header dir-left-nowrap">
  5. <view class="header-item box-grow-1" @click="setActiveHeader(0)">
  6. <app-form-id>
  7. <text :class="{'active-item': status === 0}">
  8. 全部
  9. </text>
  10. </app-form-id>
  11. </view>
  12. <view class="header-item box-grow-1" @click="setActiveHeader(1)">
  13. <app-form-id>
  14. <text :class="{'active-item': status === 1}">
  15. 待支付
  16. </text>
  17. </app-form-id>
  18. </view>
  19. <view class="header-item box-grow-1" @click="setActiveHeader(2)">
  20. <app-form-id>
  21. <text :class="{'active-item': status === 2}">
  22. 待使用
  23. </text>
  24. </app-form-id>
  25. </view>
  26. <view class="header-item box-grow-1" @click="setActiveHeader(4)">
  27. <app-form-id>
  28. <text :class="{'active-item': status === 4}">
  29. 待评价
  30. </text>
  31. </app-form-id>
  32. </view>
  33. </view>
  34. <view class="product-list" v-if="list.length > 0">
  35. <view class="product" v-for="(item, index) in list" :key="index">
  36. <view class="top dir-left-nowrap main-between" @click.stop="jump(item)">
  37. <view class="image-content">
  38. <image :src="item.detail[0].goods_info.pic_url"></image>
  39. <view class="tip-angle" v-if="item.cancel_status == 2">
  40. 退款中
  41. </view>
  42. <view class="tip-angle" v-else-if="item.cancel_status == 1 && item.is_pay == 0">
  43. 已取消
  44. </view>
  45. <view class="tip-angle" v-else-if="item.cancel_status == 1">
  46. 已退款
  47. </view>
  48. <view class='tip-angle' v-else-if="item.is_comment == 1">
  49. 已评价
  50. </view>
  51. <view class="tip-angle" v-else-if="item.is_pay == 0">
  52. 待付款
  53. </view>
  54. <view class="tip-angle" v-else-if="item.is_confirm == 0">
  55. 待使用
  56. </view>
  57. <view class="tip-angle" v-else-if="item.is_confirm == 1">
  58. 已使用
  59. </view>
  60. </view>
  61. <view class="text-content dir-top-nowrap main-between">
  62. <view class="text-top">
  63. <view class="name">
  64. {{item.detail[0].goods_info.name}}
  65. </view>
  66. <view class="attr dir-left-nowrap">
  67. <view :key="n" v-for="(attr, n) in item.detail[0].goods_info.attr_list">
  68. {{attr.attr_group_name}}: {{attr.attr_name}}
  69. </view>
  70. </view>
  71. </view>
  72. <view class="text-bottom dir-left-nowrap main-right cross-center">
  73. <view class="original-price">¥{{item.detail[0].total_original_price}}</view>
  74. <view class="current-price">¥{{item.detail[0].total_price}}</view>
  75. </view>
  76. </view>
  77. </view>
  78. <view class="bottom dir-left-nowrap main-right cross-center"
  79. v-if="item.cancel_status === '0' && item.is_sale === '0' && item.sale_status === '0' && item.is_comment == 0"
  80. >
  81. <view class="but no" @click.stop="operationOrder(1, item)" v-if="item.cancel_status != 2 && item.is_pay == 1 && item.is_confirm == 0">
  82. <app-form-id>
  83. 申请退款
  84. </app-form-id>
  85. </view>
  86. <view class="but ok" @click.stop="operationOrder(2, item)" v-if="item.cancel_status != 2 && item.is_pay == 1 && item.is_confirm == 0">
  87. <app-form-id>
  88. 立即使用
  89. </app-form-id>
  90. </view>
  91. <view class="but ok" v-if="item.sale_status == 0 && item.is_sale == 0 && item.is_confirm == 1 && item.is_comment == 0">
  92. <app-jump-button form :url="`/pages/order/appraise/appraise?id=${item.id}`">
  93. 去评价
  94. </app-jump-button>
  95. </view>
  96. <view class="but no" @click.stop="operationOrder(3, item)" v-if="item.is_pay == 0">
  97. <app-form-id>
  98. 申请取消
  99. </app-form-id>
  100. </view>
  101. <view class="but ok" v-if="item.is_pay == 0" @click.stop="operationOrder(4, item)">
  102. <app-form-id>
  103. 去支付
  104. </app-form-id>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. <view class="model" v-if="model" @click.stop="model = false">
  110. <view class="model-content" v-if="modelType !== 2">
  111. <view class="model-title-top">提示</view>
  112. <view class="model-header" v-if="modelType === 1">是否申请退款</view>
  113. <view class="model-header" v-else-if="modelType === 3">是否申请取消订单</view>
  114. <view class="model-header" v-else-if="modelType === 4">申请支付</view>
  115. <view class="model-bottom dir-left-nowrap cross-center" v-if="modelType !== 2">
  116. <view class="model-but" @click.stop="cancle">
  117. <app-form-id>
  118. 取消
  119. </app-form-id>
  120. </view>
  121. <view class="model-line"></view>
  122. <view class="model-but" @click.stop="determine">
  123. <app-form-id>
  124. 确定
  125. </app-form-id>
  126. </view>
  127. </view>
  128. </view>
  129. <view class="model-use" v-if="modelType === 2">
  130. <view class="image" @click.stop="model = false"></view>
  131. <view class="model-title">核销码</view>
  132. <image class="model-image" :src="writeOffChart" mode="aspectFill"></image>
  133. </view>
  134. </view>
  135. </view>
  136. </app-layout>
  137. </template>
  138. <script>
  139. export default {
  140. name: "order",
  141. data() {
  142. return {
  143. status: 0,
  144. list: [],
  145. page: 1,
  146. over: false,
  147. model: false,
  148. modelType: 0,
  149. setItem: {},
  150. writeOffChart: '',
  151. }
  152. },
  153. onLoad() {
  154. this.request({
  155. status: this.status,
  156. page: this.page,
  157. }).then(res => {
  158. if (res) {
  159. this.list = res.list;
  160. }
  161. });
  162. },
  163. onReachBottom() {
  164. if (!this.over) {
  165. this.page+=1;
  166. this.pagingRequest({
  167. status: this.status,
  168. page: this.page,
  169. });
  170. }
  171. },
  172. methods: {
  173. setActiveHeader(data) {
  174. this.page = 1;
  175. this.status = data;
  176. this.over = false;
  177. this.list = [];
  178. this.request({
  179. status: this.status,
  180. page: this.page,
  181. }).then(res => {
  182. if (res) {
  183. this.list = res.list;
  184. }
  185. })
  186. },
  187. async request({status, page}) {
  188. const res = await this.$request({
  189. url: this.$api.book.order_list,
  190. data: {
  191. status,
  192. page,
  193. }
  194. });
  195. if (res.code === 0) {
  196. return res.data;
  197. } else {
  198. return false;
  199. }
  200. },
  201. operationOrder(number, data) {
  202. this.model = true;
  203. this.setItem = data;
  204. switch (number) {
  205. case 1:
  206. this.modelType = 1;
  207. break;
  208. case 2:
  209. uni.showLoading({
  210. mask: true,
  211. title: '加载中',
  212. });
  213. this.modelType = 2;
  214. this.$request({
  215. url: this.$api.book.clerk_code,
  216. data: {
  217. id: data.id,
  218. }
  219. }).then(res => {
  220. uni.hideLoading();
  221. if (res.code === 0) {
  222. this.writeOffChart = res.data.file_path;
  223. } else if (res.code === 1) {
  224. this.model = false;
  225. uni.showModal({
  226. title: '提示',
  227. content: res.msg,
  228. });
  229. }
  230. });
  231. break;
  232. case 3:
  233. this.modelType = 3;
  234. break;
  235. case 4:
  236. this.modelType = 4;
  237. break;
  238. }
  239. },
  240. pagingRequest({status, page}) {
  241. this.request({
  242. status,
  243. page,
  244. }).then(response => {
  245. if (response) {
  246. if (response.list.length > 0) {
  247. this.list = [...this.list, ...response.list];
  248. } else {
  249. this.over = true;
  250. }
  251. }
  252. })
  253. },
  254. cancle() {
  255. this.modelType = 0;
  256. this.model = false;
  257. },
  258. determine() {
  259. uni.showLoading({
  260. mask: true,
  261. title: '加载中',
  262. });
  263. switch (this.modelType) {
  264. case 1:
  265. this.$request({
  266. url: this.$api.order.cancel,
  267. data: {
  268. id: this.setItem.id,
  269. }
  270. }).then(res => {
  271. if (res.code === 0) {
  272. uni.hideLoading();
  273. this.model = false;
  274. for (let i = 0; i < this.list.length; i++) {
  275. if (this.setItem.id === this.list[i].id) {
  276. this.list[i].cancel_status = '2';
  277. if (this.status === 2) {
  278. this.$delete(this.list, i);
  279. }
  280. }
  281. }
  282. }
  283. });
  284. break;
  285. case 3:
  286. this.$request({
  287. url: this.$api.order.cancel,
  288. data: {
  289. id: this.setItem.id,
  290. }
  291. }).then(res => {
  292. if (res.code === 0) {
  293. uni.hideLoading();
  294. this.model = false;
  295. for (let i = 0; i < this.list.length; i++) {
  296. if (this.setItem.id === this.list[i].id) {
  297. this.list[i].cancel_status = '1';
  298. this.list[i].is_pay = '0';
  299. if (this.status === 1) {
  300. this.$delete(this.list, i);
  301. }
  302. }
  303. }
  304. }
  305. });
  306. break;
  307. case 4:
  308. this.$request({
  309. url: this.$api.order.list_pay_data,
  310. data: {
  311. id: this.setItem.id,
  312. }
  313. }).then(res => {
  314. if (res.code === 0) {
  315. uni.hideLoading();
  316. this.model = false;
  317. this.$payment.pay(res.data.id).then(() => {
  318. for (let i = 0; i < this.list.length; i++) {
  319. if (this.setItem.id === this.list[i].id) {
  320. this.list[i].is_pay = '1';
  321. if (this.status === 1) {
  322. this.$delete(this.list, i);
  323. }
  324. }
  325. }
  326. }).catch(() => {
  327. })
  328. }
  329. });
  330. break;
  331. }
  332. },
  333. jump(data) {
  334. this.$jump({
  335. open_type: 'navigate',
  336. url: `/plugins/book/orderDetails/orderDetails?id=${data.id}`
  337. });
  338. }
  339. }
  340. }
  341. </script>
  342. <style scoped lang="scss">
  343. @import './order.scss';
  344. </style>