SubscribeMessage.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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.oreder_takever,
  18. tmplIds.order_pay_success,
  19. tmplIds.order_new,
  20. ]);
  21. }
  22. /**
  23. * 订单相关订阅消息
  24. * 送货 发货 取消订单
  25. */
  26. export function openOrderSubscribe() {
  27. let tmplIds = auth();
  28. return subscribe([
  29. tmplIds.order_deliver_success,
  30. tmplIds.order_postage_success,
  31. tmplIds.order_clone
  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.pink_true
  51. ]);
  52. }
  53. /**
  54. * 砍价成功
  55. */
  56. export function openBargainSubscribe() {
  57. let tmplIds = auth();
  58. return subscribe([
  59. tmplIds.bargain_success
  60. ]);
  61. }
  62. /**
  63. * 订单退款
  64. */
  65. export function openOrderRefundSubscribe() {
  66. let tmplIds = auth();
  67. return subscribe([tmplIds.order_refund]);
  68. }
  69. /**
  70. * 充值成功
  71. */
  72. export function openRechargeSubscribe() {
  73. let tmplIds = auth();
  74. return subscribe([tmplIds.recharge_success]);
  75. }
  76. /**
  77. * 提现
  78. */
  79. export function openEextractSubscribe() {
  80. let tmplIds = auth();
  81. return subscribe([tmplIds.user_extract]);
  82. }
  83. /**
  84. * 调起订阅界面
  85. * array tmplIds 模板id
  86. */
  87. export function subscribe(tmplIds) {
  88. let wecaht = wx;
  89. return new Promise((reslove, reject) => {
  90. wecaht.requestSubscribeMessage({
  91. tmplIds: tmplIds,
  92. success(res) {
  93. return reslove(res);
  94. },
  95. fail(res) {
  96. return reslove(res);
  97. }
  98. })
  99. });
  100. }