Commit 3c60c735977e041f15f2d7883fa6fa4d91791b59

Authored by zhiyangdu
1 parent 5551d529

推荐达人页关注和取消关注

src/components/dresserList/dresserList.vue
@@ -10,8 +10,13 @@ @@ -10,8 +10,13 @@
10 {{item.user_title || item.titles}} 10 {{item.user_title || item.titles}}
11 </div> 11 </div>
12 </div> 12 </div>
13 - <div v-if="item.is_fans" class="btn">  
14 - 关注 13 + <div v-if="item.is_fans">
  14 + <div v-if="item.is_fans==0" @click.stop.prevent @click="fansShop(item)" class="btn">
  15 + 关注
  16 + </div>
  17 + <div v-else @click.stop.prevent @click="fansShop(item)" class="btn">
  18 + 已关注
  19 + </div>
15 </div> 20 </div>
16 <img v-else class="arrow_right" src="static/img/icon_arrow_right.png" /> 21 <img v-else class="arrow_right" src="static/img/icon_arrow_right.png" />
17 </div> 22 </div>
@@ -35,7 +40,14 @@ @@ -35,7 +40,14 @@
35 */ 40 */
36 toDetail(item) { 41 toDetail(item) {
37 this.$emit("toDetail", item); 42 this.$emit("toDetail", item);
38 - } 43 + },
  44 + /**
  45 + * 关注达人
  46 + * @param {object} item [数据对象]
  47 + */
  48 + fansShop(item) {
  49 + this.$emit("fansShop", item);
  50 + },
39 } 51 }
40 } 52 }
41 </script> 53 </script>
src/pages/recommendMore/recommendMore.vue
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 infinite-scroll-disabled="loading" 17 infinite-scroll-disabled="loading"
18 :infinite-scroll-distance="50"> 18 :infinite-scroll-distance="50">
19 <!-- 达人列表组件 --> 19 <!-- 达人列表组件 -->
20 - <dresserList @toDetail="toDetail" 20 + <dresserList @fansShop="fansShop" @toDetail="toDetail"
21 :dresserList="list"> 21 :dresserList="list">
22 </dresserList> 22 </dresserList>
23 </div> 23 </div>
@@ -128,8 +128,54 @@ @@ -128,8 +128,54 @@
128 } 128 }
129 } 129 }
130 }, 130 },
  131 + /**
  132 + * 关注/取消关注达人
  133 + */
  134 + fansShop(item) {
  135 + Indicator.open("加载中...");
  136 + // 判断必要参数
  137 + if (item.id && this.$route.query.uid) {
  138 + // 请求接口
  139 + this.http("/Api/" + this.getApiVersion().dynamic + "/fansShop", {
  140 + id: item.id || 0,
  141 + uid: this.$route.query.uid || 0
  142 + }, this.fansShopCallback, {
  143 + method: "post",
  144 + item
  145 + }
  146 + );
  147 + }
  148 + },
131 149
132 /** 150 /**
  151 + * 关注/取消关注达人回调
  152 + * @param {object} res [服务器返回数据]
  153 + * @param {object} ext [扩展参数]
  154 + */
  155 + fansShopCallback(res, ext) {
  156 +
  157 + // 加载完成
  158 + Indicator.close();
  159 + if (res.code) {
  160 + // 设置已关注
  161 + if (ext.item.is_fans == "0") {
  162 + // 关注达人
  163 + this.$set(ext.item, "is_fans", "1");
  164 + }else{
  165 + // 取消关注达人
  166 + this.$set(ext.item, "is_fans", "0");
  167 + }
  168 + }else if (res.statusCode === 200 && res.data.code == 400) {
  169 +
  170 + // 关注失败
  171 + this.showToast(res.data.message);
  172 + } else {
  173 +
  174 + // 关注失败
  175 + this.showToast("关注失败");
  176 + }
  177 + },
  178 + /**
133 * 通用跳转 179 * 通用跳转
134 * @param {object} item [数据对象] 180 * @param {object} item [数据对象]
135 */ 181 */