order.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <app-layout>
  3. <view class="order page-width">
  4. <!-- 切换 -->
  5. <view class="page-width switch-tab">
  6. <switch-tab
  7. v-bind:theme="theme"
  8. v-on:setTab="setTab"
  9. ></switch-tab>
  10. </view>
  11. <!-- 我送出订单列表 -->
  12. <view class="page-width order-list" v-if="tab_status === 0">
  13. <order-list
  14. v-bind:theme="theme"
  15. v-bind:big_gift_pic="big_gift_pic"
  16. v-bind:tab_status="tab_status"
  17. v-bind:order_list="list"
  18. ></order-list>
  19. </view>
  20. <!-- 我收到的 -->
  21. <view class="page-width order-win-list" v-if="tab_status === 1">
  22. <order-win-list
  23. v-bind:theme="theme"
  24. v-bind:tab_status="tab_status"
  25. v-bind:order_list="list"
  26. v-on:setShare="setShare"
  27. v-on:receipt="receipt"
  28. ></order-win-list>
  29. </view>
  30. <!-- 我参与的 -->
  31. <view class="page-width order-involved-list" v-if="tab_status === 2">
  32. <order-involved-list
  33. v-bind:order_list="list"
  34. v-bind:big_gift_pic="big_gift_pic"
  35. v-bind:tab_status="tab_status"
  36. v-on:setShare="setShare"
  37. v-on:receipt="receipt"
  38. ></order-involved-list>
  39. </view>
  40. <!-- 空白格 -->
  41. <view class="page-width empty-nav">
  42. <app-empty-bottom
  43. backgroundColor="#f7f7f7"
  44. v-bind:height="Number(96)"
  45. ></app-empty-bottom>
  46. </view>
  47. <!-- 导航 -->
  48. <view class="page-width gift-navigation">
  49. <gift-navigation
  50. v-bind:theme="theme"
  51. ></gift-navigation>
  52. </view>
  53. <!-- 分享海报 -->
  54. <view class="page-width share-poster">
  55. <app-share-qr-code-poster @share="hShareAppMessage" v-bind:isHidden="false" v-bind:url="shareUrl" v-model="share"></app-share-qr-code-poster>
  56. </view>
  57. </view>
  58. </app-layout>
  59. </template>
  60. <script>
  61. import { mapState } from 'vuex';
  62. import giftNavigation from '../components/announcement/gift-navigation.vue';
  63. import switchTab from '../components/order/switch-tab.vue';
  64. import orderList from '../components/order/order-list.vue';
  65. import appEmptyBottom from'../../../components/basic-component/app-empty-bottom/app-empty-bottom.vue';
  66. import orderWinList from '../components/order/order-win-list.vue';
  67. import orderInvolvedList from '../components/order/order-involved-list.vue';
  68. import appShareQrCodePoster from '../../../components/page-component/app-share-qr-code-poster/app-share-qr-code-poster.vue';
  69. export default {
  70. name: 'order',
  71. data() {
  72. return {
  73. tab_status: 0,
  74. list: [],
  75. page_count: 1,
  76. page: 1,
  77. url: ``,
  78. share: false,
  79. shareUrl: ``,
  80. gift_id: -1,
  81. turn_no: '',
  82. share_img: '',
  83. bless_word: ''
  84. }
  85. },
  86. onLoad() { this.$commonLoad.onload();
  87. this.list = [];
  88. this.url = this.$api.gift.send_list;
  89. this.$nextTick(() => {
  90. this.request();
  91. });
  92. },
  93. // #ifdef MP
  94. onShareAppMessage(e) {
  95. if (e.from === 'button') {
  96. return this.$shareAppMessage({
  97. path: '/plugins/gift/index/index',
  98. imageUrl: this.share_img,
  99. // #ifdef MP-ALIPAY
  100. bgImgUrl: this.share_img,
  101. // #endif
  102. title: this.bless_word,
  103. params: {
  104. gift_id: this.gift_id,
  105. turn_no: this.turn_no,
  106. }
  107. });
  108. } else {
  109. return this.$shareAppMessage({
  110. path: '/plugins/gift/index/index',
  111. title: this.bless_word,
  112. imageUrl: this.big_gift_pic,
  113. });
  114. }
  115. },
  116. // #endif
  117. // 下拉加载
  118. onReachBottom() {
  119. if (this.page < this.page_count) {
  120. this.page++;
  121. this.request();
  122. }
  123. },
  124. methods: {
  125. hShareAppMessage(s = false) {
  126. return this.$shareAppMessage({
  127. path: '/plugins/gift/index/index',
  128. imageUrl: this.share_img,
  129. // #ifdef MP-ALIPAY
  130. bgImgUrl: this.share_img,
  131. // #endif
  132. title: this.bless_word,
  133. params: {
  134. gift_id: this.gift_id,
  135. turn_no: this.turn_no,
  136. }
  137. },s);
  138. },
  139. // 切换请求
  140. setTab(data) {
  141. this.tab_status = data;
  142. this.list = [];
  143. this.page = 1;
  144. switch(data) {
  145. case 0:
  146. this.url = this.$api.gift.send_list;
  147. break;
  148. case 1:
  149. this.url = this.$api.gift.my_win;
  150. break;
  151. case 2:
  152. this.url = this.$api.gift.my_join;
  153. }
  154. this.request();
  155. },
  156. async request() {
  157. this.$utils.showLoading();
  158. try {
  159. const res = await this.$request({
  160. url: this.url,
  161. methods: 'get',
  162. data: {
  163. page: this.page,
  164. }
  165. });
  166. if (res.code === 0) {
  167. this.list.push( ...res.data.list);
  168. this.page_count = res.data.pagination.page_count;
  169. } else {
  170. uni.showModal({
  171. title: '提示',
  172. content: res.msg,
  173. })
  174. }
  175. this.$utils.hideLoading();
  176. } catch (e) {
  177. this.$utils.hideLoading();
  178. throw new Error(e);
  179. }
  180. },
  181. async setShare(data) {
  182. this.$utils.showLoading();
  183. const res = await this.$request({
  184. url: this.$api.gift.turn,
  185. data: {
  186. id: data.id,
  187. }
  188. });
  189. if (res.code === 0) {
  190. this.turn_no = res.data.turn_no;
  191. this.gift_id = data.gift_id;
  192. this.bless_word = data.bless_word;
  193. if (data.item.is_big_gift === 1) {
  194. this.share_img = this.big_gift_pic;
  195. } else {
  196. this.share_img = data.item.detail[0].cover_pic;
  197. }
  198. this.share = true;
  199. } else {
  200. uni.showModal({
  201. title: '提示',
  202. content: res.msg,
  203. })
  204. }
  205. this.$utils.hideLoading();
  206. },
  207. receipt(index) {
  208. let _this = this;
  209. uni.showModal({
  210. title: '提示',
  211. content: '确认收货',
  212. success: function(res) {
  213. if (res.confirm) {
  214. _this.$request({
  215. url: _this.$api.order.confirm,
  216. data: {
  217. id: _this.list[index].giftOrder[0].order_id,
  218. }
  219. }).then(res => {
  220. if (res.code === 0) {
  221. _this.list[index].status = '已完成';
  222. _this.list[index].status_num = 7;
  223. }
  224. })
  225. }
  226. }
  227. })
  228. }
  229. },
  230. computed: {
  231. ...mapState('gift',{
  232. theme: state => state.theme,
  233. big_gift_pic: state => state.big_gift_pic,
  234. }),
  235. },
  236. components: {
  237. 'gift-navigation': giftNavigation,
  238. 'switch-tab': switchTab,
  239. 'order-list': orderList,
  240. 'app-empty-bottom': appEmptyBottom,
  241. 'order-win-list': orderWinList,
  242. 'order-involved-list': orderInvolvedList,
  243. 'app-share-qr-code-poster': appShareQrCodePoster,
  244. },
  245. }
  246. </script>
  247. <style scoped lang="scss">
  248. @import '../css/gift.scss';
  249. /*订单页面*/
  250. .order {
  251. position: absolute;
  252. height: 100%;
  253. top: 0;
  254. left: 0;
  255. background-color: #f7f7f7;
  256. }
  257. /*状态开关*/
  258. .switch-tab {
  259. position: fixed;
  260. top: 0;
  261. left: 0;
  262. z-index: 1500;
  263. }
  264. /*订单列表*/
  265. .order-list {
  266. margin-top: #{115upx};
  267. }
  268. .order-win-list {
  269. margin-top: #{115upx};
  270. }
  271. .order-involved-list {
  272. margin-top: #{115upx};
  273. }
  274. </style>