From ca3432c4f05c8fb702514d9b46b684d7aed116f3 Mon Sep 17 00:00:00 2001 From: "huan.xu" <275942173@qq.com> Date: Fri, 17 Apr 2020 21:27:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A5=E6=B8=94=E6=9C=89=E6=96=B9=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/app.js | 2 ++ src/api/yyyf.js | 17 +++++++++++++++++ src/pages/index.vue | 28 +++++++++++++++++++++++++--- 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/api/yyyf.js diff --git a/src/api/app.js b/src/api/app.js index 8184e33..edf7e6c 100644 --- a/src/api/app.js +++ b/src/api/app.js @@ -10,6 +10,8 @@ export const userApi = 'https://www.zhixinchains.com/user'; //用户 export const FILE_URL = 'https://file.zhixinchains.com/'; //图片地址 +export const yyyfApi = 'http://localhost:81101'; //用户 + // export const c2cApi = 'https://c2c.flamex.io'; //法币 // export const btcApi = 'https://btc.flamex.io'; //BTC钱包 // export const eosApi = 'https://eos.flamex.io'; //EOS钱包 diff --git a/src/api/yyyf.js b/src/api/yyyf.js new file mode 100644 index 0000000..d3e0492 --- /dev/null +++ b/src/api/yyyf.js @@ -0,0 +1,17 @@ +import request from '@/utils/request'; +import axios from 'axios'; +import Cookie from '@/common/cookie'; +import {getCurrentLanguage, languageCode2BELocalCode} from '@/common/i18n'; +import {userApi, ethApi} from './app'; + +const Host = yyyfApi + '/'; + +//登录 +export function signIn(data) { + return request({ + method: 'post', + url: Host + 'loginFromYyyf/login', + params: data, + timeout: -1, + }); +} diff --git a/src/pages/index.vue b/src/pages/index.vue index f8e257a..2f9714a 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -295,7 +295,8 @@ import {getUsd, getRange, getCurrencyUrl} from '@/api/currency'; import {getGongGao, getLunbo} from '@/api/priceSysconf.js'; import {getCurrentLanguage} from '@/common/i18n'; import {FILE_URL} from '@/api/app'; - +import Cookie from '@/common/cookie'; +import {signIn} from '@/api/yyyf'; // 引入汇率 import {getExchangeRateCookie} from '@/utils/auth'; @@ -326,13 +327,13 @@ export default { }, created() { let params = this.parseUrl(); + //判断是否来自以渔有方 if ( !$.isEmptyObject(params) && params.userId != undefined && params.reqType != undefined ) { - alert(2); - location.href = '/'; + this.loginFromYyyf(params); } // 获取图片地址 @@ -399,6 +400,27 @@ export default { } 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 ||