Authored by huangyi

Merge remote-tracking branch 'origin/feature/wheel-surf' into feature/wheel-surf

# Conflicts:
#	utils/validator.js
... ... @@ -20,7 +20,7 @@ const whSurfController = {
page: 'wheel-surf'
});
},
async create(req, res) {
async actCreate(req, res) {
const title = req.body.title;
const startTime = req.body.startTime;
const endTime = req.body.endTime;
... ... @@ -40,20 +40,39 @@ const whSurfController = {
type
};
const result = await req.ctx(wheelSurfModel).create(params);
try {
const result = await req.ctx(wheelSurfModel).create(params);
return res.json({ code: 200, data: result});
} catch (err) {
res.json(err);
}
return res.json({
code: 200,
data: result
});
},
async list(req, res) {
const result = await req.ctx(wheelSurfModel).list();
async actDelete(req, res) {
const id = req.body.id;
return res.json({
code: 200,
data: result
});
try {
const result = await req.ctx(wheelSurfModel).actDelete(id);
return res.json({ code: 200, data: result});
} catch (err) {
res.json(err);
}
},
async actList(req, res) {
try {
const result = await req.ctx(wheelSurfModel).list();
return res.json({
code: 200,
data: result
});
} catch (err) {
res.json(err);
}
},
getConfigList: async function(req, res) {
... ...
... ... @@ -7,12 +7,16 @@ class ActWheelSurfModel extends global.yoho.BaseModel {
}
list() {
return Activity.findAll({where: {type: 1}});
return Activity.findAll({where: {type: 1}})
}
create(data) {
return Activity.create(data);
}
actDelete(id) {
return Activity.findOne({where: {id}}).then(activity => {
return activity.destroy();
});
}
configModify(obj) {
... ...
... ... @@ -94,8 +94,9 @@ router.get('/api/user/exportInfoUserList', user.exportInfoUserList);
// 大转盘活动管理
router.get('/wheelSurf', wheelSurf.entry);
router.post('/wheelSurf/api/create', wheelSurf.create);
router.get('/wheelSurf/api/list', wheelSurf.list);
router.post('/wheelSurf/api/create', wheelSurf.actCreate);
router.post('/wheelSurf/api/delete', wheelSurf.actDelete);
router.get('/wheelSurf/api/list', wheelSurf.actList);
router.get('/wheelSurf/api/config/list', wheelSurf.getConfigList);
router.post('/wheelSurf/api/config/modify', wheelSurf.configModify);
... ...
... ... @@ -40,8 +40,6 @@
<a class="btn btn-info" href="/admin/activity/article?actId={{id}}">文章列表</a>
<a class="btn btn-primary" href="/admin/activity/createArticle?actId={{id}}">
创建文章</a>
<a class="btn btn-primary" href="/admin/wheelSurf/decor?actId={{id}}">
大转盘活动配置</a>
<button class="btn btn-danger btn-delete" data-id="{{id}}">删除活动
</button>
</td>
... ...
<!-- page content -->
<div class="right_col" role="main">
<div id="app">
<App></App>
</div>
<div class="vue-app-container">
<App></App>
</div>
<!-- /page content -->
... ...
... ... @@ -2,7 +2,7 @@ import Vue from 'vue';
import VueRouter from 'vue-router';
import iView from 'iview';
import App from 'vue@/App.vue';
import {create, list, decor} from 'vue@/wheel-surf';
import {create, list, conf} from 'vue@/wheel-surf';
import 'admin/wheel-surf.page.css';
import 'iview/dist/styles/iview.css';
... ... @@ -13,14 +13,14 @@ Vue.use(iView);
const router = new VueRouter({
routes: [
{path: '/admin/wheelSurf', name: 'list', component: list},
{path: '/admin/wheelSurf/decor', name: 'decor', component: decor},
{path: '/admin/wheelSurf/conf', name: 'conf', component: conf},
{path: '/admin/wheelSurf/create', name: 'create', component: create}
],
mode: 'history'
});
new Vue({
el: '#app',
el: '.vue-app-container',
components: {
App
},
... ...
... ... @@ -220,6 +220,23 @@ body .container.body .right_col {
border-radius: 0;
height: 57px;
}
.nav-md .vue-app-container {
position: absolute;
left: 230px;
top: 68px;
right: 0;
bottom: 0;
}
.nav-sm .vue-app-container {
position: absolute;
left: 70px;
top: 68px;
right: 0;
bottom: 0;
}
@media (max-width: 991px) {
.nav-md .container.body .right_col, .nav-md .container.body .top_nav {
width: 100%;
... ... @@ -235,6 +252,14 @@ body .container.body .right_col {
.right_col {
padding: 10px !important;
}
.nav-md .vue-app-container {
position: absolute;
left: 0;
top: 68px;
right: 0;
bottom: 0;
}
}
@media (max-width: 1200px) {
.x_title h2 {
... ...
<template>
<router-view></router-view>
<div class="vue-app-inner-view">
<router-view></router-view>
</div>
</template>
<script>
... ... @@ -9,5 +11,25 @@
</script>
<style>
.vue-app-container {
overflow: auto;
}
.nav_menu {
margin-bottom: 0;
}
.container, .main_container {
height: 100%;
}
footer {
display: none;
bottom: 10px;
right: 10px;
}
.vue-app-inner-view {
padding: 0 10px 60px 10px;
}
</style>
... ...
<template>
<Tabs size="small">
<TabPane label="基础配置">
<Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="120">
<FormItem label="活动规则" required>
<Input type="textarea" :autosize="{minRows: 2,maxRows: 30}"
placeholder="请输入活动规则" :maxlength="2000"></Input>
</FormItem>
<FormItem label="分享链接" required>
<Input type="text"
placeholder="活动分享链接"></Input>
</FormItem>
<FormItem label="提示文案(上)" required>
<Input type="text"
placeholder="提示文案(上)"></Input>
</FormItem>
<FormItem label="提示文案(下)" required>
<Input type="text"
placeholder="提示文案(下)"></Input>
</FormItem>
<FormItem label="跳转链接(左)" required>
<Input type="text"
placeholder="活动底部链接(左)"></Input>
</FormItem>
<FormItem label="跳转链接(右)" required>
<Input type="text"
placeholder="活动底部链接(右)"></Input>
</FormItem>
<FormItem label="活动最大参与次数" required>
<Input type="text"
placeholder="活动最大参与次数"></Input>
</FormItem>
<FormItem label="每天最大抽奖次数" required>
<Input type="text"
placeholder="每天最大抽奖次数"></Input>
</FormItem>
<FormItem>
<Button type="primary" @click="handleSubmit('formValidate')">保存</Button>
<Button type="warning" @click="handleSubmit('formValidate')">预览</Button>
</FormItem>
</Form>
</TabPane>
<TabPane label="奖品配置">标签二的内容</TabPane>
</Tabs>
</template>
<script>
export default {
data () {
return {
formValidate: {
name: '',
mail: '',
city: '',
gender: '',
interest: [],
date: '',
time: '',
desc: ''
},
ruleValidate: {
name: [
{ required: true, message: 'The name cannot be empty', trigger: 'blur' }
],
mail: [
{ required: true, message: 'Mailbox cannot be empty', trigger: 'blur' },
{ type: 'email', message: 'Incorrect email format', trigger: 'blur' }
],
city: [
{ required: true, message: 'Please select the city', trigger: 'change' }
],
gender: [
{ required: true, message: 'Please select gender', trigger: 'change' }
],
interest: [
{ required: true, type: 'array', min: 1, message: 'Choose at least one hobby', trigger: 'change' },
{ type: 'array', max: 2, message: 'Choose two hobbies at best', trigger: 'change' }
],
date: [
{ required: true, type: 'date', message: 'Please select the date', trigger: 'change' }
],
time: [
{ required: true, type: 'string', message: 'Please select time', trigger: 'change' }
],
desc: [
{ required: true, message: 'Please enter a personal introduction', trigger: 'blur' },
{ type: 'string', min: 20, message: 'Introduce no less than 20 words', trigger: 'blur' }
]
}
}
},
methods: {
handleSubmit (name) {
this.$refs[name].validate((valid) => {
if (valid) {
this.$Message.success('Success!');
} else {
this.$Message.error('Fail!');
}
})
},
handleReset (name) {
this.$refs[name].resetFields();
}
}
}
</script>
<style lang="scss">
.ivu-form-item {
margin-bottom: 10px;
}
</style>
... ...
... ... @@ -4,7 +4,7 @@
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>大转盘活动创建</h2>
<h2>活动创建</h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
... ...
<template>
<div class="decor">
活动配置
<div>
<button class="btn btn-info">预览</button>
<button class="btn btn-primary">保存</button>
</div>
</div>
</template>
<script>
module.exports = {
data() {
return {
actId: 0
};
},
created() {
this.actId = this.$route.query.actId;
},
methods: {
create() {
this.$router.push({name: 'create'});
}
}
}
</script>
<style>
</style>
import list from './list';
import decor from './decor';
import conf from './conf';
import create from './create';
export {
list,
decor,
conf,
create
}
... ...
<template>
<div class="list">
<button class="btn btn-primary" @click="toCreate">创建新活动</button>
<Button type="primary" class="create-btn" @click="toCreate">创建新活动</Button>
<div class="activity-list">
<Table :columns="columns1" :data="data"></Table>
</div>
... ... @@ -22,6 +22,38 @@
{
title: '结束时间',
key: 'endTime'
},
{
title: '操作',
render: (h, {row}) => {
return h('div', [
h('Button', {
props: {
type: 'primary',
size: 'small'
},
style: {
marginRight: '5px'
},
on: {
click: () => {
this.conf(row.id)
}
}
}, '配置'),
h('Button', {
props: {
type: 'error',
size: 'small'
},
on: {
click: () => {
this.delete(row.id)
}
}
}, '删除'),
])
}
}
],
data: []
... ... @@ -30,20 +62,43 @@
methods: {
toCreate() {
this.$router.push({name: 'create'});
},
conf(actId) {
this.$router.push({name: 'conf', query: {actId}});
},
delete(id) {
this.$Modal.warning({
content: '删除后不可恢复,确认删除?',
onOk: () => {
$.ajax({
method: 'post',
url: '/admin/wheelSurf/api/delete',
data: {id}
}).then(() => {
this.list();
});
}
});
},
list() {
$.ajax({
url: '/admin/wheelSurf/api/list',
}).then(res => {
this.data = res.data;
});
}
},
created() {
$.ajax({
url: '/admin/wheelSurf/api/list',
}).then(res => {
this.data = res.data;
});
this.list();
}
}
</script>
<style lang="scss">
.activity-list {
height: 600px;
}
.create-btn {
margin-bottom: 10px;
}
</style>
... ...