From 362c07025f2333bd9a1e9882df01b20a0736267a Mon Sep 17 00:00:00 2001 From: "huan.xu" <275942173@qq.com> Date: Thu, 23 Apr 2020 16:28:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/app.js | 2 +- src/components/common/header.vue | 59 +++++++++++++++++++++++++++++++ src/pages/index.vue | 60 -------------------------------- 3 files changed, 60 insertions(+), 61 deletions(-) diff --git a/src/api/app.js b/src/api/app.js index edf7e6c..5758b23 100644 --- a/src/api/app.js +++ b/src/api/app.js @@ -10,7 +10,7 @@ export const userApi = 'https://www.zhixinchains.com/user'; //用户 export const FILE_URL = 'https://file.zhixinchains.com/'; //图片地址 -export const yyyfApi = 'http://localhost:81101'; //用户 +export const yyyfApi = 'http://10.10.17.93:90/yyyfuser'; //用户 // export const c2cApi = 'https://c2c.flamex.io'; //法币 // export const btcApi = 'https://btc.flamex.io'; //BTC钱包 diff --git a/src/components/common/header.vue b/src/components/common/header.vue index ab2252b..8571fb3 100644 --- a/src/components/common/header.vue +++ b/src/components/common/header.vue @@ -197,6 +197,7 @@ import {getExchangeRateCookie, setExchangeRateCookie} from '@/utils/auth'; import {logOut} from '@/api/user'; import Cookie from '@/common/cookie'; import {FILE_URL} from '@/api/app'; +import {signIn} from '@/api/yyyf'; const Menu = { icon: [{t: 'nav.menu_name', link: '/'}], @@ -279,6 +280,15 @@ export default { }, created() { + let params = this.parseUrl(); + //判断是否来自以渔有方 + if ( + !$.isEmptyObject(params) && + params.userId != undefined && + params.reqType != undefined + ) { + this.loginFromYyyf(params); + } this.file = FILE_URL; this.perUrl = window.location.pathname.split('/')[1]; // console.log(this.perUrl); @@ -315,6 +325,55 @@ export default { }, methods: { + parseUrl: function() { + let params = {}; //定义数组 + let url = decodeURIComponent(location.href); + let paramsIndex = url.indexOf('?'); + if (paramsIndex != -1) { + paramsIndex = paramsIndex + 1; + let paramsStr = url.substring(paramsIndex); + let paramsAttr = paramsStr.split('&'); + for (let x in paramsAttr) { + let y = paramsAttr[x].split('='); + if (y[0] == undefined || y[0] == '') { + continue; + } + if (y[1] != undefined) { + let value = ''; + let len = y.length; + for (let j = 1; j < len; j++) { + value += + y[j] == '' && + paramsAttr[x].charAt(value.length + y[0].length + 1) != '' + ? '=' + : y[j]; + } + params[y[0]] = value; + } + } + } + return params; + }, + loginFromYyyf: function(params) { + signIn(params).then(res => { + // console.log(res); + if (res.data.code === 200) { + debugger; + this.loading = false; + //保存登录的token到cookie + // Cookie.set('token', res.data.data.token); + localStorage.setItem('yyyfToken', res.data.data.yyyfUserToken); + + //保存登录的用户信息到cookie + // Cookie.set('userData', res.data.data); + //localStorage.setItem('userData', JSON.stringify(res.data.data)); + location.href = '/'; + } else { + this.loading = false; + this.$message.warning(res.data.msg); + } + }); + }, switchLang(command) { if (!command) { return; diff --git a/src/pages/index.vue b/src/pages/index.vue index 2f9714a..427f07a 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -326,16 +326,6 @@ export default { }; }, created() { - let params = this.parseUrl(); - //判断是否来自以渔有方 - if ( - !$.isEmptyObject(params) && - params.userId != undefined && - params.reqType != undefined - ) { - this.loginFromYyyf(params); - } - // 获取图片地址 this.fileUrl = FILE_URL; @@ -371,56 +361,6 @@ export default { clearInterval(this.timer); }, methods: { - parseUrl() { - let params = {}; //定义数组 - let url = decodeURIComponent(location.href); - let paramsIndex = url.indexOf('?'); - if (paramsIndex != -1) { - paramsIndex = paramsIndex + 1; - let paramsStr = url.substring(paramsIndex); - let paramsAttr = paramsStr.split('&'); - for (let x in paramsAttr) { - let y = paramsAttr[x].split('='); - if (y[0] == undefined || y[0] == '') { - continue; - } - if (y[1] != undefined) { - let value = ''; - let len = y.length; - for (let j = 1; j < len; j++) { - value += - y[j] == '' && - paramsAttr[x].charAt(value.length + y[0].length + 1) != '' - ? '=' - : y[j]; - } - params[y[0]] = value; - } - } - } - return params; - }, - loginFromYyyf(data) { - signIn(data).then(res => { - // console.log(res); - if (res.data.code === 200) { - debugger; - this.loading = false; - //保存登录的token到cookie - // Cookie.set('token', res.data.data.token); - localStorage.setItem('yyyfToken', res.data.data.token); - - //保存登录的用户信息到cookie - // Cookie.set('userData', res.data.data); - localStorage.setItem('userData', JSON.stringify(res.data.data)); - - location.href = '/'; - } else { - this.loading = false; - this.$message.warning(res.data.msg); - } - }); - }, setSize1: function() { var width = window.innerWidth ||