剩下兑奖逻辑

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_HOST = https://test.szxgl.cn
VITE_CDN = https://test.szxgl.cn
VITE_FOLDER = /vite
VITE_API = /vite-api
VITE_HOST = https://wmm-stg.pingan.com.cn
VITE_CDN = https://cdn.xglpa.com
VITE_FOLDER = /vite-4
VITE_API = /intfgw/data/mmoactivity
VITE_URL = https://w-stg.pingan.com.cn/lckj/pawm-mmo-activity-xgl-frontend/index.html

View File

@ -50,4 +50,12 @@ export function exchangePrize(data, authorization) {
true,
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 {
const res = await drawApi({}, userStore.token);
const res = await drawApi(
{ subAnswerKey: userStore.drawKey },
userStore.token
);
if (res.code == 0) {
// isDrawn
hasPrize.value = res.data.isDrawn == 1 ? true : false; // true || false
userStore.updateDraw(); //
// if (res.data.isDrawn == 1) {
// hasPrize.value = true
// } else {
// hasPrize.value = false
// }
//
if (res.data.isDrawn == 1) {
money.value = res.data.prizeAmount;
code.value = res.data.prizeCode;
userStore.updatePrize(res.data);
}
} else {
hasPrize.value = false; // true || false
}
@ -60,15 +65,6 @@ const drawFn = (event) => {
});
gsap.killTweensOf(".draw-light,.draw");
}, 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 Preloader from "@/plugins/Preloader";
import { loadImg, pageImg } from "@/data/imgList";
import { getMyPrize } from '@/api'
import { useMainStore } from '@/store'
import { getMyPrize } from "@/api";
import { useMainStore } from "@/store";
//
const emit = defineEmits(["LoadPage"]);
const userStore = useMainStore()
const userStore = useMainStore();
const loadNum = ref(0);
@ -45,19 +45,18 @@ onMounted(() => {
duration: 0.2,
autoAlpha: 1,
onComplete: () => {
if(import.meta.env.VITE_MODE!='dev'){
getMyPrize({}, userStore.token).then(
res => {
if (import.meta.env.VITE_MODE != "dev") {
getMyPrize({}, userStore.token).then((res) => {
if (res.code == 0) {
console.log('我的奖品', res);
if(res.data){
// userStore.updatePrize(code,money)
console.log("我的奖品", res);
if (res.data) {
console.log("有奖品");
userStore.updatePrize(res.data);
}
}
}
)
});
}
Preloader({
name: "内页资源",
imgs: pageImg,
@ -81,9 +80,6 @@ onMounted(() => {
});
});
});
</script>
<template>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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