index.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('com-rich-text');
  4. ComponentHelper::loadComponentView('com-upload');
  5. ?>
  6. <link rel=" stylesheet" href="/resources/css/iconfont.css?t=<?= Yii::$app->params['css_cache_time'] ?>"">
  7. <div id="app" v-cloak>
  8. <div style="display:flex;justify-content:space-between;align-items:center;background-color:#FFF;padding: 10px 20px;font-weight:800;font-size:15px;">
  9. <div>招商活动设置</div>
  10. <div>
  11. <el-button :loading="btnLoading" class="button-item" type="primary" @click="store('ruleForm')" size="small">保存
  12. </el-button>
  13. </div>
  14. </div>
  15. <el-card class="box-card" v-loading="loading" shadow="never" style="border:0;min-width: 1200px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  16. <div class="form_box">
  17. <template>
  18. <el-card>
  19. <el-form :model="ruleForm" size="small" ref="ruleForm" label-width="150px" id="settingForm">
  20. <el-row>
  21. <div style="display:flex;justify-content:space-between;">
  22. <el-tabs v-model="activeName" type="card">
  23. <el-tab-pane label="基础设置" name="basic">
  24. <?php ComponentHelper::loadComponentView('basic', __DIR__ . '/'); ?>
  25. </el-tab-pane>
  26. <el-tab-pane label="海报设置" name="poster">
  27. <?php ComponentHelper::loadComponentView('poster', __DIR__ . '/'); ?>
  28. </el-tab-pane>
  29. </el-tabs>
  30. </div>
  31. </el-row>
  32. </el-form>
  33. </el-card>
  34. </template>
  35. </div>
  36. </el-card>
  37. </div>
  38. <script>
  39. const app = new Vue({
  40. el: '#app',
  41. data() {
  42. return {
  43. activeName: 'basic',
  44. loading: false,
  45. btnLoading: false,
  46. list: [],
  47. listLoading: false,
  48. addImgLoad: false,
  49. select_index: 3,
  50. avatar_max_top: 1285,
  51. avatar_max_left: 610,
  52. select_arr: [],
  53. ruleForm: {
  54. // 基础设置
  55. basic: {
  56. is_enable: 1,
  57. name: '',
  58. is_commission: 0,
  59. commission_type: 0,
  60. investment_scale: 0,
  61. investment_scale_parent: 0,
  62. site_scale: 0,
  63. site_scale_parent: 0,
  64. payment_method: 0,
  65. payment_type: 0,
  66. valid_duration: 0,
  67. is_show_at_center: 1,
  68. poster: {
  69. bg_pic: {
  70. url: '',
  71. is_show: 0
  72. },
  73. qr_code: {
  74. is_show: 0,
  75. size: 80,
  76. top: 0,
  77. left: 0,
  78. type: 1,
  79. file_type: 'image',
  80. },
  81. }
  82. },
  83. },
  84. }
  85. },
  86. mounted: function() {
  87. this.loadData();
  88. },
  89. watch: {
  90. },
  91. computed: {
  92. selectBool() {
  93. return function(num) {
  94. if (JSON.stringify(this.select_arr).indexOf(num) != -1) {
  95. return true;
  96. } else {
  97. return false;
  98. }
  99. }
  100. }
  101. },
  102. methods: {
  103. assiginObj(target = {}, sources = {}) {
  104. let obj = target;
  105. if (typeof target != 'object' || typeof sources != 'object') {
  106. return sources; // 如果其中一个不是对象 就返回sources
  107. }
  108. for (let key in sources) {
  109. // 如果target也存在 那就再次合并
  110. if (target.hasOwnProperty(key)) {
  111. obj[key] = this.assiginObj(target[key], sources[key]);
  112. } else {
  113. // 不存在就直接添加
  114. obj[key] = sources[key];
  115. }
  116. }
  117. return obj;
  118. },
  119. loadData() {
  120. if (this.loading === true) return;
  121. this.loading = true;
  122. request({
  123. params: {
  124. r: 'business-activity/setting/index',
  125. },
  126. method: 'get'
  127. }).then(e => {
  128. this.loading = false;
  129. if (e.data.code == 0) {
  130. let basic = e.data.data;
  131. this.ruleForm.basic = this.assiginObj(this.ruleForm.basic, basic);
  132. if (this.ruleForm.basic.poster.qr_code.is_show == 1) {
  133. this.select_arr.push(3);
  134. }
  135. }
  136. }).catch(e => {
  137. this.loading = false;
  138. })
  139. },
  140. deleteSelect(num) { //删除所选择的属性
  141. this.select_arr.forEach((item, index) => {
  142. if (item == num) {
  143. this.select_arr.splice(index, 1);
  144. if (num == 3) {
  145. this.ruleForm.basic.poster.qr_code.is_show = 0;
  146. }
  147. }
  148. })
  149. if (this.select_index == num) {
  150. this.select_index = 0;
  151. }
  152. },
  153. attarController(e, str) { //属性控制器
  154. if (str != 'avatarSize' && str != 'nameSize') {
  155. this.avatar_max_top = 1334 - e;
  156. this.avatar_max_left = 750 - e;
  157. this.ruleForm.basic.poster.qr_code.max_top = this.avatar_max_top;
  158. this.ruleForm.basic.poster.qr_code.max_left = this.avatar_max_left;
  159. }
  160. },
  161. selectItem(num) { //选中了哪一个海报属性
  162. this.select_index = num;
  163. if (JSON.stringify(this.select_arr).indexOf(num) == -1) {
  164. this.select_arr.push(num);
  165. }
  166. },
  167. beginAddImg(e) {
  168. if (e[0]) { //判断图片是否正在上传
  169. this.addImgLoad = true;
  170. }
  171. },
  172. handleSuccess(e) { //图片上传成功
  173. this.ruleForm.basic.poster.bg_pic.url = e.response.data.data.url;
  174. this.addImgLoad = false;
  175. this.$message({
  176. message: '图片上传成功!',
  177. type: 'success'
  178. });
  179. },
  180. store(formName) {
  181. this.$refs[formName].validate((valid) => {
  182. if (this.ruleForm.basic.poster.bg_pic.url == '') {
  183. this.$message.error('请添加海报背景');
  184. return;
  185. }
  186. if (this.ruleForm.basic.poster.bg_pic.url) {
  187. this.ruleForm.basic.poster.bg_pic.is_show = 1;
  188. } else {
  189. this.ruleForm.basic.poster.bg_pic.is_show = 0;
  190. }
  191. this.select_arr.forEach((item, index) => {
  192. if (item == 3) {
  193. this.ruleForm.basic.poster.qr_code.is_show = 1;
  194. }
  195. })
  196. if (!this.ruleForm.basic.poster.qr_code.is_show) {
  197. this.$message.error('请添加二维码');
  198. return;
  199. }
  200. let share = this.ruleForm.basic.poster;
  201. for (let key in share) {
  202. if (key == 'bg_pic') {
  203. let img = document.getElementsByClassName("main_content_img");
  204. this.ruleForm.basic.poster[key].width = img[0].width;
  205. this.ruleForm.basic.poster[key].height = img[0].height;
  206. } else {
  207. this.ruleForm.basic.poster[key].top_ratio = Math.floor(share[key].top / share[key].max_top * 100) / 100;
  208. this.ruleForm.basic.poster[key].left_ratio = Math.floor(share[key].left / share[key].max_left * 100) / 100;
  209. }
  210. }
  211. this.ruleForm.basic.poster.frame = {
  212. width: 750,
  213. height: 1334
  214. };
  215. if (valid) {
  216. if (this.btnLoading) return
  217. this.btnLoading = true;
  218. request({
  219. params: {
  220. r: 'business-activity/setting/index',
  221. },
  222. method: 'post',
  223. data: this.ruleForm.basic
  224. }).then(e => {
  225. this.btnLoading = false;
  226. if (e.data.code == 0) {
  227. this.$message.success(e.data.msg);
  228. } else {
  229. this.$message.error(e.data.msg);
  230. }
  231. }).catch(e => {
  232. this.$message.error(e);
  233. this.btnLoading = false;
  234. })
  235. } else {
  236. this.btnLoading = false;
  237. console.log('error submit!!');
  238. return false;
  239. }
  240. });
  241. },
  242. },
  243. });
  244. </script>
  245. <style>
  246. #settingForm .el-form-item__label {
  247. font-size: 13px;
  248. }
  249. .my-desc-label {
  250. font-size: 13px;
  251. }
  252. img {
  253. display: block;
  254. }
  255. .el-menu-item:hover {
  256. background: #ffffff !important;
  257. }
  258. .el-submenu__title:hover {
  259. background: #ffffff !important;
  260. }
  261. .header_box {
  262. border-radius: 5px 5px 0 0;
  263. color: #808695;
  264. }
  265. .add_temp_box {
  266. margin-bottom: 10px;
  267. }
  268. .template_data_left_title {
  269. margin-right: 13px;
  270. }
  271. .el-input {
  272. /* height: 40px; */
  273. width: 229px;
  274. }
  275. .main_box {
  276. background: #fff;
  277. padding: 0 25px 25px;
  278. }
  279. .main_img_box {
  280. width: 376px;
  281. height: 760px;
  282. position: relative;
  283. margin-right: 48px;
  284. }
  285. .main_img {
  286. position: absolute;
  287. top: 0;
  288. left: 0;
  289. }
  290. .main_content {
  291. background: #ffffff;
  292. width: 750px;
  293. height: 1334px;
  294. position: absolute;
  295. top: 137px;
  296. left: 49.1%;
  297. transform: translateX(-50%);
  298. border-radius: 0 0 77px 74px;
  299. scrollbar-width: none;
  300. zoom: 0.464;
  301. /* firefox */
  302. -ms-overflow-style: none;
  303. /* IE 10+ */
  304. overflow-x: hidden;
  305. overflow-y: hidden;
  306. }
  307. .main_content_img {
  308. width: 100%;
  309. }
  310. .add_img_title {
  311. font-size: 14px;
  312. font-weight: 700;
  313. margin-bottom: 30px;
  314. }
  315. .add_img_text {
  316. margin-right: 30px;
  317. color: #606266;
  318. }
  319. .edit_box .el-button {
  320. width: 158px;
  321. height: 35px;
  322. padding: 10px 20px;
  323. }
  324. .edit_box {
  325. padding-top: 40px;
  326. }
  327. .btn_list_box {
  328. margin: 40px 0;
  329. padding-bottom: 30px;
  330. width: 500px;
  331. border-bottom: 1px solid #F1F1F1;
  332. }
  333. .btn_list {
  334. border-radius: 5px;
  335. width: 80px;
  336. height: 80px;
  337. border: 2px solid #C5C8CE;
  338. position: relative;
  339. margin-right: 26px;
  340. cursor: pointer;
  341. }
  342. .btn_active {
  343. border: 2px solid #2DB7F5;
  344. background: #CBF3FF;
  345. }
  346. .btn_icon {
  347. color: #C5C8CE;
  348. font-size: 45px;
  349. position: absolute;
  350. top: 50%;
  351. left: 50%;
  352. transform: translate(-50%, -50%);
  353. }
  354. .btn_icon_close {
  355. position: absolute;
  356. right: 3px;
  357. top: 4px;
  358. color: #C5C8CE;
  359. }
  360. .btn_icon_close_active {
  361. color: #2DB7F5;
  362. }
  363. .set_title {
  364. font-weight: 700;
  365. color: #515A6E;
  366. font-size: 14px;
  367. margin-bottom: 19px;
  368. }
  369. .slider_title {
  370. width: 56px;
  371. text-align: right;
  372. margin-right: 17px;
  373. color: #606266;
  374. }
  375. .diy_avatar {
  376. position: absolute;
  377. color: #C5C8CE;
  378. }
  379. .save_btn {
  380. margin-top: 80px;
  381. }
  382. /* 修改原生element滑块的样式 */
  383. .el-input-number.is-without-controls .el-input__inner {
  384. padding-left: 10px;
  385. padding-right: 10px;
  386. }
  387. .el-input-number .el-input {
  388. display: block;
  389. width: 45px;
  390. height: 20px;
  391. font-size: 12px;
  392. }
  393. .el-slider__button {
  394. width: 10px;
  395. height: 10px;
  396. border: 1px solid #03C5FF;
  397. }
  398. .el-slider__button-wrapper {
  399. top: -17px;
  400. }
  401. .el-slider__runway {
  402. height: 2px;
  403. }
  404. .el-slider__input {
  405. margin-top: 0;
  406. }
  407. .el-slider__bar {
  408. height: 3px;
  409. }
  410. /* 修改原生element颜色选择器样式 */
  411. .el-color-picker__trigger {
  412. border-radius: 50%;
  413. height: 30px;
  414. width: 30px;
  415. padding: 3px;
  416. }
  417. .el-color-picker__color {
  418. border: 0px;
  419. }
  420. .el-color-picker__icon {
  421. display: none;
  422. }
  423. .el-color-picker__color-inner {
  424. border-radius: 50%;
  425. }
  426. /* 公共样式 */
  427. .flex {
  428. display: -webkit-box;
  429. display: -webkit-flex;
  430. /* #ifndef APP-NVUE */
  431. display: flex;
  432. /* #endif */
  433. }
  434. .flex-x-center {
  435. display: -webkit-box;
  436. display: -webkit-flex;
  437. /* #ifndef APP-NVUE */
  438. display: flex;
  439. /* #endif */
  440. -webkit-box-pack: center;
  441. -webkit-justify-content: center;
  442. -ms-flex-pack: center;
  443. justify-content: center;
  444. }
  445. .flex-x-between {
  446. display: -webkit-box;
  447. display: -webkit-flex;
  448. /* #ifndef APP-NVUE */
  449. display: flex;
  450. /* #endif */
  451. -webkit-box-pack: space-between;
  452. -webkit-justify-content: space-between;
  453. -ms-flex-pack: space-between;
  454. justify-content: space-between;
  455. }
  456. .flex-y-center {
  457. display: -webkit-box;
  458. display: -webkit-flex;
  459. /* #ifndef APP-NVUE */
  460. display: flex;
  461. /* #endif */
  462. -webkit-box-align: center;
  463. -webkit-align-items: center;
  464. -ms-flex-align: center;
  465. -ms-grid-row-align: center;
  466. align-items: center;
  467. }
  468. /* 溢出隐藏 */
  469. .over1 {
  470. text-overflow: -o-ellipsis-lastline;
  471. overflow: hidden;
  472. text-overflow: ellipsis;
  473. display: -webkit-box;
  474. -webkit-line-clamp: 1;
  475. -webkit-box-orient: vertical;
  476. }
  477. .over2 {
  478. text-overflow: -o-ellipsis-lastline;
  479. overflow: hidden;
  480. text-overflow: ellipsis;
  481. display: -webkit-box;
  482. -webkit-line-clamp: 2;
  483. -webkit-box-orient: vertical;
  484. }
  485. .pagination {
  486. width: 100%;
  487. flex-direction: row-reverse;
  488. }
  489. .default_tips {
  490. text-align: center;
  491. margin-top: 200px;
  492. color: #D0D2D6;
  493. font-size: 35px;
  494. }
  495. </style>