Authored by 李奇

活动配置修改

@@ -103,7 +103,8 @@ const whSurfController = { @@ -103,7 +103,8 @@ const whSurfController = {
103 btm_tip_one: {type: 'string', empty: true}, 103 btm_tip_one: {type: 'string', empty: true},
104 btm_tip_two: {type: 'string', empty: true}, 104 btm_tip_two: {type: 'string', empty: true},
105 my_prize_btn: {type: 'string', empty: true}, 105 my_prize_btn: {type: 'string', empty: true},
106 - jump_url: {type: 'string', empty: true}, 106 + jump_url_left: {type: 'string', empty: true},
  107 + jump_url_right: {type: 'string', empty: true},
107 win_prize_bg: {type: 'string', empty: true}, 108 win_prize_bg: {type: 'string', empty: true},
108 try_again_bg: {type: 'string', empty: true}, 109 try_again_bg: {type: 'string', empty: true},
109 status: {type: 'number', empty: true} 110 status: {type: 'number', empty: true}
@@ -65,7 +65,11 @@ module.exports = function(Sequelize, DataTypes) { @@ -65,7 +65,11 @@ module.exports = function(Sequelize, DataTypes) {
65 type: DataTypes.STRING(300), 65 type: DataTypes.STRING(300),
66 allowNull: true 66 allowNull: true
67 }, 67 },
68 - jump_url: { 68 + jump_url_left: {
  69 + type: DataTypes.STRING(500),
  70 + allowNull: true
  71 + },
  72 + jump_url_right: {
69 type: DataTypes.STRING(500), 73 type: DataTypes.STRING(500),
70 allowNull: true 74 allowNull: true
71 }, 75 },
@@ -26,7 +26,8 @@ CREATE TABLE IF NOT EXISTS act_wheel_surf_conf ( @@ -26,7 +26,8 @@ CREATE TABLE IF NOT EXISTS act_wheel_surf_conf (
26 `btm_tip_one` VARCHAR(60) DEFAULT 0 COMMENT '活动提示文案1', 26 `btm_tip_one` VARCHAR(60) DEFAULT 0 COMMENT '活动提示文案1',
27 `btm_tip_two` VARCHAR(60) DEFAULT 0 COMMENT '活动提示文案2', 27 `btm_tip_two` VARCHAR(60) DEFAULT 0 COMMENT '活动提示文案2',
28 `my_prize_btn` VARCHAR(300) DEFAULT 0 COMMENT '我的奖品', 28 `my_prize_btn` VARCHAR(300) DEFAULT 0 COMMENT '我的奖品',
29 - `jump_url` VARCHAR(500) DEFAULT 0 COMMENT '跳转链接', 29 + `jump_url_left` VARCHAR(500) DEFAULT 0 COMMENT '跳转链接左',
  30 + `jump_url_right` VARCHAR(500) DEFAULT 0 COMMENT '跳转链接右',
30 `win_prize_bg` VARCHAR(300) DEFAULT 0 COMMENT '提示中奖背景图', 31 `win_prize_bg` VARCHAR(300) DEFAULT 0 COMMENT '提示中奖背景图',
31 `try_again_bg` VARCHAR(300) DEFAULT 0 COMMENT '再来一次按钮', 32 `try_again_bg` VARCHAR(300) DEFAULT 0 COMMENT '再来一次按钮',
32 `status` INT(8) DEFAULT 0 COMMENT '预览状态0, 发布状态1', 33 `status` INT(8) DEFAULT 0 COMMENT '预览状态0, 发布状态1',
@@ -31,7 +31,8 @@ @@ -31,7 +31,8 @@
31 31
32 .vue-app-inner-view { 32 .vue-app-inner-view {
33 padding: 0 10px 10px 10px; 33 padding: 0 10px 10px 10px;
34 - max-height: 100%; 34 + height: 100%;
35 overflow: auto; 35 overflow: auto;
  36 + box-sizing: border-box;
36 } 37 }
37 </style> 38 </style>
1 <template> 1 <template>
2 <div class="prize-add"> 2 <div class="prize-add">
3 - <div class="demo-split"> 3 + <div class="add-area-split">
4 <Split v-model="split"> 4 <Split v-model="split">
5 <div slot="left" class="split-pane"> 5 <div slot="left" class="split-pane">
6 <Form ref="formValidate" :label-width="120"> 6 <Form ref="formValidate" :label-width="120">
@@ -52,7 +52,7 @@ @@ -52,7 +52,7 @@
52 }; 52 };
53 53
54 export default { 54 export default {
55 - name: 'PrizeItem', 55 + name: 'AddPrize',
56 data () { 56 data () {
57 return { 57 return {
58 actId: 0, 58 actId: 0,
@@ -69,7 +69,6 @@ @@ -69,7 +69,6 @@
69 { 69 {
70 title: '奖品类型', 70 title: '奖品类型',
71 render: (h, {row}) => { 71 render: (h, {row}) => {
72 -  
73 return h('span', {}, pirzeType[row.type]); 72 return h('span', {}, pirzeType[row.type]);
74 } 73 }
75 }, 74 },
@@ -118,7 +117,7 @@ @@ -118,7 +117,7 @@
118 } 117 }
119 ], 118 ],
120 prize: { 119 prize: {
121 - act_id: 20, 120 + act_id: '',
122 name: '', 121 name: '',
123 type: 1, 122 type: 1,
124 value: '', 123 value: '',
@@ -183,12 +182,13 @@ @@ -183,12 +182,13 @@
183 }, 182 },
184 mounted() { 183 mounted() {
185 this.actId = this.$route.query.actId; 184 this.actId = this.$route.query.actId;
  185 + this.prize.act_id = this.actId;
186 this.bindUpload(); 186 this.bindUpload();
187 this.prizeList(); 187 this.prizeList();
188 } 188 }
189 } 189 }
190 </script> 190 </script>
191 -<style lang="scss"> 191 +<style lang="scss" scoped>
192 .split-pane { 192 .split-pane {
193 padding: 10px; 193 padding: 10px;
194 194
1 <template> 1 <template>
2 <Tabs size="small"> 2 <Tabs size="small">
3 <TabPane label="基础配置"> 3 <TabPane label="基础配置">
4 - <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="120"> 4 + <div class="base-conf">
  5 + <div class="base-left">
  6 + <Form :label-width="120">
5 <FormItem label="活动规则" required> 7 <FormItem label="活动规则" required>
6 - <Input type="textarea" :autosize="{minRows: 2,maxRows: 30}" 8 + <Input type="textarea" v-model="conf.rule"
7 placeholder="请输入活动规则" :maxlength="2000"></Input> 9 placeholder="请输入活动规则" :maxlength="2000"></Input>
8 </FormItem> 10 </FormItem>
9 <FormItem label="分享链接" required> 11 <FormItem label="分享链接" required>
10 - <Input type="text" 12 + <Input type="text" v-model="conf.share_url"
11 placeholder="活动分享链接"></Input> 13 placeholder="活动分享链接"></Input>
12 </FormItem> 14 </FormItem>
13 <FormItem label="提示文案(上)" required> 15 <FormItem label="提示文案(上)" required>
14 - <Input type="text" 16 + <Input type="text" v-model="conf.btm_tip_one"
15 placeholder="提示文案(上)"></Input> 17 placeholder="提示文案(上)"></Input>
16 </FormItem> 18 </FormItem>
17 <FormItem label="提示文案(下)" required> 19 <FormItem label="提示文案(下)" required>
18 - <Input type="text" 20 + <Input type="text" v-model="conf.btm_tip_two"
19 placeholder="提示文案(下)"></Input> 21 placeholder="提示文案(下)"></Input>
20 </FormItem> 22 </FormItem>
21 <FormItem label="跳转链接(左)" required> 23 <FormItem label="跳转链接(左)" required>
22 - <Input type="text" 24 + <Input type="text" v-model="conf.jump_url_left"
23 placeholder="活动底部链接(左)"></Input> 25 placeholder="活动底部链接(左)"></Input>
24 </FormItem> 26 </FormItem>
25 <FormItem label="跳转链接(右)" required> 27 <FormItem label="跳转链接(右)" required>
26 - <Input type="text" 28 + <Input type="text" v-model="conf.jump_url_right"
27 placeholder="活动底部链接(右)"></Input> 29 placeholder="活动底部链接(右)"></Input>
28 </FormItem> 30 </FormItem>
29 <FormItem label="活动最大参与次数" required> 31 <FormItem label="活动最大参与次数" required>
30 - <Input type="text" 32 + <Input type="text" v-model="conf.act_total_times"
31 placeholder="活动最大参与次数"></Input> 33 placeholder="活动最大参与次数"></Input>
32 </FormItem> 34 </FormItem>
33 <FormItem label="每天最大抽奖次数" required> 35 <FormItem label="每天最大抽奖次数" required>
34 - <Input type="text" 36 + <Input type="text" v-model="conf.day_limit_times"
35 placeholder="每天最大抽奖次数"></Input> 37 placeholder="每天最大抽奖次数"></Input>
36 </FormItem> 38 </FormItem>
37 - <FormItem>  
38 - <Button type="primary" @click="handleSubmit('formValidate')">保存</Button>  
39 - <Button type="warning" @click="handleSubmit('formValidate')">预览</Button> 39 + </Form>
  40 + </div>
  41 + <div class="base-right">
  42 + <Form :label-width="120">
  43 + <FormItem label="主背景图" prop="prize_bg" required>
  44 + <img class="win-prize-bg" v-show="conf.main_bg" :src="conf.main_bg">
  45 + <Button v-show="!conf.main_bg">
  46 + <span ref="winPrizeBg">添加</span>
  47 + </Button>
  48 + </FormItem>
  49 + <FormItem label="转盘背景图" prop="prize_bg" required>
  50 + <img class="win-prize-bg" v-show="conf.wheel_bg" :src="conf.wheel_bg">
  51 + <Button v-show="!conf.wheel_bg">
  52 + <span ref="winPrizeBg">添加</span>
  53 + </Button>
40 </FormItem> 54 </FormItem>
41 </Form> 55 </Form>
  56 + </div>
  57 + <div class="bottom-btn">
  58 + <Button type="primary" @click="save" class="save">保存</Button>
  59 + <Button type="warning" @click="save" class="preview">预览</Button>
  60 + </div>
  61 + </div>
42 </TabPane> 62 </TabPane>
43 <TabPane label="奖品配置"> 63 <TabPane label="奖品配置">
44 - <add-prize v-for="item in prizes" :key="item"></add-prize> 64 + <add-prize></add-prize>
45 </TabPane> 65 </TabPane>
46 </Tabs> 66 </Tabs>
47 </template> 67 </template>
@@ -51,44 +71,112 @@ @@ -51,44 +71,112 @@
51 export default { 71 export default {
52 data () { 72 data () {
53 return { 73 return {
54 - formValidate: {  
55 - name: '',  
56 - mail: '',  
57 - city: '',  
58 - gender: '',  
59 - interest: [],  
60 - date: '',  
61 - time: '',  
62 - desc: ''  
63 - },  
64 - ruleValidate: {  
65 -  
66 - },  
67 - prizes: [1] 74 + actId: 0,
  75 + confId: 0,
  76 + prizes: [1],
  77 + conf: {
  78 + act_id: 0,
  79 + id: 0,
  80 + rule: '',
  81 + share_url: '',
  82 + day_limit_times: '',
  83 + act_total_times: '',
  84 + btm_tip_one: '',
  85 + btm_tip_two: '',
  86 + jump_url_left: '',
  87 + jump_url_right: '',
  88 + wheel_bg: '',
  89 + main_bg: '',
  90 + prize_btn_bg: '',
  91 + rule_btn_bg: '',
  92 + share_btn_bg: '',
  93 + day_over_limit_bg: '',
  94 + my_prize_btn: ''
  95 + }
68 } 96 }
69 }, 97 },
70 methods: { 98 methods: {
71 - handleSubmit (name) {  
72 - this.$refs[name].validate((valid) => {  
73 - if (valid) {  
74 - this.$Message.success('Success!'); 99 + bindUpload() {
  100 + window.qn_dynamic_el_upload(this.$refs.winPrizeBg, url => {
  101 + this.prize.prize_bg = url;
  102 + });
  103 + },
  104 + save() {
  105 + $.ajax({
  106 + method: 'post',
  107 + url: '/admin/wheelSurf/api/config/modify',
  108 + contentType: 'application/json',
  109 + data: JSON.stringify(Object.assign(this.conf, {act_id: this.actId}))
  110 + }).then(res => {
  111 + if (res.code === 200) {
  112 + this.$Message.success('奖品新增成功');
  113 + this.prizeList();
75 } else { 114 } else {
76 - this.$Message.error('Fail!'); 115 + this.$Message.error(res.msg);
77 } 116 }
78 - }) 117 + });
79 }, 118 },
80 - handleReset (name) {  
81 - this.$refs[name].resetFields(); 119 + getConf() {
  120 + $.ajax({
  121 + url: '/admin/wheelSurf/api/config/detail',
  122 + data: {act_id: this.actId}
  123 + }).then(res => {
  124 + if (res.code === 200 && res.data && res.data.id) {
  125 + this.conf = res.data;
  126 + } else {
  127 + this.$Message.error(res.msg);
  128 + }
  129 + });
82 } 130 }
83 }, 131 },
  132 + mounted() {
  133 + this.actId = this.$route.query.actId;
  134 + this.bindUpload();
  135 + this.getConf();
  136 + },
84 components: { 137 components: {
85 AddPrize 138 AddPrize
86 - },  
87 - mounted() {  
88 } 139 }
89 } 140 }
90 </script> 141 </script>
91 <style lang="scss"> 142 <style lang="scss">
  143 + .ivu-tabs {
  144 + height: 100%;
  145 + }
  146 +
  147 + .bottom-btn {
  148 + position: absolute;
  149 + bottom: 0;
  150 + left: 0;
  151 + right: 0;
  152 + text-align: center;
  153 + }
  154 +
  155 + .base-conf {
  156 + font-size: 0;
  157 + padding-bottom: 40px;
  158 +
  159 + .base-left, .base-right {
  160 + display: inline-block;
  161 + width: 50%;
  162 + box-sizing: border-box;
  163 + }
  164 +
  165 + .base-left {
  166 + padding-right: 20px;
  167 + }
  168 +
  169 + .base-right {
  170 + font-size: 16px;
  171 + vertical-align: top;
  172 + }
  173 +
  174 + .save {
  175 + margin-right: 20px;
  176 + }
  177 + }
  178 +
  179 +
92 </style> 180 </style>
93 181
94 182