tempEdit.blade.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. @extends('layouts.base')
  2. @section('content')
  3. <link rel="stylesheet" href="{{static_url('css/public-number.css')}}">
  4. <style>
  5. .panel{
  6. margin-bottom:10px!important;
  7. padding-left: 20px;
  8. border-radius: 10px;
  9. }
  10. .panel .active a {
  11. background-color: #29ba9c!important;
  12. border-radius: 18px!important;
  13. color:#fff;
  14. }
  15. .panel a{
  16. border:none!important;
  17. background-color:#fff!important;
  18. }
  19. .content{
  20. background: #eff3f6;
  21. padding: 10px!important;
  22. }
  23. .con{
  24. padding-bottom:40px;
  25. position:relative;
  26. min-height:100vh;
  27. background-color:#fff;
  28. border-radius: 8px;
  29. }
  30. .con .setting .block{
  31. padding:10px;
  32. background-color:#fff;
  33. border-radius: 8px;
  34. }
  35. .con .setting .block .title{
  36. display:flex;
  37. align-items:center;
  38. margin-bottom:15px;
  39. }
  40. .confirm-btn{
  41. width: calc(100% - 266px);
  42. position:fixed;
  43. bottom:0;
  44. right:0;
  45. margin-right:10px;
  46. line-height:63px;
  47. background-color: #ffffff;
  48. box-shadow: 0px 8px 23px 1px
  49. rgba(51, 51, 51, 0.3);
  50. background-color:#fff;
  51. text-align:center;
  52. }
  53. b{
  54. font-size:14px;
  55. }
  56. .head{
  57. width: 100%;
  58. height: 43px;
  59. background-color: #f6f7f9;
  60. display:flex;
  61. align-items:center;
  62. margin:0 auto;
  63. }
  64. .left{
  65. width:42%;
  66. height:100%;
  67. float:left;
  68. }
  69. .right{
  70. width:58%;
  71. height:100%;
  72. float:left;
  73. border-left:solid 1px #f6f7f9;
  74. }
  75. .block:after{
  76. content:'';
  77. display:block;
  78. clear:both;
  79. }
  80. </style>
  81. <div id='re_content' >
  82. <div class="con">
  83. <div class="setting">
  84. <div class="block">
  85. <div class="title"><span style="width: 4px;height: 18px;background-color: #29ba9c;margin-right:15px;display:inline-block;"></span><b>添加微信自定义模板</b><span style="margin-left:20px;font-size:12px;">请选择对应模板变量, 否则消息通知内容有误</span></div>
  86. <el-form ref="form" :model="form" label-width="20%">
  87. <div class="left">
  88. <div style="margin-left:20px;margin-bottom:20px;">选择模板区域</div>
  89. <el-form-item label="添加模板">
  90. <el-input v-model="templateidshort" style="width:70%;" ></el-input>
  91. <el-button type="primary" @click="addQuick">快速添加</el-button>
  92. </el-form-item>
  93. <el-form-item label="选择模板">
  94. <template>
  95. <el-select style="width:90%;" v-model="form.template_id" @change="Select" filterable>
  96. <el-option
  97. v-for="item in tmp_list"
  98. :label="item.title"
  99. :value="item.template_id">
  100. </el-option>
  101. </el-select>
  102. </template>
  103. </el-form-item>
  104. <el-form-item label="模板展示" v-if="content">
  105. <div style="width: 50%;min-height:129px;background-color: #f6f7f9;border-radius: 4px;box-sizing:border-box;padding:8px;" v-html="content">
  106. </div>
  107. </el-form-item>
  108. <el-form-item label="模板变量类型" >
  109. <template>
  110. <el-select style="width:90%;" v-model="value" @change="paramSelect" filterable>
  111. <el-option
  112. v-for="item in temp"
  113. :label="item.title"
  114. :value="item.value">
  115. </el-option>
  116. </el-select>
  117. </template>
  118. <div v-if="param.length>0" style="width:90%;">提示:点击变量后会自动插入选择的文本框的焦点位置,在发送给粉丝时系统会自动替换对应变量值</div>
  119. </el-form-item>
  120. <el-form-item label="类型选择" v-if="param.length>0" >
  121. <div style="width:90%;">
  122. <template v-for="(item,index,key) in param">
  123. <el-tag style="margin-right:10px;margin-bottom:10px;" @click="add(item)">[[item]]</el-tag>
  124. </template>
  125. </div>
  126. </el-form-item>
  127. </div>
  128. </el-form>
  129. <el-form ref="form" :model="form" label-width="15%">
  130. <div class="right">
  131. <div style="margin-left:20px;margin-bottom:20px;">模板设置变量区域</div>
  132. <el-form-item label="模板名称">
  133. <el-input v-model="form.title" @focus="addName('title')" style="width:80%;" ref="title"></el-input>
  134. </el-form-item>
  135. <el-form-item label="模板消息ID">
  136. <el-input v-model="form.template_id" style="width:80%;" disabled></el-input>
  137. </el-form-item>
  138. <el-form-item label="头部标题">
  139. <el-input type="textarea" v-model="form.first" @focus="addName('first')" style="width:80%;" ref="first"></el-input>
  140. </el-form-item>
  141. {{-- <el-form-item label="文字颜色">--}}
  142. {{-- <div><el-color-picker v-model="form.first_color" @change="change"></el-color-picker></div>--}}
  143. {{-- </el-form-item>--}}
  144. <el-form-item label="键值设置">
  145. <div class="tabel-data" style="width:80%;">
  146. <div class="head">
  147. <div style="width:25%;text-align:center;">键名</div>
  148. <div style="width:50%;text-align:center;">描述</div>
  149. <div style="width:25%;text-align:center;">颜色</div>
  150. </div>
  151. <div class="data">
  152. <div v-for="(item,index,key) in block" style="display:flex;align-items:center;margin-top:20px;">
  153. <div style="width:25%;text-align:center;">[[item.title]]</div>
  154. <div style="width:50%;text-align:center;">
  155. <el-input type="textarea" v-model="item.value" @focus="addName(item)" ></el-input>
  156. </div>
  157. <div style="width:25%;text-align:center;display:flex;align-items:center;justify-content:center;"><el-color-picker v-model="item.color" @change="change"></el-color-picker></div>
  158. </div>
  159. </div>
  160. </div>
  161. </el-form-item>
  162. </el-form-item>
  163. <el-form-item label="尾部描述">
  164. <el-input type="textarea" v-model="form.remark" @focus="addName('remark')" style="width:80%;" ref="remark"></el-input>
  165. </el-form-item>
  166. <el-form-item label="文字颜色">
  167. <div><el-color-picker v-model="form.remark_color" @change="change"></el-color-picker></div>
  168. </el-form-item>
  169. <el-form-item label="跳转链接地址">
  170. <el-input v-model="form.news_link" @focus="addName('new_link')" style="width:70%;" ref="new_link"></el-input><el-button @click="show=true" style="margin-left:10px;">选择链接</el-button>
  171. </el-form-item>
  172. </div>
  173. </el-form>
  174. </div>
  175. </div>
  176. <div class="confirm-btn">
  177. <el-button type="primary" @click="submit">提交</el-button>
  178. </div>
  179. <pop :show="show" @replace="changeProp1" @add="parHref"></pop>
  180. </div>
  181. </div>
  182. @include('public.admin.pop')
  183. <script>
  184. var vm = new Vue({
  185. el: "#re_content",
  186. delimiters: ['[[', ']]'],
  187. data() {
  188. return {
  189. info:'',
  190. id:'',
  191. templateidshort:'',
  192. name:'',
  193. show:false,
  194. tmp_list:[],
  195. content:'',
  196. temp:[],
  197. param:[],
  198. block:[],
  199. value:'',
  200. form:{
  201. tp_kw:[],
  202. tp_color:[],
  203. tp_value:[],
  204. title:'',
  205. template_id:'',
  206. first:'',
  207. first_color:"",
  208. remark:'',
  209. remark_color:"",
  210. news_link:'',
  211. },
  212. }
  213. },
  214. mounted () {
  215. this.UrlSearch()
  216. this.gettemp();
  217. },
  218. methods: {
  219. UrlSearch() {
  220. var name, value;
  221. var str = location.href; //获取到整个地址
  222. var num = str.indexOf("?")
  223. str = str.substr(num + 1); //取得num+1后所有参数,这里的num+1是下标 str.substr(start [, length ]
  224. var arr = str.split("&"); //以&分割各个参数放到数组里
  225. for (var i = 0; i < arr.length; i++) {
  226. num = arr[i].indexOf("=");
  227. if (num > 0) {
  228. name = arr[i].substring(0, num);
  229. value = arr[i].substr(num + 1);
  230. this.id = value;
  231. }
  232. }
  233. },
  234. addQuick(){
  235. this.$http.post("{!! yzWebUrl('setting.wechat-notice.addTmp') !!}",{templateidshort:this.templateidshort}).then(function (response){
  236. if (response.data.result) {
  237. this.$message({message: response.data.msg,type: 'success'});
  238. window.location.href='{!! yzWebFullUrl('setting.diy-temp.index') !!}'
  239. }
  240. else {
  241. this.$message({message: response.data.msg,type: 'error'});
  242. loading.close();
  243. location.reload();
  244. }
  245. },function (response) {
  246. this.$message({message: response.data.msg,type: 'error'});
  247. })
  248. },
  249. change(val){
  250. this.$forceUpdate()
  251. },
  252. add(item){
  253. if(!this.name){
  254. return
  255. }
  256. if(this.name instanceof Object){
  257. this.block.forEach((list,index,key)=>{
  258. if(list.title==this.name.title){
  259. this.block[index].value=[this.block[index].value]+`[${item}]`
  260. }
  261. })
  262. }else{
  263. this.form[this.name]=this.$refs[this.name].value+`[${item}]`
  264. }
  265. },
  266. addName(name){
  267. this.name=name
  268. },
  269. // 弹窗显示与隐藏的控制
  270. changeProp1(item){
  271. this.show=item;
  272. },
  273. // 当前链接的增加
  274. parHref(child,confirm){
  275. this.show=confirm;
  276. this.form.news_link=child;
  277. },
  278. paramSelect(val){
  279. this.temp.forEach((item,index,key)=>{
  280. if(item.value==val){
  281. this.param=this.temp[index].param
  282. }
  283. })
  284. },
  285. Select(val){
  286. this.block=[];
  287. this.tmp_list.forEach((item,index,key)=>{
  288. if(item.template_id==val){
  289. this.content=this.tmp_list[index].content
  290. this.form.template_id=item.template_id
  291. this.form.title=item.title
  292. this.tmp_list[index].contents.slice(1,this.tmp_list[index].contents.length-1).forEach((list,index,key)=>{
  293. this.block.push({title:list,color:"#101111",value:''})
  294. })
  295. }
  296. })
  297. },
  298. getData(){
  299. this.$http.post('{!! yzWebFullUrl('setting.diy-temp.edit') !!}',{id:this.id}).then(function (response){
  300. if (response.data.result) {
  301. this.info=response.data.data.temp
  302. this.info.data.forEach((item,index,key)=>{
  303. this.block.push({title:item.keywords,color:item.color,value:item.value})
  304. })
  305. this.form.first_color=this.info.first_color
  306. this.form.first=this.info.first
  307. this.form.news_link=this.info.news_link
  308. this.form.remark=this.info.remark
  309. this.form.remark_color=this.info.remark_color
  310. this.form.template_id=this.info.template_id
  311. this.form.title=this.info.title
  312. this.temp=response.data.data.wechat_temp
  313. this.tmp_list.forEach((item,index,key)=>{
  314. if(item.template_id==this.form.template_id){
  315. this.content=this.tmp_list[index].content
  316. }
  317. })
  318. this.$forceUpdate()
  319. }
  320. else {
  321. this.$message({message: response.data.msg,type: 'error'});
  322. }
  323. },function (response) {
  324. this.$message({message: response.data.msg,type: 'error'});
  325. })
  326. },
  327. gettemp(){
  328. this.$http.post('{!! yzWebFullUrl('setting.wechat-notice.returnJson') !!}').then(function (response){
  329. if (response.data.result) {
  330. this.tmp_list=response.data.data.tmp_list
  331. this.getData();
  332. this.$forceUpdate()
  333. }
  334. else {
  335. this.$message({message: response.data.msg,type: 'error'});
  336. }
  337. },function (response) {
  338. this.$message({message: response.data.msg,type: 'error'});
  339. })
  340. },
  341. submit() {
  342. this.block.forEach((item,index,key)=>{
  343. this.form.tp_kw.push(item.title)
  344. this.form.tp_value.push(item.value)
  345. this.form.tp_color.push(item.color)
  346. })
  347. this.$http.post('{!! yzWebFullUrl('setting.diy-temp.edit') !!}',{'temp':this.form,id:this.id}).then(function (response){
  348. this.$message({message: response.data.msg,type: 'success'});
  349. window.location.href='{!! yzWebFullUrl('setting.diy-temp.index') !!}'
  350. },function (response) {
  351. this.$message({message: response.data.msg,type: 'error'});
  352. })
  353. },
  354. },
  355. });
  356. </script>
  357. @endsection