Kaynağa Gözat

偏远地区加钱

牟新芬 3 yıl önce
ebeveyn
işleme
a7c0412d1a

+ 35 - 7
pages/users/purchase/index.vue

@@ -28,7 +28,7 @@
 				<view class="input">
 					手机号<input type='number' placeholder='请输入手机号码' placeholder-class='placeholder' v-model="delivery.mobile"></input>
 				</view>
-				<textarea placeholder-style="color:#ccc;font-size:28rpx;" placeholder="示例: 浙江省 台州市 椒江区 市府大道12号" v-model="delivery.address" />
+				<textarea placeholder-style="color:#ccc;font-size:28rpx;" placeholder="示例: 浙江省 台州市 椒江区 市府大道12号" v-model="delivery.address" @blur="getExtraFreight"/>
 			</view>
 		</view>
 		<view class="gift">
@@ -40,7 +40,7 @@
 			</view>
 			<radio-group @change="changeProduct" v-if="productList.length > 0">
 				<view class="product" v-for="(item , index) in productList" :key="index">
-					<radio :value="index.toString()" />
+					<radio :value="index.toString()" :checked="index == current"/>
 					<image :src="item.img"></image>
 					<view class="info">									
 						<view>{{item.title}}</view>
@@ -57,6 +57,7 @@
 		<view class="bottom">
 			<view>
 				<view>礼品金额:<text>¥{{price}}</text>,运费:<text>¥{{freight}}</text></view>
+				<view v-if="extraFreight">偏远地区加钱:<text>¥{{extraFreight}}</text></view>
 				<view class="total">总价:<text>¥{{total}}</text></view>
 			</view>
 			<button @click="submit">提交订单</button>
@@ -111,9 +112,11 @@
 				warehouse: [],
 				warehouseData: [],
 				warehouseId: '',
+				warehouseIndex: '',
 				expId: '',
 				productList: [],
 				productId: '',
+				current: -1,
 				delivery: {
 					out_order_id: '',
 					name: '',
@@ -123,6 +126,7 @@
 				},
 				price: 0,
 				freight: 0,
+				extraFreight: 0,
 				total: 0,
 				payData: {}
 			}
@@ -166,12 +170,14 @@
 				that.platformId = evt.target.value;
 				that.tabWarehouse(that.platformId);
 				that.warehouseId = that.warehouse[0].id;
+				that.warehouseIndex = 0;
 				if(that.warehouse[0].expCode.length > 0){
 					that.expId = that.warehouse[0].expCode[0].id;
 					that.freight = parseFloat(that.warehouse[0].expCode[0].money);
 					that.total = that.price + that.freight;
 				}	
 				that.getProductList();
+				that.getExtraFreight();
 			},
 			//选择平台后切换仓库
 			tabWarehouse:function(id){
@@ -191,15 +197,18 @@
 					title: '请先选择数据来源平台'
 				});
 				that.warehouseId = that.warehouse[index].id;
+				that.warehouseIndex = index;
 				if(that.warehouse[index].expCode.length > 0){
 					that.expId = that.warehouse[index].expCode[0].id;
 					that.freight = parseFloat(that.warehouse[index].expCode[0].money);
-					that.total = that.price + that.freight;
 				}else{
 					that.freight = 0;
-					that.total = that.price + that.freight;
 				}
+				that.current = -1;
+				that.productId = '';
+				that.price = 0;
 				that.getProductList();
+				that.getExtraFreight();
 			},
 			changeProduct:function(evt) {
 				let that = this;
@@ -207,9 +216,24 @@
 					title: '请先选择数据来源平台'
 				});
 				let index = evt.target.value;
+				that.current = index;
 				that.productId = that.productList[index].id;
 				that.price = parseFloat(that.productList[index].price);
-				that.total = that.price + that.freight;
+				that.total = (parseFloat(that.price) + parseFloat(that.freight) + parseFloat(that.extraFreight)).toFixed(2);
+			},
+			//偏远地区加钱
+			getExtraFreight:function () {
+				let that = this;
+				if(that.delivery.address.indexOf("北京") != -1){
+					that.extraFreight = parseFloat(that.warehouse[that.warehouseIndex].beijing);
+				}
+				if(that.delivery.address.indexOf("上海") != -1){
+					that.extraFreight = parseFloat(that.warehouse[that.warehouseIndex].shanghai);
+				}
+				if(that.delivery.address.indexOf("青海") != -1){
+					that.extraFreight = parseFloat(that.warehouse[that.warehouseIndex].qinghai);
+				}
+				that.total = (parseFloat(that.price) + parseFloat(that.freight) + parseFloat(that.extraFreight)).toFixed(2);
 			},
 			submit: function() {
 				let that = this;
@@ -228,18 +252,22 @@
 				if (!that.delivery.address) return that.$util.Tips({
 					title: '请输入收货地址'
 				});
+				if(that.delivery.address.indexOf("新疆") != -1 || that.delivery.address.indexOf("西藏") != -1) return that.$util.Tips({
+					title: '新疆西藏地区不发货'
+				});
 				if (!that.productId) return that.$util.Tips({
 					title: '请选择赠送礼品'
 				});
 				let orderAr = [];
 				orderAr.push(that.delivery);
-				submitOrder({					
+				submitOrder({
 					platformId: that.platformId,
 					warehouseId: that.warehouseId,
 					proId: that.productId,					
 					expId: that.expId,
 					orderAr: orderAr,
-					mono: ''
+					mono: '',
+					extraFreight: that.extraFreight
 				}).then(res => {
 					payOrder({'order_id':res.data.order_id}).then(res => {
 						that.payData = res.data;

+ 1 - 1
unpackage/dist/build/h5/index.html

@@ -1,2 +1,2 @@
 <!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>巴巴礼品网</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
-            document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/h5/static/index.f37b29dd.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/h5/static/js/chunk-vendors.60852841.js></script><script src=/h5/static/js/index.2b6259c5.js></script></body></html>
+            document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/h5/static/index.f37b29dd.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/h5/static/js/chunk-vendors.60852841.js></script><script src=/h5/static/js/index.615a6eed.js></script></body></html>