Commit 3c60c735977e041f15f2d7883fa6fa4d91791b59
1 parent
5551d529
推荐达人页关注和取消关注
Showing
2 changed files
with
62 additions
and
4 deletions
src/components/dresserList/dresserList.vue
| ... | ... | @@ -10,8 +10,13 @@ |
| 10 | 10 | {{item.user_title || item.titles}} |
| 11 | 11 | </div> |
| 12 | 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 | 20 | </div> |
| 16 | 21 | <img v-else class="arrow_right" src="static/img/icon_arrow_right.png" /> |
| 17 | 22 | </div> |
| ... | ... | @@ -35,7 +40,14 @@ |
| 35 | 40 | */ |
| 36 | 41 | toDetail(item) { |
| 37 | 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 | 53 | </script> | ... | ... |
src/pages/recommendMore/recommendMore.vue
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | infinite-scroll-disabled="loading" |
| 18 | 18 | :infinite-scroll-distance="50"> |
| 19 | 19 | <!-- 达人列表组件 --> |
| 20 | - <dresserList @toDetail="toDetail" | |
| 20 | + <dresserList @fansShop="fansShop" @toDetail="toDetail" | |
| 21 | 21 | :dresserList="list"> |
| 22 | 22 | </dresserList> |
| 23 | 23 | </div> |
| ... | ... | @@ -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 | 180 | * @param {object} item [数据对象] |
| 135 | 181 | */ | ... | ... |