导航栏切换,发不同请求,但里面操作一样的情况

59 阅读1分钟

1661090892936.jpg

    getListData() {
      //先定义一个函数接住我们需要做的操作
      const thenCallBack = (res) => {
        this.radioId = ''
        this.currentRow = {}
        this.listData = res.data.list.map((v) => {
          //后端传给我们的图片是一个数组的情况
          //因为头部两栏请求回来的字段不同,我们就需要先做处理了在赋值给我们定义的这个变量 proImg 去统一展示
          v.proImg =
            (Array.isArray(v.headerImgs) ? v.headerImgs[0] : '') ||
            (Array.isArray(v.planImgList) ? v.planImgList[0] : '')
            //每一需要展示的值都要先做处理
          v.proName = v.goodsName || v.planName
          v.proPrice = v.discountPrice || v.planPrice
          v.proSales = v.sales || v.planSales
          return v
        })
        this.query.total = Number(res.data.total)
      }
 if (this.activeName == 0) {
        goodsPage({
          goodsName: this.query.title,
          goodsTypeId: this.query.navTabsId,
          seriesId: this.query.slideTabsId,
          page: this.query.pageNum,
          pageSize: this.query.pageSize,
          isDelete: 0,
          stewardStatus: 1,
        }).then(thenCallBack)
      }

      if (this.activeName == 1) {
        stewardPlanPageList({
          planName: this.query.title,
          classifyId: this.query.navTabsId, //从4接口把返回的id值传过来
          functionId: this.query.slideTabsId, //从5接口把返回的id值传回来
          page: this.query.pageNum,
          pageSize: this.query.pageSize,
          source: 0, //固定值
          isDelete: 0,
        }).then(thenCallBack)
      }
    },