Commit b69eb087 authored by 郝聪敏's avatar 郝聪敏

feature: 添加登陆功能

parent 54b11246
...@@ -3,6 +3,10 @@ import { trim, omitBy } from 'lodash'; ...@@ -3,6 +3,10 @@ import { trim, omitBy } from 'lodash';
export default class EditorController extends Controller { export default class EditorController extends Controller {
public async login(ctx: Context) {
await ctx.renderClient('login.js', {});
}
public async home(ctx: Context) { public async home(ctx: Context) {
await ctx.renderClient('editor.js', {}); await ctx.renderClient('editor.js', {});
} }
...@@ -30,12 +34,13 @@ export default class EditorController extends Controller { ...@@ -30,12 +34,13 @@ export default class EditorController extends Controller {
let where = omitBy({ let where = omitBy({
author: author && { like: `%${author}%`}, author: author && { like: `%${author}%`},
pageName: pageName && { like: `%${pageName}%`}, pageName: pageName && { like: `%${pageName}%`},
isPublish isPublish,
enable: 1
}, v => !trim(v)); }, v => !trim(v));
if (type === 'list') { if (type === 'list') {
where = { ...where, isPublish: 1 }; where = { ...where, isPublish: 1 };
} else if (type === 'my') { } else if (type === 'my') {
where = { ...where, author: 'congmin.hao' }; where = { ...where };
} else if (type === 'template') { } else if (type === 'template') {
where = { ...where, isTemplate: 1 }; where = { ...where, isTemplate: 1 };
} }
...@@ -48,4 +53,9 @@ export default class EditorController extends Controller { ...@@ -48,4 +53,9 @@ export default class EditorController extends Controller {
const list = await ctx.model.PageInfo.findAll({ where: { isTemplate: 1 } }); const list = await ctx.model.PageInfo.findAll({ where: { isTemplate: 1 } });
ctx.body = ctx.helper.ok(list); ctx.body = ctx.helper.ok(list);
} }
public async delete(ctx: Context) {
const pageInfo = await ctx.model.PageInfo.update({ enable: 0 }, {where: { id: +ctx.params.pageId }});
ctx.body = ctx.helper.ok(pageInfo);
}
} }
\ No newline at end of file
...@@ -8,6 +8,8 @@ export default (application: Application) => { ...@@ -8,6 +8,8 @@ export default (application: Application) => {
router.get('/editor/get/list', controller.editor.getList); router.get('/editor/get/list', controller.editor.getList);
router.get('/editor/get/template', controller.editor.getTemplateList); router.get('/editor/get/template', controller.editor.getTemplateList);
router.get('/editor/get/:pageId', controller.editor.get); router.get('/editor/get/:pageId', controller.editor.get);
router.delete('/editor/:pageId', controller.editor.delete);
router.get('/editor/login', controller.editor.login);
router.get('/editor', controller.editor.home); router.get('/editor', controller.editor.home);
router.get('/editor/*', controller.editor.home); router.get('/editor/*', controller.editor.home);
router.get('/activity/:id', controller.activity.home); router.get('/activity/:id', controller.activity.home);
......
import http from '../service/http.service'; import http from '../service/http.service';
import config from '../config'; import config from '../config';
const testReq = 0;
export default { export default {
getPageList(params) { getPageList(params) {
return http.get('editor/get/list', { params }); return http.get('editor/get/list', { params });
...@@ -8,6 +8,9 @@ export default { ...@@ -8,6 +8,9 @@ export default {
getPageById(params) { getPageById(params) {
return http.get(`editor/get/${params.pageId}`); return http.get(`editor/get/${params.pageId}`);
}, },
delPageById(pageId) {
return http.delete(`editor/${pageId}`);
},
updatePage(params) { updatePage(params) {
return http.post(`editor/update`, params); return http.post(`editor/update`, params);
}, },
......
import qs from 'qs';
import http from '../service/http.service';
import config from '../config';
const { opapiHost } = config;
export function getCaptcha() {
return `${opapiHost}/user/captcha`;
}
export function login(params) {
return http.post(`${opapiHost}/backStms/prologue/login`, qs.stringify(params));
}
export function getUserInfo() {
return http.get(`${opapiHost}/backStms/oauth/currentuserinfo`);
}
\ No newline at end of file
...@@ -2,6 +2,7 @@ import { Vue, Component, Prop, Watch } from 'vue-property-decorator'; ...@@ -2,6 +2,7 @@ import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
import iView from 'iview'; import iView from 'iview';
import cherryUi from '@qg/cherry-ui'; import cherryUi from '@qg/cherry-ui';
import VueContextMenu from '@editor/component/Contextmenu/index'; import VueContextMenu from '@editor/component/Contextmenu/index';
import localStorage from '@/service/localStorage.service';
import 'iview/dist/styles/iview.css'; import 'iview/dist/styles/iview.css';
import '@qg/cherry-ui/dist/cherry.css'; import '@qg/cherry-ui/dist/cherry.css';
...@@ -14,6 +15,7 @@ Vue.use(VueContextMenu); ...@@ -14,6 +15,7 @@ Vue.use(VueContextMenu);
}) })
export default class Layout extends Vue { export default class Layout extends Vue {
activeName: string = 'list'; activeName: string = 'list';
user: string = localStorage.get('user');
get isDashboard() { get isDashboard() {
return this.activeName === 'detail'; return this.activeName === 'detail';
...@@ -30,6 +32,11 @@ export default class Layout extends Vue { ...@@ -30,6 +32,11 @@ export default class Layout extends Vue {
}); });
} }
logOut() {
localStorage.clear();
window.location.href = '/editor/login';
}
created() { created() {
console.log('>>EASY_ENV_IS_NODE create', EASY_ENV_IS_NODE); console.log('>>EASY_ENV_IS_NODE create', EASY_ENV_IS_NODE);
} }
......
...@@ -11,12 +11,16 @@ ...@@ -11,12 +11,16 @@
</i-col> </i-col>
<i-col :span="21" class="layout-menu-right"> <i-col :span="21" class="layout-menu-right">
<div class="layout-header"> <div class="layout-header">
<div class="avator">
<span>{{ user.name }}</span>
<span @click="logOut" style="cursor: pointer;">退出</span>
</div>
</div> </div>
<div class="layout-content"> <div class="layout-content">
<slot></slot> <slot></slot>
</div> </div>
<div class="layout-copy"> <div class="layout-copy">
2014-2020 &copy; QuantGroup 2014-2021 &copy; QuantGroup
</div> </div>
</i-col> </i-col>
</Row> </Row>
...@@ -122,6 +126,14 @@ ...@@ -122,6 +126,14 @@
opacity: 0; opacity: 0;
} }
.avator {
float: right;
width: 120px;
height: 45px;
line-height: 45px;
font-size: 14px;
}
body { body {
/deep/ .cr-popup { /deep/ .cr-popup {
z-index: 1111; z-index: 1111;
......
import { Vue, Component, Prop } from 'vue-property-decorator';
// import cherryUi from '../../../../../node_modules/@qg/cherry-ui/src/index';
import cherryUi from '@qg/cherry-ui';
import iView from 'iview';
import '@qg/cherry-ui/dist/cherry.css';
import 'iview/dist/styles/iview.css';
Vue.use(iView);
Vue.use(cherryUi);
@Component({
name: 'Layout'
})
export default class Layout extends Vue {
@Prop({ type: String, default: 'egg' }) title?: string;
@Prop({ type: String, default: 'Vue TypeScript Framework, Server Side Render' }) description?: string;
@Prop({ type: String, default: 'Vue,TypeScript,Isomorphic' }) keywords?: string;
isNode: boolean = EASY_ENV_IS_NODE;
created() {
console.log('>>EASY_ENV_IS_NODE create', EASY_ENV_IS_NODE);
}
}
\ No newline at end of file
<template>
<html v-if="isNode">
<head>
<title>{{title}}</title>
<meta name="keywords" :content="keywords">
<meta name="description" :content="description">
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="/public/asset/css/reset.css">
<link rel="stylesheet" href="">
</head>
<body>
<div id="app"><slot></slot></div>
</body>
</html>
<div v-else-if="!isNode" id="app"><slot></slot></div>
</template>
<style>
html {
font-size: 10vw;
}
#app {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
min-width: 740px;
}
</style>
<script lang="ts" src="./index.ts"></script>
\ No newline at end of file
const protocol = window.location.protocol;
export default { export default {
apiHost: `http://localhost:7001/`, apiHost: `http://localhost:7001/`,
qiniuHost: `https://appsync.lkbang.net/`, qiniuHost: `https://appsync.lkbang.net/`,
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=default`,
opapiHost: `${protocol}//opapi.q-gp.com`,
}; };
import prod from './prod.config'; import prod from './prod.config';
import dev from './dev.config'; import dev from './dev.config';
export default process.env.EGG_SERVER_ENV === 'prod' ? prod : dev; export default process.env.NODE_ENV === 'production' ? prod : dev;
const protocol = window.location.protocol;
export default { export default {
apiHost: `http://172.20.3.77:80/`, apiHost: `http://172.20.3.77:80/`,
qiniuHost: `https://appsync.lkbang.net/`, qiniuHost: `https://appsync.lkbang.net/`,
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=production`,
opapiHost: `${protocol}//opapi.q-gp.com`
}; };
import Http from '@/service/http.service.ts'; import Http from '@/service/http.service.ts';
import Cookies from '@/service/cookieStorage.service.ts'; import Cookies from '@/service/cookieStorage.service.ts';
import localStorage from '@/service/localStorage.service.ts'; import localStorage from '@/service/localStorage.service.ts';
import { getParameterByName } from '@/service/utils.service.ts';
import qs from 'qs'; import qs from 'qs';
const ApiBaseUrl = 'http://passportapi.q-gp.com'; const ApiBaseUrl = 'http://passportapi.q-gp.com';
...@@ -11,28 +10,25 @@ export default { ...@@ -11,28 +10,25 @@ export default {
getCaptcha() { getCaptcha() {
return Http.post(ApiBaseUrl + '/api/captcha'); return Http.post(ApiBaseUrl + '/api/captcha');
}, },
sendVcode(phone, captcha, captchaId, flowFrom) { sendVcode(phone, captcha, captchaId) {
const params = { const params = {
phoneNo: phone, phoneNo: phone,
captchaId, captchaId,
captchaValue: captcha, captchaValue: captcha,
}; };
if (flowFrom) {
params.smsMerchant = flowFrom;
}
return Http.post(ApiBaseUrl + '/api/sms/send_login_code_new_forH5', qs.stringify(params)); return Http.post(ApiBaseUrl + '/api/sms/send_login_code_new_forH5', qs.stringify(params));
}, },
sendGtVcode(gt) { sendGtVcode(gt) {
return Http.post(ApiBaseUrl + '/api/sms/send_login_code_new_forH5', qs.stringify(gt)); return Http.post(ApiBaseUrl + '/api/sms/send_login_code_new_forH5', qs.stringify(gt));
}, },
fastLogin(phone, vcode, clickId, uniqueKey) { fastLogin(phone, vcode, clickId, uniqueKey, registerFrom = 1) {
const headers = { const headers = {
Authorization: 'Verification ' + btoa(phone + ':' + vcode), Authorization: 'Verification ' + btoa(phone + ':' + vcode),
}; };
const params = { const params = {
channelId: 1, channelId: 1,
createdFrom: getParameterByName('registerFrom') || 1, createdFrom: registerFrom,
key: 'xyqb', key: 'xyqb',
btRegisterChannelId: '', btRegisterChannelId: '',
dimension: '', dimension: '',
......
...@@ -55,13 +55,12 @@ ...@@ -55,13 +55,12 @@
</template> </template>
<script> <script>
// import sa from 'sa-sdk-javascript'; import Vue from 'vue';
import Storage from '@/service/localStorage.service.ts'; import Storage from '@/service/localStorage.service.ts';
import Cookies from '@/service/cookieStorage.service.ts'; import Cookies from '@/service/cookieStorage.service.ts';
import { isPhone } from '@/service/utils.service.ts'; import { isPhone } from '@/service/utils.service.ts';
import Api from './api/api.ts'; import Api from './api/api.ts';
import { getParameterByName } from '@/service/utils.service.ts'; import config from '@/config/index';
// import './jy/jy.js';
const validOptions = [ const validOptions = [
[ [
...@@ -123,33 +122,52 @@ export default { ...@@ -123,33 +122,52 @@ export default {
} }
}, },
mounted() { mounted() {
console.log('mounted');
require('./jy/jy.ts'); require('./jy/jy.ts');
sa = () => import('sa-sdk-javascript'); this.initSa();
this.verifyMode(); this.verifyMode();
}, },
methods: { methods: {
initSa() {
sa = require('sa-sdk-javascript');
//神策数据埋点
sa.init({
server_url: config.shenceUrl,
heatmap: {
//是否开启点击图,默认 default 表示开启,自动采集 $WebClick 事件,可以设置 'not_collect' 表示关闭
clickmap:'default',
//是否开启触达注意力图,默认 default 表示开启,自动采集 $WebStay 事件,可以设置 'not_collect' 表示关闭
scroll_notice_map:'default',
//判断外层是否有 App 的 SDK ,如果有的话,会往 App 的 SDK 发数据。如果没有,就正常发送数据。
// use_app_track: true,
},
show_log: process.env.NODE_ENV !== 'production'
});
//添加公共属性
sa.registerPage({platformType:'H5'});
this.$nextTick(() => {
sa.quick("autoTrackSinglePage");
});
},
async verifyMode() { async verifyMode() {
const res = await Api.verifyMode(this.gt.clientType, this.formData.phoneNo); const res = await Api.verifyMode(this.gt.clientType, this.formData.phoneNo);
this.uniqueKey = res.uniqueKey; this.uniqueKey = res?.uniqueKey;
if (res?.verifyType === 'gt') { if (res?.verifyType === 'gt') {
this.getJyParam(res); this.getJyParam(res);
} else { } else {
this.getCaptcha(); this.getCaptcha();
} }
}, },
getJyParam(res) { getJyParam({ gt, challenge, success }) {
var vm = this; var vm = this;
initGeetest( initGeetest(
{ {
width: "100%", width: "100%",
gt: res.gt, gt: gt,
challenge: res.challenge, challenge: challenge,
offline: !res.success, offline: !success,
product: "bind" product: "bind"
}, },
function(captchaObj) { function(captchaObj) {
console.log(this);
vm.$refs.sendVcode.addEventListener('click', function() { vm.$refs.sendVcode.addEventListener('click', function() {
if (!isPhone(vm.formData.phoneNo)) { if (!isPhone(vm.formData.phoneNo)) {
vm.$notify({ type: "warning", message: "请填写正确的手机号码" }); vm.$notify({ type: "warning", message: "请填写正确的手机号码" });
...@@ -158,7 +176,6 @@ export default { ...@@ -158,7 +176,6 @@ export default {
if (vm.showCount) return; if (vm.showCount) return;
captchaObj.verify(); captchaObj.verify();
}); });
// captchaObj.appendTo("#captcha-box");
captchaObj.onSuccess(function() { captchaObj.onSuccess(function() {
var result = captchaObj.getValidate(); var result = captchaObj.getValidate();
vm.gt.geetest_challenge = result.geetest_challenge; vm.gt.geetest_challenge = result.geetest_challenge;
...@@ -167,7 +184,7 @@ export default { ...@@ -167,7 +184,7 @@ export default {
vm.getCode(captchaObj); vm.getCode(captchaObj);
}); });
captchaObj.onError(function() { captchaObj.onError(function() {
this.$toast("尝试过多,请点击重试"); vm.$toast("尝试过多,请点击重试");
}); });
} }
); );
...@@ -187,8 +204,6 @@ export default { ...@@ -187,8 +204,6 @@ export default {
await this.sendCode(); await this.sendCode();
this.smsCount(); this.smsCount();
this.$notify({ type: "success", message: "短信验证码已发送,请注意查收" }); this.$notify({ type: "success", message: "短信验证码已发送,请注意查收" });
} catch(e) {
console.log(e);
} finally { } finally {
this.resetJyState(captchaObj); this.resetJyState(captchaObj);
} }
...@@ -218,29 +233,21 @@ export default { ...@@ -218,29 +233,21 @@ export default {
if(captchaObj) captchaObj.reset(); if(captchaObj) captchaObj.reset();
}, },
async login() { async login() {
const regcode = getParameterByName('registerFrom') || '';
let le_is_login_success = false; let le_is_login_success = false;
try { try {
const { phoneNo, verifyCode } = this.formData; const { phoneNo, verifyCode } = this.formData;
const { token, uuid } = await Api.fastLogin(phoneNo, verifyCode, null, this.uniqueKey); const user = await Api.fastLogin(phoneNo, verifyCode, null, this.uniqueKey, this.registerFrom);
Storage.set('token', token); this.saveInfo(user);
Cookies.set('phoneNo', phoneNo);
if (uuid) {
Cookies.set('userid', uuid);
sa.login(user.uuid);
}
le_is_login_success = true; le_is_login_success = true;
} catch(e) { this.goNext();
console.log(e);
} finally { } finally {
sa.track('LoginEvent', { sa.track('LoginEvent', {
le_login_action: '注册/登录', le_login_action: '注册/登录',
le_login_type: '验证码登录', le_login_type: '验证码登录',
le_is_login_success, le_is_login_success,
le_channel_code: regcode, le_channel_code: this.registerFrom,
}); });
} }
this.goNext();
}, },
async goNext() { async goNext() {
const extData = { redirectURL: null, productId: 1 }; const extData = { redirectURL: null, productId: 1 };
...@@ -257,6 +264,14 @@ export default { ...@@ -257,6 +264,14 @@ export default {
onFormFailed(errorInfo) { onFormFailed(errorInfo) {
const { errors } = errorInfo; const { errors } = errorInfo;
this.$notify({ type: "warning", message: errors[0].message }); this.$notify({ type: "warning", message: errors[0].message });
},
saveInfo({ token, phoneNo, uuid }) {
Storage.set('token', token);
Cookies.set('phoneNo', phoneNo);
if (uuid) {
Cookies.set('userid', uuid);
sa.login(uuid);
}
} }
}, },
}; };
...@@ -264,7 +279,6 @@ export default { ...@@ -264,7 +279,6 @@ export default {
<style lang="less"> <style lang="less">
@import './jy/jy.less'; @import './jy/jy.less';
// @import "../style/var.less";
.login-form { .login-form {
padding: 0 20px; padding: 0 20px;
width: 100%; width: 100%;
......
...@@ -18,6 +18,7 @@ export const basicComponents = [ ...@@ -18,6 +18,7 @@ export const basicComponents = [
{ {
eleName: 'cr-button', eleName: 'cr-button',
title: '按钮', title: '按钮',
h: 42,
config: [ config: [
{ {
key: 'color', key: 'color',
...@@ -39,6 +40,7 @@ export const basicComponents = [ ...@@ -39,6 +40,7 @@ export const basicComponents = [
{ {
eleName: 'cr-field', eleName: 'cr-field',
title: '输入框', title: '输入框',
h: 48,
config: [ config: [
{ {
key: 'placeholder', key: 'placeholder',
...@@ -60,6 +62,7 @@ export const basicComponents = [ ...@@ -60,6 +62,7 @@ export const basicComponents = [
{ {
eleName: 'cr-image', eleName: 'cr-image',
title: '图片', title: '图片',
h: 140,
config: [ config: [
{ {
key: 'width', key: 'width',
...@@ -144,4 +147,4 @@ export const businessComponents = [ ...@@ -144,4 +147,4 @@ export const businessComponents = [
}, },
commonStyle: {} commonStyle: {}
} }
]; ];
\ No newline at end of file
...@@ -6,7 +6,6 @@ import GridLayout from '../../component/VueGridLayout/GridLayout.vue'; ...@@ -6,7 +6,6 @@ import GridLayout from '../../component/VueGridLayout/GridLayout.vue';
import GridItem from '../../component/VueGridLayout/GridItem.vue'; import GridItem from '../../component/VueGridLayout/GridItem.vue';
import LoginForm from '@/lib/Form/index.vue'; import LoginForm from '@/lib/Form/index.vue';
import DownloadGuide from '@/lib/DownloadGuide/index.vue'; import DownloadGuide from '@/lib/DownloadGuide/index.vue';
import { Getter, State } from 'vuex-class'; import { Getter, State } from 'vuex-class';
@Component({ components: { FreedomContainer, GridLayout, GridItem, LoginForm, DownloadGuide }, name: 'Activity'}) @Component({ components: { FreedomContainer, GridLayout, GridItem, LoginForm, DownloadGuide }, name: 'Activity'})
......
import Vue from 'vue'; import Vue from 'vue';
import VueRouter from 'vue-router'; import VueRouter from 'vue-router';
import Dashboard from '../view/dashboard/index.vue'; import Dashboard from '../view/dashboard/index.vue';
import PageList from '../view/pageList/index.vue'; import PageList from '../view/pageList/index.vue';
import myPage from '../view/myPage/index.vue'; import myPage from '../view/myPage/index.vue';
import template from '../view/template/index.vue'; import template from '../view/template/index.vue';
import localStorage from '@/service/localStorage.service';
Vue.use(VueRouter); Vue.use(VueRouter);
...@@ -17,7 +17,7 @@ VueRouter.prototype.replace = function push(location) { ...@@ -17,7 +17,7 @@ VueRouter.prototype.replace = function push(location) {
}; };
export default function createRouter() { export default function createRouter() {
return new VueRouter({ const router = new VueRouter({
mode: 'history', mode: 'history',
base: '/editor/', base: '/editor/',
routes: [ routes: [
...@@ -47,4 +47,16 @@ export default function createRouter() { ...@@ -47,4 +47,16 @@ export default function createRouter() {
}, },
] ]
}); });
router.beforeEach(async (to, from, next) => {
if (to.path !== '/login') {
if (!localStorage.get('token')) {
return next('/login');
}
}
next();
});
return router;
} }
...@@ -12,6 +12,7 @@ import { ContextMenu } from '@editor/mixins/contextMenu.mixin'; ...@@ -12,6 +12,7 @@ import { ContextMenu } from '@editor/mixins/contextMenu.mixin';
import BasicPageForm from '@editor/component/BasicPageForm/index.vue'; import BasicPageForm from '@editor/component/BasicPageForm/index.vue';
import { basicComponents, businessComponents } from '@/lib/config'; import { basicComponents, businessComponents } from '@/lib/config';
import config from '@/config/index'; import config from '@/config/index';
import localStorage from '@/service/localStorage.service';
@Component({components: { DynamicComponent, FreedomContainer, DynamicForm, GridLayout: VueGridLayout.GridLayout, @Component({components: { DynamicComponent, FreedomContainer, DynamicForm, GridLayout: VueGridLayout.GridLayout,
GridItem: VueGridLayout.GridItem, LoginForm, DownloadGuide, BasicPageForm }, name: 'DashBoard'}) GridItem: VueGridLayout.GridItem, LoginForm, DownloadGuide, BasicPageForm }, name: 'DashBoard'})
...@@ -44,6 +45,7 @@ export default class DashBoard extends Mixins(ContextMenu) { ...@@ -44,6 +45,7 @@ export default class DashBoard extends Mixins(ContextMenu) {
async created() { async created() {
const { pageId, templateId } = this.$route.params; const { pageId, templateId } = this.$route.params;
console.log(pageId, templateId); console.log(pageId, templateId);
console.log('env', process.env);
this.resetPageData(); this.resetPageData();
if (pageId) { if (pageId) {
this.getPageDate({ pageId }); this.getPageDate({ pageId });
...@@ -75,12 +77,13 @@ export default class DashBoard extends Mixins(ContextMenu) { ...@@ -75,12 +77,13 @@ export default class DashBoard extends Mixins(ContextMenu) {
} }
async save(type, pageConfig) { async save(type, pageConfig) {
const user = localStorage.get('user');
if (!type) { if (!type) {
this.showSubmitPopup = true; this.showSubmitPopup = true;
} else { } else {
this.pageData.elements.sort((a, b) => a.point.y - b.point.y); this.pageData.elements.sort((a, b) => a.point.y - b.point.y);
const { pageName, pageDescribe, coverImage, isPublish, isTemplate } = pageConfig; const { pageName, pageDescribe, coverImage, isPublish, isTemplate } = pageConfig;
const pageInfo = { page: JSON.stringify(this.pageData), author: 'congmin.hao', isPublish, pageName, pageDescribe, coverImage, isTemplate }; const pageInfo = { page: JSON.stringify(this.pageData), author: user?.account, isPublish, pageName, pageDescribe, coverImage, isTemplate };
if (+this.pageId) { pageInfo.id = this.pageId; } if (+this.pageId) { pageInfo.id = this.pageId; }
await this.savePageData(pageInfo); await this.savePageData(pageInfo);
this.showSubmitPopup = false; this.showSubmitPopup = false;
......
import { Vue, Component, Emit } from 'vue-property-decorator'; import { Vue, Component, Emit } from 'vue-property-decorator';
import Layout from 'component/layout/editor/index.vue'; import Layout from 'component/layout/editor/index.vue';
@Component({ @Component({
components: { components: {
Layout Layout
} }
}) })
export default class Home extends Vue {
export default class Home extends Vue {} created() {
\ No newline at end of file console.log('created进来了');
}
}
\ No newline at end of file
<template> <template>
<div> <div>
<QGTable <QGTable
ref="qgTable"
:columns="columns" :columns="columns"
:request="query" :request="query"
@newBtnClick="addPage" @newBtnClick="addPage"
...@@ -12,6 +13,7 @@ ...@@ -12,6 +13,7 @@
import editorApi from '@api/editor.api'; import editorApi from '@api/editor.api';
import QGTable from '@editor/component/QgTable/index.vue'; import QGTable from '@editor/component/QgTable/index.vue';
import config from '@/config/index'; import config from '@/config/index';
import localStorage from '@/service/localStorage.service';
export default { export default {
components: { components: {
QGTable, QGTable,
...@@ -106,8 +108,9 @@ export default { ...@@ -106,8 +108,9 @@ export default {
...style, ...style,
}, },
on: { on: {
'on-ok': () => { 'on-ok': async () => {
console.log('删除') await editorApi.delPageById(params.row.id);
this.$refs.qgTable.query();
}, },
}, },
}, },
...@@ -139,7 +142,8 @@ export default { ...@@ -139,7 +142,8 @@ export default {
methods: { methods: {
async query(data) { async query(data) {
console.log(data); console.log(data);
return editorApi.getPageList({ type: 'my', isPublish: 0, isTemplate: 0, ...data }); const user = localStorage.get('user');
return editorApi.getPageList({ type: 'my', isPublish: 0, isTemplate: 0, author: user?.account, ...data });
}, },
addPage() { addPage() {
this.$router.push('/detail'); this.$router.push('/detail');
......
<template> <template>
<div> <div>
<QGTable <QGTable
:columns="columns" ref="qgTable"
:request="query" :columns="columns"
@newBtnClick="addPage" :request="query"
@newBtnClick="addPage"
> >
</QGTable> </QGTable>
</div> </div>
...@@ -73,6 +74,7 @@ export default { ...@@ -73,6 +74,7 @@ export default {
{ {
key: 'id', key: 'id',
title: '链接', title: '链接',
hideSearch: true,
render: (h, params) => { render: (h, params) => {
return h('span', `${config.apiHost}activity/${params.row.id}`) return h('span', `${config.apiHost}activity/${params.row.id}`)
} }
...@@ -129,8 +131,9 @@ export default { ...@@ -129,8 +131,9 @@ export default {
...style, ...style,
}, },
on: { on: {
'on-ok': () => { 'on-ok': async () => {
console.log('删除') await editorApi.delPageById(params.row.id);
this.$refs.qgTable.query();
}, },
}, },
}, },
......
...@@ -73,6 +73,7 @@ export default { ...@@ -73,6 +73,7 @@ export default {
{ {
key: 'id', key: 'id',
title: '链接', title: '链接',
hideSearch: true,
render: (h, params) => { render: (h, params) => {
return h('span', `${config.apiHost}activity/${params.row.id}`) return h('span', `${config.apiHost}activity/${params.row.id}`)
} }
......
<template>
<layout>
<div class="wrapper">
<h1>低代码平台</h1>
<div class="login">
<i-form ref="formMail" :model="formMail" :rules="ruleFormMail">
<FormItem prop="usernameMail">
<i-input v-model="formMail.usernameMail" placeholder="Username">
<Icon type="ios-person-outline" slot="prepend"></Icon>
<span slot="append">@quantgroup.cn</span>
</i-input>
</FormItem>
<FormItem prop="passwordMail">
<i-input type="password" v-model="formMail.passwordMail" placeholder="Password">
<Icon type="ios-locked-outline" slot="prepend"></Icon>
</i-input>
</FormItem>
<FormItem>
<i-button @click="login(formMail)" type="primary" long>登录</i-button>
</FormItem>
</i-form>
<div style="color: #98a6ad; text-align: center; margin-bottom: 50px;">量化派 © {{ this.year }}</div>
</div>
</div>
</layout>
</template>
<script>
import { Form, Input, FormItem, Icon, Button } from 'iview';
import localStorage from '@/service/localStorage.service';
import { login, getUserInfo, getCaptcha } from '@api/user.api';
import layout from '@component/layout/login/index.vue';
const defaultCaptcha = getCaptcha();
export default {
data() {
return {
showTips: true,
tips: '为提升各位同学使用体验,内部在用系统后续将统一迁移至量星球,请提前做好准备~',
formMail: {
usernameMail: undefined,
passwordMail: undefined,
captcha: undefined,
},
ruleFormMail: {
usernameMail: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
passwordMail: [{ required: true, message: '请输入密码', trigger: 'blur' }],
captcha: [{ required: true, message: '请输入验证码', trigger: 'blur' }],
},
year: new Date().getFullYear(),
captcha: defaultCaptcha,
};
},
components: {
'i-form': Form,
'i-input': Input,
FormItem,
Icon,
'i-button': Button,
layout
},
created() {
this.getCaptcha();
},
methods: {
login(param1) {
this.$refs['formMail'].validate(async valid => {
if (valid) {
let newParam1 = {
username: param1.usernameMail.trim(),
password: param1.passwordMail.trim(),
captcha: param1.captcha,
};
const longinInfo = await login(newParam1);
localStorage.set('token', longinInfo.accessToken);
localStorage.set('refreshToken', longinInfo.refreshToken);
const userInfo = await getUserInfo();
localStorage.set('user', userInfo);
window.location.href = '/editor/list';
}
});
},
async getCaptcha() {
this.captcha = `${defaultCaptcha}?v=${new Date().getTime()}`;
},
},
};
</script>
<style lang="less" scoped>
.marquee-box {
position: absolute;
top: 10px;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 30px;
line-height: 30px;
font-size: 18px;
color: #fff;
background-color: #ff9900;
.marquee-box-marquee {
flex: 1;
}
.marquee-box-icon {
padding: 0 10px;
}
}
.wrapper {
position: relative;
width: 100%;
height: 100%;
padding-top: 200px;
padding-bottom: 200px;
background: #001529;
}
.wrapper > h1 {
text-align: center;
vertical-align: middle;
margin-bottom: 20px;
color: #fff;
}
.login {
margin: 0 auto;
padding-top: 15px;
width: 360px;
height: 100%;
}
.captcha {
display: flex;
justify-content: space-between;
align-items: center;
.ivu-input-wrapper {
width: 180px;
}
}
</style>
...@@ -60,9 +60,10 @@ instance.interceptors.request.use( ...@@ -60,9 +60,10 @@ instance.interceptors.request.use(
} }
config.cancelToken = new CancelToken(c => (pending[config.url as string] = c)); config.cancelToken = new CancelToken(c => (pending[config.url as string] = c));
// 添加token // 添加token
const token = localStorage.get('Token'); const token = localStorage.get('token');
if (token) { if (token) {
config.headers['x-auth-token'] = token; config.headers['X-Auth-Token'] = token;
config.headers['Access-Token'] = token;
} }
return config; return config;
...@@ -79,7 +80,8 @@ instance.interceptors.response.use( ...@@ -79,7 +80,8 @@ instance.interceptors.response.use(
// afterRequest(); // afterRequest();
delete pending[response.config.url as string]; delete pending[response.config.url as string];
if (response.data.code === '0000' && response.data.businessCode === '0000') { return response.data.data; } const codeArr = ['0000', 2000];
if (codeArr.includes(response.data.code)) { return response.data.data; }
// 后端返回异常信息时提出警告 // 后端返回异常信息时提出警告
if (response.data.code && response.data.msg) { notifyType = 'warning'; } if (response.data.code && response.data.msg) { notifyType = 'warning'; }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"use strict"; "use strict";
const npm = require("npm"); const npm = require("npm");
npm.load(() => { npm.load(() => {
npm.run("build"); npm.run("start");
}); });
\ No newline at end of file
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
"version": "0.0.1", "version": "0.0.1",
"description": "低代码平台", "description": "低代码平台",
"scripts": { "scripts": {
"start": "egg-scripts start --port 80 --daemon --workers 4", "start": "egg-scripts start --port 80 --daemon --workers 1",
"stop": "egg-scripts stop", "stop": "egg-scripts stop",
"backend": "nohup egg-scripts start --port 7001 --workers 4", "backend": "nohup egg-scripts start --port 7001 --workers 4",
"dev": "egg-bin dev -r egg-ts-helper/register", "dev": "egg-bin dev -r egg-ts-helper/register",
"debug": "egg-bin debug -r egg-ts-helper/register", "debug": "egg-bin debug -r egg-ts-helper/register",
"build": "easy build && npm run start", "build": "easy build",
"tsc": "ets && tsc -p tsconfig.json", "tsc": "ets && tsc -p tsconfig.json",
"clean": "ets clean", "clean": "ets clean",
"kill": "easy kill", "kill": "easy kill",
......
...@@ -3,8 +3,7 @@ const path = require('path'); ...@@ -3,8 +3,7 @@ const path = require('path');
const resolve = filepath => path.resolve(__dirname, filepath); const resolve = filepath => path.resolve(__dirname, filepath);
module.exports = { module.exports = {
entry: { entry: {
// 'admin/login': 'app/web/page/admin/login/login.vue', 'login': 'app/web/page/login/index.vue',
// 'admin/home': 'app/web/page/admin/home/index.ts',
'editor': 'app/web/page/editor/index.ts', 'editor': 'app/web/page/editor/index.ts',
'activity': 'app/web/page/activity/index.ts', 'activity': 'app/web/page/activity/index.ts',
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment