瀏覽代碼

custom option 流程梳理

chengwl 5 年之前
父節點
當前提交
f6c3b8e944

+ 40 - 32
vendor/fancyecommerce/fecshop/app/appadmin/modules/Catalog/block/productinfo/Managerbatchedit.php

@@ -31,7 +31,6 @@ class Managerbatchedit extends AppadminbaseBlockEdit implements AppadminbaseBloc
      */
     protected $_attrBlockName = '\fecshop\app\appadmin\modules\Catalog\block\productinfo\index\BatchAttr';
     protected $_attrBlock;
-
     public function init()
     {
         /**
@@ -83,6 +82,7 @@ class Managerbatchedit extends AppadminbaseBlockEdit implements AppadminbaseBloc
             'primaryInfo'       => $this->getCurrentProductPrimay(),
             'img_html'          => $this->getImgHtml(),
             'custom_option'     => $this->_one['custom_option'],
+            'groupOption'         => $this->getGroupOption(),
             'product_id'        => $this->_one[Yii::$service->product->getPrimaryKey()],
             //'editBar' 	    => $this->getEditBar(),
             //'textareas'	    => $this->_textareas,
@@ -265,6 +265,28 @@ class Managerbatchedit extends AppadminbaseBlockEdit implements AppadminbaseBloc
         }
         return $arr;
     }
+    public function getGroupOption()
+    {
+        $arr = [];
+        $currentAttrGroup = CRequest::param('attr_group');
+        if ($currentAttrGroup) {
+            $_currentAttrGroup = $currentAttrGroup;
+        } else {
+            $_currentAttrGroup = Yii::$service->product->getDefaultAttrGroup();
+        }
+        $editArr =Yii::$service->product->GetCustomOptionAttrInfo($_currentAttrGroup);
+        if (is_array($editArr) && !empty($editArr)) {
+            foreach ($editArr as $spuOne) {
+                $name = $spuOne['name'];
+                $displayData = isset($spuOne['display']['data']) ? $spuOne['display']['data'] : '';
+                if ($name && is_array($displayData)) {
+                    $arr[$name] = $displayData;
+                }
+                
+            }
+        }
+        return $arr;
+    }
     
     public function getVal($name, $column){
         if (isset ($this->_one[$name]) ) {
@@ -416,42 +438,27 @@ class Managerbatchedit extends AppadminbaseBlockEdit implements AppadminbaseBloc
          */
         // var_dump()
 
-        if (Yii::$app->request->post('operate') == 'copy') {
-            $productPrimaryKey = Yii::$service->product->getPrimaryKey();
-            if (isset($this->_param[$productPrimaryKey])) {
-                unset($this->_param[$productPrimaryKey]);
-                //echo 111;
-                //var_dump($this->_param);
-                //exit;
-            }
-        }
+        // if (Yii::$app->request->post('operate') == 'copy') {
+        //     $productPrimaryKey = Yii::$service->product->getPrimaryKey();
+        //     if (isset($this->_param[$productPrimaryKey])) {
+        //         unset($this->_param[$productPrimaryKey]);
+        //         //echo 111;
+        //         //var_dump($this->_param);
+        //         //exit;
+        //     }
+        // }
+        // dd($this->_param);
+        $this->_service->save($this->_param, 'catalog/product/index');
         
-        $spu_attrs = Yii::$app->request->post('spu_attrs');
-        $spuArr = $this->getSpuArr($spu_attrs);
-        if (!$spuArr || empty($spuArr)) {
+        $errors = Yii::$service->helper->errors->get();
+        if ($errors) {
             echo  json_encode([
                 'statusCode' => '300',
-                'message'    => 'spu属性为空,如果您当前选择的产品没有spu属性,请使用单个产品添加',
+                'message'    => $errors,
             ]);
             exit;
         }
-        
-        foreach ($spuArr as $spuOne) {
-            foreach ($spuOne as $k=>$v) {
-                $this->_param[$k] = $v;
-            }
-            $this->_service->save($this->_param, 'catalog/product/index');
-        
-            $errors = Yii::$service->helper->errors->get();
-            if ($errors) {
-                echo  json_encode([
-                    'statusCode' => '300',
-                    'message'    => $errors,
-                ]);
-                exit;
-            }
-        }
-        
+                
         echo  json_encode([
             'statusCode' => '200',
             'message'    => Yii::$service->page->translate->__('Save Success'),
@@ -492,7 +499,6 @@ class Managerbatchedit extends AppadminbaseBlockEdit implements AppadminbaseBloc
         $this->_param = $request_param[$this->_editFormData];
         $this->_param['attr_group'] = CRequest::param('attr_group');
         $custom_option = CRequest::param('custom_option');
-        //var_dump($custom_option);
         $custom_option = $custom_option ? json_decode($custom_option, true) : [];
         $custom_option_arr = [];
         if (is_array($custom_option) && !empty($custom_option)) {
@@ -609,6 +615,7 @@ class Managerbatchedit extends AppadminbaseBlockEdit implements AppadminbaseBloc
             }
             $this->_param['image']['gallery'] = $gallery_af;
         }
+        //TODO 处理城 custom_option
         // 自定义属性 也就是在 @common\config\fecshop_local_services\Product.php 产品服务的 customAttrGroup 配置的产品属性。
         $custom_attr = \Yii::$service->product->getGroupAttrInfo($this->_param['attr_group']);
         if (is_array($custom_attr) && !empty($custom_attr)) {
@@ -670,6 +677,7 @@ class Managerbatchedit extends AppadminbaseBlockEdit implements AppadminbaseBloc
             }
         }
         $tier_price_arr = \fec\helpers\CFunc::array_sort($tier_price_arr, 'qty', 'asc');
+        $this->_param['sku']=$this->_param['spu'];
         $this->_param['tier_price'] = $tier_price_arr;
     }
 

+ 1 - 1
vendor/fancyecommerce/fecshop/app/appadmin/modules/Catalog/block/productinfo/Manageredit.php

@@ -120,7 +120,7 @@ class Manageredit extends AppadminbaseBlockEdit implements AppadminbaseBlockEdit
                     if ($type == 'select' && is_array($data) && !empty($data)) {
                         $str .= '<select atr="'.$attr.'" class="custom_option_attr">';
                         foreach ($info['display']['data'] as $v) {
-                            $str .= '<option value="'.$v.'">' . Yii::$service->page->translate->__($v) . '</option>';
+                            $str .= '<option value="'.$v['key'].'">' . Yii::$service->page->translate->__($v['key']) . '</option>';
                         }
                         $str .= '</select>';
                     }

+ 8 - 0
vendor/fancyecommerce/fecshop/app/appadmin/modules/Catalog/block/productinfo/index/BatchAttr.php

@@ -274,6 +274,14 @@ class BatchAttr
                 ],
                 'require' => 0,
             ],
+            [
+                'label' => Yii::$service->page->translate->__('Sale Price'),
+                'name'  => 'price',
+                'display' => [
+                    'type' => 'inputString',
+                ],
+                'require' => 1,
+            ],
             
             [
                 'label' => Yii::$service->page->translate->__('Special Price'),

+ 66 - 0
vendor/fancyecommerce/fecshop/app/appadmin/modules/Catalog/block/productoption/Imageupload.php

@@ -0,0 +1,66 @@
+<?php
+/**
+ * FecShop file.
+ *
+ * @link http://www.fecshop.com/
+ * @copyright Copyright (c) 2016 FecShop Software LLC
+ * @license http://www.fecshop.com/license/
+ */
+
+namespace fecshop\app\appadmin\modules\Catalog\block\productoption;
+
+use Yii;
+use yii\base\InvalidValueException;
+
+/**
+ * block cms\article.
+ * @author Terry Zhao <2358269014@qq.com>
+ * @since 1.0
+ */
+class Imageupload
+{
+    public $imageFloder = 'media/catalog/customoption';
+    public $maxUploadMSize;
+    public $allowImgType = [
+        'image/jpeg',
+        'image/gif',
+        'image/png',
+        'image/jpg',
+        'image/pjpeg',
+    ];
+    public function init(){
+        $this->maxUploadMSize = (float)Yii::$app->store->get('product','maxUploadMSize');
+    }
+    public function upload()
+    {
+        if (empty($_FILES)) {
+            throw new InvalidValueException('$_FILES is empty.');
+        }
+        $index = 0;        //$_FILES 以文件name为数组下标,不适用foreach($_FILES as $index=>$file)
+        $post = Yii::$app->request->post();
+        if ($post['thisindex']) {
+            $rel_index = $post['thisindex'];
+        } else {
+            $rel_index = $index;
+        }
+        $img_str = '';
+        foreach ($_FILES as $FILE) {
+
+            Yii::$service->image->imageFloder = $this->imageFloder;
+            Yii::$service->image->allowImgType = $this->allowImgType;
+            if ($this->maxUploadMSize) {
+                Yii::$service->image->setMaxUploadSize($this->maxUploadMSize);
+            }
+            $saveImgInfo=Yii::$service->image->saveUploadImg($FILE);
+            $rel_index++;
+        }
+        echo json_encode([
+            'return_status' => 'success',
+            'data'=>[
+                'rel'=>$saveImgInfo[0],
+                'src'=>$saveImgInfo[1],
+            ],
+        ]);
+        exit;
+    }
+}

+ 4 - 4
vendor/fancyecommerce/fecshop/app/appadmin/modules/Catalog/block/productoption/Manageredit.php

@@ -170,14 +170,14 @@ class Manageredit extends AppadminbaseBlockEdit implements AppadminbaseBlockEdit
     public function getSaveDisplayData()
     {
         $dd = $this->_param['display_data'];
+
         $display_data_arr = [];
         if ($dd) {
-            $arr = explode('||', $dd );
+            $arr=\json_decode($dd,true);
+
             foreach ($arr as $a) {
                 if ($a) {
-                    $display_data_arr[] = [
-                        'key' => $a,
-                    ];
+                    $display_data_arr[] = $a;
                 }
             }
         }

+ 6 - 0
vendor/fancyecommerce/fecshop/app/appadmin/modules/Catalog/controllers/ProductoptionController.php

@@ -42,4 +42,10 @@ class ProductoptionController extends CatalogController
     {
         $this->getBlock('manageredit')->delete();
     }
+    // catalog
+    public function actionImageupload()
+    {
+        $this->getBlock()->upload();
+    }
+    
 }

+ 386 - 64
vendor/fancyecommerce/fecshop/app/appadmin/theme/base/default/catalog/productinfo/managerbatchedit.php

@@ -107,7 +107,30 @@ function getCategoryData(product_id,i){
 		}
 	});
 }
+function generalsku(){
+	$('.sell-sku-body-table.option tr').each(function(){
+		general_sku = '';	
+		$(this).find('.spu_option_content').each(function(){
+			attr = $(this).attr("rel");	
+			val = $(this).attr('title');	
+			if(!val){	
+				i = 1;	
+				alert("<?=  Yii::$service->page->translate->__('can not select empty') ?>");	
+			}	
+			val = val.replace(/ /g, "*")	
+			if(!general_sku){	
+				general_sku = val;	
+			}else{	
+				general_sku += "-"+val;	
+			}	
+			general_sku = general_sku.toLowerCase();	
+
+		})
+		$(this).find('.sku_code').val(general_sku);
+
+	})
 
+}
 function thissubmit(thiss){
 	// product image
 	main_image_image 		=  $('.productimg input[type=radio]:checked').val();
@@ -139,30 +162,31 @@ function thissubmit(thiss){
     
 	$(".tabsContent .image_gallery").val(image_gallery);
 	//custom_option
-	//i = 0;
-	//custom_option = new Object();
-	//jQuery(".custom_option_list tbody tr").each(function(){
-	//	option_header = new Object();
-	//	$(this).find("td").each(function(){
-	//		rel = $(this).attr("rel");
-	//		
-	//		if(rel != 'image'){
-	//			if(rel){
-	//				option_header[rel] = $(this).attr('val');
-	//			}
-	//		}else{
-	//			rel = $(this).find("img").attr("rel");
-	//			option_header['image'] = rel;
-	//		}
-	//		
-	//	});
-	//	custom_option[i] = option_header;
-	//	i++;
-	//});
-	//	
-	//custom_option = JSON.stringify(custom_option);
-	//alert(custom_option);
-	//jQuery(".custom_option_value").val(custom_option);
+	i = 0;
+	custom_option = new Object();
+	jQuery(".sell-sku-body-table.option tbody tr:gt(0)").each(function(){
+		option_header = new Object();
+		option_header['sku']=$(this).find('.sku_code').val();
+		option_header['price']=$(this).find('.price').val();
+		option_header['qty']=$(this).find('.qty').val();
+		option_header['image'] =$(this).find("img").attr("rel");
+		$(this).find('.spu_option_content').each(function(){
+			rel = $(this).attr("rel");
+			if(rel){
+				if(rel){
+					option_header[rel] = $(this).attr('title');
+				}
+			}
+			
+		})
+		console.log(option_header);
+		custom_option[i] = option_header;
+		i++;
+	});
+	console.log(custom_option);
+	custom_option = JSON.stringify(custom_option);
+	jQuery(".custom_option_value").val(custom_option);
+	
 	
 	cate_str = "";
 	jQuery(".category_tree div.ckbox.checked").each(function(){
@@ -190,45 +214,10 @@ function thissubmit(thiss){
     
     spuStr = '';
     isSkuPriceQtyEmpty = false;
-    $(".sell-sku-body-table tr ").each(function(){
-        skuStr = '';
-        iss = 0;
-        $(this).find("td.sell-sku-cell .cell-inner  p.spu_attr_content").each(function(){
-            sAttr = $(this).attr('rel');
-            sAttrVal = $(this).attr('title');
-            if (sAttr && sAttrVal) {
-                skuStr += sAttr+ '###' + sAttrVal + '|||';
-                iss = 1;
-            }
-        });
-        if (iss) {
-            sSkuCodeVal = $(this).find("td.sell-sku-cell .sku_code").val();
-            sSkuPriceVal = $(this).find("td.sell-sku-cell .sku_price").val();
-            sSkuQtyVal = $(this).find("td.sell-sku-cell .sku_qty").val();
-            if (sSkuCodeVal && sSkuPriceVal && sSkuQtyVal) {
-                skuStr += 'sku###' + sSkuCodeVal + '|||';
-                skuStr += 'price###' + sSkuPriceVal + '|||';
-                skuStr += 'qty###' + sSkuQtyVal;
-                spuStr += skuStr + '***';
-            } else {
-                isSkuPriceQtyEmpty = true;
-                
-            }
-        }
-        
-    });
-    if (isSkuPriceQtyEmpty) {
-        alert("sku,价格,库存不能为空");
-        return false;
-    }
-    if (!spuStr) {
-        alert("您应该至少添加一行spu属性");
-        return false;
-    }
-    $(".spu_attrs").val(spuStr);
 	//alert(tier_price_str);
 	jQuery(".tier_price_input").val(tier_price_str);
 	//alert($(".tier_price_input").val());
+	// jQuery(".custom_option_list tbody tr:gt(0)").find('input').remove();
 	return validateCallback(thiss, dialogAjaxDoneCloseAndReflush);
 }
 </script>
@@ -238,7 +227,7 @@ function thissubmit(thiss){
 		<?php echo CRequest::getCsrfInputHtml();  ?>	
 		<input type="hidden" name="operate"  value="<?=  $operate ?>" />
 		<input type="hidden" class="primary_info"  value="<?= $primaryInfo ?>" />
-       <input type="hidden" class="spu_attrs"  name="spu_attrs" value="" />
+       <input type="hidden" class="custom_option_value"  name="custom_option" value="" />
 		<div class="tabs" >
 			<div class="tabsHeader">
 				<div class="tabsHeaderContent">
@@ -252,8 +241,8 @@ function thissubmit(thiss){
 						<li><a href="javascript:;"><span><?=  Yii::$service->page->translate->__('Attr Group') ?></span></a></li>
 						
                         <li><a href="javascript:;"><span><?=  Yii::$service->page->translate->__('Spu Attr') ?></span></a></li>
-						<!--<li><a href="javascript:;"><span><?=  Yii::$service->page->translate->__('Custom Option') ?></span></a></li>
-						-->
+						<li><a href="javascript:;"><span><?=  Yii::$service->page->translate->__('Custom Option') ?></span></a></li>
+						
                         <li><a href="javascript:;"><span><?=  Yii::$service->page->translate->__('Relate Product') ?></span></a></li>
 					</ul>
 				</div>
@@ -495,7 +484,7 @@ function thissubmit(thiss){
                                     i = 0;
                                     hStr = '';
                                     htmlStr += getTableStr(attrArr, i, hStr); 
-                                    $(".sell-sku-body-table tbody").html(htmlStr);
+                                    $(".sell-sku-body-table.option tbody").html(htmlStr);
                                 });
                                 
                                 function getTableStr(attrArr, i, hStr) {
@@ -602,6 +591,339 @@ function thissubmit(thiss){
                             </colgroup>
                             <tbody>
                                 
+                            </tbody>
+                        </table>
+                    </div>    
+				</div>
+				<div >
+                    <div class="group_option">
+                        <?php if (is_array($groupOption) && !empty($groupOption)): $iu = 0;  ?>
+                            <?php foreach ($groupOption as $spuName => $spuData):   $iu++; ?>
+                                <div class="spu_option_one" style="margin-top:10px;margin-bottom:20px;" rel="<?= $spuName ?>">
+                                    <div style="margin-bottom: 10px;">
+                                        <label style="text-transform: capitalize;"><?= $spuName ?></label>
+                                        <input type="text" style="width:100px;"  class="spu_option_input spu_option_input_<?= $iu  ?>" />
+                                        
+                                        <a  rel="<?= $iu  ?>" style="text-align:right; float:none;" href="javascript:void(0)" class="add_option button">
+												<span> <?=  Yii::$service->page->translate->__('Add') ?></span>
+											</a>
+                                    </div>
+                                    <div class="spu_option_info spu_option_info_<?= $iu  ?>">
+                                        <?php foreach ($spuData as $sd): ?>
+                                            <span style="    margin-right: 10px;  font-size: 14px;  height: 30px; line-height: 30px; min-width: 105px;display: inline-block;">
+                                                <input class="spuOptionCheck" type="checkbox"  id="<?=  $sd?>" rel="<?=  $sd?>">
+                                                <label for="<?=  $sd?>"  style="text-transform: capitalize;font-size:14px;"><?=  $sd?></label>
+                                            </span>
+                                        <?php endforeach; ?>
+                                    </div>
+                                </div>
+                            <?php endforeach; ?>
+							<div style="display:block;height: 40px;margin-bottom:5px;" class="fill">
+								<div style="margin-bottom: 10px;max-width:30%;float:left">
+											<label style="text-transform: capitalize;">价格</label>
+											<input type="text" style="width:100px;" class="fillprice  textInput">
+											
+											<a rel="3" style="text-align:right; float:none;" href="javascript:void(0)" class="button custom_option_price">
+													<span> 填充</span>
+												</a>
+										</div>
+									<div style="margin-bottom: 10px;max-width:30%;float:left">
+										<label style="text-transform: capitalize;"> 库存</label>
+										<input type="text" style="width:100px;" class="textInput fillqty">
+										
+										<a rel="3" style="text-align:right; float:none;" href="javascript:void(0)" class="button custom_option_qty">
+												<span> 填充</span>
+											</a>
+									</div>
+									<div style="margin:0px 10px 10px  10px;max-width:30%;float:left">
+										<a rel="3" style="text-align:right; float:none;" href="javascript:void(0)" class="button custom_option_chose_image">
+												<span> 选择图片</span>
+											</a>
+									</div>
+									<div style="margin:0px 10px 10px  10px;max-width:30%;float:left">
+										<a rel="3" style="text-align:right; float:none;" href="javascript:void(0)" class="button chose_custom_op_img">
+												<span> 填充图片</span>
+											</a>
+										<div class="chosened_img"></div>
+									</div>
+									<div style="margin:0px 10px 10px  10px;max-width:30%;float:left">
+										<a rel="3" style="text-align:right; float:none;" href="javascript:void(0)" class="button" onclick="generalsku()">
+												<span>  填充sku</span>
+											</a>
+									</div>
+						</div>
+						<div class="custom_option_img_list" style="border: 1px dashed rgb(136, 136, 136); margin: 15px 0px; padding: 8px 0px;">	
+					</div>
+                        <?php endif; ?>
+	
+                        <script>
+							function deleteoptionitem(){
+									$(this).parents('tr');
+									$(this).parents('tr').remove();
+								}
+                            $(document).ready(function(){
+							
+                                $(".dialog").on("click",".spuOptionCheck",function(){
+									var optionArr = [];
+                                    var htmlStr = '<tr>';
+                                    var optionRows = {};
+                                    $columnsAllRows = 0;
+                                    $(".spu_option_one").each(function(){
+                                        var obj = {};
+                                        var spuName = $(this).attr('rel');
+                                        obj.name = spuName;
+                                        htmlStr += '<td class="sell-sku-cell sell-sku-cell-text">' + spuName + '</td>';
+                                        rows = 0;
+                                        var spuData = [];
+                                        $(this).find(".spuOptionCheck:checked").each(function(){
+                                           var val = $(this).attr('rel');
+                                           spuData.push(val);
+                                           rows++;
+                                        });
+                                        // 计算rows数
+                                        for (var x in optionRows){
+                                            v = optionRows[x];
+                                            optionRows[x] = v * rows;
+                                        }
+                                        optionRows[spuName] = 1;
+                                        obj.data = spuData;
+										optionArr.push(obj);
+                                    });
+                                    for (x in optionArr) {
+                                        obj = optionArr[x];
+                                        obj.rowSize = optionRows[obj.name];
+                                    }
+                                    htmlStr += '<td class="sell-sku-cell sell-sku-cell-text">Sku编码</td>';
+                                    htmlStr += '<td class="sell-sku-cell sell-sku-cell-text">价格</td>';
+                                    htmlStr += '<td class="sell-sku-cell sell-sku-cell-text">库存</td>';
+                                    htmlStr += '<td class="sell-sku-cell sell-sku-cell-text">图片</td>';
+                                    htmlStr += '<td class="sell-sku-cell sell-sku-cell-text">删除</td>';
+                                    htmlStr += '</tr>';
+                                    i = 0;
+									hStr = '';
+									console.log(optionArr);
+									htmlStr += getTableStr(optionArr, i, hStr); 
+									
+                                    $(".sell-sku-body-table.option tbody").html(htmlStr);
+                                });
+                                
+                                // function getTableStr(optionArr, i, hStr) {
+                                //     var optionObj = optionArr[i];
+                                //     var htmlStr = '';
+                                //     for (var j = 0; j < optionObj.data.length; j++) {
+                                //         rowspan = optionObj.rowSize;
+                                //         spuName = optionObj.name;
+                                //         vData = optionObj.data;
+                                //     	optionVal = vData[j];
+                                //         shStr = hStr;
+                                //         ii = i + 1;
+                                //         if ( ii >= optionArr.length) {
+                                //             if (j > 0) {
+                                //                 reallyDo = 'sell-sku-cell-text'; 
+                                //                 replaceWith = "sell-sku-cell-text hide";
+                                //                 shStr = shStr.replace(new RegExp(reallyDo, 'g'), replaceWith);
+                                //             }
+                                //         } else if(ii != 1){
+                                //             if (j > 0) {
+                                //                 reallyDo = 'sell-sku-cell-text'; 
+                                //                 replaceWith = "sell-sku-cell-text hide";
+                                //                 shStr = shStr.replace(new RegExp(reallyDo, 'g'), replaceWith);
+                                //             }
+                                //         }
+                                //         shStr += '<td class="sell-sku-cell sell-sku-cell-text" rowspan="'+ rowspan +'">';
+                                //         shStr += '<div class="cell-inner" style="min-width: 78px;">';
+                                //         shStr += '    <div class="sell-sku-cell-text">';
+                                //         shStr += '        <p class="spu_option_content  sell-sku-cell-text-content" rel="'+spuName+'" title="'+optionVal+'">'+optionVal+'</p>';
+                                //         shStr += '    </div>';
+                                //         shStr += '</div>';
+                                //         shStr += '</td>';
+                                //         if ( ii < optionArr.length) {
+                                //             htmlStr += getTableStr(optionArr, ii, shStr);
+                                //         } else {
+                                //             htmlStr += '<tr>' + shStr;
+                                //             htmlStr += '<td class="sell-sku-cell sell-sku-cell-input" rowspan="1">';
+                                //             htmlStr += '    <div class="cell-inner" style="min-width: 160px;">';
+                                //             htmlStr += '    <span class="sell-o-input"><span class="input-wrap">';
+                                //             htmlStr += '    <span class="next-input next-input-single next-input-medium fusion-input">';
+                                //             htmlStr += '    <input class="textInput valid sku_code" type="text" label="商家编码" name="skuOuterId" value="" maxlength="64" height="100%">';
+                                //             htmlStr += '    </span></span></span></div>';
+                                //             htmlStr += '</td>';
+                                //             htmlStr += '<td class="sell-sku-cell sell-sku-cell-money" rowspan="1">';
+                                //             htmlStr += '    <div class="cell-inner" style="min-width: 90px;">';
+                                //             htmlStr += '       <span class="sell-o-number">';
+                                //             htmlStr += '        <span class="input-wrap">';
+                                //             htmlStr += '        <span class="next-input next-input-single next-input-medium fusion-input">';
+                                //             htmlStr += '        <input class="textInput valid price" type="text" label="价格(元)" required="" value="" name="price" maxlength="15" height="100%">';
+                                //             htmlStr += '        </span></span></span></div>';
+                                //             htmlStr += '</td>';
+                                //             htmlStr += '<td class="sell-sku-cell sell-sku-cell-positiveNumber" rowspan="1">';
+                                //             htmlStr += '    <div class="cell-inner" style="min-width: 90px;">';
+                                //             htmlStr += '    <span class="sell-o-number">';
+                                //             htmlStr += '    <span class="input-wrap">';
+                                //             htmlStr += '    <span class="next-input next-input-single next-input-medium fusion-input">';
+                                //             htmlStr += '    <input class="textInput valid qty" type="text" label="数量(件)" required="" value="0" name="qty" maxlength="15" height="100%">';
+                                //             htmlStr += '    </span></span></span></div>';
+								// 			htmlStr += '</td>';
+								// 			htmlStr += '<td class="sell-sku-cell sell-sku-cell-image" rowspan="1">';
+                                //             htmlStr += '<img style="width:30px;">'
+                                //             htmlStr += '</td>';
+								// 			htmlStr += '<td class="sell-sku-cell " rowspan="1">';
+								// 			htmlStr += '<a title="删除" href="javascript:void(0)" class="btnDel deleteoptionitem" ><i class="fa fa-trash-o"></i></a>'
+                                //             htmlStr += '</td>';
+                                //             htmlStr += '</tr>';
+                                //         }
+                                //     }
+                                    
+                                //     return htmlStr;
+								// }
+								function getTableStr(optionArr, i, hStr) {
+                                    var optionObj = optionArr[i];
+                                    var htmlStr = '';
+                                    for (var j = 0; j < optionObj.data.length; j++) {
+                                        rowspan = optionObj.rowSize;
+                                        spuName = optionObj.name;
+                                        vData = optionObj.data;
+                                    	optionVal = vData[j];
+                                        shStr = hStr;
+                                        ii = i + 1;
+                                        shStr += '<td class="sell-sku-cell sell-sku-cell-text" >';
+                                        shStr += '<div class="cell-inner" style="min-width: 78px;">';
+                                        shStr += '    <div class="sell-sku-cell-text">';
+                                        shStr += '        <p class="spu_option_content  sell-sku-cell-text-content" rel="'+spuName+'" title="'+optionVal+'">'+optionVal+'</p>';
+                                        shStr += '    </div>';
+                                        shStr += '</div>';
+                                        shStr += '</td>';
+                                        if ( ii < optionArr.length) {
+                                            htmlStr += getTableStr(optionArr, ii, shStr);
+                                        } else {
+                                            htmlStr += '<tr>' + shStr;
+                                            htmlStr += '<td class="sell-sku-cell sell-sku-cell-input" rowspan="1">';
+                                            htmlStr += '    <div class="cell-inner" style="min-width: 160px;">';
+                                            htmlStr += '    <span class="sell-o-input"><span class="input-wrap">';
+                                            htmlStr += '    <span class="next-input next-input-single next-input-medium fusion-input">';
+                                            htmlStr += '    <input class="textInput valid sku_code" type="text" label="商家编码" name="skuOuterId" value="" maxlength="64" height="100%">';
+                                            htmlStr += '    </span></span></span></div>';
+                                            htmlStr += '</td>';
+                                            htmlStr += '<td class="sell-sku-cell sell-sku-cell-money" rowspan="1">';
+                                            htmlStr += '    <div class="cell-inner" style="min-width: 90px;">';
+                                            htmlStr += '       <span class="sell-o-number">';
+                                            htmlStr += '        <span class="input-wrap">';
+                                            htmlStr += '        <span class="next-input next-input-single next-input-medium fusion-input">';
+                                            htmlStr += '        <input class="textInput valid price" type="text" label="价格(元)" required="" value="" name="price" maxlength="15" height="100%">';
+                                            htmlStr += '        </span></span></span></div>';
+                                            htmlStr += '</td>';
+                                            htmlStr += '<td class="sell-sku-cell sell-sku-cell-positiveNumber" rowspan="1">';
+                                            htmlStr += '    <div class="cell-inner" style="min-width: 90px;">';
+                                            htmlStr += '    <span class="sell-o-number">';
+                                            htmlStr += '    <span class="input-wrap">';
+                                            htmlStr += '    <span class="next-input next-input-single next-input-medium fusion-input">';
+                                            htmlStr += '    <input class="textInput valid qty" type="text" label="数量(件)" required="" value="0" name="qty" maxlength="15" height="100%">';
+                                            htmlStr += '    </span></span></span></div>';
+											htmlStr += '</td>';
+											htmlStr += '<td class="sell-sku-cell sell-sku-cell-image" rowspan="1">';
+                                            htmlStr += '<img style="width:30px;">'
+                                            htmlStr += '</td>';
+											htmlStr += '<td class="sell-sku-cell " rowspan="1">';
+											htmlStr += '<a title="删除" href="javascript:void(0)" class="btnDel deleteoptionitem" ><i class="fa fa-trash-o"></i></a>'
+                                            htmlStr += '</td>';
+                                            htmlStr += '</tr>';
+                                        }
+                                    }
+                                    
+                                    return htmlStr;
+                                }
+                                
+                                $(".dialog").on("click",".add_option",function(){
+                                    var rel = $(this).attr('rel');
+                                    var str1 = ".spu_option_input_" + rel;
+                                    var str2 = ".spu_option_info_" + rel ;
+                                    var addVal = $(str1).val();
+                                    addVal = addVal.toLowerCase();
+                                    if (!addVal) {
+                                        alert("请填写值");
+                                    } else {
+                                        var isCF = 0;
+                                        $(str2 + " input").each(function(){
+                                            v = $(this).attr('rel');
+                                            v = v.toLowerCase();
+                                            if (v == addVal) {
+                                                alert("添加的值重复");
+                                                isCF = 1;
+                                            }
+                                        });
+                                        if (isCF == 0) {
+                                            appendStr = '<span style="    margin-right: 10px;  font-size: 14px;  height: 30px; line-height: 30px; min-width: 105px;display: inline-block;"><input class="spuAttrCheck" type="checkbox" id="'+addVal+'" rel="'+addVal+'"><label for="'+addVal+'" style="text-transform: capitalize;font-size:14px;">'+addVal+'</label> </span>';
+                                            //alert(appendStr);
+                                            $(str2).append(appendStr);
+                                        }
+                                    }
+                                    
+								});
+								$('.fill').on('click','.custom_option_price',function(){
+									val=$('.fillprice').val()
+									if(val){
+										$('.sell-sku-body-table.option').find('.price').val(val);
+									}else{
+										alert('请填写价格')
+									}
+
+								})
+								$('.fill').on('click','.custom_option_qty',function(){
+									val=$('.fillqty').val()
+									if(val){
+										$('.sell-sku-body-table.option').find('.qty').val(val);
+									}else{
+										alert('请填写库存')
+									}
+
+								})
+								$('.fill').on('click','.chose_custom_op_img',function(){
+									src=$('.chosened_img img').attr('src');
+									rel=$('.chosened_img img').attr('rel');
+									if(val){
+										$('.sell-sku-body-table.option').find('.sell-sku-cell-image img').attr('src',src).attr('rel',rel);
+									}else{
+										alert('请填写')
+									}
+
+								})
+								$('.fill').on('click','.custom_option_chose_image',function(){
+									var custom_option_image='';
+									$('.list.productimg .p_img img').each(function(){
+
+										custom_option_image+='<span>'
+										custom_option_image+='<img rel='+$(this).attr('rel')+' style="width:80px;" src="'+$(this).attr('src')+'">'
+										custom_option_image+='</span>'
+										
+									})
+									$('.custom_option_img_list').html(custom_option_image);
+
+								})
+								$('.sell-sku-body-table.option').on('click','.deleteoptionitem',function(){
+									$(this).parent('td').parent('tr').remove();
+								})
+							jQuery(document).on("click",".custom_option_img_list img",function(){	
+								rel = $(this).attr('rel');	
+								src = $(this).attr('src');	
+								$(".chosened_img").html('<img style="width:80px;" rel="'+rel+'" src="'+src+'">');	
+								$(".custom_option_img_list").slideUp("slow");	
+							});	
+                                
+                            });
+                        </script>
+			
+                        <table class="sell-sku-inner-table sell-sku-body-table option " style="transform: translateY(0px);">
+							
+                            <colgroup>
+                                <col width="111px">
+                                <col width="113px">
+                                <col width="109px">
+                                <col width="111px">
+                                <col width="194px">
+                                <col width="151px">
+                            </colgroup>
+                            <tbody>
+                                
                             </tbody>
                         </table>
                     </div>    

+ 67 - 4
vendor/fancyecommerce/fecshop/app/appadmin/theme/base/default/catalog/productoption/manageredit.php

@@ -25,24 +25,31 @@ use fecadmin\models\AdminRole;
 
 function thissubmit(thiss){
 	var fill = true;
-	items_input = "";
+	items_input = [];
     
     var display_type_select = $(".display_type_select").val();
+
     if (display_type_select == 'select' || display_type_select == 'editSelect') {
         $(".pageContent .items table tbody tr").each(function(){
             key_name = $(this).find(".key_name").val();
+            img=$(this).find('.img img').attr('rel');
+            item={"key":key_name}
+            if(img){
+                item.img=img
+            }
             //alert(search_engine);
             if (key_name){
-                items_input += key_name + "||";
+                items_input.push(item)
             } else {
                 fill = false
             }
         });
+
         if (fill == false) {
             alert('<?= Yii::$service->page->translate->__('can not empty'); ?>');
             return false;
         }
-        $(".items_input").val(items_input);
+        $(".items_input").val(JSON.stringify(items_input));
     } else {
         $(".items_input").val();
     }
@@ -92,6 +99,8 @@ function thissubmit(thiss){
                                         <thead>
                                             <tr>
                                                 <th><?=  Yii::$service->page->translate->__('Items') ?></th>
+                                                <th>图片</th>
+                                                <th>上传</th>
                                                 <th><?=  Yii::$service->page->translate->__('Action') ?></th>
                                             </tr>
                                         </thead>
@@ -102,6 +111,12 @@ function thissubmit(thiss){
                                                     <td>
                                                         <input class="key_name" type="text" value="<?= $one['key'] ?>">
                                                     </td>
+                                                    <td class='img'>
+                                                        <img width="30" src="<?= Yii::$service->image->getimgurl('media/catalog/customoption'.$one['img']); ?>" rel="<?=$one['img'] ?>" />
+                                                    </td>
+                                                    <td>
+                                                         <input   class="inputfile" type="file" />
+                                                    </td>
                                                     <td>
                                                         <i class="fa fa-trash-o"></i>
                                                     </td>
@@ -124,6 +139,8 @@ function thissubmit(thiss){
                                             $(".addItems").click(function(){
                                                 str = "<tr>";
                                                 str +="<td><input class=\"key_name textInput\" type=\"text\"   /></td>";
+                                                str +="<td class='img'></td>";
+                                                str +='<td><input class="inputfile" type="file"></td>';
                                                 str +="<td><i class='fa fa-trash-o'></i></td>";
                                                 str +="</tr>";
                                                 $(".items table tbody").append(str);
@@ -150,6 +167,52 @@ function thissubmit(thiss){
                                                     $(".display_itemcs").show();
                                                 }
                                             });
+                                            //响应文件添加成功事件
+                                            $('.items').on('change',".inputfile",function(){
+                                                //alert(thisindex);
+
+                                                that=this
+                                                var data = new FormData();
+                                                
+                                                //为FormData对象添加数据
+                                                $.each($(this)[0].files, function(i, file) {
+                                                    data.append('upload_file'+i, file);
+                                                });
+                                                //$(".loading").show();	//显示加载图片
+                                                //发送数据
+                                                data.append("<?= CRequest::getCsrfName() ?>", "<?= CRequest::getCsrfValue() ?>");
+                                                $.ajax({
+                                                    url:'<?= \fec\helpers\CUrl::getUrl('catalog/productoption/imageupload')  ?>',
+                                                    type:'POST',
+                                                    data:data,
+                                                    async:false,
+                                                    dataType: 'json', 
+                                                    timeout: 80000,
+                                                    cache: false,
+                                                    contentType: false,		//不可缺参数
+                                                    processData: false,		//不可缺参数
+                                                    success:function(data, textStatus){
+                                                        //data = $(data).html();
+                                                        //第一个feedback数据直接append,其他的用before第1个( .eq(0).before() )放至最前面。
+                                                        //data.replace(/&lt;/g,'<').replace(/&gt;/g,'>') 转换html标签,否则图片无法显示。
+                                                        //if($("#feedback").children('img').length == 0) $("#feedback").append(data.replace(/&lt;/g,'<').replace(/&gt;/g,'>'));
+                                                        //else $("#feedback").children('img').eq(0).before(data.replace(/&lt;/g,'<').replace(/&gt;/g,'>'));
+                                                    //	alert(data.return_status);
+                                                        if(data.return_status == "success"){
+                                                            alert("success");
+                                                            str='<img width="40" src="'+data.data.src+'" rel="'+data.data.rel+'">';
+                                                            $(that).parent('td').parent('tr').find('.img').html(str);
+                                                            // jQuery(".productimg tbody ").append(data.img_str);
+                                                            //alert(data.img_str);
+                                                        }
+                                                        //$(".loading").hide();	//加载成功移除加载图片
+                                                    },
+                                                    error:function(){
+                                                        alert('<?=  Yii::$service->page->translate->__('Upload Error') ?>');
+                                                        //$(".loading").hide();	//加载失败移除加载图片
+                                                    }
+                                                });
+                                            });
                                         });
                                     </script>
                                 </div>
@@ -166,7 +229,7 @@ function thissubmit(thiss){
 			<ul>
 				<!--<li><a class="buttonActive" href="javascript:;"><span>保存</span></a></li>-->
 				<li>
-                    <div class="buttonActive"><div class="buttonContent"><button onclick="func('accept')"  value="accept" name="accept" type="submit"><?= Yii::$service->page->translate->__('Save') ?></button></div></div>
+                    <div class="buttonActive"><div class="buttonContent"><button value="accept" name="accept" type="submit"><?= Yii::$service->page->translate->__('Save') ?></button></div></div>
                 </li>
 				<li>
 					<div class="button"><div class="buttonContent"><button type="button" class="close"><?= Yii::$service->page->translate->__('Cancel') ?></button></div></div>

+ 7 - 8
vendor/fancyecommerce/fecshop/app/appfront/modules/Catalog/block/product/CustomOption.php

@@ -75,16 +75,17 @@ class CustomOption
                 if (isset($info['display']['type']) && (in_array($info['display']['type'],['select','editSelect']))) {
                     if (isset($info['display']['data']) && is_array($info['display']['data'])) {
                         foreach ($info['display']['data'] as $val) {
-                            if (is_array($my_arr[$attr]) && in_array($val, $my_arr[$attr])) {
+                            if (is_array($my_arr[$attr]) && in_array($val['key'], $my_arr[$attr])) {
                                 $t_arr = [
-                                    'key' => $val,
-                                    'val' => $val,
+                                    'key' => $val['key'],
+                                    'val' => $val['key'],
                                 ];
                                 $require = isset($info['require']) ? $info['require'] : 0;
                                 if (isset($info['showAsImg']) && $info['showAsImg']) {
-                                    if (isset($img_arr[$val])) {
-                                        $t_arr['image'] = $img_arr[$val];
-                                    }
+                                    $t_arr['image'] = $val['img'];
+                                    // if (isset($img_arr[$val])) {
+                                    //     $t_arr['image'] = $img_arr[$val];
+                                    // }
                                 }
                                 $arr[$attr]['info'][] = $t_arr;
                                 $arr[$attr]['require'] = $require;
@@ -94,8 +95,6 @@ class CustomOption
                 }
             }
         }
-
-
         return $arr;
     }
 }

+ 13 - 3
vendor/fancyecommerce/fecshop/app/appfront/modules/Catalog/controllers/ProductController.php

@@ -98,11 +98,17 @@ class ProductController extends AppfrontController
     public function actionGetcoprice()
     {
         $custom_option_sku = Yii::$app->request->get('custom_option_sku');
+        
         $product_id = Yii::$app->request->get('product_id');
         $qty = Yii::$app->request->get('qty');
         $cart_price = 0;
         $custom_option_price = 0;
         $product = Yii::$service->product->getByPrimaryKey($product_id);
+        $custom_option=$product['custom_option'];
+        if(isset($custom_option[$custom_option_sku]['image'])&&!empty($custom_option[$custom_option_sku]['image'])){
+            // $picture=$custom_option[$custom_option_sku]['image'];
+            $picture=Yii::$service->product->image->getUrl($custom_option[$custom_option_sku]['image']);
+        }
         $cart_price = Yii::$service->product->price->getCartPriceByProductId($product_id, $qty, $custom_option_sku);
         if (!$cart_price) {
             return;
@@ -117,10 +123,14 @@ class ProductController extends AppfrontController
         $priceParam = [
             'price_info' => $price_info,
         ];
-
-        echo json_encode([
+        $data=[
             'price' =>Yii::$service->page->widget->render($priceView, $priceParam),
-        ]);
+        ];
+        if($picture){
+            $data['image']=$picture;
+        }
+
+        echo json_encode($data);
         exit;
     }
     

+ 13 - 3
vendor/fancyecommerce/fecshop/app/appfront/theme/base/front/catalog/product/index/custom_option.php

@@ -23,9 +23,9 @@
 <?php					$key 		= $one['key'];  ?>
 <?php					$image 		= $one['image'];  ?>
 			<?php   	if($image):  ?>
-				<li id="gal1">
-					<a data-image="<?= Yii::$service->product->image->getResize($image,$middle_img_width,false) ?>"  data-zoom-image="<?= Yii::$service->product->image->getUrl($image);  ?>"  attr="<?= $attr ?>"  class="imgshow active_v"  value="<?= $key ?>">
-						<img  src="<?= Yii::$service->product->image->getResize($image,[50,55],false) ?>" /></a>
+				<li id="">
+					<a    attr="<?= $attr ?>"  class="imgshow active_v"  value="<?= $key ?>">
+						<img  src="<?= Yii::$service->product->option->getResize($image,[50,55],false) ?>" /></a>
 					<b></b>
 				</li>
 			<?php   	else: ?>
@@ -222,7 +222,17 @@ $(document).ready(function(){
 						data: $data,
 						url:getCOUrl,
 						success:function(data, textStatus){ 
+
 							$(".price_info").html(data.price);
+							if(data.image){
+								var ez =   $('#zoom_03').data('elevateZoom')
+								var currentimg=ez.imageSrc;
+								small=$('.list-img').find('[data-zoom-image="'+data.image+'"]').data('image');
+								if(data.image!=currentimg){
+									ez.swaptheimage(data.image,small)
+									ez.imageSrc=data.image;
+								}
+							}
 						},
 						error:function (XMLHttpRequest, textStatus, errorThrown){}
 					});

+ 11 - 15
vendor/fancyecommerce/fecshop/services/Product.php

@@ -37,7 +37,6 @@ class Product extends Service
     public $customAttrGroup;
 
     public $customOptionGroup;
-    public $customOptionArr;
 
     public $categoryAggregateMaxCount = 5000; // Yii::$service->product->categoryAggregateMaxCount;
     /**
@@ -123,7 +122,7 @@ class Product extends Service
         $allGroupColl = $this->attrGroup->getActiveAllColl();
         // attr
         $allAttrColl = $this->attr->getActiveAllColl();
-        $customOptionArr=$this->customOptionArr;
+        $customOptionGroup=$this->customOptionGroup;
         $attrTypeColl = [];
         if ($allAttrColl) {
             foreach ($allAttrColl as $one) {
@@ -183,8 +182,8 @@ class Product extends Service
             }
         }
         foreach($customAttrGroupArr as $k=>$v){
-            if(isset($customOptionArr[$k])&& is_array($customOptionArr[$k])){
-                $customAttrGroupArr[$k]['custom_options']=$customOptionArr[$k];
+            if(isset($customOptionGroup[$k])&& is_array($customOptionGroup[$k])){
+                $customAttrGroupArr[$k]['custom_options']=$customOptionGroup[$k];
             }
         }
         $this->customAttrGroup = $customAttrGroupArr;
@@ -204,8 +203,8 @@ class Product extends Service
                 $attrTypeColl[$one[$attrPrimaryKey]] = $one;
             }
         }
-        $customOptionGroupArr = [];
-        $customOptionArr=[];
+
+        $customOptionGroup=[];
         if ($allGroupColl) {
             foreach ($allGroupColl as $one) {
                 $groupName = $one['name'];
@@ -247,19 +246,17 @@ class Product extends Service
                         $d_arr = [];
                         foreach ($attrOne['display_data'] as $o) {
                             if ($o['key']) {
-                                $d_arr[] = $o['key'];
+                                $d_arr[] = $o;
                             }
                         }
                         $displayInfo['data'] = $d_arr;
                     }
                     $attrInfo['display'] = $displayInfo;
-                    $customOptionGroupArr[$groupName][$attrType][$attrName] = $attrInfo;
-                    $customOptionArr[$groupName][$attrName]=$attrInfo;
+                    $customOptionGroup[$groupName][$attrName]=$attrInfo;
                 }
             }
         }
-        $this->customOptionGroup=$customOptionGroupArr;
-        $this->customOptionArr=$customOptionArr;
+        $this->customOptionGroup=$customOptionGroup;
     }
 
 
@@ -334,7 +331,6 @@ class Product extends Service
         
         return $arr;
     }
-    
     /**
      * @param $productAttrGroup|string
      * 得到这个产品属性组里面的所有的产品属性,
@@ -436,10 +432,10 @@ class Product extends Service
         if ($productAttrGroup == $this->_defaultAttrGroup) {
             return [];
         }
-        if (isset($this->customOptionArr[$productAttrGroup])
-                && is_array($this->customOptionArr[$productAttrGroup])
+        if (isset($this->customOptionGroup[$productAttrGroup])
+                && is_array($this->customOptionGroup[$productAttrGroup])
         ) {
-            return $this->customOptionArr[$productAttrGroup];
+            return $this->customOptionGroup[$productAttrGroup];
         }
         return [];
     }

+ 5 - 0
vendor/fancyecommerce/fecshop/services/product/Image.php

@@ -88,6 +88,11 @@ class Image extends Service
     {
         return Yii::$service->image->GetImgDir($this->imageFloder, 'common');
     }
+    protected function actionSetBaseDir($dir='')
+    {
+        $this->imageFloder=$dir;
+        return $this;
+    }
 
     /**
      * 通过产品图片的相对路径得到产品图片的url.

+ 79 - 0
vendor/fancyecommerce/fecshop/services/product/Option.php

@@ -50,6 +50,9 @@ class Option extends Service
      * @var \fecshop\services\product\ProductInterface 根据 $storage 及 $storagePath 配置的 Product 的实现
      */
     protected $_attr;
+    protected $_md5WaterImgPath;
+
+    protected $imageFloder='media/catalog/customoption';
 
 
     public function init()
@@ -161,6 +164,82 @@ class Option extends Service
         ];
         
     }
+    /**
+     * @param $imageVal | String ,图片相对路径字符串。
+     * @param $imgResize | Array or Int , 数组 [230,230] 代表生成的图片为230*230,如果宽度或者高度不够,则会用白色填充
+     *                  如果 $imgResize设置为 230, 则宽度不变,高度按照原始图的比例计算出来。
+     * @param $isWatered | Boolean , 产品图片是否打水印。
+     * 获取相应尺寸的产品图片。
+     */
+    protected function actionGetResize($imageVal, $imgResize, $isWatered = false)
+    {
+        list($newPath, $newUrl) = $this->getNewPathAndUrl($imageVal, $imgResize, $isWatered);
+        return $newUrl;
+    }
+    protected function actionGetNewPathAndUrl($imageVal, $imgResize, $isWatered = false)
+    {
+        $originImgPath = Yii::$service->image->GetImgDir($this->imageFloder.$str, 'common');
+        // if (!file_exists($originImgPath)) {
+        //     $originImgPath = Yii::$service->image->GetImgDir($this->imageFloder.$str, 'common');;
+        // }
+        $waterImgPath = '';
+        list($newPath, $newUrl) = $this->getProductNewPath($imageVal, $imgResize, $waterImgPath);
+        if ($newPath && $newUrl) {
+            if (!file_exists($newPath)) {
+                $options = [
+                    'png_compression_level' => $this->pngCompressionLevel,   
+                    'jpeg_quality'  => $this->jpegQuality,
+                ];
+                \fec\helpers\CImage::saveResizeMiddleWaterImg($originImgPath, $newPath, $imgResize, $waterImgPath, $options);
+            }
+
+            return [$newPath, $newUrl];
+        }
+    }
+      /**
+     * @param $imageVal | String ,图片相对路径字符串。
+     * @param $imgResize | Array or Int , 数组 [230,230] 代表生成的图片为230*230,如果宽度或者高度不够,则会用白色填充
+     *                  如果 $imgResize设置为 230, 则宽度不变,高度按照原始图的比例计算出来。
+     * @param $waterImgPath | String , 水印图片的路径
+     * 获取按照自定义尺寸获取的产品图片的文件绝对路径和完整url
+     */
+    protected function getProductNewPath($imageVal, $imgResize, $waterImgPath)
+    {
+        if (!$this->_md5WaterImgPath) {
+            if (!$waterImgPath) {
+                $waterImgPath = 'defaultWaterPath';
+            }
+            //echo $waterImgPath;exit;
+            $this->_md5WaterImgPath = md5($waterImgPath);
+        }
+
+        $baseDir = '/cache/'.$this->_md5WaterImgPath;
+        if (is_array($imgResize)) {
+            list($width, $height) = $imgResize;
+        } else {
+            $width = $imgResize;
+            $height = '0';
+        }
+
+        $imageArr = explode('/', $imageVal);
+        $dirArr = ['cache', $this->_md5WaterImgPath, $width, $height];
+        foreach ($imageArr as $igf) {
+            if ($igf !== '' && !strstr($igf, '.')) {
+                $dirArr[] = $igf;
+            }
+        }
+        $base=Yii::$service->image->GetImgDir($this->imageFloder, 'common');
+        $baseurl=Yii::$service->image->GetImgUrl($this->imageFloder, 'common');
+        $createDir = \fec\helpers\CDir::createFloder($base, $dirArr);
+        
+        if ($createDir) {
+            $newPath = $base.$baseDir .'/'.$width.'/'.$height.$imageVal;
+            $newUrl = $baseurl.$baseDir .'/'.$width.'/'.$height.$imageVal;
+            return [$newPath, $newUrl];
+        } else {
+            return [];
+        }
+    }