收藏
回答

setData()失效?

  markertap: function(e) {
    var that = this;
    var id;
    var temp = false;
    var pindex;
    if (typeof(e) != undefined && typeof(e) == "string") {
      //分类tab跳转
      id = e;
      temp = true;
    } else if (typeof(e.markerId) != undefined) {
      //气泡点击
      id = e.markerId;
    }
    for (var i = 0; i < that.data.markers.length; i++) {
      if (that.data.markers[i].id == id) {
        pindex = i;
        break;
      }
    }
    //图标变回
    if (that.data.detailPId != -1 && pindex != that.data.detailPId) {
      that.changeMarker(false, that.data.markers, that.data.detailPId, that.data.project)
    }
    wx: wx.request({
      url: 'https://www.s**h.com/project/form/' + id,
      header: {
        'content-type': 'application/json' // 默认值
      },
      method: 'post',
      success: function(res) {
        if (res.statusCode == 200) {
          that.setData({
            project: res.data.data,
            flag: false,
            markers: that.changeMarker(true, that.data.markers, pindex, res.data.data),
            detailPId: pindex
          })
          if (temp) {
            that.setData({
              scale: 17,
              latitude: res.data.data.coordinates.split(",")[1],
              longitude: res.data.data.coordinates.split(",")[0]
            })
          }
        }
      },
    });
    that.getPictures(id).then(function (result) {
      console.log(result)//该部分打印返回值成功 但是无法set成功值
      if (result.datas.length < 1) {
        that.setData({
          pictures: result.datas,
          fullPictures: that.getFullPictures(result.datas),
          height: "48%"
        })
      } else {
        that.setData({
          pictures: result.datas,
          fullPictures: that.getFullPictures(result.datas),
          height: "75%"
        })
      }
    })
  },
打印结果

同时该方法结束后AppData中的该值未发生变化

最后一次编辑于  2020-01-19
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签