new file: App.vue

new file:   LICENSE
new file:   README.md
new file:   WMS_PDA.code-workspace
new file:   common/api.js
new file:   common/config.js
new file:   common/demo.scss
new file:   common/mixin.js
new file:   common/props.js
new file:   components/BluetoothDeviceSelector/BluetoothDeviceSelector.vue
new file:   components/BluetoothPrint/BluetoothPrint.vue
new file:   components/PrintPanel/PrintPanel.vue
new file:   components/WorkbenchPrint/WorkbenchPrint.vue
new file:   components/demo-com/demo-com.vue
new file:   components/inputAndSelect/inputAndSelect.vue
new file:   components/page-nav/page-nav.vue
new file:   components/pagination/pagination.vue
new file:   components/space-list/space-list.vue
new file:   components/uploadImgCos/uploadImgCos.vue
new file:   core/index.js
new file:   core/mixins/index.js
new file:   core/request/apis.js
new file:   core/request/index.js
new file:   core/request/request.js
new file:   core/router/index.js
new file:   core/router/uni-simple-router.js
new file:   core/store/index.js
new file:   core/store/modules/bluetoothPrint.js
new file:   core/store/modules/broadcast.js
new file:   core/store/modules/floatWindowManager.js
new file:   core/store/modules/print.js
new file:   core/store/modules/setting.js
new file:   core/store/modules/user.js
new file:   core/utils/auth.js
new file:   core/utils/base64.js
new file:   core/utils/broadcast.js
new file:   core/utils/dpi-converter.js
new file:   core/utils/encoding-indexes.js
new file:   core/utils/encoding.js
new file:   core/utils/floatWindowManager.js
new file:   core/utils/simpleFloat.js
new file:   core/utils/tool.js
new file:   core/utils/tsc.js
new file:   env.js
new file:   main.js
new file:   manifest.json
new file:   package.json
new file:   pages.json
new file:   pages/403.vue
new file:   pages/404.vue
new file:   pages/componentsA/backtop/backtop.nvue
new file:   pages/componentsA/button/button.nvue
new file:   pages/componentsA/cell/cell.nvue
new file:   pages/componentsA/checkbox/checkbox.nvue
new file:   pages/componentsA/divider/divider.nvue
new file:   pages/componentsA/empty/empty.nvue
new file:   pages/componentsA/gap/gap.nvue
new file:   pages/componentsA/grid/grid.nvue
new file:   pages/componentsA/icon/icon.nvue
new file:   pages/componentsA/image/image.nvue
new file:   pages/componentsA/line/line.nvue
new file:   pages/componentsA/link/link.nvue
new file:   pages/componentsA/loading-icon/loading-icon.nvue
new file:   pages/componentsA/loading-page/loading-page.nvue
new file:   pages/componentsA/overlay/overlay.nvue
new file:   pages/componentsA/popup/popup.nvue
new file:   pages/componentsA/radio/radio.nvue
new file:   pages/componentsA/rate/rate.nvue
new file:   pages/componentsA/sticky/sticky.nvue
new file:   pages/componentsA/swipeAction/swipeAction.nvue
new file:   pages/componentsA/test/test.vue
new file:   pages/componentsA/transition/transition.nvue
new file:   pages/componentsB/actionSheet/actionSheet.nvue
new file:   pages/componentsB/alert/alert.nvue
new file:   pages/componentsB/badge/badge.nvue
new file:   pages/componentsB/code/code.nvue
new file:   pages/componentsB/collapse/collapse.nvue
new file:   pages/componentsB/color/color.nvue
new file:   pages/componentsB/countDown/countDown.nvue
new file:   pages/componentsB/countTo/countTo.nvue
new file:   pages/componentsB/dropdown/dropdown.nvue
new file:   pages/componentsB/keyboard/keyboard.nvue
new file:   pages/componentsB/noticeBar/noticeBar.nvue
new file:   pages/componentsB/notify/notify.nvue
new file:   pages/componentsB/numberBox/numberBox.nvue
new file:   pages/componentsB/parse/content.js
new file:   pages/componentsB/parse/jump.vue
new file:   pages/componentsB/parse/parse.nvue
new file:   pages/componentsB/progress/progress.nvue
new file:   pages/componentsB/search/search.nvue
new file:   pages/componentsB/slider/slider.nvue
new file:   pages/componentsB/switch/switch.nvue
new file:   pages/componentsB/tabbar/tabbar.nvue
new file:   pages/componentsB/tag/tag.nvue
new file:   pages/componentsB/toast/toast.nvue
new file:   pages/componentsB/upload/upload.nvue
new file:   pages/componentsC/album/album.nvue
new file:   pages/componentsC/avatar/avatar.nvue
new file:   pages/componentsC/calendar/calendar.nvue
new file:   pages/componentsC/codeInput/codeInput.nvue
new file:   pages/componentsC/datetimePicker/datetimePicker.nvue
new file:   pages/componentsC/form/form.nvue
new file:   pages/componentsC/indexList/indexList.nvue
new file:   pages/componentsC/input/input.nvue
new file:   pages/componentsC/layout/layout.nvue
new file:   pages/componentsC/list/list.nvue
new file:   pages/componentsC/loadmore/loadmore.nvue
new file:   pages/componentsC/modal/modal.nvue
new file:   pages/componentsC/navbar/navbar.nvue
new file:   pages/componentsC/noNetwork/noNetwork.nvue
new file:   pages/componentsC/picker/picker.nvue
new file:   pages/componentsC/readMore/readMore.nvue
new file:   pages/componentsC/scrollList/scrollList.nvue
new file:   pages/componentsC/skeleton/skeleton.nvue
new file:   pages/componentsC/steps/steps.vue
new file:   pages/componentsC/subsection/subsection.nvue
new file:   pages/componentsC/swiper/swiper.nvue
new file:   pages/componentsC/table/table.nvue
new file:   pages/componentsC/tabs/tabs.nvue
new file:   pages/componentsC/text/text.nvue
new file:   pages/componentsC/textarea/textarea.nvue
new file:   pages/componentsC/tooltip/tooltip.vue
new file:   pages/index/index.vue
new file:   pages/login/index.vue
new file:   pages/message/index.vue
new file:   pages/oa/index.vue
new file:   pages/settings/broadcastSettings.vue
new file:   pages/settings/index.vue
new file:   pages/settings/networkTest.vue
new file:   pages/user/index.vue
new file:   pages/work/index.vue
new file:   pages/work/storage/receiving/components/ProductInfoEditor.vue
new file:   pages/work/storage/receiving/components/detail-container.vue
new file:   pages/work/storage/receiving/components/info-container.vue
new file:   pages/work/storage/receiving/components/stockList.vue
new file:   pages/work/storage/receiving/receiving.vue
new file:   pages/work/storage/receiving/receivingCreate.vue
new file:   pages/work/storage/receiving/receivingDetail.vue
new file:   pages/work/storage/receiving/receivingList.vue
new file:   pages/work/storage/relocation.vue
new file:   static/app-plus/mp-html/js/handler.js
new file:   static/app-plus/mp-html/js/uni.webview.min.js
new file:   static/app-plus/mp-html/local.html
new file:   static/common/js/touch-emulator.js
new file:   static/icon/index.png
new file:   static/icon/index_a.png
new file:   static/icon/mime.png
new file:   static/icon/mime_a.png
new file:   static/icon/oa.png
new file:   static/icon/oa_a.png
new file:   static/loginbg.jpg
new file:   template.h5.html
new file:   tree.md
new file:   uni.scss
new file:   uni_modules/uni-read-pages/README.md
new file:   uni_modules/uni-read-pages/index.js
new file:   uni_modules/uni-read-pages/package.json
new file:   uni_modules/uni-simple-router/.eslintignore
new file:   uni_modules/uni-simple-router/.eslintrc.js
new file:   uni_modules/uni-simple-router/.github/ISSUE_TEMPLATE/bug_report.md
new file:   uni_modules/uni-simple-router/.github/ISSUE_TEMPLATE/feature_request.md
new file:   uni_modules/uni-simple-router/CODE_OF_CONDUCT.md
new file:   uni_modules/uni-simple-router/LICENSE
new file:   uni_modules/uni-simple-router/README.md
new file:   uni_modules/uni-simple-router/RFC.md
new file:   uni_modules/uni-simple-router/api-extractor.json
new file:   uni_modules/uni-simple-router/dist/link.vue
new file:   uni_modules/uni-simple-router/dist/uni-simple-router.d.ts
new file:   uni_modules/uni-simple-router/dist/uni-simple-router.js
new file:   uni_modules/uni-simple-router/github.sh
new file:   uni_modules/uni-simple-router/jest.config.js
new file:   uni_modules/uni-simple-router/package.json
new file:   uni_modules/uni-simple-router/progress.md
new file:   uni_modules/uni-simple-router/src/H5/buildRouter.ts
new file:   uni_modules/uni-simple-router/src/H5/proxyHook.ts
new file:   uni_modules/uni-simple-router/src/app/appPatch.ts
new file:   uni_modules/uni-simple-router/src/applets/appletPatch.ts
new file:   uni_modules/uni-simple-router/src/component/link.vue
new file:   uni_modules/uni-simple-router/src/global.d.ts
new file:   uni_modules/uni-simple-router/src/helpers/config.ts
new file:   uni_modules/uni-simple-router/src/helpers/createRouteMap.ts
new file:   uni_modules/uni-simple-router/src/helpers/lifeCycle.ts
new file:   uni_modules/uni-simple-router/src/helpers/mixins.ts
new file:   uni_modules/uni-simple-router/src/helpers/utils.ts
new file:   uni_modules/uni-simple-router/src/helpers/warn.ts
new file:   uni_modules/uni-simple-router/src/index.ts
new file:   uni_modules/uni-simple-router/src/options/base.ts
new file:   uni_modules/uni-simple-router/src/options/config.ts
new file:   uni_modules/uni-simple-router/src/public/hooks.ts
new file:   uni_modules/uni-simple-router/src/public/methods.ts
new file:   uni_modules/uni-simple-router/src/public/page.ts
new file:   uni_modules/uni-simple-router/src/public/query.ts
new file:   uni_modules/uni-simple-router/src/public/rewrite.ts
new file:   uni_modules/uni-simple-router/src/public/router.ts
new file:   uni_modules/uni-simple-router/src/public/uniOrigin.ts
new file:   uni_modules/uni-simple-router/test/path-to-regexp.spec.ts
new file:   uni_modules/uni-simple-router/test/query-toggle.spec.ts
new file:   uni_modules/uni-simple-router/tsconfig.json
new file:   uni_modules/uni-simple-router/webpack/webpack.common.js
new file:   uni_modules/uni-simple-router/webpack/webpack.dev.js
new file:   uni_modules/uni-simple-router/webpack/webpack.prod.js
new file:   uni_modules/uview-ui/LICENSE
new file:   uni_modules/uview-ui/README.md
new file:   uni_modules/uview-ui/changelog.md
new file:   uni_modules/uview-ui/components/u--form/u--form.vue
new file:   uni_modules/uview-ui/components/u--image/u--image.vue
new file:   uni_modules/uview-ui/components/u--input/u--input.vue
new file:   uni_modules/uview-ui/components/u--text/u--text.vue
new file:   uni_modules/uview-ui/components/u--textarea/u--textarea.vue
new file:   uni_modules/uview-ui/components/u-action-sheet/props.js
new file:   uni_modules/uview-ui/components/u-action-sheet/u-action-sheet.vue
new file:   uni_modules/uview-ui/components/u-album/props.js
new file:   uni_modules/uview-ui/components/u-album/u-album.vue
new file:   uni_modules/uview-ui/components/u-alert/props.js
new file:   uni_modules/uview-ui/components/u-alert/u-alert.vue
new file:   uni_modules/uview-ui/components/u-avatar-group/props.js
new file:   uni_modules/uview-ui/components/u-avatar-group/u-avatar-group.vue
new file:   uni_modules/uview-ui/components/u-avatar/props.js
new file:   uni_modules/uview-ui/components/u-avatar/u-avatar.vue
new file:   uni_modules/uview-ui/components/u-back-top/props.js
new file:   uni_modules/uview-ui/components/u-back-top/u-back-top.vue
new file:   uni_modules/uview-ui/components/u-badge/props.js
new file:   uni_modules/uview-ui/components/u-badge/u-badge.vue
new file:   uni_modules/uview-ui/components/u-button/nvue.scss
new file:   uni_modules/uview-ui/components/u-button/props.js
new file:   uni_modules/uview-ui/components/u-button/u-button.vue
new file:   uni_modules/uview-ui/components/u-button/vue.scss
new file:   uni_modules/uview-ui/components/u-calendar/header.vue
new file:   uni_modules/uview-ui/components/u-calendar/month.vue
new file:   uni_modules/uview-ui/components/u-calendar/props.js
new file:   uni_modules/uview-ui/components/u-calendar/u-calendar.vue
new file:   uni_modules/uview-ui/components/u-calendar/util.js
new file:   uni_modules/uview-ui/components/u-car-keyboard/props.js
new file:   uni_modules/uview-ui/components/u-car-keyboard/u-car-keyboard.vue
new file:   uni_modules/uview-ui/components/u-cell-group/props.js
new file:   uni_modules/uview-ui/components/u-cell-group/u-cell-group.vue
new file:   uni_modules/uview-ui/components/u-cell/props.js
new file:   uni_modules/uview-ui/components/u-cell/u-cell.vue
new file:   uni_modules/uview-ui/components/u-checkbox-group/props.js
new file:   uni_modules/uview-ui/components/u-checkbox-group/u-checkbox-group.vue
new file:   uni_modules/uview-ui/components/u-checkbox/props.js
new file:   uni_modules/uview-ui/components/u-checkbox/u-checkbox.vue
new file:   uni_modules/uview-ui/components/u-circle-progress/props.js
new file:   uni_modules/uview-ui/components/u-circle-progress/u-circle-progress.vue
new file:   uni_modules/uview-ui/components/u-code-input/props.js
new file:   uni_modules/uview-ui/components/u-code-input/u-code-input.vue
new file:   uni_modules/uview-ui/components/u-code/props.js
new file:   uni_modules/uview-ui/components/u-code/u-code.vue
new file:   uni_modules/uview-ui/components/u-col/props.js
new file:   uni_modules/uview-ui/components/u-col/u-col.vue
new file:   uni_modules/uview-ui/components/u-collapse-item/props.js
new file:   uni_modules/uview-ui/components/u-collapse-item/u-collapse-item.vue
new file:   uni_modules/uview-ui/components/u-collapse/props.js
new file:   uni_modules/uview-ui/components/u-collapse/u-collapse.vue
new file:   uni_modules/uview-ui/components/u-column-notice/props.js
new file:   uni_modules/uview-ui/components/u-column-notice/u-column-notice.vue
new file:   uni_modules/uview-ui/components/u-count-down/props.js
new file:   uni_modules/uview-ui/components/u-count-down/u-count-down.vue
new file:   uni_modules/uview-ui/components/u-count-down/utils.js
new file:   uni_modules/uview-ui/components/u-count-to/props.js
new file:   uni_modules/uview-ui/components/u-count-to/u-count-to.vue
new file:   uni_modules/uview-ui/components/u-datetime-picker/props.js
new file:   uni_modules/uview-ui/components/u-datetime-picker/u-datetime-picker.vue
new file:   uni_modules/uview-ui/components/u-divider/props.js
new file:   uni_modules/uview-ui/components/u-divider/u-divider.vue
new file:   uni_modules/uview-ui/components/u-dropdown-item/props.js
new file:   uni_modules/uview-ui/components/u-dropdown-item/u-dropdown-item.vue
new file:   uni_modules/uview-ui/components/u-dropdown/props.js
new file:   uni_modules/uview-ui/components/u-dropdown/u-dropdown.vue
new file:   uni_modules/uview-ui/components/u-empty/props.js
new file:   uni_modules/uview-ui/components/u-empty/u-empty.vue
new file:   uni_modules/uview-ui/components/u-form-item/props.js
new file:   uni_modules/uview-ui/components/u-form-item/u-form-item.vue
new file:   uni_modules/uview-ui/components/u-form/props.js
new file:   uni_modules/uview-ui/components/u-form/u-form.vue
new file:   uni_modules/uview-ui/components/u-gap/props.js
new file:   uni_modules/uview-ui/components/u-gap/u-gap.vue
new file:   uni_modules/uview-ui/components/u-grid-item/props.js
new file:   uni_modules/uview-ui/components/u-grid-item/u-grid-item.vue
new file:   uni_modules/uview-ui/components/u-grid/props.js
new file:   uni_modules/uview-ui/components/u-grid/u-grid.vue
new file:   uni_modules/uview-ui/components/u-icon/icons.js
new file:   uni_modules/uview-ui/components/u-icon/props.js
new file:   uni_modules/uview-ui/components/u-icon/u-icon.vue
new file:   uni_modules/uview-ui/components/u-image/props.js
new file:   uni_modules/uview-ui/components/u-image/u-image.vue
new file:   uni_modules/uview-ui/components/u-index-anchor/props.js
new file:   uni_modules/uview-ui/components/u-index-anchor/u-index-anchor.vue
new file:   uni_modules/uview-ui/components/u-index-item/props.js
new file:   uni_modules/uview-ui/components/u-index-item/u-index-item.vue
new file:   uni_modules/uview-ui/components/u-index-list/props.js
new file:   uni_modules/uview-ui/components/u-index-list/u-index-list.vue
new file:   uni_modules/uview-ui/components/u-input/props.js
new file:   uni_modules/uview-ui/components/u-input/u-input.vue
new file:   uni_modules/uview-ui/components/u-keyboard/props.js
new file:   uni_modules/uview-ui/components/u-keyboard/u-keyboard.vue
new file:   uni_modules/uview-ui/components/u-line-progress/props.js
new file:   uni_modules/uview-ui/components/u-line-progress/u-line-progress.vue
new file:   uni_modules/uview-ui/components/u-line/props.js
new file:   uni_modules/uview-ui/components/u-line/u-line.vue
new file:   uni_modules/uview-ui/components/u-link/props.js
new file:   uni_modules/uview-ui/components/u-link/u-link.vue
new file:   uni_modules/uview-ui/components/u-list-item/props.js
new file:   uni_modules/uview-ui/components/u-list-item/u-list-item.vue
new file:   uni_modules/uview-ui/components/u-list/props.js
new file:   uni_modules/uview-ui/components/u-list/u-list.vue
new file:   uni_modules/uview-ui/components/u-loading-icon/props.js
new file:   uni_modules/uview-ui/components/u-loading-icon/u-loading-icon.vue
new file:   uni_modules/uview-ui/components/u-loading-page/props.js
new file:   uni_modules/uview-ui/components/u-loading-page/u-loading-page.vue
new file:   uni_modules/uview-ui/components/u-loadmore/props.js
new file:   uni_modules/uview-ui/components/u-loadmore/u-loadmore.vue
new file:   uni_modules/uview-ui/components/u-modal/props.js
new file:   uni_modules/uview-ui/components/u-modal/u-modal.vue
new file:   uni_modules/uview-ui/components/u-navbar/props.js
new file:   uni_modules/uview-ui/components/u-navbar/u-navbar.vue
new file:   uni_modules/uview-ui/components/u-no-network/props.js
new file:   uni_modules/uview-ui/components/u-no-network/u-no-network.vue
new file:   uni_modules/uview-ui/components/u-notice-bar/props.js
new file:   uni_modules/uview-ui/components/u-notice-bar/u-notice-bar.vue
new file:   uni_modules/uview-ui/components/u-notify/props.js
new file:   uni_modules/uview-ui/components/u-notify/u-notify.vue
new file:   uni_modules/uview-ui/components/u-number-box/props.js
new file:   uni_modules/uview-ui/components/u-number-box/u-number-box.vue
new file:   uni_modules/uview-ui/components/u-number-keyboard/props.js
new file:   uni_modules/uview-ui/components/u-number-keyboard/u-number-keyboard.vue
new file:   uni_modules/uview-ui/components/u-overlay/props.js
new file:   uni_modules/uview-ui/components/u-overlay/u-overlay.vue
new file:   uni_modules/uview-ui/components/u-parse/node/node.vue
new file:   uni_modules/uview-ui/components/u-parse/parser.js
new file:   uni_modules/uview-ui/components/u-parse/props.js
new file:   uni_modules/uview-ui/components/u-parse/u-parse.vue
new file:   uni_modules/uview-ui/components/u-picker-column/props.js
new file:   uni_modules/uview-ui/components/u-picker-column/u-picker-column.vue
new file:   uni_modules/uview-ui/components/u-picker/props.js
new file:   uni_modules/uview-ui/components/u-picker/u-picker.vue
new file:   uni_modules/uview-ui/components/u-popup/props.js
new file:   uni_modules/uview-ui/components/u-popup/u-popup.vue
new file:   uni_modules/uview-ui/components/u-radio-group/props.js
new file:   uni_modules/uview-ui/components/u-radio-group/u-radio-group.vue
new file:   uni_modules/uview-ui/components/u-radio/props.js
new file:   uni_modules/uview-ui/components/u-radio/u-radio.vue
new file:   uni_modules/uview-ui/components/u-rate/props.js
new file:   uni_modules/uview-ui/components/u-rate/u-rate.vue
new file:   uni_modules/uview-ui/components/u-read-more/props.js
new file:   uni_modules/uview-ui/components/u-read-more/u-read-more.vue
new file:   uni_modules/uview-ui/components/u-row-notice/props.js
new file:   uni_modules/uview-ui/components/u-row-notice/u-row-notice.vue
new file:   uni_modules/uview-ui/components/u-row/props.js
new file:   uni_modules/uview-ui/components/u-row/u-row.vue
new file:   uni_modules/uview-ui/components/u-safe-bottom/props.js
new file:   uni_modules/uview-ui/components/u-safe-bottom/u-safe-bottom.vue
new file:   uni_modules/uview-ui/components/u-scroll-list/nvue.js
new file:   uni_modules/uview-ui/components/u-scroll-list/other.js
new file:   uni_modules/uview-ui/components/u-scroll-list/props.js
new file:   uni_modules/uview-ui/components/u-scroll-list/scrollWxs.wxs
new file:   uni_modules/uview-ui/components/u-scroll-list/u-scroll-list.vue
new file:   uni_modules/uview-ui/components/u-search/props.js
new file:   uni_modules/uview-ui/components/u-search/u-search.vue
new file:   uni_modules/uview-ui/components/u-skeleton/props.js
new file:   uni_modules/uview-ui/components/u-skeleton/u-skeleton.vue
new file:   uni_modules/uview-ui/components/u-slider/mpother.js
new file:   uni_modules/uview-ui/components/u-slider/mpwxs.js
new file:   uni_modules/uview-ui/components/u-slider/mpwxs.wxs
new file:   "uni_modules/uview-ui/components/u-slider/nvue - \345\211\257\346\234\254.js"
new file:   uni_modules/uview-ui/components/u-slider/nvue.js
new file:   uni_modules/uview-ui/components/u-slider/props.js
new file:   uni_modules/uview-ui/components/u-slider/u-slider.vue
new file:   uni_modules/uview-ui/components/u-status-bar/props.js
new file:   uni_modules/uview-ui/components/u-status-bar/u-status-bar.vue
new file:   uni_modules/uview-ui/components/u-steps-item/props.js
new file:   uni_modules/uview-ui/components/u-steps-item/u-steps-item.vue
new file:   uni_modules/uview-ui/components/u-steps/props.js
new file:   uni_modules/uview-ui/components/u-steps/u-steps.vue
new file:   uni_modules/uview-ui/components/u-sticky/props.js
new file:   uni_modules/uview-ui/components/u-sticky/u-sticky.vue
new file:   uni_modules/uview-ui/components/u-subsection/props.js
new file:   uni_modules/uview-ui/components/u-subsection/u-subsection.vue
new file:   uni_modules/uview-ui/components/u-swipe-action-item/index - backup.wxs
new file:   uni_modules/uview-ui/components/u-swipe-action-item/index.wxs
new file:   uni_modules/uview-ui/components/u-swipe-action-item/nvue - backup.js
new file:   uni_modules/uview-ui/components/u-swipe-action-item/nvue.js
new file:   uni_modules/uview-ui/components/u-swipe-action-item/props.js
new file:   uni_modules/uview-ui/components/u-swipe-action-item/u-swipe-action-item.vue
new file:   uni_modules/uview-ui/components/u-swipe-action-item/wxs.js
new file:   uni_modules/uview-ui/components/u-swipe-action/props.js
new file:   uni_modules/uview-ui/components/u-swipe-action/u-swipe-action.vue
new file:   uni_modules/uview-ui/components/u-swiper-indicator/props.js
new file:   uni_modules/uview-ui/components/u-swiper-indicator/u-swiper-indicator.vue
new file:   uni_modules/uview-ui/components/u-swiper/props.js
new file:   uni_modules/uview-ui/components/u-swiper/u-swiper.vue
new file:   uni_modules/uview-ui/components/u-switch/props.js
new file:   uni_modules/uview-ui/components/u-switch/u-switch.vue
new file:   uni_modules/uview-ui/components/u-tabbar-item/props.js
new file:   uni_modules/uview-ui/components/u-tabbar-item/u-tabbar-item.vue
new file:   uni_modules/uview-ui/components/u-tabbar/props.js
new file:   uni_modules/uview-ui/components/u-tabbar/u-tabbar.vue
new file:   uni_modules/uview-ui/components/u-table/props.js
new file:   uni_modules/uview-ui/components/u-table/u-table.vue
new file:   uni_modules/uview-ui/components/u-tabs-item/props.js
new file:   uni_modules/uview-ui/components/u-tabs-item/u-tabs-item.vue
new file:   uni_modules/uview-ui/components/u-tabs/props.js
new file:   uni_modules/uview-ui/components/u-tabs/u-tabs.vue
new file:   uni_modules/uview-ui/components/u-tag/props.js
new file:   uni_modules/uview-ui/components/u-tag/u-tag.vue
new file:   uni_modules/uview-ui/components/u-td/props.js
new file:   uni_modules/uview-ui/components/u-td/u-td.vue
new file:   uni_modules/uview-ui/components/u-text/props.js
new file:   uni_modules/uview-ui/components/u-text/u-text.vue
new file:   uni_modules/uview-ui/components/u-text/value.js
new file:   uni_modules/uview-ui/components/u-textarea/props.js
new file:   uni_modules/uview-ui/components/u-textarea/u-textarea.vue
new file:   uni_modules/uview-ui/components/u-toast/u-toast.vue
new file:   uni_modules/uview-ui/components/u-toolbar/props.js
new file:   uni_modules/uview-ui/components/u-toolbar/u-toolbar.vue
new file:   uni_modules/uview-ui/components/u-tooltip/clipboard.min.js
new file:   uni_modules/uview-ui/components/u-tooltip/props.js
new file:   uni_modules/uview-ui/components/u-tooltip/u-tooltip.vue
new file:   uni_modules/uview-ui/components/u-tr/props.js
new file:   uni_modules/uview-ui/components/u-tr/u-tr.vue
new file:   uni_modules/uview-ui/components/u-transition/nvue.ani-map.js
new file:   uni_modules/uview-ui/components/u-transition/props.js
new file:   uni_modules/uview-ui/components/u-transition/transition.js
new file:   uni_modules/uview-ui/components/u-transition/u-transition.vue
new file:   uni_modules/uview-ui/components/u-transition/vue.ani-style.scss
new file:   uni_modules/uview-ui/components/u-upload/mixin.js
new file:   uni_modules/uview-ui/components/u-upload/props.js
new file:   uni_modules/uview-ui/components/u-upload/u-upload.vue
new file:   uni_modules/uview-ui/components/u-upload/utils.js
new file:   uni_modules/uview-ui/components/uview-ui/uview-ui.vue
new file:   uni_modules/uview-ui/index.js
new file:   uni_modules/uview-ui/index.scss
new file:   uni_modules/uview-ui/libs/config/color.js
new file:   uni_modules/uview-ui/libs/config/config.js
new file:   uni_modules/uview-ui/libs/config/props.js
new file:   uni_modules/uview-ui/libs/config/props/actionSheet.js
new file:   uni_modules/uview-ui/libs/config/props/album.js
new file:   uni_modules/uview-ui/libs/config/props/alert.js
new file:   uni_modules/uview-ui/libs/config/props/avatar.js
new file:   uni_modules/uview-ui/libs/config/props/avatarGroup.js
new file:   uni_modules/uview-ui/libs/config/props/backtop.js
new file:   uni_modules/uview-ui/libs/config/props/badge.js
new file:   uni_modules/uview-ui/libs/config/props/button.js
new file:   uni_modules/uview-ui/libs/config/props/calendar.js
new file:   uni_modules/uview-ui/libs/config/props/carKeyboard.js
new file:   uni_modules/uview-ui/libs/config/props/cell.js
new file:   uni_modules/uview-ui/libs/config/props/cellGroup.js
new file:   uni_modules/uview-ui/libs/config/props/checkbox.js
new file:   uni_modules/uview-ui/libs/config/props/checkboxGroup.js
new file:   uni_modules/uview-ui/libs/config/props/circleProgress.js
new file:   uni_modules/uview-ui/libs/config/props/code.js
new file:   uni_modules/uview-ui/libs/config/props/codeInput.js
new file:   uni_modules/uview-ui/libs/config/props/col.js
new file:   uni_modules/uview-ui/libs/config/props/collapse.js
new file:   uni_modules/uview-ui/libs/config/props/collapseItem.js
new file:   uni_modules/uview-ui/libs/config/props/columnNotice.js
new file:   uni_modules/uview-ui/libs/config/props/countDown.js
new file:   uni_modules/uview-ui/libs/config/props/countTo.js
new file:   uni_modules/uview-ui/libs/config/props/datetimePicker.js
new file:   uni_modules/uview-ui/libs/config/props/divider.js
new file:   uni_modules/uview-ui/libs/config/props/empty.js
new file:   uni_modules/uview-ui/libs/config/props/form.js
new file:   uni_modules/uview-ui/libs/config/props/formItem.js
new file:   uni_modules/uview-ui/libs/config/props/gap.js
new file:   uni_modules/uview-ui/libs/config/props/grid.js
new file:   uni_modules/uview-ui/libs/config/props/gridItem.js
new file:   uni_modules/uview-ui/libs/config/props/icon.js
new file:   uni_modules/uview-ui/libs/config/props/image.js
new file:   uni_modules/uview-ui/libs/config/props/indexAnchor.js
new file:   uni_modules/uview-ui/libs/config/props/indexList.js
new file:   uni_modules/uview-ui/libs/config/props/input.js
new file:   uni_modules/uview-ui/libs/config/props/keyboard.js
new file:   uni_modules/uview-ui/libs/config/props/line.js
new file:   uni_modules/uview-ui/libs/config/props/lineProgress.js
new file:   uni_modules/uview-ui/libs/config/props/link.js
new file:   uni_modules/uview-ui/libs/config/props/list.js
new file:   uni_modules/uview-ui/libs/config/props/listItem.js
new file:   uni_modules/uview-ui/libs/config/props/loadingIcon.js
new file:   uni_modules/uview-ui/libs/config/props/loadingPage.js
new file:   uni_modules/uview-ui/libs/config/props/loadmore.js
new file:   uni_modules/uview-ui/libs/config/props/modal.js
new file:   uni_modules/uview-ui/libs/config/props/navbar.js
new file:   uni_modules/uview-ui/libs/config/props/noNetwork.js
new file:   uni_modules/uview-ui/libs/config/props/noticeBar.js
new file:   uni_modules/uview-ui/libs/config/props/notify.js
new file:   uni_modules/uview-ui/libs/config/props/numberBox.js
new file:   uni_modules/uview-ui/libs/config/props/numberKeyboard.js
new file:   uni_modules/uview-ui/libs/config/props/overlay.js
new file:   uni_modules/uview-ui/libs/config/props/parse.js
new file:   uni_modules/uview-ui/libs/config/props/picker.js
new file:   uni_modules/uview-ui/libs/config/props/popup.js
new file:   uni_modules/uview-ui/libs/config/props/radio.js
new file:   uni_modules/uview-ui/libs/config/props/radioGroup.js
new file:   uni_modules/uview-ui/libs/config/props/rate.js
new file:   uni_modules/uview-ui/libs/config/props/readMore.js
new file:   uni_modules/uview-ui/libs/config/props/row.js
new file:   uni_modules/uview-ui/libs/config/props/rowNotice.js
new file:   uni_modules/uview-ui/libs/config/props/scrollList.js
new file:   uni_modules/uview-ui/libs/config/props/search.js
new file:   uni_modules/uview-ui/libs/config/props/section.js
new file:   uni_modules/uview-ui/libs/config/props/skeleton.js
new file:   uni_modules/uview-ui/libs/config/props/slider.js
new file:   uni_modules/uview-ui/libs/config/props/statusBar.js
new file:   uni_modules/uview-ui/libs/config/props/steps.js
new file:   uni_modules/uview-ui/libs/config/props/stepsItem.js
new file:   uni_modules/uview-ui/libs/config/props/sticky.js
new file:   uni_modules/uview-ui/libs/config/props/subsection.js
new file:   uni_modules/uview-ui/libs/config/props/swipeAction.js
new file:   uni_modules/uview-ui/libs/config/props/swipeActionItem.js
new file:   uni_modules/uview-ui/libs/config/props/swiper.js
new file:   uni_modules/uview-ui/libs/config/props/swipterIndicator.js
new file:   uni_modules/uview-ui/libs/config/props/switch.js
new file:   uni_modules/uview-ui/libs/config/props/tabbar.js
new file:   uni_modules/uview-ui/libs/config/props/tabbarItem.js
new file:   uni_modules/uview-ui/libs/config/props/tabs.js
new file:   uni_modules/uview-ui/libs/config/props/tag.js
new file:   uni_modules/uview-ui/libs/config/props/text.js
new file:   uni_modules/uview-ui/libs/config/props/textarea.js
new file:   uni_modules/uview-ui/libs/config/props/toast.js
new file:   uni_modules/uview-ui/libs/config/props/toolbar.js
new file:   uni_modules/uview-ui/libs/config/props/tooltip.js
new file:   uni_modules/uview-ui/libs/config/props/transition.js
new file:   uni_modules/uview-ui/libs/config/props/upload.js
new file:   uni_modules/uview-ui/libs/config/zIndex.js
new file:   uni_modules/uview-ui/libs/css/color.scss
new file:   uni_modules/uview-ui/libs/css/common.scss
new file:   uni_modules/uview-ui/libs/css/components.scss
new file:   uni_modules/uview-ui/libs/css/flex.scss
new file:   uni_modules/uview-ui/libs/css/h5.scss
new file:   uni_modules/uview-ui/libs/css/mixin.scss
new file:   uni_modules/uview-ui/libs/css/mp.scss
new file:   uni_modules/uview-ui/libs/css/nvue.scss
new file:   uni_modules/uview-ui/libs/css/vue.scss
new file:   uni_modules/uview-ui/libs/function/colorGradient.js
new file:   uni_modules/uview-ui/libs/function/debounce.js
new file:   uni_modules/uview-ui/libs/function/digit.js
new file:   uni_modules/uview-ui/libs/function/index.js
new file:   uni_modules/uview-ui/libs/function/platform.js
new file:   uni_modules/uview-ui/libs/function/test.js
new file:   uni_modules/uview-ui/libs/function/throttle.js
new file:   uni_modules/uview-ui/libs/luch-request/adapters/index.js
new file:   uni_modules/uview-ui/libs/luch-request/core/InterceptorManager.js
new file:   uni_modules/uview-ui/libs/luch-request/core/Request.js
new file:   uni_modules/uview-ui/libs/luch-request/core/buildFullPath.js
new file:   uni_modules/uview-ui/libs/luch-request/core/defaults.js
new file:   uni_modules/uview-ui/libs/luch-request/core/dispatchRequest.js
new file:   uni_modules/uview-ui/libs/luch-request/core/mergeConfig.js
new file:   uni_modules/uview-ui/libs/luch-request/core/settle.js
new file:   uni_modules/uview-ui/libs/luch-request/helpers/buildURL.js
new file:   uni_modules/uview-ui/libs/luch-request/helpers/combineURLs.js
new file:   uni_modules/uview-ui/libs/luch-request/helpers/isAbsoluteURL.js
new file:   uni_modules/uview-ui/libs/luch-request/index.d.ts
new file:   uni_modules/uview-ui/libs/luch-request/index.js
new file:   uni_modules/uview-ui/libs/luch-request/utils.js
new file:   uni_modules/uview-ui/libs/luch-request/utils/clone.js
new file:   uni_modules/uview-ui/libs/mixin/button.js
new file:   uni_modules/uview-ui/libs/mixin/mixin.js
new file:   uni_modules/uview-ui/libs/mixin/mpMixin.js
new file:   uni_modules/uview-ui/libs/mixin/mpShare.js
new file:   uni_modules/uview-ui/libs/mixin/openType.js
new file:   uni_modules/uview-ui/libs/mixin/style.js
new file:   uni_modules/uview-ui/libs/mixin/touch.js
new file:   uni_modules/uview-ui/libs/util/async-validator.js
new file:   uni_modules/uview-ui/libs/util/calendar.js
new file:   uni_modules/uview-ui/libs/util/dayjs.js
new file:   uni_modules/uview-ui/libs/util/emitter.js
new file:   uni_modules/uview-ui/libs/util/route.js
new file:   uni_modules/uview-ui/package.json
new file:   uni_modules/uview-ui/theme.scss
new file:   vue.config.js
This commit is contained in:
zm2000 2026-03-16 14:42:06 +08:00
parent fd6cb1fda4
commit c002394df8
570 changed files with 75406 additions and 0 deletions

34
App.vue Normal file
View File

@ -0,0 +1,34 @@
<script>
export default {
onLaunch() {
},
onShow() {
},
methods: {
}
}
</script>
<style lang="scss">
/* 每个页面公共css */
@import "@/uni_modules/uview-ui/index.scss";
@import "common/demo.scss";
.status_bar {
height: var(--status-bar-height);
background-color: #FFFFFF;
}
.normar_container{
height:100vh;
display:flex;
flex-direction: column;
background-color: #f8f8f8;
}
</style>

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 www.uviewui.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

98
README.md Normal file
View File

@ -0,0 +1,98 @@
<p align="center">
<img alt="logo" src="https://uviewui.com/common/logo.png" width="120" height="120" style="margin-bottom: 10px;">
</p>
<h3 align="center" style="margin: 30px 0 30px;font-weight: bold;font-size:40px;">uView 2.0</h3>
<h3 align="center">多平台快速开发的UI框架</h3>
[![stars](https://img.shields.io/github/stars/umicro/uView2.0?style=flat-square&logo=GitHub)](https://github.com/umicro/uView2.0)
[![forks](https://img.shields.io/github/forks/umicro/uView2.0?style=flat-square&logo=GitHub)](https://github.com/umicro/uView2.0)
[![issues](https://img.shields.io/github/issues/umicro/uView2.0?style=flat-square&logo=GitHub)](https://github.com/umicro/uView2.0/issues)
[![Website](https://img.shields.io/badge/uView-up-blue?style=flat-square)](https://uviewui.com)
[![release](https://img.shields.io/github/v/release/umicro/uView2.0?style=flat-square)](https://gitee.com/umicro/uView2.0/releases)
[![license](https://img.shields.io/github/license/umicro/uView2.0?style=flat-square)](https://en.wikipedia.org/wiki/MIT_License)
## 说明
uView UI,是[uni-app](https://uniapp.dcloud.io/)全面兼容nvue的uni-app生态框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水
## [官方文档:https://uviewui.com](https://uviewui.com)
### 官方1群:1042987248(已满)
### 官方2群:249718512(已满)
### 官方3群:1129077272(已满)
### 官方4群:1084514613(已满)
### 官方5群:863820668(已满)
### 官方6群:745721078(已满)
### 官方7群:627867855(已满)
### 官方8群:496409492(已满)
### 官方9群:828504448(已满)
### 官方10群:232041042(已满)
### 官方11群:364463526(已满)
### 官方12群:229707069(已满)
### [点击加13群交流反馈:879811455](https://jq.qq.com/?_wv=1027&k=vz4By4k5)
## 特性
- 全面兼容nvue,原生渲染,高性能
- 兼容安卓,iOS,微信小程序,H5,QQ小程序,百度小程序,支付宝小程序,头条小程序
- 60+精选组件,功能丰富,多端兼容,让您快速集成,开箱即用
- 众多贴心的JS利器,让您飞镖在手,召之即来,百步穿杨
- 众多的常用页面和布局,让您专注逻辑,事半功倍
- 详尽的文档支持,现代化的演示效果
- 按需引入,精简打包体积
## 预览
您可以通过**微信**扫码,查看最佳的演示效果。
<br>
<br>
<img src="https://uviewui.com/common/weixin_mini_qrcode.png" width="220" height="220" >
## 链接
- [官方文档](https://www.uviewui.com/)
- [更新日志](https://www.uviewui.com/components/changelog.html)
- [升级指南](https://www.uviewui.com/components/changeGuide.html)
- [关于我们](https://www.uviewui.com/cooperation/about.html)
## 交流反馈
欢迎加入我们的QQ群交流反馈:[点此跳转](https://www.uviewui.com/components/addQQGroup.html)
## 关于PR
> 我们非常乐意接受各位的优质PR,但在此之前我希望您了解uView2.0是一个需要兼容多个平台的(小程序、h5、ios app、android app)包括nvue页面、vue页面。
> 所以希望在您修复bug并提交之前尽可能的去这些平台测试一下兼容性。最好能携带测试截图以方便审核。非常感谢!
## 安装
#### **uni-app插件市场链接** —— [https://ext.dcloud.net.cn/plugin?id=1593](https://ext.dcloud.net.cn/plugin?id=1593)
请通过[官网安装文档](https://www.uviewui.com/components/install.html)了解更详细的内容
## 快速上手
请通过[快速上手](https://uviewui.com/components/quickstart.html)了解更详细的内容
## 使用方法
配置easycom规则后,自动按需引入,无需`import`组件,直接引用即可。
```html
<template>
<u-button text="按钮"></u-button>
</template>
```
## 捐赠uView的研发
uView文档内容和框架源码全部开源免费,如果您认为uView帮到了您的开发工作,您可以捐赠uView的研发工作,捐赠无门槛,哪怕是一杯可乐也好(相信这比打赏主播更有意义)。
<img src="https://uviewui.com/common/wechat.png" width="220" >
<img style="margin-left: 100px;" src="https://uviewui.com/common/alipay.png" width="220" >
## 版权信息
uView遵循[MIT](https://en.wikipedia.org/wiki/MIT_License)开源协议,意味着您无需支付任何费用,也无需授权,即可将uView应用到您的产品中。

8
WMS_PDA.code-workspace Normal file
View File

@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}

3
common/api.js Normal file
View File

@ -0,0 +1,3 @@
const { http } = uni.$u
// 获取菜单
export const fetchMenu = (params, config = {}) => http.post('/ebapi/public_api/index', params, config)

3
common/config.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
baseUrl: 'https://api.youzixy.com'
}

45
common/demo.scss Normal file
View File

@ -0,0 +1,45 @@
.u-block{
padding: 14px;
&__section{
margin-bottom:10px;
}
&__title {
margin-top:10px;
font-size: 15px;
color: $u-content-color;
margin-bottom:10px;
}
&__flex{
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
}
}
// 使用了cell组件的icon图片样式
.u-cell-icon {
width: 36rpx;
height: 36rpx;
margin-right: 8rpx;
}
.u-page {
padding: 15px 15px 40px 15px;
}
.u-demo-block {
flex: 1;
margin-bottom: 23px;
&__content {
@include flex(column);
}
&__title {
font-size: 14px;
color: rgb(143, 156, 162);
margin-bottom: 8px;
@include flex;
}
}

7
common/mixin.js Normal file
View File

@ -0,0 +1,7 @@
export default {
data() {
return {
}
}
}

2
common/props.js Normal file
View File

@ -0,0 +1,2 @@
uni.$u.props.gap.bgColor = '#f3f4f6'
uni.$u.props.gap.height = '10'

View File

@ -0,0 +1,286 @@
<!-- components/bluetooth-device-selector.vue -->
<template>
<view>
<!-- 设备选择项 -->
<view class="detail-item selectable" @click="openSelector">
<text class="detail-item-label">蓝牙设备:</text>
<view class="detail-item-value">
<text>{{ selectedDeviceName || placeholder }}</text>
<u-icon name="arrow-right" size="24" color="#666"></u-icon>
</view>
</view>
<!-- 设备选择弹窗 -->
<u-popup :show="showSelector" mode="bottom" @close="closeSelector">
<view class="device-selector-popup">
<!-- 弹窗头部 -->
<view class="popup-header">
<text class="popup-title">选择蓝牙打印机</text>
<u-button class="scan-btn" type="primary" size="mini">
搜索中...
</u-button>
</view>
<!-- 设备列表 -->
<scroll-view scroll-y class="device-list" v-if="deviceList.length">
<view v-for="device in deviceList" :key="device.deviceId" class="device-item"
:class="{ selected: isDeviceSelected(device) }" @click="selectDevice(device)">
<view class="device-info">
<text class="device-name">{{ device.name }}</text>
<text class="device-id">{{ device.deviceId }}</text>
</view>
<u-icon v-if="isDeviceSelected(device)" name="checkbox-mark" size="28" color="#2979ff"></u-icon>
</view>
</scroll-view>
<u-empty class="device-list" mode="list" v-else text="暂无设备,请点击搜索"></u-empty>
<!-- 操作按钮 -->
<view class="popup-actions">
<u-button type="default" @click="closeSelector">取消</u-button>
<u-button type="primary" @click="confirmSelection" :disabled="!internalSelectedDevice">
确定
</u-button>
</view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
name: 'BluetoothDeviceSelector',
props: {
// 选中的设备
selectedDevice: {
type: Object,
default: null
},
// 占位符
placeholder: {
type: String,
default: '点击选择蓝牙打印机'
},
// 设备列表
deviceList: {
type: Array,
default: () => []
},
// 列表高度
listHeight: {
type: Number,
default: 400
},
discovering: {
type: Boolean,
default: false
}
},
data() {
return {
showSelector: false,
scanning: false,
internalSelectedDevice: null
}
},
destroyed() {
this.$emit('scan',false);
},
computed: {
selectedDeviceName() {
if (this.selectedDevice) {
return this.selectedDevice.name || this.selectedDevice.deviceId || '已选择设备';
}
return '';
}
},
watch: {
selectedDevice: {
immediate: true,
handler(newVal) {
console.log("新的设备被选中",newVal);
this.internalSelectedDevice = JSON.parse(JSON.stringify(newVal));
}
}
},
methods: {
// 打开选择器
openSelector() {
this.showSelector = true;
this.$emit('scan',true);
this.internalSelectedDevice = this.value;
},
// 关闭选择器
closeSelector() {
this.$emit('scan',false);
this.showSelector = false;
},
// 扫描设备
scanDevices(status) {
},
// 选择设备
selectDevice(device) {
this.internalSelectedDevice = device;
},
// 确认选择
confirmSelection() {
this.$emit('input', this.internalSelectedDevice);
this.$emit('change', this.internalSelectedDevice);
this.closeSelector();
},
// 检查设备是否被选中
isDeviceSelected(device) {
return this.internalSelectedDevice &&
this.internalSelectedDevice.deviceId === device.deviceId;
}
}
}
</script>
<style scoped lang="scss">
.detail-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24rpx 0;
border-bottom: 1rpx solid #f5f5f5;
&.selectable {
cursor: pointer;
&:active {
background-color: #f9f9f9;
}
}
.detail-item-label {
font-size: 32rpx;
color: #333;
font-weight: 500;
}
.detail-item-value {
display: flex;
align-items: center;
gap: 16rpx;
font-size: 28rpx;
color: #666;
max-width: 60%;
text-align: right;
text {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
.device-selector-popup {
background-color: #fff;
border-radius: 20rpx 20rpx 0 0;
height: 60vh;
display: flex;
flex-direction: column;
.popup-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 40rpx 32rpx 24rpx;
border-bottom: 1rpx solid #f0f0f0;
.popup-title {
font-size: 36rpx;
font-weight: bold;
color: #333;
flex: 1;
}
.scan-btn {
width: 200rpx;
}
}
.device-list {
flex: 1;
height: 50rpx;
.device-item {
display: flex;
align-items: center;
padding: 24rpx;
margin-bottom: 16rpx;
border-radius: 16rpx;
border: 2rpx solid #eee;
transition: all 0.3s;
&:active {
background-color: #f9f9f9;
}
&.selected {
border-color: #2979ff;
background-color: #f0f7ff;
}
.device-info {
flex: 1;
margin-left: 24rpx;
display: flex;
flex-direction: column;
.device-name {
font-size: 32rpx;
color: #333;
font-weight: 500;
margin-bottom: 8rpx;
}
.device-id {
font-size: 24rpx;
color: #999;
}
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
padding: 80rpx 0;
.empty-text {
margin-top: 24rpx;
font-size: 28rpx;
color: #999;
}
}
}
.popup-actions {
display: flex;
padding: 24rpx 32rpx;
border-top: 1rpx solid #f0f0f0;
gap: 24rpx;
height:80rpx;
line-height:80rpx;
.u-button {
flex: 1;
}
}
}
</style>

View File

@ -0,0 +1,882 @@
<!-- components/bluetooth-print.vue -->
<template>
<view class="container">
<view class="bluetooth-print" v-if="bluetoothAvailable">
<!-- 内容区域 -->
<view class="section">
<!-- 蓝牙设备选择组件 -->
<BluetoothDeviceSelector :selectedDevice="selectedDevice" :deviceList="deviceList"
@scan="scanBluetoothDevices" :discovering="discovering" @change="confirmSelection" />
<!-- 打印模板选择 -->
<view class="detail-item selectable" @click="showTemplateSelector = true">
<text class="detail-item-label">打印模板:</text>
<view class="detail-item-value">
<text>{{ printRenderData.selectedTemplate ? `${printRenderData.selectedTemplate.template_name}【${printRenderData.selectedTemplate.page_width}mm*${printRenderData.selectedTemplate.page_height}mm】` : "点击选择打印模板" }}</text>
<u-icon name="arrow-right" size="24" color="#666"></u-icon>
</view>
</view>
<view class="detail-item selectable" :prop="printRenderData" :change:prop="printRender.update"
@click="printRender.generateImage">
<text class="detail-item-label">预览</text>
</view>
<view class="view-section">
<scroll-view class="viewer" scroll-x="true" scroll-y="true" >
<image :src="imageUrl" :style="contentStyle"></image>
</scroll-view>
<view class="card-content" id="card-content" :style="contentStyle">1111</view>
</view>
<!-- 操作日志区域 -->
<view class="log-section" v-if="log.length > 0">
<view class="log-header">
<u-icon name="file-text" size="32" color="#2979ff"></u-icon>
<text class="log-title">操作日志</text>
<text class="log-count">({{ log.length }})</text>
<view class="log-actions">
<u-button size="mini" type="primary" @click="clearLogs" :plain="true">
清空
</u-button>
</view>
</view>
<scroll-view scroll-y class="log-container">
<view class="log-list">
<view v-for="(item, index) in log" :key="index" class="log-item"
:class="[`log-${item.type}`]">
<view class="log-item-header">
<u-icon :name="getLogIcon(item.type)" size="24"
:color="getLogColor(item.type)"></u-icon>
<text class="log-type">{{ getLogTypeText(item.type) }}</text>
<text class="log-time">{{ formatTime(item.timestamp) }}</text>
</view>
<view class="log-message">
{{ item.message }}
</view>
<view v-if="item.details" class="log-details">
<text class="details-label">详情:</text>
<text class="details-content">{{ item.details }}</text>
</view>
</view>
</view>
<view v-if="log.length === 0" class="log-empty">
<u-icon name="list" size="60" color="#dcdfe6"></u-icon>
<text class="empty-text">暂无操作日志</text>
</view>
</scroll-view>
</view>
</view>
<!-- 操作按钮 -->
<view class="action-buttons">
<u-button type="primary" :disabled="!selectedDevice || !printRenderData.selectedTemplate"
@click="handlePrint" :loading="printing">
{{ printing ? '打印中...' : '开始打印' }}
</u-button>
</view>
</view>
<u-empty class="bluetoothUnAvailable" mode="address" text="蓝牙未开启" velse>
</u-empty>
<!-- 打印模板选择弹窗 -->
<u-popup :show="showTemplateSelector" mode="bottom" round="20" @close="showTemplateSelector = false">
<view class="template-selector-popup">
<view class="popup-header">
<text class="popup-title">选择打印模板</text>
</view>
<scroll-view scroll-y class="template-list" style="height: 400px;">
<view v-for="template in printTemplateList" :key="template.id" class="template-item"
:class="{ selected: printRenderData.selectedTemplate && printRenderData.selectedTemplate.id === template.id }"
@click="selectTemplate(template)">
<u-icon name="file-text" size="40" color="#19be6b"></u-icon>
<view class="template-info">
<text
class="template-name">{{ template.template_name }}【{{template.page_width}}mm*{{template.page_height}}mm】</text>
</view>
<u-icon
v-if="printRenderData.selectedTemplate && printRenderData.selectedTemplate.id === template.id"
name="checkbox-mark" size="28" color="#2979ff"></u-icon>
</view>
<view v-if="printTemplateList.length === 0" class="empty-state">
<u-icon name="file-text" size="60" color="#ccc"></u-icon>
<text class="empty-text">暂无可用模板</text>
</view>
</scroll-view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
name: 'BluetoothPrint',
props: {
printData: {
type: Object,
default: () => ({})
}
},
data() {
return {
printTemplateList: [],
showTemplateSelector: false,
printing: false,
//bluetoothAvailable: true,
showView: false,
printRenderData: {
selectedTemplate: null,
targetSize: 203.2,
mmToDot: 8,
cardWidthMm: 40,
cardHeightMm: 30,
printImage: "",
},
imageUrl: null,
CanvasData: {}
}
},
mounted() {
this.init();
},
computed: {
contentStyle(){
return {
width:this.printRenderData.selectedTemplate?.page_width+"mm"||0,
height:this.printRenderData.selectedTemplate?.page_height+"mm"||0,
}
},
deviceList() {
return this.$store.state.bluetoothPrint.bluetoothDevices
},
printConfig() {
return this.$store.state.bluetoothPrint.printerConfig
},
printConfig() {
return this.$store.state.bluetoothPrint.printerConfig
},
selectedDevice() {
return this.$store.state.bluetoothPrint.currentDevice
},
discovering() {
return this.$store.state.bluetoothPrint.discovering
},
log() {
return this.$store.state.bluetoothPrint.operationLogs || []
},
bluetoothAvailable() {
return this.$store.state.bluetoothPrint.bluetoothAvailable
}
},
watch: {
printData: {
handler(newVal) {
console.log(newVal)
if (newVal.type) {
this.getPrintTemplate();
}
},
deep: true
},
bluetoothAvailable: {
handler(newVal) {
if (newVal) {
this.init();
}
}
}
},
methods: {
// 初始化
async init() {
console.log(this.deviceList);
await this.getPrintTemplate();
},
//渲染canvas
renderCanvas() {
if (this.selectedTemplate.id) {
this.showView = true;
} else {
uni.showToast({
title: '未选择打印模板',
icon: 'none'
});
}
},
// 获取打印模板
async getPrintTemplate() {
console.log("getPrintTemplate", this.printData.type)
const templates = await this.$store.dispatch("bluetoothPrint/getPrintTemplate", this.printData.type);
console.log("========templates", templates);
if (templates.code == 200) {
this.printTemplateList = templates.data || [];
}
},
// 扫描蓝牙设备
async scanBluetoothDevices(status) {
console.log("搜索设备", status ? "开" : "关");
const devices = await this.$store.dispatch('bluetoothPrint/scanDevices', status);
},
// 选择模板
selectTemplate(template) {
this.printRenderData.selectedTemplate = template;
this.showTemplateSelector = false;
},
// 确认模板选择
confirmTemplate() {
this.showTemplateSelector = false;
},
// 处理打印
async handlePrint() {
if (!this.selectedDevice) {
uni.showToast({
title: '请选择打印设备',
icon: 'none'
})
return
}
this.printing = true;
try {
await this.$store.dispatch('bluetoothPrint/printCanvas', this.CanvasData);
uni.showToast({
title: '打印指令已发送',
icon: 'success'
});
} catch (error) {
console.error('打印失败:', error);
uni.showToast({
title: error.message || '打印失败',
icon: 'none'
});
} finally {
this.printing = false;
}
},
async confirmSelection(device) {
const result = await this.$store.dispatch('bluetoothPrint/connectDevice', device);
console.log(result);
},
// 获取日志图标
getLogIcon(type) {
const icons = {
'success': 'checkmark-circle',
'error': 'close-circle',
'warning': 'error-circle',
'info': 'info-circle',
'default': 'chat'
}
return icons[type] || icons['default'];
},
// 获取日志颜色
getLogColor(type) {
const colors = {
'success': '#19be6b',
'error': '#fa3534',
'warning': '#ff9900',
'info': '#2979ff',
'default': '#909399'
}
return colors[type] || colors['default'];
},
// 获取日志类型文本
getLogTypeText(type) {
const texts = {
'success': '成功',
'error': '错误',
'warning': '警告',
'info': '信息',
'default': '日志'
}
return texts[type] || texts['default'];
},
// 格式化时间
formatTime(timestamp) {
if (!timestamp) return '';
const date = new Date(timestamp);
return `1`;
},
// 清空日志
clearLogs() {
this.$store.dispatch('bluetoothPrint/clearLogs');
},
onImage(src) {
this.imageUrl = src;
},
canvasData(canvas) {
this.CanvasData = canvas;
}
}
}
</script>
<script module="printRender" lang="renderjs">
import html2canvas from 'html2canvas'
import dpiConverter from '@/core/utils/dpi-converter'
let datas = {};
function inArray(arr, key, val) {
for (let i = 0; i < arr.length; i++) {
if (arr[i][key] === val) {
return i;
}
}
return -1;
}
// ArrayBuffer转16进度字符串示例
function ab2hex(buffer) {
var hexArr = Array.prototype.map.call(
new Uint8Array(buffer),
function (bit) {
return ('00' + bit.toString(16)).slice(-2)
}
)
return hexArr.join('');
}
function convertToGrayscale(data) {
let g = 0
for (let i = 0; i < data.length; i += 4) {
g = (data[i] * 0.3 + data[i + 1] * 0.59 + data[i + 2] * 0.11)
data[i] = g
data[i + 1] = g
data[i + 2] = g
}
return data
}
function setPixel(data, offset, value) {
data[offset] = value;
data[offset + 1] = value;
data[offset + 2] = value;
}
function adjustPixel(data, offset, value) {
data[offset] += value;
}
function convertToMonoImage(width, height, imageData, shake) {
// 创建新的数据数组,避免修改原数据
const data = new Uint8ClampedArray(imageData.data);
let g = 0;
let e = 0;
// 第一步:转为灰度(只修改R通道作为灰度值)
for (let i = 0; i < data.length; i += 4) {
// 计算灰度值
g = Math.round(data[i] * 0.3 + data[i + 1] * 0.59 + data[i + 2] * 0.11);
// 设置所有通道为相同的灰度值
data[i] = g; // R
data[i + 1] = g; // G
data[i + 2] = g; // B
// data[i + 3] 保持原alpha不变
}
if (!shake) {
// 如果不抖动,直接二值化
for (let i = 0; i < data.length; i += 4) {
const gray = data[i];
const value = gray >= 150 ? 255 : 0;
data[i] = value;
data[i + 1] = value;
data[i + 2] = value;
}
return new ImageData(data, width, height);
}
// 第二步:Floyd-Steinberg抖动
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
const idx = (y * width + x) * 4;
const oldPixel = data[idx]; // 当前像素的灰度值
// 量化
const newPixel = oldPixel >= 150 ? 255 : 0;
const error = oldPixel - newPixel;
// 设置量化后的值
data[idx] = newPixel;
data[idx + 1] = newPixel;
data[idx + 2] = newPixel;
if (error !== 0) {
// 向右传播 7/16
if (x + 1 < width) {
const rightIdx = (y * width + (x + 1)) * 4;
data[rightIdx] = Math.min(255, Math.max(0, data[rightIdx] + error * 7 / 16));
}
// 向左下传播 3/16
if (y + 1 < height && x > 0) {
const bottomLeftIdx = ((y + 1) * width + (x - 1)) * 4;
data[bottomLeftIdx] = Math.min(255, Math.max(0, data[bottomLeftIdx] + error * 3 / 16));
}
// 向下传播 5/16
if (y + 1 < height) {
const bottomIdx = ((y + 1) * width + x) * 4;
data[bottomIdx] = Math.min(255, Math.max(0, data[bottomIdx] + error * 5 / 16));
}
// 向右下传播 1/16
if (y + 1 < height && x + 1 < width) {
const bottomRightIdx = ((y + 1) * width + (x + 1)) * 4;
data[bottomRightIdx] = Math.min(255, Math.max(0, data[bottomRightIdx] + error * 1 / 16));
}
}
}
}
return new ImageData(data, width, height);
}
export default {
methods: {
async update(newval) {
datas = newval;
},
async generateImage(event, ownerInstance) {
console.log("点击预览", datas);
try {
if (!datas.selectedTemplate.id) {
throw new Error('未选择模板');
}
const element = document.getElementById('card-content')
console.log("element", element);
// 获取当前元素实际渲染尺寸
const rect = element.getBoundingClientRect();
console.log("rect", rect);
const currentWidthPx = rect.width
const currentHeightPx = rect.height
console.log("currentWidthPx", currentWidthPx);
datas.selectedTemplate.page_width
console.log('当前尺寸:', currentWidthPx, 'px');
const scaleFactor = datas.selectedTemplate.page_width*8/currentWidthPx;
const targetSize = {
width:datas.selectedTemplate.page_width*8,
height:datas.selectedTemplate.page_height*8
};
console.log('目标尺寸:', datas.selectedTemplate.page_width*8, 'px');
console.log('缩放比例:', datas.selectedTemplate.page_width*8/currentWidthPx)
console.log('目标尺寸:', targetSize, 'px')
// 生成高精度画布
html2canvas(element, {
backgroundColor: '#ffffff',
useCORS: true,
allowTaint: false,
logging: true,
width: rect.width,
height: rect.height
}).then(sourceCanvas => {
// 创建两个 canvas:一个用于图像处理,一个用于显示测试
const imageCanvas = document.createElement('canvas');
imageCanvas.width = sourceCanvas.width;
imageCanvas.height = sourceCanvas.height;
const imageCtx = imageCanvas.getContext('2d', { willReadFrequently: true });
const displayCanvas = document.createElement('canvas');
displayCanvas.width = sourceCanvas.width;
displayCanvas.height = sourceCanvas.height;
const displayCtx = displayCanvas.getContext('2d', { willReadFrequently: true });
// 复制源内容到两个 canvas
imageCtx.drawImage(sourceCanvas, 0, 0);
displayCtx.drawImage(sourceCanvas, 0, 0);
// 处理图像数据
const imgData = imageCtx.getImageData(0, 0, sourceCanvas.width, sourceCanvas.height);
const processedImgData = convertToMonoImage(
sourceCanvas.width,
sourceCanvas.height,
imgData,
true
);
// 将处理后的数据写入两个 canvas
imageCtx.putImageData(processedImgData, 0, 0);
displayCtx.putImageData(processedImgData, 0, 0);
// 在显示用的 canvas 上添加测试标记
displayCtx.fillStyle = 'red';
displayCtx.fillRect(10, 10, 50, 50);
// 等待一帧确保所有绘制完成
requestAnimationFrame(() => {
// 验证处理后的图像数据
const testImagePixel = imageCtx.getImageData(15, 15, 1, 1);
console.log('处理后图像像素 (应该是黑白):', testImagePixel.data);
// 验证显示用的测试标记
const testDisplayPixel = displayCtx.getImageData(15, 15, 1, 1);
console.log('显示用 canvas 像素 (应该是红色):', testDisplayPixel.data);
// 返回处理后的图像数据(不包含测试标记)
const finalImgData = imageCtx.getImageData(0, 0, sourceCanvas.width, sourceCanvas.height);
// 生成图片(使用 imageCanvas,不包含测试标记)
const src = imageCanvas.toDataURL('image/png');
ownerInstance.callMethod('onImage', src);
// 返回处理后的数据
ownerInstance.callMethod('canvasData', {
data: processedImgData.data,
width: imageCanvas.width,
height: imageCanvas.height
});
// 可以临时显示测试用的 canvas 来验证
// document.body.appendChild(displayCanvas);
});
});
} catch (error) {
console.error('生成失败:', error)
}
},
/**
* 保存为打印文件
*/
savePrintFile() {
if (!this.printImage) return
const link = document.createElement('a')
link.download = `print-card-${this.cardWidthMm}x${this.cardHeightMm}mm-${this.targetDpi}dpi.png`
link.href = this.printImage
link.click()
},
}
}
</script>
<style scoped lang="scss">
.container {
width: 100%;
height: 100%;
}
.bluetooth-print {
height: 100%;
padding: 20rpx;
display: flex;
flex-direction: column;
box-sizing: border-box;
.section {
display: flex;
flex-direction: column;
flex: 1;
height: 100rpx;
gap: 24rpx;
}
.view-section {
width: 100%;
height: 300rpx;
.viewer {
width: 100%;
height: 100%;
}
.card-content {
position: fixed;
top: 100%;
width: 40mm;
height: 30mm;
font-size: 1mm;
color:#ff0000;
}
}
// 日志区域样式
.log-section {
background: #fff;
border-radius: 12rpx;
border: 1rpx solid #e4e7ed;
overflow: hidden;
margin-top: 16rpx;
flex: 1;
display: flex;
flex-direction: column;
.log-header {
display: flex;
align-items: center;
padding: 24rpx 32rpx;
border-bottom: 1rpx solid #f0f0f0;
background: #f8f9fa;
.log-title {
font-size: 32rpx;
font-weight: 600;
color: #303133;
margin-left: 12rpx;
}
.log-count {
font-size: 24rpx;
color: #909399;
margin-left: 8rpx;
}
.log-actions {
margin-left: auto;
}
}
.log-container {
flex: 1;
height: 400rpx;
.log-list {
padding: 16rpx 24rpx;
}
.log-item {
padding: 20rpx;
margin-bottom: 16rpx;
border-radius: 8rpx;
background: #f8f9fa;
border-left: 4rpx solid;
&.log-success {
border-left-color: #19be6b;
background: linear-gradient(135deg, #f0f9eb 0%, #e8f5e9 100%);
}
&.log-error {
border-left-color: #fa3534;
background: linear-gradient(135deg, #fef0f0 0%, #fde2e2 100%);
}
&.log-warning {
border-left-color: #ff9900;
background: linear-gradient(135deg, #fdf6ec 0%, #fef8e8 100%);
}
&.log-info {
border-left-color: #2979ff;
background: linear-gradient(135deg, #ecf5ff 0%, #e8f3ff 100%);
}
.log-item-header {
display: flex;
align-items: center;
margin-bottom: 12rpx;
.log-type {
font-size: 24rpx;
font-weight: 500;
margin-left: 8rpx;
color: #303133;
}
.log-time {
margin-left: auto;
font-size: 22rpx;
color: #909399;
}
}
.log-message {
font-size: 28rpx;
color: #606266;
line-height: 1.5;
word-break: break-all;
}
.log-details {
margin-top: 8rpx;
padding-top: 8rpx;
border-top: 1rpx dashed #dcdfe6;
.details-label {
font-size: 24rpx;
color: #909399;
font-weight: 500;
}
.details-content {
font-size: 24rpx;
color: #606266;
margin-left: 4rpx;
}
}
}
.log-empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 80rpx 0;
color: #c0c4cc;
.empty-text {
margin-top: 16rpx;
font-size: 28rpx;
color: #909399;
}
}
}
}
.detail-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24rpx 0;
border-bottom: 1rpx solid #f5f5f5;
&.selectable {
cursor: pointer;
&:active {
background-color: #f9f9f9;
}
}
.detail-item-label {
font-size: 32rpx;
color: #333;
font-weight: 500;
}
.detail-item-value {
display: flex;
align-items: center;
gap: 16rpx;
font-size: 28rpx;
color: #666;
max-width: 60%;
text-align: right;
text {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
.action-buttons {
margin-top: auto;
padding-top: 30rpx;
border-top: 1rpx solid #eee;
}
}
.template-selector-popup {
background-color: #fff;
border-radius: 20rpx 20rpx 0 0;
height: 60vh;
.popup-header {
padding: 40rpx 32rpx 24rpx;
border-bottom: 1rpx solid #f0f0f0;
.popup-title {
font-size: 36rpx;
font-weight: bold;
color: #333;
}
}
.template-list {
padding: 24rpx 32rpx;
.template-item {
display: flex;
align-items: center;
padding: 24rpx;
margin-bottom: 16rpx;
border-radius: 16rpx;
border: 2rpx solid #eee;
&:active {
background-color: #f9f9f9;
}
&.selected {
border-color: #2979ff;
background-color: #f0f7ff;
}
.template-info {
flex: 1;
margin-left: 24rpx;
display: flex;
flex-direction: column;
.template-name {
font-size: 32rpx;
color: #333;
font-weight: 500;
margin-bottom: 8rpx;
}
.template-desc {
font-size: 24rpx;
color: #999;
}
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
padding: 80rpx 0;
.empty-text {
margin-top: 24rpx;
font-size: 28rpx;
color: #999;
}
}
}
.popup-actions {
display: flex;
padding: 24rpx 32rpx;
border-top: 1rpx solid #f0f0f0;
gap: 24rpx;
.u-button {
flex: 1;
}
}
}
.bluetoothUnAvailable {
width: 100%;
height: 100%;
}
</style>

View File

@ -0,0 +1,95 @@
<template>
<view>
<!-- 打印面板弹窗 -->
<u-popup
:show="show"
mode="bottom"
closeable
@close="handleClose"
>
<view class="print-panel">
<!-- 标题 -->
<view class="panel-header">
<text class="title">打印选项</text>
</view>
<!-- 内容区域,只保留工作台打印 -->
<view class="panel-content">
<WorkbenchPrint
:printData="printData"
@print="handleWorkbenchPrint"
/>
</view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
name: 'PrintPanel',
props: {
// 控制显示隐藏
show: {
type: Boolean,
default: false
},
// 打印数据,格式: {type, value: {key1, key2}}
printData: {
type: Object,
default: () => ({})
},
// 只能使用打印台
onlyWork: {
type: Boolean,
default: false
}
},
// 移除tab相关,只保留工作台打印
// 移除tab切换和onlyWork监听
methods: {
// 关闭弹窗
handleClose() {
this.$emit('close')
},
// 工作台打印
handleWorkbenchPrint() {
this.$emit('workbench-print')
}
}
}
</script>
<style scoped lang="scss">
.print-panel {
height: 90vh;
display: flex;
flex-direction: column;
.panel-header {
padding: 30rpx;
text-align: center;
border-bottom: 1rpx solid #f5f5f5;
.title {
font-size: 36rpx;
font-weight: bold;
color: #333;
}
}
.panel-content {
flex: 1;
overflow: hidden;
.tab-content {
height: 100%;
}
}
}
</style>

View File

@ -0,0 +1,510 @@
<!-- components/workbench-print.vue -->
<template>
<view class="container">
<view class="workbench-print">
<!-- 内容区域 -->
<scroll-view scroll-y class="scroll-container">
<view class="section">
<!-- 工作台选择 -->
<view class="detail-item selectable" @click="showWorkbenchSelector = true">
<text class="detail-item-label">选择打印台:</text>
<view class="detail-item-value">
<text>{{ selectedWorkbench ? selectedWorkbench.name : "点击选择打印台" }}</text>
<u-icon name="arrow-right" size="24" color="#666"></u-icon>
</view>
</view>
<!-- 打印机选择(工作台选中后出现) -->
<view class="detail-item selectable" v-if="selectedWorkbench" @click="showPrinterSelector = true">
<text class="detail-item-label">打印机:</text>
<view class="detail-item-value">
<text>{{ selectedPrinter ? selectedPrinter.name : "点击选择打印机" }}</text>
<u-icon name="arrow-right" size="24" color="#666"></u-icon>
</view>
</view>
<!-- 打印模板选择 -->
<view class="detail-item selectable" @click="showTemplateSelector = true"
v-if="printData.type != 'express'">
<text class="detail-item-label">打印模板:</text>
<view class="detail-item-value">
<text>{{ selectedTemplate ?
`${selectedTemplate.template_name}【${selectedTemplate.page_width} *
${selectedTemplate.page_height}】` : "点击选择打印模板" }}</text>
<u-icon name="arrow-right" size="24" color="#666"></u-icon>
</view>
</view>
<view v-else></view>
</view>
</scroll-view>
<!-- 操作按钮 -->
<view class="action-buttons">
<u-button type="primary" :disabled="!selectedWorkbench || !selectedTemplate || !selectedPrinter"
@click="handlePrint" :loading="printing">
{{ printing ? '打印中...' : '开始打印' }}
</u-button>
</view>
</view>
<!-- 工作台选择弹窗 -->
<u-popup :show="showWorkbenchSelector" mode="bottom" round="20" @close="showWorkbenchSelector = false">
<view class="workbench-selector-popup">
<view class="popup-header">
<text class="popup-title">选择打印工作台</text>
</view>
<scroll-view scroll-y class="workbench-list" style="height: 40vh;">
<view v-for="workbench in workbenchList" :key="workbench.id" class="workbench-item"
:class="{ selected: selectedWorkbench && selectedWorkbench.id === workbench.id }"
@click="selectWorkbench(workbench)">
<u-icon name="coupon" size="40" color="#2979ff"></u-icon>
<view class="workbench-info">
<text class="workbench-name">{{ workbench.name }}</text>
</view>
<u-icon v-if="selectedWorkbench && selectedWorkbench.id === workbench.id" name="checkbox-mark"
size="28" color="#2979ff"></u-icon>
</view>
<view v-if="workbenchList.length === 0" class="empty-state">
<u-icon name="server-man" size="60" color="#ccc"></u-icon>
<text class="empty-text">暂无可用工作台</text>
</view>
</scroll-view>
<view class="popup-actions">
<u-button type="default" @click="showWorkbenchSelector = false">取消</u-button>
<u-button type="primary" @click="confirmWorkbenchSelection" :disabled="!selectedWorkbench">
确定
</u-button>
</view>
</view>
</u-popup>
<!-- 打印机选择弹窗 -->
<u-popup :show="showPrinterSelector" mode="bottom" round="20" @close="showPrinterSelector = false">
<view class="printer-selector-popup">
<view class="popup-header">
<text class="popup-title">选择打印机</text>
</view>
<scroll-view scroll-y class="printer-list" style="height: 40vh;">
<view v-for="printer in printerList" :key="printer.id" class="printer-item"
:class="{ selected: selectedPrinter && selectedPrinter.name === printer.name }"
@click="selectPrinter(printer)">
<view class="printer-info">
<text class="printer-name">{{ printer.name }}</text>
</view>
<u-icon v-if="selectedPrinter && selectedPrinter.name === printer.name" name="checkbox-mark"
size="28" color="#2979ff"></u-icon>
</view>
<view v-if="printerList.length === 0" class="empty-state">
<u-icon name="printer-man" size="60" color="#ccc"></u-icon>
<text class="empty-text">暂无可用打印机</text>
</view>
</scroll-view>
<view class="popup-actions">
<u-button type="default" @click="showPrinterSelector = false">取消</u-button>
<u-button type="primary" @click="confirmPrinterSelection" :disabled="!selectedPrinter">
确定
</u-button>
</view>
</view>
</u-popup>
<!-- 打印模板选择弹窗 -->
<u-popup :show="showTemplateSelector" mode="bottom" round="20" @close="showTemplateSelector = false">
<view class="template-selector-popup">
<view class="popup-header">
<text class="popup-title">选择打印模板</text>
</view>
<scroll-view scroll-y class="template-list" style="height: 40vh;">
<view v-for="template in templateList" :key="template.id" class="template-item"
:class="{ selected: selectedTemplate && selectedTemplate.id === template.id }"
@click="selectTemplate(template)">
<view class="template-info">
<text class="template-name">{{ template.template_name }}【{{ template.page_width }} * {{
template.page_height }}】</text>
</view>
<u-icon v-if="selectedTemplate && selectedTemplate.id === template.id" name="checkbox-mark"
size="28" color="#2979ff"></u-icon>
</view>
<view v-if="templateList.length === 0" class="empty-state">
<u-icon name="file-text" size="60" color="#ccc"></u-icon>
<text class="empty-text">暂无可用模板</text>
</view>
</scroll-view>
<view class="popup-actions">
<u-button type="default" @click="showTemplateSelector = false">取消</u-button>
<u-button type="primary" @click="confirmTemplateSelection" :disabled="!selectedTemplate">
确定
</u-button>
</view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
name: 'WorkbenchPrint',
props: {
printData: {
type: Object,
default: () => ({})
}
},
data() {
return {
//显示弹窗相关
showWorkbenchSelector: false,
showTemplateSelector: false,
showPrinterSelector: false,
// 工作台相关
workbenchList: [],
selectedWorkbench: null,
// 打印机相关
printerList: [],
selectedPrinter: null,
// 模板相关
templateList: [],
selectedTemplate: null,
// 状态相关
printing: false,
}
},
mounted() {
this.init();
},
methods: {
// 初始化
async init() {
await this.loadWorkbenchList();
await this.loadTemplateList();
},
// 加载工作台列表
async loadWorkbenchList() {
try {
const workbenches = await this.$http('print.getList');
console.log('工作台列表:', workbenches);
if (workbenches.code == "200") {
this.workbenchList = workbenches.data.list || [];
console.log("工作台列表:", this.workbenchList);
} else {
throw new Error(workbenches.message || '加载工作台失败');
}
} catch (error) {
console.error('加载工作台列表失败:', error);
uni.showToast({
title: '加载工作台失败',
icon: 'none'
});
}
},
// 加载模板列表
async loadTemplateList() {
try {
const templates = await this.$http('common.listTemplatesByType', {
businessType: this.printData.type
});
console.log('模板列表:', templates);
if (templates.code == "200") {
this.templateList = templates.data || [];
console.log("模板列表:", this.templateList);
} else {
throw new Error(templates.message || '加载模板失败');
}
} catch (error) {
console.error('加载模板列表失败:', error);
uni.showToast({
title: '加载模板失败',
icon: 'none'
});
}
},
// 选择工作台
// 选择工作台
async selectWorkbench(workbench) {
this.selectedWorkbench = workbench;
},
async selectPrinter(printer) {
this.selectedPrinter = printer;
},
// 加载打印机列表
async loadPrinterList(workbenchId) {
try {
const res = await this.$http("print.getComputerPrinter", {
id: workbenchId
});
this.printerList = res.data || [];
this.printerList.forEach(printer => {
if(this.selectedWorkbench.default_printer && printer.printer_name === this.selectedWorkbench.default_printer){
this.selectedPrinter = printer;
}
});
} catch (error) {
this.printerList = [];
uni.showToast({ title: '加载打印机失败', icon: 'none' });
}
},
// 确认工作台选择
async confirmWorkbenchSelection() {
this.showWorkbenchSelector = false;
// 选择后加载打印机列表
await this.loadPrinterList(this.selectedWorkbench.id);
//检查默认打印机是否在列表中
console.log("选择的工作台:", this.selectedWorkbench);
console.log("打印机列表:", this.printerList);
this.selectedPrinter = null;
if(this.selectedWorkbench.default_printer_name){
const defaultPrinter = this.printerList.find(printer => printer.name === this.selectedWorkbench.default_printer_name);
if(defaultPrinter){
this.selectedPrinter = defaultPrinter;
}
}
},
async confirmPrinterSelection() {
this.showPrinterSelector = false;
},
// 选择模板
selectTemplate(template) {
this.selectedTemplate = template;
},
// 确认模板选择
confirmTemplateSelection() {
this.showTemplateSelector = false;
},
// 处理打印
async handlePrint() {
if (!this.selectedWorkbench) {
uni.showToast({
title: '请选择打印工作台',
icon: 'none'
});
return;
}
if (!this.selectedTemplate) {
uni.showToast({
title: '请选择打印模板',
icon: 'none'
});
return;
}
this.printing = true;
try {
const printInfo = {
type: "customize",
computerId: this.selectedWorkbench.id,
template: this.selectedTemplate,
data: this.printData.value,
printer: this.selectedPrinter.name,
timestamp: Date.now(),
size: 1
};
// 调用打印API
const res = await this.$store.dispatch('print/sendPrint', printInfo);
console.log(res);
if (res.flag == "failure") {
uni.showToast({
title: res.message || '打印失败',
icon: 'failure'
});
} else {
uni.showToast({
title: '打印任务已发送',
icon: 'success'
});
}
// 触发父组件事件
this.$emit('print', printInfo);
} catch (error) {
console.error('打印失败:', error);
uni.showToast({
title: error.message || '打印失败',
icon: 'none'
});
} finally {
this.printing = false;
}
}
}
}
</script>
<style scoped lang="scss">
.container {
width: 100%;
height: 100%;
}
.workbench-print {
height: 100%;
padding: 20rpx;
display: flex;
flex-direction: column;
box-sizing: border-box;
.scroll-container {
flex: 1;
}
.section {
padding-bottom: 40rpx;
}
.detail-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24rpx 0;
border-bottom: 1rpx solid #f5f5f5;
&.selectable {
cursor: pointer;
&:active {
background-color: #f9f9f9;
}
}
.detail-item-label {
font-size: 32rpx;
color: #333;
font-weight: 500;
}
.detail-item-value {
display: flex;
align-items: center;
gap: 16rpx;
font-size: 28rpx;
color: #666;
max-width: 60%;
text-align: right;
text {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
.action-buttons {
margin-top: auto;
padding-top: 30rpx;
border-top: 1rpx solid #eee;
}
}
.printer-selector-popup,
.workbench-selector-popup,
.template-selector-popup {
background-color: #fff;
border-radius: 20rpx 20rpx 0 0;
.popup-header {
padding: 40rpx 32rpx 24rpx;
border-bottom: 1rpx solid #f0f0f0;
.popup-title {
font-size: 36rpx;
font-weight: bold;
color: #333;
}
}
.workbench-list,
.printer-list,
.template-list {
padding: 24rpx 32rpx;
box-sizing: border-box;
.workbench-item,
.printer-item,
.template-item {
display: flex;
align-items: center;
padding: 24rpx;
margin-bottom: 16rpx;
border-radius: 16rpx;
border: 2rpx solid #eee;
&:active {
background-color: #f9f9f9;
}
&.selected {
border-color: #2979ff;
background-color: #f0f7ff;
}
.workbench-info,
.printer-info,
.template-info {
flex: 1;
margin-left: 24rpx;
.workbench-name,
.printer-name,
.template-name {
font-size: 32rpx;
color: #333;
font-weight: 500;
}
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
padding: 80rpx 0;
.empty-text {
margin-top: 24rpx;
font-size: 28rpx;
color: #999;
}
}
}
.popup-actions {
display: flex;
padding: 24rpx 32rpx;
border-top: 1rpx solid #f0f0f0;
gap: 24rpx;
.u-button {
flex: 1;
}
}
}
</style>

View File

@ -0,0 +1,25 @@
<template>
<view class="abc">
<u-button>nihao</u-button>
</view>
</template>
<script>
export default {
name:"demo-com",
options: { styleIsolation: 'shared' },
data() {
return {
};
}
}
</script>
<style lang="scss">
.abc ::v-deep .u-button {
color: red !important;
}
</style>

View File

@ -0,0 +1,227 @@
<template>
<view>
<u-popup :show="show" mode="bottom" :closeable="true" border-radius="20" @close="handleClose">
<view class="title">
{{title}}
<view class="clear-btn" @click="handleClear">清除</view>
</view>
<view class="popup-content">
<!-- 搜索框 -->
<view class="search-box">
<u-input
v-model="searchText"
placeholder="请输入关键词搜索"
clearable
@input="handleSearch"
>
<template #prefix>
<u-icon name="search" size="18" color="#909399"></u-icon>
</template>
</u-input>
</view>
<!-- 底部列表 -->
<scroll-view
class="list-container"
scroll-y="true"
:style="{ height: listHeight + 'rpx' }"
>
<view class="list-item"
v-for="item in filteredList"
:key="item.value"
:class="{ active: selectedValue === item.value }"
@click="handleSelect(item)"
>
<text class="item-text">{{ item.label }}</text>
<u-icon
v-if="selectedValue === item.value"
name="checkbox-mark"
color="#2979ff"
size="20"
></u-icon>
</view>
<u-empty
v-if="filteredList.length === 0"
mode="data"
icon="http://cdn.uviewui.com/uview/empty/data.png"
text="暂无数据"
></u-empty>
</scroll-view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
name:"inputAndSelect",
props: {
show: Boolean,
list: {
type: Array,
default: () => []
},
title:[String],
value: [String, Number],
// 列表高度,单位rpx
listHeight: {
type: Number,
default: 600
}
},
data() {
return {
searchText: '',
selectedValue: null,
filteredList: []
};
},
watch: {
show(newVal) {
if (newVal) {
this.selectedValue = this.value;
this.filteredList = [...this.list];
this.searchText = '';
}
},
list: {
immediate: true,
handler(newVal) {
this.filteredList = [...newVal];
}
},
value(newVal) {
this.selectedValue = newVal;
}
},
methods: {
handleClose() {
this.$emit('close');
},
handleSearch() {
if (!this.searchText.trim()) {
this.filteredList = [...this.list];
return;
}
const searchText = this.searchText.toLowerCase();
this.filteredList = this.list.filter(item =>
item.label && item.label.toLowerCase().includes(searchText)
);
},
handleSelect(item) {
this.selectedValue = item.value;
// 回传选中的值
this.$emit('change', item);
// 关闭弹窗
this.$emit('close');
},
handleClear() {
this.selectedValue = null;
// 回传清除操作,可以传null或空对象
this.$emit('change', null);
// 关闭弹窗
this.$emit('close');
}
}
}
</script>
<style lang="scss" scoped>
.title {
height: 96rpx;
line-height: 96rpx;
text-align: center;
background-color: #FFF;
color: #000;
margin-bottom: 20rpx;
border-bottom: 1px solid rgba(0,0,0,.3);
position: relative;
.clear-btn {
position: absolute;
left: 30rpx;
top: 0;
color: #2979ff;
font-size: 28rpx;
height: 100%;
line-height: 96rpx;
}
}
.popup-content {
padding: 30rpx;
background-color: #fff;
}
.search-box {
margin-bottom: 30rpx;
background-color: #f5f7fa;
border-radius: 10rpx;
padding: 0 20rpx;
}
.quick-filter {
margin-bottom: 20rpx;
white-space: nowrap;
.filter-tags {
display: flex;
flex-wrap: nowrap;
padding: 10rpx 0;
}
.filter-tag {
padding: 12rpx 24rpx;
margin-right: 20rpx;
background-color: #f5f7fa;
border-radius: 50rpx;
font-size: 26rpx;
color: #606266;
flex-shrink: 0;
&.active {
background-color: #ecf5ff;
color: #2979ff;
font-weight: bold;
}
}
}
.list-container {
border-top: 2rpx solid #f0f0f0;
padding-top: 20rpx;
.list-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24rpx 20rpx;
border-bottom: 1rpx solid #f5f5f5;
.item-text {
font-size: 28rpx;
color: #333;
}
&:active {
background-color: #f5f7fa;
}
&.active {
.item-text {
color: #2979ff;
font-weight: bold;
}
}
&:last-child {
border-bottom: none;
}
}
}
</style>

View File

@ -0,0 +1,131 @@
<template>
<view class="nav-wrap">
<view class="status_bar"></view>
<view class="nav-title">
<view class="left" @click="back">
<u-icon v-if="showBack" name="arrow-left"></u-icon>
<u-icon v-else name="home" @click="toHome"></u-icon>
</view>
<view class="title">{{title}}</view>
<view class="right">
<slot name="right"></slot>
</view>
</view>
</view>
</template>
<script>
export default {
props: {
title: String,
},
data() {
return {
showBack: true, // 默认显示返回按钮
pagesLength: 0
}
},
methods: {
checkPagesLength() {
// 获取当前页面栈
const pages = getCurrentPages();
this.pagesLength = pages.length;
this.showBack = pages.length > 1;
console.log('当前页面栈长度:', pages.length, '显示返回按钮:', this.showBack);
},
back() {
console.log("返回");
if (this.showBack) {
// 有上一页,正常返回
uni.navigateBack({
delta: 1,
fail: (err) => {
console.log('返回失败:', err);
// 返回失败时也跳转到首页
this.toHome();
}
});
} else {
// 没有上一页,跳转到首页
this.toHome();
}
},
toHome() {
console.log('跳转到首页');
// 根据你的路由配置调整首页路径
// 假设首页是 tabBar 页面
uni.switchTab({
url: '/pages/index/index', // 替换为你的首页路径
fail: (err) => {
console.error('跳转首页失败:', err);
// 如果 switchTab 失败,尝试 reLaunch
uni.reLaunch({
url: '/pages/index/index'
});
}
});
}
},
created() {
// 组件创建时检查
this.checkPagesLength();
},
mounted() {
// 挂载时再次检查
this.$nextTick(() => {
this.checkPagesLength();
});
}
}
</script>
<style lang="scss" scoped>
.nav-wrap {
position: relative;
}
.nav-title {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
justify-content: flex-start;
height:110rpx;
line-height:110rpx;
background: #FFF;
justify-content: space-between;
padding:0 20rpx;
.left {
width: 80rpx;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
.u-icon {
font-size: 40rpx;
}
}
.title {
flex: 1;
text-align: center;
font-size: 32rpx;
font-weight: bold;
color: #333;
}
.right {
width: 80rpx;
}
}
.status_bar {
height: var(--status-bar-height);
width: 100%;
}
</style>

View File

@ -0,0 +1,227 @@
<template>
<view class="page-indicator">
<!-- 上一页 -->
<view
class="page-btn prev"
:class="{'disabled': pageNum <= 1}"
@click="handlePrev"
>
{{ prevText }}
</view>
<!-- 当前页/总页数 -->
<view class="page-info">
<text>{{ pageNum }}</text>/<text>{{ totalPages }}</text>
</view>
<!-- 下一页 -->
<view
class="page-btn next"
:class="{'disabled': pageNum >= totalPages}"
@click="handleNext"
>
{{ nextText }}
</view>
<!-- 总数显示(可选) -->
<view v-if="showTotal" class="total-info">
总数:{{ total }}
</view>
</view>
</template>
<script>
export default {
name: 'UPagination',
props: {
// 当前页码
pageNum: {
type: Number,
default: 1,
validator: (value) => value > 0
},
// 每页显示数量
pageSize: {
type: Number,
default: 10,
validator: (value) => value > 0
},
// 总数据量
total: {
type: Number,
default: 0,
validator: (value) => value >= 0
},
// 是否显示总数
showTotal: {
type: Boolean,
default: false
},
// 上一页按钮文字
prevText: {
type: String,
default: '上一页'
},
// 下一页按钮文字
nextText: {
type: String,
default: '下一页'
},
// 是否显示第一页/最后一页
showFirstLast: {
type: Boolean,
default: false
},
// 第一页按钮文字
firstText: {
type: String,
default: '首页'
},
// 最后一页按钮文字
lastText: {
type: String,
default: '末页'
},
// 是否禁用分页器
disabled: {
type: Boolean,
default: false
}
},
computed: {
// 计算总页数
totalPages() {
if (this.total <= 0 || this.pageSize <= 0) return 0
return Math.ceil(this.total / this.pageSize)
},
// 是否有上一页
hasPrev() {
return this.pageNum > 1
},
// 是否有下一页
hasNext() {
return this.pageNum < this.totalPages
}
},
methods: {
// 上一页点击事件
handlePrev() {
if (this.disabled || !this.hasPrev) return
const prevPage = this.pageNum - 1
this.$emit('change', prevPage)
this.$emit('update:pageNum', prevPage)
},
// 下一页点击事件
handleNext() {
if (this.disabled || !this.hasNext) return
const nextPage = this.pageNum + 1
this.$emit('change', nextPage)
this.$emit('update:pageNum', nextPage)
},
// 跳转到指定页(供外部调用)
goToPage(page) {
if (this.disabled) return
let targetPage = page
if (page < 1) targetPage = 1
if (page > this.totalPages) targetPage = this.totalPages
this.$emit('change', targetPage)
this.$emit('update:pageNum', targetPage)
},
// 跳转到首页
goToFirst() {
if (this.disabled || this.pageNum === 1) return
this.goToPage(1)
},
// 跳转到末页
goToLast() {
if (this.disabled || this.pageNum === this.totalPages) return
this.goToPage(this.totalPages)
}
}
}
</script>
<style lang="scss" scoped>
.page-indicator {
display: flex;
align-items: center;
justify-content: center;
padding: 20rpx 0;
font-size: 28rpx;
color: #333;
.page-btn {
padding: 0rpx 30rpx;
margin: 0 10rpx;
border: 1rpx solid #dcdfe6;
border-radius: 8rpx;
background-color: #fff;
transition: all 0.3s;
height:60rpx;
line-height: 60rpx;
&:active {
background-color: #f5f7fa;
}
&.disabled {
color: #c0c4cc;
cursor: not-allowed;
border-color: #ebeef5;
background-color: #f5f7fa;
&:active {
background-color: #f5f7fa;
}
}
&.prev {
margin-right: 20rpx;
}
&.next {
margin-left: 20rpx;
}
}
.page-info {
margin: 0 20rpx;
min-width: 80rpx;
text-align: center;
text:first-child {
color: #2979ff;
font-weight: bold;
}
}
.total-info {
margin-left: 40rpx;
color: #909399;
font-size: 24rpx;
}
}
</style>

View File

@ -0,0 +1,286 @@
<template>
<!-- 货位列表弹窗 -->
<u-popup :show="show" mode="bottom" round="20" :closeable="true" :safeAreaInsetBottom="true" @close="handleClose">
<view class="space-list-container">
<!-- 标题 -->
<view class="popup-header">
<text class="popup-title">选择货位</text>
<text class="popup-subtitle">共{{ spaceList.length }}个货位</text>
</view>
<!-- 搜索框 -->
<view class="search-box" v-if="showSearch">
<u-search v-model="searchKeyword" placeholder="搜索货位编码、自定义名称" bg-color="#f5f5f5" shape="round"
:show-action="false" @search="handleSearch" @clear="handleSearch"></u-search>
</view>
<!-- 货位列表 -->
<scroll-view class="space-list-scroll" scroll-y :style="{ height: scrollHeight }">
<!-- 空状态 -->
<u-empty v-if="filteredList.length === 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png"
:text="searchKeyword ? '未找到相关货位' : '暂无货位数据'"></u-empty>
<!-- 货位列表项 -->
<view v-for="(item, index) in filteredList" :key="item.id || index" class="space-item"
:class="{ 'space-item-selected': selectedId === item.id }" @click="handleSelect(item)">
<view class="space-item-left">
<!-- 货位信息 -->
<view class="space-info">
<!-- 货位编码 -->
<view class="space-code">
<text class="code-text">{{ item.space_code }}</text>
</view>
<!-- 自定义名称 -->
<view v-if="item.custom_name" class="custom-name">
<text class="name-text">{{ item.custom_name }}</text>
</view>
<!-- 自定义条码 -->
<view v-if="item.custom_barcode" class="custom-barcode">
<text class="barcode-text">条码:{{ item.custom_barcode }}</text>
</view>
</view>
</view>
<view class="space-item-right">
<!-- 选中标记 -->
<u-icon v-if="selectedId === item.id" name="checkmark-circle-fill" color="#2979ff" size="20"
class="check-icon" />
</view>
</view>
</scroll-view>
<!-- 底部按钮 -->
<view class="popup-footer" v-if="showConfirm">
<u-button type="primary" :disabled="!selectedItem" @click="handleConfirm">
确认选择
</u-button>
</view>
</view>
</u-popup>
</template>
<script>
export default {
name: 'space-list',
props: {
// 货位列表数据
spaceList: {
type: Array,
default: () => []
},
// 是否显示弹窗
show: {
type: Boolean,
default: false
},
// 是否显示搜索框
showSearch: {
type: Boolean,
default: true
},
// 是否显示确认按钮
showConfirm: {
type: Boolean,
default: true
},
// 滚动区域高度(默认500rpx)
scrollHeight: {
type: String,
default: '500rpx'
}
},
data() {
return {
searchKeyword: '',
selectedItem: null,
filteredList: [],
selectedId: null,
};
},
watch: {
spaceList: {
immediate: true,
handler(newVal) {
this.filteredList = [...newVal];
}
},
selectedId: {
immediate: true,
handler(newVal) {
if (newVal) {
this.selectedItem = this.spaceList.find(item => item.id === newVal);
}
}
}
},
methods: {
// 搜索处理
handleSearch() {
const keyword = this.searchKeyword.trim().toLowerCase();
if (!keyword) {
this.filteredList = [...this.spaceList];
return;
}
this.filteredList = this.spaceList.filter(item => {
return (
(item.space_code && item.space_code.toLowerCase().includes(keyword)) ||
(item.custom_name && item.custom_name.toLowerCase().includes(keyword)) ||
(item.custom_barcode && item.custom_barcode.toLowerCase().includes(keyword))
);
});
// 触发搜索事件
this.$emit('searchSpace', this.searchKeyword);
},
// 选择货位项
handleSelect(item) {
this.selectedItem = item;
this.selectedId = item.id;
// 如果不显示确认按钮,直接触发选择事件
if (!this.showConfirm) {
this.$emit('select', item);
this.$emit('close');
}
},
// 确认选择
handleConfirm() {
if (this.selectedItem) {
this.$emit('select', this.selectedItem);
this.handleClose();
}
},
// 关闭弹窗
handleClose() {
this.searchKeyword = '';
this.selectedItem = null;
this.selectedId = null;
this.$emit('close');
}
}
};
</script>
<style lang="scss" scoped>
.space-list-container {
padding: 30rpx;
background-color: #f5f5f5;
.popup-header {
text-align: center;
margin-bottom: 30rpx;
.popup-title {
display: block;
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 10rpx;
}
.popup-subtitle {
font-size: 24rpx;
color: #909399;
}
}
.search-box {
background-color: #fff;
border-radius: 12rpx;
padding: 20rpx 24rpx;
margin-bottom: 24rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
}
.space-list-scroll {
background-color: #fff;
border-radius: 12rpx;
overflow: hidden;
}
.space-item {
display: flex;
align-items: center;
padding: 24rpx;
border-bottom: 1rpx solid #f0f0f0;
position: relative;
&:last-child {
border-bottom: none;
}
&-selected {
background-color: #f0f7ff;
}
&-left {
flex: 1;
margin-right: 20rpx;
}
&-right {
display: flex;
align-items: center;
}
.space-info {
.space-code {
margin-bottom: 8rpx;
.code-text {
font-size: 28rpx;
font-weight: 500;
color: #333;
line-height: 1.4;
}
}
.custom-name {
margin-bottom: 8rpx;
.name-text {
font-size: 26rpx;
color: #666;
line-height: 1.4;
}
}
.custom-barcode {
.barcode-text {
font-size: 24rpx;
color: #909399;
line-height: 1.4;
}
}
}
.check-icon {
margin-left: 10rpx;
}
}
.popup-footer {
margin-top: 30rpx;
::v-deep .u-button {
height: 80rpx;
border-radius: 12rpx;
font-size: 30rpx;
}
}
}
</style>

View File

@ -0,0 +1,405 @@
<template>
<u-upload
ref="uUploadRef"
:fileList="fileList"
:maxCount="maxCount"
:multiple="multiple"
:disabled="disabled"
@afterRead="handleAfterRead"
@delete="handleDelete"
>
</u-upload>
</template>
<script>
export default {
name: "UploadImgCos",
props: {
business_type: {
type: String,
required: true
},
business_id: {
type: Number,
required: true
},
value: {
type: Array,
default: () => []
},
maxCount: {
type: Number,
default: 6
},
multiple: {
type: Boolean,
default: true
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
internalFileList: [],
// 记录正在上传的文件,用于避免重复上传
uploadingFiles: new Set()
};
},
computed: {
fileList: {
get() {
return this.internalFileList;
},
set(value) {
this.internalFileList = value;
}
}
},
watch: {
value: {
immediate: true,
handler(newVal) {
this.formatFileList(newVal);
}
}
},
methods: {
/**
* 格式化文件列表
*/
formatFileList(externalList) {
if (!externalList || !Array.isArray(externalList)) {
this.internalFileList = [];
return;
}
this.internalFileList = externalList.map(item => {
if (item.status) {
return item;
}
return {
url: item.url || item.path || '',
name: item.name || this.extractFileName(item.url) || '',
status: 'success',
message: '',
id: item.id || item.fileId || ''
};
});
},
/**
* 提取文件名
*/
extractFileName(filePath) {
if (!filePath || typeof filePath !== 'string') return null;
return filePath.split(/[\\/]/).pop();
},
/**
* 获取文件MD5
*/
async getFileMd5(filePath) {
return new Promise((resolve, reject) => {
uni.getFileInfo({
filePath,
digestAlgorithm: "md5",
success: resolve,
fail: reject
});
});
},
/**
* 处理文件选择
*/
async handleAfterRead(event) {
if (this.disabled) return;
const { file, name } = event;
const files = Array.isArray(file) ? file : [file];
// 检查数量限制
const remainingSlots = this.maxCount - this.fileList.length;
if (remainingSlots <= 0) {
uni.showToast({
title: `最多只能上传${this.maxCount}个文件`,
icon: 'none'
});
return;
}
const filesToUpload = files.slice(0, remainingSlots);
// 添加文件到列表(初始状态为pending)
const startIndex = this.fileList.length;
filesToUpload.forEach((file) => {
this.fileList.push({
...file,
status: "pending",
message: "等待上传"
});
});
// 串行上传
for (let i = 0; i < filesToUpload.length; i++) {
const fileIndex = startIndex + i;
await this.processFileUpload(filesToUpload[i], fileIndex);
}
},
/**
* 处理单个文件上传流程
*/
async processFileUpload(file, fileIndex) {
try {
// 检查是否已经在上传
const fileKey = `${file.url}_${file.size}`;
if (this.uploadingFiles.has(fileKey)) {
return;
}
this.uploadingFiles.add(fileKey);
// 1. 获取文件MD5
const fileInfo = await this.getFileMd5(file.url);
const fileName = this.extractFileName(file.url) || file.name;
// 2. 更新状态为上传中
this.fileList[fileIndex] = {
...file,
status: "uploading",
message: "上传中",
md5: fileInfo.digest
};
// 3. 获取COS上传配置
const uploadConfig = await this.$http('common.getCOSUploadConfig', {
data: {
fileName,
fileSize: fileInfo.size,
fileType: file.type,
id: this.business_id,
md5: fileInfo.digest,
type: this.business_type,
}
});
const configData = uploadConfig.data;
if (!configData) {
throw new Error("获取上传配置失败");
}
// 4. 执行COS上传(这里不会返回响应数据)
await this.uploadToCOS(file.url, configData, fileIndex);
// 5. 通知后端上传完成
const notifyResult = await this.notifyUploadComplete(configData.fileInfo, fileIndex);
// 6. 更新状态为成功
if (notifyResult.data?.data) {
const { fileUrl, fileId } = notifyResult.data.data;
this.fileList[fileIndex] = {
...this.fileList[fileIndex],
status: "success",
message: "",
url: fileUrl,
id: fileId,
successUrl: fileUrl // 保存成功后的URL
};
// 7. 关联文件
await this.referenceFiles();
// 触发成功事件
this.$emit('upload-success', {
file: this.fileList[fileIndex],
index: fileIndex
});
}
} catch (error) {
console.error("上传流程失败:", error);
this.fileList[fileIndex] = {
...this.fileList[fileIndex],
status: "error",
message: error.message || "上传失败"
};
} finally {
// 清理上传记录
const fileKey = `${file.url}_${file.size}`;
this.uploadingFiles.delete(fileKey);
}
},
/**
* 上传文件到COS(关键修改:不需要处理响应)
*/
uploadToCOS(filePath, config, fileIndex) {
return new Promise((resolve, reject) => {
// COS上传不会返回数据,所以这里只是发起请求
const uploadTask = uni.uploadFile({
url: config.uploadUrl, // 应该从config中获取
filePath: filePath,
name: 'file',
formData: config.data,
// COS上传成功不会有响应体,只会有状态码
success: (res) => {
// 注意:COS返回的HTTP状态码成功通常是204或200,但没有响应体
if (res.statusCode === 200 || res.statusCode === 204) {
resolve();
} else {
reject(new Error(`COS上传失败,状态码: ${res.statusCode}`));
}
},
fail: (error) => {
reject(new Error("COS上传请求失败"));
}
});
// 可以监听上传进度
uploadTask.onProgressUpdate = (res) => {
this.fileList[fileIndex] = {
...this.fileList[fileIndex],
progress: res.progress,
message: `上传中 ${res.progress}%`
};
// 触发进度事件
this.$emit('upload-progress', {
index: fileIndex,
progress: res.progress,
totalBytesSent: res.totalBytesSent,
totalBytesExpectedToSend: res.totalBytesExpectedToSend
});
};
});
},
/**
* 通知后端上传完成
*/
async notifyUploadComplete(config, fileIndex) {
try {
// 调用后端接口,通知COS上传已完成
const response = await this.$http('common.uploadSuccessNotify', {
...config,
fileInfo: {
fileName: config.fileName,
fileSize: config.fileSize,
fileType: config.fileType,
md5: config.md5
}
});
return response;
} catch (error) {
console.error("上传完成通知失败:", error);
throw error;
}
},
/**
* 关联文件
*/
async referenceFiles() {
console.log("this.fileList",this.fileList);
try {
// 获取所有成功的文件(包括之前已经关联的)
const validFiles = this.fileList
.filter(item => item.status === "success" && item.id)
.map(item => ({ file_id: item.id }));
if (validFiles.length === 0) {
// 如果没有成功文件,也要通知后端清空关联
const response = await this.$http('common.ReferenceFile', {
id: this.business_id,
type: this.business_type,
images: []
});
// 更新外部绑定
this.$emit('change', this.fileList);
this.$emit('input', this.fileList);
return response;
}
const response = await this.$http('common.ReferenceFile', {
id: this.business_id,
type: this.business_type,
images: validFiles
});
// 更新外部绑定
this.$emit('change', this.fileList);
this.$emit('input', this.fileList);
return response;
} catch (error) {
console.error("关联文件失败:", error);
throw error;
}
},
/**
* 处理删除 - 修正版本
*/
async handleDelete(index) {
const deletedFile = this.fileList[index];
// 从列表中移除
this.fileList.splice(index, 1);
// 立即更新UI
this.$emit('delete', {
file: deletedFile,
index
});
// 更新外部绑定(立即更新,不等待)
this.$emit('change', this.fileList);
this.$emit('input', this.fileList);
// 异步更新文件关联
try {
await this.referenceFiles();
} catch (error) {
console.error("删除后重新关联失败:", error);
// 这里可以选择给用户提示,但不阻塞UI
}
},
/**
* 手动上传
*/
upload() {
if (this.$refs.uUploadRef && !this.disabled) {
this.$refs.uUploadRef.chooseFile();
}
},
/**
* 获取上传成功的文件
*/
getSuccessFiles() {
return this.fileList.filter(item => item.status === "success");
},
/**
* 清空文件
*/
clearFiles() {
this.fileList = [];
this.$emit('input', []);
this.$emit('change', []);
}
}
};
</script>
<style scoped>
</style>

39
core/index.js Normal file
View File

@ -0,0 +1,39 @@
import {
BASE_URL,
API_URL,
IMG_URL
} from '../env.js';
import http from '@/core/request';
import tools from '@/core/utils/tool';
import mixin from '@/core/mixins';
const install = Vue => {
Vue.prototype.$BASE_URL = BASE_URL;
Vue.prototype.$API_URL = API_URL;
Vue.prototype.$IMG_URL = IMG_URL;
// 挂载请求
Vue.prototype.$http = http;
// 挂载工具函数
Vue.prototype.$tools = tools;
Vue.mixin(mixin);
}
export async function init(options) {
// #ifdef H5
platform.entry();
if(options.query && options.query.appid)
// #endif
// #ifdef MP-WEIXIN
// 检测小程序更新(如果从朋友圈场景进入则无此API)
options.scene !== 1154 && wechat.checkMiniProgramUpdate();
// #endif
await store.dispatch("appInit", options); // 加载商城基本信息
// #ifdef MP-WEIXIN
// #endif
}
export default {
install
}

58
core/mixins/index.js Normal file
View File

@ -0,0 +1,58 @@
/**
* MixinIndex v1.0.0
* @description shopro-mixin-index 1.0.0 shopro全局入口组件
* @Author lidongtony
* @Date 2021-04-18
* @Email lidongtony@qq.com
*/
import store from '@/core/store'
import http from '@/core/request'
import {
router
} from '@/core/router'
export default {
onLoad(options) {
let that = this;
if (options?.page) {
router.replace({
path: decodeURIComponent(options.page)
})
}
if (options?.custom_id) {
router.replace({
path: '/pages/index/view',
query: {
id: options.custom_id
}
})
}
if (options?.spm) {
let shareParams = share.getShareQuery(options.spm);
console.log('shareParams: ',shareParams);
// 保存推荐信息
if (shareParams.shareUserId) {
if (store.getters.isLogin) {
http('common.shareAdd', {
spm: options.spm
});
} else {
uni.setStorageSync('spm', options.spm);
}
}
// 跳转分享路径
let page = {};
if (shareParams.page) {
page.path = shareParams.page;
}
if (shareParams.pageId) {
page.query = {
id: shareParams.pageId
}
}
if (page.path) {
router.replace(page);
}
}
}
}

152
core/request/apis.js Normal file
View File

@ -0,0 +1,152 @@
/**
* 接口列表文件
*/
export default {
/** 公共 ↓ **/
common: {
ping: {
path: "index.ping",
auth: false,
method: "POST",
isSystemApi: true
},
store: {
path: "index.loadStores",
auth: false,
method: "POST",
isSystemApi: true
},
getCOSUploadConfig: {
path: "index.getCOSUploadConfig",
auth: true,
method: "POST",
isSystemApi: true
},
uploadSuccessNotify: {
path: "index.uploadSuccessNotify",
auth: true,
method: "POST",
isSystemApi: true
},
ReferenceFile: {
path: "index.ReferenceFile",
auth: true,
method: "POST",
isSystemApi: true
},
searchSpace: {
path: "index.searchSpace",
auth: true,
method: "POST",
isSystemApi: true
},
listTemplatesByType: {
path: "setting.printTemplate.listTemplatesByType",
auth: true,
method: "POST",
isSystemApi: true
}
},
/** 用户 ↓ **/
user: {
info: {
path: "user.info",
auth: false,
method: "POST",
isSystemApi: true
},
login: {
path: "user.login",
auth: false,
method: "POST",
isSystemApi: true
},
changeRole: {
path: "user.changeRole",
auth: true,
method: "POST",
isSystemApi: true
}
},
storage: {
receiving: {
getReceivingList: {
path: "storage.receiving.getReceivingList",
auth: true,
method: "POST",
isSystemApi: true
},
create: {
path: "storage.receiving.create",
auth: true,
method: "POST",
isSystemApi: true
},
get: {
path: "storage.receiving.get",
auth: true,
method: "POST",
isSystemApi: true
},
addDetail: {
path: "storage.receiving.addDetail",
auth: true,
method: "POST",
isSystemApi: true
},
deleteDetail: {
path: "storage.receiving.deleteDetail",
auth: true,
method: "POST",
isSystemApi: true
},
detailChange: {
path: "storage.receiving.detailChange",
auth: true,
method: "POST",
isSystemApi: true
},
cancel: {
path: "storage.receiving.cancel",
auth: true,
method: "POST",
isSystemApi: true
},
completeReceiving: {
path: "storage.receiving.completeReceiving",
auth: true,
method: "POST",
isSystemApi: true
}
}
},
stock: {
search: {
path: "stock.search",
auth: true,
method: "POST",
isSystemApi: true
}
},
print: {
getList: {
path: "print.getList",
auth: true,
method: "POST",
isSystemApi: true
},
getComputerPrinter: {
path: "print.getComputerPrinter",
auth: true,
method: "POST",
isSystemApi: true
},
send:{
path: "print.send",
auth: true,
method: "POST",
isSystemApi: true
}
}
};

91
core/request/index.js Normal file
View File

@ -0,0 +1,91 @@
import coreRequest from './request'
import apiList from './apis.js'
import store from '@/core/store/index.js'
import { setToken,removeToken } from '../utils/auth';
import router from '@/core/router'
const Request = new coreRequest();
export default function http(
url,
data = {},
toastBefore = '', // 请求前加载提示
toastAfter = true, // 请求后错误提示
responseType = 'text'
) {
let api = getApiPath(url);
console.log(api);
/* 请求之前拦截器 */
Request.interceptor.request((config, cancel) => {
let token = uni.getStorageSync('token');
if (api.auth && !token) {
store.dispatch('logout');
uni.hideLoading()
throw (`暂未登录,已阻止此次API请求: '${api.url}'`);
}
token && Request.setConfig(config => {
config.header.authorization = `Bearer ${token}`
})
if (toastBefore !== '') {
uni.showLoading({
title: toastBefore,
mask: true
});
}
return config
});
/* 请求之后拦截器 */
Request.interceptor.response((res) => {
const headers = res.header;
console.log(res);
const response = res.data;
const token = headers?.authorization || headers?.Authorization // 新的token
if (token) {
const newToken = token.substring(7) // 去掉'Bearer '前缀
setToken(newToken)
}
uni.hideLoading();
if (response?.flag === "failure") {
if (toastAfter) {
uni.showToast({
title: response.message || '请求出错,稍后重试',
icon: 'none',
duration: 1000,
mask: true
});
}
}
// token过期注销
if (res.statusCode === 401) {
removeToken();
uni.showToast({
title: '登录已过期,请重新登录',
icon: 'none',
duration: 1000,
mask: true
});
uni.reLaunch('/pages/login/index')
}
return response
})
return Request.request({
url: api.url,
path: api.path,
data,
method: api.method,
responseType
})
}
// 组装接口路径
function getApiPath(url) {
let apiArray = url.split(".");
let api = apiList;
apiArray.forEach(v => {
api = api[v];
});
return api;
}

141
core/request/request.js Normal file
View File

@ -0,0 +1,141 @@
/**
* Request:请求封装
* @property {Object} config = 私有属性,默认值
* @property {Function} isUrl = 私有方法,url是否完整
* @property {Function} requestBefore = 私有方法,请求前
* @property {Function} requestAfter = 私有方法,请求后
*/
import {
API_URL
} from '@/env'
export default class Request {
constructor() {
// 默认配置
this.config = {
baseUrl: API_URL,
header: {
'content-type': 'application/json',
'platform': 'pda',
'project':'warehouse'
},
url: '',
data: {},
path:'',
params: {},
method: 'GET',
dataType: 'json',
// #ifndef MP-ALIPAY || APP-PLUS
responseType: 'text',
// #endif
custom: {},
// #ifdef APP-PLUS
sslVerify: false
// #endif
}
/* 拦截器 */
this.interceptor = {
request: cb => {
if (cb) {
this.requestBefore = cb
} else {
this.requestBefore = request => request
}
},
response: (cb) => {
if (cb) {
this.requestAfter = cb
} else {
this.requestAfter = response => response
}
}
}
}
/* 判断url是否完整 */
static isUrl(url) {
return /(http|https):\/\/([\w.]+\/?)\S*/.test(url)
}
static addQueryString(params) {
let paramsData = ''
Object.keys(params).forEach(key => {
paramsData += key + '=' + encodeURIComponent(params[key]) + '&'
})
return paramsData.substring(0, paramsData.length - 1)
}
/* 请求前 */
static requestBefore(config) {
return config
}
/* 请求后 */
static requestAfter(response) {
return response
}
/*设置全局配置*/
setConfig(func) {
return func(this.config)
}
/**
* @Function
* @param {Object} options - 请求配置项
* @prop {String} options.url - 请求路径
* @prop {Object} options.data - 请求参数
* @prop {Object} [options.responseType = config.responseType] [text|arraybuffer] - 响应的数据类型
* @prop {Object} [options.dataType = config.dataType] - 如果设为 json,会尝试对返回的数据做一次 JSON.parse
* @prop {Object} [options.header = config.header] - 请求header
* @prop {Object} [options.method = config.method] - 请求方法
* @returns {Promise<unknown>}
*/
async request(options = {}) {
options = {
...options,
...this.config,
...this.requestBefore(options)
}
return new Promise((resolve, reject) => {
let mergeUrl = Request.isUrl(options.url) ? options.url : (options.baseUrl + options.url);
let mergePath = options.path ? options.path : '';
console.log(options,mergePath,options.baseUrl);
if(mergePath){
const timestamp = Math.round(new Date() / 1000);
mergeUrl = `${options.baseUrl}?method=${mergePath}&v=1.0&timestamp=${timestamp}`
}
console.log(mergeUrl);
if (JSON.stringify(options.params) !== '{}') {
let query = Request.addQueryString(options.params);
mergeUrl += mergeUrl.indexOf('?') === -1 ? `?${query}` : `&${query}`
}
options.url = mergeUrl
options.success = res => {
resolve(this.requestAfter(res))
}
options.fail = err => {
reject(this.requestAfter(err))
}
uni.request(options)
})
}
get(url, options = {}) {
return this.request({
url,
method: 'GET',
...options
})
}
post(url, data, options = {}) {
return this.request({
url,
data,
method: 'POST',
...options
})
}
}

129
core/router/index.js Normal file
View File

@ -0,0 +1,129 @@
// 路由
import {
RouterMount,
createRouter
} from './uni-simple-router.js'
import store from '@/core/store'
import {
getToken,
removeToken
} from '@/core/utils/auth'
const router = createRouter({
platform: process.env.VUE_APP_PLATFORM,
applet: {
animationDuration: 0 //默认 300ms
},
routerErrorEach: ({
type,
msg
}) => {
switch (type) {
case 3: // APP退出应用
case 2:
// #ifdef APP-PLUS
router.$lockStatus = false;
uni.showModal({
title: '提示',
content: '您确定要退出应用吗?',
success: function(res) {
if (res.confirm) {
plus.runtime.quit();
}
}
});
// #endif
break;
case 0:
router.$lockStatus = false;
break;
default:
break;
}
//console.log("异常路由",type);
},
// 通配符,非定义页面,跳转404
routes: [...ROUTES,
{
path: '*',
redirect: (to) => {
return {
path: '/pages/404'
}
}
},
]
});
//全局路由前置守卫
router.beforeEach(async (to, from, next) => {
const hasToken = getToken();
if (hasToken) {
console.log("去哪里",to);
if (to.path === '/pages/login/index') {
// 已登录时访问登录页,重定向到首页
next({
path: '/pages/index/index',
replace: true
});
} else {
const hasGetUserInfo = store.getters.user.employees_name;
console.log("有没有用户信息",hasGetUserInfo);
if (hasGetUserInfo) {
const isVisible =await store.dispatch('floatWindowManager/is_visible');
if(to.meta && to.meta.auth){
console.log(to.path);
const hasPermiss =await store.dispatch('checkPath',to.path);
if(!hasPermiss){
next({path:"/pages/403"})
return;
}
}
if(to.path==from.path){
next(false);
}else{
next();
}
} else {
console.log("没有用户信息");
await store.dispatch('getUserInfo');
console.log("获取完成,去哪里",to)
try {
await store.dispatch('floatWindowManager/is_visible');
// 关键修改:等待获取用户信息
if (to.path === '/pages/index/index'){
next();
}else{
next({
path: to.fullPath,
NAVTYPE: 'SwitchTab'
})
}
} catch (error) {
await store.dispatch('logout');
}
}
}
} else {
// 没有Token的情况
if (to.path === '/pages/login/index') {
next();
} else {
uni.hideTabBar();
next({
path: '/pages/login/index',
query: {
redirect: to.fullPath || to.path
},
replace:true
});
}
}
});
export {
router,
RouterMount
}

File diff suppressed because one or more lines are too long

23
core/store/index.js Normal file
View File

@ -0,0 +1,23 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
import user from './modules/user.js'
import setting from './modules/setting.js'
import broadcast from './modules/broadcast.js'
import floatWindowManager from './modules/floatWindowManager.js'
import bluetoothPrint from './modules/bluetoothPrint.js'
import print from './modules/print.js'
const store = new Vuex.Store({
modules: {
user,
setting,
broadcast,
floatWindowManager,
bluetoothPrint,
print
}
})
export default store

View File

@ -0,0 +1,873 @@
// store/modules/bluetoothPrint.js
import tscEncoder from '@/core/utils/tsc.js'; // 导入你的TSC指令生成器
import http from '@/core/request/index'
const state = () => ({
bluetoothAvailable: false,
// 设备状态
bluetoothDevices: [],
currentDevice: null,
connectionStatus: 'disconnected', // disconnected/scanning/connecting/connected/error
deviceServices: [],
template: null,
discovering: false,
// TSC打印机状态
printer: null, // TSC打印机实例
printerConfig: {
dpi: 203, // 打印机DPI: 203/300
width: 40, // 标签宽度(mm)
height: 30, // 标签高度(mm)
gap: 2, // 标签间隙(mm)
direction: 0, // 打印方向
reference: [0, 0], // 参考坐标原点
density: 8, // 打印浓度 1-15
speed: 3, // 打印速度 1-6
},
// 打印控制
isPrinting: false,
printQueue: [],
printHistory: [],
// 连接管理
autoReconnect: true,
reconnectAttempts: 0,
maxReconnectAttempts: 3,
// 错误与日志
lastError: null,
operationLogs: []
});
const getters = {
// 连接状态
isConnected: state => state.connectionStatus === 'connected',
isReadyToPrint: state => state.connectionStatus === 'connected' && !state.isPrinting,
// 设备信息
connectedDeviceInfo: state => ({
name: state.currentDevice?.name || '未连接',
id: state.currentDevice?.id ? state.currentDevice.id.substring(0, 8) + '...' : '',
status: state.connectionStatus
}),
// 打印机配置
printerDPI: state => state.printerConfig.dpi,
mmToDot: (state, getters) => (mm) => {
// 根据DPI将毫米转换为点数
return Math.floor(mm * (getters.printerDPI / 25.4));
},
// 队列状态
queueLength: state => state.printQueue.length,
hasPendingTasks: state => state.printQueue.length > 0
};
const mutations = {
// 设备管理
SET_DEVICES(state, devices) {
state.bluetoothDevices = devices;
},
ADD_DEVICE(state, device) {
if (!state.bluetoothDevices.some(d => d.deviceId === device.deviceId)) {
state.bluetoothDevices.push({
...device,
isTSCPrinter: device.name && (
device.name.includes('TSC') ||
device.name.includes('打印机') ||
device.name.includes('PRT')
)
});
}
},
SET_CURRENT_DEVICE(state, device) {
state.currentDevice = device;
},
SET_CONNECTION_STATUS(state, status) {
state.connectionStatus = status;
},
// 打印机实例
INIT_PRINTER_INSTANCE(state) {
if (!state.printer) {
state.printer = tscEncoder.jpPrinter.createNew();
}
},
UPDATE_PRINTER_CONFIG(state, config) {
state.printerConfig = {
...state.printerConfig,
...config
};
},
// 打印状态
SET_PRINTING(state, printing) {
state.isPrinting = printing;
},
// 队列管理
ADD_TO_QUEUE(state, task) {
const taskWithId = {
...task,
id: Math.random(),
createdAt: new Date().toISOString(),
status: 'pending'
};
state.printQueue.push(taskWithId);
},
REMOVE_FROM_QUEUE(state, taskId) {
state.printQueue = state.printQueue.filter(task => task.id !== taskId);
},
UPDATE_TASK_STATUS(state, {
taskId,
status
}) {
const task = state.printQueue.find(t => t.id === taskId);
if (task) task.status = status;
},
// 历史记录
ADD_TO_HISTORY(state, task) {
state.printHistory.unshift({
...task,
printedAt: new Date().toISOString()
});
// 保持最多50条历史记录
if (state.printHistory.length > 50) {
state.printHistory.pop();
}
},
// 重连管理
SET_RECONNECT_ATTEMPTS(state, attempts) {
state.reconnectAttempts = attempts;
},
// 错误与日志
SET_ERROR(state, error) {
state.lastError = error;
if (error) {
state.operationLogs.unshift({
type: 'error',
message: error.message || error.errMsg || String(error),
timestamp: new Date().toISOString()
});
}
},
ADD_LOG(state, log) {
state.operationLogs.unshift({
...log,
timestamp: new Date().toISOString()
});
if (state.operationLogs.length > 100) {
state.operationLogs.pop();
}
},
// 重置状态
RESET_SCAN(state) {
state.bluetoothDevices = [];
},
RESET_CONNECTION(state) {
state.currentDevice = null;
state.connectionStatus = 'disconnected';
state.deviceServices = [];
state.reconnectAttempts = 0;
},
CLEAR_QUEUE(state) {
state.printQueue = [];
},
AVAILABLE(state, status) {
state.bluetoothAvailable = status
},
DISCOVERING(state, status) {
state.discovering = status
}
};
const actions = {
/**
* 初始化蓝牙适配器
*/
async initializeBluetooth({
commit,
dispatch,
state
}) {
try {
const [fail] = await uni.openBluetoothAdapter();
if (fail) {
commit('AVAILABLE', false);
} else {
commit('AVAILABLE', true);
}
uni.onBluetoothAdapterStateChange(function(res) {
commit('AVAILABLE', res.available);
commit('DISCOVERING', res.discovering);
})
uni.onBluetoothDeviceFound(async function(devices) {
console.log("新设备加入列表");
commit('ADD_DEVICE', devices.devices[0]);
})
uni.onBLEConnectionStateChange(async function(res) {
})
} catch (error) {
commit('AVAILABLE', false);
}
},
async getPrintTemplate({
commit,
state
}, businessType) {
return new Promise((resolve, reject) => {
http('common.listTemplatesByType', {
businessType: businessType
}).then(res => {
console.log(res);
resolve(res);
}).then(() => {
})
.catch(e => {
reject(e)
})
})
},
/**
* 开启或关闭搜索
*/
async scanDevices({
commit,
state
}, status) {
if (status) {
commit('RESET_SCAN');
await uni.startBluetoothDevicesDiscovery();
} else {
await uni.stopBluetoothDevicesDiscovery();
}
},
/**
* 连接TSC打印机
*/
async connectDevice({
commit,
state,
dispatch
}, device) {
commit('SET_CONNECTION_STATUS', 'connecting');
commit('ADD_LOG', {
type: 'info',
message: `正在连接: ${device.name}`
});
console.log(`正在连接: ${device.name}`);
try {
// 1. 创建BLE连接
const connection = await uni.createBLEConnection({
deviceId: device.deviceId,
timeout: 10000
});
console.log('连接建立:', connection);
// 2. 获取服务
const [error, servicesRes] = await uni.getBLEDeviceServices({
deviceId: device.deviceId
});
if (error || !servicesRes || !servicesRes.services || servicesRes.services.length === 0) {
throw new Error('未发现设备服务');
}
console.log('发现服务:', servicesRes.services);
// 3. 查找TSC打印机服务(参考代码使用 49535343)
// TSC蓝牙打印机通常使用特定的服务UUID,如:
// 49535343-FE7D-4AE5-8FA9-9FAFD205E455 或其他类似的
let targetService = null;
// 首先尝试查找包含特定标识的服务
for (const service of servicesRes.services) {
// 方法1: 检查是否包含TSC打印机特征标识
if (service.uuid.includes('49535343')) {
targetService = service;
console.log('找到TSC服务 (49535343):', service);
break;
}
// 方法2: 检查是否为通用打印服务
if (service.uuid.toLowerCase().includes('fff0') ||
service.uuid.toLowerCase().includes('ae30')) {
targetService = service;
console.log('找到通用打印服务:', service);
}
}
// 如果没有找到特定服务,使用第一个服务
if (!targetService && servicesRes.services.length > 0) {
targetService = servicesRes.services[0];
console.log('使用第一个服务:', targetService);
}
if (!targetService) {
throw new Error('未找到可用的打印机服务');
}
// 4. 获取该服务的特征值
const [charError, characteristicsRes] = await uni.getBLEDeviceCharacteristics({
deviceId: device.deviceId,
serviceId: targetService.uuid
});
if (charError || !characteristicsRes || !characteristicsRes.characteristics) {
throw new Error('未发现特征值');
}
console.log('发现特征值:', characteristicsRes.characteristics);
// 5. 查找读写特征
let writeChar = null;
let notifyChar = null;
let readChar = null;
for (const char of characteristicsRes.characteristics) {
console.log(`特征值 ${char.uuid}:`, char.properties);
// 查找写入特征(有write属性)
if (char.properties.write || char.properties.writeWithoutResponse) {
if (!writeChar) {
writeChar = char;
}
// 优先选择 writeWithoutResponse
if (char.properties.writeWithoutResponse) {
writeChar = char;
}
}
// 查找通知特征
if (char.properties.notify || char.properties.indicate) {
if (!notifyChar) {
notifyChar = char;
}
}
// 查找读取特征
if (char.properties.read) {
if (!readChar) {
readChar = char;
}
}
}
if (!writeChar) {
throw new Error('未找到可写的特征值');
}
console.log('选择写入特征:', writeChar);
console.log('选择通知特征:', notifyChar);
// 6. 如果需要,开启通知
if (notifyChar) {
try {
await uni.notifyBLECharacteristicValueChange({
deviceId: device.deviceId,
serviceId: targetService.uuid,
characteristicId: notifyChar.uuid,
state: true
});
console.log('已开启通知');
} catch (notifyError) {
console.warn('无法开启通知:', notifyError);
}
}
// 7. 保存设备信息
commit('SET_CURRENT_DEVICE', {
id: device.deviceId,
name: device.name || '未知设备',
serviceId: targetService.uuid,
characteristicId: writeChar.uuid,
notifyId: notifyChar ? notifyChar.uuid : null,
readId: readChar ? readChar.uuid : null,
writeType: writeChar.properties.writeWithoutResponse ? 'writeWithoutResponse' : 'write',
properties: writeChar.properties
});
commit('SET_CONNECTION_STATUS', 'connected');
commit('ADD_LOG', {
type: 'success',
message: `连接成功: ${device.name || device.deviceId}`
});
// 8. 监听连接状态变化
uni.onBLEConnectionStateChange((changeRes) => {
console.log('连接状态变化:', changeRes);
if (!changeRes.connected && state.currentDevice?.id === changeRes.deviceId) {
commit('ADD_LOG', {
type: 'warning',
message: '蓝牙连接已断开'
});
commit('SET_CONNECTION_STATUS', 'disconnected');
if (state.autoReconnect && state.reconnectAttempts < state.maxReconnectAttempts) {
dispatch('attemptReconnect');
}
}
});
// 9. 监听特征值变化(如果有通知)
if (notifyChar) {
uni.onBLECharacteristicValueChange((res) => {
console.log('收到特征值变化:', res);
// 这里可以处理打印机返回的数据
});
}
return true;
} catch (error) {
console.error('连接失败:', error);
commit('SET_CONNECTION_STATUS', 'error');
commit('SET_ERROR', error);
commit('ADD_LOG', {
type: 'error',
message: `连接失败: ${error.message || error.errMsg || '未知错误'}`
});
return false;
}
},
/**
* 发送打印数据到TSC打印机
*/
async sendPrintData({
commit,
state,
dispatch
}, printTask) {
if (state.connectionStatus !== 'connected') {
throw new Error('打印机未连接');
}
if (state.isPrinting) {
// 加入队列等待
commit('ADD_TO_QUEUE', printTask);
return {
queued: true,
taskId: state.printQueue[state.printQueue.length - 1].id
};
}
commit('INIT_PRINTER_INSTANCE');
commit('SET_PRINTING', true);
const taskId = printTask.id || Math.random();
try {
commit('ADD_LOG', {
type: 'info',
message: `开始打印任务: ${printTask.title || '未命名'}`
});
// 1. 准备TSC指令
const printer = state.printer;
printer.clear(); // 清空缓冲区
if (printTask.size) {
commit('ADD_LOG', {
type: 'info',
message: `重设大小${printTask.size.width} * ${printTask.size.height}`
});
console.log(`重设大小${printTask.size.width} * ${printTask.size.height}`);
printer.setSize(printTask.size.width,printTask.size.height);
}
console.log("printTask",printTask);
printer.setBitmap(0, 0, 0, printTask);
commit('ADD_LOG', {
type: 'info',
message: `生成打印任务内容: ${printTask.title || '未命名'}`
});
// 3. 添加打印指令
printer.setPrint(printTask.copies || 1);
// 4. 获取二进制数据
const commandData = printer.getData();
// 5. 分片发送(BLE限制)
const chunkSize = 20; // BLE MTU通常为20字节
const chunks = [];
// 确保 commandData 是 Uint8Array 或 ArrayBuffer
let dataArray;
if (typeof commandData === 'string') {
// 如果是字符串,转换为 Uint8Array
const encoder = new TextEncoder();
dataArray = encoder.encode(commandData);
} else if (commandData instanceof ArrayBuffer) {
dataArray = new Uint8Array(commandData);
} else if (commandData instanceof Uint8Array) {
dataArray = commandData;
} else {
// 尝试其他类型转换
dataArray = new Uint8Array(commandData);
}
for (let i = 0; i < dataArray.length; i += chunkSize) {
const chunk = dataArray.slice(i, Math.min(i + chunkSize, dataArray.length));
chunks.push(chunk);
}
// 6. 发送数据
for (let i = 0; i < chunks.length; i++) {
const chunk = chunks[i];
await uni.writeBLECharacteristicValue({
deviceId: state.currentDevice.id,
serviceId: state.currentDevice.serviceId,
characteristicId: state.currentDevice.characteristicId,
value: chunk.buffer, // 直接传递 ArrayBuffer
writeType: state.currentDevice.writeType
});
// 添加延迟,避免发送过快
if (i < chunks.length - 1) {
await delay(20);
}
}
// 7. 记录成功
commit('ADD_TO_HISTORY', {
...printTask,
id: taskId,
success: true
});
commit('ADD_LOG', {
type: 'success',
message: `打印完成: ${printTask.title || '任务'}`
});
return {
success: true,
taskId
};
} catch (error) {
commit('SET_ERROR', error);
commit('ADD_LOG', {
type: 'error',
message: `打印失败: ${error.errMsg || error.message}`
});
// 记录失败历史
commit('ADD_TO_HISTORY', {
...printTask,
id: taskId,
success: false,
error: error.message
});
throw error;
} finally {
commit('SET_PRINTING', false);
// 检查并处理下一个队列任务
if (state.printQueue.length > 0) {
const nextTask = state.printQueue[0];
commit('REMOVE_FROM_QUEUE', nextTask.id);
setTimeout(() => {
dispatch('sendPrintData', nextTask);
}, 500);
}
}
},
/**
* 生成标签内容
*/
async generateLabelContent({
getters,
commit,
state
}, {
printer,
data,
size
}) {
printer.setCls();
commit('ADD_LOG', {
type: 'info',
message: `开始生成标签`
});
const mmToDot = getters.mmToDot;
// 设置标签尺寸
printer.setSize(size.width, size.height);
commit('ADD_LOG', {
type: 'info',
message: `设置标签大小完成${size.width}, ${size.height}`
});
// 添加文本
if (data.texts) {
data.texts.forEach(text => {
printer.setText(
mmToDot(text.x || 10),
mmToDot(text.y || 10),
text.font || 'TSS24.BF2',
text.rotation || 0,
text.xScale || 1,
text.yScale || 1,
text.content
);
});
}
// 添加条形码
if (data.barcodes) {
data.barcodes.forEach(barcode => {
printer.setBarCode(
mmToDot(barcode.x || 10),
mmToDot(barcode.y || 40),
barcode.type || '128',
mmToDot(barcode.height || 20),
barcode.readable ? 1 : 0,
barcode.rotation || 0,
barcode.narrow || 2,
barcode.wide || 4,
barcode.content
);
});
}
// 添加二维码
if (data.qrcodes) {
data.qrcodes.forEach(qrcode => {
printer.setQrcode(
mmToDot(qrcode.x || 10),
mmToDot(qrcode.y || 70),
qrcode.level || 'M',
qrcode.width || 4,
qrcode.mode || 'A',
qrcode.rotation || 0,
qrcode.model || "M1",
qrcode.mask || "S7",
qrcode.content
);
});
}
// 添加线条
if (data.bars) {
data.bars.forEach(bar => {
printer.setBar(
mmToDot(bar.x || 10),
mmToDot(bar.y || 10),
mmToDot(bar.width || 50),
mmToDot(bar.height || 2)
);
});
}
// 添加方框
if (data.boxes) {
data.boxes.forEach(box => {
printer.setBox(
mmToDot(box.x1 || 10),
mmToDot(box.y1 || 10),
mmToDot(box.x2 || 60),
mmToDot(box.y2 || 40),
mmToDot(box.thickness || 1)
);
});
}
commit('ADD_LOG', {
type: 'info',
message: `开始生成标签完成`
});
},
/**
* 打印商品标签(示例)
*/
async printProductLabel({
dispatch
}, productData) {
const task = {
type: 'label',
title: `商品标签-${productData.code}`,
copies: productData.copies || 1,
size: {
width: 70,
height: 20
},
data: {
texts: [{
x: 25,
y: 2,
font: 'TSS24.BF2',
content: productData.name,
rotation: 0
},
{
x: 25,
y: 5,
font: 'TSS24.BF2',
content: `型号:${productData.model}`,
rotation: 0
},
{
x: 25,
y: 8,
font: 'TSS24.BF2',
content: `价格¥${productData.price}`,
xScale: 2,
yScale: 2,
rotation: 0
},
],
qrcodes: [{
x: 2,
y: 2,
width: 7,
content: productData.code,
readable: true,
}],
}
};
return dispatch('sendPrintData', task);
},
/**
* 打印canvas
*/
async printCanvas({
dispatch
}, canvasData) {
return dispatch('sendPrintData', canvasData);
console.log("canvasData",canvasData);
},
/**
* 断开连接
*/
async disconnectDevice({
commit,
state
}) {
if (!state.currentDevice) return;
try {
await uni.closeBLEConnection({
deviceId: state.currentDevice.id
});
commit('RESET_CONNECTION');
commit('ADD_LOG', {
type: 'info',
message: '已断开连接'
});
return true;
} catch (error) {
commit('SET_ERROR', error);
return false;
}
},
/**
* 尝试重连
*/
async attemptReconnect({
commit,
state,
dispatch
}) {
if (!state.autoReconnect ||
!state.currentDevice ||
state.reconnectAttempts >= state.maxReconnectAttempts) {
return;
}
commit('SET_RECONNECT_ATTEMPTS', state.reconnectAttempts + 1);
commit('ADD_LOG', {
type: 'info',
message: `重连尝试 (${state.reconnectAttempts}/${state.maxReconnectAttempts})`
});
setTimeout(async () => {
const success = await dispatch('connectDevice', state.currentDevice);
if (!success) {
dispatch('attemptReconnect');
} else {
commit('SET_RECONNECT_ATTEMPTS', 0);
}
}, 2000);
},
/**
* 清空打印队列
*/
clearPrintQueue({
commit
}) {
commit('CLEAR_QUEUE');
commit('ADD_LOG', {
type: 'info',
message: '打印队列已清空'
});
},
/**
* 重置模块状态
*/
resetModule({
commit
}) {
commit('RESET_CONNECTION');
commit('RESET_SCAN');
commit('CLEAR_QUEUE');
commit('SET_PRINTING', false);
commit('SET_ERROR', null);
commit('SET_RECONNECT_ATTEMPTS', 0);
commit('ADD_LOG', {
type: 'info',
message: '模块状态已重置'
});
}
};
// 工具函数
function arrayBufferToBase64(buffer) {
let binary = '';
const bytes = new Uint8Array(buffer);
for (let i = 0; i < bytes.length; i++) {
binary += String.fromCharCode(bytes[i]);
}
return uni.arrayBufferToBase64 ?
uni.arrayBufferToBase64(binary) :
btoa(binary);
}
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export default {
namespaced: true,
state,
getters,
mutations,
actions
};

View File

@ -0,0 +1,308 @@
import BroadcastManager from "@/core/utils/broadcast.js";
// 创建单例实例
const scanner = new BroadcastManager();
// 默认回调(只用于日志)
const defaultCallbacks = {
onResult: (result) => {
console.log('[Broadcast] 收到数据:', result.data);
}
};
// 全局回调存储器
let cachedCallbacks = {
...defaultCallbacks
};
const actions = {
/**
* 初始化广播模块(只读取配置,不自动注册)
*/
async init({
commit,
rootGetters
}) {
try {
commit('setLoading', true);
// 获取配置
const broadcastSetting = rootGetters['setting/broadcastSettings'];
// 检查是否开启广播
const allSettings = rootGetters['setting/allSettings'] || {};
const broadcastEnabled = allSettings['broadcast.enabled'] !== 'false';
if (!broadcastEnabled) {
console.log('[Broadcast] 广播功能已禁用,跳过初始化');
commit('setEnabled', false);
commit('setInitialized', true);
return false;
}
if (!broadcastSetting || !broadcastSetting.action) {
throw new Error('缺少广播配置');
}
// 构建配置
const scanConfig = {
broadcastAction: broadcastSetting.action,
dataKey: broadcastSetting.key || 'value'
};
// 只使用默认回调,不合并广播配置中的回调
// 广播配置中的callbacks字段应该用于其他用途,不是给广播模块用的
const success = scanner.setConfig(scanConfig, defaultCallbacks);
if (success) {
commit('setEnabled', true);
commit('setInitialized', true);
commit('setConfig', scanConfig);
// 不再保存回调到state,回调是独立的
}
return success;
} catch (error) {
console.error('[Broadcast] 初始化失败:', error);
commit('setEnabled', false);
commit('setError', error.message);
return false;
} finally {
commit('setLoading', false);
}
},
/**
* 开始监听(外部调用,使用缓存的回调)
*/
start({
commit,
state
}) {
if (!state.initialized) {
console.error('[Broadcast] 请先初始化模块');
return false;
}
if (!state.enabled) {
console.warn('[Broadcast] 广播功能已禁用');
return false;
}
// 确保使用最新的缓存回调
if (state.config) {
scanner.setConfig(state.config, cachedCallbacks);
}
const success = scanner.start();
if (success) {
commit('setActive', true);
}
return success;
},
/**
* 停止监听
*/
stop({
commit,
state
}) {
if (!state.enabled) {
return true;
}
const success = scanner.stop();
if (success) {
commit('setActive', false);
}
return success;
},
/**
* 暂停监听
*/
pause({
commit
}) {
return actions.stop({
commit
});
},
/**
* 恢复监听
*/
resume({
commit,
state
}) {
return actions.start({
commit,
state
});
},
/**
* 更新配置
*/
setConfig({
commit,
state
}, config) {
if (!config || !config.broadcastAction) {
throw new Error('配置必须包含broadcastAction');
}
if (!state.enabled) {
console.warn('[Broadcast] 广播功能已禁用,配置更新无效');
return false;
}
// 使用缓存的回调函数
const success = scanner.setConfig(config, cachedCallbacks);
if (success) {
commit('setConfig', config);
commit('setActive', false); // 配置更新后需要重新启动
}
return success;
},
/**
* 设置回调函数(独立存储,不立即生效)
*/
setCallbacks({
commit
}, callbacks) {
// 更新全局缓存回调
cachedCallbacks = {
...defaultCallbacks,
...cachedCallbacks,
...callbacks
};
console.log('[Broadcast] 回调函数已缓存,将在下次启动时生效');
return true;
},
/**
* 更新Action
*/
setAction({
commit,
state
}, action) {
if (!action) {
throw new Error('Action不能为空');
}
if (!state.enabled) {
console.warn('[Broadcast] 广播功能已禁用,Action更新无效');
return false;
}
const newConfig = {
...state.config,
broadcastAction: action
};
return actions.setConfig({
commit,
state
}, newConfig);
},
/**
* 获取状态
*/
getStatus({
state
}) {
const scannerStatus = scanner.getStatus();
return {
...scannerStatus,
moduleEnabled: state.enabled,
moduleInitialized: state.initialized,
moduleActive: state.active
};
},
/**
* 重置模块
*/
reset({
commit
}) {
scanner.destroy();
// 重置缓存回调
cachedCallbacks = {
...defaultCallbacks
};
commit('resetState');
},
/**
* 获取当前缓存回调
*/
getCurrentCallbacks() {
return {
...cachedCallbacks
};
}
};
const mutations = {
setLoading(state, isLoading) {
state.loading = isLoading;
},
setInitialized(state, initialized) {
state.initialized = initialized;
},
setEnabled(state, enabled) {
state.enabled = enabled;
},
setActive(state, active) {
state.active = active;
},
setConfig(state, config) {
state.config = config;
},
setError(state, error) {
state.error = error;
},
resetState(state) {
state.initialized = false;
state.enabled = false;
state.active = false;
state.loading = false;
state.config = null;
state.error = null;
}
};
const state = () => ({
initialized: false,
enabled: false, // 广播是否启用(根据配置)
active: false, // 是否正在监听
loading: false,
config: null,
error: null
});
const getters = {
isEnabled: (state) => state.enabled,
isReady: (state) => state.initialized && !state.loading,
isActive: (state) => state.active,
currentConfig: (state) => state.config
};
export default {
namespaced: true,
state,
getters,
mutations,
actions
};

View File

@ -0,0 +1,248 @@
// @/core/store/modules/floatWindowManager.js
// Vuex 状态管理模块
import floatWindowManager from '@/core/utils/floatWindowManager';
const state = {
// 浮窗状态
isInitialized: false,
isVisible: false,
badgeCount: 0,
isLoading: false,
error: null
};
const getters = {
// 浮窗是否准备就绪
isReady: (state) => state.isInitialized,
// 浮窗是否可见
isVisible: (state) => state.isVisible,
// 当前角标数量
badgeCount: (state) => state.badgeCount,
// 是否正在加载
isLoading: (state) => state.isLoading,
// 错误信息
error: (state) => state.error
};
const mutations = {
SET_INITIALIZED(state, isInitialized) {
state.isInitialized = isInitialized;
},
SET_VISIBLE(state, isVisible) {
//console.log("浮窗已设置显示")
state.isVisible = isVisible;
},
SET_BADGE_COUNT(state, count) {
state.badgeCount = count;
},
SET_LOADING(state, isLoading) {
state.isLoading = isLoading;
},
SET_ERROR(state, error) {
state.error = error;
}
};
const actions = {
/**
* 初始化浮窗
*/
async initialize({ commit, dispatch }, options = {}) {
try {
commit('SET_LOADING', true);
commit('SET_ERROR', null);
const success = await floatWindowManager.init(options);
if (success) {
commit('SET_INITIALIZED', true);
commit('SET_BADGE_COUNT', floatWindowManager.getBadgeCount());
// 设置默认点击行为
floatWindowManager.setOnClickListener(() => {
dispatch('handleFloatClick');
});
}
return success;
} catch (error) {
commit('SET_ERROR', error.message);
console.error('初始化浮窗失败:', error);
return false;
} finally {
commit('SET_LOADING', false);
}
},
async is_visible({commit, state}){
try{
if(!state.isVisible){
const success = floatWindowManager.show();
if (success) {
commit('SET_VISIBLE', true);
}
}
return state.isVisible;
}catch(e){
console.log("is_visible",e);
return false;
}
},
/**
* 显示浮窗
*/
async show({ commit, state }) {
if (!state.isInitialized) {
const initialized = await dispatch('initialize');
if (!initialized) return false;
}
const success = floatWindowManager.show();
if (success) {
commit('SET_VISIBLE', true);
}
return success;
},
/**
* 隐藏浮窗
*/
async hide({ commit, state }) {
if (!state.isInitialized) return true;
const success = floatWindowManager.hide();
if (success) {
commit('SET_VISIBLE', false);
}
return success;
},
/**
* 设置角标数量
*/
async setBadge({ commit }, count) {
if (typeof count !== 'number' || count < 0) {
throw new Error('角标数量必须为非负数字');
}
const success = floatWindowManager.setBadge(count);
if (success) {
commit('SET_BADGE_COUNT', count);
}
return success;
},
/**
* 清除角标
*/
async clearBadge({ commit }) {
const success = floatWindowManager.clearBadge();
if (success) {
commit('SET_BADGE_COUNT', 0);
}
return success;
},
/**
* 增加角标数量
*/
async increaseBadge({ commit, state }, increment = 1) {
const newCount = state.badgeCount + increment;
return dispatch('setBadge', newCount);
},
/**
* 减少角标数量
*/
async decreaseBadge({ commit, state }, decrement = 1) {
const newCount = Math.max(0, state.badgeCount - decrement);
return dispatch('setBadge', newCount);
},
/**
* 更新浮窗位置
*/
async updatePosition({ state }, position) {
if (!state.isInitialized) {
throw new Error('浮窗未初始化');
}
return floatWindowManager.updatePosition(position);
},
/**
* 设置点击回调
*/
async setOnClickListener({ state }, callback) {
if (!state.isInitialized) {
throw new Error('浮窗未初始化');
}
if (typeof callback !== 'function') {
throw new Error('回调必须是一个函数');
}
return floatWindowManager.setOnClickListener(callback);
},
/**
* 处理浮窗点击(默认行为)
*/
async handleFloatClick() {
try {
console.log('浮窗点击处理');
// 这里可以添加全局的点击处理逻辑
// 比如发送埋点、跳转页面等
uni.navigateTo({
url: '/pages/message/index'
});
} catch (error) {
console.error('浮窗点击处理失败:', error);
}
},
/**
* 销毁浮窗
*/
async destroy({ commit }) {
try {
floatWindowManager.destroy();
commit('SET_INITIALIZED', false);
commit('SET_VISIBLE', false);
commit('SET_BADGE_COUNT', 0);
commit('SET_ERROR', null);
return true;
} catch (error) {
console.error('销毁浮窗失败:', error);
return false;
}
},
/**
* 重置浮窗状态
*/
async reset({ dispatch }) {
await dispatch('destroy');
return dispatch('initialize');
}
};
export default {
namespaced: true,
state,
getters,
mutations,
actions
};

View File

@ -0,0 +1,34 @@
// 打印相关 Vuex 模块
// 用于管理打印台、打印机、打印任务等状态
import http from '@/core/request/index'
const state = {
};
const mutations = {
};
const actions = {
// 提交打印任务
async sendPrint({ commit }, data) {
console.log('提交打印任务:', data);
const result = await http('print.send', data);
console.log('打印任务提交结果:', result);
return result;
}
};
const getters = {
workbenchList: state => state.workbenchList,
printerList: state => state.printerList,
printTask: state => state.printTask,
};
export default {
namespaced: true,
state,
mutations,
actions,
getters
};

View File

@ -0,0 +1,281 @@
// modules/setting.js
import http from "../../request";
// 默认键值对设置
const defaultSettings = {
// 广播相关
'broadcast.action': 'com.pda.scan.RESULT',
'broadcast.key': 'scan_data',
// 扫描相关
'scan.sound': 'true',
'scan.vibrate': 'true',
'scan.auto_focus': 'true',
// 界面相关
'ui.theme': 'light',
'ui.language': 'zh_CN',
// 系统相关
'system.auto_sync': 'true',
'system.cache_size': '100'
};
const STORAGE_KEY = 'app_settings';
const state = {
settings: {}
};
const mutations = {
// 初始化设置
INIT_SETTINGS(state) {
// 从本地存储加载
const saved = uni.getStorageSync(STORAGE_KEY);
if (saved) {
try {
const parsed = JSON.parse(saved);
// 合并默认设置和保存的设置
state.settings = { ...defaultSettings, ...parsed };
console.log('从存储加载设置:', state.settings);
} catch (error) {
console.error('解析设置失败:', error);
state.settings = { ...defaultSettings };
console.log('使用默认设置:', state.settings);
}
} else {
state.settings = { ...defaultSettings };
console.log('首次使用默认设置:', state.settings);
// 保存默认设置到存储
uni.setStorageSync(STORAGE_KEY, JSON.stringify(state.settings));
}
},
// 设置单个键值
SET_KEY_VALUE(state, { key, value }) {
state.settings[key] = value;
uni.setStorageSync(STORAGE_KEY, JSON.stringify(state.settings));
console.log('保存设置:', key, '=', value);
},
// 批量设置
SET_MULTIPLE(state, settings) {
Object.keys(settings).forEach(key => {
state.settings[key] = settings[key];
});
uni.setStorageSync(STORAGE_KEY, JSON.stringify(state.settings));
console.log('批量保存设置:', settings);
},
// 删除设置
DELETE_KEY(state, key) {
if (state.settings.hasOwnProperty(key)) {
delete state.settings[key];
uni.setStorageSync(STORAGE_KEY, JSON.stringify(state.settings));
console.log('删除设置:', key);
}
},
// 重置所有设置
RESET_SETTINGS(state) {
state.settings = { ...defaultSettings };
uni.setStorageSync(STORAGE_KEY, JSON.stringify(state.settings));
console.log('重置所有设置为默认值');
},
// 清除所有设置
CLEAR_SETTINGS(state) {
state.settings = {};
uni.removeStorageSync(STORAGE_KEY);
console.log('清除所有设置');
}
};
const actions = {
// 初始化设置(确保只在需要时初始化)
initSettings({ commit, state }) {
if (Object.keys(state.settings).length === 0) {
commit('INIT_SETTINGS');
}
return state.settings;
},
netCheck() {
return new Promise((resolve, reject) => {
http('common.ping').then(response => {
resolve(1)
}).catch(error => {
reject(0)
})
})
},
// 获取单个值(确保已初始化)
getValue({ dispatch, state }, key) {
if (Object.keys(state.settings).length === 0) {
dispatch('initSettings');
}
return state.settings[key] || defaultSettings[key];
},
// 设置单个值(确保已初始化)
setValue({ dispatch, commit }, { key, value }) {
return dispatch('initSettings').then(() => {
commit('SET_KEY_VALUE', { key, value });
return true;
});
},
// 批量设置(确保已初始化)
setMultiple({ dispatch, commit }, settings) {
return dispatch('initSettings').then(() => {
commit('SET_MULTIPLE', settings);
return true;
});
},
// 删除键(确保已初始化)
deleteKey({ dispatch, commit }, key) {
return dispatch('initSettings').then(() => {
commit('DELETE_KEY', key);
return true;
});
},
// 重置设置(确保已初始化)
resetSettings({ dispatch, commit }) {
return dispatch('initSettings').then(() => {
commit('RESET_SETTINGS');
return true;
});
},
// 清除所有设置
clearSettings({ commit }) {
commit('CLEAR_SETTINGS');
return true;
},
// 获取所有设置(确保已初始化)
getAllSettings({ dispatch, state }) {
return dispatch('initSettings').then(() => {
return { ...state.settings };
});
},
// 获取默认值
getDefaultValue({}, key) {
return defaultSettings[key];
},
// 检查键是否存在(确保已初始化)
hasKey({ dispatch, state }, key) {
return dispatch('initSettings').then(() => {
return state.settings.hasOwnProperty(key);
});
},
// 获取广播设置(确保已初始化)
getBroadcastSettings({ dispatch, state }) {
return dispatch('initSettings').then(() => {
return {
action: state.settings['broadcast.action'] || defaultSettings['broadcast.action'],
key: state.settings['broadcast.key'] || defaultSettings['broadcast.key']
};
});
},
// 设置广播设置(确保已初始化)
setBroadcastSettings({ dispatch, commit }, { action, key }) {
return dispatch('initSettings').then(() => {
const settings = {};
if (action !== undefined) {
settings['broadcast.action'] = action;
}
if (key !== undefined) {
settings['broadcast.key'] = key;
}
commit('SET_MULTIPLE', settings);
console.log("保存广播设置:", settings);
return true;
});
}
};
const getters = {
// 获取所有设置
allSettings: state => {
if (Object.keys(state.settings).length === 0) {
// 如果settings为空,可能需要初始化
console.warn('settings为空,可能需要初始化');
return { ...defaultSettings };
}
return { ...state.settings };
},
// 获取广播设置
broadcastSettings: state => {
if (Object.keys(state.settings).length === 0) {
console.warn('settings为空,使用默认广播设置');
return {
action: defaultSettings['broadcast.action'],
key: defaultSettings['broadcast.key']
};
}
return {
action: state.settings['broadcast.action'] || defaultSettings['broadcast.action'],
key: state.settings['broadcast.key'] || defaultSettings['broadcast.key']
};
},
// 获取扫描设置
scanSettings: state => {
if (Object.keys(state.settings).length === 0) {
return {
sound: defaultSettings['scan.sound'] === 'true',
vibrate: defaultSettings['scan.vibrate'] === 'true',
auto_focus: defaultSettings['scan.auto_focus'] === 'true'
};
}
return {
sound: state.settings['scan.sound'] === 'true',
vibrate: state.settings['scan.vibrate'] === 'true',
auto_focus: state.settings['scan.auto_focus'] === 'true'
};
},
// 获取界面设置
uiSettings: state => {
if (Object.keys(state.settings).length === 0) {
return {
theme: defaultSettings['ui.theme'],
language: defaultSettings['ui.language']
};
}
return {
theme: state.settings['ui.theme'] || defaultSettings['ui.theme'],
language: state.settings['ui.language'] || defaultSettings['ui.language']
};
},
// 获取系统设置
systemSettings: state => {
if (Object.keys(state.settings).length === 0) {
return {
auto_sync: defaultSettings['system.auto_sync'] === 'true',
cache_size: parseInt(defaultSettings['system.cache_size'])
};
}
return {
auto_sync: state.settings['system.auto_sync'] === 'true',
cache_size: parseInt(state.settings['system.cache_size'] || defaultSettings['system.cache_size'])
};
}
};
export default {
namespaced: true,
state,
mutations,
actions,
getters
};

263
core/store/modules/user.js Normal file
View File

@ -0,0 +1,263 @@
// 用户数据模块
import http from '@/core/request/index'
import store from '@/core/store'
import tools from '@/core/utils/tool'
import {
getToken,
setToken,
removeToken
} from '@/core/utils/auth'
import { router } from '../../router'
const state = {
token: uni.getStorageSync("token") || "",
isLogin: uni.getStorageSync("isLogin") || false, // 是否登陆
userInfo: uni.getStorageSync("userInfo") || {}, // 用户信息
agentInfo: {}, //分销商信息
userData: {}, //用户其他相关信息
subscribeMessageIdsMap: [], //小程序订阅消息模板ids
authType: '', // smsLogin:手机号登录注册, accountLogin:密码登录, forgotPwd:忘记密码, changePwd:修改密码, bindMobile:绑定手机号
user: {},
app: {
device: "pda",
project:"warehouse"
},
permissions: [],
menus:[],
roleId:0,
}
const getters = {
token: state => state.token,
isLogin: state => state.isLogin,
userInfo: state => state.userInfo,
agentInfo: state => state.agentInfo,
userOtherData: state => state.userData,
authType: state => state.authType,
subscribeMessageIdsMap: state => state.subscribeMessageIdsMap,
user: state => state.user,
app: state => state.app,
permissions: state => state.permissions,
roleId:state=>state.roleId
}
const actions = {
// 获取用户信息
getUserInfo({
commit,
dispatch,
getters,
state
}, token = '') {
return new Promise((resolve, reject) => {
token && uni.setStorageSync('token', token);
http('user.info', {
device: state.app.device,
project:state.app.project
}).then(res => {
console.log(res);
const {
data
} = res
if (!data) {
uni.showToast({
title: '无权登录',
icon: 'none',
duration: 1000,
mask: true
});
dispatch('logout');
console.log("无权登录");
return false;
}
const user = data
commit('SET_PERMISSIONS', user.permissions)
commit('SET_USER', user)
commit('SET_ROLEID', user.employees_id)
resolve(user)
}).then(() => {
// 只有在登录的时候请求购物车信息,订单信息,获取登录信息之后。
token && dispatch('getCartList');
token && dispatch('getUserData');
})
.catch(e => {
reject(e)
})
})
},
// 用户其他相关信息
changeEmployee({
commit,
state
},roleId) {
return new Promise((resolve, reject) => {
http('user.changeRole',{roleId,device: state.app.device,
project:state.app.project}).then(response => {
const {
data
} = response
const user = data.user;
setToken(data.token);
commit('SET_USER', user)
commit('SET_PERMISSIONS', user.permissions)
commit('SET_ROLEID', user.employees_id)
resolve(response)
}).catch(e => {
reject(e)
})
})
},
logout({
commit,
dispatch
}) {
removeToken();
commit('SET_PERMISSIONS', [])
commit('SET_USER', {})
commit('SET_ROLEID', 0)
router.replace('/pages/login/index')
},
checkPath({
commit,
state
},path) {
let has = false;
console.log("所有菜单",state.menus);
for(let i =0;i<state.menus.length;i++){
if(state.menus[i].component==path){
has = true;
}
}
return has;
},
login({
commit,
state
}, userInfo) {
const {
username,
password
} = userInfo
return new Promise((resolve, reject) => {
http('user.login', {
username: username.trim(),
password: password,
device: state.app.device,
project:state.app.project
}).then(response => {
const {
data
} = response;
console.log("登录返回数据",data);
setToken(data.token)
resolve()
}).catch(error => {
console.log("出错",error)
reject(error)
})
})
},
}
const mutations = {
token(state, payload) {
state.token = payload;
uni.setStorageSync("token", payload);
},
// 登录态
isLogin(state, data) {
state.isLogin = data;
uni.setStorageSync('isLogin', data);
},
// 用户信息
userInfo(state, data) {
state.userInfo = data;
uni.setStorageSync("userInfo", data);
},
// 分销商信息
AGENT_INFO(state, data) {
state.agentInfo = data;
},
SET_USER: (state, user) => {
state.user = user;
const allChildren = user.menus.flatMap(item =>
item.children || [] // 确保 children 存在,否则返回空数组
);
// 2. 过滤有效菜单并限制数量
const validMenus = allChildren.filter(menu =>
menu &&
menu.component &&
menu.component !== 'Layout' &&
menu.meta &&
menu.meta.title
)
state.menus = validMenus;
},
SET_ROLEID: (state, roleId) => {
state.roleId = roleId
},
// 小程序订阅消息模板ids
MESSAGE_IDS(state, data) {
state.subscribeMessageIds = data;
},
USER_DATA(state, data) {
state.userData = data;
},
AUTH_TYPE(state, data) {
data ? uni.hideTabBar() : uni.showTabBar();
state.authType = data;
},
SET_PERMISSIONS: (state, permissions) => {
state.permissions = permissions
},
// 订阅消息
subscribeMessage(state, type) {
let arr = state.subscribeMessageIdsMap[type];
arr.length && uni.requestSubscribeMessage({
tmplIds: arr,
success: (res) => {
console.log(res);
},
fail: (err) => {
console.log(err);
}
});
},
// 解析订阅消息数据
formatMessage(state, messageIdsObj) {
// 各场景下用到的订阅模板
let typeMap = {
'result': ['order_sended', 'wallet_change'], //支付成功
'grouponResult': ['groupon_success', 'groupon_fail', 'order_sended'], //拼团支付成功后
'aftersale': ['refund_agree', 'aftersale_change', 'wallet_change'], //点击售后
'wallet': ['score_change', 'wallet_apply', 'wallet_change'], //提现提醒
'store': ['store_order_new'], //门店新订单通知
'storeApply': ['store_apply'] //门店申请通知
}
let idsMap = {}
Object.keys(typeMap).forEach(key => {
idsMap[key] = []
typeMap[key].forEach(item => {
idsMap[key].push(messageIdsObj[item])
})
})
state.subscribeMessageIdsMap = idsMap
},
}
export default {
state,
mutations,
actions,
getters
}

14
core/utils/auth.js Normal file
View File

@ -0,0 +1,14 @@
const TokenKey = 'token'
export function getToken() {
return uni.getStorageSync(TokenKey);
}
export function setToken(token) {
console.log("设置token");
return uni.setStorageSync(TokenKey,token);
}
export function removeToken() {
return uni.setStorageSync(TokenKey,'');
}

220
core/utils/base64.js Normal file
View File

@ -0,0 +1,220 @@
(function () {
var BASE64_MAPPING = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
];
/**
*ascii convert to binary
*/
var _toBinary = function (ascii) {
var binary = new Array();
while (ascii > 0) {
var b = ascii % 2;
ascii = Math.floor(ascii / 2);
binary.push(b);
}
/*
var len = binary.length;
if(6-len > 0){
for(var i = 6-len ; i > 0 ; --i){
binary.push(0);
}
}*/
binary.reverse();
return binary;
};
/**
*binary convert to decimal
*/
var _toDecimal = function (binary) {
var dec = 0;
var p = 0;
for (var i = binary.length - 1; i >= 0; --i) {
var b = binary[i];
if (b == 1) {
dec += Math.pow(2, p);
}
++p;
}
return dec;
};
/**
*unicode convert to utf-8
*/
var _toUTF8Binary = function (c, binaryArray) {
var mustLen = (8 - (c + 1)) + ((c - 1) * 6);
var fatLen = binaryArray.length;
var diff = mustLen - fatLen;
while (--diff >= 0) {
binaryArray.unshift(0);
}
var binary = [];
var _c = c;
while (--_c >= 0) {
binary.push(1);
}
binary.push(0);
var i = 0, len = 8 - (c + 1);
for (; i < len; ++i) {
binary.push(binaryArray[i]);
}
for (var j = 0; j < c - 1; ++j) {
binary.push(1);
binary.push(0);
var sum = 6;
while (--sum >= 0) {
binary.push(binaryArray[i++]);
}
}
return binary;
};
var __BASE64 = {
/**
*BASE64 Encode
*/
encoder: function (str) {
var base64_Index = [];
var binaryArray = [];
for (var i = 0, len = str.length; i < len; ++i) {
var unicode = str.charCodeAt(i);
var _tmpBinary = _toBinary(unicode);
if (unicode < 0x80) {
var _tmpdiff = 8 - _tmpBinary.length;
while (--_tmpdiff >= 0) {
_tmpBinary.unshift(0);
}
binaryArray = binaryArray.concat(_tmpBinary);
} else if (unicode >= 0x80 && unicode <= 0x7FF) {
binaryArray = binaryArray.concat(_toUTF8Binary(2, _tmpBinary));
} else if (unicode >= 0x800 && unicode <= 0xFFFF) {//UTF-8 3byte
binaryArray = binaryArray.concat(_toUTF8Binary(3, _tmpBinary));
} else if (unicode >= 0x10000 && unicode <= 0x1FFFFF) {//UTF-8 4byte
binaryArray = binaryArray.concat(_toUTF8Binary(4, _tmpBinary));
} else if (unicode >= 0x200000 && unicode <= 0x3FFFFFF) {//UTF-8 5byte
binaryArray = binaryArray.concat(_toUTF8Binary(5, _tmpBinary));
} else if (unicode >= 4000000 && unicode <= 0x7FFFFFFF) {//UTF-8 6byte
binaryArray = binaryArray.concat(_toUTF8Binary(6, _tmpBinary));
}
}
var extra_Zero_Count = 0;
for (var i = 0, len = binaryArray.length; i < len; i += 6) {
var diff = (i + 6) - len;
if (diff == 2) {
extra_Zero_Count = 2;
} else if (diff == 4) {
extra_Zero_Count = 4;
}
//if(extra_Zero_Count > 0){
// len += extra_Zero_Count+1;
//}
var _tmpExtra_Zero_Count = extra_Zero_Count;
while (--_tmpExtra_Zero_Count >= 0) {
binaryArray.push(0);
}
base64_Index.push(_toDecimal(binaryArray.slice(i, i + 6)));
}
var base64 = '';
for (var i = 0, len = base64_Index.length; i < len; ++i) {
base64 += BASE64_MAPPING[base64_Index[i]];
}
for (var i = 0, len = extra_Zero_Count / 2; i < len; ++i) {
base64 += '=';
}
return base64;
},
/**
*BASE64 Decode for UTF-8
*/
decoder: function (_base64Str) {
var _len = _base64Str.length;
var extra_Zero_Count = 0;
/**
*计算在进行BASE64编码的时候,补了几个0
*/
if (_base64Str.charAt(_len - 1) == '=') {
//alert(_base64Str.charAt(_len-1));
//alert(_base64Str.charAt(_len-2));
if (_base64Str.charAt(_len - 2) == '=') {//两个等号说明补了4个0
extra_Zero_Count = 4;
_base64Str = _base64Str.substring(0, _len - 2);
} else {//一个等号说明补了2个0
extra_Zero_Count = 2;
_base64Str = _base64Str.substring(0, _len - 1);
}
}
var binaryArray = [];
for (var i = 0, len = _base64Str.length; i < len; ++i) {
var c = _base64Str.charAt(i);
for (var j = 0, size = BASE64_MAPPING.length; j < size; ++j) {
if (c == BASE64_MAPPING[j]) {
var _tmp = _toBinary(j);
/*不足6位的补0*/
var _tmpLen = _tmp.length;
if (6 - _tmpLen > 0) {
for (var k = 6 - _tmpLen; k > 0; --k) {
_tmp.unshift(0);
}
}
binaryArray = binaryArray.concat(_tmp);
break;
}
}
}
if (extra_Zero_Count > 0) {
binaryArray = binaryArray.slice(0, binaryArray.length - extra_Zero_Count);
}
var unicode = [];
var unicodeBinary = [];
for (var i = 0, len = binaryArray.length; i < len;) {
if (binaryArray[i] == 0) {
unicode = unicode.concat(_toDecimal(binaryArray.slice(i, i + 8)));
i += 8;
} else {
var sum = 0;
while (i < len) {
if (binaryArray[i] == 1) {
++sum;
} else {
break;
}
++i;
}
unicodeBinary = unicodeBinary.concat(binaryArray.slice(i + 1, i + 8 - sum));
i += 8 - sum;
while (sum > 1) {
unicodeBinary = unicodeBinary.concat(binaryArray.slice(i + 2, i + 8));
i += 8;
--sum;
}
unicode = unicode.concat(_toDecimal(unicodeBinary));
unicodeBinary = [];
}
}
return unicode;
}
};
//window.BASE64 = __BASE64;
module.exports = {
CusBASE64: __BASE64
}
})();

238
core/utils/broadcast.js Normal file
View File

@ -0,0 +1,238 @@
/**
* 广播管理器
* 负责Android广播的注册、监听和销毁
*/
export default class BroadcastManager {
constructor() {
// 核心组件
this.main = null;
this.filter = null;
this.receiver = null;
// 状态控制
this.isListening = false;
this.isEnabled = false;
// 外部配置(必须由外部设置)
this.config = null;
// 回调函数
this.callbacks = null;
// 基础初始化
this._initEnvironment();
}
/**
* 初始化运行环境
*/
_initEnvironment() {
try {
// 检查HTML5+环境
if (typeof plus === 'undefined' || !plus.android) {
console.warn('[BroadcastManager] 非Android环境');
this.isEnabled = false;
return;
}
// 获取主Activity
this.main = plus.android.runtimeMainActivity();
if (!this.main) {
console.warn('[BroadcastManager] 无法获取主Activity');
this.isEnabled = false;
return;
}
// 导入必要的Android类
this.IntentFilter = plus.android.importClass('android.content.IntentFilter');
this.isEnabled = true;
console.log('[BroadcastManager] 环境初始化成功');
} catch (error) {
console.error('[BroadcastManager] 环境初始化失败:', error);
this.isEnabled = false;
}
}
/**
* 设置配置和回调
*/
setConfig(config, callbacks) {
if (!config || !config.broadcastAction) {
console.error('[BroadcastManager] 配置必须包含broadcastAction');
return false;
}
this.config = { ...config };
this.callbacks = callbacks || {};
console.log('[BroadcastManager] 配置已设置');
// 如果正在监听,重新注册
if (this.isListening) {
this._unregister();
return this._register();
}
return true;
}
/**
* 创建广播接收器
*/
_createReceiver() {
try {
this.filter = null;
this.receiver = null;
// 创建IntentFilter
this.filter = new this.IntentFilter();
this.filter.addAction(this.config.broadcastAction);
// 创建接收器
this.receiver = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {
onReceive: (context, intent) => {
this._handleBroadcast(context, intent);
}
});
return true;
} catch (error) {
console.error('[BroadcastManager] 创建接收器失败:', error);
return false;
}
}
/**
* 处理接收到的广播
*/
_handleBroadcast(context, intent) {
try {
plus.android.importClass(intent);
const dataKey = this.config.dataKey || 'value';
const data = intent.getStringExtra(dataKey);
if (!data) {
return;
}
const result = {
data: data,
timestamp: Date.now(),
action: intent.getAction(),
dataKey: dataKey
};
if (this.callbacks.onResult) {
this.callbacks.onResult(result);
}
} catch (error) {
console.error('[BroadcastManager] 处理广播失败:', error);
}
}
/**
* 注册接收器
*/
_register() {
if (!this.isEnabled || !this.config) {
return false;
}
try {
if (!this._createReceiver()) {
return false;
}
this.main.registerReceiver(this.receiver, this.filter);
this.isListening = true;
return true;
} catch (error) {
console.error('[BroadcastManager] 注册失败:', error);
this.isListening = false;
return false;
}
}
/**
* 注销接收器
*/
_unregister() {
if (!this.isListening || !this.receiver) {
return true;
}
try {
this.main.unregisterReceiver(this.receiver);
this.isListening = false;
return true;
} catch (error) {
console.error('[BroadcastManager] 注销失败:', error);
return false;
}
}
/**
* 开始监听
*/
start() {
if (this.isListening) {
return true;
}
if (!this.config) {
console.error('[BroadcastManager] 请先设置配置');
return false;
}
return this._register();
}
/**
* 停止监听
*/
stop() {
return this._unregister();
}
/**
* 暂停监听
*/
pause() {
return this.stop();
}
/**
* 恢复监听
*/
resume() {
return this.start();
}
/**
* 获取状态
*/
getStatus() {
return {
isEnabled: this.isEnabled,
isListening: this.isListening,
hasConfig: !!this.config,
currentAction: this.config ? this.config.broadcastAction : null
};
}
/**
* 销毁资源
*/
destroy() {
this.stop();
this.config = null;
this.callbacks = null;
}
}

View File

@ -0,0 +1,50 @@
// utils/dpi-converter.js
/**
* DPI 转换工具
* 目标: 1mm = 8dot (203.2 DPI)
*/
const DPI_TARGET = 203.2 // 1mm = 8dot 对应的 DPI
const MM_TO_DOT = 8 // 1mm = 8像素
export default {
/**
* 毫米转像素
* @param {number} mm - 毫米值
* @returns {number} 像素值
*/
mmToPx(mm) {
return Math.round(mm * MM_TO_DOT)
},
/**
* 像素转毫米
* @param {number} px - 像素值
* @returns {number} 毫米值
*/
pxToMm(px) {
return px / MM_TO_DOT
},
/**
* 获取指定毫米尺寸的画布
* @param {number} widthMm - 宽度(毫米)
* @param {number} heightMm - 高度(毫米)
* @returns {Object} 画布尺寸 { width, height }
*/
getCanvasSizeByMm(widthMm, heightMm) {
return {
width: this.mmToPx(widthMm),
height: this.mmToPx(heightMm)
}
},
/**
* 计算缩放比例
* @param {number} currentDpi - 当前 DPI
* @returns {number} 缩放比例
*/
getScaleFactor(currentDpi = 96) {
return DPI_TARGET / currentDpi
}
}

File diff suppressed because one or more lines are too long

3313
core/utils/encoding.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,694 @@
// @/core/utils/floatWindowManager.js
// 实际的浮窗操作类
class FloatWindowManager {
constructor() {
this.floatView = null;
this.badgeCount = 0;
this.isInitialized = false;
this._customClickListener = null;
// 添加:浮窗位置状态管理
this.currentPosition = { left: 100, top: 100 };
this.floatSize = { width: 40, height: 40 };
}
/**
* 初始化浮窗
* @param {Object} options - 初始化选项
*/
init(options = {}) {
//console.log('[FloatWindow] 开始初始化浮窗...');
if (this.isInitialized) {
//console.warn('[FloatWindow] 浮窗管理器已初始化,跳过重复初始化');
return Promise.resolve(true);
}
return new Promise((resolve, reject) => {
try {
// #ifdef APP-PLUS
//console.log('[FloatWindow] 检测到 APP-PLUS 环境');
if (!plus) {
const error = new Error('plus 对象不存在');
//console.error('[FloatWindow] 错误:', error);
reject(error);
return;
}
if (!plus.nativeObj) {
const error = new Error('plus.nativeObj 对象不存在');
//console.error('[FloatWindow] 错误:', error);
reject(error);
return;
}
//console.log('[FloatWindow] 检查通过,开始配置...');
// 默认配置
const config = {
size: { width: 40, height: 40 },
position: { },
opacity: 0.5,
...options
};
//console.log('[FloatWindow] 配置信息:', config);
try {
// 获取屏幕信息
const systemInfo = uni.getSystemInfoSync();
console.log('[FloatWindow] 系统信息:', {
windowWidth: systemInfo.windowWidth,
windowHeight: systemInfo.windowHeight
});
const screenWidth = systemInfo.windowWidth || 375;
const screenHeight = systemInfo.windowHeight || 667;
// 计算默认位置(右下角)
const defaultLeft = screenWidth - config.size.width - 10;
const defaultTop = screenHeight - config.size.height - 100;
// 更新内部位置状态
this.currentPosition.left = defaultLeft;
this.currentPosition.top = defaultTop;
this.floatSize.width = config.size.width;
this.floatSize.height = config.size.height;
/*console.log('[FloatWindow] 计算默认位置:', {
defaultLeft,
defaultTop,
currentPosition: this.currentPosition,
floatSize: this.floatSize
});*/
// 清理旧的浮窗
this._safeDestroy();
//console.log('[FloatWindow] 开始创建 Native View...');
// 创建新的浮窗
this.floatView = new plus.nativeObj.View('globalFloatView', {
top: this.currentPosition.top + 'px',
left: this.currentPosition.left + 'px',
width: this.floatSize.width + 'px',
height: this.floatSize.height + 'px',
opacity: config.opacity,
position: 'absolute'
});
/*console.log('[FloatWindow] Native View 创建成功:', this.floatView,{
top: this.currentPosition.top + 'px',
left: this.currentPosition.left + 'px',
width: this.floatSize.width + 'px',
height: this.floatSize.height + 'px',
opacity: config.opacity,
position: 'absolute'
});*/
// 绘制内容
this._safeDrawContent();
// 添加事件监听
this._safeAddEventListeners();
this.isInitialized = true;
//console.log('[FloatWindow] ✅ 浮窗初始化成功');
resolve(true);
} catch (innerError) {
//console.error('[FloatWindow] ❌ 内部初始化错误:', innerError);
//console.error('[FloatWindow] 错误堆栈:', innerError.stack);
reject(innerError);
}
// #endif
// #ifndef APP-PLUS
//console.warn('[FloatWindow] 非APP环境,跳过浮窗初始化');
const error = new Error('非APP环境,无法创建浮窗');
reject(error);
// #endif
} catch (outerError) {
//console.error('[FloatWindow] ❌ 初始化外层错误:', outerError);
//console.error('[FloatWindow] 错误堆栈:', outerError.stack);
reject(outerError);
}
});
}
/**
* 显示浮窗
*/
show() {
//console.log('[FloatWindow] 显示浮窗请求...');
if (!this.floatView) {
//console.warn('[FloatWindow] 浮窗未初始化,无法显示');
return false;
}
try {
//console.log('[FloatWindow] 正在显示浮窗...');
this.floatView.show();
//console.log('[FloatWindow] ✅ 浮窗显示成功');
return true;
} catch (error) {
//console.error('[FloatWindow] ❌ 显示浮窗失败:', error);
//console.error('[FloatWindow] 错误堆栈:', error.stack);
return false;
}
}
/**
* 隐藏浮窗
*/
hide() {
//console.log('[FloatWindow] 隐藏浮窗请求...');
if (!this.floatView) {
//console.warn('[FloatWindow] 浮窗未初始化,无法隐藏');
return false;
}
try {
//console.log('[FloatWindow] 正在隐藏浮窗...');
this.floatView.hide();
//console.log('[FloatWindow] ✅ 浮窗隐藏成功');
return true;
} catch (error) {
//console.error('[FloatWindow] ❌ 隐藏浮窗失败:', error);
//console.error('[FloatWindow] 错误堆栈:', error.stack);
return false;
}
}
/**
* 设置角标数量
* @param {number} count - 角标数量
*/
setBadge(count) {
//console.log('[FloatWindow] 设置角标请求,数量:', count);
if (!this.floatView) {
//console.warn('[FloatWindow] 浮窗未初始化,无法设置角标');
return false;
}
try {
if (typeof count !== 'number') {
//console.warn('[FloatWindow] 角标数量必须是数字,当前:', count);
count = parseInt(count) || 0;
}
this.badgeCount = Math.max(0, Math.floor(count));
//console.log('[FloatWindow] 更新角标数量为:', this.badgeCount);
// 清除并重新绘制
//console.log('[FloatWindow] 重新绘制浮窗内容...');
this.floatView.reset();
this._safeDrawContent();
if (this.badgeCount > 0) {
//console.log('[FloatWindow] 绘制角标...');
this._safeDrawBadge();
}
//console.log('[FloatWindow] ✅ 角标设置成功');
return true;
} catch (error) {
//console.error('[FloatWindow] ❌ 设置角标失败:', error);
//console.error('[FloatWindow] 错误堆栈:', error.stack);
return false;
}
}
/**
* 清除角标
*/
clearBadge() {
//console.log('[FloatWindow] 清除角标请求');
return this.setBadge(0);
}
/**
* 获取当前角标数量
*/
getBadgeCount() {
return this.badgeCount;
}
/**
* 更新浮窗位置
* @param {Object} position - 新位置 {left, top}
*/
updatePosition(position) {
//console.log('[FloatWindow] 更新位置请求:', position);
if (!this.floatView) {
//console.warn('[FloatWindow] 浮窗未初始化,无法更新位置');
return false;
}
try {
if (!position || typeof position.left !== 'number' || typeof position.top !== 'number') {
//console.error('[FloatWindow] 位置参数无效:', position);
return false;
}
// 更新内部位置状态
this.currentPosition.left = position.left;
this.currentPosition.top = position.top;
//console.log('[FloatWindow] 正在更新位置...');
this.floatView.setStyle({
left: position.left + 'px',
top: position.top + 'px'
});
//console.log('[FloatWindow] ✅ 位置更新成功,新位置:', this.currentPosition);
return true;
} catch (error) {
//console.error('[FloatWindow] ❌ 更新位置失败:', error);
//console.error('[FloatWindow] 错误堆栈:', error.stack);
return false;
}
}
/**
* 设置浮窗点击回调
* @param {Function} callback - 点击回调函数
*/
setOnClickListener(callback) {
//console.log('[FloatWindow] 设置点击回调请求');
if (!this.floatView) {
//console.warn('[FloatWindow] 浮窗未初始化,无法设置点击回调');
return false;
}
if (typeof callback !== 'function') {
//console.error('[FloatWindow] 回调参数必须是函数');
return false;
}
try {
this._customClickListener = callback;
//console.log('[FloatWindow] ✅ 点击回调设置成功');
return true;
} catch (error) {
//console.error('[FloatWindow] ❌ 设置点击监听失败:', error);
//console.error('[FloatWindow] 错误堆栈:', error.stack);
return false;
}
}
/**
* 获取当前浮窗位置
*/
getCurrentPosition() {
//console.log('[FloatWindow] 获取当前位置:', this.currentPosition);
return { ...this.currentPosition };
}
/**
* 销毁浮窗
*/
destroy() {
//console.log('[FloatWindow] 销毁浮窗请求');
return this._safeDestroy();
}
/**
* 检查浮窗是否已初始化
*/
isReady() {
const ready = this.isInitialized && this.floatView !== null;
//console.log('[FloatWindow] 检查浮窗就绪状态:', ready);
return ready;
}
// ============ 私有方法(安全版本) ============
/**
* 安全销毁浮窗
*/
_safeDestroy() {
try {
if (this.floatView) {
//console.log('[FloatWindow] 正在销毁浮窗实例...');
// 先隐藏
try {
this.floatView.hide();
//console.log('[FloatWindow] 浮窗已隐藏');
} catch (hideError) {
//console.warn('[FloatWindow] 隐藏浮窗时出错:', hideError);
}
// 尝试关闭
try {
this.floatView.close();
//console.log('[FloatWindow] 浮窗已关闭');
} catch (closeError) {
//console.warn('[FloatWindow] 关闭浮窗时出错:', closeError);
}
this.floatView = null;
//console.log('[FloatWindow] 浮窗实例已置空');
}
this.isInitialized = false;
this.badgeCount = 0;
this._customClickListener = null;
//console.log('[FloatWindow] ✅ 浮窗销毁完成');
return true;
} catch (error) {
//console.error('[FloatWindow] ❌ 销毁浮窗失败:', error);
//console.error('[FloatWindow] 错误堆栈:', error.stack);
return false;
}
}
/**
* 安全绘制浮窗内容
*/
_safeDrawContent() {
try {
if (!this.floatView) {
//console.warn('[FloatWindow] 浮窗实例不存在,无法绘制内容');
return false;
}
//console.log('[FloatWindow] 开始绘制浮窗内容...');
// 绘制圆形背景
this.floatView.drawRect(
{ color: 'rgba(0,0,0,1)', radius: (this.floatSize.width / 2) + 'px' },
{ top: '0px', left: '0px', width: this.floatSize.width + 'px', height: this.floatSize.height + 'px' }
);
//console.log('[FloatWindow] 背景绘制完成');
// 绘制图标
this.floatView.drawText('💬', {
top: '0px',
left: '0px',
width: '100%',
height: '100%'
}, {
align: 'center',
verticalAlign: 'middle',
color: '#FFFFFF',
size: '24px',
weight: 'bold'
});
//console.log('[FloatWindow] ✅ 内容绘制成功');
return true;
} catch (error) {
//console.error('[FloatWindow] ❌ 绘制内容失败:', error);
//console.error('[FloatWindow] 错误堆栈:', error.stack);
return false;
}
}
/**
* 安全绘制角标
*/
_safeDrawBadge() {
try {
if (!this.floatView) {
//console.warn('[FloatWindow] 浮窗实例不存在,无法绘制角标');
return false;
}
if (this.badgeCount <= 0) {
//console.log('[FloatWindow] 角标数量为0,跳过绘制');
return false;
}
//console.log('[FloatWindow] 开始绘制角标...');
const badgeSize = 18;
const badgeLeft = this.floatSize.width - badgeSize;
const badgeText = this.badgeCount > 99 ? '99+' : this.badgeCount.toString();
const fontSize = this.badgeCount > 9 ? '9px' : '11px';
/*console.log('[FloatWindow] 角标参数:', {
badgeSize,
badgeLeft,
badgeText,
fontSize,
floatWidth: this.floatSize.width
});*/
// 绘制红色角标背景
this.floatView.drawRect(
{ color: 'rgba(255,0,0,1)', radius: badgeSize / 2 + 'px' },
{ top: '0px', left: badgeLeft + 'px', width: badgeSize + 'px', height: badgeSize + 'px' }
);
//console.log('[FloatWindow] 角标背景绘制完成');
// 绘制数字
this.floatView.drawText(badgeText, {
top: '0px',
left: badgeLeft + 'px',
width: badgeSize + 'px',
height: badgeSize + 'px'
}, {
align: 'center',
verticalAlign: 'middle',
color: '#FFFFFF',
size: fontSize,
weight: 'bold'
});
//console.log('[FloatWindow] ✅ 角标绘制成功:', badgeText);
return true;
} catch (error) {
//console.error('[FloatWindow] ❌ 绘制角标失败:', error);
//console.error('[FloatWindow] 错误堆栈:', error.stack);
return false;
}
}
/**
* 安全添加事件监听
*/
_safeAddEventListeners() {
try {
if (!this.floatView) {
//console.warn('[FloatWindow] 浮窗实例不存在,无法添加事件监听');
return false;
}
//console.log('[FloatWindow] 开始添加事件监听...');
let isDragging = false;
let startX = 0, startY = 0;
let touchStartTime = 0;
let dragStartLeft = 0, dragStartTop = 0;
//console.log('[FloatWindow] 事件监听器已配置');
// 点击事件
this.floatView.addEventListener('click', (e) => {
try {
const now = Date.now();
//console.log('[FloatWindow] 点击事件触发,拖动状态:', isDragging, '时间差:', now - touchStartTime);
if (!isDragging && (now - touchStartTime < 300)) {
//console.log('[FloatWindow] 执行点击处理...');
this._safeHandleClick();
}
} catch (error) {
//console.error('[FloatWindow] 点击事件处理错误:', error);
}
});
// 触摸开始
this.floatView.addEventListener('touchstart', (touch) => {
try {
startX = touch.screenX || touch.clientX;
startY = touch.screenY || touch.clientY;
touchStartTime = Date.now();
isDragging = false;
// 记录拖拽开始时的位置
dragStartLeft = this.currentPosition.left;
dragStartTop = this.currentPosition.top;
/*console.log('[FloatWindow] 触摸开始:', {
startX,
startY,
touchStartTime,
currentPosition: this.currentPosition,
dragStartLeft,
dragStartTop
});*/
this.floatView.setStyle({ opacity: 0.8 });
//console.log('[FloatWindow] 触摸开始样式已更新');
} catch (error) {
//console.error('[FloatWindow] 触摸开始事件处理错误:', error);
}
});
// 触摸移动
this.floatView.addEventListener('touchmove', (touch) => {
try {
const currentX = touch.screenX || touch.clientX;
const currentY = touch.screenY || touch.clientY;
const moveX = Math.abs(currentX - startX);
const moveY = Math.abs(currentY - startY);
//console.log('[FloatWindow] 触摸移动:', { currentX, currentY, moveX, moveY });
if (moveX > 5 || moveY > 5) {
isDragging = true;
//console.log('[FloatWindow] 开始拖拽');
// 基于拖拽开始时的位置计算新位置
let newLeft = dragStartLeft + (currentX - startX);
let newTop = dragStartTop + (currentY - startY);
// 边界检查
const systemInfo = uni.getSystemInfoSync();
/*console.log('[FloatWindow] 系统边界:', {
width: systemInfo.windowWidth,
height: systemInfo.windowHeight
});*/
newLeft = Math.max(0, Math.min(newLeft, systemInfo.windowWidth - this.floatSize.width));
newTop = Math.max(0, Math.min(newTop, systemInfo.windowHeight - this.floatSize.height));
//console.log('[FloatWindow] 新位置:', { newLeft, newTop });
// 更新位置
this.updatePosition({ left: newLeft, top: newTop });
}
} catch (error) {
//console.error('[FloatWindow] 触摸移动事件处理错误:', error);
}
});
// 触摸结束
this.floatView.addEventListener('touchend', () => {
try {
//console.log('[FloatWindow] 触摸结束,拖拽状态:', isDragging);
this.floatView.setStyle({ opacity: 1 });
//console.log('[FloatWindow] 触摸结束样式已恢复');
if (isDragging) {
//console.log('[FloatWindow] 拖拽结束,执行吸附逻辑');
this._safeAttachToEdge();
}
setTimeout(() => {
isDragging = false;
//console.log('[FloatWindow] 拖拽状态已重置');
}, 100);
} catch (error) {
//console.error('[FloatWindow] 触摸结束事件处理错误:', error);
}
});
//console.log('[FloatWindow] ✅ 事件监听添加成功');
return true;
} catch (error) {
//console.error('[FloatWindow] ❌ 添加事件监听失败:', error);
//console.error('[FloatWindow] 错误堆栈:', error.stack);
return false;
}
}
/**
* 安全处理点击事件
*/
_safeHandleClick() {
try {
//console.log('[FloatWindow] 处理浮窗点击事件...');
// 如果有自定义点击回调,则执行
if (this._customClickListener && typeof this._customClickListener === 'function') {
//console.log('[FloatWindow] 执行自定义点击回调');
this._customClickListener();
} else {
// 默认行为:跳转到设置页面
//console.log('[FloatWindow] 执行默认行为:跳转到设置页面');
uni.navigateTo({
url: '/pages/message/index',
fail: (err) => {
//console.error('[FloatWindow] 跳转失败:', err);
}
});
}
//console.log('[FloatWindow] ✅ 点击事件处理完成');
} catch (error) {
//console.error('[FloatWindow] ❌ 处理点击事件失败:', error);
//console.error('[FloatWindow] 错误堆栈:', error.stack);
}
}
/**
* 安全吸附到边缘
*/
_safeAttachToEdge() {
try {
if (!this.floatView) {
//console.warn('[FloatWindow] 浮窗实例不存在,无法吸附');
return false;
}
//console.log('[FloatWindow] 开始吸附到边缘...');
//console.log('[FloatWindow] 当前矩形位置:', this.currentPosition);
const systemInfo = uni.getSystemInfoSync();
const centerX = this.currentPosition.left + (this.floatSize.width / 2);
/*console.log('[FloatWindow] 计算中心点:', {
centerX,
windowWidth: systemInfo.windowWidth,
currentLeft: this.currentPosition.left,
halfWidth: this.floatSize.width / 2
});*/
let newLeft = this.currentPosition.left;
if (centerX < systemInfo.windowWidth / 2) {
newLeft = 0; // 左边
//console.log('[FloatWindow] 吸附到左边');
} else {
newLeft = systemInfo.windowWidth - this.floatSize.width; // 右边
//console.log('[FloatWindow] 吸附到右边');
}
/*console.log('[FloatWindow] 吸附后位置:', {
newLeft,
top: this.currentPosition.top,
floatSize: this.floatSize
});*/
const result = this.updatePosition({ left: newLeft, top: this.currentPosition.top });
//console.log('[FloatWindow] ✅ 吸附完成,结果:', result);
return result;
} catch (error) {
//console.error('[FloatWindow] ❌ 吸附到边缘失败:', error);
//console.error('[FloatWindow] 错误堆栈:', error.stack);
return false;
}
}
}
// 创建单例实例
const floatWindowManager = new FloatWindowManager();
export default floatWindowManager;

47
core/utils/simpleFloat.js Normal file
View File

@ -0,0 +1,47 @@
// utils/simpleFloat.js - 先测试最基础的悬浮窗
export function createSimpleFloat() {
console.log('开始创建悬浮窗...');
// 获取当前页面
const currentWebview = plus.webview.currentWebview();
if (!currentWebview) {
console.error('无法获取当前页面webview');
return null;
}
console.log('当前webview:', currentWebview);
// 创建最简单的悬浮窗
const floatView = new plus.nativeObj.View('testFloat', {
top: '200px',
left: '20px',
width: '60px',
height: '60px',
backgroundColor: '#FF0000', // 使用明显的红色
borderRadius: '30px',
borderColor: '#FFFFFF',
borderWidth: '2px'
});
// 绘制文字
floatView.drawText('浮', {
top: '0px',
left: '0px',
width: '100%',
height: '100%'
}, {
align: 'center',
color: '#FFFFFF',
size: '24px'
});
// 添加到当前页面
currentWebview.append(floatView);
// 显示
floatView.show();
console.log('悬浮窗创建完成,添加到页面');
return floatView;
}

140
core/utils/tool.js Normal file
View File

@ -0,0 +1,140 @@
import {
API_URL
} from '@/env'
import {
router
} from '@/core/router'
export default {
/**
* 跳转再封装,主要是为了兼容外链。
* @param {String} path - 跳转路径
* @param {isTabbar} isTabbar - 是否是底部导航
*/
routerTo(path, isTabbar) {
if (path) {
// 是否跳转外部链接
if (~path.indexOf('http') || ~path.indexOf('www')) {
// #ifdef H5
window.location = path;
// #endif
// #ifndef H5
router.push({
path: '/pages/public/webview',
query: {
'webviewPath': path
}
})
// #endif
return false
}
if (isTabbar) {
router.replaceAll(path)
} else {
path.includes('/pages/index') && !path.includes('/pages/index/view') ? router.replaceAll(path) : router
.push(path)
}
} else {
console.log(`%cerr:没有填写跳转路径`, 'color:green;background:yellow');
}
},
/**
* 图片处理-预览图片
* @param {Array} urls - 图片列表
* @param {Number} current - 首个预览下标
*/
previewImage(urls = [], current = 0) {
uni.previewImage({
urls: urls,
current: current,
indicator: 'default',
loop: true,
fail(err) {
console.log('previewImage出错', urls, err)
},
})
},
/**
* 数据分组
* @param {Array} oArr - 原数组列表
* @param {Number} length - 单个数组长度
* @return {Array} arr - 分组后的新数组
*/
splitData(oArr = [], length = 1) {
let arr = [];
let minArr = [];
oArr.forEach(c => {
if (minArr.length === length) {
minArr = [];
}
if (minArr.length === 0) {
arr.push(minArr);
}
minArr.push(c);
});
return arr;
},
/**
* 剩余时间格式化
* @param {Number} t - 剩余多少秒
* @return {Object} format - 格式后的天时分秒对象
*/
format(t) {
let format = {
d: '00',
h: '00',
m: '00',
s: '00'
};
if (t > 0) {
let d = Math.floor(t / 86400);
let h = Math.floor((t / 3600) % 24);
let m = Math.floor((t / 60) % 60);
let s = Math.floor(t % 60);
format.d = d < 10 ? '0' + d : d;
format.h = h < 10 ? '0' + h : h;
format.m = m < 10 ? '0' + m : m;
format.s = s < 10 ? '0' + s : s;
}
return format;
},
/**
* 打电话
* @param {String<Number>} phoneNumber - 数字字符串
*/
callPhone(phoneNumber = '') {
let num = phoneNumber.toString()
uni.makePhoneCall({
phoneNumber: num,
fail(err) {
console.log('makePhoneCall出错', err)
},
});
},
/**
* 微信头像
* @param {String} url -图片地址
*/
checkMPUrl(url) {
// #ifdef MP
if (
url.substring(0, 4) === 'http' &&
url.substring(0, 5) !== 'https' &&
url.substring(0, 12) !== 'http://store' &&
url.substring(0, 10) !== 'http://tmp' &&
url.substring(0, 10) !== 'http://usr'
) {
url = 'https' + url.substring(4, url.length);
}
// #endif
return url;
},
}

534
core/utils/tsc.js Normal file
View File

@ -0,0 +1,534 @@
//utils/tsc.js
var encode = require("./encoding.js");
var jpPrinter = {
createNew: function() {
var jpPrinter = {};
var data = "";
var command = []
jpPrinter.name = "蓝牙打印机";
jpPrinter.init = function() {};
jpPrinter.addCommand = function(content) { //将指令转成数组装起
var code = new encode.TextEncoder(
'gb18030', {
NONSTANDARD_allowLegacyEncoding: true
}).encode(content)
for (var i = 0; i < code.length; ++i) {
command.push(code[i])
}
};
jpPrinter.clear = function() {
command = [];
};
/**
* 该指令用于设定卷标纸的宽度和长度
* 传入参数说明
* pageWidght:标签宽度 单位mm
* pageHeight:标签高度 单位mm
*/
jpPrinter.setSize = function(pageWidght, pageHeight) {
data = "SIZE " + pageWidght.toString() + " mm" + "," + pageHeight.toString() + " mm" + "\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令用于定义两张卷标纸间的垂直间距距离
* 传入参数说明
* 标签间隙 单位mm
*/
jpPrinter.setGap = function(printGap) {
data = "GAP " + printGap.toString() + " mm,0 mm\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令用于设定黑标高度及定义标签印完后标签额外送出的长度
* 传入参数说明
* 黑标高度 单位mm
*/
jpPrinter.setBline = function(printBline) {
data = "BLINE " + printBline.toString() + " mm,0 mm\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令用于控制在剥离模式时(peel-off mode)每张卷标停止的位置,在打印
* 下一张时打印机会将原先多推出或少推出的部分以回拉方式补偿回来。该指令仅
* 适用于剥离模式。
* 传入参数说明
* 纸张停止的距离 单位mm
*/
jpPrinter.setOffset = function(offset) {
data = "OFFSET " + offset.toString() + " mm,0 mm\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令用于控制打印速度
* 传入参数说明
* 1<=printSpeed<=6
* 实际支持速度以自检页为准
*/
jpPrinter.setSpeed = function(printSpeed) {
data = "SPEED " + printSpeed.toString() + "\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令用于控制打印时的浓度
传入参数说明
* 1<=printDensity<=15
*/
jpPrinter.setDensity = function(printDensity) {
data = "DENSITY " + printDensity.toString() + "\r\n";
jpPrinter.addCommand(data)
}
/**
* 该指令用于定义打印时出纸和打印字体的方向
* 传入参数说明
* direction=0或direction=1
*/
jpPrinter.setDirection = function(direction) {
data = "DIRECTION " + direction + "\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令用于定义卷标的参考坐标原点。坐标原点位置和打印方向有关
* 传入参数说明
* x 水平方向的坐标位置,单位dots
* y 垂直方向的坐标位置,单位dots
* 打印机分辨率200 DPI: 1 mm = 8 dots
* 打印机分辨率300 DPI: 1 mm = 12 dots
*/
jpPrinter.setReference = function(x, y) {
data = "REFERENCE " + x + "," + y + "\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令表示标签打印偏移量多少设置
* 传入参数说明 点数dot
* n 偏移量 ,单位dot 1mm=8 dots
* 打印机分辨率200 DPI: 1 mm = 8 dots
* 打印机分辨率300 DPI: 1 mm = 12 dots
*/
jpPrinter.setShift = function(n) {
data = "SHIFT " + n + "\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令用于选择对应的国际字符集
* 传入参数说明
* 001:USA
* 002:French
* 003:Latin America
* 034:Spanish
* 039:Italian
* 044:United Kingdom
* 046:Swedish
* 047:Norwegian
* 049:German
*/
jpPrinter.setCountry = function(country) {
data = "COUNTRY " + country + "\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令用于选择对应的国际代码页
* 传入参数说明
* 8-bit codepage 字符集代表
* 437:United States
* 850:Multilingual
* 852:Slavic
* 860:Portuguese
* 863:Canadian/French
* 865:Nordic
*
* Windows code page
* 1250:Central Europe
* 1252:Latin I
* 1253:Greek
* 1254:Turkish
*
* 以下代码页仅限于12×24 dot 英数字体
* WestEurope:WestEurope
* Greek:Greek
* Hebrew:Hebrew
* EastEurope:EastEurope
* Iran:Iran
* IranII:IranII
* Latvian:Latvian
* Arabic:Arabic
* Vietnam:Vietnam
* Uygur:Uygur
* Thai:Thai
* 1252:Latin I
* 1257:WPC1257
* 1251:WPC1251
* 866:Cyrillic
* 858:PC858
* 747:PC747
* 864:PC864
* 1001:PC1001
*/
jpPrinter.setCodepage = function(codepage) {
data = "CODEPAGE " + codepage + "\r\n";
jpPrinter.addCommand(data)
}
/**
* 该指令用于清除图像缓冲区(image buffer)的数据
*/
jpPrinter.setCls = function() {
data = "CLS\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令用于将标签纸向前推送指定的长度
* 传入参数说明 点数dots
* 打印机分辨率200 DPI:1 mm = 8 dots
* 打印机分辨率300 DPI:1 mm = 12 dots
*/
jpPrinter.setFeed = function(feed) {
data = "FEED " + feed + "\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令用于将标签纸向后回拉指定的长度
* 传入参数说明 点数dots
* 打印机分辨率200 DPI:1 mm = 8 dots
* 打印机分辨率300 DPI:1 mm = 12 dots
*/
jpPrinter.setBackFeed = function(backup) {
data = "BACKFEED " + backup + "\r\n";
jpPrinter.addCommand(data)
}
/**
* 该指令用于控制打印机进一张标签纸
*/
jpPrinter.setFromfeed = function() {
data = "FORMFEED\r\n";
jpPrinter.addCommand(data)
};
/**
* 在使用含有间隙或黑标的标签纸时,若不能确定第一张标签纸是否在正确打印位
* 置时,此指令可将标签纸向前推送至下一张标签纸的起点开始打印。标签尺寸和
* 间隙需要在本条指令前设置
* 注:使用该指令时,纸张高度大于或等于30 mm
*/
jpPrinter.setHome = function() { //根据Size找到下一张标签纸的位置
data = "HOME\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令用于打印出存储于影像缓冲区内的数据
*/
jpPrinter.setPagePrint = function() {
data = "PRINT 1,1\r\n"
jpPrinter.addCommand(data)
};
/**
* 该指令用于打印出存储于影像缓冲区内的数据
* 传入参数说明 打印份数
* 1≤n≤65535
*/
jpPrinter.setPrint = function(n) {
data = "PRINT " + n + ",1\r\n"
jpPrinter.addCommand(data)
};
/**
* 该指令用于控制蜂鸣器的频率,可设定10 阶的声音,每阶声音的长短由第二个参数控制
* 传入参数说明
* level 音阶:0-9
* interval 间隔时间:1-4095
*/
jpPrinter.setSound = function(level, interval) { //控制蜂鸣器
data = "SOUND " + level + "," + interval + "\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令用于设定打印机进纸时,若经过所设定的长度仍无法侦测到垂直间距,则打印机在连续纸模式工作
* 传入参数说明 点数dots
*/
jpPrinter.setLimitfeed = function(limit) { // 检测垂直间距
data = "LIMITFEED " + limit + "mm\r\n";
jpPrinter.addCommand(data)
};
/**
* 打印自检页
*/
jpPrinter.setSelfTest = function() {
data = "SELFTEST\r\n";
jpPrinter.addCommand(data)
}
/**
* 该指令用于在标签上画线
* 传入参数说明
* x 线条左上角X 坐标,单位dots
* y 线条左上角Y 坐标,单位dots
* width 线宽,单位dots
* height 线高,单位dots
*/
jpPrinter.setBar = function(x, y, width, height) { //绘制线条
data = "BAR " + x + "," + y + "," + width + "," + height + "\r\n"
jpPrinter.addCommand(data)
};
/**
* 该指令用于在卷标上绘制矩形方框
* x_start 方框左上角X 坐标,单位dots
* y_start 方框左上角Y 坐标,单位dots
* x_end 方框右下角X 坐标,单位dots
* y_end 方框右下角Y 坐标,单位dots
* thickness 方框线宽,单位dots
*/
jpPrinter.setBox = function(x_start, y_start, x_end, y_end, thickness) {
data = "BOX " + x_start + "," + y_start + "," + x_end + "," + y_end + "," + thickness + "\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令用来画一维条码
* 传入参数说明
* x 左上角水平坐标起点,以点(dot)表示
* y 左上角垂直坐标起点,以点(dot)表示
* height 条形码高度,以点(dot)表示
*readable 0 表示人眼不可识,1 表示人眼可识
*rotation 条形码旋转角度,顺时针方向 0,90,180,270
* narrow 窄bar 宽度,以点(dots)表示
* wide 宽bar 宽度,以点(dot)表示
* content 打印内容
*/
jpPrinter.setBarCode = function(x, y, codetype, height, readable, rotation, narrow, wide, content) {
data = "BARCODE " + x + "," + y + ",\"" + codetype + "\"," + height + "," + readable + "," +
rotation + "," + narrow + "," + wide + ",\"" + content + "\"\r\n"
jpPrinter.addCommand(data)
};
jpPrinter.drawBitmap = function(a, b, c, d, e, f) {
var g = "BITMAP ".concat(a, ",").concat(b, ",").concat(c / 8, ",").concat(d, ",").concat(e,
",");
jpPrinter.addCommand(cmd);
for (y = 0; y < d; y++) {
for (x = 0; x < c; x++) {
var color = res.data[(y * c + x) * 4 + 1];
if (color <= 128) {
bits[parseInt(y * pitch + x / 8)] |= (0x80 >> (x % 8));
}
}
}
for (var i = 0; i < bits.length; i++) {
command.push((~bits[i]) & 0xFF);
}
};
/**
* 打印图片(单色图片)
* res为画布参数
*/
jpPrinter.setBitmap = function(x, y, mode, res) {
console.log("res.width,res.height", res.width, res.height);
var w = res.width;
var h = res.height;
var bitw = parseInt((w + 7) / 8) * 8;
// var bitw = (parseInt(w) % 8) == 0 ? (parseInt(w) / 8) :( parseInt(w) / 8+1);
var pitch = parseInt(bitw / 8);
var bits = new Uint8Array(h * pitch);
console.log("w=" + w + ", h=" + h + ", bitw=" + bitw / 8 + ", pitch=" + pitch + ", bits=" + bits.length);
var cmd = "BITMAP " + x + "," + y + "," + pitch + "," + h + "," + mode + ",";
console.log("add cmd: " + cmd);
jpPrinter.addCommand(cmd);
// for (var i=0; i<bits.length; i++) {
// bits[i] = 0;
// }
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
var color = res.data.data[(y * w + x) * 4 + 1];
if (color <= 128) {
bits[parseInt(y * pitch + x / 8)] |= (0x80 >> (x % 8));
}
}
}
for (var i = 0; i < bits.length; i++) {
command.push((~bits[i]) & 0xFF);
}
console.log(command);
};
/**
* 将指定的区域反相打印
* 传入参数说明
* x_start 反相区域左上角X 坐标,单位dot
* y_start 反相区域左上角Y 坐标,单位dot
* x_width 反相区域宽度,单位dot
* y_height 反相区域高度,单位dot
*/
jpPrinter.setErase = function(x_start, y_start, x_width, y_height) {
data = "ERASE " + x_start + "," + y_start + "," + x_width + "," + y_height + "\r\n";
jpPrinter.addCommand(data)
};
/**
* 将指定的区域反相打印
* 传入参数说明
* x_start 反相区域左上角X 坐标,单位dot
* y_start 反相区域左上角Y 坐标,单位dot
* x_width 反相区域宽度,单位dot
* y_height 反相区域高度,单位dot
*/
jpPrinter.setReverse = function(x_start, y_start, x_width, y_height) {
data = "REVERSE " + x_start + "," + y_start + "," + x_width + "," + y_height + "\r\n";
jpPrinter.addCommand(data)
};
/**
* 该指令用于打印字符串
* 传入参数说明
* x 文字X 方向起始点坐标
* y 文字Y 方向起始点坐标
* font 字体名称
* 1 8×12 dot 英数字体
* 2 12×20 dot 英数字体
* 3 16×24 dot 英数字体
* 4 24×32 dot 英数字体
* 5 32×48 dot 英数字体
* 6 14×19 dot 英数字体OCR-B
* 7 21×27 dot 英数字体OCR-B
* 8 14×25 dot 英数字体OCR-A
* 9 9×17 dot 英数字体
* 10 12×24 dot 英数字体
* TSS16.BF2 简体中文16×16(GB 码)
* TSS20.BF2 简体中文20×20(GB 码)
* TST24.BF2 繁体中文24×24(大五码)
* TSS24.BF2 简体中文24×24(GB 码)
* K 韩文24×24Font(KS 码)
* TSS32.BF2 简体中文32×32(GB 码)
* rotation 文字旋转角度(顺时针方向) 0, 90, 180, 270
*/
jpPrinter.setText = function(x, y, font, rotation, x_, y_, str) {
data = "TEXT " + x + "," + y + ",\"" + font + "\"," + rotation + "," + x_ + "," + y_ + "," +
"\"" + str +
"\"\r\n"
jpPrinter.addCommand(data)
};
/**
* 该指令用来打印二维码
* x 二维码水平方向起始点坐标
* y 二维码垂直方向起始点坐标
* ECC level 选择QRCODE 纠错等级
* L 7%
* M 15%
* Q 25%
* H 30%
* cell width 二维码宽度1-10
* mode 手动/自动编码
* A Auto
* M Manual
* rotation 旋转角度(顺时针方向) 0,90,180,270
* content 内容
*/
jpPrinter.setQrcode = function(x, y, level, width, mode, rotation, model, mask, content) {
data = "QRCODE " + x + "," + y + "," + level + "," + width + "," + mode + "," + rotation + "," +
model +
"," +
mask + ",\"" + content + "\"\r\n"
jpPrinter.addCommand(data)
};
/**
* 该指令用来起动Key1 的预设功能
* 传入参数说明
* ON 开启按键
* OFF 关闭按键
*/
jpPrinter.setKey1 = function(n) {
data = "SET KYE1 " + n.toString + "\r\n"
jpPrinter.addCommand(data)
};
/**
* 该指令用来起动Key2 的预设功能
* 传入参数说明
* ON 开启按键
* OFF 关闭按键
*/
jpPrinter.setKey2 = function(n) {
data = "SET KYE2 " + n.toString + "\r\n"
jpPrinter.addCommand(data)
};
/**
* 该指令用来启动/关闭剥离模式,默认值为关闭
* 传入参数说明
* ON 起动剥离模式
* OFF 关闭剥离模式
*/
jpPrinter.setPeel = function(n) {
data = "SET PEEL " + n.toString + "\r\n"
jpPrinter.addCommand(data)
};
/**
* 此命令是用来启用/禁用撕纸位置走到撕纸处,此设置关掉电源后将保存在打印机内
* 传入参数说明
* ON 启用撕纸位置走到撕纸处
* OFF 禁用撕纸位置走到撕纸处,命令在起始位置有效
*/
jpPrinter.setTear = function(n) {
data = "SET TEAR " + n.toString + "\r\n"
jpPrinter.addCommand(data)
};
/**
* 此命令是用来启用/禁用撕纸位置走到撕纸处,此设置关掉电源后将保存在打印机内
* 传入参数说明
* ON 启用撕纸位置走到撕纸处
* OFF 禁用撕纸位置走到撕纸处,命令在起始位置有效
*/
jpPrinter.setStripper = function(n) {
data = "SET STRIPPER " + n.toString + "\r\n"
jpPrinter.addCommand(data)
};
/**
* 此设置用于启用/禁用打印头合盖传感器。如果禁用合盖传感器,打印机头被打开时,将不会传回错误信息。
* 此设置将保存在打印机内存。
* 传入参数说明
* ON 启用打印头合盖传感器
* OFF 禁用打印头合盖传感器
*/
jpPrinter.setHead = function(n) {
data = "SET HEAD " + n.toString + "\r\n"
jpPrinter.addCommand(data)
};
/**
* 此命令将禁用/启用标签机在无纸或开盖错误发生后,上纸或合盖后重新打印一次标签内容
* 传入参数说明
* OFF 禁止此功能
* ON 启用此功能
*/
jpPrinter.setReprint = function(n) {
data = "SET REPRINT " + n.toString + "\r\n"
jpPrinter.addCommand(data)
};
/**
* 设定开启/关闭碳带感应器,即切换热转式/热感印式打印。通常打印机于开启电
*源时,碳带感应器即会自动检测打印机是否已装上碳带,并藉此决定使用热感式
*或热转式打印。此项设定并不会存于打印机中。此方法仅适用于热转式机器。
* 传入参数说明
* OFF 禁止此功能
* ON 启用此功能
*/
jpPrinter.setRibbon = function(n) {
data = "SET RIBBON " + n.toString + "\r\n"
jpPrinter.addCommand(data)
};
/**
* 此命令用于设置切刀状态,关闭打印机电源后,该设置将会被存储在打印机内存中。
* 传入参数说明
* OFF 关闭切刀功能
* BATCH 在PRINT 命令结束后切纸
* pieces 0-65535,用于设置每几个标签进行切纸
*/
jpPrinter.setCut = function(n) {
data = "SET CUTTER " + n.toString + "\r\n"
jpPrinter.addCommand(data)
};
//获取打印数据
jpPrinter.getData = function() {
const text1 = command.map(code => String.fromCharCode(code)).join('');
console.log("输出命令", text1);
return command;
};
return jpPrinter;
}
};
module.exports.jpPrinter = jpPrinter;

3
env.js Normal file
View File

@ -0,0 +1,3 @@
export const BASE_URL = 'http://192.168.11.56:6060' //后台根域名 https://demo.shopro.top
export const API_URL = `${BASE_URL}/system` //后台接口域名
export const IMG_URL = 'https://ye4s.file.gzxunren.com' //全局网络图片地址变量,css背景图片地址变量在uni.scss

125
main.js Normal file
View File

@ -0,0 +1,125 @@
import Vue from 'vue'
import App from './App'
import core from "@/core";
// 引入全局uView
import uView from '@/uni_modules/uview-ui'
import mixin from './common/mixin'
import {
router,
RouterMount
} from "@/core/router";
import store from "@/core/store";
Vue.config.productionTip = false
App.mpType = 'app'
// 插件安装
Vue.use(uView)
Vue.use(router)
Vue.use(core)
const app = new Vue({
store,
...App
});
// 应用启动逻辑
async function initializeApp() {
try {
console.log('[App] 启动初始化...')
// 1. 必须先初始化设置模块(广播模块依赖它)
await store.dispatch('setting/initSettings');
console.log('[App] 设置模块初始化完成')
// 2. 初始化广播模块(它会自动读取setting模块的配置)
await store.dispatch('broadcast/init');
console.log('[App] 广播模块初始化完成')
await store.dispatch("bluetoothPrint/initializeBluetooth");
// 3. 初始化安卓消息窗口模块(APP环境)
await initializeFloatWindow();
// 4. 挂载路由和App
RouterMount(app, router, "#app");
console.log('[App] 应用启动完成')
} catch (error) {
console.error('[App] 启动失败:', error)
// 错误处理:可以显示错误页面或降级处理
// app.$router.push('/error') 或使用其他方式通知用户
}
}
// 初始化浮窗函数
async function initializeFloatWindow() {
return new Promise((resolve) => {
// #ifdef APP-PLUS
console.log('[App] 开始初始化浮窗模块')
// 检查 plus 对象是否就绪
if (typeof plus !== 'undefined' && plus.nativeObj) {
// plus 对象已就绪,立即初始化
store.dispatch('floatWindowManager/initialize')
.then(() => {
console.log('[App] 浮窗模块初始化完成')
resolve(true);
})
.catch((error) => {
console.warn('[App] 浮窗模块初始化失败:', error)
resolve(false); // 浮窗初始化失败不应阻止应用启动
});
} else {
// plus 对象未就绪,延迟初始化
console.log('[App] plus对象未就绪,延迟初始化浮窗')
const maxAttempts = 10;
let attempts = 0;
const checkPlusReady = setInterval(() => {
attempts++;
if (typeof plus !== 'undefined' && plus.nativeObj) {
clearInterval(checkPlusReady);
store.dispatch('floatWindowManager/initialize')
.then(() => {
console.log('[App] 浮窗模块初始化完成')
resolve(true);
})
.catch((error) => {
console.warn('[App] 浮窗模块初始化失败:', error)
resolve(false);
});
} else if (attempts >= maxAttempts) {
clearInterval(checkPlusReady);
console.warn('[App] plus对象等待超时,跳过浮窗初始化')
resolve(false);
} else {
console.log(`[App] 等待plus对象... (${attempts}/${maxAttempts})`)
}
}, 300); // 每300ms检查一次
}
// #endif
// #ifndef APP-PLUS
console.log('[App] 非APP环境,跳过浮窗初始化')
resolve(true); // 非APP环境直接返回成功
// #endif
});
}
// #ifdef MP
// 引入uView对小程序分享的mixin封装
const mpShare = require('@/uni_modules/uview-ui/libs/mixin/mpShare.js')
Vue.mixin(mpShare)
// #endif
Vue.mixin(mixin)
// 启动应用
initializeApp();
app.$mount();

152
manifest.json Normal file
View File

@ -0,0 +1,152 @@
{
"name" : "WMS_PDA",
"appid" : "__UNI__0B3DAD3",
"description" : "多平台快速开发的UI框架",
"versionName" : "2.0.37",
"versionCode" : 1,
"transformPx" : false,
"app-plus" : {
"optimization" : {
"subPackages" : true
},
"safearea" : {
"bottom" : {
"offset" : "none"
}
},
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
"usingComponents" : true,
"nvueCompiler" : "uni-app",
"compilerVersion" : 3,
"modules" : {
"Webview-x5" : {}
},
"distribute" : {
"android" : {
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
],
"abiFilters" : [ "armeabi-v7a", "arm64-v8a" ]
},
"ios" : {
"idfa" : false
},
"sdkConfigs" : {
"ad" : {}
},
"icons" : {
"android" : {
"hdpi" : "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/96x96.png",
"xxhdpi" : "unpackage/res/icons/144x144.png",
"xxxhdpi" : "unpackage/res/icons/192x192.png"
},
"ios" : {
"appstore" : "unpackage/res/icons/1024x1024.png",
"ipad" : {
"app" : "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png",
"notification" : "unpackage/res/icons/20x20.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"proapp@2x" : "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png"
},
"iphone" : {
"app@2x" : "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"notification@3x" : "unpackage/res/icons/60x60.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png"
}
}
}
}
},
"quickapp" : {},
"mp-weixin" : {
"appid" : "",
"setting" : {
"urlCheck" : false,
"es6" : false,
"minified" : false,
"postcss" : false
},
"optimization" : {
"subPackages" : true
},
"usingComponents" : true,
"mergeVirtualHostAttributes" : true
},
"mp-alipay" : {
"usingComponents" : true,
"component2" : true
},
"mp-qq" : {
"optimization" : {
"subPackages" : true
},
"appid" : "15646153"
},
"mp-baidu" : {
"usingComponents" : true,
"appid" : ""
},
"mp-toutiao" : {
"usingComponents" : true,
"appid" : ""
},
"h5" : {
"template" : "template.h5.html",
"router" : {
"mode" : "history",
"base" : ""
},
"optimization" : {
"treeShaking" : {
"enable" : false
}
},
"title" : "uView UI",
"sdkConfigs" : {
"maps" : {
"qqmap" : {
"key" : ""
}
}
},
"domain" : ""
},
"vueVersion" : "2"
}

16
package.json Normal file
View File

@ -0,0 +1,16 @@
{
"id": "uview-ui",
"scripts": {
"test": "eslint . --fix"
},
"dependencies": {
"html2canvas": "^1.4.1",
"qrcode": "^1.5.4",
"uni-read-pages": "^1.0.5",
"uqrcodejs": "^4.0.7"
},
"devDependencies": {
"eslint": "^8.2.0",
"eslint-config-airbnb": "^19.0.0"
}
}

159
pages.json Normal file
View File

@ -0,0 +1,159 @@
{
// "condition": { //模式配置,仅开发期间生效
// "current": 0, //当前激活的模式(list 的索引项)
// "list": [{
// "name": "test", //模式名称
// "path": "pages/componentsA/test/test", //启动页面,必选
// "query": "" //启动参数,在页面的onLoad函数里面得到
// }]
// },
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/login/index",
"style": {
"titleNView": false
}
},
{
"path" : "pages/oa/index",
"style" :
{
"titleNView": false
}
},
{
"path": "pages/index/index",
"style": {
"titleNView": false
}
},
{
"path": "pages/work/index",
"style": {
"titleNView": false
}
},
{
"path": "pages/user/index",
"style": {
"titleNView": false
}
},
{
"path": "pages/message/index",
"style": {
"titleNView": false
}
},
{
"path" : "pages/404",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/settings/broadcastSettings",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/settings/index",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/settings/networkTest",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/work/storage/receiving/receiving",
"meta": {
"auth": true
},
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/work/storage/relocation",
"meta": {
"auth": true
},
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/403",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/work/storage/receiving/receivingCreate",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/work/storage/receiving/receivingDetail",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/work/storage/receiving/receivingList",
"style" :
{
"titleNView": false
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "WMS_PDA",
"navigationBarBackgroundColor": "#FFFFFF",
"backgroundColor": "#f8f8f8"
},
"tabBar": {
"borderStyle": "white",
"backgroundColor": "#333",
"color": "#555",
"selectedColor": "#24afd6",
"list": [{
"text": "作业",
"pagePath": "pages/index/index",
"iconPath": "static/icon/index.png",
"selectedIconPath": "static/icon/index_a.png"
},
{
"text": "工单",
"pagePath": "pages/oa/index",
"iconPath": "static/icon/oa.png",
"selectedIconPath": "static/icon/oa_a.png"
},
{
"text": "我的",
"pagePath": "pages/user/index",
"iconPath": "static/icon/mime.png",
"selectedIconPath": "static/icon/mime_a.png"
}
]
}
}

319
pages/403.vue Normal file
View File

@ -0,0 +1,319 @@
<template>
<view class="normar_container">
<page-nav title="403"></page-nav>
<view class="page-not-found">
<!-- 主要内容 -->
<view class="content">
<!-- 标题 -->
<text class="title">你没有访问本页面的权限</text>
<!-- 提示信息 -->
<view class="tips">
<text class="tip-text">💡 您可以:</text>
<view class="tip-items">
<text class="tip-item">1. 返回上一页继续操作</text>
<text class="tip-item">2. 联系客服反馈需求</text>
<text class="tip-item">3. 查看其他可用功能</text>
</view>
</view>
</view>
<!-- 操作按钮 -->
<view class="action-buttons">
<u-button type="primary" shape="circle" @click="goBack" :custom-style="{marginBottom: '20rpx'}">
<u-icon name="arrow-left" size="24" color="#fff" style="margin-right: 8px;"></u-icon>
返回上一页
</u-button>
<u-button type="home" shape="circle" @click="goHome">
<u-icon name="home" size="24" color="#fff" style="margin-right: 8px;"></u-icon>
返回首页
</u-button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 页面配置
showTimeline: true,
showProgress: true,
}
},
computed: {
// 根据进度设置颜色
progressColor() {
if (this.progress < 30) return '#dd524d'; // 红色
if (this.progress < 70) return '#f0ad4e'; // 黄色
return '#4cd964'; // 绿色
}
},
onLoad(options) {
// 可以通过页面传参自定义显示内容
if (options.pageName) {
this.pageName = options.pageName;
}
// 记录访问日志(可选)
this.logAccess();
},
methods: {
// 记录页面访问
logAccess() {
console.log(`页面未开发提示:${this.pageName || '当前页面'}`);
},
// 返回上一页
goBack() {
uni.navigateBack({
delta: 1,
fail: () => {
// 如果无法返回,则跳转到首页
uni.switchTab({
url: '/pages/index/index'
});
}
});
},
// 返回首页
goHome() {
uni.switchTab({
url: '/pages/index/index'
});
},
// 联系客服
contactSupport() {
// 这里可以跳转到客服页面或拨打电话
const phone = '400-123-4567';
uni.showActionSheet({
itemList: [`拨打客服电话: ${phone}`, '在线客服'],
success: (res) => {
if (res.tapIndex === 0) {
// 拨打电话
uni.makePhoneCall({
phoneNumber: phone
});
} else if (res.tapIndex === 1) {
// 跳转到在线客服页面
uni.navigateTo({
url: '/pages/customer-service/index'
});
}
}
});
},
// 分享页面(可选)
onShareAppMessage() {
return {
title: '功能即将上线,敬请期待!',
path: '/pages/common/under-development'
};
}
}
}
</script>
<style lang="scss" scoped>
.page-not-found {
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
display: flex;
flex-direction: column;
// 头部
.header {
height: 120rpx;
background-color: #fff;
display: flex;
align-items: center;
padding: 0 30rpx;
border-bottom: 1px solid #f0f0f0;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
.header-title {
font-size: 36rpx;
font-weight: bold;
color: #333;
margin-left: 30rpx;
}
}
// 主要内容
.content {
flex: 1;
padding: 60rpx 40rpx;
text-align: center;
// 图标
.icon-container {
margin-bottom: 50rpx;
animation: pulse 2s infinite;
}
// 标题
.title {
display: block;
font-size: 48rpx;
font-weight: bold;
color: #333;
margin-bottom: 30rpx;
}
// 描述
.description {
display: block;
font-size: 32rpx;
color: #666;
margin-bottom: 60rpx;
line-height: 1.6;
}
// 时间线
.timeline {
background-color: #fff;
border-radius: 20rpx;
padding: 40rpx;
margin-bottom: 40rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
.timeline-title {
display: block;
font-size: 30rpx;
color: #999;
margin-bottom: 15rpx;
}
.timeline-date {
display: block;
font-size: 42rpx;
font-weight: bold;
color: #4cd964;
}
}
// 进度条
.progress-section {
background-color: #fff;
border-radius: 20rpx;
padding: 40rpx;
margin-bottom: 40rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
.progress-title {
display: block;
font-size: 30rpx;
color: #999;
margin-bottom: 30rpx;
text-align: left;
}
.progress-text {
display: block;
font-size: 28rpx;
color: #666;
margin-top: 20rpx;
text-align: left;
}
}
// 提示信息
.tips {
background-color: #fff;
border-radius: 20rpx;
padding: 40rpx;
margin-bottom: 40rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
text-align: left;
.tip-text {
display: block;
font-size: 32rpx;
font-weight: 500;
color: #333;
margin-bottom: 25rpx;
}
.tip-items {
display: flex;
flex-direction: column;
gap: 20rpx;
.tip-item {
font-size: 28rpx;
color: #666;
line-height: 1.6;
&::before {
content: "• ";
color: #4cd964;
font-weight: bold;
}
}
}
}
}
// 操作按钮
.action-buttons {
padding: 0 40rpx 40rpx;
::v-deep .u-btn {
height: 100rpx;
font-size: 34rpx;
display: flex;
align-items: center;
justify-content: center;
}
}
// 底部
.footer {
padding: 30rpx 0 40rpx;
text-align: center;
border-top: 1px solid #f0f0f0;
background-color: #fff;
.footer-text {
display: block;
font-size: 24rpx;
color: #999;
margin-bottom: 15rpx;
}
.version {
display: block;
font-size: 24rpx;
color: #ccc;
}
}
// 动画
@keyframes pulse {
0% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(1.05);
opacity: 0.8;
}
100% {
transform: scale(1);
opacity: 1;
}
}
}
</style>

321
pages/404.vue Normal file
View File

@ -0,0 +1,321 @@
<template>
<view class="normar_container">
<page-nav title="404"></page-nav>
<view class="page-not-found">
<!-- 主要内容 -->
<view class="content">
<!-- 标题 -->
<text class="title">页面开发中</text>
<!-- 描述 -->
<text class="description">该功能正在紧锣密鼓的开发中,敬请期待!</text>
<!-- 提示信息 -->
<view class="tips">
<text class="tip-text">💡 您可以:</text>
<view class="tip-items">
<text class="tip-item">1. 返回上一页继续操作</text>
<text class="tip-item">2. 联系客服反馈需求</text>
<text class="tip-item">3. 查看其他可用功能</text>
</view>
</view>
</view>
<!-- 操作按钮 -->
<view class="action-buttons">
<u-button type="primary" shape="circle" @click="goBack" :custom-style="{marginBottom: '20rpx'}">
<u-icon name="arrow-left" size="24" color="#fff" style="margin-right: 8px;"></u-icon>
返回上一页
</u-button>
<u-button type="home" shape="circle" @click="goHome">
<u-icon name="home" size="24" color="#fff" style="margin-right: 8px;"></u-icon>
返回首页
</u-button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 页面配置
showTimeline: true,
showProgress: true,
}
},
computed: {
// 根据进度设置颜色
progressColor() {
if (this.progress < 30) return '#dd524d'; // 红色
if (this.progress < 70) return '#f0ad4e'; // 黄色
return '#4cd964'; // 绿色
}
},
onLoad(options) {
// 可以通过页面传参自定义显示内容
if (options.pageName) {
this.pageName = options.pageName;
}
// 记录访问日志(可选)
this.logAccess();
},
methods: {
// 记录页面访问
logAccess() {
console.log(`页面未开发提示:${this.pageName || '当前页面'}`);
},
// 返回上一页
goBack() {
uni.navigateBack({
delta: 1,
fail: () => {
// 如果无法返回,则跳转到首页
uni.switchTab({
url: '/pages/index/index'
});
}
});
},
// 返回首页
goHome() {
uni.switchTab({
url: '/pages/index/index'
});
},
// 联系客服
contactSupport() {
// 这里可以跳转到客服页面或拨打电话
const phone = '400-123-4567';
uni.showActionSheet({
itemList: [`拨打客服电话: ${phone}`, '在线客服'],
success: (res) => {
if (res.tapIndex === 0) {
// 拨打电话
uni.makePhoneCall({
phoneNumber: phone
});
} else if (res.tapIndex === 1) {
// 跳转到在线客服页面
uni.navigateTo({
url: '/pages/customer-service/index'
});
}
}
});
},
// 分享页面(可选)
onShareAppMessage() {
return {
title: '功能即将上线,敬请期待!',
path: '/pages/common/under-development'
};
}
}
}
</script>
<style lang="scss" scoped>
.page-not-found {
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
display: flex;
flex-direction: column;
// 头部
.header {
height: 120rpx;
background-color: #fff;
display: flex;
align-items: center;
padding: 0 30rpx;
border-bottom: 1px solid #f0f0f0;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
.header-title {
font-size: 36rpx;
font-weight: bold;
color: #333;
margin-left: 30rpx;
}
}
// 主要内容
.content {
flex: 1;
padding: 60rpx 40rpx;
text-align: center;
// 图标
.icon-container {
margin-bottom: 50rpx;
animation: pulse 2s infinite;
}
// 标题
.title {
display: block;
font-size: 48rpx;
font-weight: bold;
color: #333;
margin-bottom: 30rpx;
}
// 描述
.description {
display: block;
font-size: 32rpx;
color: #666;
margin-bottom: 60rpx;
line-height: 1.6;
}
// 时间线
.timeline {
background-color: #fff;
border-radius: 20rpx;
padding: 40rpx;
margin-bottom: 40rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
.timeline-title {
display: block;
font-size: 30rpx;
color: #999;
margin-bottom: 15rpx;
}
.timeline-date {
display: block;
font-size: 42rpx;
font-weight: bold;
color: #4cd964;
}
}
// 进度条
.progress-section {
background-color: #fff;
border-radius: 20rpx;
padding: 40rpx;
margin-bottom: 40rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
.progress-title {
display: block;
font-size: 30rpx;
color: #999;
margin-bottom: 30rpx;
text-align: left;
}
.progress-text {
display: block;
font-size: 28rpx;
color: #666;
margin-top: 20rpx;
text-align: left;
}
}
// 提示信息
.tips {
background-color: #fff;
border-radius: 20rpx;
padding: 40rpx;
margin-bottom: 40rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
text-align: left;
.tip-text {
display: block;
font-size: 32rpx;
font-weight: 500;
color: #333;
margin-bottom: 25rpx;
}
.tip-items {
display: flex;
flex-direction: column;
gap: 20rpx;
.tip-item {
font-size: 28rpx;
color: #666;
line-height: 1.6;
&::before {
content: "• ";
color: #4cd964;
font-weight: bold;
}
}
}
}
}
// 操作按钮
.action-buttons {
padding: 0 40rpx 40rpx;
::v-deep .u-btn {
height: 100rpx;
font-size: 34rpx;
display: flex;
align-items: center;
justify-content: center;
}
}
// 底部
.footer {
padding: 30rpx 0 40rpx;
text-align: center;
border-top: 1px solid #f0f0f0;
background-color: #fff;
.footer-text {
display: block;
font-size: 24rpx;
color: #999;
margin-bottom: 15rpx;
}
.version {
display: block;
font-size: 24rpx;
color: #ccc;
}
}
// 动画
@keyframes pulse {
0% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(1.05);
opacity: 0.8;
}
100% {
transform: scale(1);
opacity: 1;
}
}
}
</style>

View File

@ -0,0 +1,132 @@
<template>
<view
class="u-page"
ref="u-back-top"
>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义backTop(滚动页面即可在右下角看到图标)</text>
<view class="u-demo-block__content">
<view class="u-page__backTop-item">
<u-checkbox-group
placement="column"
shape="square"
@change="checkboxChange"
v-model="value"
>
<u-checkbox
:customStyle="{marginBottom: '8px'}"
v-for="(item, index) in checkboxList"
:key="index"
:label="item.name"
:name="item.name"
>
</u-checkbox>
</u-checkbox-group>
</view>
</view>
</view>
<u-back-top
:right="backTopData.right"
:customStyle="backTopData.customStyle"
:bottom="backTopData.bottom"
:icon="backTopData.icon"
:mode="backTopData.mode"
:iconStyle="backTopData.iconStyle"
:duration="backTopData.duration"
:scrollTop="scrollTop"
@click="click"
></u-back-top>
</view>
</template>
<script>
export default {
data() {
return {
value: ['自定义图标'],
backTopData: {
mode: 'circle',
icon: 'arrow-upward',
bottom: 100,
customStyle: {},
iconStyle: {},
right:20,
duration: 300
},
scrollTop: 0,
// 被自定义的样式
checkboxList: [{
name: '显示方形',
},
{
name: '自定义图标',
},
{
name: '自定义距离',
},
{
name: '自定义样式',
},
{
name:'自定义返回顶部滚动时间',
}
]
}
},
onLoad() {
// 演示中默认勾选了自定义图标
this.backTopData.icon = "arrow-up"
},
onPageScroll(e) {
this.scrollTop = e.scrollTop;
},
methods: {
checkboxChange(n) {
if (n.includes('显示方形')) {
this.backTopData.mode = 'square'
} else {
this.backTopData.mode = "circle"
}
if (n.includes('自定义图标')) {
this.backTopData.icon = "arrow-up"
} else {
this.backTopData.icon = "arrow-upward"
}
if (n.includes('自定义距离')) {
this.backTopData.bottom = 300
this.backTopData.right=20
} else {
this.backTopData.bottom = 100
}
if (n.includes('自定义样式')) {
this.backTopData.customStyle = {
backgroundColor: '#2979ff',
}
this.backTopData.iconStyle = {
color: '#ffffff'
}
} else {
this.backTopData.customStyle = {}
this.backTopData.iconStyle = {}
}
if (n.includes('自定义返回顶部滚动时间')) {
this.backTopData.duration =1500
} else {
this.backTopData.duration =300
}
},
click() {
console.log('click');
}
}
}
</script>
<style lang="scss">
.u-page {
height: 1200px;
&__backTop-item{
margin-top:10px;
}
}
</style>

View File

@ -0,0 +1,330 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">按钮类型</text>
<view class="u-demo-block__content">
<view class="u-page__button-item">
<u-button
text="默认按钮"
size="normal"
type="info"
@click="click"
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="成功按钮"
size="normal"
type="success"
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="危险按钮"
size="normal"
type="error"
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="主要按钮"
size="normal"
type="primary"
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="警告按钮"
size="normal"
type="warning"
></u-button>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">镂空按钮</text>
<view class="u-demo-block__content">
<view class="u-page__button-item">
<u-button
text="镂空按钮"
size="normal"
type="info"
plain
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="镂空按钮"
size="normal"
type="success"
plain
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="镂空按钮"
size="normal"
type="error"
plain
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="镂空按钮"
size="normal"
type="primary"
plain
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="镂空按钮"
size="normal"
type="warning"
plain
></u-button>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">细边按钮</text>
<view class="u-demo-block__content">
<view class="u-page__button-item">
<u-button
text="细边按钮"
size="normal"
type="info"
plain
hairline
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="细边按钮"
size="normal"
type="success"
plain
hairline
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="细边按钮"
size="normal"
type="error"
plain
hairline
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="细边按钮"
size="normal"
type="primary"
plain
hairline
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="细边按钮"
size="normal"
type="warning"
plain
hairline
></u-button>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">禁用按钮</text>
<view class="u-demo-block__content">
<view class="u-page__button-item">
<u-button
disabled
text="禁用按钮"
size="normal"
type="info"
></u-button>
</view>
<view class="u-page__button-item">
<u-button
disabled
text="禁用按钮"
size="normal"
type="success"
></u-button>
</view>
<view class="u-page__button-item">
<u-button
disabled
text="禁用按钮"
size="normal"
type="error"
></u-button>
</view>
<view class="u-page__button-item">
<u-button
disabled
text="禁用按钮"
size="normal"
type="primary"
></u-button>
</view>
<view class="u-page__button-item">
<u-button
disabled
text="禁用按钮"
size="normal"
type="warning"
></u-button>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">加载中</text>
<view class="u-demo-block__content">
<view class="u-page__button-item">
<u-button
loadingText="加载中"
size="normal"
loading
loadingMode="circle"
type="success"
></u-button>
</view>
<view class="u-page__button-item">
<u-button
class="button-layout__item"
loadingText="加载中"
size="normal"
loading
type="error"
></u-button>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">按钮图标&按钮形状</text>
<view class="u-demo-block__content">
<view class="u-page__button-item">
<u-button
text="按钮图标"
size="normal"
icon="map"
plain
type="warning"
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="按钮图标"
size="normal"
plain
shape="circle"
type="success"
></u-button>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义颜色</text>
<view class="u-demo-block__content">
<view class="u-page__button-item">
<u-button
text="渐变色按钮"
size="normal"
color="linear-gradient(to right, rgb(66, 83, 216), rgb(213, 51, 186))"
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="渐变色按钮"
size="normal"
color="linear-gradient(to right, rgb(220, 194, 11), rgb(4, 151, 99))"
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="青绿色按钮"
size="normal"
color="rgb(10, 185, 156)"
></u-button>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义大小</text>
<view class="u-demo-block__content" style="padding-bottom: 15px; flex-direction: column;align-items: stretch;flex-wrap: nowrap;">
<u-button
text="超大尺寸"
size="large"
type="success"
></u-button>
</view>
<view class="u-demo-block__content">
<view class="u-page__button-item">
<u-button
text="普通尺寸"
size="normal"
type="error"
></u-button>
</view>
<view class="u-page__button-item">
<u-button
text="小型尺寸"
size="small"
type="primary"
></u-button>
</view>
<view class="u-page__button-item">
<u-button
class="button-layout__item"
text="超小尺寸"
size="mini"
type="warning"
></u-button>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// type: 'default',
// disabled: false
}
},
onLoad() {
setTimeout(() => {
this.type = 'primary'
this.disabled = true
}, 2000)
},
methods: {
click() {
console.log('click');
}
}
}
</script>
<style lang="scss">
.u-page {
&__button-item {
margin: 0 15px 15px 0;
}
}
.u-demo-block__content {
flex-direction: row;
flex-wrap: wrap;
align-items: center;
}
</style>

View File

@ -0,0 +1,201 @@
<template>
<view class="cell-page">
<view class="u-page__item">
<text class="u-page__item__title">基础功能</text>
<u-cell-group>
<u-cell
title="uView UI"
value="内容"
:isLink="true"
></u-cell>
<u-cell
title="利剑出鞘,一统江湖"
value="内容"
label="挣脱束缚,向往自由"
></u-cell>
</u-cell-group>
</view>
<view class="u-page__item">
<text class="u-page__item__title">自定义图标/图片</text>
<u-cell-group>
<u-cell
title="单元格"
icon="lock-fill"
></u-cell>
<u-cell
title="单元格"
icon="https://cdn.uviewui.com/uview/example/tag.png"
></u-cell>
</u-cell-group>
</view>
<view class="u-page__item">
<text class="u-page__item__title">自定义大小</text>
<u-cell-group>
<u-cell
size="large"
title="单元格"
value="内容"
isLink
></u-cell>
<u-cell
size="large"
title="单元格"
value="内容"
label="描述信息"
></u-cell>
</u-cell-group>
</view>
<view class="u-page__item">
<text class="u-page__item__title">显示右箭头</text>
<u-cell-group>
<u-cell
title="单元格"
value="组件"
isLink
></u-cell>
<u-cell
title="单元格"
value="工具"
arrow-direction="up"
isLink
></u-cell>
<u-cell
title="单元格"
value="模板"
arrow-direction="down"
isLink
></u-cell>
</u-cell-group>
</view>
<view class="u-page__item">
<text class="u-page__item__title">跳转页面</text>
<u-cell-group>
<u-cell
title="打开标签页"
isLink
url="/pages/componentsB/tag/tag"
></u-cell>
<u-cell
title="打开徽标页"
isLink
url="/pages/componentsB/badge/badge"
></u-cell>
</u-cell-group>
</view>
<view class="u-page__item">
<text class="u-page__item__title">右侧内容垂直居中</text>
<u-cell-group>
<u-cell
title="单元格"
value="内容"
label="描述信息"
center
></u-cell>
</u-cell-group>
</view>
<view class="u-page__item">
<text class="u-page__item__title">自定义插槽</text>
<u-cell-group>
<u-cell value="内容">
<view
slot="title"
class="u-slot-title"
>
<text class="u-cell-text">单元格</text>
<u-tag
text="标签"
plain
size="mini"
type="warning"
>
</u-tag>
</view>
</u-cell>
<u-cell
title="单元格"
isLink
>
<text
slot="value"
class="u-slot-value"
>99</text>
</u-cell>
</u-cell-group>
</view>
<u-gap height="30"></u-gap>
</view>
</template>
<script>
export default {
data() {
return {}
},
methods: {
click() {
console.log('Cell is clicked.');
}
}
}
</script>
<style lang="scss">
.cell-page {
padding-bottom: 20px;
}
.cell-box {
&__title {
font-size: 14px;
color: rgb(143, 156, 162);
margin: 20px 0px 0px 15px;
}
&__block {
// background-color: #fff;
margin-top: 20px;
}
}
.u-page {
padding: 0;
&__item {
&__title {
color: $u-tips-color;
background-color: $u-bg-color;
padding: 15px;
font-size: 15px;
&__slot-title {
color: $u-primary;
font-size: 14px;
}
}
}
}
.u-slot-title {
@include flex;
flex-direction: row;
align-items: center;
}
.u-cell-text {
font-size: 15px;
line-height: 22px;
color: #303133;
margin-right: 5px;
}
.u-slot-value {
line-height: 17px;
text-align: center;
font-size: 10px;
padding: 0 5px;
height: 17px;
color: #FFFFFF;
border-radius: 100px;
background-color: #f56c6c;
}
</style>

View File

@ -0,0 +1,329 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基本案例</text>
<text class="u-block__title">苹果、香蕉和橙子哪个最甜?</text>
<view class="u-demo-block__content">
<view class="u-page__checkbox-item">
<u-checkbox-group
v-model="checkboxValue1"
placement="column"
@change="checkboxChange"
>
<u-checkbox
:customStyle="{marginBottom: '8px'}"
v-for="(item, index) in checkboxList1"
:key="index"
:label="item.name"
:name="item.name"
>
</u-checkbox>
</u-checkbox-group>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义形状</text>
<text class="u-block__title">中国四大名著是?</text>
<view class="u-demo-block__content">
<view class="u-page__checkbox-item">
<u-checkbox-group
v-model="checkboxValue2"
placement="column"
@change="checkboxChange"
shape="square"
>
<u-checkbox
:customStyle="{marginBottom: '8px'}"
v-for="(item, index) in checkboxList2"
:key="index"
:label="item.name"
:name="item.name"
>
</u-checkbox>
</u-checkbox-group>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">是否禁用</text>
<text class="u-block__title">下面什么东西不能吃?</text>
<view class="u-demo-block__content">
<view class="u-page__checkbox-item">
<u-checkbox-group
v-model="checkboxValue3"
placement="column"
@change="checkboxChange"
>
<u-checkbox
:customStyle="{marginBottom: '8px'}"
v-for="(item, index) in checkboxList3"
:key="index"
:label="item.name"
:name="item.name"
:disabled="index===0"
>
</u-checkbox>
</u-checkbox-group>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">是否禁止点击提示语选中复选框</text>
<text class="u-block__title">北宋四大家是谁?</text>
<view class="u-demo-block__content">
<view class="u-page__checkbox-item">
<u-checkbox-group
v-model="checkboxValue4"
placement="column"
@change="checkboxChange"
:labelDisabled="true"
>
<u-checkbox
:customStyle="{marginBottom: '8px'}"
v-for="(item, index) in checkboxList4"
:key="index"
:label="item.name"
:name="item.name"
>
</u-checkbox>
</u-checkbox-group>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义颜色</text>
<text class="u-block__title">哪个颜色最好看?</text>
<view class="u-demo-block__content">
<view class="u-page__checkbox-item">
<u-checkbox-group
v-model="checkboxValue5"
placement="column"
@change="checkboxChange"
activeColor="#19be6b"
>
<u-checkbox
:customStyle="{marginBottom: '8px'}"
v-for="(item, index) in checkboxList5"
:key="index"
:label="item.name"
:name="item.name"
>
</u-checkbox>
</u-checkbox-group>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">横向排列形式</text>
<text class="u-block__title">什么东西不能飞?</text>
<view class="u-demo-block__content">
<view class="u-page__checkbox-item">
<u-checkbox-group
v-model="checkboxValue6"
@change="checkboxChange"
>
<u-checkbox
:customStyle="{marginRight: '16px'}"
v-for="(item, index) in checkboxList6"
:key="index"
:label="item.name"
:name="item.name"
>
</u-checkbox>
</u-checkbox-group>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">横向两端排列形式</text>
<text class="u-block__title">什么东西不能吃?</text>
<view>
<view class="u-page__checkbox-item">
<u-checkbox-group
v-model="checkboxValue7"
@change="checkboxChange"
:borderBottom="true"
placement="column"
iconPlacement="right"
>
<u-checkbox
:customStyle="{marginBottom: '16px'}"
v-for="(item, index) in checkboxList7"
:key="index"
:label="item.name"
:name="item.name"
>
</u-checkbox>
</u-checkbox-group>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 基本案列数据
checkboxList1: [{
name: '苹果',
disabled: false
},
{
name: '香蕉',
disabled: false
},
{
name: '橙子',
disabled: false
}
],
// u-checkbox-group的v-model绑定的值如果设置为某个checkbox的name,就会被默认选中
checkboxValue1: ['苹果', '橙子'],
// 自定义形状数据
checkboxList2: [{
name: '西游记',
disabled: false
},
{
name: '红楼梦',
disabled: false
},
{
name: '三国演义',
disabled: false
},
{
name: '水浒传',
disabled: false
}
],
// u-checkbox-group的v-model绑定的值如果设置为某个checkbox的name,就会被默认选中
checkboxValue2: ['西游记', '红楼梦', '三国演义', '水浒传'],
// 是否禁用数据
checkboxList3: [{
name: '冬瓜',
disabled: false
},
{
name: '西瓜',
disabled: false
},
{
name: '黄瓜',
disabled: false
},
{
name: '傻瓜',
disabled: false
}
],
// u-checkbox-group的v-model绑定的值如果设置为某个checkbox的name,就会被默认选中
checkboxValue3: ['傻瓜'],
// 是否禁止点击提示语选中复选框数据
checkboxList4: [{
name: '黄庭坚',
disabled: false
},
{
name: '欧阳修',
disabled: false
},
{
name: '苏小宝',
disabled: false
},
{
name: '王安石',
disabled: false
}
],
// u-checkbox-group的v-model绑定的值如果设置为某个checkbox的name,就会被默认选中
checkboxValue4: ['黄庭坚', '欧阳修', '王安石'],
//自定义颜色数据
checkboxList5: [{
name: '红色',
disabled: false
},
{
name: '黄色',
disabled: false
},
{
name: '绿色',
disabled: false
},
{
name: '蓝色',
disabled: false
}
],
// u-checkbox-group的v-model绑定的值如果设置为某个checkbox的name,就会被默认选中
checkboxValue5: ['绿色'],
//横向排列形式数据
checkboxList6: [{
name: '小鸟',
disabled: false
},
{
name: '游艇',
disabled: false
},
{
name: '轮船',
disabled: false
},
{
name: '飞机',
disabled: false
}
],
// u-checkbox-group的v-model绑定的值如果设置为某个checkbox的name,就会被默认选中
checkboxValue6: ['游艇', '轮船'],
//横向两端排列形式
checkboxList7: [{
name: '汽车',
disabled: false
},
{
name: '蒸汽机',
disabled: false
},
{
name: '猪肉',
disabled: false
},
{
name: '抄手',
disabled: false
}
],
// u-checkbox-group的v-model绑定的值如果设置为某个checkbox的name,就会被默认选中
checkboxValue7: ['汽车', '蒸汽机'],
}
},
watch: {
checkboxValue1(newValue, oldValue) {
// console.log('v-model', newValue);
}
},
methods: {
checkboxChange(n) {
// console.log('change', n);
}
}
}
</script>
<style lang="scss">
.u-page {}
</style>

View File

@ -0,0 +1,82 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基本案例</text>
<view>
<u-divider text="分割线"></u-divider>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">是否虚线</text>
<view>
<u-divider
text="分割线"
:dashed="true"
></u-divider>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">是否细线</text>
<view>
<u-divider
text="分割线"
:hairline="true"
></u-divider>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">是否以点代替文字</text>
<view>
<u-divider
text="分割线"
:dot="true"
></u-divider>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">文本内容靠左</text>
<view>
<u-divider
text="分割线"
textPosition="left"
></u-divider>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">文本内容靠右</text>
<view>
<u-divider
text="分割线"
textPosition="right"
></u-divider>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义文本颜色</text>
<view>
<u-divider
text="分割线"
textColor="#2979ff"
lineColor="#2979ff"
></u-divider>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style lang="scss">
.u-divider {}
</style>

View File

@ -0,0 +1,143 @@
<template>
<view class="u-page">
<view class="u-page__top-box">
<text class="u-demo-block__title">演示效果</text>
</view>
<u-empty
:mode="mode"
:icon="imgList[mode]"
>
<u-button
size="small"
type="primary"
:style="{marginTop:10+'px'}"
v-if="mode=='car'"
text="查看更多商品"
>
</u-button>
</u-empty>
<div class="empty-select">
<u-cell
:titleStyle="{fontWeight: 500}"
@click="openImg(item.imgName)"
:title="item.title"
v-for="(item, index) in list"
:key="index"
isLink
>
<image
slot="icon"
class="u-cell-icon"
:src="item.iconUrl"
mode="widthFix"
></image>
</u-cell>
</div>
</view>
</template>
<script>
export default {
data() {
// 如果使用这些图片,请勿直接引入cdn.uviewui.com的资源,因为此资源路径随时会有变动
// 变动后,您将会访问图片失败,如有需要,您可以将这些图片上传到自己的oss或者服务器再使用
const baseUrl = 'http://cdn.uviewui.com/uview/empty/'
return {
mode: 'car',
imgList: {
car: baseUrl + 'car.png',
address: baseUrl + 'address.png',
comment: baseUrl + 'comment.png',
coupon: baseUrl + 'coupon.png',
data: baseUrl + 'data.png',
history: baseUrl + 'history.png',
list: baseUrl + 'list.png',
message: baseUrl + 'message.png',
news: baseUrl + 'news.png',
order: baseUrl + 'order.png',
page: baseUrl + 'page.png',
permission: baseUrl + 'permission.png',
search: baseUrl + 'search.png',
wifi: baseUrl + 'wifi.png',
},
list: [{
imgName: 'car',
title: '购物车为空(同时传入slot)',
iconUrl: 'https://cdn.uviewui.com/uview/demo/empty/car.png'
},
{
imgName: 'data',
title: '数据为空',
iconUrl: 'https://cdn.uviewui.com/uview/demo/empty/data.png'
}, {
imgName: 'comment',
title: '评论为空',
iconUrl: 'https://cdn.uviewui.com/uview/demo/empty/comment.png'
}, {
imgName: 'coupon',
title: '没有优惠券',
iconUrl: 'https://cdn.uviewui.com/uview/demo/empty/coupon.png'
}, {
imgName: 'history',
title: '无历史记录',
iconUrl: 'https://cdn.uviewui.com/uview/demo/empty/history.png'
}, {
imgName: 'list',
title: '列表为空',
iconUrl: 'https://cdn.uviewui.com/uview/demo/empty/list.png'
}, {
imgName: 'message',
title: '消息列表为空',
iconUrl: 'https://cdn.uviewui.com/uview/demo/empty/message.png'
}, {
imgName: 'news',
title: '无新闻列表',
iconUrl: 'https://cdn.uviewui.com/uview/demo/empty/news.png'
}, {
imgName: 'order',
title: '订单为空',
iconUrl: 'https://cdn.uviewui.com/uview/demo/empty/order.png'
}, {
imgName: 'page',
title: '页面不存在',
iconUrl: 'https://cdn.uviewui.com/uview/demo/empty/page.png'
}, {
imgName: 'permission',
title: '无权限',
iconUrl: 'https://cdn.uviewui.com/uview/demo/empty/permission.png'
}, {
imgName: 'search',
title: '没有搜索结果',
iconUrl: 'https://cdn.uviewui.com/uview/demo/empty/search.png'
}, {
imgName: 'wifi',
title: '没有WiFi',
iconUrl: 'https://cdn.uviewui.com/uview/demo/empty/wifi.png'
},
]
}
},
methods: {
//点击改变图片
openImg(imgName) {
// this.mode = this.imgList[imgName]
this.mode = imgName;
}
}
}
</script>
<style lang="scss">
.u-page {
padding: 40rpx 0px;
&__top-box {
padding-left: 40rpx;
}
}
.empty-select {
margin-top: 10px;
}
</style>

View File

@ -0,0 +1,42 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基本案列</text>
<view class="u-page__gap-item">
<u-gap bgColor="#f3f4f6"></u-gap>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义颜色</text>
<view class="u-page__gap-item">
<u-gap bgColor="#2979ff"></u-gap>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义高度</text>
<view class="u-page__gap-item">
<u-gap bgColor="#f3f4f6" height="40"></u-gap>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义上下边距</text>
<view class="u-page__gap-item">
<u-gap
bgColor="#f3f4f6"
marginTop="20"
marginBottom="20"
></u-gap>
</view>
</view>
</view>
</template>
<script>
export default {
}
</script>
<style lang="scss">
</style>

View File

@ -0,0 +1,194 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基本案例</text>
<view>
<u-grid
:border="false"
@click="click"
align="center"
>
<u-grid-item
v-for="(baseListItem,baseListIndex) in baseList"
:key="baseListIndex"
>
<u-icon
:customStyle="{paddingTop:20+'rpx'}"
:name="baseListItem.name"
:size="22"
></u-icon>
<text class="grid-text">{{baseListItem.title}}</text>
</u-grid-item>
</u-grid>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">显示边框</text>
<view>
<u-grid :border="true">
<u-grid-item
v-for="(listItem,listIndex) in list"
:key="listIndex"
customStyle="padding-top: 10px; padding-bottom: 10px"
>
<u-icon
:customStyle="{paddingTop:20+'rpx'}"
:name="listItem.name"
:size="22"
></u-icon>
<text class="grid-text">{{listItem.title}}</text>
</u-grid-item>
</u-grid>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">绑定点击事件&自定义列数</text>
<view>
<u-grid
:border="false"
col="4"
>
<u-grid-item
v-for="(listItem,listIndex) in list"
:key="listIndex"
customStyle="padding-top: 10px; padding-bottom: 10px"
>
<u-icon
:customStyle="{paddingTop:20+'rpx'}"
:name="listItem.name"
:size="22"
></u-icon>
<text class="grid-text">{{listItem.title}}</text>
</u-grid-item>
</u-grid>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">可滑动</text>
<view>
<swiper
:indicator-dots="true"
class="swiper"
>
<swiper-item>
<u-grid :border="true">
<u-grid-item
v-for="(item, index) in swiperList"
:index="index"
:key="index"
>
<u-icon
:customStyle="{paddingTop:20+'rpx'}"
:name="item"
:size="22"
></u-icon>
<text class="grid-text">{{ '宫格' + (index + 1) }}</text>
</u-grid-item>
</u-grid>
</swiper-item>
<swiper-item>
<u-grid :border="true">
<u-grid-item
v-for="(item, index) in swiperList"
:index="index + 9"
:key="index"
>
<u-icon
:customStyle="{paddingTop:20+'rpx'}"
:name="item"
:size="22"
></u-icon>
<text class="grid-text">{{ '宫格' + (index + 1) }}</text>
</u-grid-item>
</u-grid>
</swiper-item>
<swiper-item>
<u-grid :border="true">
<u-grid-item
v-for="(item, index) in swiperList"
:index="index + 18"
:key="index"
>
<u-icon
:customStyle="{paddingTop:20+'rpx'}"
:name="item"
:size="22"
></u-icon>
<text class="grid-text">{{ "宫格" + (index + 1) }}</text>
</u-grid-item>
</u-grid>
</swiper-item>
</swiper>
</view>
</view>
<u-toast ref="uToast" />
</view>
</template>
<script>
export default {
data() {
return {
baseList: [{
name: 'photo',
title: '图片'
},
{
name: 'lock',
title: '锁头'
},
// {
// name: 'star',
// title: '星星'
// },
],
list: [{
name: 'photo',
title: '图片'
},
{
name: 'lock',
title: '锁头'
},
{
name: 'star',
title: '星星'
},
{
name: 'hourglass',
title: '沙漏'
},
{
name: 'home',
title: '首页'
},
{
name: 'volume',
title: '音量'
},
],
swiperList: ['integral', 'kefu-ermai', 'coupon', 'gift', 'scan', 'pause-circle', 'wifi', 'email', 'list'],
}
},
methods: {
click(name) {
this.$refs.uToast.success(`点击了第${name}个`)
}
}
}
</script>
<style lang="scss">
.swiper {
height: 220px;
}
.grid-text {
font-size: 14px;
color: #909399;
padding: 10rpx 0 20rpx 0rpx;
/* #ifndef APP-PLUS */
box-sizing: border-box;
/* #endif */
}
</style>

View File

@ -0,0 +1,664 @@
<template>
<view class="u-page">
<view class="u-border-left u-border-top u-page__grid">
<view
@tap="selectIcon(item.name)"
class="u-page__grid__item u-border-bottom u-border-right"
v-for="(item, index) in iconList"
:key="index"
>
<view class="u-page__grid__item__icon">
<u-icon
:name="item.name"
size="30"
color="#909399"
></u-icon>
</view>
<text class="u-page__grid__item__text">{{item.name}}</text>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
iconList: [{
name: 'level'
},
{
name: 'woman'
},
{
name: 'man'
},
{
name: 'arrow-left-double'
},
{
name: 'arrow-right-double'
},
{
name: 'chat'
},
{
name: 'chat-fill'
},
{
name: 'red-packet'
},
{
name: 'red-packet-fill'
},
{
name: 'order'
},
{
name: 'checkbox-mark'
},
{
name: 'arrow-up-fill'
},
{
name: 'arrow-down-fill'
},
{
name: 'backspace'
},
{
name: 'photo'
},
{
name: 'photo-fill'
},
{
name: 'lock'
},
{
name: 'lock-fill'
},
{
name: 'lock-open'
},
{
name: 'lock-opened-fill'
},
{
name: 'hourglass'
},
{
name: 'hourglass-half-fill'
},
{
name: 'home'
},
{
name: 'home-fill'
},
{
name: 'fingerprint'
},
{
name: 'cut'
},
{
name: 'star'
},
{
name: 'star-fill'
},
{
name: 'share'
},
{
name: 'share-fill'
},
{
name: 'volume'
},
{
name: 'volume-fill'
},
{
name: 'volume-off'
},
{
name: 'volume-off-fill'
},
{
name: 'trash'
},
{
name: 'trash-fill'
},
{
name: 'rewind-right'
},
{
name: 'rewind-right-fill'
},
{
name: 'rewind-left'
},
{
name: 'rewind-left-fill'
},
{
name: 'shopping-cart'
},
{
name: 'shopping-cart-fill'
},
{
name: 'question'
},
{
name: 'question-circle'
},
{
name: 'question-circle-fill'
},
{
name: 'plus'
},
{
name: 'plus-circle'
},
{
name: 'plus-circle-fill'
},
{
name: 'tags'
},
{
name: 'tags-fill'
},
{
name: 'pause'
},
{
name: 'pause-circle'
},
{
name: 'pause-circle-fill'
},
{
name: 'play-circle'
},
{
name: 'play-circle-fill'
},
{
name: 'map'
},
{
name: 'map-fill'
},
{
name: 'phone'
},
{
name: 'phone-fill'
},
{
name: 'list'
},
{
name: 'list-dot'
},
{
name: 'man-delete'
},
{
name: 'man-add'
},
{
name: 'man-add-fill'
},
{
name: 'person-delete-fill'
},
{
name: 'info'
},
{
name: 'info-circle'
},
{
name: 'info-circle-fill'
},
{
name: 'minus'
},
{
name: 'minus-circle'
},
{
name: 'minus-circle-fill'
},
{
name: 'mic'
},
{
name: 'mic-off'
},
{
name: 'grid'
},
{
name: 'grid-fill'
},
{
name: 'eye'
},
{
name: 'eye-fill'
},
{
name: 'eye-off'
},
{
name: 'file-text'
},
{
name: 'file-text-fill'
},
{
name: 'edit-pen'
},
{
name: 'edit-pen-fill'
},
{
name: 'email'
},
{
name: 'email-fill'
},
{
name: 'download'
},
{
name: 'checkmark'
},
{
name: 'checkmark-circle'
},
{
name: 'checkmark-circle-fill'
},
{
name: 'clock'
},
{
name: 'clock-fill'
},
{
name: 'close'
},
{
name: 'close-circle'
},
{
name: 'close-circle-fill'
},
{
name: 'calendar'
},
{
name: 'calendar-fill'
},
{
name: 'car'
},
{
name: 'car-fill'
},
{
name: 'bell'
},
{
name: 'bell-fill'
},
{
name: 'bookmark'
},
{
name: 'bookmark-fill'
},
{
name: 'attach'
},
{
name: 'play-right'
},
{
name: 'play-right-fill'
},
{
name: 'play-left'
},
{
name: 'play-left-fill'
},
{
name: 'error'
},
{
name: 'error-circle'
},
{
name: 'error-circle-fill'
},
{
name: 'wifi'
},
{
name: 'wifi-off'
},
{
name: 'skip-back-left'
},
{
name: 'skip-forward-right'
},
{
name: 'search'
},
{
name: 'setting'
},
{
name: 'setting-fill'
},
{
name: 'more-dot-fill'
},
{
name: 'more-circle'
},
{
name: 'more-circle-fill'
},
{
name: 'bag'
},
{
name: 'bag-fill'
},
{
name: 'arrow-upward'
},
{
name: 'arrow-downward'
},
{
name: 'arrow-leftward'
},
{
name: 'arrow-rightward'
},
{
name: 'arrow-up'
},
{
name: 'arrow-down'
},
{
name: 'arrow-left'
},
{
name: 'arrow-right'
},
{
name: 'rmb'
},
{
name: 'rmb-circle'
},
{
name: 'rmb-circle-fill'
},
{
name: 'thumb-up'
},
{
name: 'thumb-up-fill'
},
{
name: 'thumb-down'
},
{
name: 'thumb-down-fill'
},
{
name: 'coupon'
},
{
name: 'coupon-fill'
},
{
name: 'kefu-ermai'
},
{
name: 'server-fill'
},
{
name: 'server-man'
},
{
name: 'scan'
},
{
name: 'warning'
},
{
name: 'warning-fill'
},
{
name: 'google'
},
{
name: 'google-circle-fill'
},
{
name: 'chrome-circle-fill'
},
{
name: 'ie'
},
{
name: 'IE-circle-fill'
},
{
name: 'github-circle-fill'
},
{
name: 'android-fill'
},
{
name: 'android-circle-fill'
},
{
name: 'apple-fill'
},
{
name: 'camera'
},
{
name: 'camera-fill'
},
{
name: 'pushpin'
},
{
name: 'pushpin-fill'
},
{
name: 'minus-square-fill'
},
{
name: 'plus-square-fill'
},
{
name: 'heart'
},
{
name: 'heart-fill'
},
{
name: 'reload'
},
{
name: 'account'
},
{
name: 'account-fill'
},
{
name: 'minus-people-fill'
},
{
name: 'plus-people-fill'
},
{
name: 'integral'
},
{
name: 'integral-fill'
},
{
name: 'zhihu'
},
{
name: 'zhihu-circle-fill'
},
{
name: 'gift'
},
{
name: 'gift-fill'
},
{
name: 'zhifubao'
},
{
name: 'zhifubao-circle-fill'
},
{
name: 'weixin-fill'
},
{
name: 'weixin-circle-fill'
},
{
name: 'twitter'
},
{
name: 'twitter-circle-fill'
},
{
name: 'taobao'
},
{
name: 'taobao-circle-fill'
},
{
name: 'weibo'
},
{
name: 'weibo-circle-fill'
},
{
name: 'qq-fill'
},
{
name: 'qq-circle-fill'
},
{
name: 'moments'
},
{
name: 'moments-circel-fill'
},
{
name: 'qzone'
},
{
name: 'qzone-circle-fill'
},
{
name: 'facebook'
},
{
name: 'facebook-circle-fill'
},
{
name: 'baidu'
},
{
name: 'baidu-circle-fill'
},
{
name: 'share-square'
},
]
};
},
methods: {
selectIcon(name) {
// #ifdef H5
return uni.$u.toast('H5暂不支持复制');
// #endif
uni.setClipboardData({
data: name,
success: () => {
}
});
uni.hideToast()
uni.$u.toast('图标名称已复制');
}
}
}
</script>
<style lang="scss">
.u-page {
padding: 14rpx;
&__grid {
@include flex(row);
flex-wrap: wrap;
&__item {
@include flex(column);
align-items: center;
justify-content: center;
height: 240rpx;
width: 240rpx;
padding: 0 5px;
&__icon {
height: 130rpx;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: flex-end;
}
&__text {
color: $u-tips-color;
/* #ifndef APP-NVUE */
word-wrap: break-word;
word-break: break-all;
/* #endif */
font-size: 14px;
height: 110rpx;
}
}
}
}
</style>

View File

@ -0,0 +1,99 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基本案例</text>
<view class="u-demo-block__content">
<view class="u-page__image-item">
<u--image
:showLoading="true"
:src="src"
width="80px"
height="80px"
@click="click"
></u--image>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义形状</text>
<view class="u-demo-block__content">
<view class="u-page__image-item">
<u--image
shape="circle"
:src="src"
width="80px"
height="80px"
></u--image>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义圆角</text>
<view class="u-demo-block__content">
<view class="u-page__image-item">
<u--image
radius="4"
:src="src"
width="80px"
height="80px"
></u--image>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">图片模式(widthFit)</text>
<view class="u-demo-block__content">
<view class="u-page__image-item">
<u--image
:src="src"
width="80px"
height="80px"
mode="widthFit"
></u--image>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义图片加载插槽</text>
<view class="u-demo-block__content">
<view class="u-page__image-item">
<u--image
:src="src1"
width="80px"
height="80px"
mode="widthFit"
>
<template v-slot:loading>
<u-loading-icon color="red"></u-loading-icon>
</template>
</u--image>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
src: 'https://cdn.uviewui.com/uview/album/1.jpg',
src1:''
}
},
onLoad() {
setTimeout(()=>{
this.src1 = this.src
},3000)
},
methods: {
click() {
console.log('click');
}
}
}
</script>
<style lang="scss">
</style>

View File

@ -0,0 +1,74 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基本案例</text>
<view class="u-page__line-item">
<u-line></u-line>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义颜色</text>
<view class="u-page__line-item">
<u-line color="#2979ff"></u-line>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义长度</text>
<view class="u-page__line-item">
<u-line length="200"></u-line>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义方向</text>
<view class="u-page__line-item">
<u-line
length="30"
color="#2979ff"
direction="col"
></u-line>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">是否显示1px粗线条</text>
<view class="u-page__line-item">
<u-line :hairline="false"></u-line>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">线条与上下左右元素的间距</text>
<view class="u-page__line-item">
<u-line margin="20"></u-line>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">是否虚线</text>
<view class="u-page__line-item">
<u-line
color="#2979ff"
:dashed="true"
></u-line>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style lang="scss">
.u-page{
&__line-item{
margin-top:5px;
}
}
</style>

View File

@ -0,0 +1,75 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基本案例</text>
<view class="u-demo-block__content">
<view class="u-page__link-item">
<u-link
href="https://uviewui.com/"
text="打开uView UI文档"
@click="click"
></u-link>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">显示下划线</text>
<view class="u-demo-block__content">
<view class="u-page__link-item">
<u-link
href="https://uviewui.com/"
:underLine="true"
text="Go to uView doc"
></u-link>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义颜色</text>
<view class="u-demo-block__content">
<view class="u-page__link-item">
<u-link
href="https://uviewui.com/"
lineColor="#19be6b"
color="#19be6b"
text="打开uView UI文档"
></u-link>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义链接内容</text>
<view class="u-demo-block__content">
<view class="u-page__link-item">
<u-link
href="https://uniapp.dcloud.io/"
text="打开uni-app文档"
></u-link>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
click() {
console.log('click');
}
}
}
</script>
<style lang="scss">
.u-page {
&__link-item {
margin-top: 5px;
}
}
</style>

View File

@ -0,0 +1,79 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基本案列</text>
<view class="u-demo-block__content">
<view class="u-page__loading-item">
<u-loading-icon></u-loading-icon>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">半圆loading</text>
<view class="u-demo-block__content">
<view class="u-page__loading-item">
<u-loading-icon mode="semicircle"></u-loading-icon>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">圆形loading</text>
<view class="u-demo-block__content">
<view class="u-page__loading-item">
<u-loading-icon mode="circle"></u-loading-icon>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义动画</text>
<view class="u-demo-block__content">
<view class="u-page__loading-item">
<u-loading-icon mode="circle" timingFunction="linear"></u-loading-icon>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义颜色</text>
<view class="u-demo-block__content">
<view class="u-page__loading-item">
<u-loading-icon color="#19be6b"></u-loading-icon>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义文字</text>
<view class="u-demo-block__content">
<view class="u-page__loading-item">
<u-loading-icon
:vertical="true"
text="加载中"
></u-loading-icon>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
}
}
</script>
<style lang="scss">
.u-page {
&__loading-item {
margin-top: 5px;
}
}
.u-demo-block__content {
flex-direction: row;
flex-wrap: wrap;
align-items: center;
}
</style>

View File

@ -0,0 +1,132 @@
<template>
<view class="u-page">
<u-navbar
title="加载页"
@leftClick="navigateBack"
safeAreaInsetTop
fixed
placeholder
></u-navbar>
<u-gap
bgColor="#fff"
height="20"
></u-gap>
<u-cell-group>
<u-cell
:titleStyle="{fontWeight: 500}"
@click="openLoadingPage(index)"
:title="item.title"
v-for="(item, index) in list"
:key="index"
isLink
>
<image
slot="icon"
class="u-cell-icon"
:src="item.iconUrl"
mode="widthFix"
></image>
</u-cell>
</u-cell-group>
<u-loading-page
:loadingText="loadingPageData.loadingText"
:image="loadingPageData.image"
:iconSize="loadingPageData.iconSize"
:loadingMode="loadingPageData.loadingMode"
:bgColor="loadingPageData.bgColor"
:loading="loading"
:color="loadingPageData.color"
:loadingColor="loadingPageData.loadingColor"
>
</u-loading-page>
</view>
</template>
<script>
export default {
data() {
return {
loading: false,
loadingPageData: {
// 自定义提示内容
loadingText: '',
// 自定义图片
image: '',
// 自定义加载动画模式
loadingMode: '',
// 自定义背景色
bgColor: '#ffffff',
},
list: [{
title: '自定义提示内容',
iconUrl: 'https://cdn.uviewui.com/uview/demo/loading-page/promptContent.png',
},
{
title: '自定义图片',
iconUrl: 'https://cdn.uviewui.com/uview/demo/loading-page/customPicture.png',
},
{
title: '自定义加载动画模式',
iconUrl: 'https://cdn.uviewui.com/uview/demo/loading-page/customMode.png',
},
{
title: '自定义背景色',
iconUrl: 'https://cdn.uviewui.com/uview/demo/loading-page/customBgColor.png',
},
]
}
},
methods: {
navigateBack() {
uni.navigateBack()
},
openLoadingPage(indexNum) {
this.loadingPageData = {
loadingText: '',
image: '',
loadingMode: '',
bgColor: '#ffffff',
iconSize: 28
}
if (indexNum == 0) {
//自定义提示内容
this.loadingPageData.loadingMode = 'semicircle'
this.loadingPageData.loadingText = "Hello uView"
this.loadingPageData.color = '#C8C8C8'
this.loadingPageData.loadingColor = '#C8C8C8'
} else if (indexNum == 1) {
// 自定义图片
this.loadingPageData.image = "/static/uview/common/logo.png"
this.loadingPageData.loadingText = "uView UI"
this.loadingPageData.iconSize = 40
this.loadingPageData.color = '#C8C8C8'
this.loadingPageData.loadingColor = '#C8C8C8'
} else if (indexNum == 2) {
// 自定义加载动画模式
this.loadingPageData.loadingMode = 'circle'
this.loadingPageData.loadingText = "uView UI"
this.loadingPageData.color = '#C8C8C8'
this.loadingPageData.loadingColor = '#C8C8C8'
} else if (indexNum == 3) {
// 自定义背景色
this.loadingPageData.loadingMode = 'spinner'
this.loadingPageData.bgColor = 'rgba(0, 0, 0, 0.3)'
this.loadingPageData.loadingText = "uView UI"
this.loadingPageData.color = '#eee'
this.loadingPageData.loadingColor = '#ddd'
}
this.loading = true
setTimeout(() => {
this.loading = false
}, 2000)
}
}
}
</script>
<style lang="scss">
.u-page {
padding: 0;
}
</style>

View File

@ -0,0 +1,103 @@
<template>
<view class="u-page">
<u-navbar
title="遮罩层"
@leftClick="navigateBack"
safeAreaInsetTop
fixed
placeholder
></u-navbar>
<u-cell
:titleStyle="{fontWeight: 500}"
@click="openMask(index)"
:title="item.title"
v-for="(item, index) in list"
:key="index"
isLink
>
<image
slot="icon"
class="u-cell-icon"
:src="item.iconUrl"
mode="widthFix"
></image>
</u-cell>
<u-overlay
:show="show"
@click="show = !show"
></u-overlay>
<u-overlay
:show="showSlot"
@click="showSlot = !showSlot"
>
<view class="overlay-wrap">
<view class="overlay-wrap__box"></view>
</view>
</u-overlay>
<u-overlay
opacity=".85"
:show="showOpcatiy"
@click="showOpcatiy = !showOpcatiy"
>
</u-overlay>
</view>
</template>
<script>
export default {
data() {
return {
show: false,
showSlot: false,
showOpcatiy: false,
list: [{
title: '基本案列',
iconUrl: 'https://cdn.uviewui.com/uview/demo/overlay/baseCases.png'
},
{
title: '嵌入内容',
iconUrl: 'https://cdn.uviewui.com/uview/demo/overlay/embeddedContent.png'
},
{
title: '设置透明度',
iconUrl: 'https://cdn.uviewui.com/uview/demo/overlay/setTransparency.png'
},
]
}
},
methods: {
openMask(indexNum) {
if (indexNum == 0) {
this.show = !this.show;
} else if (indexNum == 1) {
this.showSlot = !this.showSlot
} else if (indexNum == 2) {
this.showOpcatiy = !this.showOpcatiy
}
},
navigateBack() {
uni.navigateBack()
}
}
}
</script>
<style lang="scss">
.u-page {
padding: 0;
}
.overlay-wrap {
@include flex;
justify-content: center;
align-items: center;
flex: 1;
&__box {
width: 200rpx;
height: 200rpx;
background-color: #70e1f5;
}
}
</style>

View File

@ -0,0 +1,182 @@
<template>
<view>
<u-navbar
title="弹窗"
@leftClick="navigateBack"
safeAreaInsetTop
fixed
placeholder
></u-navbar>
<u-gap
height="20"
bgColor="#fff"
></u-gap>
<u-cell-group>
<u-cell
:titleStyle="{fontWeight: 500}"
@click="openPopup(item.popupData)"
:title="item.title"
v-for="(item, index) in list"
:key="index"
isLink
>
<image
slot="icon"
class="u-cell-icon"
:src="item.iconUrl"
mode="widthFix"
></image>
</u-cell>
</u-cell-group>
<u-popup
:safeAreaInsetBottom="true"
:safeAreaInsetTop="true"
:mode="popupData.mode"
:show="show"
:round="popupData.round"
:overlay="popupData.overlay"
:borderRadius="popupData.borderRadius"
:closeable="popupData.closeable"
:closeOnClickOverlay="popupData.closeOnClickOverlay"
@close="close"
@open="open"
>
<view
class="u-popup-slot"
:style="{
width: ['bottom', 'top'].includes(popupData.mode) ? '750rpx' : '200px',
marginTop: ['left', 'right'].includes(popupData.mode) ? '480rpx' : '0',
}"
>
<u-button
type="success"
text="点我关闭"
customStyle="width: 200rpx"
@click="show = !show"
></u-button>
</view>
</u-popup>
</view>
</template>
<script>
export default {
data() {
return {
show: false,
popupData: {
overlay: true,
mode: 'bottom',
borderRadius: '',
closeable: true,
closeOnClickOverlay: true
},
list: [{
popupData: {
overlay: true,
mode: 'top',
closeOnClickOverlay: true
},
title: '顶部弹出',
iconUrl: 'https://cdn.uviewui.com/uview/demo/popup/modeTop.png'
},
{
popupData: {
overlay: true,
mode: 'right',
closeOnClickOverlay: true
},
title: '右侧弹出',
iconUrl: 'https://cdn.uviewui.com/uview/demo/popup/modeRight.png'
},
{
popupData: {
overlay: true,
mode: 'bottom',
closeOnClickOverlay: true
},
title: '底部弹出',
iconUrl: 'https://cdn.uviewui.com/uview/demo/popup/modeBottom.png'
},
{
popupData: {
overlay: true,
mode: 'left',
closeOnClickOverlay: true
},
title: '左侧弹出',
iconUrl: 'https://cdn.uviewui.com/uview/demo/popup/modeLeft.png'
},
{
popupData: {
overlay: true,
mode: 'center',
round: 10,
closeOnClickOverlay: true
},
title: '居中弹出',
iconUrl: 'https://cdn.uviewui.com/uview/demo/popup/modeCenter.png'
},
{
popupData: {
overlay: true,
mode: 'bottom',
round: 10,
closeOnClickOverlay: true
},
title: '显示圆角',
iconUrl: 'https://cdn.uviewui.com/uview/demo/popup/showRadis.png'
},
{
popupData: {
overlay: true,
mode: 'bottom',
closeable: false,
closeOnClickOverlay: false
},
title: '禁止点击遮罩关闭',
iconUrl: 'https://cdn.uviewui.com/uview/demo/popup/noClose.png'
},
{
popupData: {
overlay: true,
mode: 'bottom',
closeable: true,
closeOnClickOverlay: true
},
title: '显示关闭按钮',
iconUrl: 'https://cdn.uviewui.com/uview/demo/popup/showCloseBtn.png'
}
]
}
},
methods: {
openPopup(popupData) {
this.popupData = popupData
uni.$u.sleep().then(() => {
this.show = !this.show
})
},
navigateBack() {
uni.navigateBack()
},
open() {
// console.log('open');
},
close() {
this.show = false
// console.log('close');
}
}
}
</script>
<style lang="scss">
.u-popup-slot {
width: 200px;
height: 150px;
@include flex;
justify-content: center;
align-items: center;
}
</style>

View File

@ -0,0 +1,330 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基本案例</text>
<text class="u-block__title">苹果、香蕉和橙子哪个最甜?</text>
<view class="u-demo-block__content">
<view class="u-page__radio-item">
<u-radio-group
v-model="radiovalue1"
placement="column"
@change="groupChange"
>
<u-radio
:customStyle="{marginBottom: '8px'}"
v-for="(item, index) in radiolist1"
:key="index"
:label="item.name"
:name="item.name"
@change="radioChange"
>
</u-radio>
</u-radio-group>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义形状</text>
<text class="u-block__title">王者荣耀谁最帅?</text>
<view class="u-demo-block__content">
<view class="u-page__radio-item">
<u-radio-group
v-model="radiovalue2"
placement="column"
shape="square"
>
<u-radio
:customStyle="{marginBottom: '8px'}"
v-for="(item, index) in radiolist2"
:key="index"
:label="item.name"
:name="item.name"
>
</u-radio>
</u-radio-group>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">是否禁用</text>
<text class="u-block__title">苹果、香蕉和菠萝哪个最甜?</text>
<view class="u-demo-block__content">
<view class="u-page__radio-item">
<u-radio-group
v-model="radiovalue3"
placement="column"
>
<u-radio
:customStyle="{marginBottom: '8px'}"
v-for="(item, index) in radiolist3"
:key="index"
:label="item.name"
:name="item.name"
:disabled="!index"
>
</u-radio>
</u-radio-group>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">纵向排列</text>
<text class="u-block__title">狙击枪用哪个倍镜最好?</text>
<view class="u-demo-block__content">
<view class="u-page__radio-item">
<u-radio-group
v-model="radiovalue4"
placement="column"
:labelDisabled="true"
>
<u-radio
:customStyle="{marginBottom:'8px'}"
v-for="(item, index) in radiolist4"
:key="index"
:label="item.name"
:name="item.name"
>
</u-radio>
</u-radio-group>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义颜色?</text>
<text class="u-block__title">你比较喜欢下面哪个颜色?</text>
<view class="u-demo-block__content">
<view class="u-page__radio-item">
<u-radio-group
v-model="radiovalue5"
placement="column"
activeColor="#19be6b"
>
<u-radio
:customStyle="{marginBottom: '8px'}"
v-for="(item, index) in radiolist5"
:key="index"
:label="item.name"
:name="item.name"
>
</u-radio>
</u-radio-group>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">横向排列形式?</text>
<text class="u-block__title">王者荣耀哪个英雄最美?</text>
<view class="u-demo-block__content">
<view class="u-page__radio-item">
<u-radio-group
v-model="radiovalue6"
placement="row"
>
<u-radio
:customStyle="{marginRight: '16px'}"
v-for="(item, index) in radiolist6"
:key="index"
:label="item.name"
:name="item.name"
>
</u-radio>
</u-radio-group>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">横向两端排列形式?</text>
<text class="u-block__title">你觉得阿木木可爱吗?</text>
<view>
<view class="u-page__radio-item">
<u-radio-group
v-model="radiovalue7"
:borderBottom="true"
placement="column"
iconPlacement="right"
>
<u-radio
:customStyle="{marginBottom: '16px'}"
v-for="(item, index) in radiolist7"
:key="index"
:label="item.name"
:name="item.name"
>
</u-radio>
</u-radio-group>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 基本案列数据
radiolist1: [{
name: '苹果',
disabled: false
},
{
name: '香蕉',
disabled: false
},
{
name: '橙子',
disabled: false
}, {
name: '榴莲',
disabled: false
}
],
// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
radiovalue1: '苹果',
// 自定义形状数据
radiolist2: [{
name: '李白',
disabled: false
},
{
name: '韩信',
disabled: false
},
{
name: '马可波罗',
disabled: false
}, {
name: '百里守约',
disabled: false
}
],
// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
radiovalue2: '李白',
// 是否禁用数据
radiolist3: [{
name: '苹果',
disabled: false
},
{
name: '香蕉',
disabled: false
},
{
name: '菠萝',
disabled: false
}
],
// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
radiovalue3: '苹果',
// 是否禁止点击提示语选中单选框数据
radiolist4: [{
name: '3倍镜',
disabled: false
},
{
name: '4倍镜',
disabled: false
},
{
name: '6倍镜',
disabled: false
},
{
name: '8倍镜',
disabled: false
}
],
// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
radiovalue4: '6倍镜',
//自定义颜色数据
radiolist5: [{
name: '红色',
disabled: false
},
{
name: '绿色',
disabled: false
},
{
name: '蓝色',
disabled: false
},
{
name: '黄色',
disabled: false
}
],
// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
radiovalue5: '绿色',
//横向排列形式数据
radiolist6: [{
name: '妲己',
disabled: false
},
{
name: '虞姬',
disabled: false
},
{
name: '不知火舞',
disabled: false
},
],
// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
radiovalue6: '妲己',
//横向两端排列形式数据
radiolist7: [{
name: '可爱',
disabled: false
},
{
name: '一般',
disabled: false
},
{
name: '不可爱',
disabled: false
},
],
// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
radiovalue7: '可爱',
}
},
watch: {
radiovalue1(newValue, oldValue) {
console.log('v-model', newValue);
}
},
methods: {
groupChange(n) {
console.log('groupChange', n);
},
radioChange(n) {
console.log('radioChange', n);
}
}
}
</script>
<style lang="scss">
.u-page {
&__style {
font-size: 16px;
color: rgb(96, 98, 102);
margin-bottom: 20rpx;
font-weight: bold;
}
&__title {
font-size: 16px;
color: rgb(96, 98, 102);
margin-bottom: 20rpx;
}
}
</style>

View File

@ -0,0 +1,146 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基本案例</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-rate size="20"></u-rate>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义选中星星数量</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-rate
size="20"
v-model="value"
@change="change"
></u-rate>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义星星大小</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-rate size="30" count="4"></u-rate>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">是否禁用评分</text>
<view class="u-demo-block__content">
<view class="u-page__rate-item">
<u-rate size="20" disabled></u-rate>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">是否只读评分</text>
<view class="u-demo-block__content">
<view class="u-page__rate-item">
<u-rate size="20" readonly></u-rate>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义选中星星颜色</text>
<view class="u-demo-block__content">
<view class="u-page__rate-item">
<u-rate
size="20"
v-model="activeColorValue"
activeColor="#2979ff"
></u-rate>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义未选中星星颜色</text>
<view class="u-demo-block__content">
<view class="u-page__rate-item">
<u-rate
size="20"
v-model="value1"
inactiveColor="#2979ff"
></u-rate>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">禁止触摸选择</text>
<view class="u-demo-block__content">
<view class="u-page__rate-item">
<u-rate size="20" :touchable="false"></u-rate>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">允许触摸选择</text>
<view class="u-demo-block__content">
<view class="u-page__rate-item">
<u-rate size="20" :touchable="true"></u-rate>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">是否允许半星</text>
<view class="u-demo-block__content">
<view class="u-page__rate-item">
<u-rate
size="20"
v-model="HalfValue"
:allowHalf="true"
@change="change"
></u-rate>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义选中的图标</text>
<view class="u-demo-block__content">
<view class="u-page__rate-item">
<u-rate
size="20"
v-model="activeIconValue"
inactiveIcon="heart"
activeIcon="heart-fill"
></u-rate>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
//自定义星星的个数
value: 3,
value1: 2,
// 自定义选择星星颜色个数
activeColorValue: 3,
// 是否允许半星的个数
HalfValue: 3.5,
// 自定义图标星星个数
activeIconValue: 3,
}
},
watch: {
value(newValue, oldValue) {
// console.log(newValue);
}
},
methods: {
change(e) {
// console.log('change', e);
}
},
}
</script>
<style lang="scss">
.u-page {}
</style>

View File

@ -0,0 +1,57 @@
<template>
<view class="u-page">
<!-- <u-navbar
title="吸顶"
@leftClick="navigateBack"
safeAreaInsetTop
fixed
placeholder
></u-navbar> -->
<view class="u-demo-block">
<text class="u-demo-block__title">基础使用</text>
<u--text
type="content"
text="滚动页面,即可看到下方的按钮会吸顶。"
></u--text>
<!-- #ifdef APP-NVUE -->
<u--text
type="warning"
text="目前由于nvue的bug,设置sticky的top值无效。"
></u--text>
<!-- #endif -->
</view>
<u-sticky>
<u-button
text="吸顶按钮"
type="success"
></u-button>
</u-sticky>
<u-gap
bgColor="#fff"
height="1500px"
></u-gap>
<u-divider text="已到底部"></u-divider>
</view>
</template>
<script>
export default {
data() {
return {
}
},
mixins: [uni.$u.mixin],
methods: {
navigateBack() {
uni.navigateBack()
}
}
}
</script>
<style lang="scss">
.u-page {
}
</style>

View File

@ -0,0 +1,228 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">演示案例</text>
<view class="u-page__swipe-action-item">
<u-swipe-action>
<u-swipe-action-item
v-if="show1"
:options="options1"
@click="click"
>
<view class="swipe-action u-border-top u-border-bottom">
<view class="swipe-action__content">
<text class="swipe-action__content__text">基础使用</text>
</view>
</view>
</u-swipe-action-item>
</u-swipe-action>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">按钮组</text>
<view class="u-page__swipe-action-item">
<u-swipe-action>
<u-swipe-action-item :options="options2">
<view class="swipe-action u-border-top u-border-bottom">
<view class="swipe-action__content">
<text class="swipe-action__content__text">两个按钮并列</text>
</view>
</view>
</u-swipe-action-item>
</u-swipe-action>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">带图标</text>
<view class="u-page__swipe-action-item">
<u-swipe-action>
<u-swipe-action-item :options="options3">
<view class="swipe-action u-border-top u-border-bottom">
<view class="swipe-action__content">
<text class="swipe-action__content__text">自定义图标</text>
</view>
</view>
</u-swipe-action-item>
</u-swipe-action>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">组合使用</text>
<view class="u-page__swipe-action-item">
<u-swipe-action>
<u-swipe-action-item
:options="item.options"
v-for="(item, index) in options4"
:disabled="item.disabled"
:key="index"
>
<view
class="swipe-action u-border-top"
:class="[index === options4.length - 1 && 'u-border-bottom']"
>
<view class="swipe-action__content">
<text class="swipe-action__content__text">{{ item.text }}</text>
</view>
</view>
</u-swipe-action-item>
</u-swipe-action>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义按钮形状</text>
<view class="u-page__swipe-action-item">
<u-swipe-action>
<u-swipe-action-item :options="options5">
<view class="swipe-action u-border-top u-border-bottom">
<view class="swipe-action__content">
<text class="swipe-action__content__text">圆形按钮</text>
</view>
</view>
</u-swipe-action-item>
</u-swipe-action>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
show1: true,
moveX: 0,
showText: '当前状态:关',
showStatus: false,
options1: [{
text: '删除',
style: {
backgroundColor: '#f56c6c'
}
}],
options2: [{
text: '收藏',
style: {
backgroundColor: '#3c9cff'
}
}, {
text: '删除',
style: {
backgroundColor: '#f56c6c'
}
}],
options3: [{
text: '收藏',
icon: 'star-fill',
iconSize: '20',
style: {
backgroundColor: '#f9ae3d'
}
}],
options4: [{
text: '禁用状态',
disabled: true,
options: [{
text: '置顶',
style: {
backgroundColor: '#3c9cff',
}
},
{
text: '取消',
style: {
backgroundColor: '#f9ae3d',
}
},
],
}, {
text: '正常状态',
disabled: false,
options: [{
text: '置顶',
style: {
backgroundColor: '#3c9cff',
}
},
{
text: '取消',
style: {
backgroundColor: '#f9ae3d',
}
},
],
}, {
text: '自动关闭',
disabled: false,
options: [{
text: '置顶',
style: {
backgroundColor: '#3c9cff',
}
},
{
text: '取消',
style: {
backgroundColor: '#f9ae3d',
}
},
],
}],
options5: [{
icon: 'trash-fill',
style: {
backgroundColor: '#f56c6c',
width: '40px',
height: '40px',
borderRadius: '100px',
margin: '0 6px'
}
}, {
icon: 'heart-fill',
style: {
backgroundColor: '#5ac725',
width: '40px',
height: '40px',
borderRadius: '100px',
margin: '0 6px'
}
}]
}
},
methods: {
click(index) {
console.log('click', index);
uni.showModal({
title: '温馨提示',
content: '确定要删除吗?',
success: res => {
if (res.confirm) {
this.show1 = false
}
}
})
}
}
}
</script>
<style lang="scss">
.u-page {
padding: 0;
}
.u-demo-block__title {
padding: 10px 0 2px 15px;
}
.swipe-action {
&__content {
padding: 25rpx 0;
&__text {
font-size: 15px;
color: $u-main-color;
padding-left: 30rpx;
}
}
}
</style>

View File

@ -0,0 +1,33 @@
<template>
<view>
<u-list style="height: 500px; background-color: red;">
<u-list-item>
<u-image src="https://img2020.cnblogs.com/blog/35695/202112/35695-20211222112522991-1769312387.jpg"></u-image>
</u-list-item>
<u-list-item>
<u-image src="https://img2020.cnblogs.com/blog/35695/202112/35695-20211222112522991-1769312387.jpg"></u-image>
</u-list-item>
<u-list-item>
<u-image src="https://img2020.cnblogs.com/blog/35695/202112/35695-20211222112522991-1769312387.jpg"></u-image>
</u-list-item>
<u-list-item>
<u-image src="https://img2020.cnblogs.com/blog/35695/202112/35695-20211222112522991-1769312387.jpg"></u-image>
</u-list-item>
<u-list-item>
<u-image src="https://img2020.cnblogs.com/blog/35695/202112/35695-20211222112522991-1769312387.jpg"></u-image>
</u-list-item>
<u-list-item>
<u-image src="https://img2020.cnblogs.com/blog/35695/202112/35695-20211222112522991-1769312387.jpg"></u-image>
</u-list-item>
<u-list-item>
<u-image src="https://img2020.cnblogs.com/blog/35695/202112/35695-20211222112522991-1769312387.jpg"></u-image>
</u-list-item>
</u-list>
</view>
</template>
<script>
export default {
}
</script>

View File

@ -0,0 +1,164 @@
<template>
<view class="u-page">
<u-gap height="20" bgColor="#fff"></u-gap>
<u-cell-group border>
<u-cell
:titleStyle="{ fontWeight: 500 }"
@click="openTransition(item.mode)"
:title="item.title"
v-for="(item, index) in list"
:key="index"
clickable
>
<image
slot="icon"
class="u-cell-icon"
:src="item.iconUrl"
mode="widthFix"
></image>
</u-cell>
<u-transition
:mode="mode"
:show="show"
:custom-style="style"
@click="click"
@beforeEnter="beforeEnter"
@enter="enter"
@afterEnter="afterEnter"
@beforeLeave="beforeLeave"
@leave="leave"
@afterLeave="afterLeave"
>
<view class="transition"></view>
</u-transition>
</u-cell-group>
</view>
</template>
<script>
export default {
data() {
return {
mode: "",
show: false,
style: {
position: "fixed",
top: `${uni.$u.sys().windowHeight / 2 - 50}px`,
left: `${uni.$u.sys().windowWidth / 2 - 50}px`,
width: "120px",
height: "120px",
backgroundColor: "#1989fa",
},
list: [
{
mode: "fade",
title: "淡入",
iconUrl:
"https://cdn.uviewui.com/uview/demo/transition/fade.png",
},
{
mode: "fade-up",
title: "上滑淡入",
iconUrl:
"https://cdn.uviewui.com/uview/demo/transition/fadeUp.png",
},
{
mode: "zoom",
title: "缩放",
iconUrl:
"https://cdn.uviewui.com/uview/demo/transition/zoom.png",
},
{
mode: "fade-zoom",
title: "缩放淡入",
iconUrl:
"https://cdn.uviewui.com/uview/demo/transition/fadeZoom.png",
},
{
mode: "fade-down",
title: "下滑淡入",
iconUrl:
"https://cdn.uviewui.com/uview/demo/transition/fadeDown.png",
},
{
mode: "fade-left",
title: "左滑淡入",
iconUrl:
"https://cdn.uviewui.com/uview/demo/transition/fadeLeft.png",
},
{
mode: "fade-right",
title: "右滑淡入",
iconUrl:
"https://cdn.uviewui.com/uview/demo/transition/fadeRight.png",
},
{
mode: "slide-up",
title: "上滑进入",
iconUrl:
"https://cdn.uviewui.com/uview/demo/transition/slideUp.png",
},
{
mode: "slide-down",
title: "下滑进入",
iconUrl:
"https://cdn.uviewui.com/uview/demo/transition/slideDown.png",
},
{
mode: "slide-left",
title: "左滑进入",
iconUrl:
"https://cdn.uviewui.com/uview/demo/transition/slideLeft.png",
},
{
mode: "slide-right",
title: "右滑进入",
iconUrl:
"https://cdn.uviewui.com/uview/demo/transition/slideRight.png",
},
],
};
},
mixins: [uni.$u.mixin],
methods: {
openTransition(mode) {
this.mode = mode;
this.show = true;
setTimeout(() => {
this.show = false;
}, 1500);
},
click() {
// console.log("click");
},
beforeEnter() {
// console.log("beforeEnter");
},
enter() {
// console.log("enter");
},
afterEnter() {
// console.log("afterEnter");
},
beforeLeave() {
// console.log("beforeLeave");
},
leave() {
// console.log("leave");
},
afterLeave() {
// console.log("afterLeave");
},
},
};
</script>
<style lang="scss">
.u-page {
padding: 0;
}
.transition {
background-color: $u-primary;
}
</style>

View File

@ -0,0 +1,188 @@
<template>
<view class="u-page">
<u-navbar
title="上拉菜单"
@leftClick="navigateBack"
safeAreaInsetTop
fixed
placeholder
></u-navbar>
<u-cell-group>
<u-cell
@click="openSheet(index)"
:title="item.title"
v-for="(item, index) in list"
:key="index"
isLink
>
<image
slot="icon"
class="u-cell-icon"
:src="item.iconUrl"
mode="widthFix"
></image>
</u-cell>
</u-cell-group>
<u-action-sheet
:show="show0"
@close="close"
@select="select"
:actions="actions0"
:closeOnClickOverlay="false"
>
</u-action-sheet>
<u-action-sheet
:show="show1"
@close="show1 = false"
:actions="actions1"
>
</u-action-sheet>
<u-action-sheet
:show="show2"
@close="show2 = false"
:actions="actions2"
cancelText="取消"
>
</u-action-sheet>
<u-action-sheet
:show="show3"
@close="show3 = false"
:actions="actions3"
description="这是一段描述文本,字号偏小,颜色偏淡"
>
</u-action-sheet>
<u-action-sheet
:show="show4"
@close="show4 = false"
title="标题位置"
:round="10"
>
<text style="margin: 10px 20px 30px 20px; color: #303133; font-size: 15px;">这是一段通过slot传入的内容,您可以在此自定义操作面板</text>
</u-action-sheet>
<u-action-sheet
:show="show5"
@close="show5 = false"
title="微信开放能力"
:actions="actions5"
@getuserinfo="getuserinfo"
></u-action-sheet>
</view>
</template>
<script>
export default {
data() {
return {
show0: false,
show1: false,
show2: false,
show3: false,
show4: false,
show5: false,
actions0: [{
name: '选项1',
},
{
name: '选项2',
},
{
name: '选项3',
subname: '描述文本'
},
],
actions1: [{
name: '选项1',
},
{
loading: true
},
{
name: '选项被禁用',
disabled: true
},
],
actions2: [{
name: '选项1',
},
{
name: '选项2',
},
{
name: '选项3',
},
],
actions3: [{
name: '选项1',
},
{
name: '选项2',
},
{
name: '选项3',
},
],
actions5: [{
name: '获取用户信息',
openType: 'getUserInfo',
color: uni.$u.color['success']
}],
list: [{
title: '普通使用',
iconUrl: 'https://cdn.uviewui.com/uview/demo/actionSheet/custom.png'
},
{
title: '设置状态',
iconUrl: 'https://cdn.uviewui.com/uview/demo/actionSheet/status.png'
},
{
title: '显示取消按钮',
iconUrl: 'https://cdn.uviewui.com/uview/demo/actionSheet/cancel.png'
},
{
title: '描述内容',
iconUrl: 'https://cdn.uviewui.com/uview/demo/actionSheet/desc.png'
},
{
title: '显示标题(显示圆角)',
iconUrl: 'https://cdn.uviewui.com/uview/demo/actionSheet/title.png'
},
{
title: '微信开放能力',
iconUrl: 'https://cdn.uviewui.com/uview/demo/actionSheet/open.png'
}
]
}
},
onLoad() {
},
methods: {
// 点击cell,判断显示哪个功能
openSheet(index) {
// #ifndef MP
if (index === 5) return uni.$u.toast('请在微信内预览')
// #endif
this[`show${index}`] = true
},
getuserinfo(res) {
uni.$u.toast(`用户名:${res.userInfo.nickName}`)
},
navigateBack() {
uni.navigateBack()
},
close() {
console.log('close');
this['show0'] = false
},
select(e) {
console.log('select', e);
}
}
}
</script>
<style lang="scss">
.u-page {
padding: 0;
}
</style>

View File

@ -0,0 +1,146 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础功能</text>
<view class="u-demo-block__content">
<view class="u-alert-item">
<u-alert
description="山不在于高,有了神仙就出名"
type="warning"
></u-alert>
</view>
<view class="u-alert-item">
<u-alert
description="水不在深,有龙则灵"
type="primary"
></u-alert>
</view>
<view class="u-alert-item">
<u-alert
description="斯是陋室,惟吾德馨。苔痕上阶绿,草色入帘青"
type="error"
></u-alert>
</view>
<view class="u-alert-item">
<u-alert
description="谈笑有鸿儒,往来无白丁"
type="info"
></u-alert>
</view>
<view class="u-alert-item">
<u-alert
description="可以调素琴,阅金经"
type="success"
></u-alert>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">深浅色</text>
<view class="u-demo-block__content">
<view class="u-alert-item">
<u-alert
description="无丝竹之乱耳,无案牍之劳形"
type="warning"
></u-alert>
</view>
<view class="u-alert-item">
<u-alert
description="南阳诸葛庐,西蜀子云亭。孔子云:何陋之有"
type="warning"
effect="dark"
></u-alert>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">显示图标</text>
<view class="u-demo-block__content">
<view class="u-alert-item">
<u-alert
description="六王毕,四海一;蜀山兀,阿房出"
type="error"
showIcon
></u-alert>
</view>
<view class="u-alert-item">
<u-alert
description="覆压三百余里,隔离天日。骊山北构而西折,直走咸阳,二川溶溶,流入宫墙"
type="error"
effect="dark"
showIcon
></u-alert>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">可关闭</text>
<view class="u-demo-block__content">
<view class="u-alert-item">
<u-alert
description="五步一楼,十步一阁;廊腰缦回,檐牙高啄;各抱地势,钩心斗角"
type="success"
showIcon
closable
></u-alert>
</view>
<view class="u-alert-item">
<u-alert
description="盘盘焉,囷囷焉,蜂房水涡,矗不知其几千万落"
type="success"
effect="dark"
closable
showIcon
></u-alert>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">带标题</text>
<view class="u-demo-block__content">
<view class="u-alert-item">
<u-alert
title="妃嫔媵嫱,王子皇孙,辞楼下殿"
description="长桥卧波,未云何龙?复道行空,不霁何虹"
type="info"
showIcon
closable
></u-alert>
</view>
<view class="u-alert-item">
<u-alert
title="辇来于秦,朝歌夜弦,为秦宫人。明星荧荧,开妆镜也"
description="高低冥迷,不知西东。歌台暖响,春光融融;舞殿冷袖,风雨凄凄。一日之内,一宫之间,而气候不齐"
type="info"
effect="dark"
closable
showIcon
></u-alert>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
description: '',
title: ''
}
}
}
</script>
<style lang="scss">
.u-alert-item {
flex: 1;
margin-bottom: 10px;
}
.u-demo-block__content {
flex-direction: column !important;
align-items: stretch;
}
</style>

View File

@ -0,0 +1,163 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">直角边形状</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-badge
:value="1500"
shape="horn"
></u-badge>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">徽标数显示方式</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-badge
:value="5132"
numberType="ellipsis"
></u-badge>
</view>
<view class="u-page__tag-item">
<u-badge
:value="1011"
numberType="overflow"
></u-badge>
</view>
<view class="u-page__tag-item">
<u-badge
:value="1500"
numberType="limit"
></u-badge>
</view>
<view class="u-page__tag-item">
<u-badge
:value="45187"
numberType="limit"
></u-badge>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">显示圆点</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-badge
:value="1011"
numberType="overflow"
isDot
>
</u-badge>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义主题</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-badge
:value="9"
type="error"
>
</u-badge>
</view>
<view class="u-page__tag-item">
<u-badge
:value="9"
type="warning"
>
</u-badge>
</view>
<view class="u-page__tag-item">
<u-badge
:value="9"
type="success"
>
</u-badge>
</view>
<view class="u-page__tag-item">
<u-badge
:value="9"
type="primary"
>
</u-badge>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">反转色</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-badge
:value="9"
type="error"
inverted
>
</u-badge>
</view>
<view class="u-page__tag-item">
<u-badge
:value="1532"
inverted
type="warning"
>
</u-badge>
</view>
<view class="u-page__tag-item">
<u-badge
:value="12"
inverted
type="success"
>
</u-badge>
</view>
<view class="u-page__tag-item">
<u-badge
:value="999"
inverted
type="primary"
>
</u-badge>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {}
}
}
</script>
<style lang="scss">
.box {
justify-content: space-between;
}
.u-page__tag-item {
margin-right: 40px;
margin-top: 10px;
}
.badge-box {
width: 45px;
height: 45px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
background-color: #E6E6E6;
}
.u-demo-block__content {
flex-direction: row;
flex-wrap: wrap;
align-items: center;
}
</style>

View File

@ -0,0 +1,157 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础功能</text>
<view class="u-demo-block__content">
<u-code
ref="uCode"
@change="codeChange"
seconds="20"
change-text="XS获取"
@start="disabled1 = true"
@end="disabled1 = false"
></u-code>
<u-button
@tap="getCode"
:text="tips"
type="success"
size="small"
:disabled="disabled1"
></u-button>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">保持倒计时(开始后,左上角返退出此页面再进入,会发现倒计时还在继续)</text>
<view class="u-demo-block__content">
<u-code
ref="uCode1"
@change="codeChange1"
keep-running
change-text="倒计时XS"
@start="disabled2 = true"
@end="disabled2 = false"
></u-code>
<u-button
type="primary"
@tap="getCode1"
:text="tips1"
size="small"
:disabled="disabled2"
></u-button>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">文本样式</text>
<view class="u-demo-block__content">
<u-code
ref="uCode2"
@change="codeChange2"
keep-running
start-text="点我获取验证码"
></u-code>
<text
@tap="getCode2"
:text="tips2"
class="u-page__code-text"
>{{tips2}}</text>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
tips: '',
// 此为错误定义,见下方说明
// refCode: null,
tips1: '',
tips2: '',
disabled1: false,
disabled2: false,
disabled3: false
}
},
onReady() {
// 注意这里不能将一个组件赋值给data的一个变量,否则在微信小程序会
// 造成循环引用而报错,如果你想这样做,请在onReady或者onLoad生命周期中定义,如下
// this.refCode = this.$refs.uCode;
},
methods: {
codeChange(text) {
this.tips = text;
},
codeChange1(text) {
this.tips1 = text;
},
codeChange2(text) {
this.tips2 = text;
},
getCode() {
if (this.$refs.uCode.canGetCode) {
// 模拟向后端请求验证码
uni.showLoading({
title: '正在获取验证码'
})
setTimeout(() => {
uni.hideLoading();
// 这里此提示会被this.start()方法中的提示覆盖
uni.$u.toast('验证码已发送');
// 通知验证码组件内部开始倒计时
this.$refs.uCode.start();
}, 2000);
} else {
uni.$u.toast('倒计时结束后再发送');
}
},
getCode1() {
if (this.$refs.uCode1.canGetCode) {
// 模拟向后端请求验证码
uni.showLoading({
title: '正在获取验证码'
})
setTimeout(() => {
uni.hideLoading();
// 这里此提示会被this.start()方法中的提示覆盖
uni.$u.toast('验证码已发送');
// 通知验证码组件内部开始倒计时
this.$refs.uCode1.start();
}, 2000);
} else {
uni.$u.toast('倒计时结束后再发送');
}
},
getCode2() {
if (this.$refs.uCode2.canGetCode) {
// 模拟向后端请求验证码
uni.showLoading({
title: '正在获取验证码'
})
setTimeout(() => {
uni.hideLoading();
// 这里此提示会被this.start()方法中的提示覆盖
uni.$u.toast('验证码已发送');
// 通知验证码组件内部开始倒计时
this.$refs.uCode2.start();
}, 2000);
} else {
uni.$u.toast('倒计时结束后再发送');
}
}
}
}
</script>
<style lang="scss">
.u-page {
&__code-text {
color: $u-primary;
font-size: 15px;
}
}
.u-demo-block__content {
@include flex;
}
</style>

View File

@ -0,0 +1,180 @@
<template>
<view class="u-page">
<view class="u-page__item">
<text class="u-page__item__title">基础功能</text>
<u-collapse
@change="change"
@close="close"
@open="open"
>
<u-collapse-item
title="文档指南"
name="Docs guide"
>
<text class="u-collapse-content">涵盖uniapp各个方面,给开发者方向指导和设计理念,让您茅塞顿开,一马平川</text>
</u-collapse-item>
<u-collapse-item
title="组件全面"
name="Variety components"
>
<text class="u-collapse-content">众多组件覆盖开发过程的各个需求,组件功能丰富,多端兼容。让您快速集成,开箱即用</text>
</u-collapse-item>
<u-collapse-item
title="众多利器"
name="Numerous tools"
>
<text class="u-collapse-content">众多的贴心小工具,是您开发过程中召之即来的利器,让您飞镖在手,百步穿杨</text>
</u-collapse-item>
</u-collapse>
</view>
<view class="u-page__item">
<text class="u-page__item__title">展开和禁用</text>
<u-collapse
:value="['2']"
>
<u-collapse-item
title="文档指南"
>
<text class="u-collapse-content">涵盖uniapp各个方面,给开发者方向指导和设计理念,让您茅塞顿开,一马平川</text>
</u-collapse-item>
<u-collapse-item
disabled
title="组件全面"
>
<text class="u-collapse-content">众多组件覆盖开发过程的各个需求,组件功能丰富,多端兼容。让您快速集成,开箱即用</text>
</u-collapse-item>
<u-collapse-item
name="2"
title="众多利器"
>
<text class="u-collapse-content">众多的贴心小工具,是您开发过程中召之即来的利器,让您飞镖在手,百步穿杨</text>
</u-collapse-item>
</u-collapse>
</view>
<view class="u-page__item">
<text class="u-page__item__title">手风琴模式</text>
<u-collapse
accordion
>
<u-collapse-item
title="文档指南"
>
<text class="u-collapse-content">涵盖uniapp各个方面,给开发者方向指导和设计理念,让您茅塞顿开,一马平川</text>
</u-collapse-item>
<u-collapse-item
title="组件全面"
>
<text class="u-collapse-content">众多组件覆盖开发过程的各个需求,组件功能丰富,多端兼容。让您快速集成,开箱即用</text>
</u-collapse-item>
<u-collapse-item
title="众多利器"
>
<text class="u-collapse-content">众多的贴心小工具,是您开发过程中召之即来的利器,让您飞镖在手,百步穿杨</text>
</u-collapse-item>
</u-collapse>
</view>
<view class="u-page__item">
<text class="u-page__item__title">移除下划线</text>
<u-collapse
accordion
:border="false"
>
<u-collapse-item
title="文档指南"
>
<text class="u-collapse-content">涵盖uniapp各个方面,给开发者方向指导和设计理念,让您茅塞顿开,一马平川</text>
</u-collapse-item>
<u-collapse-item
title="组件全面"
>
<text class="u-collapse-content">众多组件覆盖开发过程的各个需求,组件功能丰富,多端兼容。让您快速集成,开箱即用</text>
</u-collapse-item>
<u-collapse-item
title="众多利器"
>
<text class="u-collapse-content">众多的贴心小工具,是您开发过程中召之即来的利器,让您飞镖在手,百步穿杨</text>
</u-collapse-item>
</u-collapse>
</view>
<!-- 微信小程序不支持,因为微信中不支持 <slot name="title" slot="title" />的写法 -->
<!-- #ifndef MP-WEIXIN -->
<view class="u-page__item">
<text class="u-page__item__title">自定义标题和内容</text>
<u-collapse
accordion
>
<u-collapse-item
>
<text slot="title" class="u-page__item__title__slot-title">文档指南</text>
<text class="u-collapse-content">涵盖uniapp各个方面,给开发者方向指导和设计理念,让您茅塞顿开,一马平川</text>
</u-collapse-item>
<!-- <u-collapse-item
:isLink="false"
>
<text slot="title" class="u-page__item__title__slot-title">文档指南</text>
<text class="u-collapse-content">涵盖uniapp各个方面,给开发者方向指导和设计理念,让您茅塞顿开,一马平川</text>
</u-collapse-item> -->
<u-collapse-item
title="组件全面"
>
<u-icon name="tags-fill" size="20" slot="icon"></u-icon>
<text class="u-collapse-content">众多组件覆盖开发过程的各个需求,组件功能丰富,多端兼容。让您快速集成,开箱即用</text>
</u-collapse-item>
<u-collapse-item
title="众多利器"
>
<text slot="value" class="u-page__item__title__slot-title">自定义内容</text>
<text class="u-collapse-content">众多的贴心小工具,是您开发过程中召之即来的利器,让您飞镖在手,百步穿杨</text>
</u-collapse-item>
</u-collapse>
</view>
<!-- #endif -->
<u-gap height="50"></u-gap>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
open(e) {
// console.log('open', e)
},
close(e) {
// console.log('close', e)
},
change(e) {
// console.log('change', e)
}
}
}
</script>
<style lang="scss">
.u-page {
padding: 0;
&__item {
&__title {
color: $u-tips-color;
background-color: $u-bg-color;
padding: 15px;
font-size: 15px;
&__slot-title {
color: $u-primary;
font-size: 14px;
}
}
}
}
.u-collapse-content {
color: $u-tips-color;
font-size: 14px;
}
</style>

View File

@ -0,0 +1,291 @@
<template>
<view class="u-page">
<view class="u-page__item">
<text class="u-page__item__title" style="margin-top: 0;">主色调</text>
<view class="u-page__item__color-box">
<view
class="u-page__item__color-box__item"
style="background-color: #3c9cff;"
>
<text class="u-page__item__color-box__item__title">Primary</text>
<text class="u-page__item__color-box__item__value">#3c9cff</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #398ade;"
>
<text class="u-page__item__color-box__item__title">Dark</text>
<text class="u-page__item__color-box__item__value">#398ade</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #9acafc;"
>
<text class="u-page__item__color-box__item__title">Disabled</text>
<text class="u-page__item__color-box__item__value">#9acafc</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #ecf5ff;"
>
<text class="u-page__item__color-box__item__title u-tips-color">Light</text>
<text class="u-page__item__color-box__item__value u-tips-color">#ecf5ff</text>
</view>
</view>
</view>
<view class="u-page__item">
<text class="u-page__item__title">Error</text>
<view class="u-page__item__color-box">
<view
class="u-page__item__color-box__item"
style="background-color: #f56c6c;"
>
<text class="u-page__item__color-box__item__title">Error</text>
<text class="u-page__item__color-box__item__value">#f56c6c</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #e45656;"
>
<text class="u-page__item__color-box__item__title">Dark</text>
<text class="u-page__item__color-box__item__value">#e45656</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #f7b2b2;"
>
<text class="u-page__item__color-box__item__title">Disabled</text>
<text class="u-page__item__color-box__item__value">#f7b2b2</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #fef0f0;"
>
<text class="u-page__item__color-box__item__title u-tips-color">Light</text>
<text class="u-page__item__color-box__item__value u-tips-color">#fef0f0</text>
</view>
</view>
</view>
<view class="u-page__item">
<text class="u-page__item__title">Warning</text>
<view class="u-page__item__color-box">
<view
class="u-page__item__color-box__item"
style="background-color: #f9ae3d;"
>
<text class="u-page__item__color-box__item__title">Warning</text>
<text class="u-page__item__color-box__item__value">#f9ae3d</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #f1a532;"
>
<text class="u-page__item__color-box__item__title">Dark</text>
<text class="u-page__item__color-box__item__value">#f1a532</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #f9d39b;"
>
<text class="u-page__item__color-box__item__title">Disabled</text>
<text class="u-page__item__color-box__item__value">#f9d39b</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #fdf6ec;"
>
<text class="u-page__item__color-box__item__title u-tips-color">Light</text>
<text class="u-page__item__color-box__item__value u-tips-color">#fdf6ec</text>
</view>
</view>
</view>
<view class="u-page__item">
<text class="u-page__item__title">Info</text>
<view class="u-page__item__color-box">
<view
class="u-page__item__color-box__item"
style="background-color: #909399;"
>
<text class="u-page__item__color-box__item__title">Info</text>
<text class="u-page__item__color-box__item__value">#909399</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #767a82;"
>
<text class="u-page__item__color-box__item__title">Dark</text>
<text class="u-page__item__color-box__item__value">#767a82</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #c4c6c9;"
>
<text class="u-page__item__color-box__item__title">Disabled</text>
<text class="u-page__item__color-box__item__value">#c4c6c9</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #f4f4f5;"
>
<text class="u-page__item__color-box__item__title u-tips-color">Light</text>
<text class="u-page__item__color-box__item__value u-tips-color">#f4f4f5</text>
</view>
</view>
</view>
<view class="u-page__item">
<text class="u-page__item__title">Success</text>
<view class="u-page__item__color-box">
<view
class="u-page__item__color-box__item"
style="background-color: #5ac725;"
>
<text class="u-page__item__color-box__item__title">Success</text>
<text class="u-page__item__color-box__item__value">#5ac725</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #53c21d;"
>
<text class="u-page__item__color-box__item__title">Dark</text>
<text class="u-page__item__color-box__item__value">#53c21d</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #a9e08f;"
>
<text class="u-page__item__color-box__item__title">Disabled</text>
<text class="u-page__item__color-box__item__value">#a9e08f</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #f5fff0;"
>
<text class="u-page__item__color-box__item__title u-tips-color">Light</text>
<text class="u-page__item__color-box__item__value u-tips-color">#f5fff0</text>
</view>
</view>
</view>
<view class="u-page__item">
<text class="u-page__item__title">文字颜色</text>
<view class="u-page__item__color-box">
<view
class="u-page__item__color-box__item"
style="background-color: #303133;"
>
<text class="u-page__item__color-box__item__title">主要文字</text>
<text class="u-page__item__color-box__item__value">#303133</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #606266;"
>
<text class="u-page__item__color-box__item__title">常规文字</text>
<text class="u-page__item__color-box__item__value">#606266</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #909399;"
>
<text class="u-page__item__color-box__item__title">次要文字</text>
<text class="u-page__item__color-box__item__value">#909399</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #c0c4cc;"
>
<text class="u-page__item__color-box__item__title">占位文字</text>
<text class="u-page__item__color-box__item__value">#c0c4cc</text>
</view>
</view>
</view>
<view class="u-page__item">
<text class="u-page__item__title">边框颜色</text>
<view class="u-page__item__color-box">
<view
class="u-page__item__color-box__item"
style="background-color: #9a9998;"
>
<text class="u-page__item__color-box__item__title ">一级边框</text>
<text class="u-page__item__color-box__item__value ">#9a9998</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #b4b3b1;"
>
<text class="u-page__item__color-box__item__title ">二级边框</text>
<text class="u-page__item__color-box__item__value ">#b4b3b1</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #ceccca;"
>
<text class="u-page__item__color-box__item__title ">三级边框</text>
<text class="u-page__item__color-box__item__value ">#ceccca</text>
</view>
<view
class="u-page__item__color-box__item"
style="background-color: #e7e6e4;"
>
<text class="u-page__item__color-box__item__title u-tips-color">四级边框</text>
<text class="u-page__item__color-box__item__value u-tips-color">#e7e6e4</text>
</view>
</view>
</view>
<view class="u-page__item">
<text class="u-page__item__title">背景颜色</text>
<view class="u-page__item__color-box">
<view
class="u-page__item__color-box__item"
style="background-color: #f3f4f6;"
>
<text class="u-page__item__color-box__item__title u-tips-color">背景颜色</text>
<text class="u-page__item__color-box__item__value u-tips-color">#f3f4f6</text>
</view>
</view>
</view>
</view>
</template>
<style lang="scss">
.u-page {
padding: 15px;
&__item {
&__title {
font-size: 15px;
color: $u-content-color;
margin-top: 16px;
margin-bottom: 4px;
}
&__color-box {
@include flex;
justify-content: space-between;
&__item {
width: 160rpx;
@include flex(column);
align-items: center;
justify-content: center;
padding: 5px 0;
border-radius: 3px;
&__title {
font-size: 13px;
color: #fff;
}
&__value {
font-size: 14px;
color: #fff;
}
}
}
}
}
.u-tips-color {
color: $u-tips-color;
}
</style>

View File

@ -0,0 +1,239 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础用法</text>
<view class="u-demo-block__content">
<u-count-down
:time="30 * 60 * 60 * 1000"
format="HH:mm:ss"
autoStart
millisecond
@finish="finish"
>
</u-count-down>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义格式</text>
<view class="u-demo-block__content">
<u-count-down
:time="30 * 60 * 60 * 1000"
format="DD:HH:mm:ss"
autoStart
millisecond
@change="onChange"
>
<view class="time">
<text class="time__item">{{ timeData.days }}&nbsp;天</text>
<text class="time__item">{{ timeData.hours>10?timeData.hours:'0'+timeData.hours}}&nbsp;时</text>
<text class="time__item">{{ timeData.minutes }}&nbsp;分</text>
<text class="time__item">{{ timeData.seconds }}&nbsp;秒</text>
</view>
</u-count-down>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">毫秒级渲染</text>
<view class="u-demo-block__content">
<u-count-down
:time="30 * 60 * 60 * 1000"
format="HH:mm:ss:SSS"
autoStart
millisecond
>
</u-count-down>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义样式</text>
<view class="u-demo-block__content">
<u-count-down
:time="30 * 60 * 60 * 1000"
format="HH:mm:ss"
autoStart
millisecond
@change="onChange"
>
<view class="time">
<view class="time__custom">
<text class="time__custom__item">{{ timeData.hours>10?timeData.hours:'0'+timeData.hours}}</text>
</view>
<text class="time__doc">:</text>
<view class="time__custom">
<text class="time__custom__item">{{ timeData.minutes }}</text>
</view>
<text class="time__doc">:</text>
<view class="time__custom">
<text class="time__custom__item">{{ timeData.seconds }}</text>
</view>
</view>
</u-count-down>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">手动控制</text>
<view class="u-demo-block__content">
<u-count-down
ref="countDown"
:time="3* 1000"
format="ss:SSS"
:autoStart="false"
millisecond
>
</u-count-down>
</view>
<u-grid
:border="true"
:customStyle="{marginTop:10+'px'}"
>
<u-grid-item @click="reset">
<view class="count-down__grid-item">
<u-icon
name="reload"
:size="22"
></u-icon>
<text class="count-down__grid-item__grid-text">重置</text>
</view>
</u-grid-item>
<u-grid-item @click="start">
<view class="count-down__grid-item">
<view class="count-down__grid-item__circle">
<u-icon
color="#fff"
name="play-right-fill"
:size="22"
></u-icon>
</view>
<text class="count-down__grid-item__grid-text">开始</text>
</view>
</u-grid-item>
<u-grid-item @click="pause">
<view class="count-down__grid-item">
<u-icon
name="pause-circle"
:size="22"
></u-icon>
<text class="count-down__grid-item__grid-text">暂停</text>
</view>
</u-grid-item>
</u-grid>
</view>
</view>
</template>
<script>
export default {
data() {
return {
timeData: {},
}
},
onLoad() {
},
methods: {
//开始
start() {
this.$refs.countDown.start();
},
// 暂停
pause() {
this.$refs.countDown.pause();
},
// 重置
reset() {
this.$refs.countDown.reset();
},
onChange(e) {
this.timeData = e
},
finish() {
console.log('finish');
}
}
}
</script>
<style lang="scss">
.u-page {
}
.time {
@include flex;
align-items: center;
&__custom {
margin-top: 4px;
width: 22px;
height: 22px;
background-color: $u-primary;
border-radius: 4px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
&__item {
color: #fff;
font-size: 12px;
text-align: center;
}
}
&__doc {
color: $u-primary;
padding: 0px 4px;
}
&__item {
color: #606266;
font-size: 15px;
margin-right: 4px;
}
}
.u-view {
padding: 40px 20px 0px 20px;
&__title {
font-size: 14px;
color: rgb(143, 156, 162);
margin-bottom: 10px;
}
}
// 手动控制的btn样式
.count-down {
&__grid-item {
width: 70px;
height: 70px;
@include flex;
justify-content: center;
align-items: center;
&__circle {
width: 32px;
height: 32px;
border-radius: 32px;
background-color: $u-primary;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
box-shadow: 1px 1px 4px rgba(155, 191, 255, .7);
}
&__grid-text {
font-size: 14px;
color: #909399;
/* #ifndef APP-PLUS */
box-sizing: border-box;
/* #endif */
margin-left: 6px;
}
}
}
</style>

View File

@ -0,0 +1,176 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础功能</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-count-to
:endVal="value"
@end="end"
></u-count-to>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">倒计数</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-count-to :startVal="startVal1"></u-count-to>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">显示小数位</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-count-to
:startVal="startVal2"
:endVal="endVal"
:decimals="decimals"
></u-count-to>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">千分位分隔符</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-count-to
:startVal="startVal3"
:endVal="endVal2"
separator=","
:decimals="decimals"
></u-count-to>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义控制</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-count-to
ref="uCountTo"
:endVal="endVal3"
:autoplay="autoplay"
></u-count-to>
</view>
</view>
<view class="u-demo-block__content">
<view
class=""
style="flex: 1;"
>
<u-grid
border
align="center"
customStyle="margin-top: 20px;margin-bottom: 20"
>
<u-grid-item @click="start">
<view class="u-grid-slot">
<view class="u-grid-slot__circle">
<text class="u-grid-slot__circle__text">开始</text>
</view>
</view>
</u-grid-item>
<u-grid-item @click="paused">
<view class="u-grid-slot">
<view class="u-grid-slot__circle">
<text class="u-grid-slot__circle__text">暂停</text>
</view>
</view>
</u-grid-item>
<u-grid-item @click="resume">
<view class="u-grid-slot">
<view class="u-grid-slot__circle">
<text class="u-grid-slot__circle__text">继续</text>
</view>
</view>
</u-grid-item>
</u-grid>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-count-to
:endVal="value"
color="#909399"
:fontSize="fontSize"
:bold="true"
></u-count-to>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
value: 3000,
startVal1: 300,
startVal2: 100.00,
endVal: 10.55,
decimals: 2,
startVal3: 2000,
endVal2: 1542,
endVal3: 3000,
autoplay: false,
color: '#FF0000',
fontSize: 40,
}
},
onLoad() {
// setTimeout(() => {
// this.value = 3000
// }, 3000)
},
methods: {
start() {
this.$refs.uCountTo.start();
},
paused() {
this.$refs.uCountTo.stop()
},
resume() {
this.$refs.uCountTo.resume()
},
end() {
console.log('end');
}
}
}
</script>
<style lang="scss">
.u-demo-block__content {
flex-direction: row;
flex-wrap: wrap;
align-items: center;
}
.u-grid-slot {
border-radius: 100px;
border-color: #dbfbdb;
border-width: 2px;
@include flex;
&__circle {
width: 50px;
height: 50px;
background-color: #dbfbdb;
border-radius: 100px;
justify-content: center;
align-items: center;
margin: 2px;
&__text {
color: rgb(25, 190, 107);
font-size: 13px;
}
}
}
</style>

View File

@ -0,0 +1,31 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础功能</text>
<view class="u-demo-block__content">
<u-dropdown>
<u-dropdown-item title="标题1">
<view class="" style="height: 300px;">
123
</view>
</u-dropdown-item>
<u-dropdown-item title="标题2">
456
</u-dropdown-item>
<u-dropdown-item title="标题3">
789
</u-dropdown-item>
<u-dropdown-item title="标题4">
abc
</u-dropdown-item>
</u-dropdown>
</view>
</view>
</view>
</template>
<script>
</script>
<style>
</style>

View File

@ -0,0 +1,131 @@
<template>
<view class="u-page">
<u-navbar
title="键盘"
@leftClick="navigateBack"
safeAreaInsetTop
fixed
placeholder
></u-navbar>
<u-gap height="20" bgColor="#fff"></u-gap>
<u-cell-group>
<u-cell
:titleStyle="{fontWeight: 500}"
@click="openKeyboard(index)"
:title="item.title"
v-for="(item, index) in list"
:key="index"
isLink
>
<image
slot="icon"
class="u-cell-icon"
:src="item.iconUrl"
mode="widthFix"
></image>
</u-cell>
</u-cell-group>
<u-keyboard
:mode="keyData.mode"
:dotDisabled="keyData.dotDisabled"
:random='keyData.random'
:show="show"
@close="close"
@cancel="cancel"
@confirm="confirm"
@change="change"
@backspace="backspace"
></u-keyboard>
</view>
</template>
<script>
export default {
data() {
return {
input: '',
keyData: {
mode: '',
dotDisabled: false,
random: false,
},
list: [{
title: '车牌号键盘',
iconUrl: 'https://cdn.uviewui.com/uview/demo/keyboard/car.png'
},
{
title: '数字键盘',
iconUrl: 'https://cdn.uviewui.com/uview/demo/keyboard/number.png'
},
{
title: '身份证键盘',
iconUrl: 'https://cdn.uviewui.com/uview/demo/keyboard/IdCard.png'
},
{
title: '隐藏键盘"."符号',
iconUrl: 'https://cdn.uviewui.com/uview/demo/keyboard/dot.png'
},
{
title: '打乱键盘按键的顺序',
iconUrl: 'https://cdn.uviewui.com/uview/demo/keyboard/order.png'
},
],
show: false
}
},
methods: {
navigateBack() {
uni.navigateBack();
},
// 点击展示不同的键盘
openKeyboard(indexNum) {
this.keyData = {
mode: '',
dotDisabled: false,
random: false,
}
if (indexNum == 0) {
this.keyData.mode = ''
} else if (indexNum == 1) {
this.keyData.mode = 'number'
} else if (indexNum == 2) {
this.keyData.mode = 'card'
} else if (indexNum == 3) {
this.keyData.mode = 'number'
this.keyData.dotDisabled = true
} else if (indexNum == 4) {
this.keyData.mode = 'number'
this.keyData.random = true
}
this.input = ''
this.show = true
},
change(e) {
// console.log('change');
this.input += e
},
close() {
// console.log('close');
this.show = false
},
cancel() {
// console.log('cancel');
this.show = false
},
confirm() {
// console.log('confirm');
this.show = false
},
backspace() {
this.input = this.input.slice(0, -1)
}
}
}
</script>
<style lang="scss">
.u-page {
padding: 0;
}
</style>

View File

@ -0,0 +1,104 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础功能</text>
<view class="u-demo-block__content">
<u-notice-bar
:text="text1"
></u-notice-bar>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">可关闭</text>
<view class="u-demo-block__content">
<u-notice-bar
:text="text5"
mode="closable"
></u-notice-bar>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义横向滚动速度</text>
<view class="u-demo-block__content">
<u-notice-bar
:text="text2"
speed="250"
mode="closable"
></u-notice-bar>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">可跳转(点击右箭头)</text>
<view class="u-demo-block__content">
<u-notice-bar
:text="text3"
mode="link"
url="/pages/componentsB/tag/tag"
></u-notice-bar>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">横向步进滚动</text>
<view class="u-demo-block__content">
<u-notice-bar
:text="text4"
:step="true"
@click="click"
></u-notice-bar>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">纵向滚动</text>
<view class="u-demo-block__content">
<u-notice-bar
:text="text4"
direction="column"
@click="click"
></u-notice-bar>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义样式</text>
<view class="u-demo-block__content">
<u-notice-bar
:text="text1"
color="#ffffff"
bgColor="#f56c6c"
></u-notice-bar>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
text1: 'uView UI众多组件覆盖开发过程的各个需求,组件功能丰富,多端兼容。让您快速集成,开箱即用',
text2: 'uView UI众多的贴心小工具,是您开发过程中召之即来的利器,让您飞镖在手,百步穿杨',
text3: 'uView UI收集众多的常用页面和布局,减少开发者的重复工作,让您专注逻辑,事半功倍',
text4: [
'寒雨连江夜入吴',
'平明送客楚山孤',
'洛阳亲友如相问',
'一片冰心在玉壶'
],
text5: '涵盖uniapp各个方面,给开发者方向指导和设计理念,让您茅塞顿开,一马平川'
}
},
onLoad() {
},
methods: {
click(e) {
console.log(e)
}
},
}
</script>
<style lang="scss">
.u-demo-block__content {
@include flex(column);
}
</style>

View File

@ -0,0 +1,146 @@
<template>
<view class="u-page">
<u-gap
height="30"
bgColor="#fff"
></u-gap>
<u-cell-group>
<u-cell
:titleStyle="{fontWeight: 500}"
@click="openNotify(item.notifyData)"
:title="item.title"
v-for="(item, index) in list"
:key="index"
isLink
>
<image
slot="icon"
class="u-cell-icon"
:src="item.iconUrl"
mode="widthFix"
></image>
</u-cell>
</u-cell-group>
<u-notify ref="uNotify"></u-notify>
</view>
</template>
<script>
export default {
data() {
return {
show: false,
notifyData: {
message: 'notify顶部提示',
type: 'primary',
color: '#ffffff',
bgColor: '',
fontSize: 15,
duration: 3000,
},
list: [{
notifyData: {
message: 'notify顶部提示',
type: 'primary',
color: '#ffffff',
bgColor: '',
fontSize: 15,
duration: 3000
},
title: '主要通知',
iconUrl: 'https://cdn.uviewui.com/uview/demo/notify/main.png'
}, {
notifyData: {
message: 'notify顶部提示',
type: 'success',
color: '#ffffff',
bgColor: '',
fontSize: 15,
duration: 3000,
safeAreaInsetTop: false
},
title: '成功通知',
iconUrl: 'https://cdn.uviewui.com/uview/demo/notify/success.png'
}, {
notifyData: {
message: 'notify顶部提示',
type: 'error',
color: '#ffffff',
bgColor: '',
fontSize: 14,
duration: 3000,
safeAreaInsetTop: false
},
title: '危险通知',
iconUrl: 'https://cdn.uviewui.com/uview/demo/notify/error.png'
}, {
notifyData: {
message: 'notify顶部提示',
type: 'warning',
color: '#ffffff',
bgColor: '',
fontSize: 15,
duration: 3000,
safeAreaInsetTop: false
},
title: '警告通知',
iconUrl: 'https://cdn.uviewui.com/uview/demo/notify/warning.png'
},
{
notifyData: {
message: 'notify顶部提示',
color: '#fff',
bgColor: '#000',
fontSize: 15,
duration: 3000,
safeAreaInsetTop: false
},
title: '自定义样式',
iconUrl: 'https://cdn.uviewui.com/uview/demo/notify/customStyle.png'
},
{
notifyData: {
message: 'notify顶部提示',
type: 'primary',
color: '#ffffff',
bgColor: '',
fontSize: 15,
duration: 6000,
safeAreaInsetTop: false
},
title: '自定义时间',
iconUrl: 'https://cdn.uviewui.com/uview/demo/notify/customTime.png'
},
{
notifyData: {
message: 'notify顶部提示',
color: '#fff',
bgColor: '',
fontSize: 15,
duration: 3000,
safeAreaInsetTop: true
},
title: '插入状态栏高度',
iconUrl: 'https://cdn.uviewui.com/uview/demo/notify/height.png'
}
]
}
},
onLoad() {},
methods: {
openNotify(params) {
this.$refs.uNotify.show({
...params
})
// 也可以通过主题形式调用,如:
// this.$refs.uNotify.primary('Primary主题')
}
}
}
</script>
<style lang="scss">
.u-page {
padding: 0;
}
</style>

View File

@ -0,0 +1,250 @@
<template>
<view class="">
<u-cell-group :border="true">
<u-cell
:border="true"
title="基础用法"
>
<u-number-box
slot="right-icon"
v-model="value1"
step="1"
@change="change"
>
</u-number-box>
</u-cell>
<u-cell
:border="true"
title="步长设置"
>
<u-number-box
slot="right-icon"
v-model="value2"
:step="step1"
@change="change"
>
</u-number-box>
</u-cell>
<u-cell
:border="true"
title="限制输入范围"
>
<u-number-box
slot="right-icon"
v-model="value3"
step="1"
:min="min1"
:max="max1"
@change="change"
>
</u-number-box>
</u-cell>
<u-cell
:border="true"
title="限制输入整数"
>
<u-number-box
slot="right-icon"
v-model="value4"
step="1"
integer
@change="change"
>
</u-number-box>
</u-cell>
<u-cell
:border="true"
title="禁用状态"
>
<u-number-box
slot="right-icon"
v-model="value5"
step="1"
:disabled="true"
@change="change"
>
</u-number-box>
</u-cell>
<u-cell
:border="true"
title="禁用输入框"
>
<u-number-box
slot="right-icon"
v-model="value6"
step="1"
:disabledInput="true"
@change="change"
>
</u-number-box>
</u-cell>
<u-cell
:border="true"
title="禁用长按"
>
<u-number-box
slot="right-icon"
v-model="value7"
step="1"
:longPress="false"
@change="change"
>
</u-number-box>
</u-cell>
<u-cell
:border="true"
title="固定小数位数"
>
<u-number-box
slot="right-icon"
v-model="value8"
step="0.2"
decimalLength="1"
@change="change"
>
</u-number-box>
</u-cell>
<u-cell
:border="true"
title="异步变更"
>
<u-number-box
slot="right-icon"
v-model="value9"
step="1"
:asyncChange="asyncChange"
@change="myAsyncChange"
>
</u-number-box>
</u-cell>
<u-cell
:border="true"
title="自定义大小颜色样式"
>
<u-number-box
slot="right-icon"
v-model="value10"
step="1"
:color="color"
:buttonSize="buttonSize"
:bgColor="bgColor"
@change="change"
iconStyle="color: #fff"
>
</u-number-box>
</u-cell>
<u-cell
:border="true"
title="自定义(为0时减少按钮会消失)"
>
<u-number-box
slot="right-icon"
v-model="value11"
step="1"
:min="0"
:showMinus="value11 > 0"
>
<view
slot="minus"
class="minus"
>
<u-icon
name="minus"
size="12"
></u-icon>
</view>
<text
slot="input"
style="width: 50px;text-align: center;"
class="input"
>{{value11}}</text>
<view
slot="plus"
class="plus"
>
<u-icon
name="plus"
color="#FFFFFF"
size="12"
></u-icon>
</view>
</u-number-box>
</u-cell>
</u-cell-group>
</view>
</template>
<script>
export default {
data() {
return {
value1: 3,
value2: 3,
value3: 3,
value4: 3,
value5: 3,
value6: 3,
value7: 3,
value8: 3.1,
value9: 3,
value10: 3,
value11: 3,
step1: 2,
min1: 5,
max1: 8,
asyncChange: true,
color: '#FFFFFF',
buttonSize: 36,
bgColor: '#2979ff'
}
},
methods: {
change(e) {
console.log('change', e);
},
myAsyncChange(e) {
this.asyncChange = false
uni.showLoading({
title: '正在加载'
})
setTimeout(() => {
uni.hideLoading()
this.value9 = e
this.asyncChange = true
}, 3000)
}
}
}
</script>
<style lang="scss">
.minus {
width: 22px;
height: 22px;
border-width: 1px;
border-color: #E6E6E6;
border-top-left-radius: 100px;
border-top-right-radius: 100px;
border-bottom-left-radius: 100px;
border-bottom-right-radius: 100px;
@include flex;
justify-content: center;
align-items: center;
}
.input {
padding: 0 10px;
}
.plus {
width: 22px;
height: 22px;
background-color: #FF0000;
border-radius: 50%;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
}
</style>

View File

@ -0,0 +1,203 @@
/**
* @fileoverview 用于测试的 html 内容
*/
module.exports = `<title>富文本示例</title>
<div>
<section style="text-align: center; margin: 0px auto;">
<section style="border-radius: 4px; border: 1px solid #757576; display: inline-block; padding: 5px 20px;">
<span style="font-size: 18px; color: #595959;">表格</span>
</section>
</section>
<section style="margin-top: 1.5em;">
<table width="100%" cellspacing="0" cellpadding="5">
<thead>
<tr>
<th>标题 1</th>
<th>标题 2</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">内容 1</td>
<td align="center">内容 2</td>
</tr>
<tr style="background-color: #f6f8fa;">
<td align="center">内容 3</td>
<td align="center"><a>链接</a></td>
</tr>
<tr>
<td align="center">内容 5</td>
<td align="center">内容 6</td>
</tr>
</tbody>
</table>
<div style="font-size: 12px; color: gray; text-align: center; margin-top: 5px;">普通表格</div>
</section>
<section style="margin-top: 1.5em;">
<table width="500px" cellspacing="0" cellpadding="5">
<thead>
<tr>
<th>标题 1</th>
<th>标题 2</th>
<th>标题 3</th>
<th>标题 4</th>
<th>标题 5</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">内容 1</td>
<td align="center">内容 2</td>
<td align="center">内容 3</td>
<td align="center">内容 4</td>
<td align="center">内容 5</td>
</tr>
<tr style="background-color: #f6f8fa;">
<td align="center"><a>链接</a></td>
<td align="center">内容 7</td>
<td align="center">内容 8</td>
<td align="center">内容 9</td>
<td align="center">内容 10</td>
</tr>
<tr>
<td align="center">内容 11</td>
<td align="center">内容 12</td>
<td align="center">内容 13</td>
<td align="center">内容 14</td>
<td align="center">内容 15</td>
</tr>
</tbody>
</table>
<div style="font-size: 12px; color: gray; text-align: center; margin-top: 5px;">长表格,可以单独横向滚动</div>
</section>
<section style="margin-top: 1.5em;">
<table width="100%" cellspacing="0" cellpadding="5">
<thead>
<tr>
<th align="center">标题 1</th>
<th align="center">标题 2</th>
<th align="center">标题 3</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center" colspan="2">内容 1</td>
<td align="center" rowspan="2">内容 2</td>
</tr>
<tr>
<td align="center" rowspan="2">内容 3</td>
<td align="center">内容 4</td>
</tr>
<tr>
<td align="center" colspan="2">内容 5</td>
</tr>
<tr>
<td align="center">内容 6</td>
<td align="center">内容 7</td>
<td align="center"><a>链接</a></td>
</tr>
</tbody>
</table>
<div style="font-size: 12px; color: gray; text-align: center; margin-top: 5px;">含有合并单元格的表格</div>
</section>
<section id="list" style="text-align: center; margin: 0px auto; margin-top: 2em">
<section style="border-radius: 4px; border: 1px solid #757576; display: inline-block; padding: 5px 20px;">
<span style="font-size: 18px; color: #595959;">列表</span>
</section>
</section>
<section style="margin-top: 1.5em;">
<ol style="margin-bottom: 1.5em;">
<li>这是第一条列表项</li>
<li>这是第二条列表项</li>
<li>这是第三条 <a>链接</a></li>
</ol>
<ol type="A" style="margin-bottom: 1.5em;">
<li>这是第一条列表项</li>
<li>这是第二条列表项</li>
<li>这是第三条 <a>链接</a></li>
</ol>
<ol type="I" style="margin-bottom: 1.5em;">
<li>这是第一条列表项</li>
<li>这是第二条列表项</li>
<li>这是第三条 <a>链接</a></li>
</ol>
<ul>
<li>第一级无序列表</li>
<li>第一级无序列表
<ul>
<li>第二级无序列表</li>
<li>第二级无序列表
<ul>
<li>第三级无序列表</li>
<li>第三级 <a>链接</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
<section style="text-align: center; margin: 0px auto; margin-top: 2em">
<section style="border-radius: 4px; border: 1px solid #757576; display: inline-block; padding: 5px 20px;">
<span style="font-size: 18px; color: #595959;">文本</span>
</section>
</section>
<section style="margin-top: 1.5em;">
<p style="margin-bottom: 1em;">
<ruby>
拼<rp>(</rp><rt>pin</rt><rp>)</rp>
音<rp>(</rp><rt>yin</rt><rp>)</rp>
</ruby>
&nbsp;&nbsp;<i>斜体</i>
&nbsp;&nbsp;<b>粗体</b>
&nbsp;&nbsp;上标<sup>1</sup>
&nbsp;&nbsp;下标<sub>2</sub>
</p>
<p style="margin-bottom: 1em;">
<span style="text-decoration: overline;">上划线</span>
&nbsp;&nbsp;<s>中划线</s>
&nbsp;&nbsp;<u>下划线</u>
</p>
<p>
<big>大一号</big>
&nbsp;&nbsp;<span>正常</span>
&nbsp;&nbsp;<small>小一号</small>
</p>
<h2 style="margin-top: 0.5em;">大标题</h2>
<h3 style="margin-top: 0.5em;">中标题</h3>
<h4 style="margin-top: 0.5em;">小标题</h4>
</section>
<section style="text-align: center; margin: 0px auto; margin-top: 2em">
<section style="border-radius: 4px; border: 1px solid #757576; display: inline-block; padding: 5px 20px;">
<span style="font-size: 18px; color: #595959;">链接</span>
</section>
</section>
<section style="margin-top: 1.5em; text-align: center;">
<a href="#">跳转到顶部</a>&nbsp;&nbsp;&nbsp;<a href="#list">跳转到列表</a>
<div style="font-size: 12px; color: gray; margin-top: 5px;">锚点链接,将滚动到对应位置</div>
</section>
<section style="margin-top: 1.5em; text-align: center;">
<a href="https://github.com/jin-yufeng/mp-html">外部链接</a>
<div style="font-size: 12px; color: gray; margin-top: 5px;">外部链接,将复制链接</div>
</section>
<section style="margin-top: 1.5em; text-align: center;">
<a href="/pages/componentsB/parse/jump">内部链接</a>
<div style="font-size: 12px; color: gray; margin-top: 5px;">内部链接,将跳转页面</div>
</section>
<section style="text-align: center; margin: 0px auto; margin-top: 2em">
<section style="border-radius: 4px; border: 1px solid #757576; display: inline-block; padding: 5px 20px;">
<span style="font-size: 18px; color: #595959;">图片</span>
</section>
</section>
<section style="margin-top: 1.5em; text-align: center;">
<img src="/demo-thumb.jpg?sign=91b3e495d16f96a0df3d263c9ff95821&t=1609059235" original-src="/demo.jpg?sign=af7082bed28711177bd952dbab67373e&t=1609059255">
<div style="font-size: 12px; color: gray; margin-top: 5px;">点击预览高清图</div>
</section>
<section style="margin-top: 1.5em; text-align: center;">
<svg width="40px" height="40px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;">
<path fill="#000" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z">
<animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"/>
</path>
</svg>
<div style="font-size: 12px; color: gray; margin-top: 5px;">svg 动画</div>
</section>
</div>`

View File

@ -0,0 +1,12 @@
<template>
<view>
跳转测试页面
</view>
</template>
<script>
export default {}
</script>
<style>
</style>

View File

@ -0,0 +1,51 @@
<template>
<view class="u-content">
<u-parse container-style="padding: 20px" :content="content" domain="https://6874-html-foe72-1259071903.tcb.qcloud.la/demo" lazy-load scroll-table selectable use-anchor :tag-style="tagStyle" @load="load" @ready="ready" @imgTap="imgTap" @linkTap="linkTap" />
</view>
</template>
<script>
const content = require('./content')
export default {
data() {
return {
content: '',
tagStyle: {
table: 'box-sizing: border-box; border-top: 1px solid #dfe2e5; border-left: 1px solid #dfe2e5;',
th: 'border-right: 1px solid #dfe2e5; border-bottom: 1px solid #dfe2e5;',
td: 'border-right: 1px solid #dfe2e5; border-bottom: 1px solid #dfe2e5;',
li: 'margin: 5px 0;'
}
}
},
onLoad() {
// 模拟网络请求
setTimeout(() => {
this.content = content
}, 200)
},
methods: {
load() {
// dom 结构加载完毕时触发
},
ready() {
// 渲染完毕时触发
},
imgTap() {
// 图片被点击时触发
},
linkTap() {
// 链接被点击时触发
}
}
}
</script>
<style lang="scss">
.u-content {
padding: 24rpx;
font-size: 32rpx;
color: $u-content-color;
line-height: 1.6;
}
</style>

View File

@ -0,0 +1,155 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础功能</text>
<view class="u-demo-block__content">
<u-line-progress :percentage="percentage1">
</u-line-progress>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">不显示百分比</text>
<view class="u-demo-block__content">
<u-line-progress
:showText="false"
:percentage="percentage2"
>
</u-line-progress>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义高度</text>
<view class="u-demo-block__content">
<u-line-progress
height="8"
:showText="false"
:percentage="percentage3"
>
</u-line-progress>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义颜色</text>
<view class="u-demo-block__content">
<u-line-progress
height="8"
:showText="false"
:percentage="percentage4"
activeColor="#3c9cff"
inactiveColor="#f3f4f6"
>
</u-line-progress>
</view>
</view>
<view
class="u-demo-block"
v-if="!androidNvue"
>
<text class="u-demo-block__title">自定义样式(不支持安卓环境的nvue)</text>
<view class="u-demo-block__content">
<u-line-progress
height="8"
:showText="false"
:percentage="percentage5"
activeColor="#3c9cff"
inactiveColor="#f3f4f6"
>
<text class="u-percentage-slot">{{percentage4}}%</text>
</u-line-progress>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">手动加减</text>
<view class="u-demo-block__content">
<u-line-progress
height="8"
:showText="false"
:percentage="percentage6"
activeColor="#3c9cff"
inactiveColor="#f3f4f6"
>
</u-line-progress>
<view class="button-group">
<view class="button-group__circle" hover-class="u-hover-class" @click="computedWidth('minus')">
<text class="button-group__circle__text">减少</text>
</view>
<view class="button-group__circle" hover-class="u-hover-class" @click="computedWidth('plus')">
<text class="button-group__circle__text">增加</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
androidNvue: false,
percentage1: 30,
percentage2: 40,
percentage3: 50,
percentage4: 60,
percentage5: 70,
percentage6: 50,
}
},
onLoad() {
// #ifdef APP-NVUE
this.androidNvue = uni.$u.os() === 'android'
// #endif
uni.$u.sleep(2500).then(() => {
this.percentage1 = 120
})
},
methods: {
computedWidth(type) {
if(type === 'plus') {
this.percentage6 = uni.$u.range(0, 100, this.percentage6 + 10)
} else {
this.percentage6 = uni.$u.range(0, 100, this.percentage6 - 10)
}
}
},
}
</script>
<style lang="scss">
.u-page {}
.u-percentage-slot {
padding: 1px 5px;
background-color: $u-warning;
color: #fff;
border-radius: 100px;
font-size: 10px;
margin-right: -5px;
}
.u-demo-block__content {
flex-direction: column !important;
flex-wrap: nowrap;
align-items: stretch;
}
.button-group {
@include flex;
justify-content: center;
&__circle {
width: 50px;
height: 50px;
background-color: #dbfbdb;
border-radius: 100px;
justify-content: center;
align-items: center;
margin: 30px 30px;
&__text {
color: rgb(25, 190, 107);
font-size: 13px;
}
}
}
</style>

View File

@ -0,0 +1,218 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础功能</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-search
v-model="value1"
:show-action="false"
@change="change"
></u-search>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">设置初始值</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-search
v-model="value2"
:show-action="false"
></u-search>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">搜索框形状</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-search
v-model="value3"
:show-action="false"
shape="round"
></u-search>
</view>
</view>
<view class="u-demo-block__content m-t-10">
<view class="u-page__tag-item">
<u-search
v-model="value4"
:show-action="false"
shape="square"
></u-search>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">右侧控件</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-search v-model="value5"></u-search>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">禁用输入框</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-search
placeholder="输入框被禁用,可以监听点击事件进行跳转"
disabled
:show-action="false"
></u-search>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">点击左侧图标</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-search
v-model="value6"
:show-action="false"
@clickIcon="clickIcon"
></u-search>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">搜索框内容水平对齐</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-search
v-model="value7"
:show-action="false"
input-align="left"
></u-search>
</view>
</view>
<view class="u-demo-block__content m-t-10">
<view class="u-page__tag-item">
<u-search
v-model="value8"
:show-action="false"
input-align="center"
></u-search>
</view>
</view>
<view class="u-demo-block__content m-t-10">
<view class="u-page__tag-item">
<u-search
v-model="value9"
:show-action="false"
input-align="right"
></u-search>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-search
v-model="value10"
:show-action="false"
borderColor="rgb(230, 230, 230)"
bgColor="#fff"
></u-search>
</view>
</view>
<view class="u-demo-block__content m-t-10">
<view class="u-page__tag-item">
<u-search
v-model="value11"
:show-action="false"
search-icon-color="#FF0000"
></u-search>
</view>
</view>
<view class="u-demo-block__content m-t-10">
<view class="u-page__tag-item">
<u-search
v-model="value12"
:show-action="false"
placeholder-color="#FF0000"
></u-search>
</view>
</view>
<view class="u-demo-block__content m-t-10">
<view class="u-page__tag-item">
<u-search
v-model="value13"
:show-action="false"
color="#FF0000"
></u-search>
</view>
</view>
<view class="u-demo-block__content m-t-10">
<view class="u-page__tag-item">
<u-search
v-model="value14"
label="手机"
:show-action="false"
>
</u-search>
</view>
</view>
<view class="u-demo-block__content m-t-10">
<view class="u-page__tag-item">
<u-search
v-model="value15"
search-icon="scan"
:show-action="false"
>
</u-search>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
value1: '',
value2: '天山雪莲',
value3: '',
value4: '',
value5: '',
value6: '',
value7: '',
value8: '',
value9: '',
value10: '',
value11: '',
value12: '',
value13: '',
value14: '',
value15: ''
}
},
watch: {
value1(newValue, oldValue) {
// console.log('value1', newValue);
}
},
methods: {
change(e) {
console.log(e);
},
clickIcon() {
uni.$u.toast('点击了左侧图标')
}
}
}
</script>
<style lang="scss">
.u-page__tag-item {
@include flex(column);
flex: 1
}
.m-t-10 {
margin-top: 10px;
}
</style>

View File

@ -0,0 +1,81 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基本案例</text>
<view class="u-page__slide-item">
<u-slider
v-model="value1"
></u-slider>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义范围(0—50)</text>
<view class="u-page__slide-item">
<u-slider
v-model="value2"
showValue
min="0"
max="50"
></u-slider>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">指定步长(每次步进5)</text>
<view class="u-page__slide-item">
<u-slider
v-model="value4"
:step="5"
></u-slider>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义样式</text>
<view class="u-page__slide-item">
<u-slider
v-model="value5"
activeColor="#deab8a"
blockColor="#f47920"
></u-slider>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
value1: 30,
value2: 30,
value3: 30,
value4: 30,
value5: 30
}
},
watch: {
value1(n) {
// console.log(n);
}
},
methods: {
moving(value) {
// console.log('moving', value)
},
click(value) {
// console.log('click', value)
},
end(value) {
// console.log('end', value)
},
start(value) {
// console.log('start', value)
}
}
}
</script>
<style lang="scss">
.u-page {
}
</style>

View File

@ -0,0 +1,177 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础功能</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-switch
v-model="value1"
@change="change"
></u-switch>
</view>
<view class="u-page__tag-item">
<u-switch v-model="value2"></u-switch>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">加载中</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-switch
v-model="value3"
loading
></u-switch>
</view>
<view class="u-page__tag-item">
<u-switch
v-model="value4"
loading
></u-switch>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">禁用状态</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-switch
v-model="value5"
disabled
></u-switch>
</view>
<view class="u-page__tag-item">
<u-switch
v-model="value6"
disabled
></u-switch>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义尺寸</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-switch
v-model="value7"
size="28"
></u-switch>
</view>
<view class="u-page__tag-item">
<u-switch
v-model="value8"
size="20"
></u-switch>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义颜色</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-switch
v-model="value9"
activeColor="#f56c6c"
loading
></u-switch>
</view>
<view class="u-page__tag-item">
<u-switch
v-model="value10"
activeColor="#5ac725"
loading
></u-switch>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义样式</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-switch
:space="2"
v-model="value11"
activeColor="#f56c6c"
inactiveColor="rgb(230, 230, 230)"
></u-switch>
</view>
<view class="u-page__tag-item">
<u-switch
space="2"
v-model="value12"
activeColor="#f9ae3d"
inactiveColor="rgb(230, 230, 230)"
></u-switch>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">异步控制</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-switch
v-model="value13"
asyncChange
@change="asyncChange"
></u-switch>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
value1: false,
value2: true,
value3: false,
value4: true,
value5: false,
value6: true,
value7: false,
value8: true,
value9: true,
value10: true,
value11: false,
value12: true,
value13: true,
}
},
watch: {
value1(newValue, oldValue) {
console.log('v-model', newValue);
}
},
methods: {
change(e) {
console.log('change', e);
},
asyncChange(e) {
uni.showModal({
content: e ? '确定要打开吗' : '确定要关闭吗',
success: (res) => {
if (res.confirm) {
this.value13 = e
}
}
})
}
}
}
</script>
<style lang="scss">
.u-page {
&__tag-item {
margin-right: 30px;
}
}
.u-demo-block__content {
flex-direction: row;
flex-wrap: wrap;
align-items: center;
}
</style>

View File

@ -0,0 +1,274 @@
<template>
<view class="u-page">
<view class="u-page__item">
<text class="u-page__item__title">基础功能</text>
<u-tabbar
:value="value1"
@change="change1"
:fixed="false"
:placeholder="false"
:safeAreaInsetBottom="false"
>
<u-tabbar-item
text="首页"
icon="home"
@click="click1"
></u-tabbar-item>
<u-tabbar-item
text="放映厅"
icon="photo"
@click="click1"
></u-tabbar-item>
<u-tabbar-item
text="直播"
icon="play-right"
@click="click1"
></u-tabbar-item>
<u-tabbar-item
text="我的"
icon="account"
@click="click1"
></u-tabbar-item>
</u-tabbar>
</view>
<view class="u-page__item">
<text class="u-page__item__title">显示徽标</text>
<u-tabbar
:value="value2"
:placeholder="false"
@change="name => value2 = name"
:fixed="false"
:safeAreaInsetBottom="false"
>
<u-tabbar-item
text="首页"
icon="home"
dot
></u-tabbar-item>
<u-tabbar-item
text="放映厅"
icon="photo"
badge="3"
></u-tabbar-item>
<u-tabbar-item
text="直播"
icon="play-right"
></u-tabbar-item>
<u-tabbar-item
text="我的"
icon="account"
></u-tabbar-item>
</u-tabbar>
</view>
<view class="u-page__item">
<text class="u-page__item__title">匹配标签的名称</text>
<u-tabbar
:placeholder="false"
:value="value3"
@change="name => value3 = name"
:fixed="false"
:safeAreaInsetBottom="false"
>
<u-tabbar-item
text="首页"
icon="home"
name="home"
></u-tabbar-item>
<u-tabbar-item
text="放映厅"
icon="photo"
name="photo"
></u-tabbar-item>
<u-tabbar-item
text="直播"
icon="play-right"
name="play-right"
></u-tabbar-item>
<u-tabbar-item
text="我的"
name="account"
icon="account"
></u-tabbar-item>
</u-tabbar>
</view>
<view class="u-page__item">
<text class="u-page__item__title">自定义图标/颜色</text>
<u-tabbar
:value="value4"
@change="name => value4 = name"
:fixed="false"
:placeholder="false"
activeColor="#d81e06"
:safeAreaInsetBottom="false"
>
<u-tabbar-item text="首页">
<image
class="u-page__item__slot-icon"
slot="active-icon"
src="https://cdn.uviewui.com/uview/common/bell-selected.png"
></image>
<image
class="u-page__item__slot-icon"
slot="inactive-icon"
src="https://cdn.uviewui.com/uview/common/bell.png"
></image>
</u-tabbar-item>
<u-tabbar-item
text="放映厅"
icon="photo"
></u-tabbar-item>
<u-tabbar-item
text="直播"
icon="play-right"
></u-tabbar-item>
<u-tabbar-item
text="我的"
icon="account"
></u-tabbar-item>
</u-tabbar>
</view>
<view class="u-page__item">
<text class="u-page__item__title">拦截切换事件(点击第二个标签)</text>
<u-tabbar
:value="value5"
:fixed="false"
@change="change5"
:safeAreaInsetBottom="false"
:placeholder="false"
>
<u-tabbar-item
text="首页"
icon="home"
>
</u-tabbar-item>
<u-tabbar-item
text="放映厅"
icon="photo"
></u-tabbar-item>
<u-tabbar-item
text="直播"
icon="play-right"
></u-tabbar-item>
<u-tabbar-item
text="我的"
icon="account"
></u-tabbar-item>
</u-tabbar>
</view>
<view class="u-page__item">
<text class="u-page__item__title">去除上边框</text>
<u-tabbar
:value="value7"
:placeholder="false"
:border="false"
@change="name => value7 = name"
:fixed="false"
:safeAreaInsetBottom="false"
>
<u-tabbar-item
text="首页"
icon="home"
></u-tabbar-item>
<u-tabbar-item
text="放映厅"
icon="photo"
></u-tabbar-item>
<u-tabbar-item
text="直播"
icon="play-right"
></u-tabbar-item>
<u-tabbar-item
text="我的"
icon="account"
></u-tabbar-item>
</u-tabbar>
</view>
<view class="u-page__item">
<text class="u-page__item__title">固定在底部(固定在屏幕最下方)</text>
<u-gap height="150"></u-gap>
<u-tabbar
:value="value6"
@change="name => value6 = name"
:fixed="true"
:placeholder="true"
:safeAreaInsetBottom="true"
>
<u-tabbar-item
text="首页"
icon="home"
>
</u-tabbar-item>
<u-tabbar-item
text="放映厅"
icon="photo"
></u-tabbar-item>
<u-tabbar-item
text="直播"
icon="play-right"
></u-tabbar-item>
<u-tabbar-item
text="我的"
icon="account"
></u-tabbar-item>
</u-tabbar>
</view>
</view>
</template>
<script>
export default {
data() {
return {
value1: 0,
value2: 1,
value3: 'play-right',
value4: 0,
value5: 0,
value6: 0,
value7: 3
}
},
onLoad() {
},
methods: {
change5(name) {
if (name === 1) return uni.$u.toast('请您先登录')
else this.value5 = name
},
change1(e) {
this.value1 = e
console.log('change1', e);
},
click1(e) {
console.log('click1', e);
}
},
}
</script>
<style lang="scss">
.u-page {
padding: 0;
&__item {
&__title {
color: $u-tips-color;
background-color: $u-bg-color;
padding: 15px;
font-size: 15px;
&__slot-title {
color: $u-primary;
font-size: 14px;
}
}
&__slot-icon {
width: 17px;
height: 17px;
}
}
}
</style>

View File

@ -0,0 +1,335 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础功能</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-tag
text="标签"
plain
size="mini"
type="warning"
>
</u-tag>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义主题</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-tag text="标签">
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="warning"
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="success"
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="error"
>
</u-tag>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">圆形标签</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-tag
text="标签"
plain
shape="circle"
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="warning"
shape="circle"
>
</u-tag>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">镂空标签</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-tag
text="标签"
plain
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="warning"
plain
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="success"
plain
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="error"
plain
>
</u-tag>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">镂空带背景色</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-tag
text="标签"
plain
plainFill
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="warning"
plain
plainFill
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="success"
plain
plainFill
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="error"
plain
plainFill
>
</u-tag>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义尺寸</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-tag
text="标签"
plain
size="mini"
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="warning"
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="success"
plain
size="large"
>
</u-tag>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">可关闭标签</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-tag
text="标签"
size="mini"
closable
:show="close1"
@close="close1 = false"
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="warning"
closable
:show="close2"
@close="close2 = false"
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="success"
plain
size="large"
closable
:show="close3"
@close="close3 = false"
>
</u-tag>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">带图片和图标</text>
<view class="u-demo-block__content">
<view class="u-page__tag-item">
<u-tag
text="标签"
size="mini"
icon="map"
plain
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="warning"
icon="tags-fill"
>
</u-tag>
</view>
<view class="u-page__tag-item">
<u-tag
text="标签"
type="success"
plain
size="large"
icon="https://cdn.uviewui.com/uview/example/tag.png"
>
</u-tag>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">单选标签</text>
<view class="u-demo-block__content">
<view
class="u-page__tag-item"
v-for="(item, index) in radios"
:key="index"
>
<u-tag
:text="`选项${index + 1}`"
:plain="!item.checked"
type="warning"
:name="index"
@click="radioClick"
>
</u-tag>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">多选标签</text>
<view class="u-demo-block__content">
<view
class="u-page__tag-item"
v-for="(item, index) in checkboxs"
:key="index"
>
<u-tag
:text="`选项${index + 1}`"
:plain="!item.checked"
type="warning"
:name="index"
@click="checkboxClick"
>
</u-tag>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
close1: true,
close2: true,
close3: true,
radios: [{
checked: true
},
{
checked: false
},
{
checked: false
}
],
checkboxs: [{
checked: true
},
{
checked: false
},
{
checked: false
}
]
}
},
methods: {
radioClick(name) {
this.radios.map((item, index) => {
item.checked = index === name ? true : false
})
},
checkboxClick(name) {
this.checkboxs[name].checked = !this.checkboxs[name].checked
}
}
}
</script>
<style lang="scss">
.u-page__tag-item {
margin-right: 20px;
}
.u-demo-block__content {
flex-direction: row;
flex-wrap: wrap;
align-items: center;
}
</style>

View File

@ -0,0 +1,113 @@
<template>
<view class="u-page">
<u-gap
height="30"
bgColor="#fff"
></u-gap>
<u-toast ref="uToast"></u-toast>
<u-cell-group title-bg-color="rgb(243, 244, 246)">
<u-cell
:titleStyle="{fontWeight: 500}"
:title="item.title"
v-for="(item, index) in list"
:key="index"
isLink
:icon="item.iconUrl"
@click="showToast(item)"
>
<!-- <image
slot="icon"
class="u-cell-icon"
:src="getIcon(item.icon)"
mode="widthFix"
></image> -->
</u-cell>
</u-cell-group>
</view>
</template>
<script>
export default {
data() {
return {
show: false,
list: [{
type: 'default',
title: '默认主题',
message: "锦瑟无端五十弦",
iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/default.png'
},
{
type: 'error',
icon: false,
title: '失败主题',
message: "一弦一柱思华年",
iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/error.png'
},
{
type: 'success',
title: '成功主题(带图标)',
message: "庄生晓梦迷蝴蝶",
iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
},
{
type: 'warning',
position: "top",
title: '位置偏移上方',
message: "望帝春心托杜鹃",
iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/top.png'
},
{
type: 'loading',
title: '正在加载',
message: "正在加载",
iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/loading.png'
},
{
type: 'default',
title: '结束后跳转标签页',
message: "此情可待成追忆",
url: '/pages/componentsB/tag/tag',
iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/jump.png'
}
],
}
},
computed: {
getIcon() {
return path => {
return 'https://cdn.uviewui.com/uview/example/' + path + '.png';
}
},
},
methods: {
showToast(params) {
this.$refs.uToast.show({
...params,
complete() {
params.url && uni.navigateTo({
url: params.url
})
}
})
}
}
}
</script>
<style lang="scss">
.u-page {
padding: 0;
}
.u-cell-icon {
width: 36rpx;
height: 36rpx;
margin-right: 8rpx;
}
.u-cell-group__title__text {
font-weight: bold;
}
</style>

View File

@ -0,0 +1,180 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础用法</text>
<view class="u-demo-block__content">
<view class="u-page__upload-item">
<u-upload
:fileList="fileList1"
@afterRead="afterRead"
@delete="deletePic"
name="1"
multiple
:maxCount="10"
></u-upload>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">上传视频</text>
<view class="u-demo-block__content">
<view class="u-page__upload-item">
<u-upload
:fileList="fileList2"
@afterRead="afterRead"
@delete="deletePic"
name="2"
multiple
:maxCount="10"
accept="video"
></u-upload>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">文件预览</text>
<view class="u-demo-block__content">
<view class="u-page__upload-item">
<u-upload
:fileList="fileList3"
@afterRead="afterRead"
@delete="deletePic"
name="3"
multiple
:maxCount="10"
:previewFullImage="true"
></u-upload>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">隐藏上传按钮</text>
<view class="u-demo-block__content">
<view class="u-page__upload-item">
<u-upload
:fileList="fileList4"
@afterRead="afterRead"
@delete="deletePic"
name="4"
multiple
:maxCount="2"
></u-upload>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">限制上传数量</text>
<view class="u-demo-block__content">
<view class="u-page__upload-item">
<u-upload
:fileList="fileList5"
@afterRead="afterRead"
@delete="deletePic"
name="5"
multiple
:maxCount="3"
></u-upload>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">自定义上传样式</text>
<view class="u-demo-block__content">
<view class="u-page__upload-item">
<u-upload
:fileList="fileList6"
@afterRead="afterRead"
@delete="deletePic"
name="6"
multiple
:maxCount="1"
width="250"
height="150"
>
<image src="https://cdn.uviewui.com/uview/demo/upload/positive.png" mode="widthFix" style="width: 250px;height: 150px;"></image>
</u-upload>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
fileList1: [],
fileList2: [],
fileList3: [{
url: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
}],
fileList4: [{
url: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
},
{
url: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
}
],
fileList5: [],
fileList6: [],
fileList7: []
}
},
onLoad() {
},
methods: {
// 删除图片
deletePic(event) {
this[`fileList${event.name}`].splice(event.index, 1)
},
// 新增图片
async afterRead(event) {
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
let lists = [].concat(event.file)
let fileListLen = this[`fileList${event.name}`].length
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
status: 'uploading',
message: '上传中'
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url)
let item = this[`fileList${event.name}`][fileListLen]
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: result
}))
fileListLen++
}
},
uploadFilePromise(url) {
return new Promise((resolve, reject) => {
let a = uni.uploadFile({
url: 'http://www.example.com/upload', // 仅为示例,非真实的接口地址
filePath: url,
name: 'file',
formData: {
user: 'test'
},
success: (res) => {
setTimeout(() => {
resolve(res.data.data)
}, 1000)
}
});
})
},
},
}
</script>
<style lang="scss">
.u-page {
&__upload-item{
margin-top:5px;
}
}
</style>

View File

@ -0,0 +1,218 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础使用</text>
<view class="u-demo-block__content">
<view class="album">
<view class="album__avatar">
<image
src="/static/uview/common/logo.png"
mode=""
style="width: 32px;height: 32px;"
></image>
</view>
<view class="album__content">
<u--text
text="uView UI"
type="primary"
bold
size="17"
></u--text>
<u--text
margin="0 0 8px 0"
text="全面的组件和便捷的工具会让您信手拈来,如鱼得水"
></u--text>
<u-album
:urls="urls1"
keyName="src2"
></u-album>
</view>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">多图模式</text>
<view class="u-demo-block__content">
<view class="album">
<view class="album__avatar">
<image
src="/static/uview/common/logo.png"
mode=""
style="width: 32px;height: 32px;"
></image>
</view>
<view class="album__content">
<u--text
text="uView UI"
type="primary"
bold
size="17"
></u--text>
<u--text
margin="0 0 8px 0"
text="全面的组件和便捷的工具会让您信手拈来,如鱼得水"
></u--text>
<u-album :urls="urls2"></u-album>
</view>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">图文对齐</text>
<view class="u-demo-block__content">
<view class="album">
<view class="album__avatar">
<image
src="/static/uview/common/logo.png"
mode=""
style="width: 32px;height: 32px;"
></image>
</view>
<view class="album__content">
<u--text
text="uView UI"
type="primary"
bold
size="17"
></u--text>
<view :style="{
marginBottom: '8px',
width: albumWidth + 'px'
}">
<u--text
text="全面的组件和便捷的工具会让您信手拈来,如鱼得水"
:customStyle="{
width: albumWidth + 'px'
}"
></u--text>
</view>
<u-album
:urls="urls2"
@albumWidth="width => albumWidth = width"
multipleSize="68"
></u-album>
</view>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">更改裁剪模式</text>
<view class="u-demo-block__content">
<view class="album">
<view class="album__avatar">
<image
src="/static/uview/common/logo.png"
mode=""
style="width: 32px;height: 32px;"
></image>
</view>
<view class="album__content">
<u--text
text="uView UI"
type="primary"
bold
size="17"
></u--text>
<u--text
margin="0 0 8px 0"
text="全面的组件和便捷的工具会让您信手拈来,如鱼得水"
></u--text>
<u-album
:urls="urls3"
rowCount="2"
maxCount="4"
multipleMode="scaleToFill"
></u-album>
</view>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">更改图片大小</text>
<view class="u-demo-block__content">
<view class="album">
<view class="album__avatar">
<image
src="/static/uview/common/logo.png"
mode=""
style="width: 32px;height: 32px;"
></image>
</view>
<view class="album__content">
<u--text
text="uView UI"
type="primary"
bold
size="17"
></u--text>
<u--text
margin="0 0 8px 0"
text="全面的组件和便捷的工具会让您信手拈来,如鱼得水"
></u--text>
<u-album
:urls="urls4"
rowCount="2"
maxCount="4"
multipleSize="50"
></u-album>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
albumWidth: 0,
urls1: [{
src2: 'https://cdn.uviewui.com/uview/album/1.jpg',
}],
urls2: [
'https://cdn.uviewui.com/uview/album/1.jpg',
'https://cdn.uviewui.com/uview/album/2.jpg',
'https://cdn.uviewui.com/uview/album/3.jpg',
'https://cdn.uviewui.com/uview/album/4.jpg',
'https://cdn.uviewui.com/uview/album/5.jpg',
'https://cdn.uviewui.com/uview/album/6.jpg',
'https://cdn.uviewui.com/uview/album/7.jpg',
'https://cdn.uviewui.com/uview/album/8.jpg',
'https://cdn.uviewui.com/uview/album/9.jpg',
'https://cdn.uviewui.com/uview/album/10.jpg',
],
urls3: [
'https://cdn.uviewui.com/uview/album/5.jpg',
'https://cdn.uviewui.com/uview/album/6.jpg',
'https://cdn.uviewui.com/uview/album/7.jpg',
'https://cdn.uviewui.com/uview/album/8.jpg',
],
urls4: [
'https://cdn.uviewui.com/uview/album/7.jpg',
'https://cdn.uviewui.com/uview/album/8.jpg',
'https://cdn.uviewui.com/uview/album/9.jpg',
'https://cdn.uviewui.com/uview/album/10.jpg',
]
}
}
}
</script>
<style lang="scss">
.album {
@include flex;
align-items: flex-start;
&__avatar {
background-color: $u-bg-color;
padding: 5px;
border-radius: 3px;
}
&__content {
margin-left: 10px;
flex: 1;
}
}
</style>

View File

@ -0,0 +1,182 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础演示</text>
<view class="u-demo-block__content">
<u-avatar :src="src1"></u-avatar>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">头像形状</text>
<view class="u-demo-block__content">
<view class="u-avatar-item">
<u-avatar
:src="src2"
shape="circle"
@click="click"
></u-avatar>
</view>
<view class="u-avatar-item">
<u-avatar
:src="src3"
shape="square"
></u-avatar>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">头像尺寸</text>
<view class="u-demo-block__content">
<view class="u-avatar-item">
<u-avatar
:src="src4"
size="30"
></u-avatar>
</view>
<view class="u-avatar-item">
<u-avatar
:src="src5"
size="40"
></u-avatar>
</view>
<view class="u-avatar-item">
<u-avatar
:src="src6"
size="50"
></u-avatar>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">图标头像</text>
<view class="u-demo-block__content">
<view class="u-avatar-item">
<u-avatar
icon="red-packet-fill"
fontSize="22"
></u-avatar>
</view>
<view class="u-avatar-item">
<u-avatar
icon="star-fill"
fontSize="22"
></u-avatar>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">文字头像(自动背景色)</text>
<view class="u-demo-block__content">
<view class="u-avatar-item">
<u-avatar
text="U"
fontSize="20"
randomBgColor
:colorIndex="0"
></u-avatar>
</view>
<view class="u-avatar-item">
<u-avatar
text="邓"
fontSize="18"
randomBgColor
></u-avatar>
</view>
<view class="u-avatar-item">
<u-avatar
text="张"
fontSize="18"
randomBgColor
></u-avatar>
</view>
<view class="u-avatar-item">
<u-avatar
text="王"
fontSize="18"
randomBgColor
></u-avatar>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">图片加载失败(显示默认头像)</text>
<view class="u-demo-block__content">
<u-avatar :src="src7"></u-avatar>
</view>
</view>
<!-- #ifdef MP-WEIXIN || MP-QQ || MP-BAIDU -->
<view class="u-demo-block">
<text class="u-demo-block__title">小程序开放能力</text>
<view class="u-demo-block__content">
<view class="u-avatar-item">
<u-avatar
mpAvatar
size="60"
></u-avatar>
</view>
</view>
</view>
<!-- #endif -->
<view class="u-demo-block">
<text class="u-demo-block__title">头像组</text>
<view class="u-demo-block__content">
<u-avatar-group
:urls="urls"
size="35"
gap="0.4"
></u-avatar-group>
</view>
<view class="u-demo-block__content" style="margin-top: 20px">
<u-avatar-group
:urls="urls"
size="35"
gap="0.6"
></u-avatar-group>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
src1: 'https://cdn.uviewui.com/uview/album/1.jpg',
src2: 'https://cdn.uviewui.com/uview/album/2.jpg',
src3: 'https://cdn.uviewui.com/uview/album/3.jpg',
src4: 'https://cdn.uviewui.com/uview/album/4.jpg',
src5: 'https://cdn.uviewui.com/uview/album/5.jpg',
src6: 'https://cdn.uviewui.com/uview/album/6.jpg',
src7: 'https://cdn.uviewui.com/uview/album/noExist.jpg',
urls: [
'https://cdn.uviewui.com/uview/album/1.jpg',
'https://cdn.uviewui.com/uview/album/2.jpg',
'https://cdn.uviewui.com/uview/album/3.jpg',
'https://cdn.uviewui.com/uview/album/4.jpg',
'https://cdn.uviewui.com/uview/album/7.jpg',
'https://cdn.uviewui.com/uview/album/6.jpg',
'https://cdn.uviewui.com/uview/album/5.jpg'
]
}
},
onLoad() {
},
methods: {
click(name) {
console.log('click', name);
}
},
}
</script>
<style lang="scss">
.u-demo-block__content {
@include flex;
align-items: center;
}
.u-avatar-item {
margin-right: 30px;
}
</style>

View File

@ -0,0 +1,203 @@
<template>
<view class="u-page">
<u-navbar
title="日历"
@leftClick="navigateBack"
safeAreaInsetTop
fixed
placeholder
></u-navbar>
<u-cell-group>
<u-cell
@click="showCalendar(index)"
:title="item.title"
v-for="(item, index) in list"
:key="index"
:label="values[index]"
isLink
>
<image
slot="icon"
class="u-cell-icon"
:src="item.iconUrl"
mode="widthFix"
></image>
</u-cell>
</u-cell-group>
<u-calendar
:show="show1"
defaultDate="2022-02-15"
@confirm="confirm"
@close="close"
></u-calendar>
<u-calendar
:show="show2"
mode="multiple"
:defaultDate="['2022-03-01']"
@confirm="confirm"
@close="close"
></u-calendar>
<u-calendar
:show="show3"
mode="range"
@confirm="confirm"
@close="close"
></u-calendar>
<u-calendar
:show="show4"
mode="range"
@confirm="confirm"
@close="close"
color="#f56c6c"
:defaultDate="customThemeDefaultDate"
></u-calendar>
<u-calendar
:show="show5"
mode="range"
@confirm="confirm"
@close="close"
:defaultDate="customTextDefaultDate"
startText="住店"
endText="离店"
confirmDisabledText="请选择离店日期"
:formatter="formatter"
></u-calendar>
<u-calendar
:show="show6"
@confirm="confirm"
@close="close"
:maxDate="maxDate"
></u-calendar>
<u-calendar
:show="show7"
@confirm="confirm"
@close="close"
showLunar
></u-calendar>
<u-calendar
:show="show8"
@confirm="confirm"
@close="close"
mode="multiple"
:defaultDate="defaultDateMultiple"
></u-calendar>
</view>
</template>
<script>
export default {
data() {
const d = new Date()
const year = d.getFullYear()
let month = d.getMonth() + 1
month = month < 10 ? `0${month}` : month
const date = d.getDate()
return {
index: 0,
show1: false,
show2: false,
show3: false,
show4: false,
show5: false,
show6: false,
show7: false,
show8: false,
values: ['','','','','','','',''],
customThemeDefaultDate: [`${year}-${month}-${date}`, `${year}-${month}-${date + 5}`],
customTextDefaultDate: [`${year}-${month}-${date}`],
maxDate: `${year}-${month}-${date + 10}`,
defaultDateMultiple: [`${year}-${month}-${date}`, `${year}-${month}-${date + 1}`, `${year}-${month}-${date + 2}`],
list: [{
title: '单个日期',
iconUrl: 'https://cdn.uviewui.com/uview/demo/calendar/7.png'
},
{
title: '多个日期',
iconUrl: 'https://cdn.uviewui.com/uview/demo/calendar/8.png'
},
{
title: '日期范围',
iconUrl: 'https://cdn.uviewui.com/uview/demo/calendar/9.png'
},
{
title: '自定义主题颜色',
iconUrl: 'https://cdn.uviewui.com/uview/demo/calendar/15.png'
},{
title: '自定义文案',
iconUrl: 'https://cdn.uviewui.com/uview/demo/calendar/14.png'
},{
title: '日期最大范围',
iconUrl: 'https://cdn.uviewui.com/uview/demo/calendar/13.png'
},{
title: '显示农历',
iconUrl: 'https://cdn.uviewui.com/uview/demo/calendar/5.png'
},{
title: '默认日期',
iconUrl: 'https://cdn.uviewui.com/uview/demo/calendar/10.png'
}
]
}
},
methods: {
showCalendar(index) {
this.index = index + 1
this[`show${index + 1}`] = true
},
navigateBack() {
uni.navigateBack();
},
confirm(e) {
this[`show${this.index}`] = false
console.log(e);
switch(this.index - 1) {
case 0:
this.values[this.index - 1] = e[0];
break;
case 1:
e.forEach((value, index) => {
index === 0 ? this.values[this.index - 1] = value : this.values[this.index - 1] += ';' + value
})
break;
case 2:
this.values[this.index - 1] = e[0] + '~' + e[e.length - 1];
break;
case 3:
this.values[this.index - 1] = e[0] + '~' + e[e.length - 1];
break;
case 4:
this.values[this.index - 1] = e[0] + '~' + e[e.length - 1];
break;
case 5:
this.values[this.index - 1] = e[0];
break;
case 6:
this.values[this.index - 1] = e[0];
break;
case 7:
e.forEach((value, index) => {
index === 0 ? this.values[this.index - 1] = value : this.values[this.index - 1] += ';' + value
})
break;
}
},
close() {
this[`show${this.index}`] = false
},
formatter(day) {
const d = new Date()
let month = d.getMonth() + 1
const date = d.getDate()
if(day.month == month && day.day == date + 3) {
day.bottomInfo = '有优惠'
day.dot = true
}
return day
}
},
}
</script>
<style lang="scss">
.u-page {
padding: 0;
}
</style>

View File

@ -0,0 +1,153 @@
<template>
<view class="u-page">
<view class="u-demo-block">
<text class="u-demo-block__title">基础使用</text>
<view class="u-demo-block__content">
<u-code-input
v-model="value1"
:maxlength="4"
@change="change"
@finish="finish"
></u-code-input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">横线模式</text>
<view class="u-demo-block__content">
<u-code-input
v-model="value2"
mode="line"
:maxlength="4"
:bold="true"
></u-code-input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">设置长度</text>
<view class="u-demo-block__content">
<u-code-input
v-model="value3"
:maxlength="6"
></u-code-input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">设置间距</text>
<view class="u-demo-block__content">
<u-code-input
v-model="value4"
mode="box"
:space="0"
:maxlength="4"
></u-code-input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">细边框</text>
<view class="u-demo-block__content">
<u-code-input
v-model="value5"
mode="box"
:space="0"
:maxlength="4"
hairline
></u-code-input>
</view>
<view
class="u-demo-block__content"
style="margin-top: 10px;"
>
<u-code-input
v-model="value6"
mode="line"
:space="10"
:maxlength="4"
hairline
></u-code-input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">调整颜色</text>
<view class="u-demo-block__content">
<u-code-input
v-model="value7"
mode="box"
:space="0"
:maxlength="4"
hairline
color="#f56c6c"
borderColor="#f56c6c"
></u-code-input>
<view class="u-demo-block__content" style="margin-top: 10px;">
<u-code-input
v-model="value10"
mode="line"
size="30"
:maxlength="4"
hairline
color="#3c9cff"
borderColor="#3c9cff"
></u-code-input>
</view>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">点模式</text>
<view class="u-demo-block__content">
<u-code-input
v-model="value8"
mode="box"
dot
:space="0"
:maxlength="4"
hairline
></u-code-input>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">预置内容</text>
<view class="u-demo-block__content">
<u-code-input
v-model="value9"
mode="box"
:space="0"
:maxlength="4"
hairline
fontSize="17"
></u-code-input>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
value1: '',
value2: '',
value3: '',
value4: '',
value5: '',
value6: '',
value7: '',
value8: '',
value9: '123',
value10: '34'
}
},
methods: {
change(e) {
console.log('change', e);
},
finish(e) {
console.log('finish', e);
}
},
}
</script>
<style lang="scss">
</style>

Some files were not shown because too many files have changed in this diff Show More