love.blade.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. @extends('layouts.base')
  2. @section('title', '基础设置')
  3. @section('content')
  4. <link rel="stylesheet" href="{{resource_get('plugins/new-poster/views/admin/index.css')}}">
  5. <link rel="stylesheet" href="{{resource_get('plugins/new-poster/views/admin/edit.css')}}">
  6. <link rel="stylesheet" href="{{static_url('css/public-number.css')}}">
  7. <style>
  8. /* 导航 */
  9. .el-radio-button .el-radio-button__inner,.el-radio-button:first-child .el-radio-button__inner {border-radius: 4px 4px 4px 4px;border-left: 0px;}
  10. .el-radio-button__inner{border:0;}
  11. .el-radio-button:last-child .el-radio-button__inner {border-radius: 4px 4px 4px 4px;}
  12. .upload-boxed .el-icon-close {position: absolute;top: -5px;right: -5px;color: #fff;background: #333;border-radius: 50%;cursor: pointer;}
  13. .el-radio__inner { border: 1px solid #cfcfcf;}
  14. .edit-poster .el-form-item__label{width:20%!important}
  15. .edit-poster .el-form-item__content{margin-left:20%!important}
  16. </style>
  17. <div class="all">
  18. <div id="app" v-cloak>
  19. <el-form ref="form" :model="form" :rules="rules" label-width="15%">
  20. <div class="vue-head">
  21. <el-radio-group v-model="order_type">
  22. <el-radio-button label="1">海报设置</el-radio-button>
  23. </el-radio-group>
  24. </div>
  25. <div v-show="order_type==1">
  26. <div class="vue-head">
  27. <div class="vue-main-title">
  28. <div class="vue-main-title-left"></div>
  29. <div class="vue-main-title-content">基础设置</div>
  30. </div>
  31. <div class="vue-main-form">
  32. <el-form-item label="海报名称" prop="title">
  33. <el-input v-model="form.title" style="width:70%;" ref="title"></el-input>
  34. </el-form-item>
  35. <el-form-item label="是否启用" prop="status">
  36. <el-switch v-model="form.status" :active-value="1" :inactive-value="0"></el-switch>
  37. </el-form-item>
  38. </div>
  39. </div>
  40. <div class="vue-head" style="margin-top:20px">
  41. <div class="vue-main-title">
  42. <div class="vue-main-title-left"></div>
  43. <div class="vue-main-title-content">海报设计</div>
  44. </div>
  45. <div class="vue-main-form">
  46. <div style="width:85%;margin:auto;display:flex;margin-bottom:30px;">
  47. <div style="width: 320px;height: 504px;border: 1px solid #ccc;position: relative;" :style="{backgroundColor:(background_type==0?form.color:'')}">
  48. <img v-if="form.background_url&&background_type==1" :src="form.background_url" alt="" style="width:100%;height:100%;">
  49. <drag-resize
  50. v-for="(rect, index) in rects"
  51. :key="index"
  52. :w="rect.width"
  53. :h="rect.height"
  54. :x="rect.left"
  55. :y="rect.top"
  56. :axis="rect.axis"
  57. :is-active="rect.active"
  58. :minw="rect.minw"
  59. :minh="rect.minh"
  60. :is-draggable="rect.draggable"
  61. :is-resizable="rect.resizable"
  62. :parent-limitation="rect.parentLim"
  63. :aspect-ratio="rect.aspectRatio"
  64. :z="rect.zIndex"
  65. :content-class="rect.class"
  66. v-on:activated="activateEv(index)"
  67. v-on:deactivated="deactivateEv(index)"
  68. v-on:dragging="changePosition($event, index)"
  69. v-on:resizing="changeSize($event, index)"
  70. style="position: absolute;"
  71. >
  72. <div v-if="rect.type=='nickname'"
  73. :style="{color:rect.color,fontSize:rect.size+'px',fontWeight:(rect.bold?'bold':''),fontStyle:(rect.italic?'italic':''),textDecoration:((rect.slide||rect.under)?rect.slide?'line-through':'underline':'')}"
  74. style="width:100%;height:100%;white-space:nowrap;overflow:hidden"
  75. >
  76. 昵称
  77. </div>
  78. <div v-if="rect.type=='usable_love'"
  79. :style="{color:rect.color,fontSize:rect.size+'px',fontWeight:(rect.bold?'bold':''),fontStyle:(rect.italic?'italic':''),textDecoration:((rect.slide||rect.under)?rect.slide?'line-through':'underline':'')}"
  80. style="width:100%;height:100%;white-space:nowrap;overflow:hidden"
  81. >
  82. 个人可用爱心值余值
  83. </div>
  84. <div v-if="rect.type=='frozen_love'"
  85. :style="{color:rect.color,fontSize:rect.size+'px',fontWeight:(rect.bold?'bold':''),fontStyle:(rect.italic?'italic':''),textDecoration:((rect.slide||rect.under)?rect.slide?'line-through':'underline':'')}"
  86. style="width:100%;height:100%;white-space:nowrap;overflow:hidden"
  87. >
  88. 个人冻结爱心值余值
  89. </div>
  90. <!-- 会员头像 -->
  91. <img v-if="rect.type=='head'" :src="head_url" alt="" style="width:100%;height:100%;">
  92. <!-- 二维码 -->
  93. <img v-if="rect.type=='qr'" :src="qr_url" alt="" style="width:100%;height:100%;">
  94. </drag-resize>
  95. </div>
  96. <div class="edit-poster" style="flex:1;margin-left:10%">
  97. <!-- <div>背景图片</div> -->
  98. <el-form-item label="背景" prop="background">
  99. <el-radio v-model="background_type" :label="0">颜色</el-radio>
  100. <el-radio v-model="background_type" :label="1">自定义图片</el-radio>
  101. </el-form-item>
  102. <el-form-item label="" prop="background" v-if="background_type==1">
  103. <div class="upload-box" @click="openUpload('background')" v-if="!form.background_url">
  104. <i class="el-icon-plus" style="font-size:32px"></i>
  105. </div>
  106. <div @click="openUpload('background')" class="upload-boxed" v-if="form.background_url" style="height:236.25px">
  107. <img :src="form.background_url" alt="" style="width:150px;height:236.25px;border-radius: 5px;cursor: pointer;">
  108. <i class="el-icon-close" @click.stop="clearImg('background')" title="点击清除图片"></i>
  109. <div class="upload-boxed-text">点击重新上传</div>
  110. </div>
  111. <div class="tip">建议背景图片尺寸: 640*1008
  112. <span v-if="isDecorate">
  113. <span @click.stop="jumpUrl" style="color: #196dfa;font-weight: 600;margin-left: 15px;cursor:pointer;">图片智能在线设计</span><i class="el-icon-question" style="color:#196dfa;margin-left:2px;" @click="showIntroduce = true;"></i>
  114. </span>
  115. </div>
  116. </el-form-item>
  117. <el-form-item label="" prop="" v-else>
  118. <el-color-picker v-model="form.color" style="display:inline-block"></el-color-picker>
  119. </el-form-item>
  120. <el-form-item label="海报元素" prop="" >
  121. <div style="width:500px;">
  122. <el-button size="small" @click="addEle('nickname')">昵称</el-button>
  123. <el-button size="small" @click="addEle('usable_love')">个人可用爱心值余值</el-button>
  124. <el-button size="small" @click="addEle('frozen_love')">个人冻结爱心值余值</el-button>
  125. <el-button size="small" @click="addEle('head')">会员头像</el-button>
  126. <el-button size="small" @click="addEle('qr')">推广二维码</el-button>
  127. <el-button type="text" v-if="choosed_index!=-1" icon="iconfont icon-ht_operation_delete" @click="delEle" title="删除当前元素" style="color:#F56C6C"></el-button>
  128. </div>
  129. </el-form-item>
  130. <!-- 昵称、可用、冻结爱心值 显示项 -->
  131. <div v-if="choosed_obj.type=='nickname' || choosed_obj.type=='usable_love' || choosed_obj.type=='frozen_love'">
  132. <el-form-item label="文字颜色">
  133. <el-color-picker v-model="choosed_obj.color" style="display:inline-block"></el-color-picker>
  134. </el-form-item>
  135. <el-form-item label="文字大小">
  136. <el-input v-model="choosed_obj.size" style="width:200px">
  137. <template slot="append">PX</template>
  138. </el-input>
  139. </el-form-item>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. </el-form>
  147. <!-- 分页 -->
  148. <div class="vue-page">
  149. <div class="vue-center">
  150. <el-button type="primary" @click="submitForm('form')">提交</el-button>
  151. <el-button @click="goBack">返回</el-button>
  152. </div>
  153. </div>
  154. <upload-img :upload-show="uploadShow" :name="chooseImgName" @replace="changeProp" @sure="sureImg"></upload-img>
  155. <pop :show="show" @replace="changeLink" @add="parHref"></pop>
  156. <program :pro="pro" @replacepro="changeprogram" @addpro="parpro"></program>
  157. </div>
  158. </div>
  159. @include('public.admin.uploadImg')
  160. @include('public.admin.vueDragResize')
  161. @include('public.admin.pop')
  162. @include('public.admin.program')
  163. <script>
  164. const CktUrl = "{!! $ckt_url !!}"; //* 创客贴url
  165. const IsDecorate = "{!! $is_decorate !!}";
  166. </script>
  167. <script>
  168. const qr_url = `{!! resource_get('plugins/new-poster/assets/img/qr.png') !!}`;
  169. const head_url = `{!! resource_get('plugins/new-poster/assets/img/head.jpg') !!}`;
  170. const thumb_url = `{!! resource_get('plugins/new-poster/assets/img/img.jpg') !!}`;
  171. const app_qr_url = `{!! resource_get('plugins/new-poster/assets/img/qr_app_share.jpg') !!}`;
  172. const qr_shop = `{!! resource_get('plugins/new-poster/assets/img/qr_shop.jpg') !!}`;
  173. const logo_url = `{!! resource_get('plugins/new-poster/assets/img/logo.png') !!}`;
  174. const goods_url = `{!! resource_get('plugins/new-poster/assets/img/goods.png') !!}`;
  175. let data = {!! json_encode($data)?:'[]' !!};
  176. let poster = {!! json_encode($poster)?:'{}' !!};
  177. let id = 0;
  178. let background_type = 1;
  179. if(data==null) {
  180. data = [];
  181. }
  182. if(poster==null) {
  183. poster = {};
  184. }
  185. else{
  186. id = poster.id;
  187. background_type = poster.background?1:0;
  188. }
  189. var app = new Vue({
  190. el:"#app",
  191. delimiters: ['[[', ']]'],
  192. name: 'test',
  193. data() {
  194. return{
  195. id:id,
  196. poster_type:1,
  197. background_type:background_type,
  198. label_word:"",
  199. label_show:false,
  200. history_show:false,
  201. show:false,//是否开启公众号弹窗
  202. pro:false ,//是否开启小程序弹窗
  203. chooseLink:'',
  204. chooseMiniLink:'',
  205. link_type:1,
  206. rects:[],
  207. data:data,
  208. zIndex:0,//全局层次
  209. choosed_obj:{},
  210. choosed_index:-1,
  211. qr_url :qr_url,
  212. head_url :head_url,
  213. thumb_url:thumb_url,
  214. app_qr_url:app_qr_url,
  215. logo_url:logo_url,
  216. qr_shop:qr_shop,
  217. goods_url:goods_url,
  218. listWidth:"",
  219. listHeight:"",
  220. color1:'1',
  221. order_type:1,
  222. link_show:false,
  223. link_ref : "",
  224. link_form:{
  225. },
  226. form:{
  227. // poster
  228. title:poster.title || "",
  229. status:poster.status || 0,
  230. background:poster.background || "",
  231. background_url:poster.background_url || "",
  232. color:poster.color || "",
  233. },
  234. uploadShow:false,
  235. chooseImgName:'',
  236. img_type:"",
  237. submit_url:'',
  238. showVisible:false,
  239. loading: false,
  240. rules:{
  241. name:{ required: true, message: '请输入'}
  242. },
  243. isDecorate:IsDecorate,
  244. }
  245. },
  246. created() {
  247. },
  248. mounted() {
  249. if(this.id) {
  250. this.submit_url = '{!! yzWebFullUrl('plugin.new-poster.admin.poster.edit-love') !!}'
  251. }
  252. else {
  253. this.submit_url = '{!! yzWebFullUrl('plugin.new-poster.admin.poster.add-love') !!}'
  254. }
  255. this.poster_type = this.getParam('poster_type');
  256. console.log(this.poster_type)
  257. this.setPosterView(this.data);
  258. },
  259. methods: {
  260. setPosterView(data) {
  261. data.forEach((item,index) => {
  262. let width = parseInt(item.width);
  263. let height = parseInt(item.height);
  264. let top = parseInt(item.top);
  265. let left =parseInt(item.left);
  266. if(item.type=='nickname'||item.type=='usable_love'||item.type=='frozen_love') {
  267. let size = Number(item.size.split('p')[0]);
  268. this.rects.push(
  269. {zIndex:this.zIndex+1,type:item.type,color:item.color,size:size,bold:item.bold,italic:item.italic,slide:item.slide,under:item.under,width:width,height:height,left:left,top:top,axis:"both",active:false,minw:40,minh:20,draggable:true,resizable:true,parentLim:true,aspectRatio:false,class:""}
  270. )
  271. }
  272. else if(item.type=="qr"){
  273. this.rects.push(
  274. {zIndex:this.zIndex+1,type:item.type,width:width,height:height,left:left,top:top,axis:"both",active:false,minw:40,minh:40,draggable:true,resizable:true,parentLim:true,aspectRatio:true,class:""}
  275. )
  276. }
  277. else if(item.type=="head") {
  278. this.rects.push(
  279. {zIndex:this.zIndex+1,type:item.type,width:width,height:height,left:left,top:top,axis:"both",active:false,minw:40,minh:40,draggable:true,resizable:true,parentLim:true,aspectRatio:true,class:""}
  280. )
  281. }
  282. this.zIndex++;
  283. })
  284. },
  285. submitForm(formName) {
  286. console.log(this.form)
  287. console.log(this.rects)
  288. let that = this;
  289. let json = {
  290. poster:{
  291. poster_type:this.poster_type,
  292. title:this.form.title,
  293. status:this.form.status,
  294. background:this.form.background,
  295. background_url:this.form.background_url,
  296. color:this.form.color,
  297. },
  298. poster_supplement:{
  299. },
  300. data:[],
  301. };
  302. // 背景类型
  303. if(this.background_type==1) {
  304. json.poster.color = "";
  305. }
  306. else {
  307. json.poster.background = "";
  308. json.poster.background_url = "";
  309. }
  310. this.rects.forEach((item,index) => {
  311. if(item.type=='nickname'||item.type=='usable_love' ||item.type=='frozen_love') {
  312. json.data.push({color:item.color,size:item.size+'px',bold:item.bold,italic:item.italic,slide:item.slide,under:item.under,width:item.width+'px',height:item.height+'px',top:item.top+'px',left:item.left+'px',type:item.type})
  313. }
  314. if(item.type=="qr"){
  315. json.data.push({width:item.width+'px',height:item.height+'px',top:item.top+'px',left:item.left+'px',type:item.type})
  316. }
  317. if(item.type=="head") {
  318. json.data.push({width:item.width+'px',height:item.height+'px',top:item.top+'px',left:item.left+'px',type:item.type})
  319. }
  320. });
  321. let json1 = {
  322. form_data : json,
  323. }
  324. if(this.id) {
  325. json1.id = this.id
  326. }
  327. this.$refs[formName].validate((valid) => {
  328. if (valid) {
  329. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  330. this.$http.post(this.submit_url, json1).then(response => {
  331. if (response.data.result) {
  332. this.$message({type: 'success',message: '操作成功!'});
  333. this.goBack();
  334. } else {
  335. this.$message({message: response.data.msg,type: 'error'});
  336. }
  337. loading.close();
  338. },response => {
  339. loading.close();
  340. });
  341. }
  342. else {
  343. console.log('error submit!!');
  344. return false;
  345. }
  346. });
  347. },
  348. goBack() {
  349. history.go(-1)
  350. },
  351. openUpload(str,img_type) {
  352. this.chooseImgName = str;
  353. this.uploadShow = true;
  354. this.img_type = img_type;
  355. },
  356. changeProp(val) {
  357. if(val == true) {
  358. this.uploadShow = false;
  359. }
  360. else {
  361. this.uploadShow = true;
  362. }
  363. },
  364. sureImg(name,image,image_url) {
  365. if(this.img_type) {
  366. this.rects[this.choosed_index][name] = image;
  367. this.rects[this.choosed_index][name+'_url'] = image_url;
  368. this.choosed_obj[name] = image;
  369. this.choosed_obj[name+'_url'] = image_url;
  370. this.$forceUpdate();
  371. }
  372. else {
  373. this.form[name] = image;
  374. this.form[name+'_url'] = image_url;
  375. }
  376. console.log(this.rects)
  377. },
  378. clearImg(str,type) {
  379. if(type) {
  380. this.rects[this.choosed_index][str] = "";
  381. this.rects[this.choosed_index][str+'_url'] = "";
  382. this.choosed_obj[str] = "";
  383. this.choosed_obj[str+'_url'] = "";
  384. }
  385. else {
  386. this.form[str] = "";
  387. this.form[str+'_url'] = "";
  388. }
  389. this.$forceUpdate();
  390. },
  391. addEle(type) {
  392. let is_true = false;
  393. let choose_index = -1;
  394. this.rects.some((item,index) => {
  395. if(item.type == type) {
  396. is_true = true;
  397. choose_index = index
  398. return true
  399. }
  400. });
  401. if(is_true) {
  402. this.rects[choose_index].active = true;
  403. return false;
  404. }
  405. if (type=='nickname'||type=='usable_love' ||type=='frozen_love') {
  406. this.rects.push(
  407. {zIndex:this.zIndex+1,type:type,color:"#f00",size:18,width:200,height:30,left:0,top:0,axis:"both",active:false,minw:40,minh:40,draggable:true,resizable:true,parentLim:true,aspectRatio:false,class:""}
  408. )
  409. }
  410. if(type=="qr"){
  411. this.rects.push(
  412. {zIndex:this.zIndex+1,type:type,width:100,height:100,left:0,top:0,axis:"both",active:false,minw:40,minh:40,draggable:true,resizable:true,parentLim:true,aspectRatio:true,class:""}
  413. )
  414. }
  415. if(type=="head") {
  416. this.rects.push(
  417. {zIndex:this.zIndex+1,type:type,width:100,height:100,left:0,top:0,axis:"both",active:false,minw:40,minh:40,draggable:true,resizable:true,parentLim:true,aspectRatio:true,class:""}
  418. )
  419. }
  420. this.zIndex++;
  421. },
  422. delEle() {
  423. console.log(this.rects);
  424. let list = JSON.parse(JSON.stringify(this.rects));
  425. list.splice(this.choosed_index,1);
  426. console.log(list);
  427. this.rects = [];
  428. // 样式处理
  429. setTimeout(() => {
  430. list.forEach((item,index) => {
  431. this.rects.push(item)
  432. })
  433. },10)
  434. this.choosed_obj = {};
  435. console.log(this.rects);
  436. this.choosed_index = -1;
  437. },
  438. activateEv(index) {
  439. console.log(index);
  440. if(this.choosed_index!=-1) {
  441. this.rects[this.choosed_index].active = false;
  442. }
  443. this.choosed_obj = this.rects[index];
  444. this.choosed_index = index;
  445. this.rects[index].active = true;
  446. },
  447. deactivateEv(index) {
  448. console.log(index)
  449. // this.rects[index].active = false;
  450. // this.choosed_index!=-1;
  451. },
  452. changePosition(newRect, index) {
  453. this.rects[index].top = newRect.top;
  454. this.rects[index].left = newRect.left;
  455. this.rects[index].width = newRect.width;
  456. this.rects[index].height = newRect.height;
  457. },
  458. changeSize(newRect, index) {
  459. this.rects[index].top = newRect.top;
  460. this.rects[index].left = newRect.left;
  461. this.rects[index].width = newRect.width;
  462. this.rects[index].height = newRect.height;
  463. },
  464. showLink(type,name,link_type) {
  465. if(type=="link") {
  466. this.chooseLink = name;
  467. this.show = true;
  468. }
  469. else {
  470. this.chooseMiniLink = name;
  471. this.pro = true;
  472. }
  473. this.link_type = link_type;
  474. },
  475. changeProp(val) {
  476. if(val == true) {
  477. this.uploadShow = false;
  478. }
  479. else {
  480. this.uploadShow = true;
  481. }
  482. },
  483. //弹窗显示与隐藏的控制
  484. changeLink(item){
  485. this.show=item;
  486. },
  487. //当前链接的增加
  488. parHref(child,confirm){
  489. this.show=confirm;
  490. // this.form.link=child;
  491. if(this.link_type!=5) {
  492. this.form[this.chooseLink] = child;
  493. }
  494. else {
  495. this.rects[this.choosed_index]['h5_link'] = child;
  496. this.$forceUpdate();
  497. }
  498. },
  499. changeprogram(item){
  500. this.pro=item;
  501. },
  502. parpro(child,confirm){
  503. this.pro=confirm;
  504. if(this.link_type!=2) {
  505. this.form[this.chooseMiniLink] = child;
  506. }
  507. else {
  508. this.rects[this.choosed_index]['mini_link'] = child;
  509. this.$forceUpdate();
  510. }
  511. },
  512. changeText(type) {
  513. if(type=='b') {
  514. this.choosed_obj.bold = this.choosed_obj.bold==1?0:1;
  515. this.rects[this.choosed_index].bold = this.choosed_obj.bold;
  516. }
  517. if(type=='i') {
  518. this.choosed_obj.italic = this.choosed_obj.italic==1?0:1;
  519. this.rects[this.choosed_index].italic = this.choosed_obj.italic;
  520. }
  521. if(type=='s') {
  522. this.choosed_obj.slide = this.choosed_obj.slide==1?0:1;
  523. this.rects[this.choosed_index].slide = this.choosed_obj.slide;
  524. if(this.rects[this.choosed_index].slide) {
  525. this.rects[this.choosed_index].under = 0;
  526. }
  527. }
  528. if(type=='u') {
  529. this.choosed_obj.under = this.choosed_obj.under==1?0:1;
  530. this.rects[this.choosed_index].under = this.choosed_obj.under;
  531. if(this.rects[this.choosed_index].under) {
  532. this.rects[this.choosed_index].slide = 0;
  533. }
  534. }
  535. },
  536. getParam(name) {
  537. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  538. var r = window.location.search.substr(1).match(reg);
  539. if (r != null) return unescape(r[2]);
  540. return null;
  541. },
  542. jumpUrl() {
  543. window.open(CktUrl);
  544. },
  545. },
  546. })
  547. </script>
  548. @endsection