VapplicationList.js 4.3 KB
import {
  request
} from "../../request/index.js"
const a = getApp()
Page({
  data: {
    baseUrl: a.globalData.baseUrl,
    statusTop: a.globalData.statusHeight,
    imagesUrl: a.globalData.imagesUrl,
    four: 4,
    msg: '',
    per: 1,
    che_id: '',
    perList: [],
    it_cloose: false,
  },
  onLoad: function (options) {
    let that = this
    //  console.log(options);
    that.setData({
      che_id: options.che_id,
    })
    that.getPersonList()
  },
  onShow: function () {},
  goback() {
    wx.navigateBack()
  },
  async getPersonList() {
    let that = this
    try {
      const {
        data: {
          data
        }
      } = await request({
        url: 'api/my2/shenList',
        data: {
          che_id: that.data.che_id
        }
      })
      //  console.log(data);
      if (data.length == 0) {
        that.setData({
          it_cloose: true
        })
      }
      that.setData({
        perList: data,
      })
    } catch (err) {
      //  console.log(err);
      that.setData({
        msg: err.msg
      })
      that.popTest()
    }
  },
  async truePerson(e) {
    let that = this
    let id = e.currentTarget.dataset.id
    let per = Number(that.data.per)
    if (per > 3) {
      wx.showModal({
        title: '',
        content: '团队已达人数上限,请移出多余团队成员后再进行添加',
        success: function (res) {
          if (res.confirm) {
            wx.navigateTo({
              url: '/pages/VmyTeam/VmyTeam'
            })
          } else {

          }
        }
      })
    } else {

      try {
        const {
          data
        } = await request({
          url: 'api/my2/shenAgree',
          data: {
            id: id,
            che_id: that.data.che_id,
            type: 1,
          }
        })
        //  console.log(data);
        if (data.code == 1) {
          that.setData({
            msg: data.msg
          })
          that.popSuccessTest()
          setTimeout(() => {
            that.getPersonList()
          }, 1000);

        } else {
          that.setData({
            msg: data.msg
          })
          that.popTest()
        }

      } catch (err) {
        //  console.log(err);
        that.setData({
          msg: err.msg,
          msg: '团队已达人数上限,请移出多余团队成员后再进行添加'
        })
        that.popTest()
      }
    }
  },
  async falsePerson(e) {
    let id = e.currentTarget.dataset.id
    let that = this
    try {
      const {
        data
      } = await request({
        url: 'api/my2/shenAgree',
        data: {
          id: id,
          che_id: that.data.che_id,
          type: 0,
        }
      })
      //  console.log(data);
      if (data.code == 1) {
        that.setData({
          msg: data.msg
        })
        that.popSuccessTest()
        setTimeout(() => {
          that.getPersonList()
        }, 1000);
      } else {
        that.setData({
          msg: data.msg
        })
        that.popTest()
      }

    } catch (err) {
      //  console.log(err);
      that.setData({
        msg: err.msg
      })
      that.popTest()
    }
  },















  async public() {
    let that = this
    try {
      const {
        data: {
          data
        }
      } = await request({
        url: '',
        data: {
          goods_id: that.data.goods_id
        }
      })
      //  console.log(data);
      that.setData({
        public: data
      })
    } catch (err) {
      //  console.log(err);
      that.setData({
        msg: err.msg
      })
      that.popTest()
    }
  },
  popTest() {
    wx.showToast({
      title: this.data.msg,
      icon: 'none', //如果要纯文本,不要icon,将值设为'none'
      duration: 1300
    })
  },
  goLogin() {
    wx.showModal({
      title: '提示',
      content: '您尚未登录,前往登录',
      success: function (res) {
        if (res.confirm) {
          wx.navigateTo({
            // url: '/pages/authorization/authorization'
          })

        } else {
          wx.switchTab({
            url: '/pages/home/home'
          })
        }
      }
    })
  },
  popSuccessTest() {
    wx.showToast({
      title: this.data.msg,
      icon: '', //默认值是success,就算没有icon这个值,就算有其他值最终也显示success
      duration: 1300, //停留时间
    })
  },
})