NoteStar преди 5 години
родител
ревизия
f7cd911d2a

+ 4 - 3
apphtml5/theme/terry/theme01/assets/css/fec.css

@@ -194,7 +194,8 @@ a{font-size:0.8em;}
 .pg .label {
    float: left;
     font-size: 0.5rem;
-    width: 2.4rem;
+    min-width: 2.4rem;
+    max-width: 4.2rem;
 }
 
 
@@ -224,7 +225,7 @@ a{font-size:0.8em;}
     float: left;
     height: 49px;
     padding: 1px;
-    width: 44px;
+    min-width: 44px;
 	line-height:49px;
 }
 
@@ -272,7 +273,7 @@ a{font-size:0.8em;}
     height: 44px;
     line-height: 44px;
     min-width: 15px;
-    padding: 0px;
+    padding: 0px 5px;
 	text-align:center;
 }
 

+ 94 - 0
apphtml5/theme/terry/theme01/catalog/product/index.php

@@ -87,6 +87,50 @@
 					?>
 					<?= Yii::$service->page->widget->render($optionsView,$optionsParam); ?>
 				</div>
+
+                <!-- 自定义界面Star -->
+                <div class="product_custom_options">
+                    <?php
+                    $groupAttrArr = [
+                        'Bust'=>'80',
+                        'Waist'=>'60',
+                        'Hips'=>'70',
+                        'Hollow to floor'=>'60',
+                    ];
+                    ?>
+                    <div id="user_custom">
+                        <?php if(is_array($groupAttrArr)): ?>
+                            <?php  echo "<table style='line-height: 1rem;' ><tr><td width='40%'><div>"; ?>
+                            <?php foreach($groupAttrArr as $k => $v): ?>
+                                <?= "".$k."</br>"; ?>
+                            <?php endforeach; ?>
+                            <?php echo "</div></td><td><div id='my_size_box'>" ?>
+                            <?php foreach($groupAttrArr as $k => $v): ?>
+                                <?= "".$v."cm</br>"; ?>
+                            <?php endforeach; ?>
+                            <?php echo "</div></td></tr></table>" ?>
+                        <?php endif; ?>
+
+                    </div>
+                    <div id="user_custom_content" style="display: none;">
+
+                        <?php if(is_array($groupAttrArr)): ?>
+                            <?php  echo "<table style='line-height: 1rem;'><tr><td width='40%'><div>"; ?>
+                            <?php foreach($groupAttrArr as $k => $v): ?>
+                                <?= "".$k."</br>"; ?>
+                            <?php endforeach; ?>
+                            <?php echo "</div></td><td><div>" ?>
+                            <?php foreach($groupAttrArr as $k => $v): ?>
+                                <input class="custom_op" type="number" min="1" max="500" attr="<?=$k?>" style="width: 50px;">cm</br>
+                            <?php endforeach; ?>
+                            <?php echo "</div></td></tr></table>" ?>
+                        <?php endif; ?>
+
+                    </div>
+                </div>
+
+                <!-- 自定义界面End -->
+
 				<div class="product_qty pg">
 					<div class="label"><?= Yii::$service->page->translate->__('Qty:'); ?></div>
 					<div class="rg">
@@ -253,6 +297,32 @@
 			error:function (XMLHttpRequest, textStatus, errorThrown){}
 		});
 
+
+        //自定义JS
+        $(".my_sizebj").click(function(){
+            var my_size = $(this).text();
+            var my_size_attr = new Array();
+            my_size_attr['s'] = new Array('80','60','70','90');
+            my_size_attr['m'] = new Array('90','70','80','100');
+            my_size_attr['xl'] = new Array('100','80','90','110');
+
+            if(my_size == 'CustomSize'){
+                $("#user_custom").css('display','none');
+                $("#user_custom_content").css('display','block');
+            }else{
+                $("#user_custom").css('display','block');
+                $("#user_custom_content").css('display','none');
+                var my_size_for = my_size_attr[my_size];
+                var my_size_html = '';
+                var x;
+                for(x in my_size_for){
+                    my_size_html += my_size_for[x] + "cm<br/>";
+                }
+                $("#my_size_box").html(my_size_html);
+
+            }
+        });
+
 		$(".addProductToCart").click(function(){
 			i = 1;
 			$(".product_custom_options .pg .rg ul.required").each(function(){
@@ -274,6 +344,29 @@
 					custom_option[attr] = value;
 				});
 				custom_option_json = JSON.stringify(custom_option);
+
+
+                var a = $(".current.my_sizebj").text();
+                if(a == 'CustomSize'){
+                    customsize = new Object();
+                    $("input.custom_op").each(function(){
+                        attr = $(this).attr("attr");
+                        value = $(this).val();
+                        customsize[attr] = value;
+
+                        if(value == ''){
+                            alert("Please fill in "+ attr);
+                            throw SyntaxError();
+                        }
+
+                    });
+                    customsize = JSON.stringify(customsize);
+                }else{
+
+                    customsize = '';
+                }
+
+
 				//alert(custom_option_json);
 				sku = $(".sku").val();
 				qty = $(".qty").val();
@@ -290,6 +383,7 @@
 				$data['custom_option'] 	= custom_option_json;
 				$data['product_id'] 	= "<?= $_id ?>";
 				$data['qty'] 			= qty;
+                $data['customsize']     = customsize;
 				if (csrfName && csrfVal) {
 					$data[csrfName] 		= csrfVal;
 				}

+ 1 - 1
apphtml5/theme/terry/theme01/catalog/product/index/custom_option.php

@@ -30,7 +30,7 @@
 				</li>
 <?php   	            else: ?>
 				<li>
-					<a attr="<?= $attr ?>" class="noimgshow active_v" value="<?= $key ?>"><?= Yii::$service->page->translate->__($val); ?></a>
+					<a attr="<?= $attr ?>" class="noimgshow active_v <?= $attr ?>bj" value="<?= $key ?>"><?= Yii::$service->page->translate->__($val); ?></a>
 					<b></b>
 				</li>
 <?php   				endif;  ?>