<!DOCTYPE html>
<html>
	<?php echo $this->fetch('head.html'); ?>
	<body>
		<div class="header">
			<div class="header-back"></div>
			<div class="header-title">产品编辑</div>
		</div>
		<div class="header-row"></div>
		<div class="main-body">
			<form action="/moduleshop.php?m=b2b_product&a=save&ajax=1">
				<input type="hidden" name="id" value="<?php echo $this->_var['data']['id']; ?>" />
				<div class="input-flex">
					<div class="input-flex-label">名称</div>
					<input type="text" name="title" value="<?php echo $this->_var['data']['title']; ?>" class="input-flex-text" />
				</div>
				<div class="input-flex">
					<div class="input-flex-label">平台大类</div>
					<select name="catid" class="input-flex-select">
						<option value="0">请选择</option>
						<?php $_from = $this->_var['catlist']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
							<option value="<?php echo $this->_var['c']['catid']; ?>" <?php if ($this->_var['data']['catid'] == $this->_var['c']['catid']): ?>selected<?php endif; ?>><?php echo $this->_var['c']['title']; ?></option>
							<?php if ($this->_var['c']['child']): ?>
							<?php $_from = $this->_var['c']['child']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'cc');if (count($_from)):
    foreach ($_from AS $this->_var['cc']):
?>
							<option value="<?php echo $this->_var['cc']['catid']; ?>" <?php if ($this->_var['data']['catid'] == $this->_var['cc']['catid']): ?>selected<?php endif; ?>>|--<?php echo $this->_var['cc']['title']; ?></option>
							<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
							<?php endif; ?>
						<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
					</select>
				</div>
				 <div class="input-flex">
				 	<div class="input-flex-label">店铺分类</div>
				 	<select name="shop_catid" class="input-flex-select">
				 		<option value="0">请选择</option>
				 		<?php $_from = $this->_var['shop_catlist']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
				 			<option value="<?php echo $this->_var['c']['catid']; ?>" <?php if ($this->_var['data']['shop_catid'] == $this->_var['c']['catid']): ?>selected<?php endif; ?>><?php echo $this->_var['c']['title']; ?></option>
				 			<?php if ($this->_var['c']['child']): ?>
				 			<?php $_from = $this->_var['c']['child']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'cc');if (count($_from)):
    foreach ($_from AS $this->_var['cc']):
?>
				 			<option value="<?php echo $this->_var['cc']['catid']; ?>" <?php if ($this->_var['data']['shop_catid'] == $this->_var['cc']['catid']): ?>selected<?php endif; ?>>|--<?php echo $this->_var['cc']['title']; ?></option>
				 			<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
				 			<?php endif; ?>
				 		<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
				 	</select>
				 </div> 
				<div class="textarea-flex" style="margin-bottom: 0;">
					<div class="textarea-flex-label">产品介绍</div>
					<textarea class="textarea-flex-text h60" name="description"><?php echo $this->_var['data']['description']; ?></textarea>
				</div>
				<div class="input-flex">
					<div class="input-flex-label">价格</div>
					<input type="text" name="price" value="<?php echo $this->_var['data']['price']; ?>" class="input-flex-text" />
				</div>
				<div class="input-flex">
					<div class="input-flex-label">库存</div>
					<input type="text" name="total_num" value="<?php echo $this->_var['data']['total_num']; ?>" class="input-flex-text" />
				</div>
				<div class="input-flex">
					<div class="input-flex-label">上架</div>
					<div class="switch-group">
						<div class="switch-left <?php if ($this->_var['data']['status'] == 1): ?>switch-active<?php endif; ?> js-switch" data-value="1">是</div>
						<div class="switch-right <?php if ($this->_var['data']['status'] != 1): ?>switch-active<?php endif; ?> js-switch" data-value="2">否</div>
						<input type="hidden" name="status" value="<?php echo $this->_var['data']['status']; ?>" class="switch-value" />
					</div>
				</div>
				<div class="input-flex">
					<div class="input-flex-label">推荐</div>
					<div class="switch-group">
						<div class="switch-left <?php if ($this->_var['data']['isrecommend'] == 1): ?>switch-active<?php endif; ?> js-switch" data-value="1">是</div>
						<div class="switch-right <?php if ($this->_var['data']['isrecommend'] != 1): ?>switch-active<?php endif; ?> js-switch" data-value="0">否</div>
						<input type="hidden" name="isrecommend" value="<?php echo $this->_var['data']['isrecommend']; ?>" class="switch-value" />
					</div>
				</div>
				<div class="input-flex">
					<div class="input-flex-label">新品</div>
					<div class="switch-group">
						<div class="switch-left <?php if ($this->_var['data']['isnew'] == 1): ?>switch-active<?php endif; ?> js-switch" data-value="1">是</div>
						<div class="switch-right <?php if ($this->_var['data']['isnew'] != 1): ?>switch-active<?php endif; ?> js-switch" data-value="0">否</div>
						<input type="hidden" name="isnew" value="<?php echo $this->_var['data']['isnew']; ?>" class="switch-value" />
					</div>
				</div>
				<div class="bg-fff mgb-5">
					<input type="hidden" name="imgsdata" id="imgsdata" value="<?php echo $this->_var['data']['imgsdata']; ?>" />
				<?php echo $this->fetch('inc/uploader-data.html'); ?>
				</div>
				<div class="flex bg-fff pd-10 mgb-5" id="vdApp">
					<div class="input-flex-label">商品视频</div>
					<div class="flex-1">
						<input type="hidden" v-model="videoid" name="videoid" id="videoid" />
						
						<div class="flex mgb-5">
							<div @click="videoClass='flex-col'" class="btn" id="js-choice-video">视频库</div>
						</div>
						<div class="flex-col">
							<img class="wmax" :src="videobg" />
						</div>
						<div :class="videoClass" class="modal-group">
							<div @click="videoClass=''" class="modal-mask"></div>
							<div class="modal">
								<div class="modal-header">
									<div class="modal-title">选择视频</div>
									<div  @click="videoClass=''"  class="modal-close icon-close"></div>
								</div>
								<div class="modal-body">
									<div v-for="(item,index) in list" :key="index" class="row-item-text">
										<div class="flex-1">{{item.title}}</div>
										<div @click="choiceVideo(item)" class="btn-small">选择</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="sky-editor-content" name="content" id="content" contenteditable="true"><?php echo $this->_var['data']['content']; ?></div>
				<div id="tableFieldBox">
					<?php echo $this->fetch('b2b_product/tablefields.html'); ?>
				</div> 
				<div  class="btn-row-submit js-submit">保存</div>
			</form>
		</div>
		 
		<?php echo $this->fetch('footer.html'); ?>
		<script src="/plugin/skyeditor/skyeditor.js"></script>
		 
		<script src="/plugin/lrz/lrz.bundle.js"></script>
		<script src="<?php echo $this->_var['skins']; ?>inc/uploader-data.js"></script>
		<script src="/plugin/vue/vue.min.js"></script>
		<script >
			var vdApp=new Vue({
				el:"#vdApp",
				data:function(){
					return {
						list:[],
						videoid:0,
						videobg:"",
						videoClass:""
					}
				},
				created:function(){
					this.getPage();
					<?php if ($this->_var['data']): ?>
						this.videoid="<?php echo $this->_var['data']['videoid']; ?>";
						this.videobg="<?php echo $this->_var['data']['videobg']; ?>";
					<?php endif; ?>
				},
				methods:{
					choiceVideo:function(item){
						this.videoid=item.id;
						this.videobg=item.imgurl;
						this.videoClass="";
					},
					getPage:function(){
						var that=this;
						$.ajax({
							url:"/moduleshop.php?m=b2b_video&type=online&ajax=1",
							dataType:"json",
							success:function(res){
								that.list=res.data.list;
							}
						})
					}
				}
			})
		</script>
	</body>
</html>
