function requestSubscribeMessage(tmplIds){

  return new Promise((resolve, reject) => {
    wx.requestSubscribeMessage({
      tmplIds: tmplIds,
      success (res) {
        console.log("succ:", res)
        resolve(res)
      },
      fail(err){
        console.log("error:", err)
        let code = err.errCode
        let title = "未知错误";
        switch (code) {
          case 10001:
            title = "参数传空了"
            break;
          case 10002:
            title = "请检查您的网络"
            break;
          case 10003:
            title = "请检查您的网络"
            break;
          case 10004:
            title = "参数类型错误"
            break;
          case 10005:
            title = "无法展示 UI"
            break;
          case 20001:
            title = "没有模板数据"
            break;
          case 20002:
            title = "模板消息类型错误"
            break;
          case 20003:
            title = "模板消息数量超过上限"
            break;
          case 20004:
            title = "用户关闭了主开关，无法进行订阅"
            break;
          case 20005:
            title = "小程序被禁封"
            break;
          case 20013:
            title = "不允许通过该接口订阅设备消息"
            break;
        
          default:
            break;
        }

        // wx.showToast({
        //   title: title,
        //   icon: 'error'
        // })

        
        reject(err)
      }
    })
  })
  
}

module.exports = {
  requestSubscribeMessage
}