update sth
This commit is contained in:
parent
d0e0c3dd96
commit
11f9f297ea
@ -3,6 +3,10 @@
|
|||||||
<router-view/>
|
<router-view/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<script>
|
||||||
|
var jcchain = require("./chain/jcchain.js");
|
||||||
|
window.jcchain = jcchain;
|
||||||
|
</script>
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
body{
|
body{
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
@ -5123,7 +5123,7 @@ eval("\n/**\n * @singleton\n * class Test {}\n * new Test() === new Test() // re
|
|||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n\nvar __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, {\n enumerable: true,\n get: function get() {\n return m[k];\n }\n });\n} : function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nvar __decorate = this && this.__decorate || function (decorators, target, key, desc) {\n var c = arguments.length,\n r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,\n d;\n if ((typeof Reflect === \"undefined\" ? \"undefined\" : _typeof(Reflect)) === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {\n if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n }\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\n\nvar __exportStar = this && this.__exportStar || function (m, exports) {\n for (var p in m) {\n if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n }\n};\n\nvar __importDefault = this && this.__importDefault || function (mod) {\n return mod && mod.__esModule ? mod : {\n \"default\": mod\n };\n};\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.JCChain = void 0;\n\nvar ChainManager_1 = __importDefault(__webpack_require__(/*! ./chain/ChainManager */ \"./src/chain/ChainManager.ts\"));\n\nvar singleton_decorator_1 = __webpack_require__(/*! ./decorator/singleton.decorator */ \"./src/decorator/singleton.decorator.ts\");\n\nvar UserModule_1 = __webpack_require__(/*! ./module/UserModule */ \"./src/module/UserModule.ts\");\n\nvar JCChain =\n/** @class */\nfunction () {\n function JCChain() {\n this.chainManager = new ChainManager_1[\"default\"]();\n }\n\n JCChain.prototype.login = function () {\n return this.chainManager.login();\n };\n\n JCChain.prototype.selectWalletAndLogin = function (walletType) {\n this.chainManager.bc.walletType = walletType;\n return this.chainManager.login();\n };\n\n JCChain.prototype.logout = function () {\n return this.chainManager.logout();\n };\n\n Object.defineProperty(JCChain.prototype, \"logined\", {\n get: function get() {\n return !!UserModule_1.UserModule.token;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(JCChain.prototype, \"token\", {\n get: function get() {\n return UserModule_1.UserModule.token;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(JCChain.prototype, \"account\", {\n get: function get() {\n return UserModule_1.UserModule.accountId;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(JCChain.prototype, \"chainId\", {\n get: function get() {\n return UserModule_1.UserModule.chainId;\n },\n enumerable: false,\n configurable: true\n });\n JCChain = __decorate([singleton_decorator_1.singleton], JCChain);\n return JCChain;\n}();\n\nexports.JCChain = JCChain;\n\n__exportStar(__webpack_require__(/*! ./utils/event-bus */ \"./src/utils/event-bus.ts\"), exports);\n\n//# sourceURL=webpack://jcchain/./src/index.ts?");
|
eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n\nvar __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, {\n enumerable: true,\n get: function get() {\n return m[k];\n }\n });\n} : function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nvar __decorate = this && this.__decorate || function (decorators, target, key, desc) {\n var c = arguments.length,\n r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,\n d;\n if ((typeof Reflect === \"undefined\" ? \"undefined\" : _typeof(Reflect)) === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {\n if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n }\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\n\nvar __exportStar = this && this.__exportStar || function (m, exports) {\n for (var p in m) {\n if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n }\n};\n\nvar __importDefault = this && this.__importDefault || function (mod) {\n return mod && mod.__esModule ? mod : {\n \"default\": mod\n };\n};\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.JCChain = void 0;\n\nvar ChainManager_1 = __importDefault(__webpack_require__(/*! ./chain/ChainManager */ \"./src/chain/ChainManager.ts\"));\n\nvar singleton_decorator_1 = __webpack_require__(/*! ./decorator/singleton.decorator */ \"./src/decorator/singleton.decorator.ts\");\n\nvar UserModule_1 = __webpack_require__(/*! ./module/UserModule */ \"./src/module/UserModule.ts\");\n\nvar JCChain =\n/** @class */\nfunction () {\n function JCChain() {\n this.chainManager = new ChainManager_1[\"default\"]();\n }\n\n JCChain.prototype.login = function () {\n return this.chainManager.login();\n };\n\n JCChain.prototype.selectWalletAndLogin = function (walletType) {\n this.chainManager.bc.walletType = walletType;\n return this.chainManager.login();\n };\n\n JCChain.prototype.logout = function () {\n return this.chainManager.logout();\n };\n\n Object.defineProperty(JCChain.prototype, \"logined\", {\n get: function get() {\n return !!UserModule_1.UserModule.token;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(JCChain.prototype, \"token\", {\n get: function get() {\n return UserModule_1.UserModule.token;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(JCChain.prototype, \"account\", {\n get: function get() {\n return UserModule_1.UserModule.accountId;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(JCChain.prototype, \"chainId\", {\n get: function get() {\n return UserModule_1.UserModule.chainId;\n },\n enumerable: false,\n configurable: true\n });\n JCChain = __decorate([singleton_decorator_1.singleton], JCChain);\n return JCChain;\n}();\n\nexports.JCChain = JCChain;\n\n__exportStar(__webpack_require__(/*! ./utils/event-bus */ \"./src/utils/event-bus.ts\"), exports);\n\n__exportStar(__webpack_require__(/*! ./utils/chain.util */ \"./src/utils/chain.util.ts\"), exports);\n\n__exportStar(__webpack_require__(/*! ./utils/browser */ \"./src/utils/browser.ts\"), exports);\n\n//# sourceURL=webpack://jcchain/./src/index.ts?");
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
28
src/decorators/singleton.decorator.js
Normal file
28
src/decorators/singleton.decorator.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* @singleton
|
||||||
|
* class Test {}
|
||||||
|
* new Test() === new Test() // returns `true`
|
||||||
|
* const TestSingleton = singleton(Test)
|
||||||
|
* new TestSingleton() === new TestSingleton() //returns 'true'
|
||||||
|
*/
|
||||||
|
|
||||||
|
// eslint-disable-next-line symbol-description
|
||||||
|
export const SINGLETON_KEY = Symbol();
|
||||||
|
|
||||||
|
export const singleton = (classTarget) =>
|
||||||
|
new Proxy(classTarget, {
|
||||||
|
construct(target, argumentsList, newTarget) {
|
||||||
|
// Skip proxy for children
|
||||||
|
if (target.prototype !== newTarget.prototype) {
|
||||||
|
return Reflect.construct(target, argumentsList, newTarget);
|
||||||
|
}
|
||||||
|
if (!target[SINGLETON_KEY]) {
|
||||||
|
target[SINGLETON_KEY] = Reflect.construct(
|
||||||
|
target,
|
||||||
|
argumentsList,
|
||||||
|
newTarget
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return target[SINGLETON_KEY];
|
||||||
|
},
|
||||||
|
});
|
63
src/utils/chain.util.js
Normal file
63
src/utils/chain.util.js
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
export function verifyInjectedProvider(check) {
|
||||||
|
return window.ethereum
|
||||||
|
? window.ethereum[check]
|
||||||
|
: window.web3 &&
|
||||||
|
window.web3.currentProvider &&
|
||||||
|
window.web3.currentProvider[check];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check if there have metamask
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
export function hasMetamask() {
|
||||||
|
if (!!window.ethereum || !!window.web3) {
|
||||||
|
return verifyInjectedProvider("isMetaMask");
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* change price with customer decimals to bigNum with 18 decimals
|
||||||
|
* @param {number} price
|
||||||
|
* @param {number} decimals
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
export function parsePrice(price, decimals) {
|
||||||
|
const n = 19 - decimals;
|
||||||
|
return price + new Array(n).join("0");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* format price with customer decimals to string for display
|
||||||
|
* @param {number | string} price
|
||||||
|
* @param {number} decimals
|
||||||
|
* @param {number} fixed
|
||||||
|
* @return {number | string}
|
||||||
|
*/
|
||||||
|
export function formatPrice(price, decimals, fixed = 2) {
|
||||||
|
if (!decimals) {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
let str = price + "";
|
||||||
|
const length = str.length;
|
||||||
|
str = str.padStart(decimals, "0");
|
||||||
|
if (decimals >= length) {
|
||||||
|
str = "0." + str;
|
||||||
|
} else {
|
||||||
|
const pos = length - decimals;
|
||||||
|
str = str.slice(0, pos) + "." + str.slice(pos);
|
||||||
|
}
|
||||||
|
str = str.slice(0, str.lastIndexOf(".") + fixed + 1);
|
||||||
|
return str.replace(/0+$/, "").replace(/\.+$/, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* number to hex string
|
||||||
|
* @param {number} chainId
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
export function toHexChainId(chainId) {
|
||||||
|
return "0x" + chainId.toString(16);
|
||||||
|
}
|
22
src/utils/cookies.js
Normal file
22
src/utils/cookies.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
const languageKey = "language";
|
||||||
|
export const getLanguage = () => localStorage.getItem(languageKey);
|
||||||
|
export const setLanguage = (language) =>
|
||||||
|
localStorage.setItem(languageKey, language);
|
||||||
|
|
||||||
|
const sizeKey = "size";
|
||||||
|
export const getSize = () => localStorage.getItem(sizeKey);
|
||||||
|
export const setSize = (size) => localStorage.setItem(sizeKey, size);
|
||||||
|
|
||||||
|
const miniKey = "mini";
|
||||||
|
export const getMini = () => localStorage.getItem(miniKey);
|
||||||
|
export const setMini = (mini) => localStorage.setItem(miniKey, mini);
|
||||||
|
|
||||||
|
// User
|
||||||
|
const tokenKey = "vue_typescript_access_token";
|
||||||
|
export const getToken = () => localStorage.getItem(tokenKey);
|
||||||
|
export const setToken = (token) => localStorage.setItem(tokenKey, token);
|
||||||
|
export const removeToken = () => localStorage.removeItem(tokenKey);
|
||||||
|
|
||||||
|
export const getItem = (key) => localStorage.getItem(key);
|
||||||
|
export const setItem = (key, val) => localStorage.setItem(miniKey, val);
|
||||||
|
export const removeItem = (key) => localStorage.removeItem(key);
|
69
src/utils/resize.js
Normal file
69
src/utils/resize.js
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
import { Component, Vue, Watch } from "vue-property-decorator";
|
||||||
|
|
||||||
|
const WIDTH = 992; // refer to Bootstrap's responsive design
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
name: "ResizeMixin",
|
||||||
|
})
|
||||||
|
export default class extends Vue {
|
||||||
|
@Watch("$route")
|
||||||
|
onRouteChange() {
|
||||||
|
console.log("route change: ", this.$route?.fullPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeMount() {
|
||||||
|
window.addEventListener("resize", this.resizeHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
const mobile = isMobile();
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeDestroy() {
|
||||||
|
window.removeEventListener("resize", this.resizeHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
isMobile() {
|
||||||
|
const rect = document.body.getBoundingClientRect();
|
||||||
|
return rect.width - 1 < WIDTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
resizeHandler() {
|
||||||
|
if (!document.hidden) {
|
||||||
|
const isMobile = this.isMobile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isMobile() {
|
||||||
|
let mobile = false;
|
||||||
|
|
||||||
|
function hasTouchEvent() {
|
||||||
|
try {
|
||||||
|
document.createEvent("TouchEvent");
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasMobileUserAgent() {
|
||||||
|
if (
|
||||||
|
/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(
|
||||||
|
navigator.userAgent
|
||||||
|
) ||
|
||||||
|
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(
|
||||||
|
navigator.userAgent.substr(0, 4)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
} else if (hasTouchEvent()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mobile = hasMobileUserAgent();
|
||||||
|
|
||||||
|
return mobile;
|
||||||
|
}
|
@ -16,15 +16,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var jcchain = require("../../chain/jcchain.js");
|
|
||||||
export default {
|
export default {
|
||||||
name: "Header",
|
name: "Header",
|
||||||
created() {
|
created() {
|
||||||
this.chain = new jcchain.JCChain();
|
this.chain = new jcchain.JCChain();
|
||||||
this.chain.chainManager.init().then(() => {
|
this.chain.chainManager.init().then(() => {
|
||||||
console.log('wallet init')
|
console.log('wallet init')
|
||||||
console.log(this.chain.logined)
|
|
||||||
console.log(this.chain.account)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -57,6 +57,7 @@ export default {
|
|||||||
leaderboardMe: null,
|
leaderboardMe: null,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
busy: false,
|
busy: false,
|
||||||
|
account: '',
|
||||||
limit: 10,
|
limit: 10,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -66,11 +67,22 @@ 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: "0xCC8EFe18ca9f000786D73D993e85A9eFc3ac9417",
|
account: this.account,
|
||||||
offset: this.offset,
|
offset: this.offset,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
})
|
})
|
||||||
@ -85,9 +97,13 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
this.loadLocalData()
|
||||||
|
if (!this.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: "0xCC8EFe18ca9f000786D73D993e85A9eFc3ac9417",
|
account: this.account,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
})
|
})
|
||||||
@ -101,7 +117,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: "0xCC8EFe18ca9f000786D73D993e85A9eFc3ac9417",
|
account: this.account,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log("成功", res.data);
|
console.log("成功", res.data);
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
<p>WALLET FIRST.</p>
|
<p>WALLET FIRST.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="wallet" @click="metaMask">
|
<div class="wallet" @click="metaMask" v-if="hasMetamask">
|
||||||
METAMASK
|
METAMASK
|
||||||
<p class="recommand">Recommand</p>
|
<p class="recommand">Recommand</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="connect" @click="walletConnect">WALLET CONNECT</div>
|
<div class="connect" @click="walletConnect" v-if="showWc">WALLET CONNECT</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -21,7 +21,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var jcchain = require("../../chain/jcchain.js");
|
|
||||||
|
|
||||||
import Header from "../layout/Header.vue";
|
import Header from "../layout/Header.vue";
|
||||||
export default {
|
export default {
|
||||||
@ -32,10 +32,16 @@ export default {
|
|||||||
return {
|
return {
|
||||||
DisabLogin: false,
|
DisabLogin: false,
|
||||||
chain: null,
|
chain: null,
|
||||||
|
hasMetamask: true,
|
||||||
|
isMobile: false,
|
||||||
|
showWc: true
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.hasMetamask = jcchain.hasMetamask()
|
||||||
|
this.isMobile = jcchain.isMobile()
|
||||||
this.chain = new jcchain.JCChain();
|
this.chain = new jcchain.JCChain();
|
||||||
|
this.showWc = !(this.hasMetamask && this.isMobile)
|
||||||
this.chain.chainManager.init().then(() => {
|
this.chain.chainManager.init().then(() => {
|
||||||
if (this.chain.logined) {
|
if (this.chain.logined) {
|
||||||
this.checkWalletBind();
|
this.checkWalletBind();
|
||||||
|
@ -141,6 +141,7 @@ export default {
|
|||||||
userinfo: null,
|
userinfo: null,
|
||||||
listevent: null,
|
listevent: null,
|
||||||
currentIndex: 0,
|
currentIndex: 0,
|
||||||
|
account: '',
|
||||||
time: null,
|
time: null,
|
||||||
endTime: "2022-11-20 18:00:00",
|
endTime: "2022-11-20 18:00:00",
|
||||||
flag: false,
|
flag: false,
|
||||||
@ -157,8 +158,12 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
this.loadLocalData()
|
||||||
|
if (!this.account) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.$axios
|
this.$axios
|
||||||
.post("http://192.168.100.83:3000/aa1/user_info", {
|
.post(process.env.VUE_APP_API_HOST + "/aa1/user_info", {
|
||||||
account: "0xCC8EFe18ca9f000786D73D993e85A9eFc3ac9417",
|
account: "0xCC8EFe18ca9f000786D73D993e85A9eFc3ac9417",
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -170,7 +175,7 @@ export default {
|
|||||||
alert(err.response.data.msg);
|
alert(err.response.data.msg);
|
||||||
});
|
});
|
||||||
this.$axios
|
this.$axios
|
||||||
.post("http://192.168.100.83:3000/aa1/list_event_log", {
|
.post(process.env.VUE_APP_API_HOST + "/aa1/list_event_log", {
|
||||||
account: "0xCC8EFe18ca9f000786D73D993e85A9eFc3ac9417",
|
account: "0xCC8EFe18ca9f000786D73D993e85A9eFc3ac9417",
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -191,6 +196,16 @@ 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");
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user