人人商城

notice.html 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. {template 'common/header'}
  2. <ul class="nav nav-tabs">
  3. <li><a href="{php echo url('mc/fans/display');}">粉丝列表</a></li>
  4. <li class="active"><a href="javascript:;"><i class="icon-group"></i> 发送客服消息</a></li>
  5. </ul>
  6. <style>
  7. .infol{margin-left:15px;padding:5px;max-width:60%;}
  8. .infor{margin-right:15px;padding:5px;max-width:60%;}
  9. .pull-left,.pull-right{position:relative;}
  10. .alert{margin-bottom:5px;padding:5px}
  11. .more{cursor:pointer;}
  12. </style>
  13. <div class="clearfix">
  14. <div class="panel panel-default">
  15. <div class="panel-heading">
  16. 和 <span class="text-danger"> {$nickname} </span> 的聊天记录
  17. </div>
  18. <div class="panel-body" id="log" style="max-height:300px;overflow-y:scroll">
  19. <div id="more" data-id="{$maxid}" class="text-center more text-info"><i class="fa fa-clock-o"></i> 查看更多消息</div>
  20. <div id="prev" data-id="{$maxid}">
  21. <div id="position"></div>
  22. </div>
  23. <div id="last" data-id="{$maxid}" style="margin-bottom:30px;"></div>
  24. </div>
  25. </div>
  26. <div class="panel panel-default">
  27. <div class="panel-heading">
  28. 和 <span class="text-danger"> {$nickname} </span> 的聊天
  29. </div>
  30. <div class="panel-body">
  31. <form action="" class="form-horizontal" role="form" id="form0">
  32. <div class="form-group">
  33. <label class="col-xs-12 col-sm-3 col-md-2 control-label">消息类型</label>
  34. <div class="col-sm-10">
  35. <label class="radio-inline"><input type="radio" value="7" name="msgtype" checked>文本</label>
  36. <label class="radio-inline"><input type="radio" value="2" name="msgtype">图片</label>
  37. <label class="radio-inline"><input type="radio" value="3" name="msgtype">语音</label>
  38. <label class="radio-inline"><input type="radio" value="4" name="msgtype">视频</label>
  39. <label class="radio-inline"><input type="radio" value="5" name="msgtype">音乐</label>
  40. <label class="radio-inline"><input type="radio" value="6" name="msgtype">图文</label>
  41. </div>
  42. </div>
  43. </form>
  44. <form action="{php echo url('mc/notice/post')}" method="post" class="form-horizontal reply" role="form" id="form7">
  45. <input type="hidden" name="msgtype" value="text">
  46. <input type="hidden" name="acid" value="{$fans['acid']}">
  47. <input type="hidden" name="openid" value="{$fans['openid']}">
  48. <div class="form-group">
  49. <label class="col-xs-12 col-sm-3 col-md-2 control-label">消息内容</label>
  50. <div class="col-sm-10">
  51. <textarea name="content" id="contentinput" class="form-control" cols="30" rows="2" placeholder="添加要回复的内容"></textarea>
  52. <div class="help-block">设置用户添加公众帐号好友时,发送的欢迎信息。<a href="javascript:;" id="content"><i class="fa fa-github-alt"></i> 表情</a></div>
  53. </div>
  54. </div>
  55. </form>
  56. <form action="{php echo url('mc/notice/post')}" method="post" class="form-horizontal reply" role="form" id="form2" style="display:none;">
  57. <input type="hidden" name="msgtype" value="image">
  58. <input type="hidden" name="acid" value="{$fans['acid']}">
  59. <input type="hidden" name="openid" value="{$fans['openid']}">
  60. <div class="form-group">
  61. <label class="col-xs-12 col-sm-3 col-md-2 control-label">上传图片</label>
  62. <div class="col-sm-9 col-xs-12">
  63. {php echo tpl_form_field_wechat_image('media_id', '', '');}
  64. <span class="help-block">请上传所要回复的图片</span>
  65. </div>
  66. </div>
  67. </form>
  68. <form action="{php echo url('mc/notice/post')}" method="post" class="form-horizontal reply" role="form" id="form3" style="display:none;">
  69. <input type="hidden" name="msgtype" value="voice">
  70. <input type="hidden" name="acid" value="{$fans['acid']}">
  71. <input type="hidden" name="openid" value="{$fans['openid']}">
  72. <div class="form-group">
  73. <label class="col-xs-12 col-sm-3 col-md-2 control-label">上传语音</label>
  74. <div class="col-sm-9 col-xs-12">
  75. {php echo tpl_form_field_wechat_voice('media_id', '');}
  76. <span class="help-block">请上传所要回复的语音</span>
  77. </div>
  78. </div>
  79. </form>
  80. <form action="{php echo url('mc/notice/post')}" method="post" class="form-horizontal reply" role="form" id="form4" style="display:none;">
  81. <input type="hidden" name="msgtype" value="video">
  82. <input type="hidden" name="acid" value="{$fans['acid']}">
  83. <input type="hidden" name="openid" value="{$fans['openid']}">
  84. <div class="form-group">
  85. <label class="col-xs-12 col-sm-3 col-md-2 control-label">视频标题</label>
  86. <div class="col-sm-9 col-xs-12">
  87. <input type="text" class="form-control" placeholder="添加视频消息的标题" name="title" value="">
  88. </div>
  89. </div>
  90. <div class="form-group">
  91. <label class="col-xs-12 col-sm-3 col-md-2 control-label">上传媒体缩略图</label>
  92. <div class="col-sm-9 col-xs-12">
  93. {php echo tpl_form_field_wechat_image('thumb_media_id', '', '', array('type' => 'thumb'));}
  94. <span class="help-block">请上传所要回复的媒体缩略图,上传图片必须是JPG类型</span>
  95. </div>
  96. </div>
  97. <div class="form-group">
  98. <label class="col-xs-12 col-sm-3 col-md-2 control-label">上传视频</label>
  99. <div class="col-sm-9 col-xs-12">
  100. {php echo tpl_form_field_wechat_video('media_id', '');}
  101. <span class="help-block">请上传所要回复的视频,上传视频必须是MP4类型</span>
  102. </div>
  103. </div>
  104. <div class="form-group">
  105. <label class="col-xs-12 col-sm-3 col-md-2 control-label">描述</label>
  106. <div class="col-sm-9 col-xs-12">
  107. <textarea style="height:80px;" class="form-control" cols="70" name="description" placeholder="添加视频消息的简短描述" ></textarea>
  108. <span class="help-block">描述内容将出现在视频名称下方,建议控制在20个汉字以内最佳</span>
  109. </div>
  110. </div>
  111. </form>
  112. <form action="{php echo url('mc/notice/post')}" method="post" class="form-horizontal reply" role="form" id="form5" style="display:none;">
  113. <input type="hidden" name="msgtype" value="music">
  114. <input type="hidden" name="acid" value="{$fans['acid']}">
  115. <input type="hidden" name="openid" value="{$fans['openid']}">
  116. <div class="form-group">
  117. <label class="col-xs-12 col-sm-3 col-md-2 control-label">音频标题</label>
  118. <div class="col-sm-9 col-xs-12">
  119. <input type="text" class="form-control" placeholder="添加音乐消息的标题" name="title" value="">
  120. </div>
  121. </div>
  122. <div class="form-group">
  123. <label class="col-xs-12 col-sm-3 col-md-2 control-label">上传媒体缩略图</label>
  124. <div class="col-sm-9 col-xs-12">
  125. {php echo tpl_form_field_image('thumb_media_id', '', '', array('tabs'=>array('remote'=>'active')));}
  126. <span class="help-block">请上传所要回复的媒体缩略图,上传图片必须是JPG类型</span>
  127. </div>
  128. </div>
  129. <div class="form-group">
  130. <label class="col-xs-12 col-sm-3 col-md-2 control-label">音频链接</label>
  131. <div class="col-sm-9 col-xs-12">
  132. {php echo tpl_form_field_audio('musicurl', '', array(''));}
  133. <span class="help-block">选择上传的音频文件或直接输入URL地址,常用格式:mp3</span>
  134. </div>
  135. </div>
  136. <div class="form-group">
  137. <label class="col-xs-12 col-sm-3 col-md-2 control-label">高品质链接</label>
  138. <div class="col-sm-9 col-xs-12">
  139. <input type="text" class="form-control" placeholder="" name="hqmusicurl">
  140. <span class="help-block">没有高品质音乐链接,请留空。高质量音乐链接,WIFI环境优先使用该链接播放音乐</span>
  141. </div>
  142. </div>
  143. <div class="form-group">
  144. <label class="col-xs-12 col-sm-3 col-md-2 control-label">描述</label>
  145. <div class="col-sm-9 col-xs-12">
  146. <textarea style="height:80px;" class="form-control" cols="70" name="description"placeholder="添加音乐消息的简短描述" ></textarea>
  147. <span class="help-block">描述内容将出现在音乐名称下方,建议控制在20个汉字以内最佳</span>
  148. </div>
  149. </div>
  150. </form>
  151. <form action="{php echo url('mc/notice/post')}" method="post" class="form-horizontal reply" role="form" id="form6" style="display:none">
  152. <input type="hidden" name="msgtype" value="news">
  153. <input type="hidden" name="acid" value="{$fans['acid']}">
  154. <input type="hidden" name="openid" value="{$fans['openid']}">
  155. <div class="form-group">
  156. <label class="col-xs-12 col-sm-3 col-md-2 control-label">关联关键字:</label>
  157. <div class="col-sm-9 col-xs-12" style="position:relative">
  158. <div class="input-group">
  159. <input type="hidden" name="ruleid" class="form-control" id="ruleid" value="" />
  160. <input type="text" name="keyword" class="form-control" id="keywordinput" value="" placeholder="可根据关键字直接关联指定的回复规则" autocomplete="off" />
  161. <div class="input-group-btn">
  162. <span class="btn btn-primary" id="keyword_search"><i class="fa fa-search"></i> 搜索</span>
  163. </div>
  164. </div>
  165. <div id="keyword_menu" style="width:100%;position:absolute;top:35px;left:16px;display:none;z-index:10000">
  166. <ul class="dropdown-menu" style="display:block;width:91%;height:400px;overflow-y:scroll;"></ul>
  167. </div>
  168. <div class="help-block">请选择"图文消息"关联关键字。</div>
  169. <div class="help-block">发送图文消息仅支持关联已添加的图文关键字</div>
  170. </div>
  171. </div>
  172. </form>
  173. <div class="form-group">
  174. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  175. <div class="col-sm-10">
  176. <input type="submit" class="btn btn-primary" name="submit" value="立即发送" id="submit"/>
  177. <input type="hidden" name="token" value="{$_W['token']}" />
  178. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  179. <a href="{php echo url('mc/notice/end', array('fanid' => $fanid, 'from' => base64_encode($_SERVER['HTTP_REFERER'])))}" class="btn btn-danger">关闭</a>
  180. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  181. <a href="{$_SERVER['HTTP_REFERER']}" class="btn btn-default">返回</a>
  182. </div>
  183. </div>
  184. </div>
  185. </div>
  186. </div>
  187. <script>
  188. function ajax_chats_log() {
  189. var id = $('#last').attr('data-id');
  190. var fanid = "{$fanid}";
  191. $.post("{php echo url('mc/notice/log')}", {'id' : id, 'fanid' : fanid, 'type' : 'asc'}, function(data) {
  192. data = $.parseJSON(data);
  193. if(data.code == 1) {
  194. $('#last').attr('data-id', data.id);
  195. $('#last').append(data.str);
  196. $('#log').scrollTop(100000000000);
  197. }
  198. setTimeout(ajax_chats_log, 3000);
  199. });
  200. }
  201. ajax_chats_log();
  202. $('#more').click(function(){
  203. var oldhtml = $(this).html();
  204. $(this).html('<i class="fa fa-spinner"></i> 加载中');
  205. var id = $('#prev').attr('data-id');
  206. var fanid = "{$fanid}";
  207. $.post("{php echo url('mc/notice/log')}", {'id' : id, 'fanid' : fanid, 'type' : 'desc'}, function(data) {
  208. data = $.parseJSON(data);
  209. if(data.code == 1) {
  210. $('#more').html(oldhtml);
  211. $('#prev').attr('data-id', data.id);
  212. $('#position').after(data.str);
  213. $('#log').scrollTop(-100);
  214. } else {
  215. $('#more').html('<i class="fa fa-info-circle"></i> 已加载全部');
  216. }
  217. });
  218. });
  219. util.emotion($("#content"), $("#contentinput")[0]);
  220. function select_keyword(clickid, menuid, inputid, ruleid){
  221. $(clickid).click(function(){
  222. var search_value = $(inputid).val();
  223. $('body').append('<div class="layer_bg"></div>');
  224. $('.layer_bg').height($(document).height());
  225. $('.layer_bg').css({width : '100%', position : 'absolute', top : '0', left : '0', 'z-index' : '0'});
  226. $.post("{php echo url('mc/notice/keyword')}", {'key_word' : search_value}, function(data){
  227. var data = $.parseJSON(data);
  228. var total = data.length;
  229. var html = '';
  230. if(total > 0) {
  231. for(var i = 0; i < total; i++) {
  232. html += '<li><a href="javascript:;" id="'+ data[i]['rid'] +'">' + data[i]['content'] + '</a></li>';
  233. }
  234. } else {
  235. html += '<li><a href="javascript:;" class="no-result">没有匹配到您输入的关键字</a></li>';
  236. }
  237. $(menuid + ' ul').html(html);
  238. $(menuid + ' ul li a[class!="no-result"]').click(function(){
  239. $('.layer_bg').remove();
  240. $(inputid).val($(this).html());
  241. $(ruleid).val($(this).attr('id'));
  242. $(menuid).hide();
  243. });
  244. $(menuid).show();
  245. });
  246. $('.layer_bg').click(function(){
  247. $(menuid).hide();
  248. $(this).remove();
  249. });
  250. });
  251. $(inputid).keydown(function(event){
  252. if(event.keyCode == 13){
  253. $(clickid).click();
  254. return false;
  255. }
  256. });
  257. }
  258. select_keyword('#keyword_search', '#keyword_menu', '#keywordinput', '#ruleid');
  259. $('#form0 :radio').click(function(){
  260. $('.reply').hide();
  261. var msgtype = $('#form0 :radio:checked').val();
  262. $('#form' + msgtype).show();
  263. });
  264. $('#submit').click(function(){
  265. var openid = $(':hidden[name="openid"]').val();
  266. if(!openid) {
  267. util.message('粉丝openid丢失', '', 'error');
  268. return;
  269. }
  270. var params = {
  271. 'openid' : openid
  272. };
  273. var msgtype = $('#form0 :radio:checked').val();
  274. if(msgtype == '7') {
  275. var content = $('#form7 textarea[name="content"]').val();
  276. if(!content) {
  277. util.message('请完善消息内容', '', 'error');
  278. return;
  279. }
  280. params.content = content;
  281. params.msgtype = 'text';
  282. } else if (msgtype == '2') {
  283. var media_id = $('#form2 :text[name="media_id"]').val();
  284. if(!media_id) {
  285. util.message('请上传图片', '', 'error');
  286. return;
  287. }
  288. params.media_id = media_id;
  289. params.msgtype = 'image';
  290. } else if (msgtype == '3') {
  291. var media_id = $('#form3 :text[name="media_id"]').val();
  292. if(!media_id) {
  293. util.message('请上传语音消息', '', 'error');
  294. return;
  295. }
  296. params.media_id = media_id;
  297. params.msgtype = 'voice';
  298. } else if (msgtype == '4') {
  299. var media_id = $('#form4 :text[name="media_id"]').val();
  300. var thumb_media_id = $('#form4 :text[name="thumb_media_id"]').val();
  301. if(!thumb_media_id) {
  302. util.message('请上传媒体缩略图', '', 'error');
  303. return;
  304. }
  305. if(!media_id) {
  306. util.message('请上传视频消息', '', 'error');
  307. return;
  308. }
  309. params.msgtype = 'video';
  310. params.media_id = media_id;
  311. params.thumb_media_id = thumb_media_id;
  312. params.title = $('#form4 :text[name="title"]').val();
  313. params.description = $('#form1 textarea[name="description"]').val();
  314. } else if (msgtype == '5') {
  315. var thumb_media_id = $('#form5 :text[name="thumb_media_id"]').val();
  316. var musicurl = $('#form5 :text[name="musicurl"]').val();
  317. var hqmusicurl = $('#form5 :text[name="hqmusicurl"]').val();
  318. if(!thumb_media_id) {
  319. util.message('请上传媒体缩略图', '', 'error');
  320. return;
  321. }
  322. if(!musicurl) {
  323. util.message('请上传音频文件或填写音频链接', '', 'error');
  324. return;
  325. }
  326. params.msgtype = 'music';
  327. params.thumb_media_id = thumb_media_id;
  328. params.musicurl = musicurl;
  329. params.hqmusicurl = hqmusicurl;
  330. params.title = $('#form4 :text[name="title"]').val();
  331. params.description = $('#form1 textarea[name="description"]').val();
  332. } else if (msgtype == '6') {
  333. var ruleid = $('#ruleid').val();
  334. var keyword = $('#keywordinput').val();
  335. if(!ruleid || !keyword) {
  336. util.message('选择图文消息关联的关键字', '', 'error');
  337. return;
  338. }
  339. params.msgtype = 'news';
  340. params.keyword = keyword;
  341. params.ruleid = ruleid;
  342. }
  343. var url = "{php echo url('mc/notice/post')}";
  344. $.post(url, params, function(data){
  345. try{data = $.parseJSON(data);}catch (e) {eval(data);}
  346. if(data.type) {
  347. util.message(data.message, '', 'error');
  348. return;
  349. }
  350. if(data.status == 'error') {
  351. util.message(data.message, '', 'error');
  352. return;
  353. } else if(data.status == 'success') {
  354. $("input:text").val('');
  355. $("textarea").val('');
  356. $('.input-group img').attr('src', './resource/images/nopic.jpg');
  357. //util.message(data.message, '', 'success');
  358. return;
  359. }
  360. });
  361. return;
  362. });
  363. </script>
  364. {template 'common/footer'}