setting.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <?php use common\widgets\UeditorWidget; ?>
  2. <script src="/js/mobiscroll/mobiscroll.core-2.5.2.js" type="text/javascript"></script>
  3. <script src="/js/mobiscroll/mobiscroll.core-2.5.2-zh.js" type="text/javascript"></script>
  4. <link href="/css/mobiscroll/mobiscroll.core-2.5.2.css" rel="stylesheet" type="text/css" />
  5. <link href="/css/mobiscroll/mobiscroll.animation-2.5.2.css" rel="stylesheet" type="text/css" />
  6. <script src="/js/mobiscroll/mobiscroll.datetime-2.5.1.js" type="text/javascript"></script>
  7. <script src="/js/mobiscroll/mobiscroll.datetime-2.5.1-zh.js" type="text/javascript"></script>
  8. <!-- S 可根据自己喜好引入样式风格文件 -->
  9. <script src="/js/mobiscroll/mobiscroll.android-ics-2.5.2.js" type="text/javascript"></script>
  10. <link href="/css/mobiscroll/mobiscroll.android-ics-2.5.2.css" rel="stylesheet" type="text/css" />
  11. <!-- E 可根据自己喜好引入样式风格文件 -->
  12. <div class="page-title">
  13. <div class="title-env">
  14. <h1 class="title">设置</h1>
  15. </div>
  16. <div class="breadcrumb-env">
  17. <ol class="breadcrumb bc-1">
  18. <li>
  19. <a href="/"><i class="fa-home"></i>Home</a>
  20. </li>
  21. <li>
  22. <a href="javascript:void(0)">商城管理</a>
  23. </li>
  24. <li class="active">
  25. <strong>商品管理</strong>
  26. </li>
  27. </ol>
  28. </div>
  29. </div>
  30. <div class="row">
  31. <div class="col-sm-12">
  32. <div class="panel panel-default">
  33. <div class="panel-body">
  34. <form role="form" class="form-horizontal">
  35. <div class="form-group">
  36. <label class="col-sm-2 control-label" for="field-4">*涨价方式</label>
  37. <div class="col-sm-10">
  38. <?php foreach($riseTypeName as $riseKey => $riseVal){ ?>
  39. <div class="radio-inline">
  40. <label>
  41. <input type="radio" <?php if($set['riseType'] == $riseKey){ echo 'checked'; } ?> name="riseType" value="<?= $riseKey ?>">
  42. <?= $riseVal ?>
  43. </label>
  44. </div>
  45. <?php } ?>
  46. </div>
  47. </div>
  48. <div name="riseArea">
  49. <div class="form-group">
  50. <label class="col-sm-2 control-label">*涨价时段:</label>
  51. <div class="col-sm-10">
  52. <input type="text" id="startTime" <?php if(!empty($set['startRiseTime'])){ echo 'checkStatus="yes"'; } ?> value="<?php if(!empty($set['startRiseTime'])){ echo date("Y-m-d H:i:s",$set['startRiseTime']); } ?>" style="width:40%;display:inline-block;" class="form-control" name="startTime" placeholder="请填写开始时间">
  53. <input type="text" id="endTime" <?php if(!empty($set['endRiseTime'])){ echo 'checkStatus="yes"'; } ?> value="<?php if(!empty($set['endRiseTime'])){ echo date("Y-m-d H:i:s",$set['endRiseTime']); } ?>" style="width:40%;display:inline-block;" class="form-control" name="endTime" placeholder="请填写结束时间">
  54. <p></p>
  55. </div>
  56. </div>
  57. <div class="form-group">
  58. <label class="col-sm-2 control-label">*涨价金额:</label>
  59. <div class="col-sm-10">
  60. <input type="text" class="form-control" value="<?= $set['riseAmount'] ?>" name="riseAmount" placeholder="全部商品上涨20%请填写20,上涨100元请填写100">
  61. <p></p>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="form-group-separator"></div>
  66. <div class="form-group">
  67. <label class="col-sm-2 control-label" for="field-3">*商品简要说明:</label>
  68. <div class="col-sm-10">
  69. <?= UeditorWidget::widget(['name' => 'goodSIntroduce','content' => $set['goodSIntroduce']]); ?>
  70. <p></p>
  71. </div>
  72. </div>
  73. <div class="form-group-separator"></div>
  74. <div class="form-group" style="text-align:center;">
  75. <button type="button" onclick="setSubmit('click',this)" class="btn btn-info btn-single">确认</button>
  76. <button type="button" onclick="history.go(-1);" class="btn btn-info btn-single">返回</button>
  77. </div>
  78. </form>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. <!-- footer -->
  84. <?php
  85. use backend\widgets\FooterWidget;
  86. ?>
  87. <?= FooterWidget::widget()?>
  88. <!-- footer -->
  89. <script>
  90. //验证流程
  91. var startTime = $("input[name=startTime]");
  92. var endTime = $("input[name=endTime]");
  93. var riseAmount = $("input[name=riseAmount]");
  94. var goodSIntroduce = $("textarea[name=goodSIntroduce]");
  95. var needValidate = [];
  96. var riseType = <?php echo isset($set['riseType']) && strlen($set['riseType'])>0 ? $set['riseType'] : 0; ?>;//不涨价
  97. <?php if($set['riseType'] == $noRise){ ?>
  98. $("div[name=riseArea]").css("display","none");
  99. <?php }else{ ?>
  100. needValidate = [riseAmount];
  101. $("div[name=riseArea]").css("display","block");
  102. <?php } ?>
  103. $(":radio[name=riseType]").click(function(){
  104. riseType = $(":radio[name=riseType]:checked").val();
  105. needValidate = [];
  106. if(riseType == <?= $noRise ?>){//如果涨价再开启验证
  107. $("div[name=riseArea]").css("display","none");
  108. }else{
  109. needValidate = [riseAmount];
  110. $("div[name=riseArea]").css("display","block");
  111. }
  112. });
  113. setStats(riseAmount, '请填写涨价金额或百分数', function(val, mess){
  114. var info=[false, mess];
  115. if(getLength(val) > 0){
  116. info[0] = true;
  117. info[1] = '填写正确';
  118. if(Math.floor(val) != val){
  119. info[0] = false;
  120. info[1] = '请填写整数';
  121. }
  122. }
  123. return info;
  124. });
  125. UE.getEditor('goodSIntroduce').addListener("focus", function (type,event) {
  126. goodSIntroduce.removeAttr('checkStatus');
  127. goodSIntroduce.siblings('p').removeClass('help-error-mention').html('');
  128. goodSIntroduce.parent().parent().removeClass("has-success").removeClass('has-error');
  129. })
  130. UE.getEditor('goodSIntroduce').addListener("blur", function (type,event) {
  131. var goodSIntroduceVal = UE.getEditor('goodSIntroduce').getContent();
  132. if(getLength(goodSIntroduceVal) > 0){
  133. goodSIntroduce.attr('checkStatus','yes');
  134. goodSIntroduce.siblings('p').removeClass('help-error-mention').html('');
  135. goodSIntroduce.parent().parent().addClass("has-success").removeClass("has-error");
  136. }else{
  137. goodSIntroduce.attr('checkStatus','no');
  138. goodSIntroduce.siblings('p').addClass('help-error-mention').html('简要说明不能为空');
  139. goodSIntroduce.parent().parent().addClass("has-error").removeClass("has-success");
  140. }
  141. });
  142. function setSubmit(){
  143. var verifyStatus = true;
  144. for(var m=0;m<needValidate.length;m++){
  145. var singleObj = needValidate[m];
  146. if(singleObj.attr('checkStatus') == undefined){
  147. singleObj.blur();
  148. }
  149. if(singleObj.attr('checkStatus') == 'no'){
  150. verifyStatus = false;
  151. continue;
  152. }
  153. }
  154. if(riseType == <?= $noRise ?>){//要涨价
  155. if(startTime.attr('checkStatus') == undefined || startTime.attr('checkStatus') == 'no'){
  156. verifyStatus = false;
  157. startTime.attr('checkStatus','no');
  158. startTime.siblings('p').addClass('help-error-mention').html('请填写开始时间');
  159. startTime.parent().parent().addClass("has-error").removeClass("has-success");
  160. }
  161. if(endTime.attr('checkStatus') == undefined || endTime.attr('checkStatus') == 'no'){
  162. verifyStatus = false;
  163. endTime.attr('checkStatus','no');
  164. endTime.siblings('p').addClass('help-error-mention').html('请填写结束时间');
  165. endTime.parent().parent().addClass("has-error").removeClass("has-success");
  166. }
  167. }
  168. <?php
  169. if(!empty($set['goodSIntroduce'])){
  170. ?>
  171. goodSIntroduce.attr('checkStatus','yes');
  172. <?php } ?>
  173. if(goodSIntroduce.attr('checkStatus') == undefined || goodSIntroduce.attr('checkStatus') == 'no'){
  174. goodSIntroduce.attr('checkStatus','no');
  175. goodSIntroduce.siblings('p').addClass('help-error-mention').html('简要说明不能为空');
  176. goodSIntroduce.parent().parent().addClass("has-error").removeClass("has-success");
  177. verifyStatus = false;
  178. }
  179. if(verifyStatus == false){
  180. return;
  181. }
  182. var data = "&_csrf=<?= Yii::$app->request->csrfToken ?>&startRiseTime="+startTime.val()+'&endRiseTime='+endTime.val()+"&";
  183. data += "goodSIntroduce="+goodSIntroduce.val()+"&riseType="+riseType+"&riseAmount="+riseAmount.val();
  184. $.ajax({type:"POST",url:'/goods/setting-replace',data:data,dataType:'json',async:false,success:function(data){
  185. xhPopMsg(data.msg,1300);
  186. if(data.code == 'A0001'){
  187. }
  188. }
  189. });
  190. }
  191. function setStats(obj,mess,check)
  192. {
  193. obj.focus(function(){
  194. $(this).removeAttr('checkStatus');
  195. $(this).siblings('p').removeClass('help-error-mention').html('');
  196. $(this).parent().parent().removeClass("has-success").removeClass('has-error');
  197. });
  198. obj.blur(function(){
  199. var objVal = obj.val();
  200. var info = check(objVal,mess);
  201. if(info[0]){
  202. $(this).attr('checkStatus','yes');
  203. $(this).siblings('p').removeClass('help-error-mention').html('');
  204. $(this).parent().parent().addClass("has-success").removeClass("has-error");
  205. }else{
  206. $(this).attr('checkStatus','no');
  207. $(this).siblings('p').addClass('help-error-mention').html(info[1]);
  208. $(this).parent().parent().addClass("has-error").removeClass("has-success");
  209. }
  210. });
  211. }
  212. //选择创建时间
  213. $(function () {
  214. var currYear = (new Date()).getFullYear();
  215. var opt ={};
  216. opt.date = {preset : 'date'};
  217. opt.datetime = {preset : 'datetime'};
  218. opt.time = {preset : 'time'};
  219. opt.default = {
  220. theme: 'android-ics light', //皮肤样式
  221. display: 'modal', //显示方式
  222. mode: 'scroller', //日期选择模式
  223. lang:'zh',
  224. dateFormat: 'yy-mm-dd',
  225. showNow: true,
  226. nowText: "今天",
  227. startYear:currYear - 10, //开始年份
  228. endYear:currYear + 10 //结束年份
  229. };
  230. var optDateTime = $.extend(opt['datetime'], opt['default']);
  231. $("#startTime").mobiscroll(optDateTime).datetime(optDateTime).bind("change", function(e) {
  232. $("#startTime").attr('checkStatus','yes');
  233. $("#startTime").siblings('p').removeClass('help-error-mention').html('');
  234. $("#startTime").parent().parent().addClass("has-success").removeClass("has-error");
  235. });
  236. $("#endTime").mobiscroll(optDateTime).datetime(optDateTime).bind("change", function(e) {
  237. $("#endTime").attr('checkStatus','yes');
  238. $("#endTime").siblings('p').removeClass('help-error-mention').html('');
  239. $("#endTime").parent().parent().addClass("has-success").removeClass("has-error");
  240. });
  241. });
  242. </script>