Commit abd7aa97a311bfe8e9aab82ce9d01d4a59b9d0b0

Authored by zhiyangdu
1 parent 2ecd0470

接口调用

src/pages/myGiftBox/myGiftBox.vue
@@ -17,21 +17,90 @@ @@ -17,21 +17,90 @@
17 </template> 17 </template>
18 18
19 <script> 19 <script>
  20 +// 引入组件
  21 +import { Toast, Indicator } from "mint-ui";
20 import giftItem from "@/components/giftItem/giftItem"; 22 import giftItem from "@/components/giftItem/giftItem";
21 export default { 23 export default {
22 name: "myGiftBox", 24 name: "myGiftBox",
23 data() { 25 data() {
24 return { 26 return {
25 - active: 0 27 + active: 0,
  28 + orderGiftList:null, // 礼物数据
  29 + loading: false, // 加载
  30 + pages:0 // 分页
26 }; 31 };
27 }, 32 },
28 components: { 33 components: {
29 giftItem 34 giftItem
30 }, 35 },
31 - created() {}, 36 + created() {
  37 + // 收礼订单列表
  38 + this.getorderGiftList();
  39 + },
32 methods: { 40 methods: {
33 onTap(active) { 41 onTap(active) {
34 this.active = active; 42 this.active = active;
  43 + },
  44 + /**
  45 + * 获取收礼礼物列表
  46 + */
  47 + getorderGiftList() {
  48 + this.loading = true;
  49 + this.pages++;
  50 + // 加载中提示
  51 + Indicator.open("加载中...");
  52 +
  53 + // 获取收礼礼物列表接口
  54 + this.http(
  55 + "/Api/" + this.getApiVersion().index + "/orderGiftList",
  56 + {
  57 + uid: this.$route.query.uid, // 用户id
  58 + page: this.pages, // 分页 默认为1 一页20条
  59 + type: 1, // 1 收礼列表 2 送礼列表(送礼已废弃)
  60 + status:0, // 0或者不传 全部 1 未填地址 2 未发货 3 已完成 4 已发货
  61 + },
  62 + this.getorderGiftListCallback,
  63 + {
  64 + method: "post"
  65 + }
  66 + );
  67 + },
  68 +
  69 + /**
  70 + * 获取收礼礼物列表回调
  71 + * @param {object} res [服务器返回数据]
  72 + * @param {object} ext [扩展参数]
  73 + */
  74 + getorderGiftListCallback(res, ext) {
  75 + // 加载完成
  76 + Indicator.close();
  77 +
  78 + // 返回处理
  79 + if (res.code == 200) {
  80 + // 解构数据
  81 + let { data: datas } = res;
  82 + // 设置shopFnsDynamic达人动态数据
  83 +
  84 + if (datas.list && datas.list.length) {
  85 + // 隐藏加载圈
  86 + this.loading = false;
  87 + if (this.pages > 1) {
  88 + this.$set(this, "orderGiftList", [
  89 + ...this.orderGiftList,
  90 + ...datas.list
  91 + ]);
  92 + } else {
  93 + this.$set(this, "orderGiftList", datas.list);
  94 + }
  95 + }
  96 + /* 获取达人动态数据 结束 */
  97 + } else if (res.code == 400) {
  98 + // 获取达人动态失败
  99 + Toast(res.message);
  100 + } else {
  101 + // 获取优选库精选活动失败
  102 + Toast("获取收礼订单列表失败");
  103 + }
35 } 104 }
36 } 105 }
37 }; 106 };