forked from nsjcy/frontEnd/nsjcy

LAPTOP-RI7D261L\Mr Ke
2020-02-26 a92f3c4d10bebbdc55270e72ccd97cd1ba7d4e28
SunshineLnsMinApp/pages/fzpxInfo/fzpxInfo.js
@@ -10,7 +10,11 @@
   */
  data: {
    loading: false,
    peopleInfo: {}
    peopleInfo: {},
    signStatus: '',
    id: "",
    topattList:[],
    bottomattList:[]
  },
  /**
@@ -20,7 +24,8 @@
    var that = this;
    that.setData({
      id: options.id,
      flag: options.flag,
      signStatus: options.signStatus || '',
      flag: options.flag || '',
      loading: true
    });
    wx.showLoading({
@@ -37,10 +42,18 @@
        if (res.data.code == 0) {
          res.data.data.startTime = app.formatDate(res.data.data.startTime)
          that.setData({
            activity: res.data.data
            activity: res.data.data,
            bottomattList:res.data.data.attList.filter((item)=>(item.associateType==1020)),
            topattList:res.data.data.attList.filter((item)=>(item.associateType==1000))
          })
          console.log('传过来', options.flag)
          console.log('传过来', options.signStatus)
          // 处理报名状态
          if (options.signStatus) {
            that.setData({
              signStatus: options.signStatus
            })
          } else {
          if (options.flag == 'true') {
            //可报名
            console.log('可报名')
@@ -77,6 +90,7 @@
              statusWord: '您已报名'
            })
          }
          }
        }
      }
@@ -110,6 +124,52 @@
    })
  },
  // 签到
  sign: function () {
    var id = this.data.id;
    var userinfo = wx.getStorageSync("user");
    var userId = userinfo.id;
    // 只允许从相机扫码
    wx.scanCode({
      onlyFromCamera: true,
      success(res) {
        console.log(res)
        wx.showLoading({
          title: '识别中',
        })
        wx.request({
          url: app.globalData.url + '/api/activity/sign?id'+id+'&code='+res.result+'&userId='+userId,
          method: 'GET',
          header: {
            "Content-Type": "application/json"
          },
          success: function (res) {
            wx.hideLoading();
            if (res.data.code == 0) {
              wx.showToast({
                title: '签到成功!',
                icon: 'success',
                duration: 2000
              })
            } else {
              wx.showToast({
                title: '报名失败,请稍后重试!',
                icon: 'none'
              })
            }
          }
        })
      }
    })
  },
  // 返回
  goBack: function () {
    wx.navigateBack({
      delta: 1
    });
  },
  // 提交报名
  submit: function() {
    var peopleInfo = this.data.peopleInfo;