SubscribeMessage.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import {
  2. SUBSCRIBE_MESSAGE
  3. } from '../config/cache.js';
  4. export function auth() {
  5. let tmplIds = {};
  6. let messageTmplIds = uni.getStorageSync(SUBSCRIBE_MESSAGE);
  7. tmplIds = messageTmplIds ? JSON.parse(messageTmplIds) : {};
  8. return tmplIds;
  9. }
  10. /**
  11. * 支付成功后订阅消息id
  12. * 订阅 确认收货通知 订单支付成功 新订单管理员提醒
  13. */
  14. export function openPaySubscribe() {
  15. let tmplIds = auth();
  16. return subscribe([
  17. tmplIds.order_pay_success,
  18. tmplIds.order_deliver_success,
  19. tmplIds.order_postage_success,
  20. ]);
  21. }
  22. /**
  23. * 订单相关订阅消息
  24. * 送货 发货 取消订单
  25. */
  26. export function openOrderSubscribe() {
  27. let tmplIds = auth();
  28. return subscribe([
  29. tmplIds.order_take,
  30. tmplIds.integral_accout,
  31. tmplIds.order_brokerage
  32. ]);
  33. }
  34. /**
  35. * 提现消息订阅
  36. * 成功 和 失败 消息
  37. */
  38. export function openExtrctSubscribe() {
  39. let tmplIds = auth();
  40. return subscribe([
  41. tmplIds.user_extract
  42. ]);
  43. }
  44. /**
  45. * 拼团成功
  46. */
  47. export function openPinkSubscribe() {
  48. let tmplIds = auth();
  49. return subscribe([
  50. tmplIds.open_pink_success,
  51. tmplIds.can_pink_success
  52. ]);
  53. }
  54. /**
  55. * 砍价成功
  56. */
  57. export function openBargainSubscribe() {
  58. let tmplIds = auth();
  59. return subscribe([
  60. tmplIds.bargain_success
  61. ]);
  62. }
  63. /**
  64. * 订单退款
  65. */
  66. export function openOrderRefundSubscribe() {
  67. let tmplIds = auth();
  68. return subscribe([
  69. tmplIds.order_refund
  70. ]);
  71. }
  72. /**
  73. * 充值成功
  74. */
  75. export function openRechargeSubscribe() {
  76. let tmplIds = auth();
  77. return subscribe([
  78. tmplIds.recharge_success
  79. ]);
  80. }
  81. /**
  82. * 调起订阅界面
  83. * array tmplIds 模板id
  84. */
  85. export function subscribe(subscrip443tionmessagee502call) {
  86. let weChat = wx;
  87. return new Promise((reslove, reject) => {
  88. weChat.requestSubscribeMessage({
  89. tmplIds: subscrip443tionmessagee502call,
  90. success(res) {
  91. return reslove(res);
  92. },
  93. fail(res) {
  94. return reslove(res);
  95. }
  96. })
  97. });
  98. }