This commit is contained in:
zpc 2025-05-19 01:38:02 +08:00
parent 7fe88a2b4e
commit 66b12684e5
14 changed files with 190 additions and 203 deletions

View File

@ -156,7 +156,7 @@ export default {
provider = 'weixin',
data
}) {
console.log('wxdata', data)
console.log('wxdata', data,this)
// #ifdef H5
console.log('进入h5支付', data)
return new Promise((resolve, reject) => {

View File

@ -8,7 +8,7 @@ class AppPlatform extends BasePlatform {
getPayData(url,data) {
return data;
}
pay({ data }) {
pay({ data }, event) {
return new Promise((resolve) => {
console.log(`App支付${data.amount}分,订单号:${data.orderId}`);
// 模拟调用H5支付SDK

View File

@ -11,7 +11,13 @@ class BasePlatform {
this.code = ''; // 平台代码WEB/MP/APP
this.env = ''; // 运行环境标识
}
/**
* 获取配置
* @returns
*/
async getConfig() {
return {};
}
getPayData(url, data) {
throw new Error('子类必须实现 getPayData 方法');
}
@ -30,7 +36,7 @@ class BasePlatform {
*/
pay({
data
}) {
}, event) {
throw new Error('子类必须实现 pay 方法');
}

View File

@ -38,7 +38,7 @@ class H5Platform extends BasePlatform {
console.log('处理数据', data);
return data;
}
pay({ data }) {
pay({ data }, event) {
console.log('支付1111');
return new Promise((resolve) => {

View File

@ -7,14 +7,44 @@ class MiniProgramPlatform extends BasePlatform {
super();
this.code = 'MP-WEIXIN';
this.env = 'miniProgram';
this.config = null;
}
async getConfig() {
if (this.config) {
return this.config;
}
this.config = { isWebPay: true };
return this.config;
}
getPayData(url, data) {
return data;
}
pay({
data
}) {
return new Promise((resolve, reject) => {
}, event) {
console.log(this,event);
return new Promise(async (resolve, reject) => {
let config = await this.getConfig();
if (config.isWebPay) {
console.log('开启H5支付', data);
console.log(data);
uni.showModal({
title: '支付提示',
content: data.tips ? data.tips : "您即将进入客服聊天界面完成支付也可前往「我的」页面下载官方APP享受更便捷的购物及充值服务。",
confirmText: "前往支付",
cancelText: "关闭",
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
let provider = "weixin";
uni.requestPayment({
provider,
@ -139,7 +169,7 @@ class MiniProgramPlatform extends BasePlatform {
resolve(null);
});
}
delOrderNo(){}
delOrderNo() { }
/**
* 重写获取用户中心菜单列表添加微信小程序特有菜单
@ -148,7 +178,7 @@ class MiniProgramPlatform extends BasePlatform {
getUserMenuList() {
// 获取基础菜单列表
const baseMenuList = super.getUserMenuList();
// 添加客服菜单项(仅微信小程序)
const customServiceMenu = {
id: 9,
@ -158,9 +188,9 @@ class MiniProgramPlatform extends BasePlatform {
path: '',
isCustomService: true,
// 客服按钮不需要处理函数,由微信小程序原生组件处理
handler: () => {}
handler: () => { }
};
// 将客服菜单插入到第二个位置
return [...baseMenuList.slice(0, 1), customServiceMenu, ...baseMenuList.slice(1)];
}

View File

@ -69,12 +69,21 @@ export default {
currentPrizeIndex: -1,
internalMode: 1, //
skipButtonOpacity: 0, //
isSkip: false,
isBatchMode: false, //
batchCount: 0, //
batchResults: [], //
batchCallback: null, //
batchIndices: [], //
chaoShenIndex: -1,
timers: {
skipButton: null, //
firstBatch: null, //
secondBatch: null, //
drawResult: null, //
showDelay: null, // DOM
playDelay: null //
},
};
},
computed: {
@ -98,8 +107,8 @@ export default {
10: "800rpx" // 10使5
};
// 使currentMode使internalMode
console.log(modeMap[this.currentMode],"modeMap[this.currentMode]");
console.log(modeMap[this.currentMode], "modeMap[this.currentMode]");
return modeMap[this.currentMode] || "480rpx";
},
//
@ -115,21 +124,21 @@ export default {
},
//
skipButtonStyle() {
return ()=>{
return () => {
return {
opacity: this.skipButtonOpacity,
transition: 'opacity 0.5s ease'
opacity: this.skipButtonOpacity,
transition: 'opacity 0.5s ease'
};
};
};
}
},
methods: {
onLuckyEnd1() {
//
this.$emit("end",[]);
this.$emit("end", []);
// startDrawWithResult
if (this.drawResultCallback && typeof this.drawResultCallback === 'function') {
@ -330,7 +339,9 @@ export default {
try {
console.log("[批次抽奖] endCallBack 被调用,批次模式:", this.isBatchMode, "当前模式:", this.internalMode, "批次计数:", this
.batchCount);
if (this.isSkip) {
return;
}
//
const prizeData =
this.prizes[this.currentPrizeIndex]?.data || this.prizes[0]?.data;
@ -389,7 +400,7 @@ export default {
if (this.batchCount < 2) {
//
console.log("[批次抽奖] 第一批次完成,准备开始第二批次");
setTimeout(() => {
this.timers.firstBatch = setTimeout(() => {
console.log("[批次抽奖] 即将调用startSecondBatch");
this.startSecondBatch();
}, 800);
@ -420,7 +431,7 @@ export default {
this.$refs.detailGrandPrize.show();
return;
}
setTimeout(() => {
this.timers.drawResult = setTimeout(() => {
//
this.$emit("end", batchResult);
@ -449,7 +460,7 @@ export default {
return;
}
setTimeout(() => {
this.timers.drawResult = setTimeout(() => {
//
this.$emit("end", result);
@ -502,113 +513,36 @@ export default {
console.log("[跳过动画] 批次模式:", this.isBatchMode, "当前模式:", this.internalMode, "批次计数:", this.batchCount);
this.hide();
//
if (this.isBatchMode && this.internalMode === 10) {
//
if (this.batchCallback && typeof this.batchCallback === 'function') {
console.log("[跳过动画] 批次模式下跳过动画,准备返回结果");
//
if (this.batchResults.length === 0) {
console.log("[跳过动画] 没有现有结果,创建随机结果");
// 使
let indices = [];
if (this.batchIndices && this.batchIndices.length > 0) {
indices = this.batchIndices;
} else {
// 10
for (let i = 0; i < 10; i++) {
indices.push(Math.floor(Math.random() * this.prizes.length));
}
}
//
for (let i = 0; i < indices.length; i++) {
const index = indices[i];
if (index >= 0 && index < this.prizes.length) {
const prizeData = this.prizes[index].data;
if (prizeData) {
this.batchResults.push(prizeData);
}
}
}
}
//
let firstPrize = this.batchResults[0] || null;
const result = {
allPrizes: this.batchResults,
message: `抽奖已跳过,共获得 ${this.batchResults.length} 件奖品`,
skipped: true,
prizeData: firstPrize,
prizeInfo: firstPrize ? {
name: firstPrize.title,
image: firstPrize.imgurl,
description: `价值:${firstPrize.price}`,
data: firstPrize,
} : null
};
//
this.$emit("end", result);
console.log("[跳过动画] 调用批次回调函数");
this.batchCallback(result);
this.batchCallback = null;
let stopIndex = 0;
if (this.internalMode > 1) {
stopIndex = [];
let maxIndex = this.internalMode;
if (maxIndex > 5) {
maxIndex = 5;
}
//
this.isBatchMode = false;
this.batchCount = 0;
this.batchResults = [];
return this;
}
//
if (this.currentPrizeIndex >= 0 && this.prizes.length > 0) {
const prizeData = this.prizes[this.currentPrizeIndex]?.data || this.prizes[0]?.data;
if (prizeData) {
const result = {
prize: {
index: this.currentPrizeIndex
},
prizeData: prizeData,
allPrizes: [prizeData],
message: `恭喜您获得 ${prizeData.title}`,
prizeInfo: {
name: prizeData.title,
image: prizeData.imgurl,
description: `价值:${prizeData.price}`,
data: prizeData,
},
skipped: true //
};
if (this.bgmCtx && this.bgmCtx.slotBgm) {
this.bgmCtx.slotBgm.pause();
}
//
this.$emit("end", result);
// startDrawWithResult
if (this.drawResultCallback && typeof this.drawResultCallback === 'function') {
this.drawResultCallback(result);
//
this.drawResultCallback = null;
}
for (let i = 0; i < maxIndex; i++) {
stopIndex.push(0);
}
}
// stop
this.$refs.myLucky.stop(stopIndex);
//
this.$emit("end", []);
return this; // this
},
//
skipAnimation() {
this.isSkip = true;
//
Object.values(this.timers).forEach(timer => {
if (timer) {
clearTimeout(timer);
}
});
//
this.forceEndDraw();
},
//
@ -618,6 +552,9 @@ export default {
console.error("抽奖特效尚未初始化请先调用init方法");
return this;
}
if (this.isSkip) {
this.isSkip = false;
}
//
this.drawResultCallback = typeof callback === 'function' ? callback : null;
@ -658,14 +595,14 @@ export default {
}
//
setTimeout(() => {
this.timers.skipButton = setTimeout(() => {
this.skipButtonOpacity = 1;
}, 1000);
//
if (this.isBatchMode && this.internalMode === 10) {
console.log("[批次抽奖] 设置2秒后自动停止第一批次");
setTimeout(() => {
this.timers.firstBatch = setTimeout(() => {
// 使5
const firstBatchIndices = this.batchIndices.slice(0, 5);
console.log("[批次抽奖] 停止第一批次抽奖,使用索引:", firstBatchIndices);
@ -757,6 +694,7 @@ export default {
this.prizes = [];
this.prizeList = [];
this.currentPrizeIndex = -1;
this.isSkip = false;
return this;
},
@ -772,7 +710,11 @@ export default {
console.error("抽奖特效尚未初始化请先调用init方法");
return this;
}
if (this.isSkip) {
this.isSkip = false;
}
//
this.skipButtonOpacity = 0;
//
if (!resultIndices || !Array.isArray(resultIndices)) {
console.error("抽奖结果必须是数组");
@ -829,12 +771,12 @@ export default {
}
//
setTimeout(() => {
this.timers.skipButton = setTimeout(() => {
this.skipButtonOpacity = 1;
}, 1000);
// 2
setTimeout(() => {
this.timers.firstBatch = setTimeout(() => {
// 使5
const firstBatchIndices = resultIndices.slice(0, 5);
console.log("[批次抽奖] 停止第一批次抽奖,使用索引:", firstBatchIndices);
@ -885,12 +827,12 @@ export default {
}
//
setTimeout(() => {
this.timers.skipButton = setTimeout(() => {
this.skipButtonOpacity = 1;
}, 1000);
// 2
setTimeout(() => {
this.timers.drawResult = setTimeout(() => {
//
this.stopDraw(resultIndices);
}, 2000);
@ -967,12 +909,12 @@ export default {
}
//
setTimeout(() => {
this.timers.skipButton = setTimeout(() => {
this.skipButtonOpacity = 1;
}, 1000);
// 2
setTimeout(() => {
this.timers.secondBatch = setTimeout(() => {
// 使
let indices = [];
if (this.batchIndices && this.batchIndices.length > 5) {
@ -1012,6 +954,14 @@ export default {
});
},
},
beforeDestroy() {
//
Object.values(this.timers).forEach(timer => {
if (timer) {
clearTimeout(timer);
}
});
},
mounted() {
//
},
@ -1047,77 +997,78 @@ export default {
left: 0;
z-index: 999;
}
.detail-lucky{
//
.slot-container {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
position: relative;
}
.slot-icon {
padding-bottom: 25rpx;
}
.detail-lucky {
//
.slot-view {
background-size: 100% 100%;
width: 100%;
padding-top: 80rpx;
padding-bottom: 80rpx;
display: flex;
justify-content: center;
align-items: center;
}
//
.slot-container {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
position: relative;
}
//
.slot-view-1 {
background: url("https://image.zfunbox.cn/static/image/lucky/di_5.png") no-repeat;
background-size: 100% 100%;
}
.slot-icon {
padding-bottom: 25rpx;
}
.slot-view-3 {
background: url("https://image.zfunbox.cn/static/image/lucky/di_3.png") no-repeat;
background-size: 100% 100%;
}
//
.slot-view {
background-size: 100% 100%;
width: 100%;
padding-top: 80rpx;
padding-bottom: 80rpx;
display: flex;
justify-content: center;
align-items: center;
}
.slot-view-5 {
background: url("https://image.zfunbox.cn/static/image/lucky/di_5.png") no-repeat;
background-size: 100% 100%;
}
//
.slot-view-1 {
background: url("https://image.zfunbox.cn/static/image/lucky/di_5.png") no-repeat;
background-size: 100% 100%;
}
//
.item-lottry {
height: 152.78rpx;
width: 152.78rpx;
display: flex;
justify-content: center;
align-items: center;
font-size: 30rpx;
border-radius: 16rpx;
color: black;
box-sizing: border-box;
background-color: rgba(255, 255, 255, 1);
}
.slot-view-3 {
background: url("https://image.zfunbox.cn/static/image/lucky/di_3.png") no-repeat;
background-size: 100% 100%;
}
//
.skip-animation {
color: #249073;
font-size: 21rpx;
text-align: center;
padding-top: 20rpx;
padding-bottom: 10rpx;
display: inline-block;
opacity: 0;
transition: opacity 0.5s ease;
user-select: none;
}
.slot-view-5 {
background: url("https://image.zfunbox.cn/static/image/lucky/di_5.png") no-repeat;
background-size: 100% 100%;
}
.skip-animation:active {
opacity: 0.7;
}
}
//
.item-lottry {
height: 152.78rpx;
width: 152.78rpx;
display: flex;
justify-content: center;
align-items: center;
font-size: 30rpx;
border-radius: 16rpx;
color: black;
box-sizing: border-box;
background-color: rgba(255, 255, 255, 1);
}
//
.skip-animation {
color: #249073;
font-size: 21rpx;
text-align: center;
padding-top: 20rpx;
padding-bottom: 10rpx;
display: inline-block;
opacity: 0;
transition: opacity 0.5s ease;
user-select: none;
}
.skip-animation:active {
opacity: 0.7;
}
}
</style>

View File

@ -675,7 +675,7 @@ export default {
if (res.data.status == 1) {
const status = await this.$platform.pay({
data: res.data.res
})
},this)
if (status == "success") {
this.getPrize(res.data.order_num);
this.doRefresh();

View File

@ -813,7 +813,7 @@
if (res.data.status == 1) {
const status = await this.$platform.pay({
data: res.data.res
})
},this);
if (status == 'success') {
this.getPrize(res.data.order_num)

View File

@ -383,7 +383,7 @@ export default {
if (res.data.status == 1) {
const status = await this.$platform.pay({
data: res.data.res
});
},this);
if (status == "success") {
this.load(this.goods_id);

View File

@ -334,7 +334,7 @@ export default {
const status = await this.$platform.pay({
data: res.data.res
})
},this)
if (status == 'success') {
// that.getPrize(res.data.order_num)
that.getData();
@ -399,7 +399,7 @@ export default {
const status = await this.$platform.pay({
data: res.data.res
})
},this)
if (status == 'success') {
// that.getPrize(res.data.order_num)
that.getData();

View File

@ -631,7 +631,7 @@ export default {
if (res.data.status == 1) {
const status = await this.$platform.pay({
data: res.data.res
})
},this)
if (status == 'success') {
this.tabChange(this.tabCur)

View File

@ -579,7 +579,7 @@ export default {
if (res.data.status == 1) {
const status = await this.$platform.pay({
data: res.data.res
})
},this)
if (status == "success") {
this.getPrize(res.data.order_num);

View File

@ -733,7 +733,7 @@ export default {
//
const status = await this.$platform.pay({
data: res.data.res
})
},this)
if (status == 'success') {
//

View File

@ -104,7 +104,7 @@ export default {
const res = await createOrderProducts(pro.products_id);
console.log(res);
this.order_num = res.order_num;
const status = await this.$platform.pay({ data: res.res });
const status = await this.$platform.pay({ data: res.res },this);
if (status == 'success') {
this.getPrizeLog(res.order_num);
}