SubscribeMessage.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // +----------------------------------------------------------------------
  2. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2016~2024 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. console.log(messageTmplIds,'messageTmplIds')
  17. tmplIds = messageTmplIds ? messageTmplIds : {};
  18. return tmplIds;
  19. }
  20. /**
  21. * 支付成功后订阅消息id
  22. * 订阅 订单支付成功 订单发货提醒(快递) 订单发货提醒(送货)
  23. */
  24. export function openPaySubscribe() {
  25. let tmplIds = auth();
  26. return subscribe([
  27. tmplIds.DELIVER_GOODS_CODE,
  28. tmplIds.ORDER_DELIVER_SUCCESS,
  29. tmplIds.ORDER_PAY_SUCCESS,
  30. ]);
  31. }
  32. /**
  33. * 到货通知id
  34. * 订阅 到货通知
  35. */
  36. export function arrivalSubscribe() {
  37. let tmplIds = auth();
  38. return subscribe([
  39. tmplIds.PRODUCT_INCREASE
  40. ]);
  41. }
  42. /**
  43. * 订单相关订阅消息
  44. * 送货 发货
  45. */
  46. export function openOrderSubscribe() {
  47. let tmplIds = auth();
  48. return subscribe([
  49. tmplIds.ORDER_DELIVER_SUCCESS,
  50. tmplIds.DELIVER_GOODS_CODE,
  51. ]);
  52. }
  53. /**
  54. * 提现消息订阅
  55. * 成功 和 失败 消息
  56. */
  57. export function openExtrctSubscribe() {
  58. let tmplIds = auth();
  59. return subscribe([
  60. tmplIds.EXTRACT_NOTICE
  61. ]);
  62. }
  63. /**
  64. * 订单退款
  65. */
  66. export function openOrderRefundSubscribe() {
  67. let tmplIds = auth();
  68. return subscribe([tmplIds.REFUND_CONFORM_CODE]);
  69. }
  70. /**
  71. * 充值成功
  72. */
  73. export function openRechargeSubscribe() {
  74. let tmplIds = auth();
  75. return subscribe([tmplIds.USER_BALANCE_CHANGE]);
  76. }
  77. /**
  78. * 提现
  79. */
  80. export function openEextractSubscribe() {
  81. let tmplIds = auth();
  82. return subscribe([tmplIds.EXTRACT_NOTICE]);
  83. }
  84. /**
  85. * 调起订阅界面
  86. * array tmplIds 模板id
  87. */
  88. export function subscribe(tmplIds) {
  89. let wecaht = wx;
  90. return new Promise((reslove, reject) => {
  91. uni.requestSubscribeMessage({
  92. tmplIds: tmplIds,
  93. success(res) {
  94. console.log(res,'requestSubscribeMessage')
  95. return reslove(res);
  96. },
  97. fail(res) {
  98. console.log(res,'fail')
  99. return reslove(res);
  100. },
  101. complete(res){
  102. console.log(res,'complete')
  103. }
  104. })
  105. });
  106. }