SubscribeMessage.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // +----------------------------------------------------------------------
  2. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2016~2021 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. tmplIds.order_brokerage
  41. ]);
  42. }
  43. /**
  44. * 提现消息订阅
  45. * 成功 和 失败 消息
  46. */
  47. export function openExtrctSubscribe() {
  48. let tmplIds = auth();
  49. return subscribe([
  50. tmplIds.user_extract
  51. ]);
  52. }
  53. /**
  54. * 拼团成功
  55. */
  56. export function openPinkSubscribe() {
  57. let tmplIds = auth();
  58. return subscribe([
  59. tmplIds.pink_true,
  60. tmplIds.pink_status
  61. ]);
  62. }
  63. /**
  64. * 砍价成功
  65. */
  66. export function openBargainSubscribe() {
  67. let tmplIds = auth();
  68. return subscribe([
  69. tmplIds.bargain_success
  70. ]);
  71. }
  72. /**
  73. * 订单退款
  74. */
  75. export function openOrderRefundSubscribe() {
  76. let tmplIds = auth();
  77. return subscribe([
  78. tmplIds.order_refund
  79. ]);
  80. }
  81. /**
  82. * 充值成功
  83. */
  84. export function openRechargeSubscribe() {
  85. let tmplIds = auth();
  86. return subscribe([
  87. tmplIds.recharge_success
  88. ]);
  89. }
  90. /**
  91. * 调起订阅界面
  92. * array tmplIds 模板id
  93. */
  94. export function subscribe(subscrip443tionmessagee502call) {
  95. let weChat = wx;
  96. return new Promise((reslove, reject) => {
  97. weChat.requestSubscribeMessage({
  98. tmplIds: subscrip443tionmessagee502call,
  99. success(res) {
  100. return reslove(res);
  101. },
  102. fail(res) {
  103. return reslove(res);
  104. }
  105. })
  106. });
  107. }