人人商城

post.html 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. {template 'common/header-gw'}
  2. {template 'extension/service-tabs'}
  3. <div class="main">
  4. <form class="form-horizontal form" action="" method="post" enctype="multipart/form-data" onsubmit="return formcheck(this)">
  5. <h5 class="page-header">添加服务 <small>服务是最常用的一类回复, 如天气预报, 笑话, 百科, 翻译等简单功能</small></h5>
  6. <div class="form-group">
  7. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">服务名称</label>
  8. <div class="col-sm-10 col-xs-12">
  9. <input type="text" class="form-control" placeholder="" name="service" value="{$rule['rule']['name']}">
  10. </div>
  11. </div>
  12. <div class="form-group">
  13. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">功能介绍</label>
  14. <div class="col-sm-10 col-xs-12">
  15. <input type="text" class="form-control" placeholder="" name="description" value="{php echo htmlspecialchars($row['description']);}"/>
  16. </div>
  17. </div>
  18. <div class="form-group">
  19. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>
  20. <div class="col-sm-10 col-xs-12">
  21. <label for="status_1" class="radio-inline"><input type="radio" name="status" id="status_1" value="1" {if $rule['rule']['status'] == 1 || empty($rule['rule']['status'])} checked="checked"{/if} /> 启用</label>
  22. <label for="status_0" class="radio-inline"><input type="radio" name="status" id="status_0" value="0" {if !empty($rule) && $rule['rule']['status'] == 0} checked="checked"{/if} /> 禁用</label>
  23. </div>
  24. </div>
  25. <div class="form-group">
  26. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">触发关键字</label>
  27. <div class="col-sm-10 col-xs-12">
  28. <input type="text" class="form-control" placeholder="" name="keywords" value="{$rule['keywords']}" /> &nbsp;
  29. <label for="adv-keyword" class="checkbox-inline">
  30. <input type="checkbox" id="adv-keyword" /> 高级触发
  31. </label>
  32. <span class="help-block">当用户的对话内容符合以上的关键字定义时,会触发这个回复定义。多个关键字请使用逗号隔开。</span>
  33. </div>
  34. </div>
  35. <div class="form-group">
  36. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">回复</label>
  37. <div class="col-sm-10 col-xs-12">
  38. <div class="alert alert-warning">
  39. <div><span style="display:inline-block; width:150px; font-weight:600;">[from]</span>粉丝用户的OpenID</div>
  40. <div><span style="display:inline-block; width:150px; font-weight:600;">[to]</span>当前公众号的OpenID</div>
  41. <div><span style="display:inline-block; width:150px; font-weight:600;">[rule]</span>当前回复的回复编号</div>
  42. </div>
  43. <span class="help-block" style="margin:5px 0;">可在回复内容的任何地方使用预定义标记来表示特定内容</span>
  44. <div id="module-form">
  45. <div class="alert alert-info">
  46. <a class="close" data-dismiss="alert">×</a>
  47. <h5 class="alert-heading">添加处理接口</h5>
  48. <div class="form-group">
  49. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">接口类型:</label>
  50. <div class="col-sm-10 col-xs-12">
  51. <label for="radio_1" class="radio-inline"><input type="radio" name="type" id="radio_1" onclick="$('#remote').show();$('#location').hide();" value="1" {if strexists($row['apiurl'], 'http://')} checked="checked"{/if} /> 远程地址</label>
  52. <label for="radio_0" class="radio-inline"><input type="radio" name="type" id="radio_0" onclick="$('#remote').hide();$('#location').show();" value="0" {if !strexists($row['apiurl'], 'http://')} checked="checked"{/if} /> 本地文件</label>
  53. </div>
  54. </div>
  55. <div id="remote" {if !strexists($row['apiurl'], 'http://')}style="display:none;"{/if}>
  56. <div class="form-group">
  57. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">远程地址:</label>
  58. <div class="col-sm-10 col-xs-12">
  59. <input type="text" id="" class="form-control" placeholder="" name="apiurl" value="{$row['apiurl']}">
  60. <div class="help-block" style="margin-top:10px;">
  61. <ol style="margin-top:10px;">
  62. <li>使用远程地址接口,你可以兼容其他的微信公众平台管理工具。</li>
  63. <li>你应该填写其他平台提供给你保存至公众平台的URL和Token</li>
  64. <li>添加此模块的规则后,只针对于单个规则定义有效,如果需要全部路由给接口处理,则修改该模块的优先级顺序。</li>
  65. <li>具体请<a href="http://www.we7.cc/docs/#api" target="_blank">查看“自定义接口回复”文档</a></li>
  66. </ol>
  67. </div>
  68. </div>
  69. </div>
  70. <div class="form-group">
  71. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label" style="color:red">Token:</label>
  72. <div class="col-sm-10 col-xs-12">
  73. <input type="text" name="wetoken" class="form-control" value="{$row['token']}" />
  74. <div class="help-block">与目标平台接入设置值一致,必须为英文或者数字,长度为3到32个字符.</div>
  75. </div>
  76. </div>
  77. </div>
  78. <div id="location" {if strexists($row['apiurl'], 'http://')} style="display:none;"{/if}>
  79. <div class="form-group">
  80. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">文件列表:</label>
  81. <div class="col-sm-10 col-xs-12">
  82. <select name="apilocal" class="form-control">
  83. <option value="0">请选择本地文件</option>
  84. {loop $apis $file}
  85. <option {if $row['apilocal'] == $file} selected="selected"{/if} value="{$file}">{$file}</option>
  86. {/loop}
  87. </select>
  88. <div class="help-block" style="margin-top:10px;">
  89. <ol style="margin-top:10px;">
  90. <li>使用本地文件扩展你可以快速的扩展微擎功能。</li>
  91. <li>添加此模块的规则后,只针对于单个规则定义有效,如果需要全部路由给接口处理,则修改该模块的优先级顺序。</li>
  92. <li>本地文件存放在模块文件夹内(/source/modules/userapi/api)下。</li>
  93. <li>具体请<a href="http://www.we7.cc/docs/#api" target="_blank">查看“自定义接口回复”文档</a></li>
  94. </ol>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. <div class="form-group">
  100. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">默认回复文字</label>
  101. <div class="col-sm-10 col-xs-12">
  102. <input type="text" id="" class="form-control" placeholder="" name="default-text" value="{$row['default_text']}">
  103. <div class="help-block">当接口无回复时,则返回用户此处设置的文字信息,优先级高于“默认回复URL”</div>
  104. </div>
  105. </div>
  106. <div class="form-group">
  107. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">缓存时间</label>
  108. <div class="col-sm-10 col-xs-12">
  109. <input type="text" id="" class="form-control" placeholder="" name="cachetime" value="{$row['cachetime']}">
  110. <div class="help-block">接口返回数据将缓存在微擎系统中的时限,默认为0不缓存。</div> </div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. <div class="form-group">
  117. <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
  118. <div class="col-sm-10">
  119. <input name="submit" type="submit" value="提交" class="btn btn-primary span3" />
  120. <input type="hidden" name="token" value="{$_W['token']}" />
  121. </div>
  122. </div>
  123. <table class="tb">
  124. <tr class="hide adv-keyword">
  125. <th><label for="">高级触发规则</label></th>
  126. <td>
  127. <div class="keyword-list list" id="keyword-list">
  128. {loop $rule[keyword] $item}
  129. {if $item['type'] != '1'}
  130. <div class="item" id="keyword-item-{$item['id']}">
  131. {template 'rule/item'}
  132. </div>
  133. {/if}
  134. {/loop}
  135. </div>
  136. <a href="javascript:;" onclick="keywordHandler.buildForm()" class="add-kw-button"><i class="icon-plus"></i> 添加关键字</a>
  137. </td>
  138. </tr>
  139. </table>
  140. </form>
  141. </div>
  142. <script type="text/html" id="keyword-item-html">
  143. {php unset($item); include template('rule/item', TEMPLATE_INCLUDEPATH);}
  144. </script>
  145. <script type="text/javascript">
  146. <!--
  147. $(function(){
  148. $('#adv-setting').click(function(){
  149. if(this.checked) {
  150. $('.adv-setting').show();
  151. } else {
  152. $('.adv-setting').hide();
  153. }
  154. });
  155. $('#adv-keyword').click(function(){
  156. if(this.checked) {
  157. $('.adv-keyword').show();
  158. } else {
  159. $('.adv-keyword').hide();
  160. }
  161. });
  162. {if $rule['kwd-adv']}
  163. $('#adv-keyword').attr('checked', 'checked');
  164. $('.adv-keyword').show();
  165. {/if}
  166. });
  167. var keywordHandler = {
  168. 'buildForm' : function() {
  169. var obj = buildAddForm('keyword-item-html', $('#keyword-list'));
  170. obj.find('.btn-group .btn').on('click', function(){
  171. $(this).parent().next().html($(this).attr('description'));
  172. obj.find('#keyword-type-new').val($(this).attr('value'));
  173. });
  174. obj.find('#form').show();
  175. obj.find('#show').hide();
  176. },
  177. 'doAdd' : function(itemid) {
  178. var parent = $('#' + itemid);
  179. if ($('.keyword-name-new', parent).val() == '' && $('.keyword-type-new', parent).val() != 4) {
  180. message('请输入关键字!', '', 'error');
  181. return false;
  182. }
  183. if($('.keyword-type-new', parent).val() == 4) {
  184. $('.keyword-name-new', parent).val('');
  185. }
  186. var typetips = $('.active', parent).html();
  187. $('#show #type', parent).html(typetips);
  188. $('#show #content', parent).html($('.keyword-name-new', parent).val());
  189. $('#show', parent).css('display', 'block');
  190. $('#form', parent).css('display', 'none');
  191. },
  192. 'doEditItem' : function(itemid) {
  193. $('#keyword-list .item').each(function(){
  194. $('#form', $(this)).css('display', 'none');
  195. $('#show', $(this)).css('display', 'block');
  196. });
  197. doEditItem(itemid);
  198. }
  199. };
  200. function buildModuleForm(module) {
  201. try {
  202. $.ajax({
  203. url: "{php echo url('member/module', array('do' => 'form', 'id' => $rule['rule'][id]))}",
  204. type: "GET",
  205. data: {'name' : module.toLowerCase()},
  206. dataType: "html"
  207. }).done(function(s) {
  208. if (s && s.indexOf('"type":"error"') >= 0) {
  209. message('请重新选择公众号!', '{php echo url('rule/post')}', 'error');
  210. return false;
  211. }
  212. formCheckers = [];
  213. $('#module-form').html(s);
  214. });
  215. }
  216. catch (e) {
  217. }
  218. }
  219. function formcheck(form) {
  220. if (form['name'].value == '') {
  221. message('抱歉,规则名称为必填项,请返回修改!', '', 'error');
  222. return false;
  223. }
  224. if ($(':text[name="keywords"]').val() == '' && $('.keyword-name-new').val() == '' && $('.keyword-type-new').val() != 4) {
  225. message('抱歉,您至少要设置一个触发关键字!', '', 'error');
  226. return false;
  227. }
  228. $(':text[name="keywords"]').val($(':text[name="keywords"]').val().replace(/,/g, ','));
  229. return true;
  230. }
  231. {if empty($rid)}
  232. $(function(){
  233. keywordHandler.buildForm();
  234. });
  235. {else}
  236. $('.btn-group .btn').on('click', function(){
  237. $(this).parent().next().html($(this).attr('description'));
  238. $(this).parent().parent().find('#keyword-type-new').val($(this).attr('value'));
  239. });
  240. {/if}
  241. //-->
  242. </script>
  243. {template 'common/footer-gw'}