【代码优化】SYSTEM:微信小程序的订阅
parent
77306a54e7
commit
ececc6f67c
|
@ -130,7 +130,7 @@
|
||||||
import TradeConfigApi from '@/sheep/api/trade/config';
|
import TradeConfigApi from '@/sheep/api/trade/config';
|
||||||
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
||||||
import AfterSaleApi from '@/sheep/api/trade/afterSale';
|
import AfterSaleApi from '@/sheep/api/trade/afterSale';
|
||||||
import { SubscribeTemplate } from '@/sheep/util/const';
|
import { WxaSubscribeTemplate } from '@/sheep/util/const';
|
||||||
|
|
||||||
const form = ref(null);
|
const form = ref(null);
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
|
|
|
@ -166,7 +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';
|
import { WxaSubscribeTemplate } from '@/sheep/util/const';
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
orderPayload: {},
|
orderPayload: {},
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
import { onLoad } from '@dcloudio/uni-app';
|
import { onLoad } from '@dcloudio/uni-app';
|
||||||
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
||||||
import PayWalletApi from '@/sheep/api/pay/wallet';
|
import PayWalletApi from '@/sheep/api/pay/wallet';
|
||||||
import { SubscribeTemplate } from '@/sheep/util/const';
|
import { WxaSubscribeTemplate } from '@/sheep/util/const';
|
||||||
|
|
||||||
const userWallet = computed(() => sheep.$store('user').userWallet);
|
const userWallet = computed(() => sheep.$store('user').userWallet);
|
||||||
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
|
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// #ifdef MP
|
// #ifdef MP
|
||||||
sheep.$platform.useProvider('wechat').subscribeMessage(SubscribeTemplate.WALLET_RECHARGER_PAID);
|
sheep.$platform.useProvider('wechat').subscribeMessage(WxaSubscribeTemplate.PAY_WALLET_RECHARGER_SUCCESS);
|
||||||
// #endif
|
// #endif
|
||||||
sheep.$router.go('/pages/pay/index', {
|
sheep.$router.go('/pages/pay/index', {
|
||||||
id: data.payOrderId,
|
id: data.payOrderId,
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
import PayOrderApi from '@/sheep/api/pay/order';
|
import PayOrderApi from '@/sheep/api/pay/order';
|
||||||
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
||||||
import OrderApi from '@/sheep/api/trade/order';
|
import OrderApi from '@/sheep/api/trade/order';
|
||||||
import { SubscribeTemplate } from '@/sheep/util/const';
|
import { WxaSubscribeTemplate } from '@/sheep/util/const';
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
id: 0, // 支付单号
|
id: 0, // 支付单号
|
||||||
|
@ -159,9 +159,9 @@
|
||||||
const showSubscribeBtn = ref(false) // 默认隐藏
|
const showSubscribeBtn = ref(false) // 默认隐藏
|
||||||
const SUBSCRIBE_BTN_STATUS_STORAGE_KEY = "subscribe_btn_status"
|
const SUBSCRIBE_BTN_STATUS_STORAGE_KEY = "subscribe_btn_status"
|
||||||
function subscribeMessage() {
|
function subscribeMessage() {
|
||||||
let event = [SubscribeTemplate.DELIVERY_ORDER];
|
let event = [WxaSubscribeTemplate.TRADE_ORDER_DELIVERY];
|
||||||
if (state.tradeOrder.type === 3) {
|
if (state.tradeOrder.type === 3) {
|
||||||
event.push(SubscribeTemplate.COMBINATION_RESULT);
|
event.push(WxaSubscribeTemplate.PROMOTION_COMBINATION_SUCCESS);
|
||||||
}
|
}
|
||||||
sheep.$platform.useProvider('wechat').subscribeMessage(event, () => {
|
sheep.$platform.useProvider('wechat').subscribeMessage(event, () => {
|
||||||
// 订阅后记录一下订阅状态
|
// 订阅后记录一下订阅状态
|
||||||
|
|
|
@ -56,14 +56,15 @@ export const TimeStatusEnum = {
|
||||||
END: '已结束',
|
END: '已结束',
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 订阅模版枚举
|
/**
|
||||||
export const SubscribeTemplate = {
|
* 微信小程序的订阅模版
|
||||||
WALLET_RECHARGER_PAID: "充值成功通知",
|
*/
|
||||||
DELIVERY_ORDER: "订单发货通知",
|
export const WxaSubscribeTemplate = {
|
||||||
COMBINATION_RESULT: "拼团结果通知"
|
TRADE_ORDER_DELIVERY: "订单发货通知",
|
||||||
|
PROMOTION_COMBINATION_SUCCESS: "拼团结果通知",
|
||||||
|
PAY_WALLET_RECHARGER_SUCCESS: "充值成功通知",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const getTimeStatusEnum = (startTime, endTime) => {
|
export const getTimeStatusEnum = (startTime, endTime) => {
|
||||||
const now = dayjs();
|
const now = dayjs();
|
||||||
if (now.isBefore(startTime)) {
|
if (now.isBefore(startTime)) {
|
||||||
|
|
Loading…
Reference in New Issue