change sth
This commit is contained in:
parent
f815364ec7
commit
b59d8caad2
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
@ -15,5 +16,9 @@
|
|||||||
"dom.iterable",
|
"dom.iterable",
|
||||||
"scripthost"
|
"scripthost"
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
"vueCompilerOptions": {
|
||||||
|
"target": 2.7,
|
||||||
|
"experimentalDisableTemplateSupport": true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
"vue-clipboard2": "^0.3.3",
|
"vue-clipboard2": "^0.3.3",
|
||||||
"vue-infinite-scroll": "^2.0.2",
|
"vue-infinite-scroll": "^2.0.2",
|
||||||
"vue-router": "^3.5.1",
|
"vue-router": "^3.5.1",
|
||||||
"vuex": "^3.6.2"
|
"vuex": "^3.6.2",
|
||||||
|
"vuex-module-decorators": "^2.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.12.16",
|
"@babel/core": "^7.12.16",
|
||||||
|
20
src/App.vue
20
src/App.vue
@ -4,28 +4,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
var jcchain = require("./chain/jcchain.js");
|
var jcchain = require("./chain/jcchain.js");
|
||||||
window.jcchain = jcchain;
|
window.jcchain = jcchain;
|
||||||
window.chain = new jcchain.JCChain()
|
window.chain = new jcchain.JCChain()
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
|
||||||
loadLocalData() {
|
|
||||||
let userInfo = localStorage.getItem('userinfo')
|
|
||||||
if (userInfo) {
|
|
||||||
try {
|
|
||||||
let userData = JSON.parse(userInfo)
|
|
||||||
this.account = userData.account;
|
|
||||||
this.$store.commit('updataAccount', userData.account);
|
|
||||||
console.log(this.$store.state.account)
|
|
||||||
} catch(err) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
console.log('app mounted')
|
|
||||||
this.loadLocalData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
|
33
src/main.js
33
src/main.js
@ -1,24 +1,23 @@
|
|||||||
import Vue from 'vue'
|
import Vue from "vue";
|
||||||
import App from './App.vue'
|
import App from "./App.vue";
|
||||||
import router from './router'
|
import router from "./router";
|
||||||
import store from './store'
|
import store from "./store";
|
||||||
import axios from 'axios';
|
import axios from "axios";
|
||||||
import VueClipBoard from 'vue-clipboard2'
|
import VueClipBoard from "vue-clipboard2";
|
||||||
// 完整引入,main.js写入以下代码
|
import "@/permission";
|
||||||
import ElementUI from 'element-ui'
|
import ElementUI from "element-ui";
|
||||||
import 'element-ui/lib/theme-chalk/index.css'
|
import "element-ui/lib/theme-chalk/index.css";
|
||||||
import "@/assets/font/font.css";
|
import "@/assets/font/font.css";
|
||||||
import infiniteScroll from 'vue-infinite-scroll'
|
import infiniteScroll from "vue-infinite-scroll";
|
||||||
Vue.use(infiniteScroll)
|
Vue.use(infiniteScroll);
|
||||||
Vue.prototype.$axios = axios;
|
Vue.prototype.$axios = axios;
|
||||||
Vue.use(ElementUI)
|
Vue.use(ElementUI);
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false;
|
||||||
|
|
||||||
|
Vue.use(VueClipBoard);
|
||||||
Vue.use(VueClipBoard)
|
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
router,
|
router,
|
||||||
store,
|
store,
|
||||||
render: h => h(App)
|
render: (h) => h(App),
|
||||||
}).$mount('#app')
|
}).$mount("#app");
|
||||||
|
42
src/permission.js
Normal file
42
src/permission.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import router from "./router/index";
|
||||||
|
import { AppModule } from "./store/modules/app";
|
||||||
|
|
||||||
|
const whiteList = ["/login", "/mobile.html"];
|
||||||
|
const loadLocalData = function () {
|
||||||
|
let userInfo = localStorage.getItem("userinfo");
|
||||||
|
if (userInfo) {
|
||||||
|
try {
|
||||||
|
let userData = JSON.parse(userInfo);
|
||||||
|
AppModule.updateAccount(userData.account);
|
||||||
|
console.log(userData);
|
||||||
|
} catch (err) {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
loadLocalData();
|
||||||
|
router.beforeEach((to, _, next) => {
|
||||||
|
// Determine whether the user has logged in
|
||||||
|
console.log(to);
|
||||||
|
if (AppModule.account) {
|
||||||
|
if (to.path === "/login") {
|
||||||
|
// If is logged in, redirect to the home page
|
||||||
|
next({ path: "/mobile.html" });
|
||||||
|
} else {
|
||||||
|
// Check whether the user has obtained his permission roles
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Has no token
|
||||||
|
if (whiteList.indexOf(to.path) !== -1) {
|
||||||
|
// In the free login whitelist, go directly
|
||||||
|
next();
|
||||||
|
} else {
|
||||||
|
// Other pages that do not have permission to access are redirected to the login page.
|
||||||
|
next(`/login?redirect=${to.fullPath}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.afterEach((to) => {
|
||||||
|
// set page title
|
||||||
|
document.title = to.meta.title;
|
||||||
|
});
|
@ -18,18 +18,21 @@ const routes = [
|
|||||||
{
|
{
|
||||||
path: "/login",
|
path: "/login",
|
||||||
name: "login",
|
name: "login",
|
||||||
|
meta: { title: "login" },
|
||||||
component: () =>
|
component: () =>
|
||||||
import(/* webpackChunkName: "login" */ "../views/mobile/Login.vue"),
|
import(/* webpackChunkName: "login" */ "../views/mobile/Login.vue"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/signup",
|
path: "/signup",
|
||||||
name: "Signup",
|
name: "Signup",
|
||||||
|
meta: { title: "Signup" },
|
||||||
component: () =>
|
component: () =>
|
||||||
import(/* webpackChunkName: "singup" */ "../views/mobile/Signup.vue"),
|
import(/* webpackChunkName: "singup" */ "../views/mobile/Signup.vue"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/recommend",
|
path: "/recommend",
|
||||||
name: "Recommend",
|
name: "Recommend",
|
||||||
|
meta: { title: "Recommend" },
|
||||||
component: () =>
|
component: () =>
|
||||||
import(
|
import(
|
||||||
/* webpackChunkName: "recommend" */ "../views/mobile/Recommend.vue"
|
/* webpackChunkName: "recommend" */ "../views/mobile/Recommend.vue"
|
||||||
@ -38,6 +41,7 @@ const routes = [
|
|||||||
{
|
{
|
||||||
path: "/success",
|
path: "/success",
|
||||||
name: "Success",
|
name: "Success",
|
||||||
|
meta: { title: "Success" },
|
||||||
component: () =>
|
component: () =>
|
||||||
import(
|
import(
|
||||||
/* webpackChunkName: "success" */ "../views/mobile/Success.vue"
|
/* webpackChunkName: "success" */ "../views/mobile/Success.vue"
|
||||||
@ -46,6 +50,7 @@ const routes = [
|
|||||||
{
|
{
|
||||||
path: "/rankinglist",
|
path: "/rankinglist",
|
||||||
name: "RankingList",
|
name: "RankingList",
|
||||||
|
meta: { title: "Quest Info" },
|
||||||
component: () =>
|
component: () =>
|
||||||
import(
|
import(
|
||||||
/* webpackChunkName: "rankinglist" */ "../views/mobile/RankingList.vue"
|
/* webpackChunkName: "rankinglist" */ "../views/mobile/RankingList.vue"
|
||||||
@ -54,6 +59,7 @@ const routes = [
|
|||||||
{
|
{
|
||||||
path: "/listdetails",
|
path: "/listdetails",
|
||||||
name: "ListDetails",
|
name: "ListDetails",
|
||||||
|
meta: { title: "Leader board" },
|
||||||
component: () =>
|
component: () =>
|
||||||
import(
|
import(
|
||||||
/* webpackChunkName: "listdetails" */ "../views/mobile/ListDetails.vue"
|
/* webpackChunkName: "listdetails" */ "../views/mobile/ListDetails.vue"
|
||||||
|
@ -3,26 +3,4 @@ import Vuex from "vuex";
|
|||||||
|
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex);
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({});
|
||||||
state() {
|
|
||||||
return {
|
|
||||||
account: "",
|
|
||||||
token: "",
|
|
||||||
status: 0,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
getters: {},
|
|
||||||
mutations: {
|
|
||||||
updataAccount(state, _account) {
|
|
||||||
state.account = _account;
|
|
||||||
},
|
|
||||||
updataToken(state, _token) {
|
|
||||||
state.token = _token;
|
|
||||||
},
|
|
||||||
updateStatus(state, _state) {
|
|
||||||
state.status = _state;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
actions: {},
|
|
||||||
modules: {},
|
|
||||||
});
|
|
||||||
|
26
src/store/modules/app.js
Normal file
26
src/store/modules/app.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import {
|
||||||
|
VuexModule,
|
||||||
|
Module,
|
||||||
|
Mutation,
|
||||||
|
Action,
|
||||||
|
getModule,
|
||||||
|
} from "vuex-module-decorators";
|
||||||
|
|
||||||
|
import store from "@/store";
|
||||||
|
|
||||||
|
@Module({ dynamic: true, store, name: "app" })
|
||||||
|
class App extends VuexModule {
|
||||||
|
account = "";
|
||||||
|
|
||||||
|
@Mutation
|
||||||
|
SET_ACCOUNT(acc) {
|
||||||
|
this.account = acc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Action
|
||||||
|
updateAccount(acc) {
|
||||||
|
this.SET_ACCOUNT(acc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const AppModule = getModule(App);
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="logo-img">
|
<div class="logo-img" @click="toHome">
|
||||||
<img class="imgs" src="../../assets/mobile/logo.png" alt="" />
|
<img class="imgs" src="../../assets/mobile/logo.png" alt="" />
|
||||||
</div>
|
</div>
|
||||||
<div class="header-login" @click="header">
|
<div class="header-login" @click="header">
|
||||||
@ -24,9 +24,6 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (!this.$store.state.account && location.pathname.indexOf('login') == -1 ) {
|
|
||||||
location.href = '/desktop.html'
|
|
||||||
}
|
|
||||||
chain.chainManager.init().then(() => {
|
chain.chainManager.init().then(() => {
|
||||||
console.log("header wallet init");
|
console.log("header wallet init");
|
||||||
});
|
});
|
||||||
@ -40,6 +37,9 @@ export default {
|
|||||||
header(){
|
header(){
|
||||||
this.hide = true
|
this.hide = true
|
||||||
},
|
},
|
||||||
|
toHome() {
|
||||||
|
location.href = '/mobile.html'
|
||||||
|
},
|
||||||
logout() {
|
logout() {
|
||||||
chain.logout();
|
chain.logout();
|
||||||
localStorage.removeItem('userinfo');
|
localStorage.removeItem('userinfo');
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { AppModule } from "@/store/modules/app";
|
||||||
import infiniteScroll from "vue-infinite-scroll";
|
import infiniteScroll from "vue-infinite-scroll";
|
||||||
export default {
|
export default {
|
||||||
directives: { infiniteScroll },
|
directives: { infiniteScroll },
|
||||||
@ -74,7 +75,7 @@ export default {
|
|||||||
updateData() {
|
updateData() {
|
||||||
this.$axios
|
this.$axios
|
||||||
.post(process.env.VUE_APP_API_HOST + "/aa1/leaderboard", {
|
.post(process.env.VUE_APP_API_HOST + "/aa1/leaderboard", {
|
||||||
account: this.$store.state.account,
|
account: AppModule.account,
|
||||||
offset: this.offset,
|
offset: this.offset,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
})
|
})
|
||||||
@ -89,12 +90,9 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (!this.$store.state.account) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.$axios
|
this.$axios
|
||||||
.post(process.env.VUE_APP_API_HOST + "/aa1/leaderboard", {
|
.post(process.env.VUE_APP_API_HOST + "/aa1/leaderboard", {
|
||||||
account: this.$store.state.account,
|
account: AppModule.account,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
})
|
})
|
||||||
@ -108,7 +106,7 @@ export default {
|
|||||||
});
|
});
|
||||||
this.$axios
|
this.$axios
|
||||||
.post(process.env.VUE_APP_API_HOST + "/aa1/leaderboard_me", {
|
.post(process.env.VUE_APP_API_HOST + "/aa1/leaderboard_me", {
|
||||||
account: this.$store.state.account,
|
account: AppModule.account,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log("成功", res.data);
|
console.log("成功", res.data);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
|
||||||
|
import { AppModule } from "@/store/modules/app";
|
||||||
import Header from "../layout/Header.vue";
|
import Header from "../layout/Header.vue";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -37,6 +38,20 @@ export default {
|
|||||||
showWc: true
|
showWc: true
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
'$route': {
|
||||||
|
handler: function(route) {
|
||||||
|
const query = route.query
|
||||||
|
if (query) {
|
||||||
|
this.redirect = query.redirect
|
||||||
|
this.otherQuery = this.getOtherQuery(query)
|
||||||
|
}
|
||||||
|
console.log(this.redirect)
|
||||||
|
console.log(this.otherQuery)
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.hasMetamask = jcchain.hasMetamask()
|
this.hasMetamask = jcchain.hasMetamask()
|
||||||
this.isMobile = jcchain.isMobile()
|
this.isMobile = jcchain.isMobile()
|
||||||
@ -52,7 +67,6 @@ export default {
|
|||||||
window.dispatchEvent(event);
|
window.dispatchEvent(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(process.env.VUE_APP_API_HOST)
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
Login() {
|
Login() {
|
||||||
@ -68,22 +82,24 @@ export default {
|
|||||||
logined: this.chain.logined,
|
logined: this.chain.logined,
|
||||||
token: this.chain.token,
|
token: this.chain.token,
|
||||||
};
|
};
|
||||||
this.$store.commit('updataAccount', this.chain.account);
|
AppModule.updateAccount(this.chain.account);
|
||||||
this.$store.commit('updataToken', this.chain.token);
|
|
||||||
window.localStorage.setItem("userinfo", JSON.stringify(userInfo));
|
window.localStorage.setItem("userinfo", JSON.stringify(userInfo));
|
||||||
let userinfo = window.localStorage.getItem("userinfo");
|
|
||||||
console.log(JSON.parse(userinfo) , "2022");
|
|
||||||
window.logincb && window.logincb();
|
window.logincb && window.logincb();
|
||||||
window.logincb = undefined;
|
window.logincb = undefined;
|
||||||
this.toggleLoginBtn();
|
|
||||||
window.onChainLogined && window.onChainLogined();
|
|
||||||
this.checkWalletBind();
|
|
||||||
let event = new Event("account_ready", {
|
let event = new Event("account_ready", {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
cancelable: false,
|
cancelable: false,
|
||||||
});
|
});
|
||||||
window.dispatchEvent(event);
|
window.dispatchEvent(event);
|
||||||
this.$router.push("/signup");
|
if (!this.redirect) {
|
||||||
|
location.href = '/mobile.html'
|
||||||
|
} else {
|
||||||
|
this.$router.push({
|
||||||
|
path: this.redirect || '/mobile.html',
|
||||||
|
query: this.otherQuery
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
chainLogin(cb) {
|
chainLogin(cb) {
|
||||||
window.logincb = cb;
|
window.logincb = cb;
|
||||||
@ -96,9 +112,14 @@ export default {
|
|||||||
walletConnect() {
|
walletConnect() {
|
||||||
this.chain.selectWalletAndLogin(2).then(this.logSuccess.bind(window));
|
this.chain.selectWalletAndLogin(2).then(this.logSuccess.bind(window));
|
||||||
},
|
},
|
||||||
toggleLoginBtn() {},
|
getOtherQuery(query) {
|
||||||
checkWalletBind() {},
|
return Object.keys(query).reduce((acc, cur) => {
|
||||||
onChainLogined() {},
|
if (cur !== 'redirect') {
|
||||||
|
acc[cur] = query[cur]
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}, {})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -171,6 +171,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import Footer from "../layout/Footer.vue";
|
import Footer from "../layout/Footer.vue";
|
||||||
import Clipboard from "clipboard";
|
import Clipboard from "clipboard";
|
||||||
|
import { AppModule } from "@/store/modules/app";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Footer,
|
Footer,
|
||||||
@ -200,13 +201,11 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (!this.$store.state.account) {
|
|
||||||
return;
|
this.address = this.formatAddress(AppModule.account)
|
||||||
}
|
|
||||||
this.address = this.formatAddress(this.$store.state.account)
|
|
||||||
this.$axios
|
this.$axios
|
||||||
.post(process.env.VUE_APP_API_HOST + "/aa1/user_info", {
|
.post(process.env.VUE_APP_API_HOST + "/aa1/user_info", {
|
||||||
account: this.$store.state.account,
|
account: AppModule.account,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log("success", res.data);
|
console.log("success", res.data);
|
||||||
@ -220,7 +219,7 @@ export default {
|
|||||||
});
|
});
|
||||||
this.$axios
|
this.$axios
|
||||||
.post(process.env.VUE_APP_API_HOST + "/aa1/list_event_log", {
|
.post(process.env.VUE_APP_API_HOST + "/aa1/list_event_log", {
|
||||||
account: this.$store.state.account,
|
account: AppModule.account,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log("success", res.data);
|
console.log("success", res.data);
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { AppModule } from '@/store/modules/app';
|
||||||
import { Message } from 'element-ui';
|
import { Message } from 'element-ui';
|
||||||
|
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ export default {
|
|||||||
navigator() {
|
navigator() {
|
||||||
this.$axios
|
this.$axios
|
||||||
.post(process.env.VUE_APP_API_HOST + "/aa1/join", {
|
.post(process.env.VUE_APP_API_HOST + "/aa1/join", {
|
||||||
account: this.$store.state.account ,
|
account: AppModule.account ,
|
||||||
invite_code: this.number,
|
invite_code: this.number,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {checkStatus} from '@/api/webapi'
|
import {checkStatus} from '@/api/webapi'
|
||||||
|
import { AppModule } from '@/store/modules/app';
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -38,13 +39,13 @@ export default {
|
|||||||
console.log("iframe load");
|
console.log("iframe load");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
console.log("send wallet address to remote page");
|
console.log("send wallet address to remote page");
|
||||||
self.sendAddressToIframe(self.$store.state.account);
|
self.sendAddressToIframe(AppModule.account);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async checkStatus() {
|
async checkStatus() {
|
||||||
let res = await checkStatus(this.$store.state.account)
|
let res = await checkStatus(AppModule.account)
|
||||||
if (res.errcode) {
|
if (res.errcode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user