60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
// app.ts
|
|
import { commonBehavior } from './behaviors/common';
|
|
|
|
interface IAppOption {
|
|
// checkLoginStatus: (options?: WechatMiniprogram.App.LaunchShowOption) => boolean;
|
|
globalData: {
|
|
version: null, //版本号
|
|
userInfo: Object,
|
|
inputWidth: Number, //页面组件宽度
|
|
inputWidthW: Number,
|
|
commonBehavior: Object, //全局混入函数
|
|
customerList: Array, //客户数据
|
|
supplierList: Array, //供应商数据
|
|
statusColorMap: Object, //单据状态颜色
|
|
};
|
|
}
|
|
|
|
App<IAppOption>({
|
|
globalData: {
|
|
version: null,
|
|
userInfo: {},
|
|
inputWidth: 300, //页面组件宽度
|
|
inputWidthW: 330,
|
|
commonBehavior: commonBehavior,
|
|
customerList: [],
|
|
supplierList: [],
|
|
statusColorMap: {
|
|
'未复核': '#909399', // 灰色:未操作、待处理
|
|
'已复核': '#67C23A', // 浅绿:已复核,环节完成
|
|
'审核中': '#E6A23C', // 橙色:审核进行中,需关注
|
|
'已终审': '#529B2E', // 深绿:终审通过,比已复核更深以示区别
|
|
'已排程': '#409EFF', // 蓝色:已纳入计划,等待执行
|
|
'已生产': '#00B4D8', // 青色:生产完毕,清新科技感
|
|
'已入库': '#9B59B6', // 紫色:已入库,库存状态用紫
|
|
'已发货': '#2C3E50', // 深灰蓝:运输/发货中,稳重感
|
|
'已作废': '#F56C6C' // 浅红:异常/作废,区别于主色深红
|
|
},
|
|
},
|
|
// checkLoginStatus() {
|
|
// }
|
|
})
|
|
|
|
// 保存原始的 Page 构造函数
|
|
const originalPage = Page;
|
|
|
|
// 重写 Page
|
|
Page = function (options: any) {
|
|
// 如果页面未定义 behaviors,则初始化为空数组
|
|
const behaviors = options.behaviors || [];
|
|
// 将全局混入的 behavior 添加到最前面(确保优先级较低,页面自身可覆盖)
|
|
options.behaviors = [commonBehavior, ...behaviors];
|
|
// 调用原始 Page 构造器
|
|
originalPage(options);
|
|
};
|
|
|
|
const originalComponent = Component;
|
|
Component = function (options: any) {
|
|
options.behaviors = [commonBehavior, ...(options.behaviors || [])];
|
|
return originalComponent(options);
|
|
}; |