lhl 4 years ago
parent
commit
a7c8cac6d0
6 changed files with 394 additions and 436 deletions
  1. 0 19
      pages/index/index.vue
  2. 1 1
      pages/order/createOrder.vue
  3. 0 7
      pages/product/product.vue
  4. 213 213
      pages/set/address.vue
  5. 1 0
      pages/store/apply.vue
  6. 179 196
      utils/newRequest.js

+ 0 - 19
pages/index/index.vue

@@ -130,25 +130,6 @@ export default {
 				obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
 			}
 		}
-		// 初次加载页面高度时修改页面高度
-		// bastList(newValue, oldValue) {
-		// 	let obj = this;
-		// 	let bHeight = Math.ceil(newValue.length / 2);
-		// 	obj.$nextTick(function() {
-		// 		uni.createSelectorQuery()
-		// 			.select('#list-box')
-		// 			.fields(
-		// 				{
-		// 					size: true
-		// 				},
-		// 				function(data) {
-		// 					obj.pageProportion = data.width / 750;
-		// 					obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
-		// 				}
-		// 			)
-		// 			.exec();
-		// 	});
-		// }
 	},
 	data() {
 		return {

+ 1 - 1
pages/order/createOrder.vue

@@ -13,7 +13,7 @@
 						<text class="name">{{ addressData.real_name }}</text>
 						<text class="mobile">{{ addressData.phone }}</text>
 					</view>
-					<text class="address">{{ addressData.province + addressData.city + addressData.district }} {{ addressData.detail }}</text>
+					<text class="address">{{ addressData.province + addressData.city + addressData.district }} {{addressData.street}} {{addressData.village}} {{ addressData.detail }}</text>
 				</view>
 				<text class="iconfont iconenter"></text>
 			</view>

+ 0 - 7
pages/product/product.vue

@@ -33,11 +33,6 @@
 							{{ actionPrice * goodsNumber }}
 						</view>
 						<image src="../../static/icon/del.png" mode="" class="right-img" @click="close()"></image>
-						<!-- <text class="stock">库存:{{ goodsStore }}件</text> -->
-						<!-- <view class="selected" v-if="specList != ''">
-							已选:
-							<text class="selected-text" v-for="(sItem, sIndex) in specSelected" :key="sIndex">{{ sItem }}</text>
-						</view> -->
 					</view>
 				</view>
 				<view v-for="(item, index) in specList" :key="index" class="attr-list">
@@ -55,10 +50,8 @@
 					</view>
 				</view>
 				<view class="attr-list" v-if="showDrop">
-					<!-- <text>选择是否上门安装</text> -->
 					<view class="item-list">
 						<text class="selected">上门安装</text>
-						<!-- <text :class="{ selected: !is_drop }" @click="dropClick(0)">否</text> -->
 					</view>
 				</view>
 				<view class="mun-box">

+ 213 - 213
pages/set/address.vue

@@ -1,213 +1,213 @@
-<template>
-	<view class="content b-t">
-		<view class="list" v-for="(item, index) in addressList" :key="index" @click="checkAddress(item)">
-			<view class="wrapper">
-				<view class="address-box">
-					<text class="name">{{ item.real_name }}</text>
-					<text class="mobile">{{ item.phone }}</text>
-				</view>
-				<view class="u-box">
-					<text class="address">{{ item.province + item.city + item.district }} {{ item.detail }}</text>
-				</view>
-			</view>
-			<view class="buttom">
-				<view class="default-buttom" @click.stop="defaultUp(item,index)">
-					<view class="iconfont iconroundcheckfill checkbox" :class="{ checked: item.is_default == 1 }"></view>
-					<text class="text">设为默认地址</text>
-				</view>
-				<view class="operation">
-					<view @click.stop="addAddress('edit', item)">
-						<text class="iconfont iconedit"></text>
-						<text class="text">编辑</text>
-					</view>
-					<view class="blank"></view>
-					<view @click.stop="delAddress(item)">
-						<text class="iconfont icondelete"></text>
-						<text class="text">删除</text>
-					</view>
-				</view>
-			</view>
-		</view>
-		<button class="add-btn" @click="addAddress('add')">新增地址</button>
-	</view>
-</template>
-
-<script>
-import { getAddressList,setAddressDefault,addressDel } from '@/api/user.js';
-export default {
-	data() {
-		return {
-			source: 0,
-			addressList: []
-		};
-	},
-	onLoad(option) {
-		this.source = option.source||0
-		this.loadAddress();
-	},
-	methods: {
-		// 加载地址
-		loadAddress() {
-			getAddressList({
-				page: 1,
-				limit: 100
-			}).then(({ data }) => {
-				this.addressList = data;
-			});
-		},
-		// 设为默认地址
-		defaultUp(data,ind) {
-			this.addressList=this.addressList.map((e) => {
-				e.is_default=0
-				return e
-			})
-			this.addressList[ind].is_default=1
-			setAddressDefault({
-				id: data.id
-			}).then(({ data }) => {
-				this.loadAddress();
-			}).catch((e) => {
-				console.log(e);
-			});
-		},
-		//删除地址
-		delAddress(item) {
-			addressDel({
-				id:item.id
-			}).then(({data})=>{
-				this.$api.msg('删除成功')
-			})
-			let s = this.addressList.indexOf(item);
-			this.addressList.splice(s, 1);
-		},
-		//选择地址
-		checkAddress(item) {
-			if (this.source == 1) {
-				//this.$api.prePage()获取上一页实例,在App.vue定义
-				this.$api.prePage().addressData = item;
-				uni.navigateBack();
-			}
-		},
-		// 添加地址
-		addAddress(type, item) {
-			let url=`/pages/set/addressManage?type=${type}`
-			if(item&&item.id){
-				url += `&id=${item.id}`;
-			}
-			
-			uni.navigateTo({
-				url
-			});
-		},
-		//添加或修改成功之后回调
-		refreshList() {
-			// 重新加载地址
-			this.loadAddress()
-		}
-	}
-};
-</script>
-
-<style lang="scss">
-page {
-	padding-bottom: 120rpx;
-	padding-top: 20rpx;
-	background-color: $page-color-base;
-}
-.content {
-	position: relative;
-}
-.list {
-	align-items: center;
-	padding: 20rpx 30rpx;
-	background: #fff;
-	margin: 20rpx;
-	margin-top: 0;
-	.buttom {
-		display: flex;
-		align-items: center;
-		justify-content: space-between;
-		padding-top: 10rpx;
-		.checkbox {
-			font-size: 44rpx;
-			line-height: 1;
-			padding: 4rpx;
-			color: $font-color-disabled;
-			background: #fff;
-			border-radius: 50px;
-		}
-		.checkbox.checked {
-			color: $base-color;
-		}
-		.default-buttom {
-			display: flex;
-			align-items: center;
-		}
-		.operation {
-			display: flex;
-			align-items: center;
-			.blank {
-				width: 30rpx;
-			}
-		}
-		.text {
-			padding-left: 10rpx;
-			font-size: 24rpx;
-			color: #666666;
-		}
-	}
-}
-.wrapper {
-	display: flex;
-	flex-direction: column;
-	flex: 1;
-	border-bottom: 1px solid #f0f0f0;
-	padding-bottom: 20rpx;
-}
-.address-box {
-	display: flex;
-	align-items: center;
-	justify-content: space-between;
-	.address {
-		font-size: $font-base + 2rpx;
-		color: $font-color-dark;
-	}
-	.mobile {
-		font-size: $font-base;
-		color: rgba(51, 51, 51, 1);
-	}
-}
-.u-box {
-	font-size: $font-base;
-	color: $font-color-light;
-	margin-top: 16rpx;
-	.name {
-		margin-right: 30rpx;
-	}
-}
-.icon-bianji {
-	display: flex;
-	align-items: center;
-	height: 80rpx;
-	font-size: 40rpx;
-	color: $font-color-light;
-	padding-left: 30rpx;
-}
-
-.add-btn {
-	position: fixed;
-	left: 30rpx;
-	right: 30rpx;
-	bottom: 16rpx;
-	z-index: 95;
-	display: flex;
-	align-items: center;
-	justify-content: center;
-	width: 690rpx;
-	height: 80rpx;
-	font-size: $font-lg;
-	color: #fff;
-	background-color: $base-color;
-	border-radius: 10rpx;
-}
-</style>
+<template>
+	<view class="content b-t">
+		<view class="list" v-for="(item, index) in addressList" :key="index" @click="checkAddress(item)">
+			<view class="wrapper">
+				<view class="address-box">
+					<text class="name">{{ item.real_name }}</text>
+					<text class="mobile">{{ item.phone }}</text>
+				</view>
+				<view class="u-box">
+					<text class="address">{{ item.province + item.city + item.district }} {{item.street}} {{item.village}} {{ item.detail }}</text>
+				</view>
+			</view>
+			<view class="buttom">
+				<view class="default-buttom" @click.stop="defaultUp(item,index)">
+					<view class="iconfont iconroundcheckfill checkbox" :class="{ checked: item.is_default == 1 }"></view>
+					<text class="text">设为默认地址</text>
+				</view>
+				<view class="operation">
+					<view @click.stop="addAddress('edit', item)">
+						<text class="iconfont iconedit"></text>
+						<text class="text">编辑</text>
+					</view>
+					<view class="blank"></view>
+					<view @click.stop="delAddress(item)">
+						<text class="iconfont icondelete"></text>
+						<text class="text">删除</text>
+					</view>
+				</view>
+			</view>
+		</view>
+		<button class="add-btn" @click="addAddress('add')">新增地址</button>
+	</view>
+</template>
+
+<script>
+import { getAddressList,setAddressDefault,addressDel } from '@/api/user.js';
+export default {
+	data() {
+		return {
+			source: 0,
+			addressList: []
+		};
+	},
+	onLoad(option) {
+		this.source = option.source||0
+		this.loadAddress();
+	},
+	methods: {
+		// 加载地址
+		loadAddress() {
+			getAddressList({
+				page: 1,
+				limit: 100
+			}).then(({ data }) => {
+				this.addressList = data;
+			});
+		},
+		// 设为默认地址
+		defaultUp(data,ind) {
+			this.addressList=this.addressList.map((e) => {
+				e.is_default=0
+				return e
+			})
+			this.addressList[ind].is_default=1
+			setAddressDefault({
+				id: data.id
+			}).then(({ data }) => {
+				this.loadAddress();
+			}).catch((e) => {
+				console.log(e);
+			});
+		},
+		//删除地址
+		delAddress(item) {
+			addressDel({
+				id:item.id
+			}).then(({data})=>{
+				this.$api.msg('删除成功')
+			})
+			let s = this.addressList.indexOf(item);
+			this.addressList.splice(s, 1);
+		},
+		//选择地址
+		checkAddress(item) {
+			if (this.source == 1) {
+				//this.$api.prePage()获取上一页实例,在App.vue定义
+				this.$api.prePage().addressData = item;
+				uni.navigateBack();
+			}
+		},
+		// 添加地址
+		addAddress(type, item) {
+			let url=`/pages/set/addressManage?type=${type}`
+			if(item&&item.id){
+				url += `&id=${item.id}`;
+			}
+			
+			uni.navigateTo({
+				url
+			});
+		},
+		//添加或修改成功之后回调
+		refreshList() {
+			// 重新加载地址
+			this.loadAddress()
+		}
+	}
+};
+</script>
+
+<style lang="scss">
+page {
+	padding-bottom: 120rpx;
+	padding-top: 20rpx;
+	background-color: $page-color-base;
+}
+.content {
+	position: relative;
+}
+.list {
+	align-items: center;
+	padding: 20rpx 30rpx;
+	background: #fff;
+	margin: 20rpx;
+	margin-top: 0;
+	.buttom {
+		display: flex;
+		align-items: center;
+		justify-content: space-between;
+		padding-top: 10rpx;
+		.checkbox {
+			font-size: 44rpx;
+			line-height: 1;
+			padding: 4rpx;
+			color: $font-color-disabled;
+			background: #fff;
+			border-radius: 50px;
+		}
+		.checkbox.checked {
+			color: $base-color;
+		}
+		.default-buttom {
+			display: flex;
+			align-items: center;
+		}
+		.operation {
+			display: flex;
+			align-items: center;
+			.blank {
+				width: 30rpx;
+			}
+		}
+		.text {
+			padding-left: 10rpx;
+			font-size: 24rpx;
+			color: #666666;
+		}
+	}
+}
+.wrapper {
+	display: flex;
+	flex-direction: column;
+	flex: 1;
+	border-bottom: 1px solid #f0f0f0;
+	padding-bottom: 20rpx;
+}
+.address-box {
+	display: flex;
+	align-items: center;
+	justify-content: space-between;
+	.address {
+		font-size: $font-base + 2rpx;
+		color: $font-color-dark;
+	}
+	.mobile {
+		font-size: $font-base;
+		color: rgba(51, 51, 51, 1);
+	}
+}
+.u-box {
+	font-size: $font-base;
+	color: $font-color-light;
+	margin-top: 16rpx;
+	.name {
+		margin-right: 30rpx;
+	}
+}
+.icon-bianji {
+	display: flex;
+	align-items: center;
+	height: 80rpx;
+	font-size: 40rpx;
+	color: $font-color-light;
+	padding-left: 30rpx;
+}
+
+.add-btn {
+	position: fixed;
+	left: 30rpx;
+	right: 30rpx;
+	bottom: 16rpx;
+	z-index: 95;
+	display: flex;
+	align-items: center;
+	justify-content: center;
+	width: 690rpx;
+	height: 80rpx;
+	font-size: $font-lg;
+	color: #fff;
+	background-color: $base-color;
+	border-radius: 10rpx;
+}
+</style>

+ 1 - 0
pages/store/apply.vue

@@ -155,6 +155,7 @@ export default {
 				filename: ''
 			}).then(res => {
 				console.log(res[0].url);
+				
 				obj[item] = res[0].url
 			}).catch( err => {
 				console.log(err)

+ 179 - 196
utils/newRequest.js

@@ -1,196 +1,179 @@
-import store from '../store'
-let service = {
-	baseURL: store.state.baseURL, // 请求头
-	header: {
-		'Content-Type': "application/x-www-form-urlencoded"
-	},
-	// 请求拦截器
-	interceptors: {
-		// 安装请求前拦截
-		request: function(success, iserror) {
-			service.request.success = success;
-			service.request.error = iserror;
-		},
-		// 安装请求完成后拦截
-		response: function(success, iserror) {
-			service.response.success = success;
-			service.response.error = iserror;
-		}
-	},
-	// 请求前拦截
-	request: {
-		// 回调成功执行方法
-		success: function(e) {
-			return e
-		},
-		// 回调失败
-		error: function(e) {
-			return e
-		}
-	},
-	// 请求完成后拦截
-	response: {
-		// 回调成功执行方法
-		success: function(e) {
-			return e
-		},
-		// 回调失败
-		error: function(e) {
-			return e
-		}
-	},
-	// 开始请求
-	open: async function(data) {
-		return await new Promise(function(resolve, reject) {
-			let requestData = ''; //保存处理完成后请求数据
-			let url =''//保存链接地址
-			//console.log(data);
-			// 请求前数据处理
-			requestData = service.request.success(data);
-			// #ifdef H5
-			
-			if(process.env.NODE_ENV === 'development'){
-				url= requestData.url;
-			    console.log('开发环境')
-			}else{
-				url=service.baseURL + requestData.url;
-			    console.log('生产环境')
-			}
-			// #endif
-			// #ifndef H5
-			url=service.baseURL + requestData.url;
-			// #endif
-			// 数据复制用于请求
-			uni.request({
-				url:url,
-				method: requestData.method || 'GET',
-				data: requestData.data,
-				header: data.header || service.header,
-				success: res => {
-					if (res.statusCode == 200) {
-						try {
-							resolve(service.response.success(res));
-						} catch (e) {
-							service.response.error(e)
-						}
-					}
-
-				},
-				// 请求失败数据处理
-				fail: (err) => {
-					service.response.error(err)
-				}
-			});
-		})
-	},
-	// 上传文件
-	upFilse: async function(data) {
-		return await new Promise(function(resolve, reject) {
-			let requestData = ''; //保存处理完成后请求数据
-			let url = '' //保存请求地址
-			try {
-				// 请求前数据处理
-				requestData = service.request.success(data);
-			} catch (e) {
-				// 请求报错拦截
-				service.request.error(e);
-			}
-			// #ifdef H5
-			if(process.env.NODE_ENV === 'development'){
-				url= requestData.url;
-			    console.log('开发环境')
-			}else{
-				url=service.baseURL + requestData.url;
-			    console.log('生产环境')
-			}
-			// #endif
-			// #ifndef H5
-			url=service.baseURL + requestData.url;
-			// #endif
-			let config = {
-				// 上传图片的API
-				upload_img_url:url
-			}
-
-			let Uploader = {
-				// 选择图片
-				choose(num) {
-					return new Promise((resolve, reject) => {
-						uni.chooseImage({
-							count: num,
-							success(res) {
-								// console.log(res);
-								// 缓存文件路径
-								resolve(res.tempFilePaths)
-							},
-							fail(err) {
-								console.log(err)
-								reject(err)
-							}
-						})
-					})
-
-				},
-				// 上传图片
-				upload_one(path) {
-					return new Promise((resolve, reject) => {
-						uni.showLoading({
-							title: '上传中'
-						})
-						uni.uploadFile({
-							url: config.upload_img_url, //仅为示例,非真实的接口地址
-							filePath: path,
-							name: 'file',
-							header: {
-								"Authori-zation": 'Bearer ' + uni.getStorageSync('token')
-							},
-							success: (uploadFileRes) => {
-								if ("string" === typeof uploadFileRes.data) {
-									resolve(JSON.parse(uploadFileRes.data).data)
-								} else {
-									resolve(uploadFileRes.data.data)
-								}
-							},
-							complete() {
-								uni.hideLoading()
-							}
-						});
-					})
-				},
-				// 上传多个图片
-				upload(path_arr) {
-					let num = path_arr.length;
-					return new Promise(async (resolve, reject) => {
-						let img_urls = []
-						for (let i = 0; i < num; i++) {
-							let img_url = await this.upload_one(path_arr[i]);
-							img_urls.push(img_url)
-						};
-						resolve(img_urls)
-					})
-				},
-				// 触发上传图片事件
-				choose_and_upload(num) {
-					return new Promise(async (resolve, reject) => {
-						// 选择图片
-						let path_arr = await this.choose(num);
-						// 上传图片
-						await this.upload(path_arr).then((e) => {
-							resolve(e);
-						}).catch((e) => {
-							reject(e)
-						});
-					})
-				}
-			};
-			Uploader.choose_and_upload(1).then((e) => {
-				resolve(e);
-			}).catch((e) => {
-				console.log(e);
-			})
-		})
-	},
-};
-
-
-export default service
+import store from '../store'
+let service = {
+	// baseURL: store.state.baseURL, // 请求头
+	baseURL: '', // 请求头
+	header: {
+		'Content-Type': "application/x-www-form-urlencoded"
+	},
+	// 请求拦截器
+	interceptors: {
+		// 安装请求前拦截
+		request: function(success, iserror) {
+			service.request.success = success;
+			service.request.error = iserror;
+		},
+		// 安装请求完成后拦截
+		response: function(success, iserror) {
+			service.response.success = success;
+			service.response.error = iserror;
+		}
+	},
+	// 请求前拦截
+	request: {
+		// 回调成功执行方法
+		success: function(e) {
+			return e
+		},
+		// 回调失败
+		error: function(e) {
+			return e
+		}
+	},
+	// 请求完成后拦截
+	response: {
+		// 回调成功执行方法
+		success: function(e) {
+			return e
+		},
+		// 回调失败
+		error: function(e) {
+			return e
+		}
+	},
+	// 开始请求
+	open: async function(data) {
+		return await new Promise(function(resolve, reject) {
+			let requestData = ''; //保存处理完成后请求数据
+			//console.log(data);
+			// 请求前数据处理
+			requestData = service.request.success(data);
+			// 保存请求地址;
+			let url;
+			if (requestData.url.indexOf('http') > -1) {
+				url = requestData.url
+			} else {
+				url = service.baseURL + requestData.url
+			}
+			// 数据复制用于请求
+			uni.request({
+				url: url,
+				method: requestData.method || 'GET',
+				data: requestData.data,
+				header: data.header || service.header,
+				success: res => {
+					if (res.statusCode == 200) {
+						try {
+							resolve(service.response.success(res));
+						} catch (e) {
+							service.response.error(e)
+						}
+					}
+
+				},
+				// 请求失败数据处理
+				fail: (err) => {
+					service.response.error(err)
+				}
+			});
+		})
+	},
+	// 上传文件
+	upFilse: async function(data) {
+		return await new Promise(function(resolve, reject) {
+			let requestData = ''; //保存处理完成后请求数据
+			try {
+				// 请求前数据处理
+				requestData = service.request.success(data);
+			} catch (e) {
+				// 请求报错拦截
+				service.request.error(e);
+			}
+			let config = {
+				// 上传图片的API
+				upload_img_url: service.baseURL + requestData.url
+			}
+
+			let Uploader = {
+				// 选择图片
+				choose(num) {
+					return new Promise((resolve, reject) => {
+						uni.chooseImage({
+							count: num,
+							sourceType: ['album'],
+							sizeType: ['compressed'],
+							success(res) {
+								// console.log(res);
+								// 缓存文件路径
+								resolve(res.tempFilePaths)
+							},
+							fail(err) {
+								console.log(err)
+								reject(err)
+							}
+						})
+					})
+				},
+				// 上传图片
+				upload_one(path) {
+					return new Promise((resolve, reject) => {
+						uni.showLoading({
+							title: '上传中'
+						})
+						uni.uploadFile({
+							url: config.upload_img_url, //仅为示例,非真实的接口地址
+							filePath: path,
+							name: 'file',
+							header: {
+								"Authori-zation": 'Bearer ' + uni.getStorageSync('token')
+							},
+							success: (uploadFileRes) => {
+								if ("string" === typeof uploadFileRes.data) {
+									resolve(JSON.parse(uploadFileRes.data).data)
+								} else {
+									resolve(uploadFileRes.data.data)
+								}
+								
+							},
+							complete: () =>{
+								uni.hideLoading()
+							}
+						});
+					})
+				},
+				// 上传多个图片
+				upload(path_arr) {
+					let num = path_arr.length;
+					return new Promise(async (resolve, reject) => {
+						let img_urls = []
+						for (let i = 0; i < num; i++) {
+							let img_url = await this.upload_one(path_arr[i]);
+							img_urls.push(img_url)
+						};
+						resolve(img_urls)
+					})
+				},
+				// 触发上传图片事件
+				choose_and_upload(num) {
+					return new Promise(async (resolve, reject) => {
+						// 选择图片
+						let path_arr = await this.choose(num);
+						// 上传图片
+						await this.upload(path_arr).then((e) => {
+							resolve(e);
+						}).catch((e) => {
+							reject(e)
+						});
+					})
+				}
+			};
+			Uploader.choose_and_upload(1).then((e) => {
+				resolve(e);
+			}).catch((e) => {
+				console.log(e);
+			})
+		})
+	},
+};
+
+
+export default service