forked from nsjcy/frontEnd/nsjcy

liuwh
2020-02-24 2bcd556961208b80af1cb157633c594faab1eca2
SunshineLnsMinApp/pages/fzpxInfo/fzpxInfo.js
@@ -10,17 +10,19 @@
   */
  data: {
    loading: false,
    peopleInfo: {}
    peopleInfo: {},
    signStatus: '',
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
  onLoad: function (options) {
    var that = this;
    that.setData({
      id: options.id,
      flag: options.flag,
      signStatus: options.signStatus || '',
      flag: options.flag || '',
      loading: true
    });
    wx.showLoading({
@@ -28,7 +30,7 @@
    })
    wx.request({
      url: app.globalData.url + '/api/activity/find?id=' + options.id,
      success: function(res) {
      success: function (res) {
        console.log(res);
        that.setData({
          loading: false
@@ -40,42 +42,49 @@
            activity: res.data.data
          })
          console.log('传过来', options.flag)
          console.log('传过来', options.signStatus)
          // 处理报名状态
          if (options.flag == 'true') {
            //可报名
            console.log('可报名')
            if (res.data.data.activityPersonNum < res.data.data.activityPersonQuota) {
              if (res.data.data.activityStatus == 1) {
                that.setData({
                  canApply: true
                })
              }
              if (res.data.data.activityStatus == 2) {
          if (options.signStatus) {
            that.setData({
              signStatus: options.signStatus
            })
          } else {
            if (options.flag == 'true') {
              //可报名
              console.log('可报名')
              if (res.data.data.activityPersonNum < res.data.data.activityPersonQuota) {
                if (res.data.data.activityStatus == 1) {
                  that.setData({
                    canApply: true
                  })
                }
                if (res.data.data.activityStatus == 2) {
                  that.setData({
                    canApply: false,
                    statusWord: '活动正在进行'
                  })
                }
                if (res.data.data.activityStatus == 3) {
                  that.setData({
                    canApply: false,
                    statusWord: '活动已结束'
                  })
                }
              } else {
                that.setData({
                  canApply: false,
                  statusWord: '活动正在进行'
                  statusWord: '报名人数已满'
                })
              }
              if (res.data.data.activityStatus == 3) {
                that.setData({
                  canApply: false,
                  statusWord: '活动已结束'
                })
              }
            } else {
              //不可报名
              console.log('不可报名')
              that.setData({
                canApply: false,
                statusWord: '报名人数已满'
                statusWord: '您已报名'
              })
            }
          } else {
            //不可报名
            console.log('不可报名')
            that.setData({
              canApply: false,
              statusWord: '您已报名'
            })
          }
        }
@@ -84,7 +93,7 @@
  },
  // 跳转
  linkFunction: function() {
  linkFunction: function () {
    wx.showToast({
      title: '抱歉,报名人数已满',
      icon: 'none',
@@ -93,14 +102,14 @@
  },
  // 呼叫组织方
  makePhoneCall: function(e) {
  makePhoneCall: function (e) {
    var phone = e.currentTarget.dataset['phone'];
    wx.makePhoneCall({
      phoneNumber: phone
    })
  },
  inputChange: function(e) {
  inputChange: function (e) {
    var name = e.currentTarget.dataset.name;
    this.setData({
      peopleInfo: {
@@ -110,8 +119,26 @@
    })
  },
  // 签到
  sign: function () {
    // 只允许从相机扫码
    wx.scanCode({
      onlyFromCamera: true,
      success(res) {
        console.log(res)
      }
    })
  },
  // 返回
  goBack: function () {
    wx.navigateBack({
      delta: 1
    });
  },
  // 提交报名
  submit: function() {
  submit: function () {
    var peopleInfo = this.data.peopleInfo;
    var userinfo = wx.getStorageSync("user");
    var personId = userinfo.id;
@@ -149,7 +176,7 @@
      header: {
        "Content-Type": "application/json"
      },
      success: function(res) {
      success: function (res) {
        wx.hideLoading();
        if (res.data.code == 0) {
          wx.reLaunch({