// pages/com/com.js
//防止多次点击
const app = getApp();
function comButtonClicked(self) {
  var timestamp = Date.parse(new Date())/ 1000;  
  var selfTime =self.data.timestampClicked;
  if(timestamp - selfTime >= 2 || selfTime == 0){
    self.setData({
      timestampClicked: timestamp
    })
    return true;
  }else{
    console.log('2秒内多次点击')
    return false;
  }
}
//获取用户信息USERINFO 输入self 输出账号信息
function comUserInfo(self) {
  wx.request({
    url: app.globalData.serverInfo.gateWayUrl,
    header: {
      'content-type': 'application/json'
    },
    method: 'POST',
    data:{
      api_name: "get_user_info",
      login_manager_id: self
    },
    success: function(res) {
      if (res.data.state == 1) {
        wx.setStorage({
          key: 'userInfo',
          data: res.data.data
        });
      }
    }
  });
}
function comTest(self) {
 console.log('调用了com->com.js->下面的ComTest函数,并携带了数据:'+self);
}
module.exports.comButtonClicked = comButtonClicked;
module.exports.comUserInfo = comUserInfo;
module.exports.comTest = comTest;