!63 【新增】订阅消息:订单发货、充值退款消息订阅

Merge pull request !63 from puhui999/master
pull/64/head
芋道源码 2024-07-30 15:14:12 +00:00 committed by Gitee
commit 59c6613102
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 216 additions and 208 deletions

View File

@ -166,6 +166,7 @@
import OrderApi from '@/sheep/api/trade/order'; import OrderApi from '@/sheep/api/trade/order';
import CouponApi from '@/sheep/api/promotion/coupon'; import CouponApi from '@/sheep/api/promotion/coupon';
import { fen2yuan } from '@/sheep/hooks/useGoods'; import { fen2yuan } from '@/sheep/hooks/useGoods';
import { SubscribeTemplate } from '@/sheep/util/const';
const state = reactive({ const state = reactive({
orderPayload: {}, orderPayload: {},
@ -231,6 +232,11 @@
if (state.orderPayload.items[0].cartId > 0) { if (state.orderPayload.items[0].cartId > 0) {
sheep.$store('cart').getList(); sheep.$store('cart').getList();
} }
// #ifdef MP
sheep.$platform.useProvider('wechat').subscribeMessage(SubscribeTemplate.DELIVERY_ORDER);
// #endif
// //
sheep.$router.redirect('/pages/pay/index', { sheep.$router.redirect('/pages/pay/index', {
id: data.payOrderId, id: data.payOrderId,

View File

@ -74,20 +74,20 @@
// //
async function onConfirm() { async function onConfirm() {
// const { code, data } = await PayWalletApi.createWalletRecharge({ const { code, data } = await PayWalletApi.createWalletRecharge({
// packageId: state.packageList.find((item) => fen2yuan(item.payPrice) === state.recharge_money)?.id, packageId: state.packageList.find((item) => fen2yuan(item.payPrice) === state.recharge_money)?.id,
// payPrice: state.recharge_money * 100 payPrice: state.recharge_money * 100,
// }); });
// if (code !== 0) { if (code !== 0) {
// return; return;
// } }
// #ifdef MP // #ifdef MP
sheep.$platform.useProvider('wechat').subscribeMessage(SubscribeTemplate.MONEY_CHANGE); sheep.$platform.useProvider('wechat').subscribeMessage([SubscribeTemplate.WALLET_RECHARGER_PAID, SubscribeTemplate.WALLET_RECHARGE_REFUNDED]);
// #endif // #endif
// sheep.$router.go('/pages/pay/index', { sheep.$router.go('/pages/pay/index', {
// id: data.payOrderId, id: data.payOrderId,
// orderType: 'recharge' orderType: 'recharge',
// }); });
} }
onLoad(() => { onLoad(() => {

View File

@ -4,9 +4,9 @@ export default {
// 微信相关 // 微信相关
wechat: { wechat: {
// 小程序订阅消息 // 小程序订阅消息
subscribeTemplate: () => getSubscribeTemplateList: () =>
request({ request({
url: '/member/social-user/get-subscribe-template', url: '/member/social-user/get-subscribe-template-list',
method: 'GET', method: 'GET',
custom: { custom: {
showError: false, showError: false,

View File

@ -164,7 +164,7 @@ const checkUpdate = async (silence = true) => {
// 获取订阅消息模板 // 获取订阅消息模板
async function getSubscribeTemplate() { async function getSubscribeTemplate() {
const { code, data } = await third.wechat.subscribeTemplate(); const { code, data } = await third.wechat.getSubscribeTemplateList();
if (code === 0) { if (code === 0) {
subscribeEventList = data; subscribeEventList = data;
} }
@ -176,14 +176,14 @@ function subscribeMessage(event) {
if (typeof event === 'string') { if (typeof event === 'string') {
const temp = subscribeEventList.find(item => item.title.includes(event)); const temp = subscribeEventList.find(item => item.title.includes(event));
if (temp) { if (temp) {
tmplIds.push(temp.priTmplId); tmplIds.push(temp.id);
} }
} }
if (typeof event === 'object') { if (typeof event === 'object') {
event.forEach((e) => { event.forEach((e) => {
const temp = subscribeEventList.find(item => item.title.includes(e)); const temp = subscribeEventList.find(item => item.title.includes(e));
if (temp) { if (temp) {
tmplIds.push(temp.priTmplId); tmplIds.push(temp.id);
} }
}); });
} }

View File

@ -59,7 +59,9 @@ export const TimeStatusEnum = {
// TODO 订阅模版枚举 // TODO 订阅模版枚举
export const SubscribeTemplate = { export const SubscribeTemplate = {
ORDER_AFTERSALE_CHANGE: "售后进度通知", ORDER_AFTERSALE_CHANGE: "售后进度通知",
MONEY_CHANGE: "充值成功通知" WALLET_RECHARGER_PAID: "充值成功通知",
WALLET_RECHARGE_REFUNDED: "退款申请通知",
DELIVERY_ORDER: "订单发货通知",
} }