Commit 178576ee0a40b59a4726483391648a575aa98846

Authored by zhiyangdu
1 parent a040fcf7

接口调试

src/components/swiper/swiper.vue
1 1 <template>
2   - <div class="swiper-box" v-if="swipers && swipers.list && swipers.list.length">
  2 + <div class="swiper-box" v-if="swipers && swipers.length">
3 3 <swipe class="swipe" :autoplay="5000" :show-indicators="swipers.showIndicators ? swipers.showIndicators : showIndicators" @change="onChange">
4   - <swipe-item class="swipe-item" v-for="(item, index) in swipers.list" :key="index">
5   - <div class="item" @click="toDetail(item)">
  4 + <swipe-item class="swipe-item" v-for="(item, index) in swipers" :key="index">
  5 + <div class="item" @click="$parent.toDetail(item)">
6 6 <div class="img-box">
7 7 <img v-lazy="item.simg + SIGN.BIG" class="img" mode="widthFix" />
8 8 </div>
... ... @@ -30,15 +30,6 @@
30 30 SwipeItem
31 31 },
32 32 methods: {
33   -
34   - /**
35   - * 跳转连接
36   - * @param {object} item [详情对象]
37   - */
38   - toDetail(item) {
39   - this.$emit("detail", item);
40   - },
41   -
42 33 /**
43 34 * 当swiper切换
44 35 * @param {int} index [切换swiper索引]
... ...
src/components/swiperItem/swiperItem.vue
1 1 <template>
2   - <div class="swiper-box" v-if="swipers && swipers.list && swipers.list.length">
3   - <swipe class="swipe" :autoplay="5000" :show-indicators="swipers.showIndicators ? swipers.showIndicators : showIndicators" @change="onChange">
4   - <swipe-item class="swipe-item" v-for="(item, index) in swipers.list" :key="index">
  2 + <div class="swiper-box" v-if="navs && navs.length">
  3 + <swipe class="swipe" @change="onChange">
  4 + <swipe-item class="swipe-item" v-for="(item, index) in navs" :key="index">
5 5 <div class="app_list_box">
6   - <div class="app_list" v-if="serviceList && serviceList.list && serviceList.list.length">
7   - <div v-for="(item,index) in serviceList.list" :key="index" @click="onItem(item)">
  6 + <div class="app_list">
  7 + <div v-for="(items, index) in item" :key="index" @click="$parent.toDetail(item)">
8 8 <img v-lazy="item.simg" />
9 9 <div>{{item.title}}</div>
10 10 </div>
... ... @@ -27,20 +27,12 @@
27 27 showIndicators: false
28 28 }
29 29 },
30   - props: ["swipers"],
  30 + props: ["navs"],
31 31 components: {
32 32 Swipe,
33 33 SwipeItem
34 34 },
35 35 methods: {
36   -
37   - /**
38   - * 跳转连接
39   - * @param {object} item [详情对象]
40   - */
41   - toDetail(item) {
42   -
43   - },
44 36 /**
45 37 * 当swiper切换
46 38 * @param {int} index [切换swiper索引]
... ...
src/pages/index/index.vue
1 1 <template>
2 2 <div>
3 3 <!--轮播-->
4   - <swiper></swiper>
  4 + <swiper v-if="activityAdInfo&&activityAdInfo.banner" :swipers="activityAdInfo.banner"></swiper>
5 5 <!--导航-->
6   - <swiperItem></swiperItem>
  6 + <swiperItem v-if="activityAdInfo&&activityAdInfo.nav" :navs="activityAdInfo.nav"></swiperItem>
7 7 <!--优惠专区-->
8 8 <discountZone></discountZone>
9 9 <!--天天特惠-->
... ... @@ -19,11 +19,12 @@
19 19 import discountZone from "@/components/discountZone/discountZone";
20 20 import preferential from "@/components/preferential/preferential";
21 21 import videoArea from "@/components/videoArea/videoArea";
  22 + import { Toast, Indicator } from "mint-ui";
22 23 export default {
23 24 name: 'index',
24 25 data () {
25 26 return {
26   -
  27 + activityAdInfo:null
27 28 }
28 29 },
29 30 components:{
... ... @@ -34,10 +35,64 @@
34 35 videoArea
35 36 },
36 37 created(){
37   -
  38 + this.activityAd();
38 39 },
39 40 methods: {
  41 + /**
  42 + * 调用通用跳转
  43 + * @param {object} item [通用跳转对象]
  44 + */
  45 + toDetail(item) {
  46 +
  47 + // 判断是否有通用跳转函数
  48 + if (typeof this.$parent.gotoDetail === "function") {
  49 +
  50 + // 调用通用跳转
  51 + this.$parent.gotoDetail(item);
  52 + }
  53 + },
  54 + /**
  55 + * 获取优选库精选活动
  56 + */
  57 + activityAd() {
  58 + // 加载中提示
  59 + Indicator.open("加载中...");
40 60  
  61 + // 获取证书请求接口
  62 + this.http(
  63 + "/Api/" + this.getApiVersion().index + "/activityAd",
  64 + {
  65 +// id: this.$route.query.id
  66 + id: 20
  67 + },
  68 + this.activityAdCallback,
  69 + {
  70 + method: "post"
  71 + }
  72 + );
  73 + },
  74 + /**
  75 + * 获取优选库精选活动
  76 + * @param {object} res [服务器返回数据]
  77 + * @param {object} ext [扩展参数]
  78 + */
  79 + activityAdCallback(res, ext) {
  80 + // 加载完成
  81 + Indicator.close();
  82 + // 返回处理
  83 + if (res.code == 200) {
  84 + // 解构数据
  85 + let { data: datas } = res;
  86 + /* 获取获取证书信息 开始 */
  87 + this.activityAdInfo = res.data;
  88 + } else if (res.code == 400) {
  89 + // 获取证书信息失败
  90 + Toast(res.message);
  91 + } else {
  92 + // 获取证书信息计划失败
  93 + Toast("获取优选库精选活动失败");
  94 + }
  95 + },
41 96 }
42 97 }
43 98 </script>
... ...