Browse Source

auto commit

gcz 4 years ago
parent
commit
bf61849786

+ 37 - 14
components/liudx-pickerAddress/index.vue

@@ -12,21 +12,21 @@
 			<picker-view-column>
 				<view class="u-column-item" v-for="(item,index) in districtsObj.provinces" :key="index">
 					<view class="u-line-1">
-						{{item.AreaName}}
+						{{item.areaName}}
 					</view>
 				</view>
 			</picker-view-column>
 			<picker-view-column>
 				<view class="u-column-item" v-for="(item,index) in districtsObj.cities" :key="index">
 					<view class="u-line-1">
-						{{item.AreaName}}
+						{{item.areaName}}
 					</view>
 				</view>
 			</picker-view-column>
 			<picker-view-column>
 				<view class="u-column-item" v-for="(item,index) in districtsObj.areas" :key="index">
 					<view class="u-line-1">
-						{{item.AreaName}}
+						{{item.areaName}}
 					</view>
 				</view>
 			</picker-view-column>
@@ -56,6 +56,7 @@
 		},
 		data() {
 			return {
+				token:'',
 				pickVal:[0, 0, 0],
 				districtsObj: {
 					provinces: [],
@@ -70,13 +71,23 @@
 		watch: {
 			// 如果地区发生变化,为了让picker联动起来,必须重置this.citys和this.areas
 			province(val) {
-				this.loadCities(this.districtsObj.provinces[this.province].AreaId);
+				this.loadCities(this.districtsObj.provinces[this.province].areaId);
 			},
 			city(val) {
-				this.loadAreas(this.districtsObj.cities[this.city].AreaId);
+				this.loadAreas(this.districtsObj.cities[this.city].areaId);
 			}
 		},
 		mounted() {
+			let self = this;
+			uni.getStorage({
+				key:'token',
+				success: function (res) {
+					self.token = res.data;
+				},
+				fail:function(err){
+					console.log('getStorage err',err)
+				}
+			});
 			this.loadDistrict()
 		},
 		methods: {
@@ -88,38 +99,50 @@
 			},
 			loadProvinces() { // 加载省份
 				uni.request({
-					url: 'http://test-api.tiananhub.com/api/province/GetListProvince',
+					// url: 'http://test-api.tiananhub.com/api/province/GetListProvince',
+					url: this.config.apiBaseurl + '/positiont/search',
+					header: {
+					    Authorization:'Bearer ' + this.token
+					},
 					method: 'get',
 					success: async (res) => {
 						let {data} = res.data
 						this.districtsObj.provinces = data
-						this.loadCities(data[0].AreaId)
+						this.loadCities(data[0].areaId)
 					},
 					fail:async(res) => {
 					}
 				})
 			},
-			loadCities(AreaId) {
+			loadCities(areaId) {
 				uni.request({
-					url: 'http://test-api.tiananhub.com/api/province/GetListCity',
+					// url: 'http://test-api.tiananhub.com/api/province/GetListCity',
+					url: this.config.apiBaseurl + '/positiont/search',
+					header: {
+					    Authorization:'Bearer ' + this.token
+					},
 					data: {
-						AreaId
+						parentId:areaId
 					},
 					method: 'get',
 					success: async (res) => {
 						let {data} = res.data
 						this.districtsObj.cities = data
-						if(data[0]){this.loadAreas(data[0].AreaId)}
+						if(data[0]){this.loadAreas(data[0].areaId)}
 					},
 					fail:async(res) => {
 					}
 				})
 			},
-			loadAreas(AreaId) {
+			loadAreas(areaId) {
 				uni.request({
-					url: 'http://test-api.tiananhub.com/api/province/GetListCity',
+					// url: 'http://test-api.tiananhub.com/api/province/GetListCity',
+					url: this.config.apiBaseurl + '/positiont/search',
+					header: {
+					    Authorization:'Bearer ' + this.token
+					},
 					data: {
-						AreaId
+						parentId:areaId
 					},
 					method: 'get',
 					success: async (res) => {

+ 12 - 4
pages/confirmorder/confirmorder.vue

@@ -77,6 +77,7 @@
 			}
 		},
 		onShow() {
+			this.getAddrs();
 			
 		},
 		onLoad() {
@@ -92,7 +93,7 @@
 				   // console.log(self.token);
 				}
 			});			
-			this.getAddrs();
+			
 		},
 		methods: {
 			submit(){
@@ -171,13 +172,19 @@
 				// 	console.log('err',err)
 				// });				
 			},
-			goAddrs(){
+			goAddrs(){				
 				uni.navigateTo({
 					url:`/pages/usercenter/addrs/addrs`,
+					success: () => {
+						uni.setStorage({
+							key:'selectAddr',
+							data:true
+						});
+					},
 					fail(err) {
 						console.log(err)
 					}
-				})
+				});
 			},
 			getAddrs(){
 				// console.log('this.token',this.token);
@@ -187,7 +194,8 @@
 					this.addrsList = res.data.data;
 					if(res.data.data.length>0){
 						this.memberReceiveAddressId = res.data.data[0].id;
-						this.theAddr = res.data.data[0].detailAddress;
+						this.theAddr = res.data.data[0].city+res.data.data[0].region+res.data.data[0].detailAddress;
+						console.log('this.theAddr',this.theAddr);
 						// console.log('this.memberReceiveAddressId',this.memberReceiveAddressId);
 					}else{
 						this.theAddr = '您还没有设置收货地址,请到个人中心页面设置!';

+ 45 - 12
pages/usercenter/addrs/addrs.vue

@@ -41,9 +41,10 @@
 				</view>
 			</view> -->
 			
-			<view class="form-item required" @click="addressShow = true">
-				<view class="form-item-til">详细地址</view>
+			<view class="form-item select-addr required" @click="addressShow = true">
+				<view class="form-item-til">选择地址</view>
 				<view class="form-item-con">
+					<text v-if="address==''">请选择地址</text>
 					{{address}}
 					<pickerAddress v-model="addressShow" @confirm="addresspick" />
 				</view>
@@ -126,6 +127,17 @@
 		longitude: ''
 	};
 	export default {
+		// beforeRouteEnter(to, from, next){
+		// 	console.log('from',from);
+		// 	next(vm =>{
+		// 		console.log('22222222',from) // 上一页面的路由信息
+		// 	})
+		// },
+		// beforeRouteLeave(to, from, next) {
+		// 	console.log(' beforeRouteLeave !', this)
+		// 	const answer = window.confirm('确认离开?')
+		// 	answer ? next() : next(false)
+		//   },
 		components: {
 			// BaiduMap,
 			// BmNavigation,
@@ -147,6 +159,7 @@
 				address: '',
 								
 				isedit: false,
+				isselectAddr:false,
 				addrsList: [],
 				token:'',
 				params: Object.assign({},defaultparams),
@@ -174,12 +187,13 @@
 				zoom: 12,
 			}
 		},
-		onShow() {
+		onShow() {			
 			let serf = this;
 			this.getAddrList();
 
 		},
 		onLoad() {
+			
 			let self = this;
 			uni.getStorage({
 				key:'token',
@@ -188,15 +202,33 @@
 				   // console.log(res.data);
 				}
 			});
+			uni.getStorage({
+				key:'selectAddr',
+				success: function (res) {
+					self.isselectAddr = true;
+				   // console.log(res.data);
+				},
+				fail:function(){
+					self.isselectAddr = false;
+				}
+			});
 			
 
+		},
+		onUnload() {
+			console.log('1111111111111');
+			this.isselectAddr = false;
+			uni.setStorage({
+				key:'selectAddr',
+				data:false
+			});
 		},
 		methods: {
 			addresspick(obj) {
 				console.log('addresspick',obj);
-				this.params.province = obj.province.AreaName;
-				this.params.city = obj.city.AreaName;
-				this.params.region = obj.area.AreaName||'';
+				this.params.province = obj.province.areaName;
+				this.params.city = obj.city.areaName;
+				this.params.region = obj.area.areaName||'';
 				this.concatAddr();
 			},
 			concatAddr(){
@@ -205,10 +237,10 @@
 			getAddrList() {
 				let thetoken = 'Bearer ' + this.token;
 				this.$api.http.get(this.config.apiBaseurl + '/member/address/list',{header: {Authorization:thetoken}}).then(res => {
-					console.log('getAddrList', res);
+					// console.log('getAddrList', res);
 					this.addrsList = res.data.data;					
 					if(this.addrsList.length == 1 && this.addrsList[0].defaultStatus!=1){
-						console.log('getAddrListlength', this.addrsList[0]);
+						// console.log('getAddrListlength', this.addrsList[0]);
 						// setTimeout(function(){console.log(this)},5000);
 						setTimeout(this.setDefault(this.addrsList[0].id),1000);
 						// this.setDefault(this.addrsList[0].id);
@@ -224,6 +256,7 @@
 				this.fixPageOpen = false;
 				this.params = Object.assign({},defaultparams);
 				this.isedit = false;
+				this.address = '';
 				this.getAddrList();
 				
 			},
@@ -273,7 +306,7 @@
 						Authorization: 'Bearer '+ this.token, //注意Bearer后面有一空格
 					},
 					}).then(res => {
-						this.closeFixPage();
+						this.closeFixPage();						
 						//产品跳转
 						uni.getStorage({
 							key:'productID',
@@ -315,14 +348,14 @@
 				this.$refs.popup.open();
 			},
 			selectDefault(item){
-				console.log('item',item);
+				// console.log('item',item);
 				if(item.defaultStatus != 1){
 					this.setDefault(item.id);
 				}
 				console.log(this.$router);
 				console.log(this.$router.history.current.fullPath);
-				this.$router.go(-1);
-			},
+				if(this.isselectAddr){this.$router.go(-1);}
+			},			
 			setDefault(id){
 				this.$api.http.put(this.config.apiBaseurl + '/member/address/default/'+id,{},{
 					header: {

File diff suppressed because it is too large
+ 1 - 1
unpackage/dist/build/h5/index.html