SubscribeMessage.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import { CACHE_SUBSCRIBE_MESSAGE } from './../config.js';
  2. export function auth()
  3. {
  4. let tmplIds = {};
  5. let messageTmplIds = wx.getStorageSync(CACHE_SUBSCRIBE_MESSAGE);
  6. tmplIds = messageTmplIds ? JSON.parse(messageTmplIds) : {};
  7. return tmplIds;
  8. }
  9. /**
  10. * 支付成功后订阅消息id
  11. * 订阅 确认收货通知 订单支付成功 新订单管理员提醒
  12. */
  13. export function openPaySubscribe()
  14. {
  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. {
  28. let tmplIds = auth();
  29. return subscribe([
  30. tmplIds.order_deliver_success,
  31. tmplIds.order_postage_success,
  32. tmplIds.order_clone
  33. ])
  34. }
  35. /**
  36. * 提现消息订阅
  37. * 成功 和 失败 消息
  38. */
  39. export function openExtrctSubscribe()
  40. {
  41. let tmplIds = auth();
  42. return subscribe([
  43. tmplIds.user_extract
  44. ]);
  45. }
  46. /**
  47. * 拼团成功
  48. */
  49. export function openPinkSubscribe()
  50. {
  51. let tmplIds = auth();
  52. return subscribe([
  53. tmplIds.pink_true
  54. ]);
  55. }
  56. /**
  57. * 砍价成功
  58. */
  59. export function openBargainSubscribe()
  60. {
  61. let tmplIds = auth();
  62. return subscribe([
  63. tmplIds.bargain_success
  64. ]);
  65. }
  66. /**
  67. * 订单退款
  68. */
  69. export function openOrderRefundSubscribe()
  70. {
  71. let tmplIds = auth();
  72. return subscribe([tmplIds.order_refund]);
  73. }
  74. /**
  75. * 充值成功
  76. */
  77. export function openRechargeSubscribe()
  78. {
  79. let tmplIds = auth();
  80. return subscribe([tmplIds.recharge_success]);
  81. }
  82. /**
  83. * 提现
  84. */
  85. export function openEextractSubscribe()
  86. {
  87. let tmplIds = auth();
  88. return subscribe([tmplIds.user_extract]);
  89. }
  90. /**
  91. * 调起订阅界面
  92. * array tmplIds 模板id
  93. */
  94. export function subscribe(tmplIds)
  95. {
  96. let wecaht = wx;
  97. return new Promise((reslove) => {
  98. wecaht.requestSubscribeMessage({
  99. tmplIds: tmplIds,
  100. success(res) {
  101. return reslove(res);
  102. },
  103. fail(res) {
  104. return reslove(res);
  105. },
  106. complete:function(res){
  107. return reslove(res);
  108. },
  109. })
  110. });
  111. }