新增google验证
This commit is contained in:
parent
0f23b8ee6f
commit
bf5899833c
167
package-lock.json
generated
167
package-lock.json
generated
@ -16,11 +16,14 @@
|
||||
"core-js": "^3.8.3",
|
||||
"crypto-js": "^4.2.0",
|
||||
"element-ui": "^2.15.14",
|
||||
"google-auth-library": "^9.9.0",
|
||||
"js-cookie": "^3.0.5",
|
||||
"moment": "^2.30.1",
|
||||
"postcss-px-to-viewport": "^1.1.1",
|
||||
"swiper": "^5.4.5",
|
||||
"vue": "^2.6.14",
|
||||
"vue-google-oauth2": "^1.5.10",
|
||||
"vue-google-signin-button-directive": "^1.0.3",
|
||||
"vue-gtag": "^1.16.1",
|
||||
"vue-loader": "^15.10.1",
|
||||
"vue-router": "^3.5.1",
|
||||
@ -4519,6 +4522,17 @@
|
||||
"node": ">= 10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/agent-base": {
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmmirror.com/agent-base/-/agent-base-7.1.1.tgz",
|
||||
"integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/aggregate-error": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/aggregate-error/-/aggregate-error-3.1.0.tgz",
|
||||
@ -4965,8 +4979,7 @@
|
||||
"node_modules/base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
|
||||
},
|
||||
"node_modules/batch": {
|
||||
"version": "0.6.1",
|
||||
@ -4982,6 +4995,14 @@
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/bignumber.js": {
|
||||
"version": "9.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/bignumber.js/-/bignumber.js-9.1.2.tgz",
|
||||
"integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/binary-extensions": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.3.0.tgz",
|
||||
@ -5117,6 +5138,11 @@
|
||||
"ieee754": "^1.1.13"
|
||||
}
|
||||
},
|
||||
"node_modules/buffer-equal-constant-time": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
|
||||
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="
|
||||
},
|
||||
"node_modules/buffer-from": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/buffer-from/-/buffer-from-1.1.2.tgz",
|
||||
@ -6097,7 +6123,6 @@
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmmirror.com/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
@ -6466,6 +6491,14 @@
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ecdsa-sig-formatter": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmmirror.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
|
||||
"integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
|
||||
"dependencies": {
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmmirror.com/ee-first/-/ee-first-1.1.1.tgz",
|
||||
@ -7277,6 +7310,11 @@
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/extend": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/extend/-/extend-3.0.2.tgz",
|
||||
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
|
||||
},
|
||||
"node_modules/fast-deep-equal": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmmirror.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
||||
@ -7588,6 +7626,49 @@
|
||||
"integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/gaxios": {
|
||||
"version": "6.5.0",
|
||||
"resolved": "https://registry.npmmirror.com/gaxios/-/gaxios-6.5.0.tgz",
|
||||
"integrity": "sha512-R9QGdv8j4/dlNoQbX3hSaK/S0rkMijqjVvW3YM06CoBdbU/VdKd159j4hePpng0KuE6Lh6JJ7UdmVGJZFcAG1w==",
|
||||
"dependencies": {
|
||||
"extend": "^3.0.2",
|
||||
"https-proxy-agent": "^7.0.1",
|
||||
"is-stream": "^2.0.0",
|
||||
"node-fetch": "^2.6.9",
|
||||
"uuid": "^9.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/gaxios/node_modules/is-stream": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/is-stream/-/is-stream-2.0.1.tgz",
|
||||
"integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/gaxios/node_modules/uuid": {
|
||||
"version": "9.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/uuid/-/uuid-9.0.1.tgz",
|
||||
"integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==",
|
||||
"bin": {
|
||||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/gcp-metadata": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/gcp-metadata/-/gcp-metadata-6.1.0.tgz",
|
||||
"integrity": "sha512-Jh/AIwwgaxan+7ZUUmRLCjtchyDiqh4KjBJ5tW3plBZb5iL/BPcso8A5DlzeD9qlw0duCamnNdpFjxwaT0KyKg==",
|
||||
"dependencies": {
|
||||
"gaxios": "^6.0.0",
|
||||
"json-bigint": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/gensync": {
|
||||
"version": "1.0.0-beta.2",
|
||||
"resolved": "https://registry.npmmirror.com/gensync/-/gensync-1.0.0-beta.2.tgz",
|
||||
@ -7702,6 +7783,22 @@
|
||||
"node": ">= 4"
|
||||
}
|
||||
},
|
||||
"node_modules/google-auth-library": {
|
||||
"version": "9.9.0",
|
||||
"resolved": "https://registry.npmmirror.com/google-auth-library/-/google-auth-library-9.9.0.tgz",
|
||||
"integrity": "sha512-9l+zO07h1tDJdIHN74SpnWIlNR+OuOemXlWJlLP9pXy6vFtizgpEzMuwJa4lqY9UAdiAv5DVd5ql0Am916I+aA==",
|
||||
"dependencies": {
|
||||
"base64-js": "^1.3.0",
|
||||
"ecdsa-sig-formatter": "^1.0.11",
|
||||
"gaxios": "^6.1.1",
|
||||
"gcp-metadata": "^6.1.0",
|
||||
"gtoken": "^7.0.0",
|
||||
"jws": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/gopd": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/gopd/-/gopd-1.0.1.tgz",
|
||||
@ -7715,6 +7812,18 @@
|
||||
"resolved": "https://registry.npmmirror.com/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
||||
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="
|
||||
},
|
||||
"node_modules/gtoken": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/gtoken/-/gtoken-7.1.0.tgz",
|
||||
"integrity": "sha512-pCcEwRi+TKpMlxAQObHDQ56KawURgyAf6jtIY046fJ5tIv3zDe/LEIubckAO8fj6JnAxLdmWkUfNyulQ2iKdEw==",
|
||||
"dependencies": {
|
||||
"gaxios": "^6.0.0",
|
||||
"jws": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/gzip-size": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/gzip-size/-/gzip-size-6.0.0.tgz",
|
||||
@ -8051,6 +8160,18 @@
|
||||
"node": ">= 0.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/https-proxy-agent": {
|
||||
"version": "7.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz",
|
||||
"integrity": "sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg==",
|
||||
"dependencies": {
|
||||
"agent-base": "^7.0.2",
|
||||
"debug": "4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/human-signals": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/human-signals/-/human-signals-2.1.0.tgz",
|
||||
@ -8543,6 +8664,14 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/json-bigint": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/json-bigint/-/json-bigint-1.0.0.tgz",
|
||||
"integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==",
|
||||
"dependencies": {
|
||||
"bignumber.js": "^9.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/json-buffer": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/json-buffer/-/json-buffer-3.0.1.tgz",
|
||||
@ -8599,6 +8728,25 @@
|
||||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
},
|
||||
"node_modules/jwa": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/jwa/-/jwa-2.0.0.tgz",
|
||||
"integrity": "sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA==",
|
||||
"dependencies": {
|
||||
"buffer-equal-constant-time": "1.0.1",
|
||||
"ecdsa-sig-formatter": "1.0.11",
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/jws": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/jws/-/jws-4.0.0.tgz",
|
||||
"integrity": "sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg==",
|
||||
"dependencies": {
|
||||
"jwa": "^2.0.0",
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/keyv": {
|
||||
"version": "4.5.4",
|
||||
"resolved": "https://registry.npmmirror.com/keyv/-/keyv-4.5.4.tgz",
|
||||
@ -9497,8 +9645,7 @@
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"dev": true
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"node_modules/multicast-dns": {
|
||||
"version": "7.2.5",
|
||||
@ -13049,6 +13196,16 @@
|
||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/vue-google-oauth2": {
|
||||
"version": "1.5.10",
|
||||
"resolved": "https://registry.npmmirror.com/vue-google-oauth2/-/vue-google-oauth2-1.5.10.tgz",
|
||||
"integrity": "sha512-0+ZGbauhkBhvTln2RPyeaSvRdrka194h+MeEQngy1H4UvGOC5hxRMB8QvUrVRP/w2Tt8/ByCqGDko6MuHpFpbQ=="
|
||||
},
|
||||
"node_modules/vue-google-signin-button-directive": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmmirror.com/vue-google-signin-button-directive/-/vue-google-signin-button-directive-1.0.3.tgz",
|
||||
"integrity": "sha512-S2gG+Zu+E+B/IoyXfbz/AixVrvZhnXU+G83bTtzhUAO9RaMg597G3XUpZOHHdgWBc/Szys/kHSbPXlONjR4wjQ=="
|
||||
},
|
||||
"node_modules/vue-gtag": {
|
||||
"version": "1.16.1",
|
||||
"resolved": "https://registry.npmmirror.com/vue-gtag/-/vue-gtag-1.16.1.tgz",
|
||||
|
@ -38,6 +38,9 @@ export default {
|
||||
} else if (errmsg == "discord already binded to another account") {
|
||||
this.$showErr("discord already binded to another account");
|
||||
this.$emit("reconnection", this.itemData)
|
||||
} else if(errmsg == "google account already binded") {
|
||||
this.$showErr("google account already binded");
|
||||
this.$emit("reconnection", this.itemData)
|
||||
} else {
|
||||
this.beginCountdown();
|
||||
}
|
||||
|
@ -50,8 +50,12 @@ let errmsg = err
|
||||
errmsg = 'This X account has already been linked'
|
||||
} else if(errmsg.indexOf('discord already binded to another account') > -1) {
|
||||
errmsg = 'This Discord account has already been linked'
|
||||
} else if(errmsg.indexOf('google account already binded') > -1) {
|
||||
errmsg = 'This Google account has already been linked'
|
||||
} else if(errmsg.indexOf("Please complete the 'Connect Your X' quest first") > -1) {
|
||||
errmsg = "Please complete the 'Connect Your X' quest first"
|
||||
} else if(errmsg.indexOf("Please complete the 'Connect Your Google' quest first") > -1) {
|
||||
errmsg = "Please complete the 'Connect Your Google' quest first"
|
||||
} else if(errmsg.indexOf("Please complete the 'Connect Your Discord' quest first") > -1) {
|
||||
errmsg = "Please complete the 'Connect Your Discord' quest first"
|
||||
} else if(errmsg.indexOf("maintance now, please try later") > -1) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// const version = require('./package.json').version
|
||||
|
||||
const marketVersion = '1.0.7'
|
||||
const marketVersion = '1.0.8'
|
||||
export default marketVersion
|
@ -280,3 +280,9 @@ export const apiVoucherClaim = async (id) => {
|
||||
const url = `${API_BASE}/api/voucher/claim`;
|
||||
return httpPost(url, {id})
|
||||
}
|
||||
|
||||
// google 验证
|
||||
export const apiVerifyGoogle = async (code) => {
|
||||
const url = `${API_BASE}/api/user/verify_google`;
|
||||
return httpPost(url, {code})
|
||||
}
|
||||
|
@ -807,12 +807,25 @@ import {
|
||||
apiUsercheckin,
|
||||
apiEnhanceBox,
|
||||
apiNftList,
|
||||
apiClaimNft
|
||||
apiClaimNft,
|
||||
apiVerifyGoogle
|
||||
} from "./../../utils/webapi.js";
|
||||
import { sendToChain, sendHelp } from "./../../utils/chainapi.js";
|
||||
import { Wallet } from "@/wallet/index.js";
|
||||
import { formatShowAddress } from "@/utils/utils.js";
|
||||
import { formatDate } from '@/utils/utcdate.util.js';
|
||||
const scripts = [
|
||||
"https://apis.google.com/js/api.js",
|
||||
"https://accounts.google.com/gsi/client"
|
||||
];
|
||||
const DISCOVERY_DOC =
|
||||
"https://www.googleapis.com/discovery/v1/apis/drive/v3/rest";
|
||||
const CLIENT_ID =
|
||||
"53206975661-ih3r0ubph3rqejdq97b029difbrk2bqj.apps.googleusercontent.com";
|
||||
|
||||
// Authorization scopes required by the API; multiple scopes can be included, separated by spaces.
|
||||
const SCOPES = "openid email profile";
|
||||
let tokenClient;
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -828,7 +841,7 @@ export default {
|
||||
LogDialog,
|
||||
Loading,
|
||||
RuleDialog,
|
||||
NftPartner
|
||||
NftPartner,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -941,7 +954,8 @@ export default {
|
||||
nftsList: [],
|
||||
isNewUser: 0,
|
||||
isLoading: false,
|
||||
checkCodeInput: ""
|
||||
checkCodeInput: "",
|
||||
accessToken: "",
|
||||
};
|
||||
},
|
||||
watch: {},
|
||||
@ -977,6 +991,7 @@ export default {
|
||||
this.token = getToken();
|
||||
},
|
||||
mounted() {
|
||||
this.initGoolgeClient()
|
||||
this.initData();
|
||||
this.$nextTick(() => {
|
||||
if (this.$route.params.code) {
|
||||
@ -1023,7 +1038,9 @@ export default {
|
||||
TwitterRetweet: "Retweet",
|
||||
TwitterLike: "Like",
|
||||
DiscordJoin: "Join",
|
||||
DiscordConnect: "Connect"
|
||||
DiscordConnect: "Connect",
|
||||
GoogleConnect: "Connect",
|
||||
GameAchievement: "Retweet",
|
||||
};
|
||||
this.activeList.length = 0;
|
||||
for (let data of res.data.data.tasks) {
|
||||
@ -1075,6 +1092,9 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
GoogleToken(val) {
|
||||
this.accessToken = val
|
||||
},
|
||||
// 开始任务
|
||||
async toPost(data, onlyaction) {
|
||||
if(this.token) {
|
||||
@ -1135,6 +1155,11 @@ export default {
|
||||
} else if (data.task == "DiscordConnect") {
|
||||
bdc = true;
|
||||
this.loginDiscord();
|
||||
} else if (data.task == "GoogleConnect") {
|
||||
// bdc = true;
|
||||
if(data.status == 0 || data.status == 1) {
|
||||
await this.loginWithGoogle()
|
||||
}
|
||||
}
|
||||
|
||||
if (begintask) {
|
||||
@ -1150,6 +1175,10 @@ export default {
|
||||
this.$showErr(
|
||||
"Please complete the 'Connect Your Discord' quest first"
|
||||
);
|
||||
} else {
|
||||
this.$showErr(
|
||||
"Please complete the 'Connect Your Google' quest first"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.$showErr(`Unknown error[${res.errcode}]`);
|
||||
@ -1183,6 +1212,15 @@ export default {
|
||||
}
|
||||
});
|
||||
}
|
||||
if(val.task == "GoogleConnect") {
|
||||
this.activeList.forEach(item => {
|
||||
if(item.task != "GoogleConnect") {
|
||||
return
|
||||
} else {
|
||||
item.status = 0
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
// 检查任务状态
|
||||
async getActivitrStatue(id) {
|
||||
@ -1668,7 +1706,52 @@ export default {
|
||||
datafluxRum.addRumGlobalContext("task_type", {
|
||||
name: name
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async initGApi() {
|
||||
return new Promise((resolve, reject) => {
|
||||
gapi.load("client", async () => {
|
||||
await gapi.client.init({ discoveryDocs: [DISCOVERY_DOC] });
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
},
|
||||
initTokenClient(scopes, cb) {
|
||||
tokenClient = google.accounts.oauth2.initTokenClient({
|
||||
client_id: CLIENT_ID,
|
||||
scope: scopes,
|
||||
callback: cb // defined later
|
||||
});
|
||||
console.log("google client init success");
|
||||
},
|
||||
async initGoolgeClient() {
|
||||
await Promise.all([
|
||||
loadSingleScript([scripts[0]]),
|
||||
loadSingleScript([scripts[1]])
|
||||
]);
|
||||
await this.initGApi();
|
||||
this.initTokenClient(SCOPES);
|
||||
},
|
||||
async loginWithGoogle() {
|
||||
tokenClient.callback = async resp => {
|
||||
if (resp.error !== undefined) {
|
||||
throw resp;
|
||||
}
|
||||
let access_token = gapi.client.getToken().access_token;
|
||||
let res = await apiVerifyGoogle(access_token)
|
||||
console.log(res)
|
||||
};
|
||||
|
||||
if (gapi.client.getToken() === null) {
|
||||
// Prompt the user to select a Google Account and ask for consent to share their data
|
||||
// when establishing a new session.
|
||||
tokenClient.requestAccessToken({ prompt: "consent" });
|
||||
} else {
|
||||
// Skip display of account chooser and consent dialog for an existing session.
|
||||
tokenClient.requestAccessToken({ prompt: "" });
|
||||
return
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user