subscribe-page.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const QIWEI_MONTHLY_PRICE = 200;
  2. const SEAT_PLANS = [
  3. { seats: 1, label: '1 个号', note: '个人试用' },
  4. { seats: 3, label: '3 个号', note: '小团队' },
  5. { seats: 10, label: '10 个号', note: '成长团队', recommended: true },
  6. { seats: 20, label: '20 个号', note: '中型团队' },
  7. { seats: 50, label: '50 个号', note: '大型团队' }
  8. ];
  9. const DURATION_PLANS = [
  10. { months: 1, label: '1 个月' },
  11. { months: 6, label: '6 个月' },
  12. { months: 12, label: '12 个月' }
  13. ];
  14. const ERROR_CODES = {
  15. 'QW-AUTH-401': { http: 401, title: '认证失败', tip: '鉴权 token 无效或已过期,请检查 QIWEI_AUTH_TOKEN 后重试。' },
  16. 'QW-PAY-402': { http: 402, title: '飞马余额不足', tip: '账户余额不足以完成本次订阅扣费,请先充值飞马余额。' },
  17. 'QW-SUB-402': { http: 402, title: '订阅未开通或已到期', tip: '请在动态流程页选择席位并完成开通,扣费成功后即可继续登录。' },
  18. 'QW-SEAT-403': { http: 403, title: '席位已满', tip: '当前订阅席位已全部占用,请增购席位或停用闲置设备。' },
  19. 'QW-UP-502': { http: 502, title: '企业微信服务暂时不可用', tip: '网关或上游服务异常,请稍后重试。' }
  20. };
  21. function classifySubscribeError(httpStatus, message) {
  22. const text = String(message || '');
  23. if (httpStatus === 401 || /认证失败|unauthorized/i.test(text)) return 'QW-AUTH-401';
  24. if (/余额不足/.test(text)) return 'QW-PAY-402';
  25. if (httpStatus === 402) return 'QW-SUB-402';
  26. if (httpStatus === 403 || /席位/.test(text)) return 'QW-SEAT-403';
  27. return 'QW-UP-502';
  28. }
  29. module.exports = {
  30. QIWEI_MONTHLY_PRICE,
  31. SEAT_PLANS,
  32. DURATION_PLANS,
  33. ERROR_CODES,
  34. classifySubscribeError
  35. };