Bladeren bron

商品管理增加商品规则检查,幸运2021玩法不能配错

joe 4 jaren geleden
bovenliggende
commit
bcf0036543
2 gewijzigde bestanden met toevoegingen van 28 en 0 verwijderingen
  1. 2 0
      app/admin/controller/store/StoreProduct.php
  2. 26 0
      app/admin/view/store/store_product/create.php

+ 2 - 0
app/admin/controller/store/StoreProduct.php

@@ -23,6 +23,7 @@ use think\facade\Route as Url;
 use app\admin\model\system\{
     SystemAttachment, ShippingTemplates
 };
+use \think\facade\Config;
 
 
 /**
@@ -141,6 +142,7 @@ class StoreProduct extends AuthController
     public function create($id = 0)
     {
         $this->assign('id', (int)$id);
+        $this->assign('lucky_id', Config::get('activity.lucky_cate_id'));
         return $this->fetch();
     }
 

+ 26 - 0
app/admin/view/store/store_product/create.php

@@ -880,6 +880,7 @@
 </div>
 <script>
     var id = {$id};
+    var lucky_id = {$lucky_id};
     new Vue({
         el: '#app',
         data: {
@@ -1447,6 +1448,7 @@
                     return that.showMsg(res.msg);
                 });
             },
+
             handleSubmit:function () {
                 var that = this, cate_id = $('input[name="cate_id"]').val();
                 if (cate_id != '') {
@@ -1454,7 +1456,11 @@
                 }
                 if (!that.formData.cate_id.length) {
                     return that.showMsg('请选择商品分类');
+                } else if (that.formData.cate_id.length > 1) {
+                    return that.showMsg('商品不能属于多个分类');
                 }
+                var is_lucky = that.formData.cate_id[0] == lucky_id;
+
                 if (!that.formData.temp_id) {
                     return that.showMsg('请选择运费模板');
                 }
@@ -1472,6 +1478,9 @@
                 if (!that.formData.slider_image.length) {
                     return that.showMsg('请填选择商品轮播图');
                 }
+                if (is_lucky && that.formData.spec_type == 0) {
+                    return that.showMsg('幸运2021 必须为多规格');
+                }
                 if (that.formData.spec_type == 0) {
                     if (!that.formData.attr.pic) {
                         return that.showMsg('请选择单规则图片');
@@ -1503,6 +1512,23 @@
                     };
                     that.formData.attrs = [attr];
                 } else {
+                    if(is_lucky && !that.formData.items.find(function(val) {
+                        if (val.value == '幸运' && val.detail.length == 2 &&
+                            val.detail[0] == '20' && val.detail[1] == '21') {
+                            return true;
+                        }
+                    })) {
+                        return that.showMsg('缺少[幸运]规格或格式不正确');
+                    }
+
+                    if(!is_lucky && that.formData.items.find(function(val) {
+                        if (val.value == '幸运') {
+                            return true;
+                        }
+                    })) {
+                        return that.showMsg('非 幸运2021 使用了[幸运]规格');
+                    }
+
                     if (!that.formData.attrs.length) {
                         return that.showMsg('请添加多规格属性');
                     }