add.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <?php $shoname_name = D('Home/Front')->get_config_by_name('shoname'); ?>
  6. <title><?php echo $shoname; ?></title>
  7. <link rel="shortcut icon" href="" />
  8. <meta name="renderer" content="webkit">
  9. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  11. <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
  12. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  13. <!--[if lt IE 9]>
  14. <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  15. <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  16. <![endif]-->
  17. <link href="./resource/css/bootstrap.min.css?v=201903260001" rel="stylesheet">
  18. <link href="./resource/css/common.css?v=201903260001" rel="stylesheet">
  19. <script type="text/javascript">
  20. window.sysinfo = {
  21. <?php if (!empty($_W['uniacid']) ){ ?>'uniacid': '{$_W['uniacid']}',<?php } ?>
  22. <?php if( !empty($_W['acid']) ){ ?>'acid': '{$_W['acid']}',<?php } ?>
  23. <?php if (!empty($_W['openid']) ) { ?>'openid': '{$_W['openid']}',<?php } ?>
  24. <?php if( !empty($_W['uid']) ) { ?>'uid': '{$_W['uid']}',<?php } ?>
  25. 'isfounder': <?php if (!empty($_W['isfounder']) ) { ?>1<?php }else{ ?>0<?php } ?>,
  26. 'siteroot': '{$_W['siteroot']}',
  27. 'siteurl': '{$_W['siteurl']}',
  28. 'attachurl': '{$_W['attachurl']}',
  29. 'attachurl_local': '{$_W['attachurl_local']}',
  30. 'attachurl_remote': '{$_W['attachurl_remote']}',
  31. 'module': {'url' : '<?php if( defined('MODULE_URL') ) { ?>{MODULE_URL}<?php } ?>', 'name' : '<?php if (defined('IN_MODULE') ) { ?>{IN_MODULE}<?php } ?>'},
  32. 'cookie': {'pre': ''},
  33. 'account': {:json_encode($_W['account'])},
  34. };
  35. </script>
  36. <script type="text/javascript" src="./resource/js/lib/jquery-1.11.1.min.js"></script>
  37. <script type="text/javascript" src="./resource/js/lib/bootstrap.min.js"></script>
  38. <script type="text/javascript" src="./resource/js/app/util.js?v=201903260001"></script>
  39. <script type="text/javascript" src="./resource/js/app/common.min.js?v=201903260001"></script>
  40. <script type="text/javascript" src="./resource/js/require.js?v=201903260001"></script>
  41. <script type="text/javascript" src="./resource/js/lib/jquery.nice-select.js?v=201903260001"></script>
  42. <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
  43. <link href="/static/css/snailfish.css?v=20200909" rel="stylesheet">
  44. <style>
  45. .layui-form-selected dl{z-index: 1000;}
  46. </style>
  47. </head>
  48. <body layadmin-themealias="default">
  49. <div class="layui-fluid">
  50. <div class="layui-card">
  51. <div class="layui-card-header layui-elem-quote">当前位置:<span class="line-text"><?php if( !empty($item['id']) ){ ?>编辑<?php }else{ ?>添加<?php } ?>菜谱<?php if( !empty($item['id']) ){ ?>({$item['title']})<?php } ?></span></div>
  52. <div class="layui-card-body" style="padding:15px;">
  53. <form action="" method="post" class="layui-form" lay-filter="component-layui-form-item" enctype="multipart/form-data" >
  54. <input type="hidden" name="data[id]" value="{$item['id']}"/>
  55. <div class="layui-form-item">
  56. <label class="layui-form-label"><font color="red">*</font>菜谱名称</label>
  57. <div class="layui-input-block">
  58. <input type="text" id='recipe_name' name="data[recipe_name]" class="form-control" value="{$item['recipe_name']}" required lay-verify="required" >
  59. </div>
  60. </div>
  61. <div class="layui-form-item">
  62. <label class="layui-form-label">菜谱简介</label>
  63. <div class="layui-input-block">
  64. <textarea name="sub_name" id="sub_name" rows="5" class="form-control" data-parent=".sub_name" maxlength="100" data-rule-maxlength="100">{$item['sub_name']}</textarea>
  65. <div class="layui-form-mid layui-word-aux">介绍菜谱的卖点、特色,建议100个字以内</div>
  66. </div>
  67. </div>
  68. <div class="layui-form-item">
  69. <label class="layui-form-label must">* 菜谱主图</label>
  70. <div class="layui-input-block gimgs">
  71. <?php echo tpl_form_field_image2('data[images]',$item['images']); ?>
  72. <span class="layui-form-mid layui-word-aux image-block"></span>
  73. </div>
  74. </div>
  75. <div class="layui-form-item">
  76. <label class="layui-form-label must">菜谱视频</label>
  77. <div class="layui-input-block gimgs">
  78. <?php echo tpl_form_field_video('data[video]',$item['video'] );?>
  79. <span class="layui-form-mid layui-word-aux image-block">
  80. 请输入视频链接地址或者选择上传视频(支持抖音视频地址)<br/>
  81. 视频时长建议9-30秒,视频大小不超过30MB,建议宽高比例5:4,支持的视频格式MP4<br/>
  82. 当视频有填写,优先调用视频做为列表图。
  83. </span>
  84. </div>
  85. </div>
  86. <div class="layui-form-item">
  87. <label class="layui-form-label">启用</label>
  88. <div class="layui-input-block ">
  89. <input type="checkbox" id="state" lay-filter="state" lay-skin="primary" name="state" class="form-control valid" <?php if( empty($item) || $item['state'] ==1 ){ ?>checked<?php } ?> value="1" />
  90. </div>
  91. </div>
  92. <div class="layui-form-item">
  93. <label class="layui-form-label must">关联会员</label>
  94. <div class="layui-input-block">
  95. <div class="input-group " style="margin: 0;">
  96. <input type="text" disabled value="{$item['member_id']}" class="form-control valid" name="data[member_id]" placeholder="" id="member_id" >
  97. <span class="input-group-btn">
  98. <span data-input="#member_id" id="chose_member_id" class="btn btn-default">选择会员</span>
  99. </span>
  100. </div>
  101. <?php if( !empty($saler) ){ ?>
  102. <div class="input-group " style="margin: 0;">
  103. <div class="layadmin-text-center choose_user">
  104. <img style="" src="{$saler['avatar']}">
  105. <div class="layadmin-maillist-img" style="">{$saler['username']}</div>
  106. <button type="button" class="layui-btn layui-btn-sm" onclick="cancle_bind(this,'member_id')"><i class="layui-icon">&#xe640;</i></button>
  107. </div>
  108. </div>
  109. <?php } ?>
  110. </div>
  111. </div>
  112. <div class="layui-form-item">
  113. <label class="layui-form-label">菜谱分类</label>
  114. <div class="layui-input-block">
  115. <select id="cates" name='data[cate_id]' class="form-control select1" >
  116. <?php foreach($category as $c){ ?>
  117. <option value="{$c['id']}" <?php if( $c['id']==$item['cate_id'] ){ ?>selected<?php } ?> >{$c['name']}</option>
  118. <?php } ?>
  119. </select>
  120. </div>
  121. </div>
  122. <div class="layui-form-item">
  123. <label class="layui-form-label">菜谱时间</label>
  124. <div class="layui-input-block">
  125. <input type="text" id='make_time' name="data[make_time]" class="form-control" value="{$item['make_time']}" >
  126. </div>
  127. </div>
  128. <div class="layui-form-item">
  129. <label class="layui-form-label">菜谱难度</label>
  130. <div class="layui-input-block">
  131. <label class="radio-inline"><input type="radio" name="diff_type" value="1" <?php if( !isset($item['diff_type']) || $item['diff_type'] == 1 ){ ?>checked="true"<?php } ?> title="简单" /> </label>
  132. <label class="radio-inline"><input type="radio" name="diff_type" value="2" <?php if( isset($item['diff_type']) && $item['diff_type'] == 2 ){ ?>checked="true"<?php } ?> title="容易" /> </label>
  133. <label class="radio-inline"><input type="radio" name="diff_type" value="3" <?php if( isset($item['diff_type']) && $item['diff_type'] == 3 ){ ?>checked="true"<?php } ?> title="困难" /> </label>
  134. <div class="layui-form-mid layui-word-aux"></div>
  135. </div>
  136. </div>
  137. <div class="layui-form-item" >
  138. <label class="layui-form-label">全部食材</label>
  139. <div class="layui-input-block">
  140. <input name="button" type="button" class="btn btn-default" value="添加食材" onclick='addCaipu()'>
  141. </div>
  142. </div>
  143. <div id="caipu_div">
  144. <?php if(!empty($ing_list)){ ?>
  145. <?php foreach( $ing_list as $ing ){ ?>
  146. <div class="layui-form-item">
  147. <label class="layui-form-label">名称&nbsp;<i class="layui-icon" onclick="cans_this(this)" style="cursor: pointer;"></i></label>
  148. <div class="layui-input-block">
  149. <input type="text" name="" data-id="<?php echo $ing['id']; ?>" class="form-control make_time" value="<?php echo $ing['title']; ?>">
  150. </div>
  151. </div>
  152. <div class="layui-form-item">
  153. <label class="layui-form-label">商品</label>
  154. <div class="layui-input-block">
  155. <div class="input-group " style="margin: 0;">
  156. <input type="text" disabled="" value="" class="form-control valid" name="" placeholder="" id="agent_idr<?php echo $ing['id']; ?>">
  157. <span class="input-group-btn">
  158. <span data-input="#agent_idr<?php echo $ing['id']; ?>" class="btn btn-default agentid">选择商品</span>
  159. </span>
  160. </div>
  161. <?php foreach( $ing['limit_goods'] as $goods ){ ?>
  162. <div class="input-group mult_choose_goodsid" data-gid="{$goods['gid']}" style="border-radius: 0;float: left;margin: 10px;margin-left:0px;width: 22%;">
  163. <div class="layadmin-text-center choose_user">
  164. <img style="" src="{$goods['image']}">
  165. <div class="layadmin-maillist-img" style="">{$goods['goodsname']}</div>
  166. <button type="button" class="layui-btn layui-btn-sm" onclick="cancle_bind(this)"><i class="layui-icon"></i></button>
  167. <div class="goods_tip">
  168. <?php if($goods['is_finished'] == 1){ ?>
  169. <span>[已结束]&nbsp;</span>
  170. <?php } ?>
  171. <?php if($goods['is_grab'] == 1){ ?>
  172. <span>[已抢光]</span>
  173. <?php } ?>
  174. <?php if($goods['grounding'] == 0){ ?>
  175. <span>[已下架]</span>
  176. <?php } else if($goods['grounding'] == 3){ ?>
  177. <span>[已删除]</span>
  178. <?php } ?>
  179. </div>
  180. </div>
  181. </div>
  182. <?php } ?>
  183. </div>
  184. </div>
  185. <?php } ?>
  186. <?php } ?>
  187. </div>
  188. <div class="layui-form-item">
  189. <label class="layui-form-label">菜谱详情/步骤</label>
  190. <div class="layui-input-block">
  191. {:tpl_ueditor('data[content]',$item['content'],array('height'=>'300'))}
  192. </div>
  193. </div>
  194. <div class="layui-form-item">
  195. <label class="layui-form-label"> </label>
  196. <div class="layui-input-block">
  197. <input type="submit" value="提交" lay-submit lay-filter="formDemo" class="btn btn-primary" />
  198. </div>
  199. </div>
  200. </form>
  201. </div>
  202. </div>
  203. </div>
  204. <script src="/layuiadmin/layui/layui.js"></script>
  205. <script>
  206. layui.config({
  207. base: '/layuiadmin/' //静态资源所在路径
  208. }).extend({
  209. index: 'lib/index' //主入口模块
  210. }).use('index');
  211. </script>
  212. <script>
  213. var rant=0;
  214. var layer = layui.layer;
  215. var $;
  216. var cur_open_div;
  217. layui.use(['jquery', 'layer','form'], function(){
  218. $ = layui.$;
  219. var form = layui.form;
  220. form.on('radio(linktype)', function(data){
  221. if (data.value == 2) {
  222. $('#typeGroup').show();
  223. } else {
  224. $('#typeGroup').hide();
  225. }
  226. });
  227. $('#chose_member_id').click(function(){
  228. cur_open_div = $(this).attr('data-input');
  229. $.post("{:U('user/zhenquery', array('limit' => 0))}", {}, function(shtml){
  230. layer.open({
  231. type: 1,
  232. area: '930px',
  233. content: shtml //注意,如果str是object,那么需要字符拼接。
  234. });
  235. });
  236. })
  237. $('#chose_agent_id2').click(function(){
  238. cur_open_div = $(this).attr('data-input');
  239. $.post("{:U('goods/query_normal', array('template' => 'mult','is_recipe' => 1, 'unselect_goodsid' => $id))}", {}, function(shtml){
  240. layer.open({
  241. type: 1,
  242. area: '930px',
  243. content: shtml //注意,如果str是object,那么需要字符拼接。
  244. });
  245. });
  246. })
  247. $(document).delegate(".agentid","click",function(){
  248. cur_open_div = $(this).attr('data-input');
  249. $.post("{:U('goods/query_normal', array('template' => 'mult', 'unselect_goodsid' => $id))}", {}, function(shtml){
  250. layer.open({
  251. type: 1,
  252. area: '930px',
  253. content: shtml //注意,如果str是object,那么需要字符拼接。
  254. });
  255. });
  256. });
  257. $('.agent_id').click(function(){
  258. cur_open_div = $(this).attr('data-input');
  259. $.post("{:U('goods/query_normal', array('template' => 'mult', 'is_recipe' => 1, 'unselect_goodsid' => $id))}", {}, function(shtml){
  260. layer.open({
  261. type: 1,
  262. area: '930px',
  263. content: shtml //注意,如果str是object,那么需要字符拼接。
  264. });
  265. });
  266. })
  267. $('#chose_link').click(function(){
  268. cur_open_div = $(this).attr('data-input');
  269. $.post("{:U('util/selecturl', array('ok' => 1))}", {}, function(shtml){
  270. layer.open({
  271. type: 1,
  272. area: '930px',
  273. content: shtml //注意,如果str是object,那么需要字符拼接。
  274. });
  275. });
  276. })
  277. form.verify({
  278. title: [
  279. /^[\S]{1,}$/,'标题不能为空'
  280. ]
  281. });
  282. //监听提交
  283. form.on('submit(formDemo)', function(data){
  284. var gd_ar = [];
  285. //data-id="0"
  286. var s_flag = true;
  287. $('.make_time').each(function(){
  288. var need_obj = {};
  289. var obj = $(this);
  290. var cai_name = $(obj).val();
  291. var car_id = $(obj).attr('data-id');
  292. if( cai_name == '' )
  293. {
  294. s_flag = false;
  295. }
  296. var s_parent = $(obj).parent().parent();
  297. var s_next_obj = $(s_parent).next();
  298. var gd_obj = $(s_next_obj).children('.layui-input-block').children('.mult_choose_goodsid');
  299. var gd_arr = [];
  300. $(gd_obj).each(function(){
  301. gd_arr.push( $(this).attr('data-gid') );
  302. })
  303. need_obj.id = car_id;
  304. need_obj.cai_name = cai_name;
  305. need_obj.goods_ids = gd_arr;
  306. gd_ar.push( need_obj );
  307. })
  308. if( !s_flag )
  309. {
  310. layer.msg('请填写食材名称');
  311. return false;
  312. }
  313. data.field.limit_goods_list = gd_ar;
  314. $.ajax({
  315. url: data.form.action,
  316. type: data.form.method,
  317. data: data.field,
  318. dataType:'json',
  319. success: function (info) {
  320. if(info.status == 0)
  321. {
  322. layer.msg(info.result.message,{icon: 1,time: 2000});
  323. }else if(info.status == 1){
  324. var go_url = location.href;
  325. if( info.result.hasOwnProperty("url") )
  326. {
  327. go_url = info.result.url;
  328. }
  329. layer.msg('操作成功',{time: 1000,
  330. end:function(){
  331. var backurl = "{:U('recipe/index',array('ok'=>'1'))}";
  332. location.href = backurl;
  333. // location.href = info.result.url;
  334. }
  335. });
  336. }
  337. }
  338. });
  339. return false;
  340. });
  341. })
  342. function cans_this( obj )
  343. {
  344. var par_obj = $(obj).parent().parent();
  345. $(par_obj).next().remove();
  346. $(par_obj).remove();
  347. }
  348. function addCaipu()
  349. {
  350. rant++;
  351. var s_html = '';
  352. s_html +='<div class="layui-form-item">';
  353. s_html +=' <label class="layui-form-label">名称';
  354. s_html +='&nbsp;<i class="layui-icon" onclick="cans_this(this)" style="cursor: pointer;"></i>';
  355. s_html +='</label>';
  356. s_html +=' <div class="layui-input-block">';
  357. s_html +=' <input type="text" name="" data-id="0" class="form-control make_time" value="" >';
  358. s_html +=' </div>';
  359. s_html +='</div>';
  360. s_html +='<div class="layui-form-item">';
  361. s_html +=' <label class="layui-form-label">商品</label>';
  362. s_html +=' <div class="layui-input-block">';
  363. s_html +=' <div class="input-group " style="margin: 0;">';
  364. s_html +=' <input type="text" disabled value="" class="form-control valid" name="" placeholder="" id="agent_id'+rant+'">';
  365. s_html +=' <span class="input-group-btn">';
  366. s_html +=' <span data-input="#agent_id'+rant+'" class="btn btn-default agentid">选择商品</span>';
  367. s_html +=' </span>';
  368. s_html +=' </div>';
  369. s_html +=' </div>';
  370. s_html +='</div>';
  371. $('#caipu_div').append(s_html);
  372. }
  373. function addsp(){
  374. }
  375. $(function(){
  376. $(document).delegate('.btn-del','click',function(){
  377. var $btntr = $(this).parents('tr');
  378. $btntr.remove();
  379. })
  380. });
  381. function cancle_bind(obj,sdiv)
  382. {
  383. $('#'+sdiv).val('');
  384. $(obj).parent().parent().remove();
  385. }
  386. </script>
  387. </body>
  388. </html>