剩下兑奖逻辑

This commit is contained in:
Andy Leong 2024-01-21 21:22:16 +08:00
parent 57b35eb7e4
commit 22a4a20c97
12 changed files with 114 additions and 86 deletions

View File

@ -1,6 +1,6 @@
VITE_MODE = fat VITE_MODE = fat
VITE_HOST = https://test.szxgl.cn VITE_HOST = https://wmm-stg.pingan.com.cn
VITE_CDN = https://test.szxgl.cn VITE_CDN = https://cdn.xglpa.com
VITE_FOLDER = /vite VITE_FOLDER = /vite-4
VITE_API = /vite-api VITE_API = /intfgw/data/mmoactivity
VITE_URL = https://w-stg.pingan.com.cn/lckj/pawm-mmo-activity-xgl-frontend/index.html VITE_URL = https://w-stg.pingan.com.cn/lckj/pawm-mmo-activity-xgl-frontend/index.html

View File

@ -51,3 +51,11 @@ export function exchangePrize(data, authorization) {
authorization authorization
); );
} }
// 分享接口
export function getShareConfig(data, authorization) {
return http.post("/h5/Oauth/getShareConfig",
data,
true,
);
}

BIN
src/assets/images/share.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@ -32,16 +32,21 @@ const drawFn = (event) => {
); );
try { try {
const res = await drawApi({}, userStore.token); const res = await drawApi(
{ subAnswerKey: userStore.drawKey },
userStore.token
);
if (res.code == 0) { if (res.code == 0) {
// isDrawn // isDrawn
hasPrize.value = res.data.isDrawn == 1 ? true : false; // true || false hasPrize.value = res.data.isDrawn == 1 ? true : false; // true || false
userStore.updateDraw(); //
// if (res.data.isDrawn == 1) { //
// hasPrize.value = true if (res.data.isDrawn == 1) {
// } else { money.value = res.data.prizeAmount;
// hasPrize.value = false code.value = res.data.prizeCode;
// } userStore.updatePrize(res.data);
}
} else { } else {
hasPrize.value = false; // true || false hasPrize.value = false; // true || false
} }
@ -60,15 +65,6 @@ const drawFn = (event) => {
}); });
gsap.killTweensOf(".draw-light,.draw"); gsap.killTweensOf(".draw-light,.draw");
}, 1000); }, 1000);
// setTimeout(() => {
// hasPrize.value = false // true || false
// showResult.value = true
// console.log("showResult:", showResult.value);
// Toast.clear()
// gsap.from('.result-container', { duration: 0.5, scale: 0.7, autoAlpha: 0 })
// gsap.killTweensOf('.draw-light,.draw')
// }, 3000)
}); });
}; };

View File

@ -3,12 +3,12 @@ import { Toast } from "vant";
import gsap from "gsap"; import gsap from "gsap";
import Preloader from "@/plugins/Preloader"; import Preloader from "@/plugins/Preloader";
import { loadImg, pageImg } from "@/data/imgList"; import { loadImg, pageImg } from "@/data/imgList";
import { getMyPrize } from '@/api' import { getMyPrize } from "@/api";
import { useMainStore } from '@/store' import { useMainStore } from "@/store";
// //
const emit = defineEmits(["LoadPage"]); const emit = defineEmits(["LoadPage"]);
const userStore = useMainStore() const userStore = useMainStore();
const loadNum = ref(0); const loadNum = ref(0);
@ -45,17 +45,16 @@ onMounted(() => {
duration: 0.2, duration: 0.2,
autoAlpha: 1, autoAlpha: 1,
onComplete: () => { onComplete: () => {
if(import.meta.env.VITE_MODE!='dev'){ if (import.meta.env.VITE_MODE != "dev") {
getMyPrize({}, userStore.token).then( getMyPrize({}, userStore.token).then((res) => {
res => {
if (res.code == 0) { if (res.code == 0) {
console.log('我的奖品', res); console.log("我的奖品", res);
if(res.data){ if (res.data) {
// userStore.updatePrize(code,money) console.log("有奖品");
userStore.updatePrize(res.data);
} }
} }
} });
)
} }
Preloader({ Preloader({
@ -81,9 +80,6 @@ onMounted(() => {
}); });
}); });
}); });
</script> </script>
<template> <template>

View File

@ -104,8 +104,7 @@ const showResult = (event) => {
subAnswer({}, userStore.token).then((res) => { subAnswer({}, userStore.token).then((res) => {
console.log("key:", res); console.log("key:", res);
if (res.code == 0) { if (res.code == 0) {
userStore.updateDrawKey(res.data) userStore.updateDrawKey(res.data);
} }
}); });
} }
@ -218,11 +217,11 @@ onMounted(() => {
duration: 1.5, duration: 1.5,
ease: "slow(0.7,0.7,false)", ease: "slow(0.7,0.7,false)",
onStart: () => { onStart: () => {
gsap.to(".question-bg", { // gsap.to(".question-bg", {
backgroundPosition: "0px 835px", // backgroundPosition: "0px 835px",
duration: 0.75, // duration: 0.75,
ease: "slow(0.7,0.7,false)", // ease: "slow(0.7,0.7,false)",
}); // });
}, },
}) })
.to( .to(

View File

@ -30,6 +30,8 @@ const posterBg = reactive([
new URL("@/assets/images/result/poster-bg-4.jpg", import.meta.url).href, new URL("@/assets/images/result/poster-bg-4.jpg", import.meta.url).href,
]); ]);
// console.log("mbtiList", mbtiList.length);
const changBg = (event, number) => { const changBg = (event, number) => {
let e = event.target; let e = event.target;
if (number == bgId.value) return; if (number == bgId.value) return;
@ -51,7 +53,7 @@ onMounted(() => {
QRCode.toDataURL(eqCodeUrl) QRCode.toDataURL(eqCodeUrl)
.then((url) => { .then((url) => {
eqcodePic.value = url; eqcodePic.value = url;
console.log("eq", eqcodePic.value); // console.log("eq", eqcodePic.value);
}) })
.catch((err) => { .catch((err) => {
console.error(err); console.error(err);
@ -197,7 +199,7 @@ const goDraw = (event) => {
if (userStore.hasDraw) { if (userStore.hasDraw) {
emit("ResultPage", { action: "showDraw" }); emit("ResultPage", { action: "showDraw" });
} else { } else {
Toast("暂无抽奖机会"); Toast("今日暂无抽奖机会");
} }
}); });
}; };
@ -324,7 +326,7 @@ const hideShare = () => {
} }
.mbti-title { .mbti-title {
@include pos(480px, 120px, 90px, 418px); @include pos(600px, 120px, 90px, 418px);
font-size: 80px; font-size: 80px;
font-family: "HYYaKuHei"; font-family: "HYYaKuHei";
text-align: center; text-align: center;

View File

@ -207,7 +207,7 @@ export const data = [
export const mbtiList = [ export const mbtiList = [
{ {
type: 'INTJ', type: 'ISTJ',
job: '建筑师', job: '建筑师',
des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'], des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'],
blessings: ['江南几度梅花发', '福瘦双全有钱花'], blessings: ['江南几度梅花发', '福瘦双全有钱花'],
@ -215,7 +215,7 @@ export const mbtiList = [
productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href, productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href,
}, },
{ {
type: 'INTP', type: 'ISTP',
job: '建筑师', job: '建筑师',
des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'], des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'],
blessings: ['江南几度梅花发', '福瘦双全有钱花'], blessings: ['江南几度梅花发', '福瘦双全有钱花'],
@ -223,7 +223,7 @@ export const mbtiList = [
productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href, productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href,
}, },
{ {
type: 'ENTJ', type: 'ESTP',
job: '建筑师', job: '建筑师',
des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'], des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'],
blessings: ['江南几度梅花发', '福瘦双全有钱花'], blessings: ['江南几度梅花发', '福瘦双全有钱花'],
@ -231,7 +231,39 @@ export const mbtiList = [
productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href, productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href,
}, },
{ {
type: 'ENTP', type: 'ESTJ',
job: '建筑师',
des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'],
blessings: ['江南几度梅花发', '福瘦双全有钱花'],
product: '启航一年定开1号',
productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href,
},
{
type: 'ISFJ',
job: '建筑师',
des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'],
blessings: ['江南几度梅花发', '福瘦双全有钱花'],
product: '启航一年定开1号',
productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href,
},
{
type: 'ISFP',
job: '建筑师',
des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'],
blessings: ['江南几度梅花发', '福瘦双全有钱花'],
product: '启航一年定开1号',
productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href,
},
{
type: 'ESFP',
job: '建筑师',
des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'],
blessings: ['江南几度梅花发', '福瘦双全有钱花'],
product: '启航一年定开1号',
productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href,
},
{
type: 'ESFJ',
job: '建筑师', job: '建筑师',
des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'], des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'],
blessings: ['江南几度梅花发', '福瘦双全有钱花'], blessings: ['江南几度梅花发', '福瘦双全有钱花'],
@ -254,14 +286,6 @@ export const mbtiList = [
product: '启航一年定开1号', product: '启航一年定开1号',
productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href, productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href,
}, },
{
type: 'ENFJ',
job: '建筑师',
des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'],
blessings: ['江南几度梅花发', '福瘦双全有钱花'],
product: '启航一年定开1号',
productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href,
},
{ {
type: 'ENFP', type: 'ENFP',
job: '建筑师', job: '建筑师',
@ -271,7 +295,7 @@ export const mbtiList = [
productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href, productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href,
}, },
{ {
type: 'ISTJ', type: 'ENFJ',
job: '建筑师', job: '建筑师',
des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'], des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'],
blessings: ['江南几度梅花发', '福瘦双全有钱花'], blessings: ['江南几度梅花发', '福瘦双全有钱花'],
@ -279,7 +303,7 @@ export const mbtiList = [
productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href, productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href,
}, },
{ {
type: 'ISFJ', type: 'INTJ',
job: '建筑师', job: '建筑师',
des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'], des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'],
blessings: ['江南几度梅花发', '福瘦双全有钱花'], blessings: ['江南几度梅花发', '福瘦双全有钱花'],
@ -287,7 +311,7 @@ export const mbtiList = [
productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href, productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href,
}, },
{ {
type: 'ESTJ', type: 'INTP',
job: '建筑师', job: '建筑师',
des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'], des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'],
blessings: ['江南几度梅花发', '福瘦双全有钱花'], blessings: ['江南几度梅花发', '福瘦双全有钱花'],
@ -295,7 +319,15 @@ export const mbtiList = [
productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href, productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href,
}, },
{ {
type: 'ISTP', type: 'ENTP',
job: '建筑师',
des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'],
blessings: ['江南几度梅花发', '福瘦双全有钱花'],
product: '启航一年定开1号',
productPic: new URL('../assets/images/result/product-1.png', import.meta.url).href,
},
{
type: 'ENTJ',
job: '建筑师', job: '建筑师',
des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'], des: ['富有想象力和战略性的思想家,', '一切皆在计划之中'],
blessings: ['江南几度梅花发', '福瘦双全有钱花'], blessings: ['江南几度梅花发', '福瘦双全有钱花'],

View File

@ -97,8 +97,6 @@ const ruleFn = (item) => {
onMounted(() => { onMounted(() => {
let code = getQueryString("code"); let code = getQueryString("code");
let url = import.meta.env.VITE_URL; let url = import.meta.env.VITE_URL;
// console.log("code:", code);
// console.log("url:", url);
let dev = import.meta.env.VITE_MODE; let dev = import.meta.env.VITE_MODE;
if (dev != "dev") { if (dev != "dev") {
@ -106,7 +104,9 @@ onMounted(() => {
getUserInfo({ code: code }).then((res) => { getUserInfo({ code: code }).then((res) => {
if (res.code == 0) { if (res.code == 0) {
console.log("我的信息:", res.data); console.log("我的信息:", res.data);
userStore.updateToken(res.data.authorization); if (res.data) {
userStore.updateToken(res.data);
}
createBGM(); createBGM();
// //
showLoad.value = true; showLoad.value = true;
@ -214,7 +214,7 @@ const fontAdpat = () => {
} }
#musicBtn { #musicBtn {
@include pos(60px, 60px, 80px, 40px); @include pos(60px, 60px, 650px, 40px);
z-index: 99; z-index: 99;
} }

View File

@ -1,44 +1,36 @@
import wx from 'weixin-js-sdk'; import wx from 'weixin-js-sdk';
import axios from "axios"; import axios from "axios";
import { Toast } from "vant"; import { Toast } from "vant";
import {getShareConfig } from '@/api'
const imgUrl = new URL(`@/assets/images/share.jpg`, import.meta.url).href const imgUrl = new URL(`@/assets/images/share.jpg`, import.meta.url).href
const linkUrl = import.meta.env.VITE_HOST + import.meta.env.VITE_FOLDER const linkUrl = import.meta.env.VITE_HOST + import.meta.env.VITE_FOLDER
export function wxShare(option) { export function wxShare(option) {
let url = location.href.split('#')[0]; let url = location.href.split("#")[0];
axios.get('https://wx.xfhd.net/wxapi/api/jsconfig?appid=wx41d80a1bb01f658d', { getShareConfig({url:url})
params: { url }
})
.then((res) => { .then((res) => {
console.log('分享配置:', { console.log('分享配置:', {
'title': option.title, 'title': option.title,
'desc': option.desc, 'desc': option.desc,
'link': import.meta.env.VITE_URL 'link': url
}); });
let data = res.data; let data = res.data;
wx.config({ wx.config({
debug: false, // 开启调试模式 debug: false, // 开启调试模式
appId: data.appId, // 必填,公众号的唯一标识 appId: 'wxc2bc9f9e8d19b504', // 必填,公众号的唯一标识
timestamp: data.timestamp, // 必填,生成签名的时间戳 timestamp: data.timestamp, // 必填,生成签名的时间戳
nonceStr: data.nonceStr, // 必填,生成签名的随机串 nonceStr: data.nonceStr, // 必填,生成签名的随机串
signature: data.signature, // 必填签名见附录1 signature: data.signature, // 必填签名见附录1
jsApiList: [ jsApiList: [
'checkJsApi', 'checkJsApi',
'chooseImage',
'closeWindow',
'chooseWXPay',
'scanQRCode',
'showMenuItems', 'showMenuItems',
'onMenuShareAppMessage', 'onMenuShareAppMessage',
'onMenuShareTimeline', 'onMenuShareTimeline',
] // 必填需要使用的JS接口列表所有JS接口列表见附录2 ] // 必填需要使用的JS接口列表所有JS接口列表见附录2
}) })
wx.ready(function () { wx.ready(function () {
wx.hideMenuItems({
menuList: ["menuItem:copyUrl", "menuItem:share:appMessage", "menuItem:share:timeline"] // 屏蔽复制链接
});
wx.onMenuShareTimeline({ wx.onMenuShareTimeline({
link: import.meta.env.VITE_URL, // 分享链接 link: import.meta.env.VITE_URL, // 分享链接
title: option.title, // 分享标题 title: option.title, // 分享标题

View File

@ -6,9 +6,9 @@ export const useMainStore = defineStore("counter", {
return { return {
hasDraw: true, //是否有抽奖机会 hasDraw: true, //是否有抽奖机会
token: 'INFJ', token: 'INFJ',
MBTI: 'INTJ', //测试结果 MBTI: 'ENFP', //测试结果
hasPrize: true, //是否有奖品 hasPrize: false, //是否有奖品
prizeCode: 'DKS18', //兑换码 prizeCode: 'oggSVMbeLgSK', //兑换码
prizeMoney: '8.88', //金额 prizeMoney: '8.88', //金额
drawKey: '', drawKey: '',
} }
@ -17,12 +17,15 @@ export const useMainStore = defineStore("counter", {
getters: {}, getters: {},
// 异步处理方法 // 异步处理方法
actions: { actions: {
updateToken(token) { updateToken(data) {
this.token = token this.token = data.authorization
// this.hasDraw = data.drawNumber == 0 ? false : true
}, },
updatePrize(code, money) { updatePrize(data) {
this.prizeCode = code this.prizeCode = data.prizeCode
this.prizeMoney = money this.prizeMoney = data.prizeAmount
this.hasPrize = true
}, },
updateMBTI(type) { updateMBTI(type) {
this.MBTI = type this.MBTI = type

View File

@ -33,7 +33,7 @@ export default defineConfig(({ command, mode }) => {
template: 'index.html', template: 'index.html',
injectOptions: { injectOptions: {
data: { data: {
title: '首页', title: '测测你的花式性格',
}, },
} }
}, },