dever 5 years ago
parent
commit
665a186b44

+ 1 - 1
lib/dever/components/drawerPage.vue

@@ -26,7 +26,7 @@ export default {
 	transition: all 0.4s;
 }
 
-.DrawerPage.left {
+.DrawerPage.left1 {
 	transform: scale(0.9, 0.9);
 	left: 85vw;
 	box-shadow: 0 0 60upx rgba(0, 0, 0, 0.2);

+ 35 - 6
lib/dever/components/drawerWindow.vue

@@ -1,9 +1,9 @@
 <template name="drawerWindow">
 	<view :style="{background:background,zIndex:zIndex, top:top+'px'}">
-		<view class="DrawerClose" :class="show ? 'show':''" @tap="hideModal">
+		<view class="DrawerClose" :class="show ? direction:default_direction" @tap="hideModal">
 			<text class="cuIcon-pullright"></text>
 		</view>
-		<scroll-view scroll-y class="DrawerWindow" :class="show ? 'show':''" :style="{width:width,padding:padding, zIndex:zIndex+1, background:slotBg}" @tap.stop="stopFun" @touchstart="Dever.slide" @touchend="end">
+		<scroll-view scroll-y class="DrawerWindow" :class="show ? direction:default_direction" :style="{width:width,padding:padding, zIndex:zIndex+1, background:slotBg}" @tap.stop="stopFun" @touchstart="Dever.slide" @touchend="end">
 			<view class="cu-list menu card-menu margin-top-xl margin-bottom-xl shadow-lg" v-if="show">
 				<slot name="links"></slot>
 			</view>
@@ -58,9 +58,12 @@ export default {
 	},
 	data() {
 		return {
-			
+			default_direction:'default_left'
 		};
 	},
+	mounted() {
+		this.default_direction = 'default_' + this.direction;
+	},
 	methods:{
 		closeDrawer : function(){
 			this.$emit('closeDrawer');
@@ -90,17 +93,33 @@ export default {
 	width: 85vw;
 	height: 100vh;
 	left: 0;
-	top: 0;
+	top: 0;
 	transform: scale(0.9, 0.9) translateX(-100%);
 	opacity: 0;
 	pointer-events: none;
 	transition: all 0.4s;
+}
+
+.DrawerWindow.default_left {
+	transform: scale(1, 1) translateX(-100%);
+	opacity: 1;
+	pointer-events: all;
 }
 
-.DrawerWindow.show {
+.DrawerWindow.left {
 	transform: scale(1, 1) translateX(0%);
 	opacity: 1;
 	pointer-events: all;
+}
+
+.DrawerWindow.default_down {
+	transform: scale(1, 1) translateY(100%);
+}
+
+.DrawerWindow.down {
+	transform: scale(1, 1) translateY(20%);
+	opacity: 1;
+	pointer-events: all;
 }
 
 .DrawerClose {
@@ -122,10 +141,20 @@ export default {
 	transition: all 0.4s;
 }
 
-.DrawerClose.show {
+.DrawerClose.left {
 	opacity: 1;
 	pointer-events: all;
 	width: 15vw;
 	color: #fff;
+}
+
+.DrawerClose.down {
+	opacity: 0;
+	pointer-events: all;
+	width: 15vw;
+	color: #fff;
+}
+.card-menu {
+	border-radius: 0px;
 }
 </style>

+ 6 - 14
pages/dream/func/cate.vue

@@ -46,10 +46,6 @@
 export default {
 	name: "cate",
 	props: {
-		info_id : {
-			type : String,
-			value : null
-		},
 		content_id : {
 			type : String,
 			value : null
@@ -58,20 +54,21 @@ export default {
 			type : String,
 			value : null
 		},
-		parent_page_id : {
-			type : String,
-			value : null
-		},
 		width : {
 			type : String,
 			default : '100%'
 		},
+		code : {
+			type : String,
+			default : ''
+		},
 		param : {},
 		index : 0
 	},
 	data() {
 		return {
 			swiperList: [],
+			fetch : {},
 		}
 	},
 	created() {
@@ -79,12 +76,7 @@ export default {
 	},
 	methods:{
 		getData : function() {
-			var info = {
-				info_id : this.info_id,
-				page_id : this.page_id,
-				parent_page_id : this.parent_page_id,
-			}
-			this.$emit('getCate', info);
+			this.$emit('getCate');
 		},
 		choose : function(id) {
 			if (this.fetch.show[id] == 1) {

+ 5 - 13
pages/dream/func/community.vue

@@ -27,26 +27,18 @@ import uniLoadMore from "@/lib/uni-load-more/uni-load-more.vue"
 export default {
 	name: "community",
 	props: {
-		info_id : {
-			type : String,
-			value : null
-		},
 		content_id : {
 			type : String,
 			value : null
 		},
-		page_id : {
-			type : String,
-			value : null
-		},
-		parent_page_id : {
-			type : String,
-			value : null
-		},
 		width : {
 			type : String,
 			default : '100%'
 		},
+		code : {
+			type : String,
+			default : ''
+		},
 		param : {},
 		index : 0
 	},
@@ -76,7 +68,7 @@ export default {
 		},
 		getData : function() {
 			var self = this;
-			this.Dever.get(this, 'app/community/?l=api.category', {info_id:this.info_id, page_id:this.page_id, content_id:this.content_id,noloading:1}, function(t) {
+			this.Dever.get(this, 'app/community/?l=api.category', {code:this.code, content_id:this.content_id,noloading:1}, function(t) {
 				if (t && t.cate.length > 0 && t.cate[self.activeTab]) {
 					self.getInfo(t.cate[self.activeTab].id, 1);
 				}

+ 85 - 0
pages/dream/func/shop.vue

@@ -0,0 +1,85 @@
+<template name="shop">
+	<view>
+		<view class="grace-space-between">
+			<view class="grace-waterfall-item" v-for="(v, k) in productList" :key="k">
+				<view class="grace-img-card-item" v-for="(v1, k1) in v" :key="k1">
+					<image :src="v1.pic_cover" mode="widthFix" class="grace-waterfall-img" style="height:auto"></image>
+					<text class="grace-img-card-title">{{v1.name}}</text>
+					<view class="grace-img-card-more">
+						<text class="grace-img-card-price">¥99.99</text>
+						<text class="grace-img-card-btn">购买</text>
+					</view>
+				</view>
+			</view>
+		</view>
+		<graceLoading :loadingType="loadingType"></graceLoading>
+	</view>
+</template>
+
+<script>
+export default {
+	name: "cate",
+	props: {
+		content_id : {
+			type : String,
+			value : null
+		},
+		page_id : {
+			type : String,
+			value : null
+		},
+		width : {
+			type : String,
+			default : '100%'
+		},
+		code : {
+			type : String,
+			default : ''
+		},
+		param : {},
+		index : 0
+	},
+    data() {
+    	return {
+			page : 1,
+			loadingType: 3,
+			productList : [[],[]]
+		}
+    },
+	mounted() {
+		this.getData();
+	},
+	methods:{
+		getData : function() {
+			var self = this;
+			//避免重复加载
+			if(this.loadingType != 3){return ;}
+			this.loadingType = 1;
+			
+			this.Dever.get(this, 'app/collection/?l=api.getProduct', {code:this.code, content_id:this.content_id,noloading:1,noconcat:1,page:this.page}, function(t) {
+				if (t && t.product && t.product.length > 0) {
+					var lArr = [];
+					var rArr = [];
+					for (var i = 0; i < t.product.length; i++) {
+						if (i % 2 == 0) {
+							lArr.push(t.product[i]);
+						} else {
+							rArr.push(t.product[i]);
+						}
+					}
+					self.productList = [lArr, rArr];
+					self.loadingType = 3;
+					self.page++;
+				} else {
+					self.loadingType = 2;
+				}
+			});
+		},
+	},
+}
+</script>
+
+<style>
+.grace-waterfall-item{width:340rpx;}
+.grace-waterfall-img{width:340rpx;}
+</style>

+ 9 - 22
pages/dream/func/times.vue

@@ -19,53 +19,40 @@
 export default {
 	name: "times",
 	props: {
-		info_id : {
-			type : String,
-			value : null
-		},
 		content_id : {
 			type : String,
 			value : null
 		},
-		page_id : {
-			type : String,
-			value : null
-		},
-		parent_page_id : {
-			type : String,
-			value : null
-		},
 		width : {
 			type : String,
 			default : '100%'
 		},
+		code : {
+			type : String,
+			default : ''
+		},
 		param : {},
 		index : 0,
 		times : 0,
 	},
 	data() {
 		return {
-			
+			fetch : {},
 		}
 	},
-	created() {
+	mounted() {
 		this.fetch = this.param;
 	},
 	methods:{
 		getData : function() {
-			var info = {
-				info_id : this.info_id,
-				page_id : this.page_id,
-				parent_page_id : this.parent_page_id,
-			}
-			this.$emit('getTimes', info);
+			this.$emit('getTimes');
 		},
 		go : function(times) {
 			var self = this;
 			this.Dever.alert('正在进入' + times.name);
 			// 要拿到最新的page_id
-			this.Dever.post('app/collection/?l=api.getPageId', {id:self.info_id,times:times.id}, function(t) {
-				self.Dever.location('dream/view?id=' + self.info_id + '&page_id='+t.id+'&index=0&times=' + times.id);
+			this.Dever.post('app/collection/?l=api.getPageId', {code:this.code,times_id:times.id}, function(t) {
+				self.Dever.location('dream/view?code=' + t.code);
 			})
 			
 		},

+ 7 - 5
pages/dream/index.vue

@@ -43,13 +43,11 @@ export default{
 				index : 0,
 				circular : true,
 			},
-			fetch: {
-				page_id : 0,
+			fetch: {
 				is_buy : false,
 				info : {},
 				button : {},
-				times : 0,
-				index : 0,
+				code : '',
 			},
 			buyState : false,
 			rankingState : false,
@@ -79,7 +77,7 @@ export default{
 			}
 		},
 		view : function() {
-			this.Dever.location('dream/view?id='+this.id+'&page_id='+this.fetch.page_id+'&index='+this.fetch.index+'&times=' + this.fetch.times);
+			this.Dever.location('dream/view?code='+this.fetch.code);
 		},
 		hideBuy : function() {
 			this.buyState = false;
@@ -89,6 +87,10 @@ export default{
 		},
 		goRanking : function() {
 			this.rankingState = true;
+		},
+		share : function() {
+			//从后端获取分享链接需要的加密参数
+			
 		}
 	},
 	components:{

+ 37 - 34
pages/dream/view.vue

@@ -4,7 +4,7 @@
 			<drawerPage :show="drawer.show ? 'left' : ''">
 				<view class="container_main" slot="links">
 					<block v-if="login">
-						<swiper class="swiper" @change="change" :circular="swiper.circular" :current="index">
+						<swiper class="swiper" @change="change" :circular="swiper.circular" :current="fetch.index">
 							<swiper-item v-for="(v, k) in fetch.items"  v-if="v.data" :key="k" >
 								<scroll-view scroll-y="true" scroll-x="true" class="scroll-height" @scrolltolower="bottomCall">
 									<dream ref="dream" @showDrawer="showDrawer" :index="k" :item="v" :control="control" :bottom="bottom" class="item"></dream>
@@ -13,37 +13,42 @@
 						</swiper>
 					</block>
 					<block v-if="!login">
-						<dream ref="dream" @showDrawer="showDrawer" :index="index" :item="fetch.items[index]" :control="control" :bottom="bottom" class="item"></dream>
+						<dream ref="dream" @showDrawer="showDrawer" :index="fetch.index" :item="fetch.items[fetch.index]" :control="control" :bottom="bottom" class="item"></dream>
 					</block>
 				</view>
 			</drawerPage>
 			
 			
-			<drawerWindow v-for="(v, k) in drawer.item" :key="k" :show="v.show" :zIndex="v.index" padding="v.padding" :top="v.top" direction="v.direction" :width="v.width" v-on:closeDrawer="closeDrawer(k)">
+			<drawerWindow v-for="(v, k) in drawer.item" :key="k" :show="v.show" :zIndex="v.index" padding="v.padding" :top="v.top" :direction="v.direction" :width="v.width" v-on:closeDrawer="closeDrawer(k)">
 				<view slot="links">
 					<block v-if="k == 'cate'">
-						<cate ref="cate" @goIndex="goIndex" :index="index" :content_id="content_id" :info_id="fetch.info_id" :page_id="fetch.page_id" :parent_page_id="fetch.parent_page_id" :width="v.width"  :param="v.param" @getCate="getCate"></cate>
+						<cate ref="cate" @goIndex="goIndex" :index="fetch.index" :content_id="content_id" :code="code" :width="v.width" :param="v.param" :page_id="fetch.page_id"  @getCate="getCate"></cate>
 					</block>
 					
 					<block v-if="k == 'community'">
-						<community ref="community" @goIndex="goIndex" :index="index" :content_id="content_id" :info_id="fetch.info_id" :page_id="fetch.page_id" :parent_page_id="fetch.parent_page_id" :width="v.width"  :param="v.param"></community>
+						<community ref="community" @goIndex="goIndex" :index="fetch.index" :content_id="content_id" :code="code" :width="v.width" :param="v.param"></community>
 					</block>
 					
 					<block v-if="k == 'times'">
-						<times ref="times" @goIndex="goIndex" :index="index" :content_id="content_id" :info_id="fetch.info_id" :page_id="fetch.page_id" :parent_page_id="fetch.parent_page_id" :width="v.width"  :param="v.param" :times="times" @getTimes="getTimes"></times>
+						<times ref="times" @goIndex="goIndex" :index="fetch.index" :content_id="content_id" :code="code" :width="v.width" :param="v.param" :times="fetch.times_id" @getTimes="getTimes"></times>
+					</block>
+					
+					<block v-if="k == 'shop'">
+						<shop ref="shop" @goIndex="goIndex" :index="fetch.index" :content_id="content_id" :code="code" :width="v.width" :param="v.param"></shop>
 					</block>
 				</view>
 			</drawerWindow>
 			
 			<y-Fab v-if="!drawer.show && fetch.user.avatar && login" :bottom="20" :right="20" :btnList="drawer.button" @click="clickDrawerButton" :text="`P`+(swiper.index+1)" :icon_o="fetch.user.avatar"></y-Fab>
-			<y-Fab v-if="!login" :bottom="20" :right="20" @click="goHome" :text="`P`+(swiper.index+1)"></y-Fab>
+			<y-Fab v-if="!login" :bottom="20" :right="20" @click="goHome" :text="`首页`"></y-Fab>
 		</view>
 	</gracePage>
 </template>
 <script>
 import cate from "@/pages/dream/func/cate.vue";
 import community from "@/pages/dream/func/community.vue";
-import times from "@/pages/dream/func/times.vue";
+import times from "@/pages/dream/func/times.vue";
+import shop from "@/pages/dream/func/shop.vue";
 import dream from "@/pages/dream/view/dream.vue";
 import drawerPage from "@/lib/dever/components/drawerPage.vue";
 import drawerWindow from "@/lib/dever/components/drawerWindow.vue";
@@ -51,22 +56,21 @@ var graceRichText = require("@/lib/graceUI/jsTools/richText.js");
 export default{
 	data() {
 		return {
-			id : 1,
-			page_id : 1,
-			index : 0,
 			content_id : 0,
-			times : 0,
-			login : false,
+			login : false,
+			code : '',
 			swiper : {
 				index : 0,
 				circular : false,
 			},
 			fetch: {
 				items : [],
-				user : {},
+				user : {},
+				index : 0,
 				info_id : 0,
 				page_id : 0,
-				parent_page_id : 0,
+				parent_page_id : 0,
+				times_id : 0,
 			},
 			control : {},
 			bottom : {},
@@ -114,13 +118,8 @@ export default{
 		}
 	},
 	onLoad(option) {
-		this.login = true;
-		this.id = option.id;
-		this.page_id = option.page_id;
-		this.index = option.index;
-		this.times = option.times;
-		this.Dever.data('page_id', this.page_id);
-		this.Dever.data('times', this.times);
+		this.login = true;
+		this.code = option.code;
 		this.getData();
 	},
 	// 重新加载
@@ -139,7 +138,8 @@ export default{
 			}
 		},
 		record : function() {
-			this.Dever.post('app/collection/?l=api.record', {noloading:1, id:this.id, page_id:this.page_id, times:this.times, index: this.swiper.index});
+			var content_id = this.fetch.items[this.swiper.index].id;
+			this.Dever.post('app/collection/?l=api.record', {noloading:1, code:this.code, index: this.swiper.index, content_id: content_id});
 		},
 		change : function(e) {
 			this.swiper.index = e.detail.current;
@@ -175,30 +175,30 @@ export default{
 		},
 		getData : function() {
 			var self = this;
-			self.drawer.item = {};
-			//this.record();
-			this.Dever.get(this, 'app/collection/?l=api.getContent', {id:this.id, page_id:this.page_id}, function(t) {
+			self.drawer.item = {};
+			this.Dever.get(this, 'app/collection/?l=api.getContent', {code:this.code}, function(t) {
+				self.record();
 				if (t && t['func']) {
 					self.drawer.item = t['func'];
 					self.initDrawer();
 					if (t['func']['cate']) {
-						self.getCate(t);
+						self.getCate();
 					}
 					if (t['func']['times']) {
-						self.getTimes(t);
+						self.getTimes();
 					}
 				}
 			});
 		},
-		getCate : function(info) {
+		getCate : function() {
 			var self = this;
-			this.Dever.get(this, 'app/collection/?l=api.category', {id:info.info_id, parent_page_id:info.parent_page_id, page_id:info.page_id, times:this.times,noloading:1}, function(t) {
+			this.Dever.get(this, 'app/collection/?l=api.category', {code:this.code,noloading:1}, function(t) {
 				self.drawer.item['cate'].param = t;
 			});
 		},
-		getTimes : function(info) {
+		getTimes : function() {
 			var self = this;
-			this.Dever.get(this, 'app/collection/?l=api.times', {id:info.info_id, parent_page_id:info.parent_page_id, page_id:info.page_id, times:this.times,noloading:1}, function(t) {
+			this.Dever.get(this, 'app/collection/?l=api.times', {code:this.code,noloading:1}, function(t) {
 				if (t && t.times && t.times.length > 0) {
 					self.drawer.item['times'].param = t;
 				} else {
@@ -208,7 +208,7 @@ export default{
 			});
 		},
 		goIndex : function(index) {
-			this.index = index;
+			this.fetch.index = index;
 			if (this.drawer.show) {
 				this.closeDrawer(this.drawer.show);
 			}
@@ -231,10 +231,13 @@ export default{
 		},
 		clickDrawerButton : function(e) {
 			this.showDrawer(this.drawer.button[e.index].key);
+		},
+		goHome : function() {
+			this.Dever.location('dream/index?id='+this.fetch.info_id);
 		}
 	},
 	components:{
-		dream,cate,community,times,drawerPage,drawerWindow
+		dream,cate,community,times,shop,drawerPage,drawerWindow
 	}
 }
 </script>