<!--packageE/community_buying/buying_personal/buying_personal.wxml-->

<view change:themeColor="{{themeTool.changeThemeColor}}"
themeColor="{{themeColor}}"
></view>
<import src="../../../wxParse/wxParse.wxml" />
<view class="header">
	<view class="container themeDiyBackground">
		<view class="face">
			<image src="{{deliver.avatar}}"></image>
		</view>
		<view class="desc">
			<view class="name">{{deliver.deliver_name}}</view>
			<view class="region">
				<text class="iconfont icon-fontclass-dizhi"></text>
				<text>{{deliver.address}}</text>
			</view>
			<view class="address">提货地址：{{deliver.full_address}}</view>
		</view>
		<view class="buyInfo themeDiyColor" bindtap="gotoBusinessInfo" wx:if="{{deliver.thumb.length>0 || deliver.aptitute.length>0}}">商家信息</view>
	</view>
</view>

<view class="notice">
	<text class="iconfont icon-fontclass-gonggao themeDiyColor"></text>
	<view class="notice-main">
		<!-- <rich-text nodes="{{group.description}}"></rich-text> -->
		<block wx:if="{{article.nodes}}">
      <template is="wxParse" data="{{wxParseData:article.nodes}}" />
    </block>
	</view>
	
</view>

<view class="countdown">
	<block wx:if="{{group.group_status!=2}}">
		<view style="display:flex;align-items:center;"><text class="iconfont icon-naozhong themeDiyColor"></text> 距离活动<text wx:if="{{group.group_status==0}}">开始</text>
			<text wx:if="{{group.group_status==1}}">结束</text>还剩</view> 
		<van-count-down use-slot time="{{ time }}" bind:change="onChangeTime">
			<view class="bottom_time">
				<text class="radius-box themeDiyBackground">{{ timeData.days }}</text>
				<text class="text">天</text>
				<text class="radius-box themeDiyBackground">{{ timeData.hours }}</text>
				<text class="text">:</text>
				<text class="radius-box themeDiyBackground">{{ timeData.minutes }}</text>
				<text class="text">:</text>
				<text class="radius-box themeDiyBackground">{{ timeData.seconds }}</text>
			</view>
		</van-count-down>
	</block>
	<block wx:else>
		<view>活动已结束</view>
	</block>
</view>




<view class="goods-list">
	<view class="good-child" wx:for="{{group.deliver_goods}}" bindtap="openGoodsDetail" wx:key="id" data-item="{{item}}">
		<view class="good-img">
			<image src="{{item.thumb}}"></image>
		</view>
		<view class="good-info">
			<view class="good-title">{{item.title}}</view>
			<view class="goods-purchased">
				<text class="iconfont icon-fontclass-redu"></text>
				<text class="text">销量 {{item.show_sales}}   </text>
				<text class="iconfont icon-fontclass-kucun"></text>
				<text class="text">库存{{item.stock}}件</text>
				
			</view>
			<view class="good-buy">
				<view class="good-price themeDiyColor">
					<!-- {{ $i18n.t('money') }} -->
					{{language['money']}}
					<view class="price">{{item.price}}</view>
					<text wx:if="{{item.has_option==1}}">起</text> 
				</view>
				<view class="select" wx:if="{{item.has_option==0}}" catchtap>
					<icon catchtap="reduceCartNum" wx:if="{{goodsCartsTotal[item.id] && goodsCartsTotal[item.id].total>0}}" data-cartid="{{goodsCartsTotal[item.id].id}}" data-item="{{item}}" class="iconfont icon-life-game-sign themeDiyBackground"></icon>
						<input disabled="{{disabledInp}}" catchblur="updateCartNum" data-cartid="{{goodsCartsTotal[item.id].id}}" data-item="{{item}}" wx:if="{{goodsCartsTotal[item.id] && goodsCartsTotal[item.id].total>0}}" type="number" value="{{goodsCartsTotal[item.id].total}}" style="width:50rpx;text-align:center;margin:0 8px;" />
						<icon catchtap="addCartNum" data-item="{{item}}" data-cartid="{{goodsCartsTotal[item.id].id}}" confirm-type="done" class="iconfont icon-life-game-plus themeDiyBackground"></icon>
				</view>
				<view class="select" wx:if="{{item.has_option==1}}" catchtap="openSpecs" data-item="{{item}}">
					<view class="option-text-btn themeDiyBackground">选规格<text class="num themeDiyBackground" wx:if="{{goodsCartsTotal[item.id]}}">{{ goodsCartsTotal[item.id].total }}</text></view>
				</view>
				
			</view>
		</view>
	</view>
</view>


<block wx:if="{{specsShow}}">
	<yz-specs class="componentsThemeColor" goodsInfo="{{hand_goods_obj}}" cartList="{{carList}}" popupSpecs="{{specsShow}}" bind:closeSpecsPopup="close_yz_specs_popup"></yz-specs>
</block>

<yz-goodsPopup show="{{goodsPopupShow}}" bind:addCart="goodsDetailCartAdd" goodsInfo="{{hand_goods_obj}}" ></yz-goodsPopup>

<yz-cartList class="componentsThemeColor" show="{{cartListShow}}" cardata="{{carList}}" bind:cartInputBlur="cartListInputBlur" bind:addCart="cartListAdd" bind:reduceCart="cartListReduce" bind:popupcartListbtn="close_yz_cartList_popup">
	<view class="bottom-car" slot="button">
		<view class="car-box themeDiyBorder">
			<view class="car-num themeDiyColor" bindtap="openCartListPopup">
				<view class="car-num-box">
					<icon class="iconfont icon-all_buycar themeDiyColor"></icon>
					<view class="carnum-style themeDiyBackground" >{{ cartsNum }}</view>
				</view>
				<view class="small-price">
					{{language['money']}}
				</view>
				{{cartsTotal}}
			</view>
			<view class="car-add themeDiyBackground" bindtap="checkGoods" >结算</view>
		</view>
		
	</view>
</yz-cartList>


<!-- 底部购物车 -->
<view class="bottom-car">
	<view class="car-box themeDiyBorder" wx:if="{{group.group_status!=2}}">
		<view class="car-num themeDiyColor" bindtap="openCartListPopup" >
			
			<view class="car-num-box">
				<icon class="iconfont icon-all_buycar themeDiyColor"></icon>
				<view class="carnum-style themeDiyBackground" >{{ cartsNum }}</view>
			</view>
			<view class="small-price">
				{{language['money']}}
			</view>
			{{cartsTotal}}
		</view>
		<view class="car-add themeDiyBackground" bindtap="checkGoods">结算</view>
	</view>
	<view wx:else class="car-box endstyle">活动已结束</view>
</view>



<!-- 
<van-popup show="{{showChoose}}" round close-on-click-overlay="true" custom-style="width: 600rpx;border-radius: 30rpx;">
	<view class="wrapper">
		<view class="block">
			<view class="choose-title">
				您的购物车配送方式有冲突，请选择其中一种配送方式~
			</view>

			<view class="choose-content">
				<van-radio-group value="{{radioChoose}}" bind:change="typeChange">
					<view wx:for="{{dispatch_types}}" wx:for-item="item" wx:for-index="idx" wx:key="idx" style="padding: 20rpx 0;">
						<van-radio name="{{idx}}" checked-color="#ff4949">
							<view class="radio-title">{{item.name}}({{item.member_carts.length}}件)</view>
						</van-radio>
						<view class="radio-list ul">
							<view class="radio-item li" wx:for="{{item.member_carts}}" wx:for-item="goods" wx:for-index="i" wx:key="{{i}}">
								<view class="p">{{goods.title}}</view>
								<view class="p" wx:if="{{goods.option_title}}" style="font-size: 12px;color: #666666;">规格：{{goods.option_title}}</view>
							</view>
						</view>
					</view>
				</van-radio-group>
			</view>

			<view class="buttons">
				<view class="button-item">
					<view class="button-content" catchtap="closeChoose">返回</view>
				</view>
				<view class="button-item">
					<view class="button-content red" catchtap="submitGoods">去结算</view>
				</view>
			</view>
		</view>
	</view>
</van-popup> -->



<van-share-sheet show="{{ shareShow }}" bind:select="onSelectShare" options="{{ shareOptions }}" bind:close="onCloseShare" />
<buying-qrcode isshow="{{posterShow}}" buyingid="{{group_id}}" deliverid="{{deliver_id}}" ></buying-qrcode>
<float-btn class="componentsThemeColor" bind:openShare="openShareShow" isDeliverShow="{{deliver.isManager}}" ></float-btn>





<wxs module="themeTool">
	var color="";
	function setDiyBackground(nodes){
		for(var i=0;i<nodes.length;i++){
			if(nodes[i]){
				nodes[i].setStyle({
					"background":color
				})
			}
		}
	}
	function setDiyColor(nodes){
		console.log("nodes",nodes.length)
		for(var i=0;i<nodes.length;i++){
			if(nodes[i]){
				nodes[i].setStyle({
					"color":color
				})
			}
		}
	}
	function setDiyBorder(nodes){
		for(var i=0;i<nodes.length;i++){
			if(nodes[i]){
				nodes[i].setStyle({
					"border-color":color
				})
			}
		}
	}
	function setComponentsColor(nodes){
		for(var i=0;i<nodes.length;i++){
			if(nodes[i]){
				selectedTypeNodes(nodes[i])
			}
		}
	}
	function selectedTypeNodes(nodes){
		nodes.setStyle({"--themeColor":color})
		var componentsThemeColor = nodes.selectAllComponents('.componentsThemeColor');
		if(componentsThemeColor.length>0){
			setComponentsColor(componentsThemeColor);
		}
		//var themeDiyBackground = nodes.selectAllComponents('.themeDiyBackground');
		//console.log("themeDiyColor",themeDiyBackground.length);
		//setDiyBackground(themeDiyBackground);

		// var themeDiyColor = nodes.selectAllComponents('.themeDiyColor');
		// setDiyColor(themeDiyColor);

		// var themeDiyBorder = nodes.selectAllComponents('.themeDiyBorder');
		// setDiyBorder(themeDiyBorder);


	}
	function changeThemeColor(newValue, oldValue, ownerInstance, instance){
		color = newValue;
		ownerInstance.setStyle({"--themeColor":color})
	//	selectedTypeNodes(ownerInstance);
	}

	module.exports ={
		changeThemeColor:changeThemeColor
	}
</wxs>













