feat: 添加组件配置文件并优化页面结构
- 新增 components.d.json 文件,包含所有组件的属性配置 - 添加 card-item-plugin 组件及其相关文件(json、ts、wxml、wxss) - 在 app.json 中添加新的生产流程管理页面路径 - 添加多个SVG图标文件用于菜单项 - 重构 popup-plugin 组件样式和关闭逻辑 - 更新 tab-bar-plugin 的激活状态逻辑 - 优化 search-popup 使用全局样式类 - 在首页添加菜单配置和页面跳转功能 - 调整组件样式细节和间距
This commit is contained in:
@@ -4,18 +4,29 @@
|
||||
*/
|
||||
export const servicePhone = "4000-5858-22";
|
||||
|
||||
export const colors = {
|
||||
primary: "#0052d9",
|
||||
success: "#2ba471",
|
||||
warning: "#e37318",
|
||||
danger: "#d54941",
|
||||
info: "#029cd4",
|
||||
gray: "#999999",
|
||||
} as const;
|
||||
|
||||
export const defaultAvatarUrl =
|
||||
"https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0";
|
||||
|
||||
export const base = {
|
||||
appletName: "易宝赞管理系统普惠版",
|
||||
appletName: "易宝赞普惠版",
|
||||
apiHost:
|
||||
wx.getAccountInfoSync().miniProgram.envVersion == "release"
|
||||
? "https://ebaozan.com/api/"
|
||||
: "http://192.168.1.138:83/",
|
||||
|
||||
webViewBaseUrl:
|
||||
wx.getAccountInfoSync().miniProgram.envVersion == "release" ? "https://ebaozan.com/" : "http://ebaozan.cf/",
|
||||
wx.getAccountInfoSync().miniProgram.envVersion == "release"
|
||||
? "https://ebaozan.com/"
|
||||
: "http://ebaozan.cf/",
|
||||
cookieKey: "OwCookie",
|
||||
};
|
||||
|
||||
|
||||
@@ -3,12 +3,15 @@
|
||||
* YangXB 2021.11.24
|
||||
* */
|
||||
import { base, http } from "./config";
|
||||
import { getStorage, goIndexPage, isArray, setStorage, ToastErr } from "./util";
|
||||
import {
|
||||
getStorage,
|
||||
goIndexPage,
|
||||
isArray,
|
||||
setStorage,
|
||||
toastError,
|
||||
} from "./util";
|
||||
/**
|
||||
* 请求
|
||||
* @param {*} url
|
||||
* @param {*} options
|
||||
* @param {*} config
|
||||
*/
|
||||
const request = (
|
||||
url: string,
|
||||
@@ -103,7 +106,7 @@ export const wxLogin = (config?: any) => {
|
||||
});
|
||||
})
|
||||
.catch((err: any) => {
|
||||
ToastErr("服务失败:" + err.err_code);
|
||||
toastError("服务失败:" + err.err_code);
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -194,11 +197,7 @@ export const login = (
|
||||
company_id?: any
|
||||
) => {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
const data: any = {
|
||||
type: 2,
|
||||
encryptedData,
|
||||
iv,
|
||||
};
|
||||
const data: any = { type: 2, encryptedData, iv };
|
||||
|
||||
if (company_id) {
|
||||
data.companyID = company_id;
|
||||
|
||||
@@ -7,88 +7,32 @@ export const menuConfig = [
|
||||
iconColor: iconColor,
|
||||
children: [
|
||||
{
|
||||
title: "订单列表",
|
||||
title: "销售订单",
|
||||
url: "/pages/orders/ordersList/ordersList",
|
||||
auth: "SF_VIEW_ORDERS",
|
||||
},
|
||||
{
|
||||
title: "流程管理",
|
||||
url: "/pages/orders/processManage/processManage",
|
||||
auth: "SF_VIEW_ORDER_PROCESS_MANAGE",
|
||||
},
|
||||
{
|
||||
title: "录入流程",
|
||||
url: "/pages/processEntry/processEntry",
|
||||
auth: "SF_ENTER_PROCESS",
|
||||
},
|
||||
{
|
||||
title: "工量查询",
|
||||
url: "/pages/orders/workload/workload",
|
||||
auth: "SF_VIEW_WORK_LIST",
|
||||
},
|
||||
{
|
||||
title: "订单备忘",
|
||||
url: "/pages/orders/orderMemo/orderMemo",
|
||||
auth: "SF_VIEW_ORDER_MEMO",
|
||||
},
|
||||
{
|
||||
title: "订单排序",
|
||||
url: "/pages/orders/ordersSort/ordersSort",
|
||||
auth: "SF_SET_ORDER_SORT",
|
||||
},
|
||||
{
|
||||
title: "板号查询",
|
||||
url: "/pages/orders/sale_no_query/sale_no_query",
|
||||
auth: "SF_VIEW_ORDER_SALE_NO_PROCESS",
|
||||
auth: "SF_ERP_SALE_ORDERS_VIEW",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "客户管理",
|
||||
icon: "user-vip",
|
||||
title: "生产管理",
|
||||
icon: "form",
|
||||
iconColor: iconColor,
|
||||
children: [
|
||||
// {
|
||||
// title: "生产任务",
|
||||
// url: "/pages/produce/orderTask/orderTask",
|
||||
// auth: "SF_ERP_PRODUCT_TASK_VIEW",
|
||||
// },
|
||||
{
|
||||
title: "供应商管理",
|
||||
url: "/pages/crm_manage/suppliers/suppliers",
|
||||
auth: "SF_VIEW_CRM_SUPPLIER",
|
||||
title: "流程管理",
|
||||
url: "/pages/produce/processManage/processManage",
|
||||
auth: "SF_ERP_PRODUCT_PROCESS_VIEW",
|
||||
},
|
||||
{
|
||||
title: "经销商管理",
|
||||
url: "/pages/crm_manage/sales/sales",
|
||||
auth: "SF_VIEW_CRM_SALE",
|
||||
},
|
||||
{
|
||||
title: "经销商等级",
|
||||
url: "/pages/crm_manage/crm_level/crm_level",
|
||||
auth: "SF_VIEW_CRM_LEVEL",
|
||||
title: "流程录入",
|
||||
url: "/pages/processEntry/processEntry",
|
||||
auth: "SF_ERP_PRODUCT_PROCESS_ENTER",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const iconPath = "/images/nav_icons/";
|
||||
/** 导航栏 */
|
||||
export const navTabBar = [
|
||||
{
|
||||
iconPath: `${iconPath}home.svg`,
|
||||
selectedIconPath: `${iconPath}home2.svg`,
|
||||
pagePath: "/pages/index/index",
|
||||
text: "首页",
|
||||
key: "1",
|
||||
},
|
||||
{
|
||||
iconPath: `${iconPath}code.svg`,
|
||||
selectedIconPath: `${iconPath}code2.svg`,
|
||||
pagePath: "/pages/processEntry/processEntry",
|
||||
text: "扫码",
|
||||
key: "2",
|
||||
},
|
||||
{
|
||||
iconPath: `${iconPath}my.svg`,
|
||||
selectedIconPath: `${iconPath}my2.svg`,
|
||||
pagePath: "/pages/my/my",
|
||||
text: "我的",
|
||||
key: "3",
|
||||
},
|
||||
];
|
||||
|
||||
@@ -8,7 +8,13 @@ export const formatTime = (date: Date) => {
|
||||
const minute = date.getMinutes();
|
||||
const second = date.getSeconds();
|
||||
|
||||
return `${[year, month, day].map(formatNumber).join("-")} ${[hour, minute, second].map(formatNumber).join(":")}`;
|
||||
return `${[year, month, day].map(formatNumber).join("-")} ${[
|
||||
hour,
|
||||
minute,
|
||||
second,
|
||||
]
|
||||
.map(formatNumber)
|
||||
.join(":")}`;
|
||||
};
|
||||
|
||||
export const formatNumber = (n: number | string) => {
|
||||
@@ -16,24 +22,12 @@ export const formatNumber = (n: number | string) => {
|
||||
return n[1] ? n : `0${n}`;
|
||||
};
|
||||
|
||||
export const ToastOK = (title: string, duration = 2000) => {
|
||||
wx.showToast({
|
||||
title,
|
||||
icon: "success",
|
||||
duration,
|
||||
});
|
||||
};
|
||||
|
||||
export const ToastErr = (title: string, duration = 2000) => {
|
||||
wx.showToast({
|
||||
title,
|
||||
icon: "error",
|
||||
duration,
|
||||
});
|
||||
};
|
||||
|
||||
// 对话框
|
||||
export const showModal = (title: string, content: string, showCancel = false) => {
|
||||
export const showModal = (
|
||||
title: string,
|
||||
content: string,
|
||||
showCancel = false
|
||||
) => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
wx.showModal({
|
||||
title,
|
||||
@@ -51,36 +45,28 @@ export const showModal = (title: string, content: string, showCancel = false) =>
|
||||
};
|
||||
|
||||
/** 判断数据是不是数组类型 */
|
||||
export const isArray = (data: any) => {
|
||||
return data && Array.isArray(data);
|
||||
};
|
||||
export const isArray = (data: any) => data && Array.isArray(data);
|
||||
|
||||
/**
|
||||
* 转成数组
|
||||
* @param {*} data
|
||||
* @returns {Array}
|
||||
*/
|
||||
export const toArray = (data: any): any[] => {
|
||||
return isArray(data) ? data : [];
|
||||
};
|
||||
export const toArray = (data: any): any[] => (isArray(data) ? data : []);
|
||||
|
||||
/** 判断数据是不是对象类型 */
|
||||
export const isObject = (data: any) => {
|
||||
return data && `${Object.prototype.toString.call(data)}`.includes("Object");
|
||||
};
|
||||
|
||||
export const toObject = (data: any) => {
|
||||
return isObject(data) ? data : {};
|
||||
};
|
||||
export const toObject = (data: any) => (isObject(data) ? data : {});
|
||||
|
||||
export const reloadPage = () => {
|
||||
let pages = getCurrentPages(); //获取加载的页面
|
||||
let currentPage = pages[pages.length - 1]; //获取当前页面的对象
|
||||
let url = currentPage.route; //当前页面url
|
||||
// 关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面。
|
||||
wx.redirectTo({
|
||||
url: "/" + url,
|
||||
});
|
||||
wx.redirectTo({ url: "/" + url });
|
||||
};
|
||||
|
||||
/** 判断是json数据 */
|
||||
@@ -106,13 +92,21 @@ export const jsonParse = (data: any): any[] | object | null => {
|
||||
if (typeof data == "string") {
|
||||
try {
|
||||
const obj = JSON.parse(data);
|
||||
if (["Array", "Object"].includes(Object.prototype.toString.call(obj).slice(8, -1))) {
|
||||
if (
|
||||
["Array", "Object"].includes(
|
||||
Object.prototype.toString.call(obj).slice(8, -1)
|
||||
)
|
||||
) {
|
||||
return obj;
|
||||
}
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
} else if (["Array", "Object"].includes(Object.prototype.toString.call(data).slice(8, -1))) {
|
||||
} else if (
|
||||
["Array", "Object"].includes(
|
||||
Object.prototype.toString.call(data).slice(8, -1)
|
||||
)
|
||||
) {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -148,14 +142,10 @@ export const formatToDecimals = (str: any, num: number = 2) => {
|
||||
};
|
||||
|
||||
/** 获取权限 */
|
||||
export const getAuthInfo = () => {
|
||||
return toObject(wx.getStorageSync("auth_info"));
|
||||
};
|
||||
export const getAuthInfo = () => toObject(wx.getStorageSync("auth_info"));
|
||||
|
||||
export const goIndexPage = () => {
|
||||
wx.switchTab({
|
||||
url: "/pages/index/index",
|
||||
});
|
||||
wx.navigateTo({ url: "/pages/index/index" });
|
||||
};
|
||||
|
||||
export const isImageFile = (path: string) => {
|
||||
@@ -186,41 +176,37 @@ export const tabsConfigGet = () => {
|
||||
*/
|
||||
export const mediaPreview = (imageUrls: any[], currentUrl: string) => {
|
||||
console.log("媒体图片预览方法");
|
||||
const lastLen = `${currentUrl}`.indexOf("?") > -1 ? `${currentUrl}`.indexOf("?") : `${currentUrl}`.length;
|
||||
const lastLen =
|
||||
`${currentUrl}`.indexOf("?") > -1
|
||||
? `${currentUrl}`.indexOf("?")
|
||||
: `${currentUrl}`.length;
|
||||
|
||||
const suffix: any = currentUrl.substring(currentUrl.lastIndexOf(".") + 1, lastLen).toLocaleLowerCase();
|
||||
const suffix: any = currentUrl
|
||||
.substring(currentUrl.lastIndexOf(".") + 1, lastLen)
|
||||
.toLocaleLowerCase();
|
||||
|
||||
if (isImageFile("." + suffix)) {
|
||||
wx.previewImage({
|
||||
urls: imageUrls,
|
||||
current: currentUrl,
|
||||
showmenu: true,
|
||||
});
|
||||
wx.previewImage({ urls: imageUrls, current: currentUrl, showmenu: true });
|
||||
} else if (["mp3", "mp4", "m4a"].includes(suffix)) {
|
||||
wx.previewMedia({
|
||||
sources: [
|
||||
{
|
||||
url: currentUrl,
|
||||
type: "video",
|
||||
},
|
||||
],
|
||||
sources: [{ url: currentUrl, type: "video" }],
|
||||
fail() {
|
||||
wx.showToast({
|
||||
title: "播放失败",
|
||||
});
|
||||
wx.showToast({ title: "播放失败" });
|
||||
},
|
||||
});
|
||||
} else if (["doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"].includes(suffix)) {
|
||||
} else if (
|
||||
["doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"].includes(suffix)
|
||||
) {
|
||||
const downloadTask = wx.downloadFile({
|
||||
url: currentUrl,
|
||||
header: http.header,
|
||||
success: function (res) {
|
||||
success: (res) => {
|
||||
const filePath = res.tempFilePath;
|
||||
wx.openDocument({
|
||||
filePath: filePath,
|
||||
showMenu: true,
|
||||
fileType: suffix,
|
||||
success: function () {},
|
||||
success: () => {},
|
||||
});
|
||||
},
|
||||
fail() {},
|
||||
@@ -237,9 +223,7 @@ export const mediaPreview = (imageUrls: any[], currentUrl: string) => {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: "请前往网页端下载查看",
|
||||
});
|
||||
wx.showToast({ title: "请前往网页端下载查看" });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -252,9 +236,7 @@ export const uploadFile2 = (option: any) => {
|
||||
option = toObject(option);
|
||||
option.name = option.name || "files";
|
||||
|
||||
wx.showLoading({
|
||||
title: "文件上传中...",
|
||||
});
|
||||
wx.showLoading({ title: "文件上传中..." });
|
||||
wx.uploadFile({
|
||||
filePath: option.filePath,
|
||||
name: option.name,
|
||||
@@ -266,17 +248,13 @@ export const uploadFile2 = (option: any) => {
|
||||
url: option.url,
|
||||
success(res) {
|
||||
const resData = jsonParse(res.data);
|
||||
wx.showToast({
|
||||
title: "上传成功",
|
||||
});
|
||||
wx.showToast({ title: "上传成功" });
|
||||
if (option.success) {
|
||||
option.success(resData);
|
||||
}
|
||||
},
|
||||
fail() {
|
||||
wx.showToast({
|
||||
title: "上传失败",
|
||||
});
|
||||
wx.showToast({ title: "上传失败" });
|
||||
if (option.fail) {
|
||||
option.fail();
|
||||
}
|
||||
@@ -345,3 +323,4 @@ export const getCurrentPageRoute = () => {
|
||||
const currentPage = pages[pages.length - 1]; // 获取当前页面对象
|
||||
return `/${currentPage.route}`; // 获取当前页面路径
|
||||
};
|
||||
|
||||
|
||||
@@ -18,58 +18,13 @@ const playVoice = (src: string, text: string) => {
|
||||
};
|
||||
|
||||
export const voiceRequest = (text: string, cacheVoice?: boolean) => {
|
||||
// if (cacheVoice) {
|
||||
// const data = wx.getStorageSync(text);
|
||||
// console.log(data);
|
||||
// if (data) {
|
||||
// console.log("有 base64");
|
||||
// const fs = wx.getFileSystemManager();
|
||||
// //随机定义路径名称
|
||||
// var times = new Date().getTime();
|
||||
// var codeimg = wx.env.USER_DATA_PATH + "/" + times + ".mp3";
|
||||
// //将base64图片写入
|
||||
// fs.writeFile({
|
||||
// filePath: codeimg,
|
||||
// data: data,
|
||||
// encoding: "base64",
|
||||
// success: (res) => {
|
||||
// console.log(res);
|
||||
// playVoice(codeimg, text);
|
||||
// },
|
||||
// fail: (res) => {
|
||||
// console.log(res);
|
||||
// },
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
post(
|
||||
"/Tools/voice",
|
||||
{
|
||||
txt: text,
|
||||
per: 3,
|
||||
spd: 5,
|
||||
pit: 5,
|
||||
vol: 9,
|
||||
},
|
||||
{ txt: text, per: 3, spd: 5, pit: 5, vol: 9 },
|
||||
{ showLoading: false }
|
||||
).then((res: any) => {
|
||||
if (res.err_code == 0) {
|
||||
playVoice(urlAddBaseUrl(res.data), text);
|
||||
// if (cacheVoice) {
|
||||
// wx.request({
|
||||
// url: urlAddBaseUrl(res.data),
|
||||
// responseType: "arraybuffer",
|
||||
// success(res) {
|
||||
// const base64 = base64js.fromByteArray(new Uint8Array(res.data));
|
||||
// try {
|
||||
// wx.setStorageSync(text, base64);
|
||||
// } catch (_) {
|
||||
// console.log("缓存错误");
|
||||
// }
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user