index.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. <style>
  2. .form-body {
  3. padding: 20px 50% 20px 20px;
  4. background-color: #fff;
  5. margin-bottom: 20px;
  6. min-width: 1000px
  7. }
  8. .form-button {
  9. margin: 0;
  10. }
  11. .form-button .el-form-item__content {
  12. margin-left: 0 !important;
  13. }
  14. .button-item {
  15. padding: 9px 25px;
  16. }
  17. .red {
  18. color: #ff4544
  19. }
  20. .id-card {
  21. position: relative;
  22. /*height: 170px;*/
  23. width: 190px;
  24. float: left;
  25. text-align: center;
  26. /*margin-bottom: 20px;*/
  27. font-size: 12px;
  28. color: #666;
  29. margin-right: 30px;
  30. }
  31. .id-card img {
  32. max-height: 134px;
  33. max-width: 190px;
  34. background-color: #EEEFF3;
  35. }
  36. .card-upload .el-button {
  37. position: absolute;
  38. left: 50%;
  39. top: 50%;
  40. margin-top: -16px;
  41. margin-left: -16px;
  42. z-index: 1;
  43. }
  44. .com-attachment .card-upload{
  45. width: 100%;
  46. height: 100%;
  47. }
  48. .background-box{
  49. width:100%;
  50. background-size: cover;
  51. background-repeat: no-repeat;
  52. background-position: center;
  53. padding-top: 100px;
  54. }
  55. .background-box .title{
  56. width: 280px;
  57. height: 138px;
  58. margin: auto;
  59. background-size: contain;
  60. background-repeat: no-repeat;
  61. margin-bottom: 50px;
  62. }
  63. .all-components {
  64. background: #fff;
  65. padding: 20px;
  66. }
  67. .all-components .component-group {
  68. border: 1px solid #eeeeee;
  69. width: 300px;
  70. margin-bottom: 20px;
  71. }
  72. .all-components .component-group:last-child {
  73. margin-bottom: 0;
  74. }
  75. .all-components .component-group-name {
  76. height: 35px;
  77. line-height: 35px;
  78. background: #f7f7f7;
  79. padding: 0 20px;
  80. border-bottom: 1px solid #eeeeee;
  81. }
  82. .all-components .component-list {
  83. margin-right: -2px;
  84. margin-top: -2px;
  85. flex-wrap: wrap;
  86. }
  87. .all-components .component-list .component-item {
  88. width: 100px;
  89. height: 100px;
  90. border: 0 solid #eeeeee;
  91. border-width: 0 1px 1px 0;
  92. text-align: center;
  93. padding: 15px 0 0;
  94. cursor: pointer;
  95. }
  96. .all-components .component-list .component-icon {
  97. width: 40px;
  98. height: 40px;
  99. /*border: 1px solid #eee;*/
  100. }
  101. .all-components .component-list .component-name {
  102. }
  103. #diy-list {
  104. width: 95%;
  105. padding: 20px;
  106. float: left;
  107. margin: 20px;
  108. border: 1px solid #eeeeee;
  109. }
  110. .all-components {
  111. background: #fff;
  112. padding: 20px;
  113. }
  114. .all-components .component-group {
  115. border: 1px solid #eeeeee;
  116. width: 300px;
  117. margin-bottom: 20px;
  118. }
  119. .all-components .component-group:last-child {
  120. margin-bottom: 0;
  121. }
  122. .all-components .component-group-name {
  123. height: 35px;
  124. line-height: 35px;
  125. background: #f7f7f7;
  126. padding: 0 20px;
  127. border-bottom: 1px solid #eeeeee;
  128. }
  129. .all-components .component-list {
  130. margin-right: -2px;
  131. margin-top: -2px;
  132. flex-wrap: wrap;
  133. }
  134. .all-components .component-list .component-item {
  135. width: 100px;
  136. height: 100px;
  137. border: 0 solid #eeeeee;
  138. border-width: 0 1px 1px 0;
  139. text-align: center;
  140. padding: 15px 0 0;
  141. cursor: pointer;
  142. }
  143. .all-components .component-list .component-icon {
  144. width: 40px;
  145. height: 40px;
  146. /*border: 1px solid #eee;*/
  147. }
  148. .all-components .component-list .component-name {
  149. }
  150. .mobile-framework {
  151. width: 375px;
  152. height: 100%;
  153. }
  154. .mobile-framework-header {
  155. height: 60px;
  156. line-height: 60px;
  157. background: #333;
  158. color: #fff;
  159. text-align: center;
  160. background: url('/resources/addons/sudoku/img/head.png') no-repeat;
  161. }
  162. .mobile-framework-body {
  163. min-height: 645px;
  164. border: 1px solid #e2e2e2;
  165. background: #f5f7f9;
  166. }
  167. .mobile-framework .diy-component-preview {
  168. cursor: pointer;
  169. position: relative;
  170. zoom: 0.5;
  171. -moz-transform: scale(0.5);
  172. -moz-transform-origin: top left;
  173. font-size: 28px;
  174. }
  175. @-moz-document url-prefix() {
  176. .mobile-framework .diy-component-preview {
  177. cursor: pointer;
  178. position: relative;
  179. -moz-transform: scale(0.5);
  180. -moz-transform-origin: top left;
  181. font-size: 28px;
  182. width: 200% !important;
  183. height: 100%;
  184. margin-bottom: auto;
  185. }
  186. .mobile-framework .active .diy-component-preview {
  187. border: 2px dashed #409EFF;
  188. left: -2px;
  189. right: -2px;
  190. width: calc(200% + 4px) !important;
  191. }
  192. }
  193. .mobile-framework .diy-component-preview:hover {
  194. box-shadow: inset 0 0 10000px rgba(0, 0, 0, .03);
  195. }
  196. .mobile-framework .diy-component-edit {
  197. width: 100%;
  198. position: absolute;
  199. top: 0;
  200. bottom: 0;
  201. left: 465px;
  202. right: 0;
  203. background: #fff;
  204. padding: 20px;
  205. display: none;
  206. overflow: auto;
  207. }
  208. .diy-component-options {
  209. position: relative;
  210. }
  211. .diy-component-options .el-button {
  212. height: 25px;
  213. line-height: 25px;
  214. width: 25px;
  215. padding: 0;
  216. text-align: center;
  217. border: none;
  218. border-radius: 0;
  219. position: absolute;
  220. margin-left: 0;
  221. }
  222. .mobile-framework .active .diy-component-preview {
  223. border: 2px dashed #409EFF;
  224. left: -2px;
  225. right: -2px;
  226. width: calc(100% + 4px);
  227. }
  228. .mobile-framework .active .diy-component-edit {
  229. display: block;
  230. padding-right: 20%;
  231. min-width: 650px;
  232. }
  233. .all-components {
  234. max-height: 725px;
  235. overflow-y: auto;
  236. }
  237. .bottom-menu {
  238. text-align: center;
  239. height: 54px;
  240. width: 100%;
  241. }
  242. .bottom-menu .el-card__body {
  243. padding-top: 10px;
  244. }
  245. .el-dialog {
  246. min-width: 800px;
  247. }
  248. /* 公共样式 */
  249. .flex {
  250. display: -webkit-box;
  251. display: -webkit-flex;
  252. /* #ifndef APP-NVUE */
  253. display: flex;
  254. /* #endif */
  255. }
  256. .flex-x-center {
  257. display: -webkit-box;
  258. display: -webkit-flex;
  259. /* #ifndef APP-NVUE */
  260. display: flex;
  261. /* #endif */
  262. -webkit-box-pack: center;
  263. -webkit-justify-content: center;
  264. -ms-flex-pack: center;
  265. justify-content: center;
  266. }
  267. .flex-x-between {
  268. display: -webkit-box;
  269. display: -webkit-flex;
  270. /* #ifndef APP-NVUE */
  271. display: flex;
  272. /* #endif */
  273. -webkit-box-pack: space-between;
  274. -webkit-justify-content: space-between;
  275. -ms-flex-pack: space-between;
  276. justify-content: space-between;
  277. }
  278. .flex-y-center {
  279. display: -webkit-box;
  280. display: -webkit-flex;
  281. /* #ifndef APP-NVUE */
  282. display: flex;
  283. /* #endif */
  284. -webkit-box-align: center;
  285. -webkit-align-items: center;
  286. -ms-flex-align: center;
  287. -ms-grid-row-align: center;
  288. align-items: center;
  289. }
  290. /* 溢出隐藏 */
  291. .over1 {
  292. text-overflow: -o-ellipsis-lastline;
  293. overflow: hidden;
  294. text-overflow: ellipsis;
  295. display: -webkit-box;
  296. -webkit-line-clamp: 1;
  297. -webkit-box-orient: vertical;
  298. }
  299. .over2 {
  300. text-overflow: -o-ellipsis-lastline;
  301. overflow: hidden;
  302. text-overflow: ellipsis;
  303. display: -webkit-box;
  304. -webkit-line-clamp: 2;
  305. -webkit-box-orient: vertical;
  306. }
  307. .sava_btn .el-button {
  308. width: 150px;
  309. height: 40px;
  310. border-radius: 5px;
  311. }
  312. .page_msg_box {
  313. padding: 22px 23px;
  314. border-radius: 5px 5px 0 0;
  315. }
  316. </style>
  317. <?php
  318. use common\helpers\ComponentHelper;
  319. ComponentHelper::loadComponentView('com-rich-text');
  320. ?>
  321. <div id="app" v-cloak>
  322. <el-card shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  323. <div slot="header">
  324. <span>九宫格抽奖设置</span>
  325. </div>
  326. <el-tabs type="border-card">
  327. <el-tab-pane label="基础设置">
  328. <div class="form-body">
  329. <el-form :model="form" label-width="120px" ref="form" size="small" v-loading="loading" :rules="FormRules">
  330. <el-form-item label="抽奖时间" prop="open_time">
  331. <el-date-picker v-model="form.open_time" unlink-panels type="datetimerange" size="small"
  332. value-format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="开始日期"
  333. end-placeholder="结束日期">
  334. </el-date-picker>
  335. <br/>
  336. <div class="tips-text" style="line-height: 24px;">
  337. 设置抽奖活动时间
  338. </div>
  339. </el-form-item>
  340. <el-form-item label="抽奖规则" prop="type">
  341. <el-radio v-model="form.type" :label="1">一天{{ form.lucky_number }}次</el-radio>
  342. <el-radio v-model="form.type" :label="2">一人{{ form.lucky_number }}次</el-radio>
  343. <br/>
  344. <div class="tips-text" style="line-height: 24px;">
  345. 设置抽奖规则类型,是按每天发放还是每个人给固定的次数
  346. </div>
  347. </el-form-item>
  348. <el-form-item label="中奖名单" prop="is_show">
  349. <el-switch v-model="form.is_show" :active-value="1" :inactive-value="0">
  350. </el-switch>
  351. <br/>
  352. <div class="tips-text" style="line-height: 24px;">
  353. 开启后,前端显示中奖名单。
  354. </div>
  355. </el-form-item>
  356. <el-form-item label="邮费方式" prop="shipping_type">
  357. <el-radio v-model="form.shipping_type" :label="1">包邮</el-radio>
  358. <el-radio v-model="form.shipping_type" :label="2">不包邮</el-radio>
  359. <br/>
  360. <div class="tips-text" style="line-height: 24px;">
  361. 赠品奖品是否包邮
  362. </div>
  363. </el-form-item>
  364. <el-form-item label="抽奖次数" prop="lucky_number">
  365. <el-input size="small" type="number" v-model="form.lucky_number" autocomplete="off" ></el-input>
  366. <br/>
  367. <div class="tips-text" style="line-height: 24px;">
  368. 对应规则设置抽奖次数
  369. </div>
  370. </el-form-item>
  371. <el-form-item label="消耗积分" prop="use_point">
  372. <el-input size="small" type="number" v-model="form.use_point" autocomplete="off"></el-input>
  373. <br/>
  374. <div class="tips-text" style="line-height: 24px;">
  375. 抽奖是否需要消耗积分,如有设置则每抽一次消耗一次积分
  376. </div>
  377. </el-form-item>
  378. <el-form-item label="规则说明" prop="rule_explain">
  379. <com-rich-text style="width: 750px" :simple-attachment="true" v-model="form.rule_explain"></com-rich-text>
  380. <br/>
  381. <div class="tips-text" style="line-height: 24px;">
  382. 抽奖规则说明,亦可以图片形式展示
  383. </div>
  384. </el-form-item>
  385. </el-form>
  386. </div>
  387. <el-button type="primary" class="button-item" size="small" :loading=btnLoading @click="onSubmit">提交</el-button>
  388. </el-tab-pane>
  389. <el-tab-pane label="背景图设置">
  390. <div class="form_box">
  391. <el-form :model="form1"
  392. style="position: relative"
  393. size="small" label-width="160px" >
  394. <div flex="box:first" style="margin-bottom: 10px;min-width: 1280px; background-color: #ffffff;">
  395. <div class="all-components" style="max-height: 100%; overflow-y: auto;">
  396. <div style="overflow-y: auto;padding: 0 25px;width: 435px;">
  397. <div class="mobile-framework" style="height: 705px;">
  398. <div class="mobile-framework-header"></div>
  399. <div class="mobile-framework-body" id='framework-img' :style="'background:'+ form.bg_color" >
  400. <div class="background-box" :style=' "background-image:url(" + form.bg_img + ")" '>
  401. <div class="title" style="background-image: url('/resources/addons/sudoku/img/title.png');">
  402. </div>
  403. <div style="width: 280px;height: 280px;margin: 0 auto 75px;background-image: url('/resources/addons/sudoku/img/box.png');background-size: contain;background-repeat: no-repeat;">
  404. </div>
  405. </div>
  406. </div>
  407. </div>
  408. </div>
  409. </div>
  410. <div id="diy-list" style="padding-left: 2px;position: relative;">
  411. <el-form-item label="背景图" prop="id_card_reverse">
  412. <div class="id-card">
  413. <com-attachment v-model="form.bg_img" :simple="false">
  414. <div class="card-upload">
  415. <img v-if="form.bg_img"
  416. :src="form.bg_img">
  417. <img v-else src="/resources/addons/sudoku/img/indexbg2.png">
  418. <el-button icon="el-icon-plus" circle type="primary"></el-button>
  419. </div>
  420. </com-attachment>
  421. </div>
  422. </el-form-item>
  423. <el-form-item label="下半部背景颜色">
  424. <el-color-picker v-model="form.bg_color"></el-color-picker>
  425. </el-form-item>
  426. <div>
  427. <div style="width:100%; float: left; padding: 20px;">
  428. <el-button class="button-item" type="primary" style="margin-top: 24px;" @click="onSubmit" size="small">保存</el-button>
  429. </div>
  430. </div>
  431. </div>
  432. </div>
  433. </el-form>
  434. </div>
  435. </el-tab-pane>
  436. </el-tabs>
  437. </el-card>
  438. </div>
  439. <style>
  440. .el-textarea__inner {
  441. padding: 0 15px;
  442. }
  443. </style>
  444. <script>
  445. const app = new Vue({
  446. el: '#app',
  447. data() {
  448. return {
  449. loading: false,
  450. time: null,
  451. btnLoading: false,
  452. form: {
  453. bg_img: "",
  454. bg_color: "#6d0505",
  455. probability_points: 0,
  456. open_time: [],
  457. type: '',
  458. lucky_number: '',
  459. use_point: '',
  460. rule_explain: '',
  461. shipping_type: '1',
  462. is_show: 1,
  463. },
  464. form1:{},
  465. FormRules: {
  466. probability_points: [
  467. {required: true, message: '概率不能为空', trigger: 'blur'},
  468. {
  469. validator: (rule, value, callback) => {
  470. if(value>10000||value<0){
  471. callback('必须大于0');
  472. }
  473. if(value.toString().split(".")[1].length>3){
  474. callback('最大三位小数');
  475. }
  476. callback();
  477. }
  478. }
  479. ],
  480. lucky_number: [
  481. {required: true, message: '抽奖次数不能为空', trigger: 'blur'},
  482. {
  483. validator: (rule, value, callback) => {
  484. if(value>100000||value<0){
  485. callback('必须大于0,小于100000');
  486. }
  487. callback();
  488. }
  489. }
  490. ],
  491. type: [
  492. {required: true, message: '抽奖规则不能为空', trigger: 'blur'},
  493. ],
  494. shipping_type: [
  495. {required: true, message: '邮费方式不能为空', trigger: 'blur'},
  496. ],
  497. open_time: [
  498. {required: true, message: '抽奖时间不能为空', trigger: 'blur'},
  499. ],
  500. },
  501. };
  502. },
  503. methods: {
  504. onSubmit() {
  505. this.$refs.form.validate((valid) => {
  506. if (valid) {
  507. this.form.start_at = this.form.open_time[0];
  508. this.form.end_at = this.form.open_time[1];
  509. this.btnLoading = true;
  510. let para = Object.assign(this.form);
  511. console.log(para);
  512. request({
  513. params: {
  514. r: 'sudoku/setting/index',
  515. },
  516. data: para,
  517. method: 'post'
  518. }).then(e => {
  519. this.btnLoading = false;
  520. if (e.data.code === 0) {
  521. this.$message({
  522. message: e.data.msg,
  523. type: 'success'
  524. });
  525. } else {
  526. this.$message.error(e.data.msg);
  527. }
  528. }).catch(e => {
  529. this.btnLoading = false;
  530. this.$message.error(e.data.msg);
  531. });
  532. }
  533. });
  534. },
  535. getList() {
  536. this.loading = true;
  537. request({
  538. params: {
  539. r: 'sudoku/setting/index',
  540. },
  541. }).then(e => {
  542. this.loading = false;
  543. if (e.data.code === 0) {
  544. let data = e.data.data
  545. if(e.data.data.length>0|| e.data.data.length == undefined) this.form = e.data.data;
  546. if(this.form.start_at && this.form.end_at) this.$set(this.form, 'open_time', [data.start_at, data.end_at]);
  547. this.form.bg_img = this.form.bg_img?this.form.bg_img:data.api_url+'/resources/addons/sudoku/img/indexbg2.png';
  548. } else {
  549. this.$message.error(e.data.msg);
  550. }
  551. }).catch(e => {
  552. this.loading = false;
  553. });
  554. },
  555. },
  556. mounted: function () {
  557. this.getList();
  558. }
  559. })
  560. </script>