|
@@ -33,7 +33,7 @@ interface LocationResult {
|
|
|
export function toast(content: string): void {
|
|
export function toast(content: string): void {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
icon: 'none',
|
|
|
- title: content
|
|
|
|
|
|
|
+ title: content,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -55,7 +55,7 @@ export function showConfirm(content: string): Promise<UniApp.ShowModalRes> {
|
|
|
confirmText: '确定',
|
|
confirmText: '确定',
|
|
|
success: function (res) {
|
|
success: function (res) {
|
|
|
resolve(res);
|
|
resolve(res);
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -89,10 +89,7 @@ export function tansParams(params: Record<string, any>): string {
|
|
|
/**
|
|
/**
|
|
|
* 更新当前用户信息
|
|
* 更新当前用户信息
|
|
|
*/
|
|
*/
|
|
|
-export const updateUserInfo = async (
|
|
|
|
|
- store: StoreModule,
|
|
|
|
|
- storeType: string[] = ['user', 'cpy', 'cpyLi', 'vip', 'card']
|
|
|
|
|
-): Promise<void> => {
|
|
|
|
|
|
|
+export const updateUserInfo = async (store: StoreModule, storeType: string[] = ['user', 'cpy', 'cpyLi', 'vip', 'card']): Promise<void> => {
|
|
|
let res: any = null;
|
|
let res: any = null;
|
|
|
if (storeType.includes('user')) {
|
|
if (storeType.includes('user')) {
|
|
|
res = await store.dispatch('getUserInfoBytoken');
|
|
res = await store.dispatch('getUserInfoBytoken');
|
|
@@ -112,49 +109,15 @@ export const updateUserInfo = async (
|
|
|
if (storeType.includes('card')) {
|
|
if (storeType.includes('card')) {
|
|
|
// 获取当前名片信息
|
|
// 获取当前名片信息
|
|
|
await store.dispatch('getCurrentCard');
|
|
await store.dispatch('getCurrentCard');
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-// 判断是否是会员并且会员是否过期
|
|
|
|
|
-export function isVip(options: VipOptions | null): VipResult {
|
|
|
|
|
- if (!options) {
|
|
|
|
|
- return {
|
|
|
|
|
- isVip: false,
|
|
|
|
|
- text: '非会员单位'
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
- const { vipReviewStatus, vipEndDate, vipLevelName, vipLevel } = options;
|
|
|
|
|
- if (vipReviewStatus !== '1') {
|
|
|
|
|
- return {
|
|
|
|
|
- isVip: false,
|
|
|
|
|
- text: '非会员单位'
|
|
|
|
|
- };
|
|
|
|
|
- } else {
|
|
|
|
|
- const now = new Date().getTime();
|
|
|
|
|
- const end = new Date(vipEndDate).getTime();
|
|
|
|
|
- if (now > end) {
|
|
|
|
|
- return {
|
|
|
|
|
- isVip: false,
|
|
|
|
|
- text: '非会员单位',
|
|
|
|
|
- level: vipLevel
|
|
|
|
|
- };
|
|
|
|
|
- } else {
|
|
|
|
|
- return {
|
|
|
|
|
- isVip: true,
|
|
|
|
|
- text: vipLevelName,
|
|
|
|
|
- level: vipLevel
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// 返回上一页失败返回首页
|
|
// 返回上一页失败返回首页
|
|
|
export function navigateBackOrHome(): void {
|
|
export function navigateBackOrHome(): void {
|
|
|
const pages = getCurrentPages();
|
|
const pages = getCurrentPages();
|
|
|
if (pages.length === 1) {
|
|
if (pages.length === 1) {
|
|
|
uni.switchTab({
|
|
uni.switchTab({
|
|
|
- url: '/pages/plant/base/index'
|
|
|
|
|
|
|
+ url: '/pages/plant/base/index',
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
uni.navigateBack();
|
|
uni.navigateBack();
|
|
@@ -165,7 +128,7 @@ export function navigateBackOrHome(): void {
|
|
|
export function showToast(title: string): void {
|
|
export function showToast(title: string): void {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
icon: 'none',
|
|
|
- title
|
|
|
|
|
|
|
+ title,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -176,15 +139,15 @@ export function saveImagePath(url: string): void {
|
|
|
success: function () {
|
|
success: function () {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: '保存成功',
|
|
title: '保存成功',
|
|
|
- icon: 'success'
|
|
|
|
|
|
|
+ icon: 'success',
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
fail: function () {
|
|
fail: function () {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: '保存失败',
|
|
title: '保存失败',
|
|
|
- icon: 'none'
|
|
|
|
|
|
|
+ icon: 'none',
|
|
|
});
|
|
});
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -195,15 +158,15 @@ export function shareImagePath(url: string): void {
|
|
|
success: function () {
|
|
success: function () {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: '分享成功',
|
|
title: '分享成功',
|
|
|
- icon: 'success'
|
|
|
|
|
|
|
+ icon: 'success',
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
fail: function () {
|
|
fail: function () {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: '分享失败',
|
|
title: '分享失败',
|
|
|
- icon: 'none'
|
|
|
|
|
|
|
+ icon: 'none',
|
|
|
});
|
|
});
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -223,7 +186,7 @@ export function getRemainingDays(endTime: string | Date): number {
|
|
|
export function uniPreviewImage(url: string): void {
|
|
export function uniPreviewImage(url: string): void {
|
|
|
uni.previewImage({
|
|
uni.previewImage({
|
|
|
urls: [url],
|
|
urls: [url],
|
|
|
- current: url
|
|
|
|
|
|
|
+ current: url,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -269,19 +232,19 @@ export function chooseAddress(): Promise<LocationResult> {
|
|
|
},
|
|
},
|
|
|
fail: (err) => {
|
|
fail: (err) => {
|
|
|
reject(err);
|
|
reject(err);
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
reject(new Error('用户未授权地理位置权限'));
|
|
reject(new Error('用户未授权地理位置权限'));
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
});
|
|
});
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
reject(err);
|
|
reject(err);
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -293,15 +256,15 @@ export function navigateToWithToken(url: string): void {
|
|
|
type: 'reLaunch',
|
|
type: 'reLaunch',
|
|
|
url: '/pages/login/login',
|
|
url: '/pages/login/login',
|
|
|
params: {
|
|
params: {
|
|
|
- redirect: encodeURIComponent(url)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ redirect: encodeURIComponent(url),
|
|
|
|
|
+ },
|
|
|
});
|
|
});
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- uni.$u.route({
|
|
|
|
|
- type: 'navigateTo',
|
|
|
|
|
- url: url
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ uni.$u.route({
|
|
|
|
|
+ type: 'navigateTo',
|
|
|
|
|
+ url: url,
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
// 判断开启微信小程序权限功能,如果开启则返回true,否则先引导开启
|
|
// 判断开启微信小程序权限功能,如果开启则返回true,否则先引导开启
|
|
|
export const isOpenSetting = async (scope?: string): Promise<boolean> => {
|
|
export const isOpenSetting = async (scope?: string): Promise<boolean> => {
|
|
@@ -317,7 +280,7 @@ export const isOpenSetting = async (scope?: string): Promise<boolean> => {
|
|
|
console.log(res, 'getSetting res');
|
|
console.log(res, 'getSetting res');
|
|
|
resolve(!!(res.authSetting && (res.authSetting as any)[scope as string]));
|
|
resolve(!!(res.authSetting && (res.authSetting as any)[scope as string]));
|
|
|
},
|
|
},
|
|
|
- fail: () => resolve(false)
|
|
|
|
|
|
|
+ fail: () => resolve(false),
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
console.log(hasAuth, 'hasAuth');
|
|
console.log(hasAuth, 'hasAuth');
|
|
@@ -329,13 +292,13 @@ export const isOpenSetting = async (scope?: string): Promise<boolean> => {
|
|
|
success: () => resolve(true),
|
|
success: () => resolve(true),
|
|
|
fail: (res) => {
|
|
fail: (res) => {
|
|
|
console.log(res);
|
|
console.log(res);
|
|
|
-
|
|
|
|
|
- resolve(false)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ resolve(false);
|
|
|
|
|
+ },
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
console.log(authorized, 'authorized');
|
|
console.log(authorized, 'authorized');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (authorized) return true;
|
|
if (authorized) return true;
|
|
|
|
|
|
|
|
const goSetting = await new Promise<boolean>((resolve) => {
|
|
const goSetting = await new Promise<boolean>((resolve) => {
|
|
@@ -344,7 +307,7 @@ export const isOpenSetting = async (scope?: string): Promise<boolean> => {
|
|
|
content: '请打开手机自身定位并且点击右上角三个点,进入设置,允许小程序获取定位,并选择您的位置。',
|
|
content: '请打开手机自身定位并且点击右上角三个点,进入设置,允许小程序获取定位,并选择您的位置。',
|
|
|
confirmText: '去设置',
|
|
confirmText: '去设置',
|
|
|
success: (mRes: UniApp.ShowModalRes) => resolve(!!mRes.confirm),
|
|
success: (mRes: UniApp.ShowModalRes) => resolve(!!mRes.confirm),
|
|
|
- fail: () => resolve(false)
|
|
|
|
|
|
|
+ fail: () => resolve(false),
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
if (!goSetting) return false;
|
|
if (!goSetting) return false;
|
|
@@ -354,7 +317,7 @@ export const isOpenSetting = async (scope?: string): Promise<boolean> => {
|
|
|
success: (setRes) => {
|
|
success: (setRes) => {
|
|
|
resolve(!!(setRes.authSetting && (setRes.authSetting as any)[scope as string]));
|
|
resolve(!!(setRes.authSetting && (setRes.authSetting as any)[scope as string]));
|
|
|
},
|
|
},
|
|
|
- fail: () => resolve(false)
|
|
|
|
|
|
|
+ fail: () => resolve(false),
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
return !!finalAuth;
|
|
return !!finalAuth;
|
|
@@ -365,7 +328,7 @@ export const isOpenSetting = async (scope?: string): Promise<boolean> => {
|
|
|
|
|
|
|
|
// 非微信小程序平台默认返回可用
|
|
// 非微信小程序平台默认返回可用
|
|
|
return true;
|
|
return true;
|
|
|
-}
|
|
|
|
|
|
|
+};
|
|
|
// 根据传入url获取文件后缀名,根据文件后缀名返回相应的图片icon
|
|
// 根据传入url获取文件后缀名,根据文件后缀名返回相应的图片icon
|
|
|
export const getFileIconByUrl = (url: string) => {
|
|
export const getFileIconByUrl = (url: string) => {
|
|
|
const fileExtension = url.substring(url.lastIndexOf('.') + 1).toLowerCase();
|
|
const fileExtension = url.substring(url.lastIndexOf('.') + 1).toLowerCase();
|
|
@@ -390,7 +353,7 @@ export const getFileIconByUrl = (url: string) => {
|
|
|
DOCX: 'doc',
|
|
DOCX: 'doc',
|
|
|
XLS: 'xlsx',
|
|
XLS: 'xlsx',
|
|
|
XLSX: 'xlsx',
|
|
XLSX: 'xlsx',
|
|
|
- TXT: 'txt'
|
|
|
|
|
|
|
+ TXT: 'txt',
|
|
|
};
|
|
};
|
|
|
return `https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images/file-type-sub/${iconMap?.[fileExtension] || 'def'}.png`; // 默认图标
|
|
return `https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images/file-type-sub/${iconMap?.[fileExtension] || 'def'}.png`; // 默认图标
|
|
|
};
|
|
};
|
|
@@ -400,29 +363,45 @@ export const getRect = (selector: string, all: boolean = false): Promise<UniApp.
|
|
|
const instance = getCurrentInstance();
|
|
const instance = getCurrentInstance();
|
|
|
const query = uni.createSelectorQuery().in(instance);
|
|
const query = uni.createSelectorQuery().in(instance);
|
|
|
if (all) {
|
|
if (all) {
|
|
|
- query.selectAll(selector).boundingClientRect((res: any) => {
|
|
|
|
|
- if (res) {
|
|
|
|
|
- resolve(res);
|
|
|
|
|
- } else {
|
|
|
|
|
- reject('未找到节点信息');
|
|
|
|
|
- }
|
|
|
|
|
- }).exec();
|
|
|
|
|
|
|
+ query
|
|
|
|
|
+ .selectAll(selector)
|
|
|
|
|
+ .boundingClientRect((res: any) => {
|
|
|
|
|
+ if (res) {
|
|
|
|
|
+ resolve(res);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ reject('未找到节点信息');
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .exec();
|
|
|
} else {
|
|
} else {
|
|
|
- query.select(selector).boundingClientRect((res: any) => {
|
|
|
|
|
- if (res) {
|
|
|
|
|
- resolve(res);
|
|
|
|
|
- } else {
|
|
|
|
|
- reject('未找到节点信息');
|
|
|
|
|
- }
|
|
|
|
|
- }).exec();
|
|
|
|
|
|
|
+ query
|
|
|
|
|
+ .select(selector)
|
|
|
|
|
+ .boundingClientRect((res: any) => {
|
|
|
|
|
+ if (res) {
|
|
|
|
|
+ resolve(res);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ reject('未找到节点信息');
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .exec();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 根据传入存放库房数组返回文字
|
|
// 根据传入存放库房数组返回文字
|
|
|
-export const getStorageRoomNames = (rooms: Array<{ warehouseName?: string, shelvesName?: string, shelfId?: string, warehouseId?: string }>): string => {
|
|
|
|
|
|
|
+export const getStorageRoomNames = (rooms: Array<{ warehouseName?: string; shelvesName?: string; shelfId?: string; warehouseId?: string }>): string => {
|
|
|
if (!rooms || rooms.length === 0) {
|
|
if (!rooms || rooms.length === 0) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
|
- return rooms.map(room => (room.warehouseName || '') + (room.shelvesName ? '-' : '') + (room.shelvesName || '')).join(',');
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ return rooms.map((room) => (room.warehouseName || '') + (room.shelvesName ? '-' : '') + (room.shelvesName || '')).join(',');
|
|
|
|
|
+};
|
|
|
|
|
+// 根据开始日期结束日期返回字符串
|
|
|
|
|
+export const getDateRangeFrt = (startDate: string, endDate: string): string => {
|
|
|
|
|
+ if (!startDate || !endDate) {
|
|
|
|
|
+ return '-';
|
|
|
|
|
+ }
|
|
|
|
|
+ if (startDate === endDate) {
|
|
|
|
|
+ return startDate;
|
|
|
|
|
+ }
|
|
|
|
|
+ return `${startDate}至${endDate}`;
|
|
|
|
|
+};
|