zoukankan      html  css  js  c++  java
  • vue 关注已关注按钮切换

    <view class="feature-info">
    <view class="feature-list info-row">

      <text v-if="isFollow == 1" class="attention" @click="unsubscribe()">已关注</text>   <text v-if="isFollow == 0" class="attention" @click="subscribe()">关注</text>

    </view> </view>
          data() {
                return {
                    isFollow: 0,
                };
            unsubscribe() {
                    new ShopService().unfollowCoach(this.id).then((data: any) => {
                        if (data.code == 1) {
                            uni.showToast({
                                title: data.msg,
                            });
                            this.isFollow = 0;
                        } else {
                            uni.showToast({
                                title: data.msg,
                            });
                        }
                    }).catch((error: any) => {
                        uni.hideLoading()
                    });
                },
                subscribe() {
                    new ShopService().followCoach(this.id).then((data: any) => {
                        if (data.code == 1) {
                            uni.showToast({
                                title: data.msg,
                            });
                            this.isFollow = 1;
                        } else {
                            uni.showToast({
                                title: data.msg,
                            });
                        }
                    }).catch((error: any) => {
                        uni.hideLoading()
                    });
                },
    shopservice.ts

    // 关注教练 public followCoach(id: any):Promise<any> {//传id return super.post('/api.php/shop/Coach/coachSubscribe',{id: id}) } // 取消关注教练 public unfollowCoach(id: any):Promise<any> { return super.post('/api.php/shop/Coach/unsubscribe',{id: id}) }
  • 相关阅读:
    python的高级特性
    python方向
    快速搜索
    计算机组成原理——总线
    计算机组成原理——指令系统
    计算机组成原理——cpu
    计算机组成原理——2
    git提交时报错处理办法
    快速的在linux服务器上安装jdk8
    python的包管理软件Conda的用法
  • 原文地址:https://www.cnblogs.com/lsongyang/p/13539504.html
Copyright © 2011-2022 走看看