Explorar el Código

fix 压缩图片

he2802 hace 4 años
padre
commit
310215d1bd

+ 10 - 4
common/methodTool.js

@@ -20,14 +20,20 @@ export default {
 		}, 500)
 	},
 	//图片路径填补
-	splitImgHost(url) {
+	splitImgHost(url,scale=false,width=250) {
 		if (!url) {
 			return ''
 		}
-		if (url.indexOf("http") != -1 || url.indexOf("https") != -1) {
-			return url;
+		else if (url.indexOf("http") != -1 || url.indexOf("https") != -1) {
+			
+		}else{
+			url = baseUrls.BASE_IMG_URL + url
 		}
-		return baseUrls.BASE_IMG_URL + url
+		if(scale){
+			url = url+"?x-oss-process=image/resize,w_"+width
+		}
+		return url;
+		
 	},
 	exit() {
 		uni.removeStorageSync('union_id')

+ 4 - 4
components/home.vue

@@ -96,7 +96,7 @@
 						<u-empty  margin-top="150" text="暂无课程" mode="data"></u-empty>
 					</view>
 					<view v-else @click="jumpDetail(item)" class="list_box" v-for="(item, index) in list1" :key="index">
-						<image :src="$method.splitImgHost(item.coverUrl)" class="list_img"></image>
+						<image :src="$method.splitImgHost(item.coverUrl,true)" class="list_img"></image>
 						<view class="list_content">
 							<view style="margin-left: 280rpx;margin-top: 10rpx;">
 								<view class="list_title">{{ item.courseName }}</view>
@@ -114,7 +114,7 @@
 						<u-empty  margin-top="150" text="暂无题库" mode="data"></u-empty>
 					</view>
 					<view v-else @click="jumpDetail(item)" class="list_box" v-for="(item, index) in list2" :key="index">
-						<image :src="$method.splitImgHost(item.coverUrl)" class="list_img"></image>
+						<image :src="$method.splitImgHost(item.coverUrl,true)" class="list_img"></image>
 						<view class="list_content">
 							<view style="margin-left: 280rpx;margin-top: 10rpx;">
 								<view class="list_title">{{ item.bankName }}</view>
@@ -132,7 +132,7 @@
 						<u-empty  margin-top="150" text="暂无重点考点" mode="data"></u-empty>
 					</view>
 					<view v-else @click="jumpDetail(item)" class="list_box" v-for="(item, index) in list3" :key="index">
-						<image :src="$method.splitImgHost(item.coverUrl)" class="list_img"></image>
+						<image :src="$method.splitImgHost(item.coverUrl,true)" class="list_img"></image>
 						<view class="list_content">
 							<view style="margin-left: 280rpx;margin-top: 10rpx;">
 								<view class="list_title">{{ item.name }}</view>
@@ -364,7 +364,7 @@ export default {
 			this.$api.advertisingList().then(res => {
 				let index;
 				for (index in res.data.rows) {
-					res.data.rows[index].image = self.$method.splitImgHost(res.data.rows[index].adverUrl);
+					res.data.rows[index].image = self.$method.splitImgHost(res.data.rows[index].adverUrl,true,500);
 				}
 				self.list = res.data.rows.filter((item,index) => {
 					return item.type === 1

+ 2 - 2
components/my.vue

@@ -5,7 +5,7 @@
 			<u-row>
 				<u-col span="3" offset="1">
 					<navigator url="/pages2/wd/avatar" hover-class="none">
-						<image :src="userInfo != null ? $method.splitImgHost(userInfo.avatar) : ''" class="avatar"></image>
+						<image :src="userInfo != null ? $method.splitImgHost(userInfo.avatar,true) : ''" class="avatar"></image>
 					</navigator>
 				</u-col>
 				<u-col span="6">
@@ -58,7 +58,7 @@
 				</view>
 				<scroll-view class="r_sliper" scroll-x="true">
 					<view v-for="(item, index) in list" :key="index" style="margin-right: 20rpx;display:inline-block" @click="jumpDetail(item)">
-						<image :src="$method.splitImgHost(item.coverUrl)" class="r_image"></image>
+						<image :src="$method.splitImgHost(item.coverUrl,true)" class="r_image"></image>
 						<view class="r_t2">{{ item.courseName }}</view>
 					</view>
 				</scroll-view>

+ 1 - 1
components/recruitment.vue

@@ -20,7 +20,7 @@
 			<swiper class="swiper" :autoplay="true" previous-margin="15px" next-margin="15px" :circular="true">
 				<swiper-item v-for="(item, index) in list" :key="index" style="padding: 0px 5px;box-sizing: border-box;">
 					<view style="height: 100%;border-radius: 8px;overflow: hidden;">
-						<image :src="$method.splitImgHost(item.adverUrl)" mode="" style="width: 100%;height: 100%;" @click="swiperClick(index)"></image>
+						<image :src="$method.splitImgHost(item.adverUrl,true,500)" mode="" style="width: 100%;height: 100%;" @click="swiperClick(index)"></image>
 					</view>
 				</swiper-item>
 			</swiper>

+ 7 - 5
pages2/course/detail.vue

@@ -733,11 +733,13 @@ export default {
 						self.faceGetState = true;
 						self.$api.facecertificationPicDetectInfo(self.BizToken).then(faceRec => {
 							if (faceRec.data.data === 0) {
-								uni.showToast({
-									title: '识别成功',
-									icon: 'none',
-									duration: 2000
-								});
+								setTimeout(() => {
+									uni.showToast({
+										title: '识别成功',
+										icon: 'none',
+										duration: 2000
+									});
+								}, 500);
 							} else {
 								uni.showToast({
 									title: '识别失败',

+ 6 - 1
pages2/wd/avatar.vue

@@ -71,9 +71,14 @@
 						imageStatus: int
 					};
 					self.$api.aliyunpolicy(data).then(res => {
+						console.log(res.data,6)
+						if(res.data.code!=200){
+							self.$method.showToast('签名错误'+JSON.stringify(res.data))
+							return
+						}
 						var ossToken = res.data.data.resultContent;
 						if(ossToken.host==null||ossToken.host==undefined){
-							self.$method.showToast('上传路径报错'+ossToken)
+							self.$method.showToast('上传路径报错'+JSON.stringify(res.data))
 							return
 						}
 						uni.uploadFile({

+ 3 - 3
pages2/wd/collect.vue

@@ -13,7 +13,7 @@
 						<u-row >
 							<u-col span="5" >
 								<view style="padding: 5rpx;">
-									<image :src="$method.splitImgHost(item.coverUrl)" class="c_img"></image>
+									<image :src="$method.splitImgHost(item.coverUrl,true)" class="c_img"></image>
 								</view>
 							</u-col>
 							<u-col span="7" >
@@ -37,7 +37,7 @@
 		        		<u-row >
 		        			<u-col span="5" >
 		        				<view style="padding: 5rpx;">
-		        					<image :src="$method.splitImgHost(item.coverUrl)" class="c_img"></image>
+		        					<image :src="$method.splitImgHost(item.coverUrl,true)" class="c_img"></image>
 		        				</view>
 		        			</u-col>
 		        			<u-col span="7" >
@@ -61,7 +61,7 @@
 		        		<u-row >
 		        			<u-col span="5" >
 		        				<view style="padding: 5rpx;">
-		        					<image :src="$method.splitImgHost(item.coverUrl)" class="c_img"></image>
+		        					<image :src="$method.splitImgHost(item.coverUrl,true)" class="c_img"></image>
 		        				</view>
 		        			</u-col>
 		        			<u-col span="7" >