index.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. {extend name="public/container"}
  2. {block name="head_top"}
  3. <link rel="stylesheet" type="text/css" href="{__ADMIN_PATH}css/main.css" />
  4. <script src="{__FRAME_PATH}js/bootstrap.min.js"></script>
  5. <script src="{__FRAME_PATH}js/content.min.js"></script>
  6. <script src="{__ADMIN_PATH}frame/js/ajaxfileupload.js"></script>
  7. <script src="{__PLUG_PATH}moment.js"></script>
  8. {/block}
  9. {block name="content"}
  10. <div id="app" class="row">
  11. <div class="col-sm-12">
  12. <div class="wechat-reply-wrapper">
  13. <div class="ibox-title"><p>{{msg}}</p></div>
  14. <div class="ibox-content clearfix">
  15. <div class="view-wrapper col-sm-4">
  16. <div class="mobile-header">公众号</div>
  17. <section class="view-body" style="overflow:scroll;">
  18. <div class="time-wrapper"><span class="time">9:36</span></div>
  19. <div class="view-item text-box clearfix" :class="{show:type=='text'}">
  20. <div class="avatar fl"><img src="{__ADMIN_PATH}images/head.gif" /></div>
  21. <div class="box-content fl">
  22. {{dataGroup.text.content}}
  23. </div>
  24. </div>
  25. <div class="view-item news-box" :class="{show:type=='news'}" v-if="dataGroup.news.length >0">
  26. <div class="vn-content" v-if="dataGroup.news.length ==1">
  27. <div class="vn-title">{{dataGroup.news[0].title}}</div>
  28. <div class="vn-time">{{dataGroup.news[0].date}}</div>
  29. <div class="vn-picture" :style="{backgroundImage: 'url('+dataGroup.news[0].image+')'}"></div>
  30. <div class="vn-picture-info">{{dataGroup.news[0].description}}</div>
  31. <div class="vn-more">
  32. <a :href="dataGroup.news[0].url">阅读原文</a>
  33. </div>
  34. </div>
  35. <div class="vn-content" v-else>
  36. <div class="con-item-box">
  37. <div class="vn-picture" :style="{backgroundImage: 'url('+dataGroup.news[0].image+')'}"></div>
  38. <div class="first-title">{{dataGroup.news[0].title}}</div>
  39. </div>
  40. <div class="con-item-list clearfix" v-for="(newinfos,index) in dataGroup.news" v-if="index>0">
  41. <div class="list-tit-info fl">{{newinfos.title}}</div>
  42. <div class="list-pic fr" :style="{backgroundImage: 'url('+newinfos.image+')'}"></div>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="view-item text-box clearfix" :class="{show:type=='image'}">
  47. <div class="avatar fl"><img src="{__ADMIN_PATH}images/head.gif" /></div>
  48. <div class="box-content fl">
  49. <img class="picbox" :src="dataGroup.image.src" alt="" />
  50. </div>
  51. </div>
  52. <?php /* <div class="view-item music-box clearfix" :class="{show:type=='voice'}">
  53. <div class="avatar fl"><img src="{__ADMIN_PATH}images/head.gif" /></div>
  54. <div class="box-content fl">
  55. <p>{{musicTit}}</p>
  56. <p>{{musicInfo}}</p>
  57. <div class="music-icon"><i class="fa fa-music"></i></div>
  58. </div>
  59. </div> */ ?>
  60. <?php /* <div class="view-item video-box" :class="{show:type=='video'}">
  61. <div class="vn-content">
  62. <div class="vn-title">{{videoTit}}</div>
  63. <div class="vn-time">11月11日</div>
  64. <div class="video-content">
  65. <video src="" width="100%" controls="" preload=""></video>
  66. </div>
  67. </div>
  68. <div class="vn-more">{{videoInfo}}</div>
  69. </div> */ ?>
  70. </section>
  71. </div>
  72. <div class="control-wrapper col-sm-8">
  73. <section>
  74. <form action="" method="post" enctype="multipart/form-data">
  75. <div class="control-title">{{msg}}</div>
  76. <div class="control-body">
  77. <div class="form-group clearfix">
  78. <label class="col-sm-2 control-label tips" for="">规则状态</label>
  79. <div class="group-item col-sm-10">
  80. <div class="radio i-checks" style="display:inline;margin-left: 16px;">
  81. <label class="" style="padding-left: 0;">
  82. <input style="position: relative;top: 1px;left: 3px;" checked="checked" v-model="status" type="radio" value="1" name="status">
  83. 启用</label>
  84. </div>
  85. <div class="radio i-checks" style="display:inline;margin-left: 32px;">
  86. <label class="" style="padding-left: 0;">
  87. <input style="position: relative;top: 1px;left: 3px;" type="radio" value="0" v-model="status" name="status">
  88. 禁用
  89. </label>
  90. </div>
  91. </div>
  92. </div>
  93. <div class="form-group clearfix">
  94. <label class="col-sm-2 tips" for="">消息类型</label>
  95. <div class="col-sm-10 group-item">
  96. <select class="form-control m-b" v-model="type" name="account">
  97. <option value="text">文字消息</option>
  98. <option value="image">图片消息</option>
  99. <option value="news">图文消息</option>
  100. <option value="voice">声音消息</option>
  101. </select>
  102. </div>
  103. </div>
  104. <div class="control-main">
  105. <!-- 文字 -->
  106. <div class="control-item control-main-txt" :class="{show:type=='text'}">
  107. <div class="form-group clearfix">
  108. <label class="col-sm-2 tips" for="">规则内容</label>
  109. <div class="col-sm-10 group-item">
  110. <textarea v-model="dataGroup.text.content" name="" id="" cols="30" rows="10" placeholder="请输入内容"></textarea>
  111. </div>
  112. </div>
  113. </div>
  114. <!-- 图文 -->
  115. <div class="control-item control-main-news" :class="{show:type=='news'}">
  116. <div class="form-group clearfix">
  117. <label class="col-sm-2 tips" for="">选取图文</label>
  118. <div class="col-sm-10 group-item" @click="selectNews" style="cursor: pointer;"><span>选择图文消息</span></div>
  119. </div>
  120. </div>
  121. <!-- 图片 -->
  122. <div class="control-item control-main-picture" :class="{show:type=='image'}">
  123. <div class="form-group clearfix">
  124. <label class="col-sm-2 tips" for="">图片地址</label>
  125. <div class="col-sm-10 group-item">
  126. <input v-model="dataGroup.image.src" class="form-control" readonly type="text" placeholder="请上传图片"/>
  127. <span id="flag" class="file-btn" @click="uploadImg">上传</span>
  128. </div>
  129. </div>
  130. <div class="tips-info">
  131. <span>文件最大2Mb,支持bmp/png/jpeg/jpg/gif格式</span>
  132. <div class="upload-img"><img src="" alt="" /><span>上传图片</span></div>
  133. </div>
  134. </div>
  135. <!-- 音乐 -->
  136. <div class="control-item control-main-music" :class="{show:type=='voice'}">
  137. <div class="form-group clearfix">
  138. <label class="col-sm-2 tips" for="">上传声音</label>
  139. <div class="col-sm-10 group-item">
  140. <input class="form-control" type="text" readonly placeholder="请上传音乐文件或输入音乐URL地址" v-model="dataGroup.voice.src"/>
  141. <span class="file-btn" @click="uploadMusic">上传</span>
  142. </div>
  143. </div>
  144. </div>
  145. <!-- 视屏 -->
  146. <div class="control-item control-main-video" :class="{show:type=='video'}">
  147. <div class="form-group clearfix">
  148. <label class="col-sm-2 tips" for="">视频标题</label>
  149. <div class="col-sm-10 group-item">
  150. <input class="form-control" type="text" placeholder="视频标题"/>
  151. </div>
  152. </div>
  153. <div class="form-group clearfix">
  154. <label class="col-sm-2 tips" for="">视频上传</label>
  155. <div class="col-sm-10 group-item">
  156. <input class="form-control" type="text" placeholder="请上传音乐文件或输入视频URL地址"/>
  157. <span class="file-btn">上传</span>
  158. </div>
  159. </div>
  160. <div class="tips-info">
  161. <p>文件最大10MB,只支持MP4格式</p>
  162. </div>
  163. <div class="form-group">
  164. <label class="col-sm-2 tips" for="">视频描述</label>
  165. <div class="col-sm-10 group-item">
  166. <textarea name="" id="" cols="30" rows="10" placeholder="请输入内容"></textarea>
  167. </div>
  168. </div>
  169. <input id="file" type="file" name="file" style="display: none;" />
  170. </div>
  171. </div>
  172. </div>
  173. <div style="text-align: center;"><button type="button" class="btn btn-w-m btn-primary" @click="submit">提交</button></div>
  174. </form>
  175. </section>
  176. </div>
  177. </div>
  178. </div>
  179. </div>
  180. </div>
  181. {/block}
  182. {block name="script"}
  183. <script type="text/javascript">
  184. $eb = parent._mpApi, $upload = $('#file');
  185. $eb.mpFrame.start(function (Vue) {
  186. var $http = $eb.axios;
  187. const vm = new Vue({
  188. data: {
  189. status: 1,
  190. msg: '',
  191. type: 'text',
  192. textBox: '',
  193. pic: '',
  194. key:'',
  195. dataGroup:{
  196. text:{
  197. content:''
  198. },
  199. image:{
  200. src:''
  201. },
  202. voice:{
  203. src:''
  204. },
  205. news:[]
  206. },
  207. uploadColl: function () {
  208. },
  209. uploadLink: ''
  210. },
  211. methods: {
  212. transfer:function (str){
  213. var s = "";
  214. if (str.length === 0) { return "";}
  215. s = str.replace(/&amp;/g, "&");
  216. s = s.replace(/&lt;/g, "<");
  217. s = s.replace(/&gt;/g, ">");
  218. s = s.replace(/&nbsp;/g, " ");
  219. s = s.replace(/&#39;/g, "\'");
  220. s = s.replace(/&quot;/g, "\"");
  221. return s;
  222. },
  223. submit: function(){
  224. if(!this.check()) return false;
  225. $eb.axios.post("{:Url('save',array('key'=>$key))}",{key:this.key,status:this.status,data:this.dataGroup[this.type],type:this.type}).then(function(res){
  226. if(res.status == 200 && res.data.code == 200){
  227. $eb.message('success','设置成功!');
  228. }
  229. else
  230. $eb.message('error',res.data.msg || '设置失败!');
  231. }).catch(this.returnError);
  232. },
  233. check: function(){
  234. var dataGroup = this.dataGroup;
  235. switch (this.type){
  236. case 'text':
  237. if(dataGroup.text.content == '')
  238. return this.returnError('请输入文字消息内容');
  239. break;
  240. case 'image':
  241. if(dataGroup.image.src == '')
  242. return this.returnError('请上传图片');
  243. break;
  244. case 'news':
  245. if(dataGroup.news.length < 1)
  246. return this.returnError('请选择图文消息');
  247. break;
  248. case 'voice':
  249. if(dataGroup.voice.src == '')
  250. return this.returnError('请上传声音');
  251. break;
  252. }
  253. return true;
  254. },
  255. returnError:function(err){
  256. $eb.message('error',err);
  257. return false;
  258. },
  259. uploadImg: function () {
  260. var vm = this;
  261. this.uploadLink = "{:Url('upload_img')}";
  262. $('#file').attr('accept','image/*');
  263. this.uploadColl = function(pic){
  264. vm.dataGroup.image.src = vm.transfer(pic);
  265. };
  266. $('#file').trigger('click');
  267. },
  268. uploadMusic:function(){
  269. var vm = this;
  270. this.uploadLink = "{:Url('upload_file')}";
  271. $('#file').attr('accept','audio/*');
  272. this.uploadColl = function(pic){
  273. vm.dataGroup.voice.src = pic;
  274. };
  275. $('#file').trigger('click');
  276. },
  277. upload: function () {
  278. var vm = this;
  279. $('#file').on('change', function () {
  280. $.ajaxFileUpload({
  281. url: vm.uploadLink,
  282. type: 'post',
  283. secureuri: false, //一般设置为false
  284. data:{'file':'file'},
  285. fileElementId: 'file', // 上传文件的id、name属性名
  286. dataType: 'json', //返回值类型,一般设置为json、application/json
  287. success: function (data, status) {
  288. if(data.code == 200){
  289. vm.uploadColl && vm.uploadColl(data.data);
  290. $eb.message('success','上传成功!');
  291. }else{
  292. $eb.message('error',data.msg);
  293. }
  294. vm.upload();
  295. },
  296. error: function (data, status, e) {
  297. $eb.message('error','上传失败!');
  298. vm.upload();
  299. }
  300. });
  301. });
  302. },
  303. selectNews:function(){
  304. var vm = this,i;
  305. parent._selectNews$eb = function(data){
  306. var newsList = [];
  307. data.new.map((news)=>{
  308. newsList.push({
  309. title:news.title,
  310. description:news.synopsis,
  311. url:news.url,
  312. image:news.image_input,
  313. date:moment(news.add_time*1000).format('M月D日'),
  314. id:news.id
  315. });
  316. });
  317. vm.dataGroup.news = newsList;
  318. delete parent._selectNews$eb;
  319. $eb.closeModalFrame(i);
  320. };
  321. i = $eb.createModalFrame('选择图文消息',"{:Url('admin/wechat.wechatNewsCategory/select',['callback'=>'_selectNews$eb','type'=>$type])}",{w:975});
  322. }
  323. },
  324. mounted: function () {
  325. window.vm = this;
  326. this.upload();
  327. this.key = "{$key}"
  328. this.msg = "{$title}";
  329. var res= <?php echo json_encode($replay_arr); ?>;
  330. window.vm.type = res.type;
  331. window.vm.status = res.status;
  332. if(res.type == 'image') {
  333. window.vm.dataGroup.image.src = res.data.src;
  334. }else if(res.type == 'text'){
  335. window.vm.dataGroup.text.content = res.data.content;
  336. }else if(res.type == 'voice'){
  337. window.vm.dataGroup.voice.src = res.data.src;
  338. }else if(res.type == 'news'){
  339. window.vm.dataGroup.news = res.data;
  340. }
  341. if(window.vm.used_key){
  342. window.vm.keyword = res.key;
  343. }
  344. }
  345. });
  346. vm.$mount(document.getElementById('app'));
  347. });
  348. </script>
  349. {/block}