diff --git a/.env.development b/.env.development
index 2ee1b39..b3e7665 100644
--- a/.env.development
+++ b/.env.development
@@ -1 +1,5 @@
-VITE_MODE = dev
\ No newline at end of file
+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
\ No newline at end of file
diff --git a/src/api/http.js b/src/api/http.js
index efa51c5..656cb55 100644
--- a/src/api/http.js
+++ b/src/api/http.js
@@ -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'
};
diff --git a/src/api/index.js b/src/api/index.js
index b321e51..74d08a6 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -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
diff --git a/src/components/Draw.vue b/src/components/Draw.vue
index 728c93b..bde8ac9 100644
--- a/src/components/Draw.vue
+++ b/src/components/Draw.vue
@@ -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 未中奖
+
+ if(res.data.isDrawn == 1){
+ hasPrize.value = true
+ }else{
- setTimeout(() => {
+ }
+ }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)
+ }
+
+ 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')
+
+ // 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)
})
}
diff --git a/src/components/Index.vue b/src/components/Index.vue
index b4fd0ed..b17f826 100644
--- a/src/components/Index.vue
+++ b/src/components/Index.vue
@@ -1,11 +1,14 @@
diff --git a/src/page/Home/App.vue b/src/page/Home/App.vue
index 8a8017e..2e89cfc 100644
--- a/src/page/Home/App.vue
+++ b/src/page/Home/App.vue
@@ -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(() => {
- createBGM();
+
+ 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
+ })
+ }
+ }
+ )
+ }
+
});
+