goodsInfo.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/bootstrap-select/bootstrap-select.min.css" type="text/css" rel="stylesheet">
  4. <link href="/assets/custom/Plugin/bootstrap-switch/bootstrap-switch.min.css" type="text/css" rel="stylesheet">
  5. <link href="/assets/global/vendor/ascolorpicker/asColorPicker.min.css" type="text/css" rel="stylesheet">
  6. <link href="/assets/global/vendor/dropify/dropify.min.css" type="text/css" rel="stylesheet">
  7. <style type="text/css">
  8. .text-help {
  9. padding-left: 1.0715rem;
  10. }
  11. </style>
  12. @endsection
  13. @section('content')
  14. <div class="page-content container">
  15. <div class="panel panel-bordered">
  16. <div class="panel-heading">
  17. <h1 class="panel-title">
  18. <i class="icon wb-shopping-cart" aria-hidden="true"></i>
  19. @isset($goods) 编辑商品 @else 添加商品 @endisset
  20. </h1>
  21. <div class="panel-actions">
  22. <a href="{{url('/shop/goodsList')}}" class="btn btn-danger">返 回</a>
  23. </div>
  24. </div>
  25. @if (Session::has('successMsg'))
  26. <div class="alert alert-success alert-dismissible" role="alert">
  27. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  28. <span aria-hidden="true">×</span>
  29. </button>
  30. {{Session::get('successMsg')}}
  31. </div>
  32. @endif
  33. @if($errors->any())
  34. <div class="alert alert-danger alert-dismissible" role="alert">
  35. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  36. <span aria-hidden="true">×</span>
  37. </button>
  38. <strong>错误:</strong> {{$errors->first()}}
  39. </div>
  40. @endif
  41. <div class="panel-body">
  42. <form action=@isset($goods){{url('/shop/editGoods/'.$goods->id)}} @else {{url('/shop/addGoods')}} @endisset"" method="post" enctype="multipart/form-data" class="form-horizontal" role="form">
  43. {{csrf_field()}}
  44. <label>
  45. <input name="id" hidden/>
  46. </label>
  47. <div class="form-row">
  48. <div class="col-lg-6 col-md-12">
  49. <div class="form-group row">
  50. <label class="col-md-2 col-form-label">类型</label>
  51. <div class="col-md-10 d-flex align-items-center">
  52. <div class="radio-custom radio-primary radio-inline">
  53. <input type="radio" name="type" id="data_package" value="1"/>
  54. <label for="data_package">流量包</label>
  55. </div>
  56. <div class="radio-custom radio-primary radio-inline">
  57. <input type="radio" name="type" id="data_plan" value="2"/>
  58. <label for="data_plan">套餐</label>
  59. </div>
  60. </div>
  61. <span class="offset-md-2 text-help"> 套餐与账号有效期有关,流量包只扣可用流量,不影响有效期 </span>
  62. </div>
  63. <div class="form-group row">
  64. <label class="col-md-2 col-form-label" for="name">名称</label>
  65. <div class="col-md-4">
  66. <input type="text" class="form-control" name="name" id="name" required/>
  67. </div>
  68. </div>
  69. <div class="form-group row">
  70. <label class="col-md-2 col-form-label" for="price">售价</label>
  71. <div class="col-md-4 input-group">
  72. <input type="number" class="form-control" name="price" id="price" step="0.01" required/>
  73. <span class="input-group-text">元</span>
  74. </div>
  75. </div>
  76. <div class="form-group row">
  77. <label for="level" class="col-md-2 col-form-label">等级</label>
  78. <div class="col-md-4">
  79. <select data-plugin="selectpicker" data-style="btn-outline btn-primary" class="form-control" name="level" id="level">
  80. @foreach ($level_list as $level)
  81. <option value="{{$level->level}}">{{$level->name}}</option>
  82. @endforeach
  83. </select>
  84. </div>
  85. </div>
  86. <div class="form-group row package-renew">
  87. <label class="col-md-2 col-form-label" for="renew">流量重置价格</label>
  88. <div class="col-md-4 input-group">
  89. <input type="number" class="form-control" name="renew" id="renew" step="0.01" value="0"/>
  90. <span class="input-group-text">元</span>
  91. </div>
  92. </div>
  93. <div class="form-group row package-renew">
  94. <label class="col-md-2 col-form-label" for="period">重置周期</label>
  95. <div class="col-md-4 input-group">
  96. <input type="number" class="form-control" name="period" id="period" value="0"/>
  97. <span class="input-group-text">天</span>
  98. </div>
  99. <span class="text-help"> 套餐流量会每N天重置 </span>
  100. </div>
  101. <div class="form-group row">
  102. <label class="col-md-2 col-form-label" for="traffic">流量额度</label>
  103. <div class="col-md-4 input-group">
  104. <input type="number" class="form-control" name="traffic" id="traffic"/>
  105. <span class="input-group-text">MB</span>
  106. </div>
  107. </div>
  108. <div class="form-group row">
  109. <label class="col-md-2 col-form-label" for="invite_num">赠送邀请码数量</label>
  110. <div class="col-md-4 input-group">
  111. <input type="number" class="form-control" name="invite_num" id="invite_num" required/>
  112. <span class="input-group-text">枚</span>
  113. </div>
  114. </div>
  115. <div class="form-group row">
  116. <label class="col-md-2 col-form-label" for="limit_num">限购数量</label>
  117. <div class="col-md-4 input-group">
  118. <input type="number" class="form-control" name="limit_num" id="limit_num" required/>
  119. <span class="input-group-text">次</span>
  120. </div>
  121. <span class="text-help"> 每个用户可以购买该商品次数,为 0 时代表不限购 </span>
  122. </div>
  123. <div class="form-group row package-renew">
  124. <label class="col-md-2 col-form-label" for="days">有效期</label>
  125. <div class="col-md-4 input-group">
  126. <input type="number" class="form-control" name="days" id="days" value="0"/>
  127. <span class="input-group-text">天</span>
  128. </div>
  129. <span class="text-help"> 到期后会自动从总流量扣减对应的流量 </span>
  130. </div>
  131. <div class="form-group row">
  132. <label class="col-md-2 col-form-label" for="is_hot">热销</label>
  133. <div class="col-md-10">
  134. <input type="checkbox" data-toggle="switch" name="is_hot" id="is_hot" data-on-color="primary" data-off-color="default" data-on-text="是" data-off-text="否" data-size="small">
  135. </div>
  136. </div>
  137. <div class="form-group row">
  138. <label class="col-md-2 col-form-label" for="status">状态</label>
  139. <div class="col-md-10">
  140. <input type="checkbox" data-toggle="switch" name="status" id="status" data-on-color="primary" data-off-color="default" data-on-text="上架" data-off-text="下架" data-size="small">
  141. </div>
  142. </div>
  143. </div>
  144. <div class="col-lg-6 col-md-12">
  145. <div class="form-group row">
  146. <label class="col-md-2 col-form-label" for="sort">排序</label>
  147. <div class="col-md-4">
  148. <input type="number" class="form-control" name="sort" id="sort"/>
  149. </div>
  150. <span class="text-help"> 排序值越大排越前 </span>
  151. </div>
  152. <div class="form-group row">
  153. <label class="col-md-2 col-form-label" for="color">颜色</label>
  154. <div class="col-md-4">
  155. <input type="text" class="form-control" name="color" id="color" data-plugin="asColorPicker" data-mode="simple"/>
  156. </div>
  157. </div>
  158. <div class="form-group row">
  159. <label class="col-md-2 col-form-label" for="logo">商品图片</label>
  160. <div class="col-md-6">
  161. <input type="file" id="logo" name="logo" data-plugin="dropify" data-default-file=@if(isset($goods) && $goods->logo) "{{$goods->logo}}" @else "/assets/images/default.png" @endif/>
  162. </div>
  163. </div>
  164. <div class="form-group row">
  165. <label class="col-md-2 col-form-label" for="description">描述</label>
  166. <div class="col-md-8">
  167. <textarea class="form-control" rows="2" name="description" id="description" placeholder="商品的简单描述"></textarea>
  168. </div>
  169. </div>
  170. <div class="form-group row">
  171. <label class="col-md-2 col-form-label" for="info">自定义列表</label>
  172. <div class="col-md-8">
  173. <textarea class="form-control" rows="6" name="info" id="info" placeholder="商品的自定义列表添加"></textarea>
  174. </div>
  175. <span class="offset-md-2 text-help"> 每行内容请以<code>&lt;li&gt;</code> 开头
  176. <code>&lt;/li&gt;</code> 结尾</span>
  177. </div>
  178. <div class="form-actions col-12 text-right">
  179. <button type="submit" class="btn btn-success"><i class="icon wb-check"></i> 提 交</button>
  180. </div>
  181. </div>
  182. </div>
  183. </form>
  184. </div>
  185. </div>
  186. </div>
  187. @endsection
  188. @section('script')
  189. <script src="/assets/global/vendor/bootstrap-select/bootstrap-select.min.js" type="text/javascript"></script>
  190. <script src="/assets/global/vendor/ascolor/jquery-asColor.min.js" type="text/javascript"></script>
  191. <script src="/assets/global/vendor/asgradient/jquery-asGradient.min.js" type="text/javascript"></script>
  192. <script src="/assets/global/vendor/ascolorpicker/jquery-asColorPicker.min.js" type="text/javascript"></script>
  193. <script src="/assets/global/vendor/dropify/dropify.min.js" type="text/javascript"></script>
  194. <script src="/assets/global/js/Plugin/bootstrap-select.js" type="text/javascript"></script>
  195. <script src="/assets/custom/Plugin/bootstrap-switch/bootstrap-switch.min.js" type="text/javascript"></script>
  196. <script src="/assets/global/js/Plugin/ascolorpicker.js" type="text/javascript"></script>
  197. <script src="/assets/global/js/Plugin/dropify.js" type="text/javascript"></script>
  198. <script type="text/javascript">
  199. $('[data-toggle="switch"]').bootstrapSwitch();
  200. @isset($goods)
  201. $(document).ready(function () {
  202. const type = $("input[name='type']")
  203. $("#id").val('{{$goods->id}}')
  204. $("input[name='type'][value='{{$goods->type}}']").click()
  205. type.attr("disabled", true)
  206. $("#name").val('{{$goods->name}}')
  207. $("#price").val('{{$goods->price}}')
  208. $('#level').selectpicker('val', '{{$goods->level}}')
  209. @if ($goods->type == 2)
  210. $("#renew").val('{{$goods->renew}}')
  211. $("#period").val('{{$goods->period}}')
  212. $("#days").val('{{$goods->days}}').attr("disabled", true)
  213. @endif
  214. $("#traffic").val('{{$goods->traffic}}').attr("disabled", true)
  215. $("#invite_num").val('{{$goods->invite_num}}')
  216. $("#limit_num").val('{{$goods->limit_num}}')
  217. @if ($goods->is_hot)
  218. $("#is_hot").click()
  219. @endif
  220. @if ($goods->status)
  221. $("#status").click()
  222. @endif
  223. $("#sort").val('{{$goods->sort}}')
  224. $("#color").asColorPicker('val', '{{$goods->color}}')
  225. $("#description").val('{{$goods->description}}')
  226. $("#info").val('{{$goods->info}}')
  227. })
  228. @elseif(old('type'))
  229. $(document).ready(function () {
  230. const type = $("input[name='type']")
  231. $("#id").val('{{old('id')}}')
  232. $("input[name='type'][value='{{old('type')}}']").click()
  233. $("#name").val('{{old('name')}}')
  234. $("#price").val('{{old('price')}}')
  235. $('#level').selectpicker('val', '{{old('level')}}')
  236. @if (old('type') == 2)
  237. $("#renew").val('{{old('renew',0)}}')
  238. $("#period").val('{{old('period',0)}}')
  239. $("#days").val('{{old('days',0)}}')
  240. @endif
  241. $("#traffic").val('{{old('traffic')}}')
  242. $("#invite_num").val('{{old('invite_num')}}')
  243. $("#limit_num").val('{{old('limit_num')}}')
  244. @if (old('is_hot'))
  245. $("#is_hot").click()
  246. @endif
  247. @if (old('status'))
  248. $("#status").click()
  249. @endif
  250. $("#sort").val('{{old('sort')}}')
  251. $("#color").asColorPicker('val', '{{old('color')}}')
  252. $("#description").val('{{old('description')}}')
  253. $("#info").val('{{old('info')}}')
  254. })
  255. @endisset
  256. function itemControl(value) {
  257. if (value === 1) {
  258. $(".package-renew").hide();
  259. } else {
  260. $(".package-renew").show();
  261. }
  262. }
  263. // 选择商品类型
  264. $("input[name='type']").change(function () {
  265. itemControl(parseInt($(this).val()));
  266. });
  267. </script>
  268. @endsection