Browse Source

代码重构

邮箱登录
首页
创建项目
old
wangqing 5 years ago
parent
commit
0083ba8624
  1. 23
      src/api/index.js
  2. 1
      src/assets/icons/like.svg
  3. 2
      src/router/index.js
  4. 36
      src/router/modules/root.js
  5. 9
      src/store/modules/token.js
  6. 45
      src/store/modules/user.js
  7. 107
      src/views/account/login.vue
  8. 121
      src/views/home/dashboard.vue
  9. 39
      src/views/home/home-button.vue
  10. 16
      src/views/home/home-view.vue
  11. 119
      src/views/home/index.vue
  12. 5
      src/views/index.vue
  13. 28
      src/views/login.vue
  14. 232
      src/views/project/create.vue
  15. 8
      src/views/welcome.vue
  16. 3
      vue.config.js

23
src/api/index.js

@ -1,5 +1,5 @@
import axios from 'axios'
import qs from 'qs'
// import qs from 'qs'
import { MessageBox, Message } from 'element-ui'
import router from '@/router/index'
import store from '@/store/index'
@ -15,12 +15,12 @@ const toLogin = () => {
}
const api = axios.create({
baseURL: process.env.VUE_APP_API_ROOT,
baseURL: process.env.NODE_ENV !== 'development' && process.env.VUE_APP_API_ROOT,
timeout: 10000,
responseType: 'json',
withCredentials: false,
headers: {
'Content-Type': 'application/json; charset=utf-8'
'Content-Type': 'application/json'
}
})
@ -30,37 +30,32 @@ api.interceptors.request.use(
* 全局拦截请求发送前提交的参数
* 以下代码为示例在登录状态下分别对 post get 请求加上 token 参数
*/
if (store.getters['token/isLogin']) {
request.headers.token = store.state.user.token
}
if (request.method == 'post') {
if (request.data instanceof FormData) {
if (store.getters['token/isLogin']) {
if (store.getters['user/isLogin']) {
// 如果是 FormData 类型(上传图片)
request.data.append('token', store.state.token.token)
request.data.append('token', store.state.user.token)
}
} else {
// 带上 token
if (request.data == undefined) {
request.data = {}
}
if (store.getters['token/isLogin']) {
request.data.token = store.state.token.token
}
// 参数验签
let timestamp = new Date().getTime()
request.data.timestamp = '' + timestamp
let sign = signMd5Utils.getSign(request.url, request.data)
request.data.sign = sign
request.data = qs.stringify(request.data)
}
} else {
} else if (request.method === 'get') {
// 带上 token
if (request.params == undefined) {
request.params = {}
}
if (store.getters['token/isLogin']) {
request.params.token = store.state.token.token
}
let timestamp = new Date().getTime()
console.log(request.params)
request.params.timestamp = '' + timestamp
let sign = signMd5Utils.getSign(request.url, request.params)
request.params.sign = sign

1
src/assets/icons/like.svg

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1605449862303" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1143" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M332.8 249.6c38.4 0 83.2 19.2 108.8 44.8L467.2 320 512 364.8 556.8 320l25.6-25.6c32-32 70.4-44.8 108.8-44.8 19.2 0 38.4 6.4 57.6 12.8 44.8 25.6 70.4 57.6 76.8 108.8 6.4 44.8-6.4 89.6-38.4 121.6L512 774.4 236.8 492.8C204.8 460.8 185.6 416 192 371.2c6.4-44.8 38.4-83.2 76.8-108.8C288 256 313.6 249.6 332.8 249.6L332.8 249.6M332.8 185.6C300.8 185.6 268.8 192 243.2 204.8 108.8 275.2 89.6 441.6 185.6 537.6l281.6 281.6C480 832 499.2 838.4 512 838.4s32-6.4 38.4-19.2l281.6-281.6c96-96 76.8-262.4-57.6-332.8-25.6-12.8-57.6-19.2-89.6-19.2-57.6 0-115.2 25.6-153.6 64L512 275.2 486.4 249.6C448 211.2 390.4 185.6 332.8 185.6L332.8 185.6z" p-id="1144"></path></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

2
src/router/index.js

@ -46,7 +46,7 @@ Router.prototype.replace = function replace(location) {
router.beforeEach((to, from, next) => {
NProgress.start()
if (to.meta.requireLogin) {
if (store.getters['token/isLogin']) {
if (store.getters['user/isLogin']) {
next()
NProgress.done()
} else {

36
src/router/modules/root.js

@ -1,34 +1,56 @@
export default [
{
path: '/',
meta: { requireLogin: false },
component: () => import(/* webpackChunkName: 'root' */ '@/views/Home.vue'),
meta: {requireLogin: false},
component: () => import(/* webpackChunkName: 'root' */ '@/views/welcome.vue'),
children: [
{
path: '/login',
meta: { requireLogin: false },
meta: {requireLogin: false},
component: () => import(/* webpackChunkName: 'root' */ '@/views/account/login.vue')
},
{
path: '/enterprise',
meta: { requireLogin: false },
meta: {requireLogin: false},
component: () => import(/* webpackChunkName: 'root' */ '@/views/common/enterprise/index.vue')
},
{
path: '/sources',
meta: { requireLogin: false },
meta: {requireLogin: false},
component: () => import(/* webpackChunkName: 'root' */ '@/views/common/sources/index.vue')
},
{
path: '/proposal',
meta: { requireLogin: false },
meta: {requireLogin: false},
component: () => import(/* webpackChunkName: 'root' */ '@/views/common/proposal/index.vue')
},
{
path: '/console',
meta: { requireLogin: true },
meta: {requireLogin: true},
component: () => import(/* webpackChunkName: 'root' */ '@/views/account/console/index.vue')
}
]
}, {
path: '/home',
meta: {requireLogin: true},
component: () => import(/* webpackChunkName: 'root' */ '@/views/home/index.vue'),
children: [
{
path: '/',
meta: {requireLogin: true},
component: () => import(/* webpackChunkName: 'root' */ '@/views/home/home-view')
}
]
}, {
path: '/project',
meta: {requireLogin: true},
component: () => import(/* webpackChunkName: 'root' */ '@/views/home/index.vue'),
children: [
{
path: 'create',
meta: {requireLogin: true},
component: () => import(/* webpackChunkName: 'root' */ '@/views/project/create.vue')
}
]
}
]

9
src/store/modules/token.js

@ -7,14 +7,7 @@ const state = {
const getters = {
isLogin: state => {
let retn = false
if (state.token != null) {
let unix = Date.parse(new Date())
if (unix < state.failuretime * 1000) {
retn = true
}
}
return retn
return state.token
}
}

45
src/store/modules/user.js

@ -0,0 +1,45 @@
// import api from '@/api'
const state = {
token: localStorage.token,
userInfo: localStorage.userInfo
}
const getters = {
isLogin: state => {
return state.token
},
userInfo: state => {
return state.userInfo
}
}
const actions = {
login(context, payload) {
return new Promise(resolve => {
// 模拟登录成功,写入 token 信息
context.commit('setData', {
token: payload.token,
userInfo: payload
})
resolve()
})
}
}
const mutations = {
setData(state, data) {
localStorage.setItem('token', data.token)
localStorage.setItem('userInfo', JSON.stringify(data.userInfo))
state.token = data.token
state.userInfo = data.userInfo
}
}
export default {
namespaced: true,
state,
actions,
getters,
mutations
}

107
src/views/account/login.vue

@ -35,14 +35,16 @@
</div>
</el-tab-pane>
<el-tab-pane label="账号密码登录" name="account">
<el-form ref="form" label-position="top" size="small" :model="account"
class="account-login-form"
<el-form ref="accountLoginForm" label-position="top" size="small" :model="accountForm" :rules="accountLoginRules"
class="account-login-form" status-icon hide-required-asterisk
>
<el-form-item label="手机号/邮箱登录">
<el-input v-model="account.username" placeholder="请输入手机号/邮箱" autocomplete="off" />
<el-form-item label="手机号/邮箱登录" prop="account">
<el-input v-model="accountForm.account" placeholder="请输入手机号/邮箱" autocomplete="off" />
</el-form-item>
<el-form-item label="密码">
<el-input v-model="account.password" placeholder="请输入密码" autocomplete="off" show-password />
<el-form-item label="密码" prop="password">
<el-input v-model="accountForm.password" placeholder="请输入密码" autocomplete="off"
show-password
/>
</el-form-item>
<el-form-item label="">
<el-radio v-model="agreeProtocol" label="" />
@ -53,7 +55,7 @@
</el-link>
</el-form-item>
<el-form-item>
<el-button style="width: 100%;" type="primary">登录</el-button>
<el-button style="width: 100%;" type="primary" @click="loginHandle">登录</el-button>
</el-form-item>
<el-form-item style="text-align: center;">
<span class="protocol-tip">使用第三方登录 </span>
@ -75,15 +77,19 @@
@tab-click="registerHandleClick"
>
<el-tab-pane label="手机号注册" name="regPhone">
<el-form ref="form" :model="account" label-width="0px">
<el-form ref="form" :model="accountForm" label-width="0px">
<el-form-item label="">
<el-input v-model="account.username" placeholder="请输入手机号" autocomplete="off" />
<el-input v-model="accountForm.username" placeholder="请输入手机号" autocomplete="off" />
</el-form-item>
<el-form-item label="">
<el-input v-model="account.password" show-password placeholder="请输入密码" autocomplete="off" />
<el-input v-model="accountForm.password" show-password placeholder="请输入密码"
autocomplete="off"
/>
</el-form-item>
<el-form-item label="">
<el-input v-model="account.code" style="width: 150px;" placeholder="请输入验证码" autocomplete="off" />
<el-input v-model="accountForm.code" style="width: 150px;" placeholder="请输入验证码"
autocomplete="off"
/>
<el-button style="margin-left: 20px;" type="primary">发送验证码</el-button>
</el-form-item>
<el-form-item>
@ -92,22 +98,25 @@
</el-form>
</el-tab-pane>
<el-tab-pane label="邮箱注册" name="regEmail">
<el-form ref="emailRegForm" status-icon :rules="emailRegRules" :model="account"
<el-form ref="emailRegForm" status-icon :rules="emailRegRules" :model="accountForm"
label-width="0px"
>
<el-form-item label="" prop="email">
<el-input v-model="account.email" placeholder="请输入邮箱" autocomplete="off" />
<el-input v-model="accountForm.email" placeholder="请输入邮箱" autocomplete="off" />
</el-form-item>
<el-form-item label="" prop="password">
<el-input v-model="account.password" show-password placeholder="请输入密码"
<el-input v-model="accountForm.password" show-password placeholder="请输入密码"
autocomplete="off"
/>
</el-form-item>
<el-form-item label="">
<el-input v-model="account.code" oninput="value=value.replace(/[^\d]/g,'')" style="width: 150px;" maxlength="4" placeholder="请输入验证码"
<el-form-item label="" prop="code">
<el-input v-model="accountForm.code" oninput="value=value.replace(/[^\d]/g,'')"
style="width: 150px;" maxlength="4" placeholder="请输入验证码"
autocomplete="off"
/>
<el-button style="margin-left: 20px;" :disabled="validateCodeBtn" type="primary" @click="sendEmailCodeHandle">
<el-button style="margin-left: 20px;" :disabled="validateCodeBtn" type="primary"
@click="sendEmailCodeHandle"
>
{{ validateCodeBtnText }}
</el-button>
</el-form-item>
@ -141,11 +150,21 @@ export default {
callback()
}
}
const validateAccount = (rule, value, callback) => {
// /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[\W_]).{10,20}$/
const reg1 = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/
const reg2 = /^(?:0|86|\+86)?1[3456789]\d{9}$/
if (reg1.test(value) || reg2.test(value)) {
callback()
} else {
callback(new Error('请输入正确的账号'))
}
}
return {
loginType: 'wx',
validateCodeBtn: false,
validateCodeBtnText: '发送验证码',
formType: 'reg',
formType: 'login',
regType: 'regPhone',
agreeProtocol: '',
emailRegRules: {
@ -159,7 +178,12 @@ export default {
password: [{required: true, trigger: 'blur', validator: validatePassword}],
code: {required: true, trigger: 'blur', message: '请输入验证码'}
},
account: {
accountLoginRules: {
account: [
{required: true, trigger: 'blur', message: '请输入账号'}, {trigger: 'blur', validator: validateAccount}],
password: [{required: true, trigger: 'blur', validator: validatePassword}]
},
accountForm: {
email: '',
password: ''
},
@ -174,13 +198,14 @@ export default {
sendEmailCodeHandle() {
this.$refs.emailRegForm.validateField('email', err => {
if (!err) {
this.validateCodeBtn = true
this.$api.get(`/user/send-email-code?email=${this.account.email}`).then(() => {
this.msgSuccess('验证码发送成功,5分钟内有效')
this.validateCodeBtn = true
let count = 60
let timer = setInterval(() => {
count--
this.validateCodeBtnText = count + 's'
this.validateCodeBtnText = count + 's后重新发送'
if (count == 0) {
this.validateCodeBtnText = '发送验证码'
clearInterval(timer)
@ -193,27 +218,42 @@ export default {
emailRegHandle() {
this.$refs['emailRegForm'].validate(valid => {
if (valid) {
this.$api.post('/user/email-register', this.account).then(() => {
this.$api.post('/user/email-register', this.accountForm).then(() => {
this.msgSuccess('注册成功,快去登录吧')
setTimeout(() => {
this.formType = 'login'
this.loginType = 'account'
}, 1000)
})
} else {
return false
}
})
},
login() {
this.$store.dispatch('token/login').then(() => {
//
if (this.$route.query.redirect) {
this.$router.replace({
path: this.$route.query.redirect
loginHandle() {
this.$refs['accountLoginForm'].validate(valid => {
if (valid) {
this.$api.post('/user/account-login', this.accountForm).then(res => {
this.msgSuccess('登录成功')
this.$store.dispatch('user/login', res.data).then(() => {
//
// eslint-disable-next-line no-debugger
debugger
if (this.$route.query.redirect) {
this.$router.replace({
path: this.$route.query.redirect
})
} else {
if (window.history.length <= 1) {
this.$router.push({path: '/home'})
} else {
this.$router.push({path: '/home'})
}
}
})
})
} else {
if (window.history.length <= 1) {
this.$router.push({path: '/'})
} else {
this.$router.go(-1)
}
return false
}
})
}
@ -222,7 +262,6 @@ export default {
</script>
<style scoped>
.loginBody {
/* border: solid thin black; */
margin: 70px 0 0 0;
}
.loginBackImg {
@ -257,7 +296,7 @@ export default {
line-height: 20px;
}
.account-login-form .el-form-item--small.el-form-item {
margin-bottom: 5px;
margin-bottom: 8px;
}
.account-login-form .el-radio {
margin-right: 0;

121
src/views/home/dashboard.vue

@ -0,0 +1,121 @@
<template>
<el-row>
<el-row type="flex" align="top" justify="space-around">
<el-col :offset="1" :span="11">
<el-row type="flex" align="middle" justify="center">
<el-col :span="3">
<p class="tagTitle">回收概览</p>
</el-col>
<el-col :offset="1" :span="21">
<el-select v-model="value" placeholder="请选择">
<el-option
v-for="item in ['表单1']"
:key="item"
:label="item"
:value="item"
/>
</el-select>
</el-col>
</el-row>
<el-row
style="width: 719px; height: 416px; border-radius: 10px; border: 1px solid rgba(187, 187, 187, 100);"
>
<el-row style="height: 50px;" />
<el-row>
<el-row type="flex" justify="space-around">
<el-col :offset="2" :span="5">
<span>有效回收量</span>
</el-col>
<el-col :span="5">
<span>总浏览量</span>
</el-col>
<el-col :span="5">
<span>回收率</span>
</el-col>
<el-col :span="5">
<span>平局完成时间</span>
</el-col>
</el-row>
<el-row type="flex" justify="space-around">
<el-col :offset="2" :span="5">
<h4>
1231
</h4>
</el-col>
<el-col :span="5">
<h4>
3921
</h4>
</el-col>
<el-col :span="5">
<h4>28%</h4>
</el-col>
<el-col :span="5">
<h4>12分16秒</h4>
</el-col>
</el-row>
</el-row>
<el-row>
<img style="width: 719px; height: 252px;"
src="https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2cdrp.png"
>
</el-row>
</el-row>
</el-col>
<el-col :span="12">
<el-row type="flex" align="middle" justify="start">
<el-col :span="5">
<p class="tagTitle">表单提交地域分布图</p>
</el-col>
</el-row>
<el-row>
<el-col :span="18">
<img style="height: 215px;"
src="https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2cdw0.png"
>
</el-col>
</el-row>
<el-row type="flex" justify="space-around">
<el-col :span="12">
<el-row>
<el-col :span="5">
<p class="tagTitle">常用设备</p>
</el-col>
</el-row>
<el-row>
<img style="height: 160px;"
src="https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2cdta.png"
>
</el-row>
</el-col>
<el-col :span="12">
<el-row>
<el-col :span="5">
<p class="tagTitle">来源渠道</p>
</el-col>
</el-row>
<el-row>
<img style="height: 160px;"
src="https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2cdo2.png"
>
</el-row>
</el-col>
</el-row>
</el-col>
</el-row>
<el-row style="height: 30px;" />
</el-row>
</template>
<script>
export default {
name: 'HomeDashboard'
}
</script>
<style scoped>
.tagTitle {
font-size: 20px;
border-bottom: 3px solid rgba(68, 68, 68, 100);
line-height: 25px;
}
</style>

39
src/views/home/home-button.vue

@ -0,0 +1,39 @@
<template>
<el-row>
<el-col :offset="2" :span="5">
<el-button class="home-fun-btn" @click="$router.push({path:'/project/create'})">
新建项目 <i class="el-icon-plus" />
</el-button>
</el-col>
<el-col :span="5">
<el-button class="home-fun-btn">我的项目<i class="el-icon-s-custom" /></el-button>
</el-col>
<el-col :span="5">
<el-button class="home-fun-btn">行业模板<i class="el-icon-s-management" /></el-button>
</el-col>
<el-col :span="5">
<el-button class="home-fun-btn">回收站<i class="el-icon-delete-solid" /></el-button>
</el-col>
</el-row>
</template>
<script>
export default {
name: 'HomeFunction'
}
</script>
<style scoped>
.home-fun-btn {
width: 285px;
height: 145px;
line-height: 20px;
border-radius: 15px;
font-weight: 580;
background-color: rgba(255, 255, 255, 100);
color: rgba(16, 16, 16, 100);
font-size: 14px;
text-align: center;
border: 1px solid rgba(187, 187, 187, 100);
}
</style>

16
src/views/home/home-view.vue

@ -0,0 +1,16 @@
<template>
<el-row>
<Dashboard />
<HomeFunction />
</el-row>
</template>
<script>
import HomeFunction from './home-button'
import Dashboard from './dashboard'
export default {
name: 'HomeView',
components: {HomeFunction, Dashboard}
}
</script>

119
src/views/home/index.vue

@ -0,0 +1,119 @@
<template>
<el-container>
<el-header height="107px" class="homeHeaderView">
<el-row type="flex" align="middle">
<el-col :span="3" :offset="2">
<img src="@/assets/images/indexLogo.png" class="headerLogoImg"
@click="$router.push({path:'/project/create'})"
>
</el-col>
<el-col :span="5">
<el-menu :default-active="menuIndex" mode="horizontal" :router="true" text-color="#205BB5"
active-text-color="#205BB5"
>
<el-menu-item v-for="(item, index) in menuRouters" :key="index" :index="item.routerPath"
:route="item.routerPath" class="menuItem"
>
{{ item.title }}
</el-menu-item>
</el-menu>
</el-col>
<el-col :offset="8" :span="1">
<el-button round>升级</el-button>
</el-col>
<el-col :span="1">
<svg-icon name="loginWx" style="width: 24px; height: 24px;" />
</el-col>
<el-col :span="1">
<el-link href="https://element.eleme.io" target="_blank">帮助</el-link>
</el-col>
<el-col :span="3">
<img :src="getUserInfo.avatar" style="width: 68px; height: 68px; border-radius: 100px;">
</el-col>
</el-row>
</el-header>
<el-main>
<!-- 轮播·1-->
<el-row>
<el-col :span="24">
<el-carousel height="55px">
<el-carousel-item v-for="item in 2" :key="item">
<img style="height: 55px; width: 100%;"
src="https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c4aj.png"
>
</el-carousel-item>
</el-carousel>
</el-col>
</el-row>
<router-view />
</el-main>
</el-container>
</template>
<script>
import store from '@/store/index.js'
export default {
name: 'Home',
data() {
return {
menuIndex: null,
menuRouters: [
{
routerPath: '/proposal',
title: '提出建议'
},
{
routerPath: '/sources',
title: '开源项目'
},
{
routerPath: '/enterprise',
title: '提出建议'
}
]
}
},
computed: {
getStore() {
return store
},
getUserInfo() {
return JSON.parse(this.getStore.getters['user/userInfo'])
}
},
watch: {
$route(to) {
this.menuIndex = to.path
}
},
mounted() {
this.menuIndex = this.$route.path
}
}
</script>
<style scoped>
.menuItem {
line-height: 110px;
height: 110px;
font-size: 20px;
text-align: left;
font-weight: 550;
float: right;
}
.el-menu.el-menu--horizontal {
border-bottom: none;
}
.homeHeaderView {
height: 117px;
line-height: 20px;
background-color: rgba(255, 255, 255, 100);
color: rgba(16, 16, 16, 100);
font-size: 14px;
text-align: center;
}
.headerLogoImg {
width: 245px;
height: 72px;
}
</style>

5
src/views/index.vue

@ -1,5 +0,0 @@
<template>
<div>
<RouterLink to="/example">演示Demo</RouterLink>
</div>
</template>

28
src/views/login.vue

@ -1,28 +0,0 @@
<template>
<div>
<button @click="login">模拟登录</button>
</div>
</template>
<script>
export default {
methods: {
login() {
this.$store.dispatch('token/login').then(() => {
//
if (this.$route.query.redirect) {
this.$router.replace({
path: this.$route.query.redirect
})
} else {
if (window.history.length <= 1) {
this.$router.push({ path: '/' })
} else {
this.$router.go(-1)
}
}
})
}
}
}
</script>

232
src/views/project/create.vue

@ -0,0 +1,232 @@
<template>
<div class="create-wrapper">
<el-backtop target=".create-wrapper" :visibility-height="100" :bottom="60" />
<el-row>
<el-row style="height: 20px;" />
<el-row>
<el-col :offset="1" :span="2">
<el-button size="mini" round>
<i class="el-icon-arrow-left" />
返回
</el-button>
</el-col>
</el-row>
<el-row type="flex" justify="center">
<el-col :offset="4" :span="8">
<el-form ref="form">
<el-form-item label="">
<el-input class="search-template-input" />
</el-form-item>
</el-form>
</el-col>
<el-col :offset="1" :span="4">
<el-button type="primary" class="search-template-btn">查询</el-button>
</el-col>
<el-col :span="6" />
</el-row>
<el-row>
<el-col :offset="6" :span="8">
<el-menu default-active="1" class="el-menu-demo" mode="horizontal">
<el-menu-item index="1">全部</el-menu-item>
<el-menu-item index="2">问卷调查</el-menu-item>
<el-menu-item index="3">满意度调查</el-menu-item>
<el-menu-item index="4">投票评选</el-menu-item>
<el-menu-item index="5">报名登记表</el-menu-item>
<el-menu-item index="6">考试测评</el-menu-item>
</el-menu>
</el-col>
</el-row>
<el-row>
<el-col :offset="3" :span="3">
<span class="tagTitle">推荐模板</span>
</el-col>
</el-row>
<el-row>
<el-col :offset="3" :span="3">
<div class="project-template-view" style="display: flex; align-items: center;">
<div style="flex: 1;">
<i style="font-size: 40px; align-items: center;" class="el-icon-plus" />
<p style="font-size: 14px;">创建一个空白模板</p>
</div>
</div>
</el-col>
<el-col v-for="(template,index) in templateList" :key="template.title"
:offset="getTemplateOffset(index)"
:span="3"
>
<div class="project-template-view">
<img style="width: 144px; height: 133px;" :src="template.image">
<p style="color: rgba(16, 16, 16, 100); font-size: 14px; margin: 0; line-height: 30px;">
{{ template.title }}
</p>
<p style="color: rgba(189, 188, 188, 100); font-size: 12px; margin: 0;">
{{ template.likeCount }}人喜欢
<svg-icon name="like" style="width: 12px; height: 12px;" />
</p>
</div>
</el-col>
</el-row>
<el-row style="height: 20px;" />
<el-row type="flex" justify="center">
<el-col :span="5">
<el-pagination
:hide-on-single-page="true"
:total="50"
layout="prev, pager, next"
/>
</el-col>
</el-row>
<el-row />
</el-row>
</div>
</template>
<script>
export default {
name: 'CreateProject',
data() {
return {
templateList: [
{
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
},
{
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
},
{
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}, {
image: 'https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c3ec.png',
title: '垃圾分类问卷调查',
likeCount: 10000
}
]
}
},
computed: {}, methods: {
getTemplateOffset(index) {
console.log(index)
// if (index == 5 || (index != 6 && index != 0 && index % 6 === 0)) {
// return 3
// }
if ((index + 1) % 6 == 0) {
return 3
}
return 0
}
}
}
</script>
<style scoped>
.create-wrapper {
height: 100%;
overflow-x: hidden;
}
.tagTitle {
font-size: 20px;
border-bottom: 3px solid rgba(68, 68, 68, 100);
line-height: 25px;
}
.project-template-view {
width: 151px;
height: 196px;
line-height: 20px;
border-radius: 3px;
text-align: center;
margin-top: 20px;
border: 1px solid rgba(187, 187, 187, 100);
}
.el-menu.el-menu--horizontal {
border-bottom: none;
}
/deep/ .search-template-input input {
width: 651px;
height: 50px;
line-height: 20px;
border-radius: 10px;
text-align: center;
border: 1px solid rgba(187, 187, 187, 100);
}
/deep/ .search-template-btn {
width: 132px;
height: 50px;
border-radius: 10px;
background-color: rgba(25, 73, 157, 100);
color: rgba(255, 255, 255, 100);
font-size: 18px;
text-align: center;
border: 1px solid rgba(187, 187, 187, 100);
}
</style>

8
src/views/Home.vue → src/views/welcome.vue

@ -6,9 +6,9 @@
<el-col class="headerCol" :span="18">
<el-menu :default-active="menuIndex" mode="horizontal" :router="true" text-color="#205BB5" active-text-color="#205BB5">
<div class="headerLogoDiv">
<img src="../assets/images/indexLogo.png" class="headerLogo" @click="$router.push({path:'/'})">
<img src="../assets/images/indexLogo.png" class="headerLogo" @click="$router.push({path:'/home'})">
</div>
<el-button v-if="isLogin" class="headerBtn" @click="$router.push({path:'/console'})"> </el-button>
<el-button v-if="isLogin" class="headerBtn" @click="$router.push({path:'/home'})"> </el-button>
<el-button v-if="!isLogin" class="headerBtn" @click="$router.push({path:'/login'})"> </el-button>
<el-menu-item v-for="(item, index) in menuRouters" :key="index" :index="item.routerPath" :route="item.routerPath" class="menuItem">{{ item.title }}</el-menu-item>
</el-menu>
@ -37,9 +37,7 @@
</div>
</el-col>
<el-col :span="10">
<div class="bodyRight">
<img class="bodyRightImg" src="../assets/images/bodyRight.png">
</div>
<div class="bodyRight" />
</el-col>
</el-row>
</div>

3
vue.config.js

@ -65,6 +65,9 @@ module.exports = {
},
configureWebpack: config => {
config.resolve.modules = ['node_modules', 'assets/sprites']
config.resolve.alias = {
'@': path.resolve(__dirname, 'src')
}
config.plugins.push(...spritesmithTasks)
if (isCDN) {
config.externals = externals

Loading…
Cancel
Save