dever před 4 roky
rodič
revize
dbf83ae61b

+ 3 - 3
lib/graceUI/components/graceAddressPicker.vue

@@ -76,7 +76,7 @@ export default {
 		},
 		arrayIndexOf : function(arr, needFind){
 			var index = 0;
-			for(let i = 0; i < arr.length; i++){if(arr[i].label == needFind){index = i; return i;}}
+			for(let i = 0; i < arr.length; i++){if(arr[i].value == needFind){index = i; return i;}}
 			return index;
 		},
 		change : function (e) {
@@ -109,8 +109,8 @@ export default {
 }
 </script>
 <style scoped>
-.gap{position:fixed; width:100%; height:100%; top:0; left:0; bottom:0; z-index:998;}
-.gap-body{background-color:#FFFFFF; position:absolute; z-index:999; bottom:0; left:0; width:100%;}
+.gap{position:fixed; width:100%; height:100%; top:0; left:0; bottom:0; z-index:99999;}
+.gap-body{background-color:#FFFFFF; position:absolute; z-index:99999; bottom:0; left:0; width:100%;}
 .gap-header{padding:25rpx;}
 .gap-header-btn{width:200rpx; line-height:38rpx; height:38rpx; display:block; font-size:28rpx;}
 .gap-main{width:100%; height:280px;}

+ 29 - 12
lib/graceUI/components/graceDialog.vue

@@ -1,10 +1,15 @@
 <template>
-	<view class="grace-dialog-shade" v-if="show" @tap.stop="closeDialogByShade" @touchmove.stop.prevent="stopFun" :style="{backgroundColor:background, zIndex:zIndex}">
-		<view class="grace-dialog gdFadeIn" @tap.stop="stopFun" :style="{width:width, borderRadius:borderRadius}">
+	<view class="grace-dialog-shade" @tap.stop="closeDialogByShade" @touchmove.stop.prevent="stopFun" 
+	:style="{backgroundColor:background, zIndex:zIndex, height:showIn ?'100%':'0px'}">
+		<view class="grace-dialog"  :class="[showIn ? 'grace-shade-in' : 'grace-shade-out']" @tap.stop="stopFun" 
+		:style="{width:width, borderRadius:borderRadius}">
 			<view class="grace-dialog-title" v-if="isTitle" 
-			:style="{fontSize:titleSize, color:titleColor, fontWeight:titleWeight?'bold':'', background:titleBg, lineHeight:titleHeight}">{{title}}</view>
+			:style="{
+				fontSize:titleSize, color:titleColor, fontWeight:titleWeight?'bold':'', 
+				background:titleBg, lineHeight:titleHeight}">{{title}}</view>
 			<view class="grace-dialog-content" @tap.stop="stopFun"><slot name="content"></slot></view>
-			<view class="grace-dialog-close-btn" :style="{color:closeBtnColor, zIndex:zIndex+1}" v-if="isCloseBtn" @tap.stop="closeDialog"></view>
+			<view class="grace-dialog-close-btn" 
+			:style="{color:closeBtnColor, zIndex:zIndex+1}" v-if="isCloseBtn" @tap.stop="closeDialog"></view>
 			<view v-if="isBtns"><slot name="btns"></slot></view>
 		</view>
 	</view>
@@ -71,7 +76,7 @@ export default {
 		},
 		zIndex : {
 			type : Number,
-			default : 999
+			default : 99
 		},
 		canCloseByShade:{
 			type : Boolean,
@@ -80,7 +85,15 @@ export default {
 	},
 	data() {
 		return {
-			
+			showIn : false
+		}
+	},
+	created:function(){
+		this.showIn = this.show;
+	},
+	watch:{
+		show:function (val) {
+			if(val){this.open();}else{this.hide();}
 		}
 	},
 	methods:{
@@ -90,17 +103,21 @@ export default {
 		closeDialog : function(){
 			this.$emit('closeDialog');
 		},
-		stopFun : function(){}
+		stopFun : function(){},
+		open:function () {this.showIn = true;},
+		hide:function () {this.showIn = false;}
 	}
 }
 </script>
 <style scoped>
-@keyframes gdFadeIn{ from { opacity: 0; } 100% { opacity: 1; }}
-.gdFadeIn {animation:gdFadeIn 200ms linear;}
-.grace-dialog-shade{position:fixed; width:100%; height:100%; left:0; top:0; bottom:0; z-index:9991; display:flex; justify-content:center; align-items:center;}
-.grace-dialog{width:580rpx; background:#FFFFFF; position:relative;}
+.grace-dialog-shade{position:fixed; width:100%; height:100%; overflow:hidden; left:0; top:0; bottom:0; z-index:9991; display:flex; justify-content:center; align-items:center;}
+.grace-dialog{width:580rpx; background:#FFFFFF; position:relative; transition:all 200ms linear 0s;}
 .grace-dialog-title{line-height:100rpx; font-size:30rpx; text-align:center;}
-.grace-dialog-content{}
+.grace-dialog-content{transition:all 200ms linear 0s;}
 .grace-dialog-close-btn{position:absolute; z-index:9993; right:0px; top:0px; font-size:30rpx; width:80rpx; height:80rpx; line-height:80rpx; text-align:center; font-family:"grace-iconfont";}
 .grace-dialog-close-btn:before{content:"\e632";}
+.grace-shade-in{animation:grace-shade-in-a 200ms linear forwards;}
+@keyframes grace-shade-in-a{0%{transform: scale(0.1); opacity:0;} 100%{transform: scale(1); opacity:1;}}
+.grace-shade-out{animation:grace-shade-out-a 200ms ease-out forwards;}
+@keyframes grace-shade-out-a{0%{transform: scale(1); opacity:1;} 100%{transform: scale(0.1); opacity:0;}}
 </style>

+ 2 - 2
lib/graceUI/data/city-data/city.js

@@ -1,7 +1,7 @@
 /* 本数据由 GraceUI 团队精心整理,版权归 GraceUI 所有,未经允许不得发布到公开渠道及抄袭! */
 var cityData = [
-	[{"label": "北京市","value": "110000"}],
-	[{"label": "天津市","value": "120000"}],
+	[{"label": "北京市","value": "110100"}],
+	[{"label": "天津市","value": "120100"}],
 	[
 		{"label": "石家庄市","value": "130100"},
 		{"label": "唐山市","value": "130200"},

+ 137 - 21
pages/dream/view/product.vue

@@ -87,15 +87,15 @@
 						</view>
 										
 						<view class="grace-wrap" style="margin-top: 20rpx;">
-							<view class="grace-capsule margin" v-if="(item.goods.mode == 1 || item.goods.mode == 3) && mode == 1">
+							<view class="grace-capsule margin" v-if="(item.goods.mode == 1 || item.goods.mode == 3) && mode == 1" @click="openDialog">
 								<text class="grace-capsule-icon">地址</text>
-								<text class="grace-capsule-text">河北省三河市燕郊开发区理想新城一期南区36号楼</text>
+								<text class="grace-capsule-text">{{fetch.area_name}}{{fetch.address}}</text>
 							</view>
 							<view class="grace-capsule margin" v-if="(item.goods.mode == 2 || item.goods.mode == 3) && mode == 2">
 								<text class="grace-capsule-icon grace-icon-br" style="background:#E76B61;">自提</text>
-								<picker @change="selfChange" :value="self_index" :range="self_data">
+								<picker @change="storeChange" :value="store_index" :range="store_data">
 									<text class="picker grace-capsule-text grace-text-br" style="border-color:#E76B61; color:#E76B61;">
-										{{self_data[self_index]}}
+										{{store_data[store_index]}}
 									</text>
 								</picker>
 							</view>
@@ -117,6 +117,42 @@
 					</view>
 				</form>
 			</graceBottomDialog>
+			<graceDialog ref="graceDialog" :isTitle="true" :isCloseBtn="false" :title="`收货地址`" v-on:closeDialog="closeDialog">
+				<view class="content2" slot="content">
+					<form class="grace-form grace-margin-top">
+						<view class="grace-form-item grace-border-b">
+							<text class="grace-form-label">您的姓名</text>
+							<view class="grace-form-body">
+								<input type="text" class="grace-form-input" name="name" v-model="fetch.address_contact" placeholder="请填写联系姓名"></input>
+							</view>
+						</view>
+						<view class="grace-form-item grace-border-b">
+							<text class="grace-form-label">联系电话</text>
+							<view class="grace-form-body">
+								<input type="number" class="grace-form-input" name="mobile" v-model="fetch.address_mobile" placeholder="请填写联系电话"></input>
+							</view>
+						</view>
+						<view class="grace-form-item grace-border-b">
+							<text class="grace-form-label">所在地区</text>
+							<view class="grace-form-body" @tap="openPicker">
+								<input type="text" class="grace-form-input" name="area" :value="fetch.area_name" disabled placeholder="请选择所在地区"></input>
+							</view>
+						</view>
+						<view class="grace-form-item">
+							<text class="grace-form-label">详细地址</text>
+							<view class="grace-form-body">
+								<input type="text" class="grace-form-input" name="address" v-model="fetch.address" placeholder="请填写详细地址"></input>
+							</view>
+						</view>
+
+					</form>
+				</view>
+				<view slot="btns" class="grace-space-between">
+					<text class="grace-dialog-buttons" @tap="closeDialog">关闭</text>
+					<text class="grace-dialog-buttons grace-blue" @tap="setAddress">确认</text>
+				</view>
+			</graceDialog>
+			
 			<y-Fab :bottom="20" :right="140" v-if="!attrIsShow" @click="buyNow" bgColor="#e55d52" text="购买"></y-Fab>
 			<y-Fab :bottom="20" :right="260" v-if="!attrIsShow" @click="showModal" bgColor="#0fa5e5" text="评价"></y-Fab>
 			<block v-if="index == -1">
@@ -125,7 +161,8 @@
 			<view v-if="showComment">
 				<dever-publish :title="title" :is_upload="true" @hideModal="hideModal" @getRefresh="getRefresh" :type="key" :type_id="item.goods.id" :api="api"></dever-publish>
 			</view>
-		</view>
+			<graceAddressPicker v-if="address_default.length > 0" :value="address_default" :show="graceAddressPickerShow" @confirm="pickerConfirm" @close="closePicker" cancelTColor="关闭"></graceAddressPicker>
+		</view> 
 		<!-- 底部 -->
 		
 	</gracePage>
@@ -172,36 +209,75 @@ export default {
 			showComment : false,
 			fetch : {
 				info : [],
+				address : '',
+				area_name : '',
+				store : [],
 			},
-			mode : 1,
-			self_data : [],
-			self_index : 0,
+			mode : -1,
+			store_data : [],
+			store_index : 0,
+			store_relation : [],
 			freight_price : 0,
+			old_freight_price : 0,
+			graceAddressPickerShow : false,
+			address_default : [],
 		}
 	},
 	created() {
 		
 	},
 	mounted() {
-		this.self_data[0] = '河北省三河市燕郊开发区理想新城一期南区';
-		this.self_data[1] = '北京';
 		this.bottom[this.index] = this;
 		if (this.item.goods.freight) {
 			this.freight_price = this.item.goods.freight.price;
 		}
 		
+		if (this.item.goods.mode == 1 || this.item.goods.mode == 3) {
+			this.mode = 1;
+		} else if (this.item.goods.mode == 2 || this.item.goods.mode == 3) {
+			this.mode = 2;
+		}
+		
 		this.getInfo();
 		this.getData(1);
 	},
 	methods:{
+		openPicker : function() {
+			this.graceAddressPickerShow = true;
+		},
+		pickerConfirm : function(e){
+			console.info(e);
+			this.fetch.area_name = e.names[0] + ' ' + e.names[1] + ' ' + e.names[2];
+			this.fetch.area_id = e.codes[0] + ',' + e.codes[1] + ',' + e.codes[2];
+			this.closePicker();
+		},
+		closePicker : function () {
+			this.graceAddressPickerShow = false;
+		},
 		// 获取地理位置,运费等信息
 		getInfo : function() {
-			
+			var self = this;
+			var data = {};
+			data.goods_id = this.item.goods.id;
+			data.noloading = 1;
+			this.Dever.get(this, 'app/user/?l=api.goods', data, function(t) {
+				self.address_default = self.fetch.area_id.split(',');
+				if (t && t.store) {
+					var j = 0;
+					for (var i in t.store) {
+						self.store_data[j] = t.store[i].name;
+						self.store_relation[j] = i;
+						j++;
+					}
+				}
+			});
+			/*
 			this.Dever.getLocation('wgs84', '', function(t) {
 				if (t && t.longitude && t.longitude) {
 					
 				}
 			});
+			*/
 		},
 		getData : function(page) {
 			if (this.active == 0) {
@@ -216,23 +292,23 @@ export default {
 				this.getData(1);
 			}
 		},
-		selfChange : function(e) {
-			this.self_index = e.detail.value;
+		storeChange : function(e) {
+			this.store_index = e.detail.value;
 		},
 		//打开属性视图
 		buyNow : function() {
-			if (this.item.goods.type == 1) {
+			if (this.item.goods.platform == 1) {
 				this.attrIsShow = true;
 			} else {
 				//this.Dever.alert('加入到口袋里');
-				var name = this.item.goods.type_name;
+				var name = this.item.goods.platform_name;
 				uni.showModal({
 					content: '该商品是'+name+'平台商品,是否立刻去购买?',
 					cancelText: '取消',
 					confirmText: '去购买',
 					success: res => {
 						if (res.confirm) {
-							if (this.item.goods.type == 2 || this.item.goods.type == 4) {
+							if (this.item.goods.platform == 2 || this.item.goods.platform == 4) {
 								this.copy(this.item.goods.code);
 								this.Dever.alert('已复制,请打开' + name + 'APP即可购买该商品');
 							} else {
@@ -279,7 +355,15 @@ export default {
 			data.num = this.buyNum;
 			data.sku = this.skuId;
 			data.code = this.Dever.config.code;
+			data.mode = this.mode;
+
+			if (this.mode == 2) {
+				var store = this.fetch.store[this.store_relation[this.store_index]].id;
+				data.store_id = store;
+			}
+			
 			console.log(data);
+			return;
 			//如果想关闭属性
 			//this.closeAttr();
 			this.Dever.post('app/user/?l=pay.product', data, function(t) {
@@ -305,17 +389,24 @@ export default {
 			}
 			
 			if (this.item.goods.freight) {
+				var freight_price = 0;
 				this.item.goods.freight.first_num = parseInt(this.item.goods.freight.first_num);
 				var price = parseFloat(this.item.goods.freight.first_price);
-				if (this.kuNum > this.item.goods.freight.first_num) {
-					var num = this.kuNum - this.item.goods.freight.first_num;
+				if (this.buyNum > this.item.goods.freight.first_num) {
+					var num = this.buyNum - this.item.goods.freight.first_num;
 					price = parseFloat(price + (this.item.goods.freight.next_price*num));
 				}
 				
 				if (this.item.goods.freight.type == 2) {
-					this.freight_price = this.payPrice*(price/100);
+					freight_price = this.payPrice*(price/100);
 				} else {
-					this.freight_price = price;
+					freight_price = price;
+				}
+				
+				if (this.mode == 2) {
+					this.old_freight_price = freight_price;
+				} else {
+					this.freight_price = freight_price;
 				}
 			}
 			
@@ -335,10 +426,30 @@ export default {
 			this.mode = e.detail.value;
 			if (this.mode == 2) {
 				//获取当前位置的自提点
+				this.old_freight_price = this.freight_price;
 				this.freight_price = 0;
 			} else {
-				this.freight_price = this.item.goods.freight.price;
+				this.freight_price = this.old_freight_price;
 			}
+		},
+		openDialog : function() {
+			this.$refs.graceDialog.open();
+		}, 
+		
+		closeDialog : function() {
+			this.$refs.graceDialog.hide();
+		},
+		
+		setAddress : function() {
+			var data = {};
+			data.code = this.Dever.config.code;
+			data.address_contact = this.fetch.address_contact;
+			data.address_mobile = this.fetch.address_mobile;
+			data.address = this.fetch.address;
+			data.area_id = this.fetch.area_id;
+			data.noloading = 1;
+			this.closeDialog();
+			this.Dever.post('app/user/?l=api.saveAddress', data);
 		}
 	},
 	components:{deverContent, deverPublish, copyText}
@@ -384,4 +495,9 @@ export default {
 .margin{margin:10rpx 10rpx 0 0;}
 .grace-border-b{border-color:#F8F8F8;}
 .grace-check-item-v{width:100%; padding:15rpx 15rpx;}
+.content1{padding:25rpx; font-size:26rpx; text-align:center; line-height:60rpx;background-color:#F8F8F8; display:block;}
+.content2{padding-left:30rpx; padding-right:80rpx; line-height:50rpx; font-size:26rpx;}
+/* 图片形式 */
+.demo-img{width:580rpx; height:850rpx;}
+.grace-dialog-buttons{width:700rpx; line-height:88rpx; height:88rpx; display:block; overflow:hidden; text-align:center; font-size:26rpx; color:#999999;}
 </style>