Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b99a3412e2 | ||
|
|
63300f68f8 | ||
|
|
acf4f94798 | ||
|
|
87f4d220e5 |
@@ -491,6 +491,27 @@ class Manager<WXC extends AnyWXContext = AnyWXContext> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步页面加载
|
||||||
|
*
|
||||||
|
* *注意*
|
||||||
|
* 页面模块加载后,必须手动执行 loadAllModule
|
||||||
|
* loadAllModule Modular 才会真正的被加载
|
||||||
|
* 模块加载后可以处理逻辑绑定
|
||||||
|
*/
|
||||||
|
public static async PageAsync(): Promise<{
|
||||||
|
manager: Manager<AnyWXContext>,
|
||||||
|
query: Record<string, string | undefined>
|
||||||
|
}> {
|
||||||
|
return new Promise((solve) => {
|
||||||
|
Page({
|
||||||
|
async onLoad(query) {
|
||||||
|
let manager = new Manager(this);
|
||||||
|
await solve({ manager, query });
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Manager, Modular, AnyWXContext, WXContext, ILifetime}
|
export { Manager, Modular, AnyWXContext, WXContext, ILifetime}
|
||||||
@@ -4,9 +4,23 @@ import { MainFunction } from "./MainFunction";
|
|||||||
import { FunctionList } from "./FunctionList";
|
import { FunctionList } from "./FunctionList";
|
||||||
import { Mask } from "../../modular/Mask/Mask";
|
import { Mask } from "../../modular/Mask/Mask";
|
||||||
|
|
||||||
Manager.Page((manager) => {
|
(async () => {
|
||||||
|
|
||||||
|
// 初始化页面
|
||||||
|
const { manager, query } = await Manager.PageAsync();
|
||||||
|
|
||||||
|
// 添加蒙版 Modular
|
||||||
const mask = manager.addModule(Mask, "mask");
|
const mask = manager.addModule(Mask, "mask");
|
||||||
|
|
||||||
|
// 添加 UserCard Modular
|
||||||
manager.addModule(UserCard, "userCard", { mask });
|
manager.addModule(UserCard, "userCard", { mask });
|
||||||
|
|
||||||
|
// 添加 MainFunction Modular
|
||||||
manager.addModule(MainFunction, "mainFunction");
|
manager.addModule(MainFunction, "mainFunction");
|
||||||
|
|
||||||
|
// 添加 FunctionList Modular
|
||||||
manager.addModule(FunctionList, "functionList");
|
manager.addModule(FunctionList, "functionList");
|
||||||
});
|
|
||||||
|
// 初始化全部 Modular
|
||||||
|
await manager.loadAllModule(query);
|
||||||
|
})();
|
||||||
@@ -44,42 +44,27 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!--主要功能-->
|
<!--主要功能-->
|
||||||
<view class="card main-function"><!--四个功能合在一起的容器-->
|
<view class="card main-function">
|
||||||
<view class="branch-funtion">
|
|
||||||
<view><!--每个功能的容器-->
|
<!--每个功能的容器-->
|
||||||
<image class="icon" src="../../image/account/Account_UserInfo.svg"></image><!--每个功能的图片-->
|
<view class="branch-funtion" wx:for="{{ mainFunction$mainFunctionList }}" wx:key="index">
|
||||||
<view>账号信息</view><!--每个功能的文字-->
|
<view style="{{ index == (mainFunction$mainFunctionList - 1) ? 'border-bottom: 0px' : '' }}">
|
||||||
</view>
|
<!--每个功能的图片-->
|
||||||
</view>
|
<image class="icon" src="../../image/account/Account_{{ item.iconUrl }}.svg"></image>
|
||||||
|
<!--每个功能的文字-->
|
||||||
<view class="branch-funtion">
|
<view>{{ item.displayName }}</view>
|
||||||
<view>
|
|
||||||
<image class="icon" src="../../image/account/Account_DateList.svg"></image>
|
|
||||||
<view>课表缓存</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="branch-funtion">
|
|
||||||
<view>
|
|
||||||
<image class="icon" src="../../image/account/Account_Customer.svg"></image>
|
|
||||||
<view>功能定制</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="branch-funtion">
|
|
||||||
<view style="border-right: 0px;">
|
|
||||||
<image class="icon" src="../../image/account/Account_Settings.svg"></image>
|
|
||||||
<view>更多设置</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 功能列表 -->
|
<!-- 功能列表 -->
|
||||||
<view class="card function-list">
|
<view class="card function-list">
|
||||||
<view class="function" wx:for="{{functionList$functionList}}" wx:for-index="index" wx:key="id">
|
|
||||||
<view style="{{item.id == (functionList$functionList.length - 1) ? 'border-bottom: 0px' : ''}}">
|
<!-- 每一行 -->
|
||||||
<image class="icon func-icon" src="../../image/account/Account_{{item.iconUrl}}.svg" />
|
<view class="function" wx:for="{{ functionList$functionList }}" wx:key="index">
|
||||||
<view>{{item.displayName}}</view>
|
<view style="{{ index == (functionList$functionList.length - 1) ? 'border-bottom: 0px' : '' }}">
|
||||||
|
<image class="icon func-icon" src="../../image/account/Account_{{ item.iconUrl }}.svg" />
|
||||||
|
<view>{{ item.displayName }}</view>
|
||||||
<image class="icon-sub arrow" src="../../image/account/Account_Arrow.svg" />
|
<image class="icon-sub arrow" src="../../image/account/Account_Arrow.svg" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -2,11 +2,6 @@ import { Modular, Manager } from "../../core/Module";
|
|||||||
|
|
||||||
interface IFunctionListItem {
|
interface IFunctionListItem {
|
||||||
|
|
||||||
/**
|
|
||||||
* id
|
|
||||||
*/
|
|
||||||
id?: number
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示名称
|
* 显示名称
|
||||||
*/
|
*/
|
||||||
@@ -18,10 +13,6 @@ interface IFunctionListItem {
|
|||||||
iconUrl: string;
|
iconUrl: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IFunctionListData {
|
|
||||||
functionList?: IFunctionListItem[];
|
|
||||||
};
|
|
||||||
|
|
||||||
class FunctionList<M extends Manager> extends Modular<M> {
|
class FunctionList<M extends Manager> extends Modular<M> {
|
||||||
|
|
||||||
public static readonly functionList: IFunctionListItem[] = [
|
public static readonly functionList: IFunctionListItem[] = [
|
||||||
@@ -32,18 +23,12 @@ class FunctionList<M extends Manager> extends Modular<M> {
|
|||||||
{ displayName: "联系客服", iconUrl: "Support" }
|
{ displayName: "联系客服", iconUrl: "Support" }
|
||||||
];
|
];
|
||||||
|
|
||||||
public data: IFunctionListData = {
|
public data = {
|
||||||
functionList: undefined
|
functionList: FunctionList.functionList
|
||||||
};
|
};
|
||||||
|
|
||||||
public override onLoad() {
|
public override onLoad() {
|
||||||
console.log(FunctionList.functionList)
|
// Do something
|
||||||
this.setData({
|
|
||||||
functionList: FunctionList.functionList.map((value, index) => {
|
|
||||||
value.id = index;
|
|
||||||
return value;
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,30 @@
|
|||||||
import { Modular, Manager } from "../../core/Module";
|
import { Modular, Manager } from "../../core/Module";
|
||||||
|
|
||||||
|
interface IMainFunctionItem {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示名称
|
||||||
|
*/
|
||||||
|
displayName: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图标路径
|
||||||
|
*/
|
||||||
|
iconUrl: string;
|
||||||
|
}
|
||||||
|
|
||||||
class MainFunction<M extends Manager> extends Modular<M> {
|
class MainFunction<M extends Manager> extends Modular<M> {
|
||||||
|
|
||||||
|
public static readonly MainFunctionList: IMainFunctionItem[] = [
|
||||||
|
{ displayName: "账号信息", iconUrl: "UserInfo" },
|
||||||
|
{ displayName: "课表缓存", iconUrl: "DateList" },
|
||||||
|
{ displayName: "功能定制", iconUrl: "Customer" },
|
||||||
|
{ displayName: "更多设置", iconUrl: "Settings" }
|
||||||
|
];
|
||||||
|
|
||||||
|
public data? = {
|
||||||
|
mainFunctionList: MainFunction.MainFunctionList
|
||||||
|
}
|
||||||
|
|
||||||
public override onLoad() {
|
public override onLoad() {
|
||||||
// Do something
|
// Do something
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ implements Partial<ILifetime> {
|
|||||||
s.set("be", 12);
|
s.set("be", 12);
|
||||||
}, 1000)
|
}, 1000)
|
||||||
|
|
||||||
new Login().param({studentId: "1806240113", password: "qazxsw123"})
|
// new Login().param({studentId: "1806240113", password: ""})
|
||||||
.request().wait({
|
// .request().wait({
|
||||||
ok: (w) => {console.log("ok", w)},
|
// ok: (w) => {console.log("ok", w)},
|
||||||
no: (w) => {console.log("no", w)},
|
// no: (w) => {console.log("no", w)},
|
||||||
done: (w) => {console.log("done", w)}
|
// done: (w) => {console.log("done", w)}
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,17 @@ import { TestCore } from "./TestCore";
|
|||||||
* 此页面使用 Manager 进行模块化管理
|
* 此页面使用 Manager 进行模块化管理
|
||||||
* 若要添加先功能请先定义 Modular 并添加至 Manager
|
* 若要添加先功能请先定义 Modular 并添加至 Manager
|
||||||
*/
|
*/
|
||||||
Manager.Page((manager)=>{
|
(async () => {
|
||||||
|
|
||||||
|
// 初始化页面
|
||||||
|
const { manager, query } = await Manager.PageAsync();
|
||||||
|
|
||||||
|
// 添加 StatusBar Modular
|
||||||
manager.addModule(StatusBar, "statusBar");
|
manager.addModule(StatusBar, "statusBar");
|
||||||
|
|
||||||
|
// 添加 TestCore Modular
|
||||||
manager.addModule(TestCore, "testCore");
|
manager.addModule(TestCore, "testCore");
|
||||||
})
|
|
||||||
|
// 初始化全部 Modular
|
||||||
|
await manager.loadAllModule(query);
|
||||||
|
})()
|
||||||
Reference in New Issue
Block a user