Ver Fonte

fan xiang dai li

2312970463@qq.com há 3 anos atrás
pai
commit
5c9950c182
4 ficheiros alterados com 321 adições e 284 exclusões
  1. 1 1
      manifest.json
  2. 6 6
      pages/index/index.vue
  3. 114 81
      pages/product/product.vue
  4. 200 196
      utils/newRequest.js

+ 1 - 1
manifest.json

@@ -73,7 +73,7 @@
         "devServer" : {
             "proxy" : {
                 "/api" : {
-                    "target" : "http://zccy.liuniu946.com", //请求的目标域名
+                    "target" : "https://zccy.liuniu946.com", //请求的目标域名
                     "changeOrigin" : true,
                     // "secure": false,
                     "pathRewrite" : {

+ 6 - 6
pages/index/index.vue

@@ -306,12 +306,12 @@ export default {
 			});
 		}
 		// #endif
-		uni.request({
-			complete(res) {
-				console.log(res);
-			},
-			url: 'http://base.liuniu946.com/api/index'
-		});
+		// uni.request({
+		// 	complete(res) {
+		// 		console.log(res);
+		// 	},
+		// 	url: 'http://base.liuniu946.com/api/index'
+		// });
 	},
 	onShow: function() {
 		// 判断是否强制登录

+ 114 - 81
pages/product/product.vue

@@ -5,7 +5,11 @@
 		<view class="sckill-top" v-if="isSckill">
 			<view class="top-left">
 				<view class="left-top">限时秒杀价</view>
-				<view class="left-btm">¥<text class="now-pri">{{sckillGoodInfo.price}}</text><text class="old-pri">¥{{sckillGoodInfo.ot_price}}</text></view>
+				<view class="left-btm">
+					¥
+					<text class="now-pri">{{ sckillGoodInfo.price }}</text>
+					<text class="old-pri">¥{{ sckillGoodInfo.ot_price }}</text>
+				</view>
 			</view>
 			<view class="top-right">
 				<view class="right-top">距离本场结束还剩</view>
@@ -23,9 +27,9 @@
 		</view>
 		<!-- 标题 -->
 		<product-content :goodsObjact="goodsObjact" v-if="!isSckill"></product-content>
-		<view class="good-title clamp2"  v-if="isSckill">{{sckillGoodInfo.title}}</view>
+		<view class="good-title clamp2" v-if="isSckill">{{ sckillGoodInfo.title }}</view>
 		<!-- 选择数量 -->
-<!-- 		<view class="row b-b">
+		<!-- 		<view class="row b-b">
 			<text class="tit">选择</text>
 			<picker mode="selector" :range="choNum" @change="bindChange">
 				<view class="refund" v-if="goodsNumber !== 1">{{ goodsNumber || '请选择' }}</view>
@@ -40,14 +44,17 @@
 		<view class="shop-info">
 			<view class="shop-logo"><image :src="shopInfo.mer_avatar" mode=""></image></view>
 			<view class="shop-base">
-				<view class="base-name">{{shopInfo.mer_name}}</view>
-				<view class="base-addr clamp">{{shopInfo.mer_address}}</view>
+				<view class="base-name">{{ shopInfo.mer_name }}</view>
+				<view class="base-addr clamp">{{ shopInfo.mer_address }}</view>
+			</view>
+			<view class="shop-dis">
+				<image src="../../static/icon/base_addr.png" mode="aspectFill"></image>
+				距离200m
 			</view>
-			<view class="shop-dis"><image src="../../static/icon/base_addr.png" mode="aspectFill"></image>距离200m</view>
 		</view>
 		<!-- 评价 -->
 		<estimate @navTo="navTo('/pages/product/reply?id=' + product_id)" v-if="reply" :reply="reply" :list="list"></estimate>
-		
+
 		<!-- 规格信息 -->
 		<!-- <fresh-detail :goodsObjact="goodsObjact"></fresh-detail> -->
 		<!-- 图文详情 -->
@@ -125,7 +132,7 @@ import guessLike from './common/guessLike.vue';
 // 评价
 import estimate from './common/estimate.vue';
 import uniNumberBox from '@/components/uni-number-box.vue';
-import {timeComputed} from '@/utils/rocessor.js'
+import { timeComputed } from '@/utils/rocessor.js';
 export default {
 	components: {
 		guessLike,
@@ -158,7 +165,7 @@ export default {
 				percent: 1
 			}, //保存商品数据
 			//图片循环
-			imgList: [],//顶部轮播图
+			imgList: [], //顶部轮播图
 			// 对比对象
 			actionPrice: 0, //默认选中商品价格
 			actionImage: '', //默认选中图片
@@ -196,11 +203,10 @@ export default {
 				seconds: 0,
 				day: 0,
 				tpye: false
-				
 			},
-			product_id:0,
-			sckillGoodInfo: {},//秒杀商品信息
-			shopInfo: {},//店铺信息
+			product_id: 0,
+			sckillGoodInfo: {}, //秒杀商品信息
+			shopInfo: {} //店铺信息
 		};
 	},
 	filters: {
@@ -215,14 +221,14 @@ export default {
 		}
 	},
 	async onLoad(options) {
-		console.log(options)
-		
+		console.log(options);
+
 		let obj = this;
 		obj.userInfo = uni.getStorageSync('userInfo');
 		//保存商品id
 		this.goodsid = options.id;
-		this.getGoodsDetails()
-		this.product_id = options.id
+		this.getGoodsDetails();
+		this.product_id = options.id;
 		this.goodsType = options.type;
 		// 判断有无人邀请
 		if (options.spread) {
@@ -230,8 +236,7 @@ export default {
 			uni.setStorageSync('spread', options.spread);
 		}
 		saveUrl();
-		
-		
+
 		// if(options.type === '1') {
 		// 	obj.getGoodInfo()
 		// 	// obj.getTime()
@@ -241,8 +246,8 @@ export default {
 		// }else {
 		// 	this.goodsDetail();
 		// }
-		if(options.type === '1'){
-			obj.isSckill = true
+		if (options.type === '1') {
+			obj.isSckill = true;
 		}
 		// 注册邀请信息
 		// #ifdef H5
@@ -251,16 +256,15 @@ export default {
 			weixindata();
 		}
 		// #endif
-		
 	},
 	computed: {
 		...mapState(['weichatObj', 'baseURL', 'urlFile']),
 		choNum() {
-			let a = []
-			for(let i = 1 ; i <= this.goodsNumberMax ; i++ ){
-				a.push(i)
+			let a = [];
+			for (let i = 1; i <= this.goodsNumberMax; i++) {
+				a.push(i);
 			}
-			return a
+			return a;
 		}
 	},
 	// 分享
@@ -310,9 +314,10 @@ export default {
 				obj.actionImage = obj.productValue[str].image;
 				obj.uniqueId = obj.productValue[str].unique;
 				obj.goodsStore = obj.productValue[str].stock;
-				console.log(obj.uniqueId,'++++++++obj.uniqueId')
+				console.log(obj.uniqueId, '++++++++obj.uniqueId');
 			} else {
-				(obj.buys_show = false), (obj.buys_shows = true);
+				obj.buys_show = false
+				obj.buys_shows = true
 			}
 			if (obj.goodsStore == 0) {
 				obj.buys_show = false;
@@ -321,10 +326,10 @@ export default {
 			obj.specSelected[ind] = item.attr;
 		},
 		// 打開彈窗
-		specOPne(type=1) {
+		specOPne(type = 1) {
 			let obj = this;
 			obj.specClass = 'show';
-			obj.type = type
+			obj.type = type;
 		},
 		//规格弹窗开关
 		toggleSpec(str) {
@@ -361,7 +366,7 @@ export default {
 		//加入购物车
 		Addcar(item) {
 			let obj = this;
-			console.log("加入购物车",obj.goodsNumber)
+			console.log('加入购物车', obj.goodsNumber);
 			cartAdd({
 				// cartNum: '1', //商品数量
 				cartNum: obj.goodsNumber,
@@ -389,12 +394,12 @@ export default {
 			// 获取普通商品信息
 			goodsDetail({}, this.goodsid).then(function({ data }) {
 				obj.list = data;
-				console.log(data)
+				console.log(data);
 				obj.good_list = data.good_list; //保存猜你喜欢列表
 				obj.reply = data.reply; //保存评论列表
 				let goods = data.storeInfo;
 				obj.goodsObjact = goods;
-				console.log(obj.goodsObjact,"++++++++++++++")
+				console.log(obj.goodsObjact, '++++++++++++++');
 				if (obj.goodsObjact.description != null) {
 					obj.description = obj.goodsObjact.description.replace(/\<img/gi, '<img class="rich-img"');
 				} //小程序商品详情图超出屏幕问题
@@ -433,15 +438,15 @@ export default {
 			let obj = this;
 			// 获取秒杀商品信息
 			seckillGoods({}, this.goodsid).then(function({ data }) {
-				console.log(data)
+				console.log(data);
 				obj.list = data;
 				obj.good_list = data.good_list; //保存猜你喜欢列表
 				obj.reply = data.reply; //保存评论列表
 				let goods = data.storeInfo;
 				obj.goodsObjact = goods;
-				obj.goodsObjact.title = goods.title
-				obj.stopTimes = timeComputed(obj.list.isSeckillEnd.stop*1000)
-				console.log(obj.stopTimes,'dddddddddd')
+				obj.goodsObjact.title = goods.title;
+				obj.stopTimes = timeComputed(obj.list.isSeckillEnd.stop * 1000);
+				console.log(obj.stopTimes, 'dddddddddd');
 				if (obj.goodsObjact.description != null) {
 					obj.description = obj.goodsObjact.description.replace(/\<img/gi, '<img class="rich-img"');
 				} //小程序商品详情图超出屏幕问题
@@ -451,7 +456,7 @@ export default {
 					obj.many = 2;
 					obj.specList = data.productAttr; //保存产品属性
 					obj.productValue = data.productValue; //保存属性值
-					console.log(obj.productValue,'obj.productValue++++++++')
+					console.log(obj.productValue, 'obj.productValue++++++++');
 					obj.specSelected = []; //初始化默认选择对象
 					for (let i = 0; i < obj.specList.length; i++) {
 						// 设置默认数据
@@ -466,7 +471,7 @@ export default {
 					obj.goodsNumberMax = obj.productValue[str].stock;
 					obj.actionImage = obj.productValue[str].image;
 					obj.uniqueId = obj.productValue[str].unique;
-					console.log(obj.uniqueId,"obj.uniqueId+++默认")
+					console.log(obj.uniqueId, 'obj.uniqueId+++默认');
 					obj.goodsStore = obj.productValue[str].quota;
 				} else {
 					obj.many = 1;
@@ -476,25 +481,24 @@ export default {
 				obj.actionImage = goods.image_base; //保存默认选中商品图片
 				obj.goodsNumberMax = goods.stock; //保存默认选中最大可购买商品数量
 				obj.shopId = data.mer_id; //保存商店id
-				
 			});
 		},
 		// 立即购买
 		buy() {
 			let obj = this;
 			// 创建传值对象
-			let goodId = obj.goodsid
-			if(obj.isSckill) {
-				goodId = obj.product_id
+			let goodId = obj.goodsid;
+			if (obj.isSckill) {
+				goodId = obj.product_id;
 			}
-			console.log("添加的数量",obj.goodsNumber)
+			console.log('添加的数量', obj.goodsNumber);
 			let data = {
-					cartNum: obj.goodsNumber, //商品数量
-					new: 1,
-					productId: goodId,//商品编号
-					uniqueId:obj.uniqueId
-				};
-			
+				cartNum: obj.goodsNumber, //商品数量
+				new: 1,
+				productId: goodId, //商品编号
+				uniqueId: obj.uniqueId
+			};
+			console.log(data);
 			if (obj.type == 2) {
 				data.new = 0;
 			}
@@ -516,7 +520,7 @@ export default {
 						});
 						obj.goodsDetail();
 					}
-					obj.toggleSpec()
+					obj.toggleSpec();
 				})
 				.catch(e => {
 					console.log(e);
@@ -525,39 +529,69 @@ export default {
 		// 阻止触发上级事件
 		stopPrevent() {},
 		bindChange(e) {
-			this.goodsNumber = this.choNum[e.detail.value]*1;
-			console.log(this.goodsNumber)
+			this.goodsNumber = this.choNum[e.detail.value] * 1;
+			console.log(this.goodsNumber);
 		},
 		numberChange(e) {
 			//购买数量
 			this.chooseGoodsNumber = e.number;
-			this.goodsNumber = e.number
+			this.goodsNumber = e.number;
 		},
 		// getTime() {
 		// 	let start = new data()
 		// }
 		getGoodsDetails() {
-			let obj = this
-			getSeckillProductDetail({},this.goodsid).then( ({data}) => {
-				console.log(data)
+			let obj = this;
+			getSeckillProductDetail({}, this.goodsid).then(({ data }) => {
+				console.log(data, 'goodInfo6666666666666');
 				obj.imgList = data.slider_image; //保存轮播图
-				obj.sckillGoodInfo.title = data.store_name
-				obj.sckillGoodInfo.price = data.price
-				obj.sckillGoodInfo.ot_price = data.ot_price
-				obj.stopTimes = timeComputed(data.stop*1000)
-				obj.shopInfo.name = data.merchant.mer_name
-				obj.shopInfo.logo = data.merchant.mer_avatar
-				if(data.content.content !== null) {
+				obj.sckillGoodInfo.title = data.store_name; //保存商品名称
+				obj.sckillGoodInfo.price = data.price; //保存商品展示价格
+				obj.sckillGoodInfo.ot_price = data.ot_price; //保存商品市场价
+				obj.stopTimes = timeComputed(data.stop * 1000); //设置结束时间
+				obj.shopInfo.name = data.merchant.mer_name; //保存店铺名称
+				obj.shopInfo.logo = data.merchant.mer_avatar; //保存店铺logo
+				//小程序商品详情图超出屏幕问题
+				if (data.content.content !== null) {
 					obj.description = data.content.content.replace(/\<img/gi, '<img class="rich-img"');
 				}
-				getStoreDetail(data.mer_id).then( ({data}) => {
-					console.log(data,"shop data")
-					obj.shopInfo = data
-					// obj.shopInfo.mer_address = data.mer_address
-					// return item
-					
-				})
-			})
+				//获取保存店铺详细信息
+				getStoreDetail(data.mer_id).then(({ data }) => {
+					console.log(data, 'shop data');
+					obj.shopInfo = data;
+				});
+				// 获取商品属性
+				obj.specList = data.attr; //保存分类列表
+				if (Array.isArray(data.attr) == true) {
+					obj.many = 2;
+					obj.specList = data.attr; //保存产品属性
+					obj.productValue = data.sku; //保存属性值
+					obj.specSelected = []; //初始化默认选择对象
+					for (let i = 0; i < obj.specList.length; i++) {
+						// 设置默认数据
+						let attrValue = obj.specList[i].attr_value[0];
+						attrValue.check = true;
+						obj.specSelected.push(attrValue.attr);
+					}
+					let str = obj.specSelected.join(',');
+					console.log(str, 'str');
+					// 设置默认值
+					obj.actionPrice = obj.productValue[str].price;
+					obj.goodsNumberMax = obj.productValue[str].stock;
+					obj.actionImage = obj.productValue[str].image;
+					obj.uniqueId = obj.productValue[str].unique;
+					obj.goodsStore = obj.productValue[str].quota;
+				} else {
+					obj.many = 1;
+
+					obj.productValue = data.sku; //保存分类查询数据
+					obj.actionPrice = data.price; //保存默认选中商品价格
+					obj.actionImage = data.image; //保存默认选中商品图片
+					obj.goodsNumberMax = data.stock; //保存默认选中最大可购买商品数量
+					obj.shopId = data.mer_id; //保存商店id
+					obj.goodsStore = data.stock
+				}
+			});
 		}
 	}
 };
@@ -786,7 +820,7 @@ page {
 	margin: 20rpx 0;
 	width: 750rpx;
 	height: 83rpx;
-	background: #FFFFFF;
+	background: #ffffff;
 	padding: 29rpx 24rpx 30rpx 25rpx;
 	font-size: 26rpx;
 	font-weight: 500;
@@ -869,7 +903,7 @@ page {
 		position: absolute;
 		font-size: 24rpx;
 		font-weight: 500;
-		color: #901B21;
+		color: #901b21;
 		// line-height: 140rpx;
 		right: 24rpx;
 		image {
@@ -878,7 +912,6 @@ page {
 			height: 21rpx;
 		}
 	}
-	
 }
 .sckill-top {
 	width: 750rpx;
@@ -896,7 +929,7 @@ page {
 			padding: 35rpx 0 23rpx 22rpx;
 			font-size: 44rpx;
 			font-weight: 500;
-			color: #FFFFFF;
+			color: #ffffff;
 			line-height: 1;
 		}
 		.left-btm {
@@ -904,13 +937,13 @@ page {
 			font-size: 30rpx;
 			font-weight: 500;
 			// text-decoration: line-through;
-			color: #FFFFFF;
+			color: #ffffff;
 			.now-pri {
 				display: inline-block;
 				padding-right: 8rpx;
 				font-size: 44rpx;
 				font-weight: 800;
-				color: #FFFFFF;
+				color: #ffffff;
 			}
 			.old-pri {
 				text-decoration: line-through;
@@ -918,11 +951,11 @@ page {
 		}
 	}
 	.top-right {
-		padding:67rpx 20rpx 18rpx 0;
+		padding: 67rpx 20rpx 18rpx 0;
 		.right-top {
 			font-size: 22rpx;
 			font-weight: 400;
-			color: #FFFFFF;
+			color: #ffffff;
 			line-height: 1;
 			padding-bottom: 8rpx;
 		}
@@ -937,4 +970,4 @@ page {
 	font-weight: 800;
 	color: #333333;
 }
-</style>
+</style>

+ 200 - 196
utils/newRequest.js

@@ -1,196 +1,200 @@
-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, // 请求头
+	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
+			console.log(requestData.data);
+			requestData.data = requestData.data ||{};
+			requestData.data.uptime = (new Date()).getTime()
+			// 数据复制用于请求
+			console.log(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 = ''; //保存处理完成后请求数据
+			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