Ver código fonte

图片上传加载优化

xhj 2 anos atrás
pai
commit
c7babfe239

+ 5 - 1
App.vue

@@ -651,7 +651,11 @@
 					chatMsgs = uni.getStorageSync(curMember) || [];
 					console.log('chatMsgs>>>>>', chatMsgs);
 					//过滤消息来源与当前登录ID一致的消息,不计入总数中。
-					chatMsgs = chatMsgs.filter((msg) => msg.yourname !== myName);
+					try{
+						chatMsgs = chatMsgs.filter((msg) => msg.yourname !== myName);
+					}catch(e){
+						//TODO handle the exception
+					}
 					if (pushAry.includes(newName)) return result
 					return result + chatMsgs.length;
 				}, 0);

+ 1 - 1
card/create/create.css

@@ -4,7 +4,7 @@ page{background: #f9f9f9;padding-bottom: 130rpx;}
 .form .li{padding: 30rpx 0;position: relative;}
 .label{font-size: 30rpx;color: #999;width: 160rpx;}
 .photo{justify-content: space-between;}
-.userimg{width: 90rpx;height: 90rpx;border-radius: 50%;}
+.userimg{width: 90rpx;height: 90rpx;border-radius: 6rpx;}
 .rico{width: 15rpx;height: 22rpx;}
 .ipt{font-size: 30rpx;color: #333;}
 .textarea{font-size: 30rpx;color: #333;height: 100rpx;}

+ 27 - 3
card/create/create.vue

@@ -2,7 +2,7 @@
 	<view v-if="!loading">
 		<view class="form">
 			<view class="li ddflex">
-				<view class="label">头像</view>
+				<view class="label">名片页背景</view>
 				<view class="photo ddflex flex" @tap="uploadImgs()">
 					<image :src="avatar ? avatar : '../../static/images/userimg.png'" mode="aspectFill" class="userimg"></image>
 					<image src="../../static/images/rico.png" class="rico"></image>
@@ -212,7 +212,7 @@ export default {
 		getUserInfo(){
 			return new Promise((resolve,reject)=>{
 				req.getRequest('/api/user/info',{},res=>{
-					this.avatar = res.avatar;
+					// this.avatar = res.avatar;
 					this.phone = res.mobile;
 					resolve();
 				})
@@ -302,11 +302,15 @@ export default {
 				sizeType: ['original', 'compressed'],
 				sourceType: ['album', 'camera'],
 				success: function({ tempFilePaths }) {
-					var promise = Promise.all(
+					uni.showLoading({
+						title:'上传中'
+					})
+					var promise =Promise.all(
 						tempFilePaths.map(tempFilePath => {
 							return new Promise(function(resolve, reject) {
 								req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
 									that.avatar = res.src;
+									resolve()
 								});
 							});
 						})
@@ -314,9 +318,11 @@ export default {
 					promise
 						.then(function(results) {
 							console.log(results);
+							uni.hideLoading()
 						})
 						.catch(function(err) {
 							console.log(err);
+							uni.hideLoading()
 						});
 				}
 			});
@@ -328,11 +334,15 @@ export default {
 				sizeType: ['original', 'compressed'],
 				sourceType: ['album', 'camera'],
 				success: function({ tempFilePaths }) {
+					uni.showLoading({
+						title:'上传中'
+					})
 					var promise = Promise.all(
 						tempFilePaths.map(tempFilePath => {
 							return new Promise(function(resolve, reject) {
 								req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
 									that.wechatCode = res.src;
+									resolve()
 								});
 							});
 						})
@@ -340,9 +350,11 @@ export default {
 					promise
 						.then(function(results) {
 							console.log(results);
+							uni.hideLoading()
 						})
 						.catch(function(err) {
 							console.log(err);
+							uni.hideLoading()
 						});
 				}
 			});
@@ -355,6 +367,9 @@ export default {
 				sizeType: ['original', 'compressed'],
 				sourceType: ['album', 'camera'],
 				success: function({ tempFilePaths }) {
+					uni.showLoading({
+						title:'上传中'
+					})
 					var promise = Promise.all(
 						tempFilePaths.map(tempFilePath => {
 							return new Promise(function(resolve, reject) {
@@ -365,6 +380,7 @@ export default {
 									}else{
 										that.honorImgUrls = that.honorImgUrls.concat(res.src)
 									}
+									resolve()
 								});
 							});
 						})
@@ -372,9 +388,11 @@ export default {
 					promise
 						.then(function(results) {
 							console.log(results);
+							uni.hideLoading()
 						})
 						.catch(function(err) {
 							console.log(err);
+							uni.hideLoading()
 						});
 				}
 			});
@@ -391,6 +409,9 @@ export default {
 				sizeType: ['original', 'compressed'],
 				sourceType: ['album', 'camera'],
 				success: function({ tempFilePaths }) {
+					uni.showLoading({
+						title:'上传中'
+					})
 					var promise = Promise.all(
 						tempFilePaths.map(tempFilePath => {
 							return new Promise(function(resolve, reject) {
@@ -401,6 +422,7 @@ export default {
 									}else{
 										that.styleImgUrls = that.styleImgUrls.concat(res.src)
 									}
+									resolve()
 								});
 							});
 						})
@@ -408,9 +430,11 @@ export default {
 					promise
 						.then(function(results) {
 							console.log(results);
+							uni.hideLoading()
 						})
 						.catch(function(err) {
 							console.log(err);
+							uni.hideLoading()
 						});
 				}
 			});

+ 3 - 1
card/evaluate/evaluate.vue

@@ -87,7 +87,7 @@ export default {
 								req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
 									that.picList = that.picList.concat(res.src);
 									console.log('that.picList==',that.picList)
-									uni.hideLoading();
+									resolve()
 								});
 							});
 						})
@@ -95,9 +95,11 @@ export default {
 					promise
 						.then(function(results) {
 							console.log(results);
+							uni.hideLoading()
 						})
 						.catch(function(err) {
 							console.log(err);
+							uni.hideLoading()
 						});
 				}
 			});

+ 1 - 66
card/index/index.vue

@@ -770,72 +770,7 @@ import util from '../../utils/util.js';
 					},
 				})
 			},
-			uploadImg() {
-				let that = this;
-				uni.chooseImage({
-					count: 1,
-					sizeType: ['original', 'compressed'],
-					sourceType: ['album', 'camera'],
-					success: function({
-						tempFilePaths
-					}) {
-						var promise = Promise.all(
-							tempFilePaths.map(tempFilePath => {
-								return new Promise(function(resolve, reject) {
-									req.uploadFile(api.upload, tempFilePath, res => {
-										that.imageMap = res.src;
-										//上传完成,则更新保存
-										that.updateCard(3, that.imageMap);
-									});
-								});
-							})
-						);
-						promise
-							.then(function(results) {
-								console.log(results);
-							})
-							.catch(function(err) {
-								console.log(err);
-							});
-					}
-				});
-			},
-
-			uploadImgs() {
-				let that = this;
-				uni.chooseImage({
-					count: 9,
-					sizeType: ['original', 'compressed'],
-					sourceType: ['album', 'camera'],
-					success: function({
-						tempFilePaths
-					}) {
-						var promise = Promise.all(
-							tempFilePaths.map(tempFilePath => {
-								return new Promise(function(resolve, reject) {
-									req.uploadFile(api.upload, tempFilePath, res => {
-										let picUrls = that.zhiPicUrls;
-										that.zhiPicUrls = picUrls.concat(res.src);
-										if (tempFilePaths.length == that.zhiPicUrls
-											.length) {
-											//上传完成,则更新保存
-											that.updateCard(1, that.zhiPicUrls.join(
-												','));
-										}
-									});
-								});
-							})
-						);
-						promise
-							.then(function(results) {
-								console.log(results);
-							})
-							.catch(function(err) {
-								console.log(err);
-							});
-					}
-				});
-			},
+			
 
 			//预览图片
 			previewImg(picUrls, index) {

+ 6 - 0
match/activityEdit/activityEdit.vue

@@ -211,6 +211,9 @@
 					sizeType: ['original', 'compressed'],
 					sourceType: ['album', 'camera'],
 					success: function({ tempFilePaths }) {
+						uni.showLoading({
+							title:'上传中'
+						})
 						var promise = Promise.all(
 							tempFilePaths.map(tempFilePath => {
 								return new Promise(function(resolve, reject) {
@@ -226,6 +229,7 @@
 												that.fileList = that.fileList.concat(res.src)
 											}
 										}
+										resolve()
 									});
 								});
 							})
@@ -233,9 +237,11 @@
 						promise
 							.then(function(results) {
 								console.log(results);
+								uni.hideLoading()
 							})
 							.catch(function(err) {
 								console.log(err);
+								uni.hideLoading()
 							});
 					}
 				});

+ 5 - 0
match/signPerson/signPerson.vue

@@ -243,6 +243,9 @@ import util from "../../utils/util.js";
 					success: function({
 						tempFilePaths
 					}) {
+						uni.showLoading({
+							title:'上传中'
+						})
 						var promise = Promise.all(
 							tempFilePaths.map(tempFilePath => {
 								return new Promise(function(resolve, reject) {
@@ -260,11 +263,13 @@ import util from "../../utils/util.js";
 						);
 						promise
 							.then(function(results) {
+								uni.hideLoading()
 								item.value = item.value.join(',')
 								that.parmas = JSON.parse(JSON.stringify(that.parmas))
 								console.log(results);
 							})
 							.catch(function(err) {
+								uni.hideLoading()
 								console.log(err);
 							});
 					}

+ 4 - 0
mine/update/index.vue

@@ -54,7 +54,11 @@
 			},
 
 			uploadAvatar(e) {
+				uni.showLoading({
+					title:'上传中'
+				})
 				req.uploadFile('/api/nocheck/upload', e.detail.avatarUrl, res => {
+					uni.hideLoading()
 					this.avatar = res.src
 				});
 			},

+ 4 - 0
mine/userinfo/userinfo.vue

@@ -193,7 +193,11 @@
 			},
 
 			uploadAvatar(e) {
+				uni.showLoading({
+					title:'上传中'
+				})
 				req.uploadFile('/api/nocheck/upload', e.detail.avatarUrl, res => {
+					uni.hideLoading()
 					this.avatar = res.src
 				});
 				// let that = this;

+ 6 - 2
office/createTeam/index.vue

@@ -116,7 +116,7 @@ export default {
 								req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
 									let picUrls = that.zhiPicUrls;
 									that.zhiPicUrls = picUrls.concat(res.src);
-									uni.hideLoading()
+									resolve()
 								});
 							});
 						})
@@ -124,8 +124,10 @@ export default {
 					promise
 						.then(function(results) {
 							console.log(results);
+							uni.hideLoading()
 						})
 						.catch(function(err) {
+							uni.hideLoading()
 							console.log(err);
 						});
 				}
@@ -146,16 +148,18 @@ export default {
 							return new Promise(function(resolve, reject) {
 								req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
 									that.qunCode = res.src;
-									uni.hideLoading()
+									resolve()
 								});
 							});
 						})
 					);
 					promise
 						.then(function(results) {
+							uni.hideLoading()
 							console.log(results);
 						})
 						.catch(function(err) {
+							uni.hideLoading()
 							console.log(err);
 						});
 				}

+ 6 - 0
office/diary/diary.vue

@@ -47,20 +47,26 @@ export default {
 				sizeType: ['original', 'compressed'],
 				sourceType: ['album', 'camera'],
 				success: function({ tempFilePaths }) {
+					uni.showLoading({
+						title:'上传中'
+					})
 					var promise = Promise.all(
 						tempFilePaths.map(tempFilePath => {
 							return new Promise(function(resolve, reject) {
 								req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
 									that.posterUrl = res.src;
+									resolve()
 								});
 							});
 						})
 					);
 					promise
 						.then(function(results) {
+							uni.hideLoading()
 							console.log(results);
 						})
 						.catch(function(err) {
+							uni.hideLoading()
 							console.log(err);
 						});
 				}

+ 3 - 1
office/news/news.vue

@@ -173,16 +173,18 @@ export default {
 								req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
 									let picUrls = that.zhiPicUrls;
 									that.zhiPicUrls = picUrls.concat(res.src);
-									uni.hideLoading()
+									resolve()
 								});
 							});
 						})
 					);
 					promise
 						.then(function(results) {
+							uni.hideLoading()
 							console.log(results);
 						})
 						.catch(function(err) {
+							uni.hideLoading()
 							console.log(err);
 						});
 				}