Merge branch 'master' of http://gitea.zianxin.com/zianxin-tec/biz-mobile-react-cloud
This commit is contained in:
commit
7754e9c471
5 files changed
+89
-95
No files matched your search
+1
-1
@@ -371,4 +371,4 @@
|
||||
// },
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ const toDetail = async (v: any) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
1
|
||||
<crud-layout bg="/static/page/blue-bg.png">
|
||||
<z-paging
|
||||
ref="pageRef"
|
||||
|
||||
@@ -128,9 +128,9 @@
|
||||
<view class="flex flex-col items-end justify-center m-t-5rpx">
|
||||
<view class="second-text-22">{{ hooks.useEnum("hardwareRefundStatusEnum", state.curOrder.refundStatus) }}</view>
|
||||
<view class="flex">
|
||||
<view v-if="state.curOrder.carList?.length" class="m-t-4rpx m-r-10rpx second-text-26"
|
||||
>共 {{ state.curOrder.carList.length }} 件</view
|
||||
>
|
||||
<view v-if="state.curOrder.carList?.length" class="m-t-4rpx m-r-10rpx second-text-26">
|
||||
共 {{ state.curOrder.carList.length }} 件
|
||||
</view>
|
||||
<view class="main-text-30 color-red!">¥ {{ hooks.useMoney(state.curOrder.totalPrice) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -23,7 +23,7 @@ onLoad(() => {
|
||||
app._initTabbar()
|
||||
})
|
||||
onShow(() => {
|
||||
pageRef.value && pageRef.value.reload(false)
|
||||
// pageRef.value && pageRef.value.reload(false)
|
||||
})
|
||||
|
||||
const toDetail = async (v: any) => {
|
||||
@@ -35,6 +35,7 @@ const toDetail = async (v: any) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
1
|
||||
<crud-layout bg="/static/page/blue-bg.png">
|
||||
<z-paging
|
||||
ref="pageRef"
|
||||
|
||||
@@ -1,99 +1,91 @@
|
||||
import fs from "fs";
|
||||
import stripJsonComments from "./strip-json-comments";
|
||||
import fs from "fs"
|
||||
import stripJsonComments from "./strip-json-comments"
|
||||
|
||||
class TransformPages {
|
||||
routes: any = [];
|
||||
tabbar: any = [];
|
||||
includes = [];
|
||||
uniPagesJSON: any = "";
|
||||
routes: any = []
|
||||
tabbar: any = []
|
||||
includes = []
|
||||
uniPagesJSON: any = ""
|
||||
|
||||
constructor({ includes, pagesJsonDir }: any) {
|
||||
this.includes = includes;
|
||||
this.uniPagesJSON = JSON.parse(
|
||||
stripJsonComments(fs.readFileSync(pagesJsonDir, "utf-8"))
|
||||
);
|
||||
this.routes = this.getPagesRoutes().concat(this.getSubPackagesRoutes());
|
||||
this.tabbar = this.getTabbarRoutes();
|
||||
}
|
||||
constructor({ includes, pagesJsonDir }: any) {
|
||||
this.includes = includes
|
||||
this.uniPagesJSON = JSON.parse(stripJsonComments(fs.readFileSync(pagesJsonDir, "utf-8")))
|
||||
this.routes = this.getPagesRoutes().concat(this.getSubPackagesRoutes())
|
||||
this.tabbar = this.getTabbarRoutes()
|
||||
}
|
||||
|
||||
getPagesRoutes(pages = this.uniPagesJSON.pages, rootPath = null) {
|
||||
let routes = [];
|
||||
for (let i = 0; i < pages.length; i++) {
|
||||
const item = pages[i];
|
||||
let route: any = {};
|
||||
for (let j = 0; j < this.includes.length; j++) {
|
||||
const key = this.includes[j];
|
||||
let value = item[key];
|
||||
if (key === "path") {
|
||||
value = rootPath ? `/${rootPath}/${value}` : `/${value}`;
|
||||
}
|
||||
if (key === "aliasPath" && i == 0 && rootPath == null) {
|
||||
route[key] = route[key] || "/";
|
||||
} else if (value !== undefined) {
|
||||
route[key] = value;
|
||||
}
|
||||
}
|
||||
routes.push(route);
|
||||
}
|
||||
return routes;
|
||||
}
|
||||
getPagesRoutes(pages = this.uniPagesJSON.pages, rootPath = null) {
|
||||
let routes = []
|
||||
for (let i = 0; i < pages.length; i++) {
|
||||
const item = pages[i]
|
||||
let route: any = {}
|
||||
for (let j = 0; j < this.includes.length; j++) {
|
||||
const key = this.includes[j]
|
||||
let value = item[key]
|
||||
if (key === "path") {
|
||||
value = rootPath ? `/${rootPath}/${value}` : `/${value}`
|
||||
}
|
||||
if (key === "aliasPath" && i == 0 && rootPath == null) {
|
||||
route[key] = route[key] || "/"
|
||||
} else if (value !== undefined) {
|
||||
route[key] = value
|
||||
}
|
||||
}
|
||||
routes.push(route)
|
||||
}
|
||||
return routes
|
||||
}
|
||||
|
||||
getSubPackagesRoutes() {
|
||||
if (!(this.uniPagesJSON && this.uniPagesJSON.subPackages)) {
|
||||
return [];
|
||||
}
|
||||
const subPackages = this.uniPagesJSON.subPackages;
|
||||
let routes: any = [];
|
||||
for (let i = 0; i < subPackages.length; i++) {
|
||||
const subPages = subPackages[i].pages;
|
||||
const root = subPackages[i].root;
|
||||
const subRoutes = this.getPagesRoutes(subPages, root);
|
||||
routes = routes.concat(subRoutes);
|
||||
}
|
||||
return routes;
|
||||
}
|
||||
getSubPackagesRoutes() {
|
||||
if (!(this.uniPagesJSON && this.uniPagesJSON.subPackages)) {
|
||||
return []
|
||||
}
|
||||
const subPackages = this.uniPagesJSON.subPackages
|
||||
let routes: any = []
|
||||
for (let i = 0; i < subPackages.length; i++) {
|
||||
const subPages = subPackages[i].pages
|
||||
const root = subPackages[i].root
|
||||
const subRoutes = this.getPagesRoutes(subPages, root)
|
||||
routes = routes.concat(subRoutes)
|
||||
}
|
||||
return routes
|
||||
}
|
||||
|
||||
getTabbarRoutes() {
|
||||
if (
|
||||
!(
|
||||
this.uniPagesJSON &&
|
||||
this.uniPagesJSON.tabBar &&
|
||||
this.uniPagesJSON.tabBar.list
|
||||
)
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
const tabbar = this.uniPagesJSON.tabBar.list;
|
||||
let tabbarMap: any = [];
|
||||
tabbar.forEach((bar: { pagePath: string }) => {
|
||||
tabbarMap.push("/" + bar.pagePath);
|
||||
});
|
||||
return tabbarMap;
|
||||
}
|
||||
getTabbarRoutes() {
|
||||
if (!(this.uniPagesJSON && this.uniPagesJSON.tabBar && this.uniPagesJSON.tabBar.list)) {
|
||||
return []
|
||||
}
|
||||
const tabbar = this.uniPagesJSON.tabBar.list
|
||||
let tabbarMap: any = []
|
||||
tabbar.forEach((bar: { pagePath: string }) => {
|
||||
tabbarMap.push("/" + bar.pagePath)
|
||||
})
|
||||
return tabbarMap
|
||||
}
|
||||
}
|
||||
|
||||
export const useRouter = ({ pagesJsonDir, includes = [] }: any) => {
|
||||
let defaultIncludes = ["path", "aliasPath", "name"];
|
||||
includes = [...defaultIncludes, ...includes];
|
||||
let pages = new TransformPages({
|
||||
pagesJsonDir,
|
||||
includes,
|
||||
});
|
||||
if (pages.tabbar && pages.tabbar.length) {
|
||||
console.table(pages.tabbar);
|
||||
}
|
||||
if (pages.routes && pages.routes.length) {
|
||||
console.table(pages.routes);
|
||||
}
|
||||
return {
|
||||
name: "use-router",
|
||||
config() {
|
||||
return {
|
||||
define: {
|
||||
__ROUTES__: JSON.stringify(pages.routes),
|
||||
__TABBAR__: JSON.stringify(pages.tabbar),
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
};
|
||||
let defaultIncludes = ["path", "aliasPath", "name"]
|
||||
includes = [...defaultIncludes, ...includes]
|
||||
let pages = new TransformPages({
|
||||
pagesJsonDir,
|
||||
includes,
|
||||
})
|
||||
if (pages.tabbar && pages.tabbar.length) {
|
||||
console.table(pages.tabbar)
|
||||
}
|
||||
if (pages.routes && pages.routes.length) {
|
||||
console.table(pages.routes)
|
||||
}
|
||||
return {
|
||||
name: "use-router",
|
||||
config() {
|
||||
return {
|
||||
define: {
|
||||
__ROUTES__: JSON.stringify(pages.routes),
|
||||
__TABBAR__: JSON.stringify(pages.tabbar),
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user