From 4aaa7ab2b3dd5769859181622d54d519581b0175 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期一, 29 七月 2024 14:08:00 +0800
Subject: [PATCH] 提交

---
 wechat_staff/utils/common.js |   65 ++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/wechat_staff/utils/common.js b/wechat_staff/utils/common.js
new file mode 100644
index 0000000..fb5e35d
--- /dev/null
+++ b/wechat_staff/utils/common.js
@@ -0,0 +1,65 @@
+export function downloadImg(url) {
+	let that = this
+	wx.showLoading({
+		title: '涓嬭浇涓�...'
+	}); 
+	wx.downloadFile({
+		url: url, //鍥剧墖鍦板潃
+		success: function(res) { 
+			wx.saveImageToPhotosAlbum({
+				filePath: res.tempFilePath, //鍥剧墖鏂囦欢璺緞
+				success: function(data) {
+					wx.hideLoading(); //闅愯棌 loading 鎻愮ず妗�  
+				},
+				// 鎺ュ彛璋冪敤澶辫触鐨勫洖璋冨嚱鏁�
+				fail: function(err) {
+					if (err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" || err
+						.errMsg === "saveImageToPhotosAlbum:fail auth deny" || err
+						.errMsg === "saveImageToPhotosAlbum:fail authorize no response"
+					) {
+						wx.showModal({
+							title: '鎻愮ず',
+							content: '闇�瑕佹偍鎺堟潈淇濆瓨鐩稿唽',
+							modalType: false,
+							success: modalSuccess => {
+								wx.openSetting({
+									success(settingdata) {
+										console.log("settingdata",
+											settingdata)
+										if (settingdata
+											.authSetting[
+												'scope.writePhotosAlbum'
+											]) {
+											wx.showModal({
+												title: '鎻愮ず',
+												content: '鑾峰彇鏉冮檺鎴愬姛,鍐嶆鐐瑰嚮鍥剧墖鍗冲彲淇濆瓨',
+												modalType: false,
+											})
+										} else {
+											wx.showModal({
+												title: '鎻愮ず',
+												content: '鑾峰彇鏉冮檺澶辫触锛屽皢鏃犳硶淇濆瓨鍒扮浉鍐屽摝~',
+												modalType: false,
+											})
+										}
+									},
+									fail(failData) {
+										console.log("failData",
+											failData)
+									},
+									complete(finishData) {
+										console.log("finishData",
+											finishData)
+									}
+								})
+							}
+						})
+					}
+				},
+				complete(res) {
+					wx.hideLoading(); //闅愯棌 loading 鎻愮ず妗�
+				}
+			})
+		}
+	})
+}
\ No newline at end of file

--
Gitblit v1.9.3