diff --git a/miniprogram/pages/components/page-plugin/page-plugin.json b/miniprogram/pages/components/page-plugin/page-plugin.json index fe3d234..32eaf45 100644 --- a/miniprogram/pages/components/page-plugin/page-plugin.json +++ b/miniprogram/pages/components/page-plugin/page-plugin.json @@ -3,7 +3,8 @@ "usingComponents": { "t-button": "tdesign-miniprogram/button/button", "t-checkbox": "tdesign-miniprogram/checkbox/checkbox", - "t-divider": "tdesign-miniprogram/divider/divider", - "t-link": "tdesign-miniprogram/link/link" + "t-link": "tdesign-miniprogram/link/link", + "t-loading": "tdesign-miniprogram/loading/loading", + "no-auth-plugin": "/pages/components/no-auth-plugin/no-auth-plugin" } -} \ No newline at end of file +} diff --git a/miniprogram/pages/components/page-plugin/page-plugin.ts b/miniprogram/pages/components/page-plugin/page-plugin.ts index 2e9b43f..9759b63 100644 --- a/miniprogram/pages/components/page-plugin/page-plugin.ts +++ b/miniprogram/pages/components/page-plugin/page-plugin.ts @@ -1,6 +1,6 @@ import { base, defaultAvatarUrl } from "@/utils/config"; import { Subscribe } from "@/utils/subscribe"; -import { getCurrentPageRoute, getStorage, setStorage } from "@/utils/util"; +import { setStorage } from "@/utils/util"; // import { IStorage } from "@/utils/storage"; // const app = getApp(); @@ -12,22 +12,22 @@ Component({ isLogin: Boolean, loading: Boolean, isAuth: null, - style: null, + customStyle: null, }, - attached() { - this.setData({ isLogin: getStorage("isLogin") == 1 }); + // attached() { + // this.setData({ isLogin: getStorage("isLogin") == 1 }); - console.log("attached"); - Subscribe.on("isLogin", getCurrentPageRoute(), () => { - this.setData({ isLogin: getStorage("isLogin") == 1 }); - console.log("监听到 isLogin 变化:"); - }); - }, - detached() { - console.log("detached"); - Subscribe.off("isLogin", getCurrentPageRoute()); - }, + // console.log("attached"); + // Subscribe.on("isLogin", getCurrentPageRoute(), () => { + // this.setData({ isLogin: getStorage("isLogin") == 1 }); + // console.log("监听到 isLogin 变化:"); + // }); + // }, + // detached() { + // console.log("detached"); + // Subscribe.off("isLogin", getCurrentPageRoute()); + // }, data: { avatarUrl: defaultAvatarUrl, diff --git a/miniprogram/pages/components/page-plugin/page-plugin.wxml b/miniprogram/pages/components/page-plugin/page-plugin.wxml index 3d67e3f..4b42441 100644 --- a/miniprogram/pages/components/page-plugin/page-plugin.wxml +++ b/miniprogram/pages/components/page-plugin/page-plugin.wxml @@ -1,15 +1,15 @@ - + - - + + - + @@ -27,11 +27,12 @@ 我已阅读并同意 - - 《{{appletName}}平台用户服务协议》 + 《{{appletName}}平台用户服务协议》 + - 《{{appletName}}隐私权政策》 - + 《{{appletName}}隐私权政策》 + + diff --git a/miniprogram/pages/components/pagination-plugin/pagination-plugin.json b/miniprogram/pages/components/pagination-plugin/pagination-plugin.json new file mode 100644 index 0000000..4d6b044 --- /dev/null +++ b/miniprogram/pages/components/pagination-plugin/pagination-plugin.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": { + "t-picker": "tdesign-miniprogram/picker/picker", + "t-picker-item": "tdesign-miniprogram/picker-item/picker-item" + } +} + diff --git a/miniprogram/pages/components/pagination-plugin/pagination-plugin.ts b/miniprogram/pages/components/pagination-plugin/pagination-plugin.ts new file mode 100644 index 0000000..f7e5c3d --- /dev/null +++ b/miniprogram/pages/components/pagination-plugin/pagination-plugin.ts @@ -0,0 +1,102 @@ +import { getDataSet, toNumber } from "@/utils/util"; + +Component({ + options: { multipleSlots: true }, + /** + * 组件的属性列表 + */ + properties: { + curr_page: { + type: Number, + value: 1, + observer() { + this.page(); + }, + }, + total: { + type: Number, + value: 0, + observer() { + this.page(); + }, + }, + page_count: { + type: Number, + value: 20, + observer() { + this.page(); + }, + }, + }, + + /** + * 组件的初始数据 + */ + data: { + pages: [] as number[], + totalPage: 0, + open: false, + pickerPages: [] as any[], + }, + + /** + * 组件的方法列表 + */ + methods: { + page() { + const totalPage = Math.ceil( + toNumber(this.data.total) / toNumber(this.data.page_count) + ); + const showPageNum = 3; + + // 计算显示的页码范围 + let startPage = Math.max( + 1, + toNumber(this.data.curr_page) - Math.floor(showPageNum / 2) + ); + let endPage = Math.min(totalPage, startPage + showPageNum - 1); + + // 调整起始页码,确保显示的页码数量不超过最大值 + if (endPage - startPage + 1 < showPageNum) { + startPage = Math.max(1, endPage - showPageNum + 1); + } + + // 生成页码数组 + const pages = []; + for (let i = startPage; i <= endPage; i++) { + pages.push(i); + } + + this.setData({ pages, totalPage }); + }, + pageChange(e: any) { + let curr_page = getDataSet(e).page; + // if (curr_page == this.data.curr_page) { + // return; + // } + if (curr_page == "prev") { + curr_page = this.data.curr_page - 1; + } else if (curr_page == "next") { + curr_page = this.data.curr_page + 1; + } + this.triggerEvent("change", { curr_page }); + }, + pageSelect() { + this.setData({ + open: true, + pickerPages: Array.from({ length: this.data.totalPage }, (_, i) => ({ + value: i + 1, + label: `第 ${i + 1} 页`, + })), + }); + }, + onConfirm(e: any) { + const curr_page = e.detail.value[0]; + // if (curr_page == this.data.curr_page) { + // return; + // } + this.triggerEvent("change", { curr_page: curr_page }); + }, + }, +}); + diff --git a/miniprogram/pages/components/pagination-plugin/pagination-plugin.wxml b/miniprogram/pages/components/pagination-plugin/pagination-plugin.wxml new file mode 100644 index 0000000..13e23e4 --- /dev/null +++ b/miniprogram/pages/components/pagination-plugin/pagination-plugin.wxml @@ -0,0 +1,42 @@ + + 共{{total}}条 + + + {{item}} + + + + 跳转 + + + + + + diff --git a/miniprogram/pages/components/pagination-plugin/pagination-plugin.wxss b/miniprogram/pages/components/pagination-plugin/pagination-plugin.wxss new file mode 100644 index 0000000..1f3bcaf --- /dev/null +++ b/miniprogram/pages/components/pagination-plugin/pagination-plugin.wxss @@ -0,0 +1,8 @@ +.box { + display: flex; + align-items: center; + justify-content: center; + flex-wrap: wrap; + column-gap: 8px; + row-gap: 8px; +} diff --git a/miniprogram/pages/components/select-plugin/select-plugin.json b/miniprogram/pages/components/select-plugin/select-plugin.json new file mode 100644 index 0000000..85aa4cf --- /dev/null +++ b/miniprogram/pages/components/select-plugin/select-plugin.json @@ -0,0 +1,10 @@ +{ + "component": true, + "usingComponents": { + "popup-plugin": "/pages/components/popup-plugin/popup-plugin", + "t-radio-group": "tdesign-miniprogram/radio-group/radio-group", + "t-checkbox": "tdesign-miniprogram/checkbox/checkbox", + "t-checkbox-group": "tdesign-miniprogram/checkbox-group/checkbox-group" + } +} + diff --git a/miniprogram/pages/components/select-plugin/select-plugin.ts b/miniprogram/pages/components/select-plugin/select-plugin.ts new file mode 100644 index 0000000..8645f6d --- /dev/null +++ b/miniprogram/pages/components/select-plugin/select-plugin.ts @@ -0,0 +1,64 @@ +Component({ + options: { multipleSlots: true }, + /** + * 组件的属性列表 + */ + properties: { + mode: { + type: String, + value: "single", + }, + title: { + type: String, + value: "请选择", + }, + options: { + type: Array, + value: [], + }, + value: { + type: null, + value: [], + }, + }, + observers: { + "value,mode": function (v, m) { + if (m == "multiple") { + this.setData({ val: Array.isArray(v) ? [...v] : [] }); + } else { + this.setData({ val: v }); + } + }, + }, + + /** + * 组件的初始数据 + */ + data: { + visible: false, + val: [] as any[] | string | number, + }, + + /** + * 组件的方法列表 + */ + methods: { + click() { + this.setData({ visible: true }); + }, + close() { + this.setData({ visible: false }); + }, + radioChange(e: any) { + this.setData({ val: e.detail.value }); + }, + checkboxChange(e: any) { + this.setData({ val: e.detail.value }); + }, + ok() { + this.setData({ visible: false }); + this.triggerEvent("change", { value: this.data.val }); + }, + }, +}); + diff --git a/miniprogram/pages/components/select-plugin/select-plugin.wxml b/miniprogram/pages/components/select-plugin/select-plugin.wxml new file mode 100644 index 0000000..b867e9c --- /dev/null +++ b/miniprogram/pages/components/select-plugin/select-plugin.wxml @@ -0,0 +1,30 @@ + + + + + + + + + + + {{item.label}} + + + + + 确定 + + + diff --git a/miniprogram/pages/components/select-plugin/select-plugin.wxss b/miniprogram/pages/components/select-plugin/select-plugin.wxss new file mode 100644 index 0000000..6ed0c83 --- /dev/null +++ b/miniprogram/pages/components/select-plugin/select-plugin.wxss @@ -0,0 +1,10 @@ +.footer { + display: flex; + align-items: center; + justify-content: center; + position: sticky; + bottom: 0; + background: #fff; + z-index: 1; + padding-top: 12px; +} diff --git a/miniprogram/pages/components/tab-bar-plugin/tab-bar-plugin.json b/miniprogram/pages/components/tab-bar-plugin/tab-bar-plugin.json new file mode 100644 index 0000000..3417547 --- /dev/null +++ b/miniprogram/pages/components/tab-bar-plugin/tab-bar-plugin.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": { + "t-tab-bar": "tdesign-miniprogram/tab-bar/tab-bar", + "t-tab-bar-item": "tdesign-miniprogram/tab-bar-item/tab-bar-item" + } +} + diff --git a/miniprogram/pages/components/tab-bar-plugin/tab-bar-plugin.ts b/miniprogram/pages/components/tab-bar-plugin/tab-bar-plugin.ts new file mode 100644 index 0000000..4ab532a --- /dev/null +++ b/miniprogram/pages/components/tab-bar-plugin/tab-bar-plugin.ts @@ -0,0 +1,43 @@ +Component({ + options: { multipleSlots: true }, + /** + * 组件的属性列表 + */ + properties: { + active: { + type: String, + value: "home", + }, + }, + + /** + * 组件的初始数据 + */ + data: { + list: [ + { value: "home", label: "首页", icon: "home" }, + { value: "scan", label: "扫码", icon: "scan" }, + { value: "my", label: "我的", icon: "user" }, + ], + pages: { + index: "/pages/index/index", + scan: "/pages/processEntry/processEntry", + my: "/pages/my/my", + } as Record, + }, + + /** + * 组件的方法列表 + */ + methods: { + onChange(e: any) { + if (e.detail.value == this.data.active) { + return; + } + wx.reLaunch({ + url: this.data.pages[e.detail.value], + }); + }, + }, +}); + diff --git a/miniprogram/pages/components/tab-bar-plugin/tab-bar-plugin.wxml b/miniprogram/pages/components/tab-bar-plugin/tab-bar-plugin.wxml new file mode 100644 index 0000000..3479f92 --- /dev/null +++ b/miniprogram/pages/components/tab-bar-plugin/tab-bar-plugin.wxml @@ -0,0 +1,13 @@ + + + {{item.label}} + + + diff --git a/miniprogram/pages/components/tab-bar-plugin/tab-bar-plugin.wxss b/miniprogram/pages/components/tab-bar-plugin/tab-bar-plugin.wxss new file mode 100644 index 0000000..e69de29