create.htm 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. {include file="public/layout" /}
  2. <body class="bodystyle">
  3. <div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
  4. <div id="append_parent"></div>
  5. <div id="ajaxwaitid"></div>
  6. <div class="page">
  7. <div class="fixed-bar">
  8. <div class="item-title"><a class="back" href="{:url("Weapp/index")}" title="返回列表"><i class="fa fa-chevron-left"></i></a>
  9. <div class="subject">
  10. <h3>插件应用</h3>
  11. <h5></h5>
  12. </div>
  13. <ul class="tab-base nc-row">
  14. {eq name="$Think.const.CONTROLLER_NAME.'@create'|is_check_access" value="1"}
  15. <li><a href="{:url("Weapp/create")}" class="tab {if condition="in_array($Request.action, array('create'))"}current{/if}"><span>创建插件</span></a></li>
  16. {/eq}
  17. {eq name="$Think.const.CONTROLLER_NAME.'@pack'|is_check_access" value="1"}
  18. <li><a href="{:url("Weapp/pack")}" class="tab {if condition="in_array($Request.action, array('pack'))"}current{/if}"><span>打包插件</span></a></li>
  19. {/eq}
  20. </ul>
  21. </div>
  22. </div>
  23. <form class="form-horizontal" id="post_form" action="{:url('Weapp/create')}" method="post">
  24. <div class="ncap-form-default">
  25. <dl class="row">
  26. <dt class="tit">
  27. <label for="code"><em>*</em>插件标识</label>
  28. </dt>
  29. <dd class="opt">
  30. <input type="text" name="code" placeholder="比如:Demo" id="code" class="input-txt">
  31. <span class="err"></span>
  32. <p class="notic"></p>
  33. <p class="">易优插件库中唯一的标识,首字母必须大写,只支持大小字母与数字。</p>
  34. </dd>
  35. </dl>
  36. <dl class="row">
  37. <dt class="tit">
  38. <label for="name"><em>*</em>插件名称</label>
  39. </dt>
  40. <dd class="opt">
  41. <input type="text" name="name" value="" id="name" class="input-txt">
  42. <span class="err"></span>
  43. <p class="notic"></p>
  44. </dd>
  45. </dl>
  46. <dl class="row">
  47. <dt class="tit">
  48. <label for="version">插件版本号</label>
  49. </dt>
  50. <dd class="opt">
  51. v1.0.0
  52. <input type="hidden" name="version" value="v1.0.0" id="version" class="input-txt">
  53. <span class="err"></span>
  54. <p class="notic"></p>
  55. </dd>
  56. </dl>
  57. <dl class="row">
  58. <dt class="tit">
  59. <label for="min_version">CMS版本号</label>
  60. </dt>
  61. <dd class="opt">
  62. {$min_version|default='v1.1.6'}
  63. <input type="hidden" name="min_version" value="{$min_version|default='v1.1.6'}" id="min_version" class="input-txt">
  64. <p class="notic"></p>
  65. </dd>
  66. </dl>
  67. <dl class="row">
  68. <dt class="tit">
  69. <label for="author"><em>*</em>开发者</label>
  70. </dt>
  71. <dd class="opt">
  72. <input type="text" name="author" value="" id="author" class="input-txt">
  73. <p class="notic"></p>
  74. </dd>
  75. </dl>
  76. <dl class="row">
  77. <dt class="tit">
  78. <label for="scene"><em>*</em>应用场景</label>
  79. </dt>
  80. <dd class="opt">
  81. <label><input type="radio" value="0" name="scene" checked="checked" />手机端+PC端</label>&nbsp;&nbsp;
  82. <label><input type="radio" value="1" name="scene" />手机端</label>&nbsp;&nbsp;
  83. <label><input type="radio" value="2" name="scene" />PC端</label>&nbsp;&nbsp;
  84. <p class="">在哪种场景展现,不指定的场景调用插件无效。</p>
  85. </dd>
  86. </dl>
  87. <dl class="row">
  88. <dt class="tit">
  89. <label for="description"><em>*</em>插件描述</label>
  90. </dt>
  91. <dd class="opt">
  92. <textarea rows="5" cols="80" id="description" name="description" style="height:80px;" placeholder=""></textarea>
  93. <p class="notic"></p>
  94. </dd>
  95. </dl>
  96. <div class="bot"><a href="JavaScript:void(0);" onclick="checkForm();" class="ncap-btn-big ncap-btn-green" id="submitBtn">初始化结构</a></div>
  97. </div>
  98. </form>
  99. </div>
  100. <script type="text/javascript">
  101. /**
  102. * 插件标识格式判断
  103. * @param str
  104. */
  105. function checkCode(str){
  106. var reg = /^[A-Z]([a-zA-Z0-9]*)$/;
  107. if(reg.test(str)){
  108. return true;
  109. }else{
  110. return false;
  111. }
  112. }
  113. /**
  114. * 版本号格式判断
  115. * @param str
  116. */
  117. function checkVersion(str){
  118. var reg = /^v\d+\.\d+\.\d+([0-9\.]*)$/i;
  119. if(reg.test(str)){
  120. return true;
  121. }else{
  122. return false;
  123. }
  124. }
  125. /**
  126. * 插件标识验证
  127. * @param str
  128. */
  129. function ajax_check_code()
  130. {
  131. var flag = false;
  132. var code = $.trim($('input[name=code]').val());
  133. var reg = /(^[a-zA-Z0-9]{1,}$)/;
  134. if (!reg.test(code)) {
  135. showErrorMsg('插件标识格式不正确!');
  136. $('input[name=code]').focus();
  137. return false;
  138. }
  139. if ('Sample' == code) {
  140. showErrorMsg('插件标识已被占用!');
  141. $('input[name=code]').focus();
  142. return false;
  143. }
  144. $.ajax({
  145. url: "{:url('Weapp/ajax_check_code', ['_ajax'=>1])}",
  146. type: 'GET',
  147. async: false,
  148. dataType: 'JSON',
  149. data: {code: code},
  150. success: function(res){
  151. console.log(res)
  152. if(res.code == 1){
  153. flag = true;
  154. } else {
  155. showErrorMsg(res.msg);
  156. $('input[name=code]').focus();
  157. }
  158. },
  159. error: function(e){}
  160. });
  161. return flag;
  162. }
  163. // 判断输入框是否为空
  164. function checkForm(){
  165. if(!checkCode($('input[name=code]').val())){
  166. showErrorMsg('插件标识格式不正确!');
  167. $('input[name=code]').focus();
  168. return false;
  169. }
  170. if(!ajax_check_code())
  171. {
  172. return false;
  173. }
  174. if($('input[name=name]').val() == ''){
  175. showErrorMsg('插件名称不能为空!');
  176. $('input[name=name]').focus();
  177. return false;
  178. }
  179. if(!checkVersion($('input[name=version]').val())){
  180. showErrorMsg('插件版本号格式不正确!');
  181. $('input[name=version]').focus();
  182. return false;
  183. }
  184. if(!checkVersion($('input[name=min_version]').val())){
  185. showErrorMsg('CMS最低版本号格式不正确!');
  186. $('input[name=min_version]').focus();
  187. return false;
  188. }
  189. if($('input[name=author]').val() == ''){
  190. showErrorMsg('开发者不能为空!');
  191. $('input[name=author]').focus();
  192. return false;
  193. }
  194. if($('input[name=scene]').val() == ''){
  195. showErrorMsg('应用场景不能为空!');
  196. $('input[name=scene]').focus();
  197. return false;
  198. }
  199. if($('#description').val() == ''){
  200. showErrorMsg('插件名称不能为空!');
  201. $('#description').focus();
  202. return false;
  203. }
  204. layer_loading('正在处理');
  205. $('#post_form').submit();
  206. }
  207. </script>
  208. {include file="public/footer" /}