config.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <style>
  2. #config-form table tr td {
  3. border: none;
  4. padding: 10px 8px;
  5. }
  6. #config-form div a.btn {
  7. color: #fff;
  8. text-decoration: none;
  9. }
  10. #config-form table.table-notice {
  11. margin: 0 -8px;
  12. width: 100%;
  13. }
  14. #config-form table.table-notice tr td {
  15. padding: 5px 8px;
  16. width: 50%;
  17. }
  18. #config-form table.table-notice tr td input:first-child {
  19. width: 100%;
  20. }
  21. </style>
  22. <!--@formatter:off-->
  23. {php}
  24. $groupList = [
  25. 'config'=>'icpbeian,gwabeian,sitelogo,notice,sitename,title,keywords,description,theme,domain,audittype,nlptype,aip_appid,aip_apikey,aip_secretkey,apikey,autolinks,cachelifetime,flagtype,freightitemfee',
  26. 'order'=>'order_timeout,order_refund_sync,auto_delivery_time,money_score,comment_score,sendnoticemode',
  27. 'express'=>'EBusinessID,kdNiaoApiKey,logisticstype,api_mode',
  28. 'rewrite'=>'domain,rewrite,urlsuffix,moduleurlsuffix',
  29. 'uniapp'=>'notice,wxapp,mobileurl,porfilePrompt,autoredirectmobile,wx_appid,wx_app_secret,mp_appid,mp_app_secret,app_id,app_secret,,logintypelist,wechatautocreate',
  30. 'other'=>'category_mode,phone,coupon_key',
  31. ];
  32. $group = [];
  33. foreach($groupList as $k=>$v){
  34. $item = explode(',', $v);
  35. $item = array_flip($item);
  36. $group = array_merge($group, array_map(function($value) use($k){return $k;}, $item));
  37. }
  38. $epayInfo = get_addon_info('epay');
  39. $thirdInfo = get_addon_info('third');
  40. $areaInfo = \app\admin\model\shop\Area::where('id', '>', 0)->find();
  41. function getArrayTitle($name){
  42. $titleArr = [
  43. 'rewrite'=>['控制器/方法', 'URL'],
  44. 'moduleurlsuffix'=>['模块', '后缀'],
  45. 'flagtype'=>['标识', '名称'],
  46. 'score'=>['模块', '积分'],
  47. 'limitscore'=>['模块', '积分'],
  48. ];
  49. return $titleArr[$name]??['键名', '键值'];
  50. }
  51. {/php}
  52. <form id="config-form" class="edit-form form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  53. <div class="alert {$addon.tips.extend|default='alert-info-light'}" style="margin-bottom:10px;">
  54. <a href="{:addon_url('shop/index/index')}" class="btn btn-warning" target="_blank"><i class="fa fa-home"></i> 商城首页</a>
  55. <a href="__PUBLIC__index/user/index" class="btn btn-info" target="_blank"><i class="fa fa-user"></i> 会员中心</a>
  56. <a href="shop/ajax/clearcache" class="btn btn-danger btn-ajax"><i class="fa fa-trash"></i> 清除简单商城缓存</a>
  57. </div>
  58. {php}{/php}
  59. {if !$epayInfo || !$epayInfo['state'] || !$thirdInfo || !$thirdInfo['state'] || !$areaInfo}
  60. <div class="alert alert-warning-light" style="margin-bottom:10px;">
  61. <b>温馨提示:</b><br>
  62. {if !$epayInfo || !$epayInfo['state']}
  63. <i class="fa fa-info-circle"></i> 未{:$epayInfo?'启用':'安装'}《微信支付宝整合》插件,<a href="javascript:" class="btn-addtabs" data-url="addon" title="插件插件">点击前往</a><br>
  64. {/if}
  65. {if !$thirdInfo || !$thirdInfo['state']}
  66. <i class="fa fa-info-circle"></i> 未{:$thirdInfo?'启用':'安装'}《第三方登录》插件,<a href="javascript:" class="btn-addtabs" data-url="addon" title="插件插件">点击前往</a><br>
  67. {/if}
  68. {if !$areaInfo}
  69. <i class="fa fa-info-circle"></i> 地区数据未导入,<a href="javascript:" class="btn-addtabs" data-url="shop/area" title="地区管理">点击前往</a><br>
  70. {/if}
  71. </div>
  72. {/if}
  73. <div class="panel panel-default panel-intro">
  74. <div class="panel-heading">
  75. <ul class="nav nav-tabs nav-group">
  76. <li class="active"><a href="#all" data-toggle="tab">全部</a></li>
  77. <li><a href="#config" data-toggle="tab">基础配置</a></li>
  78. <li><a href="#order" data-toggle="tab">订单配置</a></li>
  79. <li><a href="#express" data-toggle="tab">快递配置</a></li>
  80. <li><a href="#rewrite" data-toggle="tab">伪静态</a></li>
  81. <li><a href="#uniapp" data-toggle="tab">Uniapp</a></li>
  82. <li><a href="#other" data-toggle="tab">其它</a></li>
  83. <li class="pull-right"><a href="{:url('shop.ajax/config?name=signin')}" title="签到配置" class="dialogit">签到配置</a></li>
  84. <li class="pull-right"><a href="{:url('shop.ajax/config?name=sms')}" title="短信配置" class="dialogit">短信配置</a></li>
  85. <li class="pull-right"><a href="{:url('shop.ajax/config?name=third')}" title="登录配置" class="dialogit">登录配置</a></li>
  86. <li class="pull-right"><a href="{:url('shop.ajax/config?name=oss')}" title="云存储配置" class="dialogit">云存储配置</a></li>
  87. <li class="pull-right"><a href="{:url('shop.ajax/config?name=epay')}" title="支付配置" class="dialogit">支付配置</a></li>
  88. </ul>
  89. </div>
  90. <div class="panel-body">
  91. <div id="myTabContent" class="tab-content">
  92. <div class="tab-pane fade active in" id="one">
  93. <!--@formatter:off-->
  94. <table class="table table-config">
  95. <tbody>
  96. {foreach $addon.config as $item}
  97. <tr data-type="{:isset($group[$item['name']])?$group[$item['name']]:'other'}">
  98. <td width="15%">
  99. {$item.title|htmlentities}
  100. {if $item.type=='array' && $item.tip}
  101. <a href="javascript:" class="text-info" data-toggle="popover" data-content="{$item.tip|htmlentities}" data-trigger="click" data-title="配置提示" data-html="true"><i class="fa fa-info-circle"></i></a>
  102. {/if}
  103. </td>
  104. <td>
  105. <div class="row">
  106. <div class="col-sm-8 col-xs-12">
  107. {switch $item.type}
  108. {case string}
  109. <input type="text" name="row[{$item.name|htmlentities}]" value="{$item.value|htmlentities}" class="form-control" data-rule="{$item.rule|htmlentities}" data-tip="{$item.tip|htmlentities}"/>
  110. {/case}
  111. {case text}
  112. <textarea name="row[{$item.name|htmlentities}]" class="form-control" data-rule="{$item.rule|htmlentities}" rows="5" data-tip="{$item.tip|htmlentities}">{$item.value|htmlentities}</textarea>
  113. {/case}
  114. {case array}
  115. {if $item.name == 'notice'}
  116. <table class="fieldlist table-notice" data-name="row[{$item.name|htmlentities}]"
  117. data-template="{$item.name|htmlentities}tpl" data-tag="tr">
  118. <tr data-type="{:isset($group[$item['name']])?$group[$item['name']]:'other'}">
  119. <td>标题</td>
  120. <td>路径</td>
  121. </tr>
  122. <tr data-type="{:isset($group[$item['name']])?$group[$item['name']]:'other'}">
  123. <td colspan="2">
  124. <a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a>
  125. <textarea name="row[{$item.name|htmlentities}]" cols="30" rows="5" class="hide">{$item.value|json_encode|htmlentities}</textarea>
  126. </td>
  127. </tr>
  128. </table>
  129. <script type="text/html" id="{$item.name|htmlentities}tpl">
  130. <tr class="form-inline" data-type="{:isset($group[$item['name']])?$group[$item['name']]:'other'}">
  131. <td>
  132. <input type="text" name="<%=name%>[<%=index%>][title]" class="form-control" value="<%=row?row['title']:''%>" size="60" />
  133. </td>
  134. <td>
  135. <div class="input-group">
  136. <input type="text" name="<%=name%>[<%=index%>][path]" class="form-control" value="<%=row?row['path']:''%>" />
  137. <div class="input-group-btn">
  138. <input type="button" value="选择" class="btn btn-info btn-select-page" style="width:50px;" />
  139. </div>
  140. </div>
  141. <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span>
  142. <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span>
  143. </td>
  144. </tr>
  145. </script>
  146. {else}
  147. <dl class="fieldlist" data-name="row[{$item.name|htmlentities}]">
  148. <dd>
  149. {php}list($arrayKeyTitle, $arrayValueTitle) = getArrayTitle($item['name']);{/php}
  150. <ins>{$arrayKeyTitle|htmlentities}</ins>
  151. <ins>{$arrayValueTitle|htmlentities}</ins>
  152. </dd>
  153. <dd>
  154. <a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a>
  155. {if $item.name=='moduleurlsuffix'}
  156. <a href="javascript:" class="btn btn-sm btn-warning btn-removerewrite" data-text="html">一键移除后缀中的html</a>
  157. {/if}
  158. {if $item.name=='rewrite'}
  159. <a href="javascript:" class="btn btn-sm btn-warning btn-removerewrite" data-text="/shop">一键移除URL中的/shop</a>
  160. {/if}
  161. </dd>
  162. <textarea name="row[{$item.name|htmlentities}]" cols="30" rows="5" class="hide">{$item.value|json_encode|htmlentities}</textarea>
  163. </dl>
  164. {/if}
  165. {/case}
  166. {case date}
  167. <input type="text" name="row[{$item.name|htmlentities}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-tip="{$item.tip|htmlentities}" data-rule="{$item.rule|htmlentities}"/>
  168. {/case}
  169. {case time}
  170. <input type="text" name="row[{$item.name|htmlentities}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="HH:mm:ss" data-tip="{$item.tip|htmlentities}" data-rule="{$item.rule|htmlentities}"/>
  171. {/case}
  172. {case datetime}
  173. <input type="text" name="row[{$item.name|htmlentities}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-tip="{$item.tip|htmlentities}" data-rule="{$item.rule|htmlentities}"/>
  174. {/case}
  175. {case number}
  176. <input type="number" name="row[{$item.name|htmlentities}]" value="{$item.value|htmlentities}" class="form-control" data-tip="{$item.tip|htmlentities}" data-rule="{$item.rule|htmlentities}"/>
  177. {/case}
  178. {case checkbox}
  179. {foreach name="item.content" item="vo"}
  180. <label for="row[{$item.name|htmlentities}][]-{$key|htmlentities}"><input id="row[{$item.name|htmlentities}][]-{$key|htmlentities}" name="row[{$item.name|htmlentities}][]" type="checkbox" value="{$key|htmlentities}" data-tip="{$item.tip|htmlentities}" {in name="key" value="$item.value" }checked{/in} /> {$vo|htmlentities}</label>
  181. {/foreach}
  182. {/case}
  183. {case radio}
  184. {foreach name="item.content" item="vo"}
  185. <label for="row[{$item.name|htmlentities}]-{$key|htmlentities}"><input id="row[{$item.name|htmlentities}]-{$key|htmlentities}" name="row[{$item.name|htmlentities}]" type="radio" value="{$key|htmlentities}" data-tip="{$item.tip|htmlentities}" {in name="key" value="$item.value" }checked{/in} /> {$vo|htmlentities}</label>
  186. {/foreach}
  187. {/case}
  188. {case value="select" break="0"}{/case}
  189. {case value="selects"}
  190. <select name="row[{$item.name|htmlentities}]{$item.type=='selects'?'[]':''}" class="form-control selectpicker" data-tip="{$item.tip|htmlentities}" {$item.type=='selects'?'multiple':''}>
  191. {foreach name="item.content" item="vo"}
  192. <option value="{$key|htmlentities}" {in name="key" value="$item.value" }selected{/in}>{$vo|htmlentities}</option>
  193. {/foreach}
  194. </select>
  195. {/case}
  196. {case value="image" break="0"}{/case}
  197. {case value="images"}
  198. <div class="form-inline">
  199. <input id="c-{$item.name|htmlentities}" class="form-control" size="35" name="row[{$item.name|htmlentities}]" type="text" value="{$item.value|htmlentities}" data-tip="{$item.tip|htmlentities}">
  200. <span><button type="button" id="faupload-{$item.name|htmlentities}" class="btn btn-danger faupload" data-input-id="c-{$item.name|htmlentities}" data-mimetype="image/*" data-multiple="{$item.type=='image'?'false':'true'}" data-preview-id="p-{$item.name|htmlentities}"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
  201. <span><button type="button" id="fachoose-{$item.name|htmlentities}" class="btn btn-primary fachoose" data-input-id="c-{$item.name|htmlentities}" data-mimetype="image/*" data-multiple="{$item.type=='image'?'false':'true'}"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
  202. <ul class="row list-inline faupload-preview" id="p-{$item.name|htmlentities}"></ul>
  203. </div>
  204. {/case}
  205. {case value="file" break="0"}{/case}
  206. {case value="files"}
  207. <div class="form-inline">
  208. <input id="c-{$item.name|htmlentities}" class="form-control" size="35" name="row[{$item.name|htmlentities}]" type="text" value="{$item.value|htmlentities}" data-tip="{$item.tip|htmlentities}">
  209. <span><button type="button" id="faupload-{$item.name|htmlentities}" class="btn btn-danger faupload" data-input-id="c-{$item.name|htmlentities}" data-multiple="{$item.type=='file'?'false':'true'}"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
  210. <span><button type="button" id="fachoose-{$item.name|htmlentities}" class="btn btn-primary fachoose" data-input-id="c-{$item.name|htmlentities}" data-multiple="{$item.type=='file'?'false':'true'}"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
  211. </div>
  212. {/case}
  213. {case value="gallery"}
  214. {php}$galleryImages = array_map(function($arr){return $arr['image'];}, (array)json_decode($item['value'], true));{/php}
  215. <div class="input-group">
  216. <input id="c-{$item.name|htmlentities}" data-rule="required" class="form-control gallery-control hidden" size="50" name="row[{$item.name|htmlentities}]" type="text" value="{$galleryImages|implode=',',###}">
  217. <div class="input-group-addon no-border no-padding pull-left">
  218. <span><button type="button" id="plupload-{$item.name|htmlentities}" class="btn btn-danger plupload" data-input-id="c-{$item.name|htmlentities}" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-{$item.name|htmlentities}"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
  219. <span><button type="button" id="fachoose-{$item.name|htmlentities}" class="btn btn-primary fachoose" data-input-id="c-{$item.name|htmlentities}" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
  220. </div>
  221. <span class="msg-box n-right" for="c-{$item.name|htmlentities}"></span>
  222. </div>
  223. <ul class="row list-inline plupload-preview" id="p-{$item.name|htmlentities}" data-template="{$item.name|htmlentities}tpl" data-name="row[{$item.name|htmlentities}]"></ul>
  224. <textarea name="row[{$item.name|htmlentities}]" class="form-control hidden" style="margin-top:5px;">{$item.value|htmlentities}</textarea>
  225. <script type="text/html" id="{$item.name|htmlentities}tpl">
  226. <li class="col-xs-4">
  227. <a href="<%=fullurl%>" data-url="<%=url%>" target="_blank" class="thumbnail">
  228. <img src="<%=fullurl%>" class="img-responsive">
  229. </a>
  230. <input type="hidden" name="row[{$item.name|htmlentities}][<%=index%>][image]" class="form-control" placeholder="" value="<%=fullurl%>"/>
  231. <input type="text" name="row[{$item.name|htmlentities}][<%=index%>][title]" class="form-control" placeholder="请输入标题" value="<%=value?value['title']:''%>"/>
  232. <div class="input-group" style="margin:5px 0;">
  233. <input type="text" name="row[{$item.name|htmlentities}][<%=index%>][path]" class="form-control" placeholder="请输入路径" value="<%=value?value['path']:''%>"/>
  234. <div class="input-group-btn">
  235. <input type="button" value="选择" class="btn btn-info btn-select-page" />
  236. </div>
  237. </div>
  238. <a href="javascript:;" class="btn btn-danger btn-xs btn-trash"><i class="fa fa-trash"></i></a>
  239. </li>
  240. </script>
  241. {/case}
  242. {case bool}
  243. <label for="row[{$item.name|htmlentities}]-yes"><input id="row[{$item.name|htmlentities}]-yes" name="row[{$item.name|htmlentities}]" type="radio" value="1" {$item.value?'checked':''} data-tip="{$item.tip|htmlentities}" /> {:__('Yes')}</label>
  244. <label for="row[{$item.name|htmlentities}]-no"><input id="row[{$item.name|htmlentities}]-no" name="row[{$item.name|htmlentities}]" type="radio" value="0" {$item.value?'':'checked'} data-tip="{$item.tip|htmlentities}" /> {:__('No')}</label>
  245. {/case}
  246. {case editor}
  247. <textarea name="row[{$item.name|htmlentities}]" class="form-control editor"
  248. data-rule="{$item.rule|htmlentities}" rows="5"
  249. data-tip="{$item.tip|htmlentities}">{$item.value|htmlentities}</textarea>
  250. {/case}
  251. {/switch}
  252. </div>
  253. <div class="col-sm-4"></div>
  254. </div>
  255. </td>
  256. </tr>
  257. {/foreach}
  258. </tbody>
  259. </table>
  260. <!--@formatter:on-->
  261. <div class="form-group layer-footer">
  262. <label class="control-label col-xs-12 col-sm-2"></label>
  263. <div class="col-xs-12 col-sm-8">
  264. <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
  265. <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  266. </div>
  267. </div>
  268. </div>
  269. </div>
  270. </div>
  271. </div>
  272. </form>
  273. <!--@formatter:off-->
  274. <script>
  275. require.callback = function () {
  276. var tabevent = function () {
  277. $(document).on("click", ".nav-group li a[data-toggle='tab']", function () {
  278. var type = $(this).attr("href").substring(1);
  279. if (type == 'all') {
  280. $(".table-config tr").show();
  281. } else {
  282. $(".table-config tr").hide();
  283. $(".table-config tr[data-type='" + type + "']").show();
  284. }
  285. });
  286. $(document).on("click", ".btn-select-page", function (e, obj) {
  287. var that = this;
  288. Fast.api.open("shop/ajax/get_page_list", "选择路径", {
  289. callback: function (data) {
  290. $(that).parent().prev().val(data).trigger("change");
  291. }
  292. })
  293. });
  294. $(document).on("keyup change", ".gallery-control", function(){
  295. $(this).parent().next().find("input:last").trigger("change");
  296. return false;
  297. });
  298. $(document).on("click", ".btn-removerewrite", function () {
  299. $("dd", $(this).closest("dl.fieldlist")).each(function () {
  300. });
  301. var reg = new RegExp($(this).data("text"));
  302. $(this).closest("dl.fieldlist").find("input[name$='[value]']").each(function () {
  303. $(this).val($(this).val().replace(reg, ''));
  304. });
  305. $(this).closest("dl.fieldlist").find("input[name$='[value]']:first").trigger("change");
  306. });
  307. };
  308. define('backend/addon', ['jquery', 'form'], function ($, Form) {
  309. var Controller = {
  310. config: function () {
  311. Form.api.bindevent($("form[role=form]"));
  312. tabevent();
  313. }
  314. };
  315. return Controller;
  316. });
  317. define('backend/shop/config', ['jquery', 'form'], function ($, Form) {
  318. var Controller = {
  319. index: function () {
  320. Form.api.bindevent($("form[role=form]"));
  321. tabevent();
  322. }
  323. };
  324. return Controller;
  325. });
  326. }
  327. </script>
  328. <!--@formatter:on-->