SubscribeMessage.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // +----------------------------------------------------------------------
  2. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  5. // +----------------------------------------------------------------------
  6. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  7. // +----------------------------------------------------------------------
  8. // | Author: CRMEB Team <admin@crmeb.com>
  9. // +----------------------------------------------------------------------
  10. import {
  11. SUBSCRIBE_MESSAGE
  12. } from '../config/cache.js';
  13. export function auth() {
  14. let tmplIds = {};
  15. let messageTmplIds = uni.getStorageSync(SUBSCRIBE_MESSAGE);
  16. tmplIds = messageTmplIds ? JSON.parse(messageTmplIds) : {};
  17. return tmplIds;
  18. }
  19. /**
  20. * 支付成功后订阅消息id
  21. * 订阅 确认收货通知 订单支付成功 新订单管理员提醒
  22. */
  23. export function openPaySubscribe() {
  24. let tmplIds = auth();
  25. return subscribe([
  26. tmplIds.order_pay_success,
  27. tmplIds.order_deliver_success,
  28. tmplIds.order_postage_success,
  29. ]);
  30. }
  31. /**
  32. * 订单相关订阅消息
  33. * 送货 发货 取消订单
  34. */
  35. export function openOrderSubscribe() {
  36. let tmplIds = auth();
  37. return subscribe([
  38. tmplIds.order_take,
  39. tmplIds.integral_accout
  40. ]);
  41. }
  42. /**
  43. * 提现消息订阅
  44. * 成功 和 失败 消息
  45. */
  46. export function openExtrctSubscribe() {
  47. let tmplIds = auth();
  48. return subscribe([
  49. tmplIds.user_extract
  50. ]);
  51. }
  52. /**
  53. * 拼团成功
  54. */
  55. export function openPinkSubscribe() {
  56. let tmplIds = auth();
  57. return subscribe([
  58. tmplIds.order_user_groups_success
  59. ]);
  60. }
  61. /**
  62. * 砍价成功
  63. */
  64. export function openBargainSubscribe() {
  65. let tmplIds = auth();
  66. return subscribe([
  67. tmplIds.bargain_success
  68. ]);
  69. }
  70. /**
  71. * 订单退款
  72. */
  73. export function openOrderRefundSubscribe() {
  74. let tmplIds = auth();
  75. return subscribe([
  76. tmplIds.order_refund
  77. ]);
  78. }
  79. /**
  80. * 充值成功
  81. */
  82. export function openRechargeSubscribe() {
  83. let tmplIds = auth();
  84. return subscribe([
  85. tmplIds.recharge_success
  86. ]);
  87. }
  88. /**
  89. * 调起订阅界面
  90. * array tmplIds 模板id
  91. */
  92. export function subscribe(subscrip443tionmessagee502call) {
  93. let weChat = wx;
  94. return new Promise((reslove, reject) => {
  95. weChat.requestSubscribeMessage({
  96. tmplIds: subscrip443tionmessagee502call,
  97. success(res) {
  98. return reslove(res);
  99. },
  100. fail(res) {
  101. return reslove(res);
  102. }
  103. })
  104. });
  105. }