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}) }
  • 相关阅读:
    好用的电脑软件
    Swoft HTTPServer 使用经验分享
    nginx location proxy_pass详解
    kafka文档
    es 安装
    rabbitmq 文档
    Mysql百万级数据迁移,怎么迁移?实战过没?
    用bat脚本在Windows上实现微信多开
    vscode保存时自动格式化
    引入bootstrap
  • 原文地址:https://www.cnblogs.com/lsongyang/p/13539504.html
Copyright © 2011-2022 走看看