完成部分接口联调
This commit is contained in:
parent
3c258cff70
commit
27b1eab2ce
@ -1 +1,5 @@
|
||||
VITE_MODE = dev
|
||||
VITE_HOST = https://wmm-stg.pingan.com.cn
|
||||
VITE_CDN = https://cdn.xglpa.com
|
||||
VITE_FOLDER = /vite-4
|
||||
VITE_API = /intfgw/data/mmoactivity
|
||||
@ -5,10 +5,12 @@ import qs from "qs";
|
||||
// json格式请求头
|
||||
const headerJSON = {
|
||||
"Content-Type": "application/json;charset=UTF-8",
|
||||
'internetGatewaySource':'internetGwSourceExt'
|
||||
};
|
||||
// FormData格式请求头
|
||||
const headerFormData = {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'internetGatewaySource':'internetGwSourceExt'
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,33 @@
|
||||
import http from './http'
|
||||
|
||||
export function drawApi(data, authorization) {
|
||||
return http.post("/api/user/addSurveyed",
|
||||
// 获取code
|
||||
export function authorize(data, authorization) {
|
||||
return http.post("/h5/Oauth/authorize",
|
||||
data,
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
// 获取用户信息
|
||||
export function getUserInfo(data, authorization) {
|
||||
return http.post("/h5/Oauth/getUserInfo",
|
||||
data,
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
// 我的奖品
|
||||
export function getMyPrize(data, authorization) {
|
||||
return http.post("/h5/activity/getMyPrize",
|
||||
data,
|
||||
true,
|
||||
authorization
|
||||
);
|
||||
}
|
||||
|
||||
// 抽奖
|
||||
export function draw(data, authorization) {
|
||||
return http.post("/h5/activity/draw",
|
||||
data,
|
||||
true,
|
||||
authorization
|
||||
|
||||
@ -4,7 +4,7 @@ import { addPoint, debounceTap } from '@/plugins'
|
||||
import { Toast } from "vant";
|
||||
import { Clipboard } from "v-clipboard";
|
||||
import { useMainStore } from "@/store";
|
||||
import { drawApi } from '@/api'
|
||||
// import { drawApi } from '@/api'
|
||||
|
||||
|
||||
// 页面配置初始化
|
||||
@ -29,16 +29,35 @@ const drawFn = (event) => {
|
||||
gsap.fromTo(e, { rotation: '-30' }, { rotation: '+30', repeat: -1, yoyo: true, ease: 'none', duration: 0.3 })
|
||||
|
||||
// const res = await drawApi({})
|
||||
const res = await draw({},userStore.token)
|
||||
|
||||
if(res.code == 0){
|
||||
// isDrawn后端判断有没有中将
|
||||
hasPrize.value = res.data.isDrawn == 1 ? true : false // true 中奖 || false 未中奖
|
||||
|
||||
setTimeout(() => {
|
||||
if(res.data.isDrawn == 1){
|
||||
hasPrize.value = true
|
||||
}else{
|
||||
|
||||
}
|
||||
}else{
|
||||
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)
|
||||
|
||||
// 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)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
<script setup>
|
||||
import { Button, Toast } from "vant";
|
||||
import { Toast } from "vant";
|
||||
import { debounceTap } from "@/plugins";
|
||||
import gsap from "gsap";
|
||||
import {draw} from '@/api'
|
||||
import {useMainStore} from '@/store'
|
||||
|
||||
const emit = defineEmits(["IndexPage"]);
|
||||
const userStore = useMainStore()
|
||||
|
||||
const start = (event) => {
|
||||
debounceTap(event.target, () => {
|
||||
|
||||
@ -4,9 +4,12 @@ import gsap from "gsap";
|
||||
import { debounceTap } from "@/plugins";
|
||||
import Preloader from "@/plugins/Preloader";
|
||||
import { loadImg, pageImg } from "@/data/imgList";
|
||||
import {getMyPrize} from '@/api'
|
||||
import {useMainStore} from '@/store'
|
||||
|
||||
// 页面配置初始化
|
||||
const emit = defineEmits(["LoadPage"]);
|
||||
const userStore = useMainStore()
|
||||
|
||||
const loadNum = ref(0);
|
||||
|
||||
@ -43,6 +46,13 @@ onMounted(() => {
|
||||
duration: 0.2,
|
||||
autoAlpha: 1,
|
||||
onComplete: () => {
|
||||
getMyPrize({},userStore.token).then(
|
||||
res=>{
|
||||
if(res.code == 0){
|
||||
console.log('我的奖品',res);
|
||||
}
|
||||
}
|
||||
)
|
||||
Preloader({
|
||||
name: "内页资源",
|
||||
imgs: pageImg,
|
||||
@ -53,6 +63,7 @@ onMounted(() => {
|
||||
},
|
||||
}).then((res) => {
|
||||
console.log("加载完成");
|
||||
|
||||
gsap.to(".LoadPage", {
|
||||
duration: 1,
|
||||
autoAlpha: 0,
|
||||
@ -65,6 +76,9 @@ onMounted(() => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@ -17,9 +17,14 @@ import Question from "@/components/Question";
|
||||
import MyPrize from "@/components/MyPrize";
|
||||
import Draw from "@/components/Draw";
|
||||
import Result from "@/components/Result";
|
||||
import { createBGM } from "@/plugins";
|
||||
import { createBGM, getQueryString } from "@/plugins";
|
||||
import { authorize, getUserInfo } from '@/api'
|
||||
import { Toast } from "vant";
|
||||
import { useMainStore } from "@/store"
|
||||
|
||||
const showLoad = ref(true);
|
||||
const userStore = useMainStore()
|
||||
|
||||
const showLoad = ref(false);
|
||||
const loadFn = (item) => {
|
||||
if (item.action == "hide") {
|
||||
showLoad.value = false;
|
||||
@ -66,7 +71,7 @@ const drawFn = (item) => {
|
||||
}
|
||||
};
|
||||
|
||||
const showResult = ref(true);
|
||||
const showResult = ref(false);
|
||||
const resultFn = (item) => {
|
||||
if (item.action == "hide") {
|
||||
showResult.value = false;
|
||||
@ -74,14 +79,102 @@ const resultFn = (item) => {
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
let code = getQueryString('code')
|
||||
console.log('code:', code);
|
||||
if (code) {
|
||||
getUserInfo({ code: code }).then(
|
||||
res => {
|
||||
if (res.code == 0) {
|
||||
console.log('我的信息:', res.data);
|
||||
userStore.updateToken(res.data.authorization)
|
||||
createBGM();
|
||||
// 开始加载组件
|
||||
showLoad.value = true
|
||||
return
|
||||
} else {
|
||||
console.log('hhhh');
|
||||
authorize({ scopeType: 1 }).then(
|
||||
res => {
|
||||
|
||||
if (res.code == 0) {
|
||||
console.log('重定向地址:', res.data);
|
||||
location.replace(res.data)
|
||||
}
|
||||
|
||||
// 活动已结束:6001
|
||||
if (res.code == '6001') {
|
||||
Toast.fail({
|
||||
message: res.msg,
|
||||
duration: 0,
|
||||
forbidClick: true
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 活动未开启:6002
|
||||
if (res.code == '6002') {
|
||||
Toast({
|
||||
message: res.msg,
|
||||
duration: 0,
|
||||
icon: 'flag-o',
|
||||
forbidClick: true
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 其余情况
|
||||
Toast.fail({
|
||||
message:res.msg,
|
||||
duration:0,
|
||||
forbidClick:true
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
)
|
||||
} else {
|
||||
authorize({ scopeType: 1 }).then(
|
||||
res => {
|
||||
|
||||
if (res.code == 0) {
|
||||
console.log('重定向地址:', res.data);
|
||||
location.replace(res.data)
|
||||
}
|
||||
|
||||
// 活动已结束:6001
|
||||
if (res.code == '6001') {
|
||||
Toast.fail({
|
||||
message: '活动已结束',
|
||||
duration: 0,
|
||||
forbidClick: true
|
||||
})
|
||||
}
|
||||
|
||||
// 活动未开启:6002
|
||||
if (res.code == '6002') {
|
||||
Toast({
|
||||
message: '活动未开始',
|
||||
duration: 0,
|
||||
icon: 'flag-o',
|
||||
forbidClick: true
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" >
|
||||
#app {
|
||||
overflow: hidden;
|
||||
background-color: rgb(255, 255, 255);
|
||||
background: linear-gradient(135deg, #f6d365, #fda085);
|
||||
}
|
||||
|
||||
#musicBtn {
|
||||
|
||||
@ -26,10 +26,12 @@ wxShare({
|
||||
|
||||
// 测试环境开vconsole
|
||||
if (isMobile()) {
|
||||
// const vConsole = new VConsole();
|
||||
|
||||
}
|
||||
|
||||
const vConsole = new VConsole();
|
||||
|
||||
|
||||
app.use(createPinia())
|
||||
app.mount('#app')
|
||||
console.log('Mode:', import.meta.env.VITE_MODE);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user