//左部模块组件
var left_html;
Vue.component('diy-left-main', {
	props : ['left'],
	data : function() {
		return {
			xqdata : [
				/*{'data_type':1,'data_name':'富文本'},*/
				{'data_type':2,'data_name':'标题'},
				{'data_type':3,'data_name':'商品'},
				{'data_type':4,'data_name':'商品<br />列表'},
				{'data_type':5,'data_name':'<b>商品<br />搜索</b>'},
				{'data_type':6,'data_name':'图片<br />导航'},
				{'data_type':7,'data_name':'图片<br />广告'},
				{'data_type':8,'data_name':'分割线'},
				{'data_type':9,'data_name':'辅助<br />空白'},
				{'data_type':16,'data_name':'辅助<br />透明'},
				{'data_type':18,'data_name':'促销<br />活动'},
				{'data_type':10,'data_name':'顶部<br />菜单'},
				{'data_type':11,'data_name':'橱窗1'},
				{'data_type':12,'data_name':'橱窗2'},
				{'data_type':13,'data_name':'橱窗3'},
				{'data_type':14,'data_name':'橱窗4'},
				{'data_type':15,'data_name':'橱窗5'},
			],
		}
	},
	template : left_html,
	created:function(){
		//渲染前追加
		left_html+='<ul class="clearfix diy-left-main">';
		left_html+='<li v-for="(vo,index) in this.xqdata" @click="leftadd(vo.data_type)"><a href="javascript:;" class="hc-diy-addModule" :data-type="vo.data_type"><b v-html="vo.data_name"></b><img src="/Public/drag/images/two-columns-text.png"></a></li>';
		left_html+='</ul>';
		this.$options.template=left_html;
	},
	mounted : function() {
		//前置操作
	},
	methods : {
		leftadd : function(val) {
			var moduleData = new Object;
			switch (val) {
				//富文本
				case 1:
					moduleData.content = {
						name: "『富文本编辑器』",
					};
					break;
				//标题
				case 2:
					moduleData.content = {
						name: "标题名称",
						titlestyle:0,
						direction:'left',
						nav_list: [
							{
								link: "#",
								is_url:false,
								url:'',
								is_param:false,
								url_param:'',
								title: "标题链接",
								showtitle: "标题链接",
								img: "/Public/drag/images/waitupload.png"
							}
						]
					};
					break;
				//商品
				case 3:
					moduleData.content = {
						layout: 1,
						showPrice: true,
						showIco: true,
						showName: true,
						group: null,
						firstPriority: 1,
						secondPriority: 3,
						thirdPriority: 5,
						goodsize: 6,
						isadd: 0,
						goodslist:[
							{
								goodsItem_id: "1",
								link: "#",
								img: "/Public/drag/images/goodsItem1.jpg",
								price: "¥100.00",
								del_price: "¥200.00",
								title: "第一个商品"	
							},
							{
								goodsItem_id: "2",
								link: "#",
								img: "/Public/drag/images/goodsItem2.jpg",
								price: "¥200.00",
								del_price: "¥300.00",
								title: "第二个商品"	
							},
							{
								goodsItem_id: "3",
								link: "#",
								img: "/Public/drag/images/goodsItem3.jpg",
								price: "¥300.00",
								del_price: "¥400.00",
								title: "第三个商品"	
							},
							{
								goodsItem_id: "4",
								link: "#",
								img: "/Public/drag/images/goodsItem4.jpg",
								price: "¥400.00",
								del_price: "¥500.00",
								title: "第四个商品"	
							}
						],
						initgoodslist: [
							{
								goodsItem_id: "1",
								link: "#",
								img: "/Public/drag/images/goodsItem1.jpg",
								price: "¥100.00",
								del_price: "¥200.00",
								title: "第一个商品"	
							},
							{
								goodsItem_id: "2",
								link: "#",
								img: "/Public/drag/images/goodsItem2.jpg",
								price: "¥200.00",
								del_price: "¥300.00",
								title: "第二个商品"	
							},
							{
								goodsItem_id: "3",
								link: "#",
								img: "/Public/drag/images/goodsItem3.jpg",
								price: "¥300.00",
								del_price: "¥400.00",
								title: "第三个商品"	
							},
							{
								goodsItem_id: "4",
								link: "#",
								img: "/Public/drag/images/goodsItem4.jpg",
								price: "¥400.00",
								del_price: "¥500.00",
								title: "第四个商品"	
							}
						]
					};
					break;
					//商品列表
				case 4:
					moduleData.content = {
						layout: 1,
						showPrice: true,
						showIco: true,
						showName: true,
						goodsNum:6,
						firstPriority: 0,
						secondPriority: 0,
						thirdPriority: 0,
						is_timelimit : 1,
						goodslist: [
							{
								goodsItem_id: "1",
								link: "#",
								img: "/Public/drag/images/goodsItem1.jpg",
								price: "¥100.00",
								del_price: "¥200.00",
								title: "第一个商品"	
							},
							{
								goodsItem_id: "2",
								link: "#",
								img: "/Public/drag/images/goodsItem2.jpg",
								price: "¥200.00",
								del_price: "¥300.00",
								title: "第二个商品"	
							},
							{
								goodsItem_id: "3",
								link: "#",
								img: "/Public/drag/images/goodsItem3.jpg",
								price: "¥300.00",
								del_price: "¥400.00",
								title: "第三个商品"	
							},
							{
								goodsItem_id: "4",
								link: "#",
								img: "/Public/drag/images/goodsItem4.jpg",
								price: "¥400.00",
								del_price: "¥500.00",
								title: "第四个商品"	
							}
						]
					};
					break;
				//商品搜索
				case 5:
					moduleData.content = {
						name: "标题名称",
					};
					break;
				//图片导航
				case 6:
					moduleData.content = {
						nav_list: [
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							title: "导航名称",
							showtitle: "导航名称",
							img: "/Public/drag/images/waitupload.png"
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							title: "导航名称",
							showtitle: "导航名称",
							img: "/Public/drag/images/waitupload.png"
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							title: "导航名称",
							showtitle: "导航名称",
							img: "/Public/drag/images/waitupload.png"
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							title: "导航名称",
							showtitle: "导航名称",
							img: "/Public/drag/images/waitupload.png"
						}]
					};
					break;
				//图片广告
				case 7:
					moduleData.content = {
						showType:1,
						space:1,
						height:10,
						nav_list: [
							{
								link: "#",
								is_url:false,
								url:'',
								is_param:false,
								url_param:'',
								title: "标题",
								showtitle: "标题",
								img: "/Public/drag/images/waitupload.png"
							}
						]
					};
					break;
				//分割线
				case 8:
					moduleData.content = {};
					break;
				//辅助留白
				case 9:
					moduleData.content = {
						height: 10
					};
					break;
				//辅助背景
				case 16:
				moduleData.content = {
					height: 10
				};
				break;
				//顶部菜单
				case 10:
					moduleData.content = {
						style: '0',
						marginstyle: '0',
						nav_list: [
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							showtitle: "首页",
							title: "首页",
							img: "/Public/drag/images/icon_home.png",
							bgColor: "#07a0e7",
							cloPicker: '0',
							fotColor: '#fff'
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							showtitle: "新品",
							title: "新品",
							img: "/Public/drag/images/icon_newgoods.png",
							bgColor: "#72c201",
							cloPicker: '1',
							fotColor: '#fff'
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							showtitle: "热卖",
							title: "热卖",
							img: "/Public/drag/images/icon_hotsale.png",
							bgColor: "#ffa800",
							cloPicker: '2',
							fotColor: '#fff'
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							showtitle: "会员主页",
							title: "会员主页",
							img: "/Public/drag/images/icon_user.png",
							bgColor: "#d50303",
							cloPicker: '3',
							fotColor: '#fff'
						}
						]
					};
					break;
				//橱窗1
				case 11:
					moduleData.content = {
						layout: 1,                    
						poster_list: [
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_1.jpg",
							title: "第一个商品"	
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_2.jpg",
							title: "第二个商品"	
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_3.jpg",
							title: "第三个商品"	
						}
						]
					};
					break;
				//橱窗2
				case 12:
					moduleData.content = {
						layout: 1,                    
						poster_list: [
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_1_1.jpg",
							title: "第一个商品"	
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_1_2.jpg",
							title: "第二个商品"	
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_1_3.jpg",
							title: "第三个商品"	
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_1_4.jpg",
							title: "第三个商品"	
						}
						]
					};
					break;
				//橱窗3
				case 13:
					moduleData.content = {
						layout: 1,                    
						poster_list: [
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_2_1.jpg",
							title: "第一个商品"	
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_2_2.jpg",
							title: "第二个商品"	
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_2_3.jpg",
							title: "第三个商品"	
						}

						]
					};
					break;
				//橱窗4
				case 14:
					moduleData.content = {
						layout: 1,                    
						poster_list: [
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_3_1.jpg",
							title: "第一个商品"	
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_3_2.jpg",
							title: "第二个商品"	
						}
						]
					};
					break;
				//橱窗5
				case 15:
					moduleData.content = {
						layout: 1,                    
						poster_list: [
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_4_5.jpg",
							title: "第三个商品"	
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_4_6.jpg",
							title: "第三个商品"	
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_4_7.jpg",
							title: "第三个商品"	
						},
						{
							link: "#",
							is_url:false,
							url:'',
							is_param:false,
							url_param:'',
							img: "/Public/drag/images/group_4_8.jpg",
							title: "第三个商品"	
						}
						]
					};
					break;
				//优惠活动
				case 18:
					moduleData.content = {
						num:1,
						promot_list:[
							{
								img: "Public/drag/images/activity_img.png",
							}
						]
					};
				break;
			}
			moduleData.data_type= val;
			var self = this;
			self.getTimestamp(function(val){
				moduleData.id = val;
				self.$emit('leftok',moduleData);//向主Vue传递数据
			});
		},
		//获取当前时间戳
		getTimestamp : function (callback) {
			var date = new Date();
			callback("" + date.getFullYear() + parseInt(date.getMonth() + 1) + date.getDate() + date.getHours() + date.getMinutes() + date.getSeconds() + date.getMilliseconds());
		}
	}
})