dever 5 years ago
parent
commit
1b69c47c99

+ 4 - 1
lib/dever/components/position.vue

@@ -1,7 +1,7 @@
 <template name="position">
 	<view>
 		<block v-for="(v, k) in item" :key="k">
-			<view :class="['position-tag', position[v.text-1]]" v-if="v.name">
+			<view :class="['position-tag', position[v.text-1]]" v-if="v.name" @click="view(v.goods_id)">
 				<view v-for="(v1, k1) in v.name_array" :key="k1">
 					<text v-bind:style="{backgroundColor:(v.bgcolor || 'transparent'),color:v.color,fontSize:v.size+'px'}" v-if="v1">{{v1}}</text>
 				</view>
@@ -56,6 +56,9 @@ export default {
 					}
 				}
 			});
+		},
+		view : function(id) {
+			this.Dever.location('dream/product?id=' + id + '&table=&code=' + this.Dever.config.code);
 		}
 	},
 }

+ 3 - 0
lib/dever/components/publish.vue

@@ -92,6 +92,9 @@
 				data.type_id = this.type_id;
 				data.to_id = this.to_id;
 				data.to_uid = this.to_uid;
+				if (this.Dever.config.code) {
+					data.code = this.Dever.config.code;
+				}
 				this.Dever.post(this.api, data, function(t) {
 					self.getRefresh(data.content);
 				});

+ 0 - 4
pages/dream/func/cate.vue

@@ -58,10 +58,6 @@ export default {
 			type : String,
 			default : '100%'
 		},
-		code : {
-			type : String,
-			default : ''
-		},
 		param : {},
 		index : 0
 	},

+ 2 - 6
pages/dream/func/community.vue

@@ -34,10 +34,6 @@ export default {
 			type : String,
 			default : '100%'
 		},
-		code : {
-			type : String,
-			default : ''
-		},
 		param : {},
 		index : 0
 	},
@@ -66,7 +62,7 @@ export default {
 		},
 		getData : function() {
 			var self = this;
-			this.Dever.get(this, 'app/community/?l=api.category', {code:this.code, content_id:this.content_id,noloading:1}, function(t) {
+			this.Dever.get(this, 'app/community/?l=api.category', {code:this.Dever.config.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);
 				}
@@ -80,7 +76,7 @@ export default {
 			if(page != 1 && self.loadingType != 3){return ;}
 			self.loadingType = 1;
 			self.cate_id = cate_id;
-			this.Dever.page([page, 'info'], this, 'app/community/?l=api.info', {cate_id:cate_id, type:this.type, type_id:this.type_id,noloading:1}, function(t) {
+			this.Dever.page([page, 'info'], this, 'app/community/?l=api.info', {code:this.Dever.config.code, cate_id:cate_id, type:this.type, type_id:this.type_id,noloading:1}, function(t) {
 				if (self.Dever.pageData.status == 1) {
 					self.loadingType = 3;
 				} else {

+ 2 - 6
pages/dream/func/my.vue

@@ -20,7 +20,7 @@
 		</view>
 		<view class="ucenter-line"></view>
 		<view class="grace-list grace-margin-top">
-			<shop ref="shop" :index="index" :content_id="content_id" :code="code" :width="width"></shop>
+			<shop ref="shop" :index="index" :content_id="content_id" :width="width"></shop>
 		</view>
 	</view>
 </template>
@@ -38,10 +38,6 @@ export default {
 			type : String,
 			default : '100%'
 		},
-		code : {
-			type : String,
-			default : ''
-		},
 		param : {},
 		index : 0
 	},
@@ -65,7 +61,7 @@ export default {
 	methods:{
 		getData : function() {
 			var self = this;
-			this.Dever.get(this, 'app/collection/?l=api.getUser', {code:this.code, content_id:this.content_id,noloading:1});
+			this.Dever.get(this, 'app/collection/?l=api.getUser', {code:this.Dever.config.code, content_id:this.content_id,noloading:1});
 		},
 		getInfo : function(t) {
 			//触底刷新

+ 1 - 5
pages/dream/func/share.vue

@@ -109,10 +109,6 @@ export default {
 			type : String,
 			default : '100%'
 		},
-		code : {
-			type : String,
-			default : ''
-		},
 		param : {},
 		index : 0,
 		type : 0,
@@ -146,7 +142,7 @@ export default {
 	methods: {
 		getData : function() {
 			var url = this.Dever.host + '/pages/dream/view';
-			this.Dever.get(this, 'app/collection/?l=api.getShare', {code:this.code,content_id:this.content_id,type:this.type, url:url, index:this.index});
+			this.Dever.get(this, 'app/collection/?l=api.getShare', {code:this.Dever.config.code,content_id:this.content_id,type:this.type, url:url, index:this.index});
 		},
 		getInfo : function() {
 			

+ 2 - 6
pages/dream/func/shop.vue

@@ -28,10 +28,6 @@ export default {
 			type : String,
 			default : '100%'
 		},
-		code : {
-			type : String,
-			default : ''
-		},
 		param : {},
 		index : 0
 	},
@@ -52,7 +48,7 @@ export default {
 			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) {
+			this.Dever.get(this, 'app/collection/?l=api.getProduct', {code:this.Dever.config.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 = [];
@@ -75,7 +71,7 @@ export default {
 			//触底刷新
 		},
 		view : function(id) {
-			this.Dever.location('dream/product?id=' + id + '&table=collection/product&code=' + this.code);
+			this.Dever.location('dream/product?id=' + id + '&table=collection/product&code=' + this.Dever.config.code);
 		}
 	},
 }

+ 48 - 8
pages/dream/func/times.vue

@@ -3,12 +3,19 @@
 		<view class="cu-timeline" v-for="(v,k) in fetch.times" :key="v.id">
 			<view class="cu-time">{{v.name}}</view>
 			<view class="cu-item" :class="v1.id == times ? 'text-blue' : ''" v-for="(v1,k1) in v.child" :key="v1.id" :style="{backgroundImage: v1.icon}">
-				<view class="content" :style="{color:v1.color,backgroundColor:v1.bgcolor}" @click="go(v1)">
+				<view class="content" :style="{color:v1.color,backgroundColor:v1.bgcolor}">
 					<view class="cu-capsule radius">
 						<view class="cu-tag bg-cyan">{{v1.name}}</view>
+						<view class="cu-tag line-white">
+							<picker mode="date" :value="fetch.user_times[v1.id] && fetch.user_times[v1.id].day != 0 ? fetch.user_times[v1.id].day : v1.year + '-' + month + '-' + day" :start="v1.year+`-01-01`" :end="v1.year+`-12-31`" @change="selectDay" :data-year="v1.year" :data-name="v1.name" :data-id="v1.id">
+								<view class="uni-input">{{fetch.user_times[v1.id] && fetch.user_times[v1.id].day != 0 ? fetch.user_times[v1.id].day : '正点'}}</view>
+							</picker>
+						</view>
+					</view>
+					<view @click="go(v1)">
+						<view class="margin-top" v-if="v1.desc&& !v1.pic">{{v1.desc}}</view>
+						<view class="margin-top" v-if="v1.pic && !v1.desc"><image :src="v1.pic" mode="widthFix" class="slide-image" style="height:auto"></image></view>
 					</view>
-					<view class="margin-top" v-if="v1.desc&& !v1.pic">{{v1.desc}}</view>
-					<view class="margin-top" v-if="v1.pic && !v1.desc"><image :src="v1.pic" mode="widthFix" class="slide-image" style="height:auto"></image></view>
 				</view>
 			</view>
 		</view>
@@ -27,10 +34,6 @@ export default {
 			type : String,
 			default : '100%'
 		},
-		code : {
-			type : String,
-			default : ''
-		},
 		param : {},
 		index : 0,
 		times : 0,
@@ -38,12 +41,28 @@ export default {
 	data() {
 		return {
 			fetch : {},
+			current : '',
+			year : '',
+			month : '',
+			day : '',
 		}
 	},
 	mounted() {
 		this.fetch = this.param;
+		this.getDate();
 	},
 	methods:{
+		getDate : function(type) {
+			const date = new Date();
+			let year = date.getFullYear();
+			let month = date.getMonth() + 1;
+			let day = date.getDate();
+
+			this.year = year;
+			this.month = month > 9 ? month : '0' + month;;
+			this.day = day > 9 ? day : '0' + day;
+			this.current = this.year + '-' + this.month + '-' + this.day;
+		},
 		getData : function() {
 			this.$emit('getTimes');
 		},
@@ -54,11 +73,32 @@ export default {
 			var self = this;
 			this.Dever.alert('正在进入' + times.name);
 			// 要拿到最新的page_id
-			this.Dever.post('app/collection/?l=api.getPageId', {code:this.code,times_id:times.id}, function(t) {
+			var day = this.fetch.user_times[times.id].day;
+			if (day == '正点') {
+				day = '';
+			}
+			this.Dever.post('app/collection/?l=api.getPageId', {code:this.Dever.config.code,times_id:times.id,day:day}, function(t) {
 				self.Dever.location('dream/view?code=' + t.code);
 			})
 			
 		},
+		selectDay : function(res) {
+			var times = {};
+			times = res.currentTarget.dataset;
+			if (!this.fetch.user_times[times.id]) {
+				this.fetch.user_times[times.id] = {};
+				this.fetch.user_times[times.id].day = '正点';
+			}
+			var old = this.fetch.user_times[times.id].day;
+			this.fetch.user_times[times.id].day = res.detail.value;
+			var current = times.year + '-' + this.month + '-' + this.day;
+			if (this.fetch.user_times[times.id].day == current) {
+				this.fetch.user_times[times.id].day = '正点';
+			}
+			if (old != res.detail.value) {
+				this.go(times);
+			}
+		},
 	},
 }
 </script>

+ 1 - 1
pages/dream/product.vue

@@ -1,6 +1,6 @@
 <template>
 	<view>
-		<product ref="product" :index="index" :item="fetch.product" :control="control" :bottom="bottom" v-if="fetch.product.id"></product>
+		<product ref="product" :index="index" :item="fetch.product" :control="control" :bottom="bottom" v-if="fetch.product.goods_id"></product>
 	</view>
 </template>
 

+ 33 - 27
pages/dream/view.vue

@@ -24,27 +24,27 @@
 				<drawerWindow v-for="(v, k) in drawer.item" :key="k" :type="k" :show="v.show" :zIndex="v.index" padding="v.padding" :top="v.top" :direction="v.direction" :width="v.width" v-on:closeDrawer="closeDrawer(k)" v-on:bottomFunc="bottomFunc">
 					<view slot="links">
 						<block v-if="k == '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>
+							<cate ref="cate" @goIndex="goIndex" :index="fetch.index" :content_id="content_id" :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="fetch.index" :content_id="content_id" :code="code" :width="v.width" :param="v.param"></community>
+							<community ref="community" @goIndex="goIndex" :index="fetch.index" :content_id="content_id" :width="v.width" :param="v.param"></community>
 						</block>
 						
 						<block v-if="k == '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>
+							<times ref="times" @goIndex="goIndex" :index="fetch.index" :content_id="content_id" :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>
+							<shop ref="shop" @goIndex="goIndex" :index="fetch.index" :content_id="content_id" :width="v.width" :param="v.param"></shop>
 						</block>
 						
 						<block v-if="k == 'my'">
-							<my ref="my" @goIndex="goIndex" :index="fetch.index" :content_id="content_id" :code="code" :width="v.width" :param="v.param"></my>
+							<my ref="my" @goIndex="goIndex" :index="fetch.index" :content_id="content_id" :width="v.width" :param="v.param"></my>
 						</block>
 						
 						<block v-if="k == 'share'">
-							<share ref="share" @goIndex="goIndex" :index="fetch.index" :content_id="content_id" :code="code" :width="v.width" :param="v.param" :type="type"></share>
+							<share ref="share" @goIndex="goIndex" :index="fetch.index" :content_id="content_id" :width="v.width" :param="v.param" :type="type"></share>
 						</block>
 					</view>
 				</drawerWindow>
@@ -70,8 +70,7 @@ export default{
 		return {
 			content_id : 0,
 			type : -1,
-			login : false,
-			code : '',
+			login : false,
 			swiper : {
 				index : 0,
 				circular : false,
@@ -132,7 +131,7 @@ export default{
 	},
 	onLoad(option) {
 		this.login = true;
-		this.code = option.code;
+		this.Dever.config.code = option.code;
 		this.getData();
 	},
 	// 重新加载
@@ -142,6 +141,9 @@ export default{
 		} else {
 			this.getData();
 		}
+	},
+	onShow : function() {
+		this.controlHandle();
 	},
 	methods:{
 		// 触底刷新
@@ -158,26 +160,30 @@ export default{
 		},
 		record : function() {
 			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});
+			this.Dever.post('app/collection/?l=api.record', {noloading:1, code:this.Dever.config.code, index: this.swiper.index, content_id: content_id});
+		},
+		
+		controlHandle : function() {
+			if (this.control) {
+				var i = 0;
+				for (i in this.control) {
+					if (this.control[i].load) {
+						console.info(i);
+						if (this.swiper.index == i) {
+							console.info('start');
+							this.control[i].start();
+						} else {
+							this.control[i].stop();
+						}
+					}
+				}
+			}
 		},
 		change : function(e) {
 			this.swiper.index = e.detail.current;
 			//用户记录
 			this.record();
-			if (this.control) {
-				var i = 0;
-				for (i in this.control) {
-					if (this.control[i].load) {
-						console.info(i);
-						if (this.swiper.index == i) {
-							console.info('start');
-							this.control[i].start();
-						} else {
-							this.control[i].stop();
-						}
-					}
-				}
-			}
+			this.controlHandle();
 			if (this.swiper.index >= this.fetch.total) {
 				
 			}
@@ -198,7 +204,7 @@ export default{
 		getData : function() {
 			var self = this;
 			self.drawer.item = {};
-			this.Dever.get(this, 'app/collection/?l=api.getContent', {code:this.code}, function(t) {
+			this.Dever.get(this, 'app/collection/?l=api.getContent', {code:this.Dever.config.code}, function(t) {
 				self.record();
 				if (t && t['func']) {
 					self.drawer.item = t['func'];
@@ -214,13 +220,13 @@ export default{
 		},
 		getCate : function() {
 			var self = this;
-			this.Dever.get(this, 'app/collection/?l=api.getCategory', {code:this.code,noloading:1}, function(t) {
+			this.Dever.get(this, 'app/collection/?l=api.getCategory', {code:this.Dever.config.code,noloading:1}, function(t) {
 				self.drawer.item['cate'].param = t;
 			});
 		},
 		getTimes : function() {
 			var self = this;
-			this.Dever.get(this, 'app/collection/?l=api.getTimes', {code:this.code,noloading:1}, function(t) {
+			this.Dever.get(this, 'app/collection/?l=api.getTimes', {code:this.Dever.config.code,noloading:1}, function(t) {
 				if (t && t.times && t.times.length > 0) {
 					self.drawer.item['times'].param = t;
 				} else {

+ 15 - 8
pages/dream/view/product.vue

@@ -95,7 +95,7 @@
 				<y-Fab :bottom="20" :right="20" v-if="!attrIsShow" @click="back" text="返回"></y-Fab>
 			</block>
 			<view v-if="showComment">
-				<publish :title="title" :is_upload="true" @hideModal="hideModal" @getRefresh="getRefresh" :type="key" :type_id="item.id" :api="api"></publish>
+				<publish :title="title" :is_upload="true" @hideModal="hideModal" @getRefresh="getRefresh" :type="key" :type_id="item.goods.id" :api="api"></publish>
 			</view>
 		</view>
 		<!-- 底部 -->
@@ -106,6 +106,7 @@
 <script>
 import deverContent from '@/lib/dever/components/content.vue';
 import publish from '@/lib/dever/components/publish.vue';
+import copyText from "@/lib/clipboard.thorui.js"; 
 export default {
 	name: "product",
 	props: {
@@ -158,7 +159,7 @@ export default {
 			if (this.active == 0) {
 				return;
 			}
-			this.Dever.page([page, 'info'], this, 'app/community/?l=api.comment', {type:this.key,type_id:this.item.id,user:true});
+			this.Dever.page([page, 'info'], this, 'app/community/?l=api.comment', {type:this.key,type_id:this.item.goods.id,user:true});
 		},
 		// 导航切换
 		navChange : function(e){
@@ -172,16 +173,17 @@ export default {
 			if (this.item.goods.type == 1) {
 				this.attrIsShow = true;
 			} else {
-				//this.Dever.alert('加入到口袋里');
+				//this.Dever.alert('加入到口袋里');
+				var name = this.item.goods.type_name;
 				uni.showModal({
-					content: '这是一个购物平台商品,是否立刻去购买?',
+					content: '该商品是'+name+'平台商品,是否立刻去购买?',
 					cancelText: '取消',
-					confirmText: '确定',
+					confirmText: '去购买',
 					success: res => {
 						if (res.confirm) {
 							if (this.item.goods.type == 2 || this.item.goods.type == 4) {
-								//this.Dever.location(this.item.goods.code);
-								this.Dever.alert('已复制,请打开淘宝app');
+								this.copy(this.item.goods.code);
+								this.Dever.alert('已复制,请打开' + name + 'APP即可看到该商品');
 							} else {
 								this.Dever.location(this.item.goods.link);
 							}
@@ -189,6 +191,11 @@ export default {
 					}
 				});
 			}
+		},
+		copy : function(value) {
+			var self = this;
+			copyText.getClipboardData(value, function(res) {
+			});
 		},
 		back : function() {
 			uni.navigateBack();
@@ -249,7 +256,7 @@ export default {
 			this.hideModal();
 		}
 	},
-	components:{deverContent, publish}
+	components:{deverContent, publish, copyText}
 }
 </script>