export function bindInput(event) {
  var obj = {},
    key = event.target.dataset['key'];
   
  obj[key] = event.detail.value;
  obj[key]= obj[key].replace(/[^0-9]/g,'');
  console.log(obj)
  this.setData(obj);
}

let hasAuth = false
const subId = 'zWTBJFpALA3KR3qx1keYJCzJdVtRjFbxrnOJc_Htn-g'
export function subcribe() {
  
  return new Promise((resolve, reject) => {
    wx.requestSubscribeMessage({
      tmplIds: [subId],
      success(res) {
        res.subId = subId
        resolve(res)
      },
      fail(err) {
        console.log(err, '订阅消息失败')
        reject(err)
      }
    })
  })

}

export function autoSubcrebe() {
  wx.getSetting({
    withSubscriptions: true,
    success: (setting) => {
      if (setting.subscriptionsSetting.itemSettings && setting.subscriptionsSetting.itemSettings[subId]) {
        subcribe()
        return
      }
      console.log('not')
    }
  })
}