dever 4 years ago
parent
commit
64f29a2db5
2 changed files with 95 additions and 3 deletions
  1. 62 0
      lib/dever/index.js
  2. 33 3
      pages/dream/view/product.vue

+ 62 - 0
lib/dever/index.js

@@ -1684,6 +1684,68 @@ var dever = {
 			}
 			uni.share(config);
 		}
+	},
+	
+	// 获取地理位置
+	getLocation : function(type, text, success) {
+		if (!type) {
+			type = 'wgs84';
+		}
+		if (!text) {
+			text = '需要获得您的位置,请您授权';
+		}
+		var self = this;
+		if (self.source != 'h5') {
+			uni.getSetting({
+				success(res) {
+					if (res.authSetting['scope.userLocation']) {
+						self.getAltitude(type, success);
+					} else {
+						uni.authorize({
+							scope: 'scope.userLocation',
+							success(res) {
+								self.getAltitude(type, success);
+							},
+							// 授权失败
+							fail(err) {
+								uni.showModal({
+									title: '提示',
+									content: text,
+									showCancel: false,
+									confirmText: '确认授权',
+									success() {
+										uni.openSetting({
+											success(res) {
+												self.getAltitude(type, success);
+											},
+											fail(err) {
+												self.alert('授权失败');
+											}
+										})
+									}
+								})
+							}
+						})
+					}
+				}
+			})
+		} else {
+			self.getAltitude(type, success);
+		}
+	},
+	
+	getAltitude : function(type, success) {
+		uni.getLocation({
+			type: type,
+			altitude: true,
+			success(res) {
+				if (success) {
+					success(res);
+				} else {
+					console.info(res);
+				}
+			}
+		})
 	}
 }
 

+ 33 - 3
pages/dream/view/product.vue

@@ -20,7 +20,7 @@
 					<text class="grace-text grace-gray grace-line-through" style="margin-left:30rpx;">¥{{item.goods.price.min.s_price}}</text>
 				</view>
 				<view class="grace-space-between grace-flex-vcenter" v-if="item.goods.type == 1">
-					<text class="grace-text-small grace-gray" v-if="item.goods.freight">运费 ¥{{item.goods.freight.price}}</text>
+					<text class="grace-text-small grace-gray" v-if="item.goods.freight && item.goods.freight.price">运费 ¥{{item.goods.freight.price}}</text>
 					<text class="grace-text-small grace-gray">已售 {{item.goods.sell_num}} 件</text>
 				</view>
 			</view>
@@ -68,7 +68,8 @@
 						<view class="grace-product-attr-info-body">
 							<text class="grace-product-attr-info-title">{{item.goods.name}}</text>
 							<view class="grace-nowrap grace-flex-vcenter">
-								<text class="grace-product-price">¥{{payPrice}}</text>
+								<text class="grace-product-price">¥{{payPrice}}</text>
+								<text class="grace-text" style="margin-left:30rpx;" v-if="freight_price > 0">运费 ¥{{freight_price}}</text>
 								<text class="grace-text grace-gray" style="margin-left:30rpx;">库存:{{kuNum}}件</text>
 							</view>
 						</view>
@@ -92,7 +93,11 @@
 							</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>
-								<text class="grace-capsule-text grace-text-br" style="border-color:#E76B61; color:#E76B61;">河北省三河市燕郊开发区理想新城一期南区</text>
+								<picker @change="selfChange" :value="self_index" :range="self_data">
+									<text class="picker grace-capsule-text grace-text-br" style="border-color:#E76B61; color:#E76B61;">
+										{{self_data[self_index]}}
+									</text>
+								</picker>
 							</view>
 						</view>
 					</view>
@@ -169,16 +174,32 @@ export default {
 				info : [],
 			},
 			mode : 1,
+			self_data : [],
+			self_index : 0,
+			freight_price : 0,
 		}
 	},
 	created() {
 		
 	},
 	mounted() {
+		this.self_data[0] = '河北省三河市燕郊开发区理想新城一期南区';
+		this.self_data[1] = '北京';
 		this.bottom[this.index] = this;
+		this.freight_price = this.item.goods.freight.price;
+		this.getInfo();
 		this.getData(1);
 	},
 	methods:{
+		// 获取地理位置,运费等信息
+		getInfo : function() {
+			
+			this.Dever.getLocation('wgs84', '', function(t) {
+				if (t && t.longitude && t.longitude) {
+					
+				}
+			});
+		},
 		getData : function(page) {
 			if (this.active == 0) {
 				return;
@@ -192,6 +213,9 @@ export default {
 				this.getData(1);
 			}
 		},
+		selfChange : function(e) {
+			this.self_index = e.detail.value;
+		},
 		//打开属性视图
 		buyNow : function() {
 			if (this.item.goods.type == 1) {
@@ -291,6 +315,12 @@ export default {
 		},
 		setMode : function(e) {
 			this.mode = e.detail.value;
+			if (this.mode == 2) {
+				//获取当前位置的自提点
+				this.freight_price = 0;
+			} else {
+				this.freight_price = this.item.goods.freight.price;
+			}
 		}
 	},
 	components:{deverContent, deverPublish, copyText}