feat: 切换城市
This commit is contained in:
@@ -9,3 +9,4 @@ export * from './orderActions';
|
||||
export * from './routeUtil';
|
||||
export * from './share'
|
||||
export * from './genPoster'
|
||||
export * from './wx_helper'
|
||||
|
||||
35
src/utils/wx_helper.ts
Normal file
35
src/utils/wx_helper.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import Taro from "@tarojs/taro";
|
||||
|
||||
export function saveImage(url) {
|
||||
Taro.getSetting().then(async (res) => {
|
||||
if (!res.authSetting["scope.writePhotosAlbum"]) {
|
||||
Taro.authorize({
|
||||
scope: "scope.writePhotosAlbum",
|
||||
success: async () => {
|
||||
try {
|
||||
Taro.saveImageToPhotosAlbum({ filePath: url });
|
||||
Taro.showToast({ title: "保存成功" });
|
||||
} catch (e) {
|
||||
Taro.showToast({ title: "图片保存失败", icon: "none" });
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
Taro.showModal({
|
||||
title: "提示",
|
||||
content: "需要开启相册权限才能保存图片",
|
||||
success: (r) => {
|
||||
if (r.confirm) Taro.openSetting();
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
} else {
|
||||
try {
|
||||
Taro.saveImageToPhotosAlbum({ filePath: url });
|
||||
Taro.showToast({ title: "保存成功" });
|
||||
} catch (e) {
|
||||
Taro.showToast({ title: "图片保存失败", icon: "none" });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user