Commit 4e1a3535b2a82ca83e6a06023ac2b28b98d907b4

Authored by zhiyangdu
1 parent d361795d

关注达人

src/components/horizList/horizList.vue
... ... @@ -47,6 +47,7 @@
47 47 </swiper-item>
48 48 <shop-daren-hot v-if="com == '5'"
49 49 @userJump="userJump"
  50 + @fansShop="fansShop"
50 51 :item="item">
51 52  
52 53 </shop-daren-hot>
... ... @@ -99,6 +100,13 @@
99 100 this.$emit("userJump", item);
100 101 },
101 102 /**
  103 + * 关注
  104 + * @param {object} item [数据对象]
  105 + */
  106 + fansShop(item){
  107 + this.$emit("fansShop", item);
  108 + },
  109 + /**
102 110 * 加入购物车
103 111 * @param {object} item [数据对象]
104 112 */
... ...
src/components/shopDarenHot/shopDarenHot.vue
... ... @@ -8,10 +8,13 @@
8 8 <div class="desc">
9 9 {{item.titles}}
10 10 </div>
11   - <div class="btn">
  11 + <div v-if="item.is_fans==0" @click.stop.prevent @click="fansShop(item)" class="btn">
12 12 关注
13 13 </div>
14   - </div>
  14 + <div v-else @click.stop.prevent @click="fansShop(item)" class="btn">
  15 + 已关注
  16 + </div>
  17 + </div>
15 18 </div>
16 19 </template>
17 20  
... ... @@ -34,6 +37,13 @@
34 37 */
35 38 userJump(item) {
36 39 this.$emit("userJump", item);
  40 + },
  41 + /**
  42 + * 关注达人
  43 + * @param {object} item [数据对象]
  44 + */
  45 + fansShop(item) {
  46 + this.$emit("fansShop", item);
37 47 },
38 48 }
39 49 }
... ...
src/pages/newDaren/newDaren.vue
... ... @@ -18,7 +18,7 @@
18 18 }">
19 19 </text-title-box>
20 20 <!--导航-->
21   - <horiz-list class="components-box" v-if="shopDarenHot && shopDarenHot.length" @jump="jump" @userJump="userJump"
  21 + <horiz-list class="components-box" v-if="shopDarenHot && shopDarenHot.length" @jump="jump" @userJump="userJump" @fansShop="fansShop"
22 22 :lists="shopDarenHot"
23 23 com="5">
24 24 </horiz-list>
... ... @@ -155,7 +155,53 @@
155 155 Toast("获取优选库精选活动失败");
156 156 }
157 157 },
158   -
  158 + /**
  159 + * 关注/取消关注达人
  160 + */
  161 + fansShop(item) {
  162 + Indicator.open("加载中...");
  163 + // 判断必要参数
  164 + if (item.id && this.$route.query.uid) {
  165 + // 请求接口
  166 + this.http("/Api/" + this.getApiVersion().dynamic + "/fansShop", {
  167 + id: item.id || 0,
  168 + uid: this.$route.query.uid || 0
  169 + }, this.fansShopCallback, {
  170 + method: "post",
  171 + item
  172 + }
  173 + );
  174 + }
  175 + },
  176 +
  177 + /**
  178 + * 关注/取消关注达人回调
  179 + * @param {object} res [服务器返回数据]
  180 + * @param {object} ext [扩展参数]
  181 + */
  182 + fansShopCallback(res, ext) {
  183 +
  184 + // 加载完成
  185 + Indicator.close();
  186 + if (res.code) {
  187 + // 设置已关注
  188 + if (ext.item.is_fans == "0") {
  189 + // 关注达人
  190 + this.$set(ext.item, "is_fans", "1");
  191 + }else{
  192 + // 取消关注达人
  193 + this.$set(ext.item, "is_fans", "0");
  194 + }
  195 + }else if (res.statusCode === 200 && res.data.code == 400) {
  196 +
  197 + // 关注失败
  198 + this.showToast(res.data.message);
  199 + } else {
  200 +
  201 + // 关注失败
  202 + this.showToast("关注失败");
  203 + }
  204 + },
159 205 /**
160 206 * 调用通用跳转
161 207 * @param {object} item [通用跳转对象]
... ...