init
This commit is contained in:
134
src/App.vue
Normal file
134
src/App.vue
Normal file
@@ -0,0 +1,134 @@
|
||||
<script setup>
|
||||
import { Howl, Howler } from 'howler';
|
||||
import { onMounted, ref } from "vue"
|
||||
import { isWeixin, isLogin, getParam, Storage, Request } from "./libs/utils"
|
||||
import Login from './components/Login.vue'
|
||||
import HomePage from './components/HomePage.vue'
|
||||
import Address from "./components/Address.vue"
|
||||
import PrizeList from "./components/PrizeList.vue"
|
||||
import Todolist from "./components/TodoList.vue";
|
||||
import Rule from "./components/Rule.vue";
|
||||
import SelectTemplate from './components/SelectTemplate.vue'
|
||||
import GenerateLoading from './components/GenerateLoading.vue'
|
||||
import SelectTemplateV2 from './components/SelectTemplateV2.vue'
|
||||
import { globalStore } from "./globalstore";
|
||||
|
||||
import bgmUrl from "./assets/audio/bgm.mp3"
|
||||
import GenerateImg from './components/GenerateImg.vue';
|
||||
var bgmSound = new Howl({
|
||||
src: [bgmUrl],
|
||||
loop: true
|
||||
});
|
||||
|
||||
const loginShow = ref(false)
|
||||
const homePageShow = ref(false)
|
||||
const todolistShow = ref(true)
|
||||
|
||||
//分享进来
|
||||
const fromShare = async () => {
|
||||
const fromId = getParam("fromid")
|
||||
if (!fromId) {
|
||||
return
|
||||
}
|
||||
|
||||
const userinfos = Storage.get("userinfos")
|
||||
if (fromId === userinfos.invite_code) {
|
||||
return
|
||||
}
|
||||
|
||||
const inviteInfos = await Request("invite/info", { invite_code: fromId, type: "iceSpr" }, "GET")
|
||||
if (inviteInfos.res.status == 200) {
|
||||
const isHelp = inviteInfos.json.helps.find(v => v.id === inviteInfos.json.id)
|
||||
if (!isHelp) {
|
||||
const result = await Request("invite/help", { invite_code: fromId, type: "iceSpr" })
|
||||
if (result.res.status == 200) {
|
||||
weui.alert("受邀成功!")
|
||||
}
|
||||
} else {
|
||||
weui.alert("您已接受过其他好友邀请,每人只能受邀一次哦~")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 登录状态
|
||||
const userStatus = async (callback) => {
|
||||
const pageCode = getParam("code")
|
||||
const userinfos = Storage.get("userinfos")
|
||||
if (isWeixin()) {
|
||||
if (!pageCode) {
|
||||
weui.alert("未获取到code")
|
||||
return
|
||||
}
|
||||
const weixinResult = await Request("wechat/login", {
|
||||
code: pageCode
|
||||
})
|
||||
Storage.set("userinfos", weixinResult.json)
|
||||
if (weixinResult.json && weixinResult.json.phone) {
|
||||
loginShow.value = false
|
||||
callback && callback()
|
||||
} else {
|
||||
loginShow.value = true
|
||||
}
|
||||
} else {
|
||||
loginShow.value = true
|
||||
}
|
||||
}
|
||||
|
||||
//初始化持久数据
|
||||
const initUserGameInfos = async (refresh_official, refresh_cap_scan) => {
|
||||
const result = await Request('game/info', { refresh_official: refresh_official, refresh_cap_scan: refresh_cap_scan }, "GET")
|
||||
|
||||
if (result.res.status === 200) {
|
||||
|
||||
globalStore.invitees = result.json.invitees
|
||||
globalStore.followed_official = result.json.followed_official
|
||||
globalStore.cap_scan = result.json.cap_scan
|
||||
globalStore.game_chances_view_recipes = result.json.game_chances_view_recipes
|
||||
globalStore.MAX_VIEW_RECIPES_DAILY = result.json.constants.MAX_VIEW_RECIPES_DAILY
|
||||
globalStore.CONSUME_POINT_1_PER_DRAW = result.json.constants.CONSUME_POINT_1_PER_DRAW
|
||||
globalStore.MAX_CAP_SCAN = result.json.constants.MAX_CAP_SCAN
|
||||
globalStore.MAX_INVITE_DAILY = result.json.constants.MAX_INVITE_DAILY
|
||||
}
|
||||
}
|
||||
|
||||
const handleLoginSuccess = async () => {
|
||||
console.log("已登录")
|
||||
loginShow.value = false
|
||||
|
||||
await initUserGameInfos(true, true)
|
||||
}
|
||||
|
||||
if (isLogin()) {
|
||||
handleLoginSuccess()
|
||||
} else {
|
||||
userStatus(handleLoginSuccess)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<router-view />
|
||||
<Login :show="loginShow" @login-success="handleLoginSuccess" />
|
||||
<!-- <HomePage :show="homePageShow" /> -->
|
||||
<!-- <Todolist /> -->
|
||||
<!-- <SelectTemplateV2 /> -->
|
||||
<!-- <GenerateImg /> -->
|
||||
<!-- <GenerateLoading /> -->
|
||||
<!-- <GenerateImgConfirm /> -->
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.logo {
|
||||
height: 6em;
|
||||
padding: 1.5em;
|
||||
will-change: filter;
|
||||
transition: filter 300ms;
|
||||
}
|
||||
|
||||
.logo:hover {
|
||||
filter: drop-shadow(0 0 2em #646cffaa);
|
||||
}
|
||||
|
||||
.logo.vue:hover {
|
||||
filter: drop-shadow(0 0 2em #42b883aa);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user