index.php 21 KB

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