ソースを参照

Merge branch 'master' of http://git.sjzkeji.com/panghu/school_webUser

zpj 2 年 前
親
コミット
f2a7490b21
1 ファイル変更、28 行追加、26 行削除
  1. 28 26
      pages-position/Internship-position.vue

+ 28 - 26
pages-position/Internship-position.vue

@@ -34,38 +34,40 @@
 				console.log('触底');
 			},
 			saveImg() {
-				let that = this
-				//获取授权列表,查看是否授权写入相册权限
-				uni.getSetting({
-					success(res) {
-						if (!res.authSetting['scope.writePhotosAlbum']) {
-							uni.authorize({
-								scope: 'scope.writePhotosAlbum',
-								success() {
-									that.saveimgtoAlbum(that.codeImg)
+				uni.downloadFile({
+					url: this.codeImg,
+					success: downloadResult => {
+						if (downloadResult.statusCode === 200) {
+							// 下载成功,保存图片到系统相册
+							uni.saveImageToPhotosAlbum({
+								filePath: downloadResult.tempFilePath,
+								success: () => {
+									uni.showToast({
+										title: '图片保存成功'
+									});
+								},
+								fail: () => {
+									uni.showToast({
+										title: '图片保存失败',
+										icon: 'none'
+									});
 								}
-							})
+							});
 						} else {
-							that.saveimgtoAlbum(that.codeImg)
+							uni.showToast({
+								title: '图片下载失败',
+								icon: 'none'
+							});
 						}
-					}
-				})
-			},
-			saveimgtoAlbum(imgurl) {
-				let that = this
-				uni.chooseImage({
-					count: 1,
-					sourceType: ['camera'],
-					success: function(res) {
-						uni.saveImageToPhotosAlbum({
-							filePath: imgurl,
-							success: function() {
-								tools.success("保存成功")
-							}
+					},
+					fail: () => {
+						uni.showToast({
+							title: '图片下载失败',
+							icon: 'none'
 						});
 					}
 				});
-			}
+			},
 		},
 	}
 </script>