SubscribeMessage.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. console.log(messageTmplIds,'messageTmplIds')
  8. tmplIds = messageTmplIds ? messageTmplIds : {};
  9. return tmplIds;
  10. }
  11. // +----------------------------------------------------------------------
  12. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  13. // +----------------------------------------------------------------------
  14. // | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
  15. // +----------------------------------------------------------------------
  16. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  17. // +----------------------------------------------------------------------
  18. // | Author: CRMEB Team <admin@crmeb.com>
  19. // +----------------------------------------------------------------------
  20. /**
  21. * 支付成功后订阅消息id
  22. * 订阅 订单支付成功 订单发货提醒(快递) 订单发货提醒(送货)
  23. */
  24. export function openPaySubscribe() {
  25. let tmplIds = auth();
  26. return subscribe([
  27. tmplIds.ORDER_POSTAGE_SUCCESS ,
  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.ORDER_POSTAGE_SUCCESS,
  51. ]);
  52. }
  53. /**
  54. * 提现消息订阅
  55. * 成功 和 失败 消息
  56. */
  57. export function openExtrctSubscribe() {
  58. let tmplIds = auth();
  59. return subscribe([
  60. tmplIds.user_extract
  61. ]);
  62. }
  63. /**
  64. * 拼团成功
  65. */
  66. export function openPinkSubscribe() {
  67. let tmplIds = auth();
  68. return subscribe([
  69. tmplIds.pink_true
  70. ]);
  71. }
  72. /**
  73. * 砍价成功
  74. */
  75. export function openBargainSubscribe() {
  76. let tmplIds = auth();
  77. return subscribe([
  78. tmplIds.bargain_success
  79. ]);
  80. }
  81. /**
  82. * 订单退款
  83. */
  84. export function openOrderRefundSubscribe() {
  85. let tmplIds = auth();
  86. return subscribe([tmplIds.ORDER_REFUND_NOTICE]);
  87. }
  88. /**
  89. * 充值成功
  90. */
  91. export function openRechargeSubscribe() {
  92. let tmplIds = auth();
  93. return subscribe([tmplIds.RECHARGE_SUCCESS]);
  94. }
  95. /**
  96. * 提现
  97. */
  98. export function openEextractSubscribe() {
  99. let tmplIds = auth();
  100. return subscribe([tmplIds.USER_EXTRACT]);
  101. }
  102. /**
  103. * 调起订阅界面
  104. * array tmplIds 模板id
  105. */
  106. export function subscribe(tmplIds) {
  107. let wecaht = wx;
  108. return new Promise((reslove, reject) => {
  109. uni.requestSubscribeMessage({
  110. tmplIds: tmplIds,
  111. success(res) {
  112. console.log(res,'requestSubscribeMessage')
  113. return reslove(res);
  114. },
  115. fail(res) {
  116. console.log(res,'fail')
  117. return reslove(res);
  118. },
  119. complete(res){
  120. console.log(res,'complete')
  121. }
  122. })
  123. });
  124. }