修改一些跳转逻辑

This commit is contained in:
cebgcontract 2022-11-16 23:57:42 +08:00
parent 11f9f297ea
commit 143601a9ea
7 changed files with 96 additions and 46 deletions

View File

@ -83,8 +83,9 @@
style="display: none" style="display: none"
></a> ></a>
<div class="dropdown-content"> <div class="dropdown-content">
<a href="# ">Quest Info</a> <a href="/recommend" id="sign_href" style="display: none;">Sign up</a>
<a href="# ">Log out</a> <a href="/rankinglist" id="quest_info">Quest Info</a>
<a href="javascript:void(0)" id="logout_btn">Log out</a>
</div> </div>
</div> </div>
</div> </div>
@ -339,6 +340,15 @@
<script src="js/model.js"></script> <script src="js/model.js"></script>
<script src="js/time.js"></script> <script src="js/time.js"></script>
<script> <script>
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
var invitecode = getUrlParam('code')
if (invitecode) {
localStorage.setItem('invite_code', invitecode)
}
var loadPic = []; var loadPic = [];
for (var i = 1; i < 101; i++) { for (var i = 1; i < 101; i++) {
loadPic.push("images/xl1/c (" + i + ").jpg"); loadPic.push("images/xl1/c (" + i + ").jpg");
@ -422,13 +432,19 @@
if (res.status == 4) { if (res.status == 4) {
$("#page_login_btn").hide(); $("#page_login_btn").hide();
$("#page_quest_btn").show(); $("#page_quest_btn").show();
$("#quest_info").show();
$("#sign_href").hide();
} else if (res.status == 1) { } else if (res.status == 1) {
$("#page_login_btn").show(); $("#page_login_btn").show();
$("#page_quest_btn").hide(); $("#page_quest_btn").hide();
$("#quest_info").hide();
$("#sign_href").show();
$("#page_login_btn").attr("href", "/sinup"); $("#page_login_btn").attr("href", "/sinup");
} else { } else {
$("#page_login_btn").show(); $("#page_login_btn").show();
$("#page_quest_btn").hide(); $("#page_quest_btn").hide();
$("#quest_info").hide();
$("#sign_href").show();
$("#page_login_btn").attr("href", "/login"); $("#page_login_btn").attr("href", "/login");
} }
} }
@ -457,9 +473,14 @@
} }
}; };
checkLogin(); checkLogin();
$("#wallet_login_btn").click(function () { $("#wallet_login_btn").click(function () {
location.href = "/sinup"; location.href = "/sinup";
}); });
$('#logout_btn').click(function(){
window.chain.logout().then(() => {
console.log('logout')
})
})
}); });
$(".anmode").each(function () { $(".anmode").each(function () {
@ -480,6 +501,8 @@
th.addClass("animated"); th.addClass("animated");
} }
} }
})
})
$(function () { $(function () {
$(".rule_sliders").click(function () { $(".rule_sliders").click(function () {
@ -543,7 +566,7 @@
$('#logined_btn').html(formatAddress(address)); $('#logined_btn').html(formatAddress(address));
$('#wallet_login_btn').hide(); $('#wallet_login_btn').hide();
$('#logined_btn').show(); $('#logined_btn').show();
$('#page_login_btn').attr('href', '/sinup'); $('#page_login_btn').attr('href', '/signup');
checkActivity(address, function() { checkActivity(address, function() {
}); });

View File

@ -6,6 +6,27 @@
<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()
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">
body{ body{

View File

@ -1,7 +1,11 @@
import axios from "axios"; import axios from "axios";
export function checkStatus(account) { export function checkStatus(account) {
return axios.post(process.env.VUE_APP_API_HOST + "/aa1/user_status", { return axios
account, .post(process.env.VUE_APP_API_HOST + "/aa1/user_status", {
}); account,
})
.then((res) => {
return res.data;
});
} }

View File

@ -67,22 +67,11 @@ export default {
this.offset += 1; this.offset += 1;
this.updateData(); this.updateData();
}, },
loadLocalData() {
let userInfo = localStorage.getItem('userinfo')
if (userInfo) {
try {
let userData = JSON.parse(userInfo)
this.account = userData.account;
console.log(userData)
} catch(err) {
}
}
},
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.account, account: this.$store.state.account,
offset: this.offset, offset: this.offset,
limit: 10, limit: 10,
}) })
@ -97,13 +86,12 @@ export default {
}, },
}, },
created() { created() {
this.loadLocalData() if (!this.$store.state.account) {
if (!this.account) {
return 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.account, account: this.$store.state.account,
offset: 0, offset: 0,
limit: 10, limit: 10,
}) })
@ -117,7 +105,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.account, account: this.$store.state.account,
}) })
.then((res) => { .then((res) => {
console.log("成功", res.data); console.log("成功", res.data);

View File

@ -158,13 +158,12 @@ export default {
}; };
}, },
created() { created() {
this.loadLocalData() if (!this.$store.state.account) {
if (!this.account) {
return; return;
} }
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: "0xCC8EFe18ca9f000786D73D993e85A9eFc3ac9417", account: this.$store.state.account,
}) })
.then((res) => { .then((res) => {
console.log("成功", res.data); console.log("成功", res.data);
@ -176,7 +175,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: "0xCC8EFe18ca9f000786D73D993e85A9eFc3ac9417", account: this.$store.state.account,
}) })
.then((res) => { .then((res) => {
console.log("成功", res.data); console.log("成功", res.data);
@ -196,16 +195,6 @@ export default {
}, 500); }, 500);
}, },
methods: { methods: {
loadLocalData() {
let userInfo = localStorage.getItem('userinfo')
if (userInfo) {
try {
let userData = JSON.parse(userInfo)
this.account = userData.account;
} catch(err) {
}
}
},
navigator() { navigator() {
this.$router.push("lisitdetails"); this.$router.push("lisitdetails");
}, },

View File

@ -13,6 +13,7 @@
</template> </template>
<script> <script>
import {checkStatus} from '@/api/webapi'
export default { export default {
data() { data() {
return { return {
@ -20,19 +21,30 @@ export default {
number:'' number:''
}; };
}, },
mounted() {
this.loadLocalData()
this.checkStatus()
},
methods: { methods: {
loadLocalData() {
let code = localStorage.getItem('invite_code')
if (code) {
this.number = code
}
},
navigator() { navigator() {
let userinfo = localStorage.getItem("userinfo");
//JSON.parse(userinfo).account
let userData = JSON.parse(userinfo)
this.$axios this.$axios
.post(process.env.VUE_APP_API_HOST + "/aa1/join", { .post(process.env.VUE_APP_API_HOST + "/aa1/join", {
account: '0xCC8EFe15ca9f000786D73D993e85A9eFc3ac9419' , account: this.$store.state.account ,
invite_code: this.number,
}) })
.then((res) => { .then((res) => {
console.log("成功", res.data); console.log(res);
this.feedList = res.data.data; if (res.data.errcode == -3) {
this.pagnation = res.data.pagnation; alert('alreay joined')
return;
}
console.log("success", res.data);
//this.$router.push("success"); //this.$router.push("success");
this.$router.push({name:'Success',params:res.data }); this.$router.push({name:'Success',params:res.data });
}) })

View File

@ -15,6 +15,7 @@
</template> </template>
<script> <script>
import {checkStatus} from '@/api/webapi'
export default { export default {
data() { data() {
return { return {
@ -23,11 +24,13 @@ export default {
}, },
mounted() { mounted() {
console.log("mounted"); console.log("mounted");
this.checkStatus()
window.addEventListener("message", (e) => { window.addEventListener("message", (e) => {
if (e.data?.type === "w3wCampaignJoinSuccess") { if (e.data?.type === "w3wCampaignJoinSuccess") {
console.log("on get iframe message: "); console.log("on get iframe message: ");
console.log(e.data); console.log(e.data);
//TODO:: , //TODO:: ,
this.checkStatus()
} }
}); });
let iframe = document.getElementById("iframe"); let iframe = document.getElementById("iframe");
@ -36,12 +39,22 @@ 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");
// TODO:: self.sendAddressToIframe(this.$store.state.account);
self.sendAddressToIframe("0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1");
}, 1000); }, 1000);
}; };
}, },
methods: { methods: {
async checkStatus() {
let res = await checkStatus(this.$store.state.account)
if (res.errcode) {
return;
}
if (res.status === 4) {
this.$router.push("rankinglist")
} else if (res.status === 1) {
this.$router.push("recommend")
}
},
navigator() { navigator() {
this.$router.push("recommend"); this.$router.push("recommend");
}, },