From d929afa146275fbf8425087e6a543a13e335ecc3 Mon Sep 17 00:00:00 2001 From: gukai <1522776404@qq.com> Date: Mon, 24 Jun 2024 19:30:51 +0800 Subject: [PATCH] first commit --- .gitignore | 8 + App.vue | 183 + README.md | 290 ++ api/index.js | 13 + api/modules/common.js | 181 + api/modules/coupon.js | 39 + api/modules/diy.js | 16 + api/modules/home.js | 63 + api/modules/inPersonToPay.js | 34 + api/modules/pay.js | 33 + api/modules/payCoupon.js | 56 + api/modules/reservation.js | 240 + api/modules/transfer.js | 25 + api/modules/user.js | 178 + components/login/loginPage.vue | 263 ++ components/login/loginPopup.vue | 185 + components/login/logins.vue | 213 + components/the/the-tabbar.vue | 189 + components/tools/isPhone/index.vue | 138 + components/tools/tools-number-step/index.vue | 95 + env.js | 15 + index.html | 20 + main.js | 52 + manifest.json | 114 + mixin/index.js | 162 + module/test/test.vue | 8 + package.json | 3 + pages.json | 110 + pages/index/index.vue | 79 + pages/my/images/av.png | Bin 0 -> 7627 bytes pages/my/images/xj.png | Bin 0 -> 3426 bytes pages/my/my.vue | 772 +++ static/css/common.scss | 48 + static/css/uni.scss | 78 + static/h5/jweixin-sdk.js | 1 + store/index.js | 31 + .../inPersonToPay/compontents/coupons.vue | 455 ++ .../inPersonToPay/compontents/twoGoods.vue | 212 + subPackages/inPersonToPay/index/index.vue | 662 +++ subPackages/inPersonToPay/result/index.vue | 174 + subPackages/login/forgotPassword/index.vue | 38 + subPackages/login/forgotPassword/nuxt.vue | 321 ++ subPackages/login/login/index.vue | 27 + subPackages/login/reg/index.vue | 174 + subPackages/login/reg/reset.vue | 161 + uni.scss | 78 + uni_modules/alipayjsapi/alipayjsapi.js | 4183 +++++++++++++++++ uni_modules/lime-painter/changelog.md | 203 + .../components/common/relation.js | 150 + .../l-painter-image/l-painter-image.vue | 28 + .../l-painter-qrcode/l-painter-qrcode.vue | 27 + .../l-painter-text/l-painter-text.vue | 29 + .../l-painter-view/l-painter-view.vue | 30 + .../components/l-painter/l-painter.vue | 445 ++ .../lime-painter/components/l-painter/nvue.js | 190 + .../components/l-painter/painter.js | 1 + .../components/l-painter/props.js | 56 + .../components/l-painter/utils.js | 363 ++ .../components/lime-painter/lime-painter.vue | 224 + .../lime-painter/hybrid/html/index.html | 119 + .../lime-painter/hybrid/html/painter.js | 1 + .../hybrid/html/uni.webview.1.5.3.js | 1 + uni_modules/lime-painter/package.json | 92 + uni_modules/lime-painter/parser.js | 388 ++ uni_modules/lime-painter/readme.md | 963 ++++ uni_modules/uni-popup/changelog.md | 70 + .../components/uni-popup-dialog/keypress.js | 45 + .../uni-popup-dialog/uni-popup-dialog.vue | 275 ++ .../uni-popup-message/uni-popup-message.vue | 143 + .../uni-popup-share/uni-popup-share.vue | 187 + .../components/uni-popup/i18n/en.json | 7 + .../components/uni-popup/i18n/index.js | 8 + .../components/uni-popup/i18n/zh-Hans.json | 7 + .../components/uni-popup/i18n/zh-Hant.json | 7 + .../components/uni-popup/keypress.js | 45 + .../uni-popup/components/uni-popup/popup.js | 26 + .../components/uni-popup/uni-popup.uvue | 90 + .../components/uni-popup/uni-popup.vue | 473 ++ uni_modules/uni-popup/package.json | 87 + uni_modules/uni-popup/readme.md | 17 + uni_modules/uni-scss/changelog.md | 8 + uni_modules/uni-scss/index.scss | 1 + uni_modules/uni-scss/package.json | 82 + uni_modules/uni-scss/readme.md | 4 + uni_modules/uni-scss/styles/index.scss | 7 + .../uni-scss/styles/setting/_border.scss | 3 + .../uni-scss/styles/setting/_color.scss | 66 + .../uni-scss/styles/setting/_radius.scss | 55 + .../uni-scss/styles/setting/_space.scss | 56 + .../uni-scss/styles/setting/_styles.scss | 167 + .../uni-scss/styles/setting/_text.scss | 24 + .../uni-scss/styles/setting/_variables.scss | 146 + .../uni-scss/styles/tools/functions.scss | 19 + uni_modules/uni-scss/theme.scss | 31 + uni_modules/uni-scss/variables.scss | 62 + uni_modules/uni-transition/changelog.md | 22 + .../uni-transition/createAnimation.js | 131 + .../uni-transition/uni-transition.vue | 286 ++ uni_modules/uni-transition/package.json | 84 + uni_modules/uni-transition/readme.md | 11 + uni_modules/uview-ui/LICENSE | 21 + uni_modules/uview-ui/README.md | 66 + uni_modules/uview-ui/changelog.md | 362 ++ .../uview-ui/components/u--form/u--form.vue | 78 + .../uview-ui/components/u--image/u--image.vue | 47 + .../uview-ui/components/u--input/u--input.vue | 73 + .../uview-ui/components/u--text/u--text.vue | 44 + .../components/u--textarea/u--textarea.vue | 48 + .../components/u-action-sheet/props.js | 54 + .../u-action-sheet/u-action-sheet.vue | 278 ++ .../uview-ui/components/u-album/props.js | 59 + .../uview-ui/components/u-album/u-album.vue | 259 + .../uview-ui/components/u-alert/props.js | 44 + .../uview-ui/components/u-alert/u-alert.vue | 243 + .../components/u-avatar-group/props.js | 52 + .../u-avatar-group/u-avatar-group.vue | 103 + .../uview-ui/components/u-avatar/props.js | 78 + .../uview-ui/components/u-avatar/u-avatar.vue | 172 + .../uview-ui/components/u-back-top/props.js | 54 + .../components/u-back-top/u-back-top.vue | 129 + .../uview-ui/components/u-badge/props.js | 72 + .../uview-ui/components/u-badge/u-badge.vue | 171 + .../uview-ui/components/u-button/nvue.scss | 46 + .../uview-ui/components/u-button/props.js | 161 + .../uview-ui/components/u-button/u-button.vue | 490 ++ .../uview-ui/components/u-button/vue.scss | 80 + .../uview-ui/components/u-calendar/header.vue | 99 + .../uview-ui/components/u-calendar/month.vue | 579 +++ .../uview-ui/components/u-calendar/props.js | 144 + .../components/u-calendar/u-calendar.vue | 384 ++ .../uview-ui/components/u-calendar/util.js | 85 + .../components/u-car-keyboard/props.js | 14 + .../u-car-keyboard/u-car-keyboard.vue | 311 ++ .../uview-ui/components/u-cell-group/props.js | 14 + .../components/u-cell-group/u-cell-group.vue | 61 + .../uview-ui/components/u-cell/props.js | 110 + .../uview-ui/components/u-cell/u-cell.vue | 229 + .../components/u-checkbox-group/props.js | 82 + .../u-checkbox-group/u-checkbox-group.vue | 103 + .../uview-ui/components/u-checkbox/props.js | 69 + .../components/u-checkbox/u-checkbox.vue | 344 ++ .../components/u-circle-progress/props.js | 8 + .../u-circle-progress/u-circle-progress.vue | 198 + .../uview-ui/components/u-code-input/props.js | 79 + .../components/u-code-input/u-code-input.vue | 252 + .../uview-ui/components/u-code/props.js | 34 + .../uview-ui/components/u-code/u-code.vue | 129 + .../uview-ui/components/u-col/props.js | 29 + .../uview-ui/components/u-col/u-col.vue | 162 + .../components/u-collapse-item/props.js | 59 + .../u-collapse-item/u-collapse-item.vue | 225 + .../uview-ui/components/u-collapse/props.js | 19 + .../components/u-collapse/u-collapse.vue | 90 + .../components/u-column-notice/props.js | 55 + .../u-column-notice/u-column-notice.vue | 160 + .../uview-ui/components/u-count-down/props.js | 24 + .../components/u-count-down/u-count-down.vue | 163 + .../uview-ui/components/u-count-down/utils.js | 62 + .../uview-ui/components/u-count-to/props.js | 59 + .../components/u-count-to/u-count-to.vue | 184 + .../components/u-datetime-picker/props.js | 116 + .../u-datetime-picker/u-datetime-picker.vue | 360 ++ .../uview-ui/components/u-divider/props.js | 44 + .../components/u-divider/u-divider.vue | 116 + .../components/u-dropdown-item/props.js | 36 + .../u-dropdown-item/u-dropdown-item.vue | 127 + .../uview-ui/components/u-dropdown/props.js | 65 + .../components/u-dropdown/u-dropdown.vue | 127 + .../uview-ui/components/u-empty/props.js | 59 + .../uview-ui/components/u-empty/u-empty.vue | 128 + .../uview-ui/components/u-form-item/props.js | 48 + .../components/u-form-item/u-form-item.vue | 235 + .../uview-ui/components/u-form/props.js | 45 + .../uview-ui/components/u-form/u-form.vue | 214 + .../uview-ui/components/u-gap/props.js | 24 + .../uview-ui/components/u-gap/u-gap.vue | 38 + .../uview-ui/components/u-grid-item/props.js | 14 + .../components/u-grid-item/u-grid-item.vue | 209 + .../uview-ui/components/u-grid/props.js | 19 + .../uview-ui/components/u-grid/u-grid.vue | 97 + .../uview-ui/components/u-icon/icons.js | 214 + .../uview-ui/components/u-icon/props.js | 89 + .../uview-ui/components/u-icon/u-icon.vue | 234 + .../uview-ui/components/u-image/props.js | 84 + .../uview-ui/components/u-image/u-image.vue | 232 + .../components/u-index-anchor/props.js | 29 + .../u-index-anchor/u-index-anchor.vue | 91 + .../uview-ui/components/u-index-item/props.js | 5 + .../components/u-index-item/u-index-item.vue | 87 + .../uview-ui/components/u-index-list/props.js | 29 + .../components/u-index-list/u-index-list.vue | 440 ++ .../uview-ui/components/u-input/props.js | 187 + .../uview-ui/components/u-input/u-input.vue | 354 ++ .../uview-ui/components/u-keyboard/props.js | 84 + .../components/u-keyboard/u-keyboard.vue | 164 + .../components/u-line-progress/props.js | 28 + .../u-line-progress/u-line-progress.vue | 144 + .../uview-ui/components/u-line/props.js | 33 + .../uview-ui/components/u-line/u-line.vue | 62 + .../uview-ui/components/u-link/props.js | 39 + .../uview-ui/components/u-link/u-link.vue | 83 + .../uview-ui/components/u-list-item/props.js | 9 + .../components/u-list-item/u-list-item.vue | 116 + .../uview-ui/components/u-list/props.js | 76 + .../uview-ui/components/u-list/u-list.vue | 157 + .../components/u-loading-icon/props.js | 59 + .../u-loading-icon/u-loading-icon.vue | 343 ++ .../components/u-loading-page/props.js | 49 + .../u-loading-page/u-loading-page.vue | 115 + .../uview-ui/components/u-loadmore/props.js | 94 + .../components/u-loadmore/u-loadmore.vue | 150 + .../uview-ui/components/u-modal/props.js | 84 + .../uview-ui/components/u-modal/u-modal.vue | 227 + .../uview-ui/components/u-navbar/props.js | 84 + .../uview-ui/components/u-navbar/u-navbar.vue | 186 + .../uview-ui/components/u-no-network/props.js | 19 + .../components/u-no-network/u-no-network.vue | 220 + .../uview-ui/components/u-notice-bar/props.js | 70 + .../components/u-notice-bar/u-notice-bar.vue | 101 + .../uview-ui/components/u-notify/props.js | 49 + .../uview-ui/components/u-notify/u-notify.vue | 211 + .../uview-ui/components/u-number-box/props.js | 109 + .../components/u-number-box/u-number-box.vue | 416 ++ .../components/u-number-keyboard/props.js | 19 + .../u-number-keyboard/u-number-keyboard.vue | 196 + .../uview-ui/components/u-overlay/props.js | 24 + .../components/u-overlay/u-overlay.vue | 68 + .../uview-ui/components/u-parse/node/node.vue | 499 ++ .../uview-ui/components/u-parse/parser.js | 1075 +++++ .../uview-ui/components/u-parse/props.js | 45 + .../uview-ui/components/u-parse/u-parse.vue | 366 ++ .../components/u-picker-column/props.js | 5 + .../u-picker-column/u-picker-column.vue | 27 + .../uview-ui/components/u-picker/props.js | 79 + .../uview-ui/components/u-picker/u-picker.vue | 254 + .../uview-ui/components/u-popup/props.js | 79 + .../uview-ui/components/u-popup/u-popup.vue | 304 ++ .../components/u-radio-group/props.js | 85 + .../u-radio-group/u-radio-group.vue | 108 + .../uview-ui/components/u-radio/props.js | 64 + .../uview-ui/components/u-radio/u-radio.vue | 339 ++ .../uview-ui/components/u-rate/props.js | 69 + .../uview-ui/components/u-rate/u-rate.vue | 306 ++ .../uview-ui/components/u-read-more/props.js | 61 + .../components/u-read-more/u-read-more.vue | 157 + .../uview-ui/components/u-row-notice/props.js | 39 + .../components/u-row-notice/u-row-notice.vue | 330 ++ .../uview-ui/components/u-row/props.js | 19 + .../uview-ui/components/u-row/u-row.vue | 93 + .../components/u-safe-bottom/props.js | 5 + .../u-safe-bottom/u-safe-bottom.vue | 56 + .../uview-ui/components/u-scroll-list/nvue.js | 28 + .../components/u-scroll-list/other.js | 0 .../components/u-scroll-list/props.js | 34 + .../components/u-scroll-list/scrollWxs.wxs | 50 + .../u-scroll-list/u-scroll-list.vue | 224 + .../uview-ui/components/u-search/props.js | 118 + .../uview-ui/components/u-search/u-search.vue | 303 ++ .../uview-ui/components/u-skeleton/props.js | 59 + .../components/u-skeleton/u-skeleton.vue | 244 + .../uview-ui/components/u-slider/mpother.js | 113 + .../uview-ui/components/u-slider/mpwxs.js | 42 + .../uview-ui/components/u-slider/mpwxs.wxs | 121 + .../components/u-slider/nvue - 副本.js | 180 + .../uview-ui/components/u-slider/nvue.js | 193 + .../uview-ui/components/u-slider/props.js | 54 + .../uview-ui/components/u-slider/u-slider.vue | 55 + .../uview-ui/components/u-status-bar/props.js | 8 + .../components/u-status-bar/u-status-bar.vue | 46 + .../uview-ui/components/u-steps-item/props.js | 24 + .../components/u-steps-item/u-steps-item.vue | 316 ++ .../uview-ui/components/u-steps/props.js | 39 + .../uview-ui/components/u-steps/u-steps.vue | 80 + .../uview-ui/components/u-sticky/props.js | 40 + .../uview-ui/components/u-sticky/u-sticky.vue | 212 + .../uview-ui/components/u-subsection/props.js | 49 + .../components/u-subsection/u-subsection.vue | 299 ++ .../u-swipe-action-item/index - backup.wxs | 256 + .../components/u-swipe-action-item/index.wxs | 225 + .../u-swipe-action-item/nvue - backup.js | 270 ++ .../components/u-swipe-action-item/nvue.js | 174 + .../components/u-swipe-action-item/props.js | 41 + .../u-swipe-action-item.vue | 190 + .../components/u-swipe-action-item/wxs.js | 15 + .../components/u-swipe-action/props.js | 9 + .../u-swipe-action/u-swipe-action.vue | 67 + .../components/u-swiper-indicator/props.js | 29 + .../u-swiper-indicator/u-swiper-indicator.vue | 110 + .../uview-ui/components/u-swiper/props.js | 125 + .../uview-ui/components/u-swiper/u-swiper.vue | 255 + .../uview-ui/components/u-switch/props.js | 54 + .../uview-ui/components/u-switch/u-switch.vue | 177 + .../components/u-tabbar-item/props.js | 35 + .../u-tabbar-item/u-tabbar-item.vue | 142 + .../uview-ui/components/u-tabbar/props.js | 44 + .../uview-ui/components/u-tabbar/u-tabbar.vue | 141 + .../uview-ui/components/u-table/props.js | 5 + .../uview-ui/components/u-table/u-table.vue | 29 + .../uview-ui/components/u-tabs-item/props.js | 5 + .../components/u-tabs-item/u-tabs-item.vue | 29 + .../uview-ui/components/u-tabs/props.js | 64 + .../uview-ui/components/u-tabs/u-tabs.vue | 354 ++ .../uview-ui/components/u-tag/props.js | 84 + .../uview-ui/components/u-tag/u-tag.vue | 358 ++ uni_modules/uview-ui/components/u-td/props.js | 5 + uni_modules/uview-ui/components/u-td/u-td.vue | 31 + .../uview-ui/components/u-text/props.js | 110 + .../uview-ui/components/u-text/u-text.vue | 223 + .../uview-ui/components/u-text/value.js | 85 + .../uview-ui/components/u-textarea/props.js | 119 + .../components/u-textarea/u-textarea.vue | 239 + .../uview-ui/components/u-toast/u-toast.vue | 291 ++ .../uview-ui/components/u-toolbar/props.js | 34 + .../components/u-toolbar/u-toolbar.vue | 102 + .../components/u-tooltip/clipboard.min.js | 58 + .../uview-ui/components/u-tooltip/props.js | 59 + .../components/u-tooltip/u-tooltip.vue | 365 ++ uni_modules/uview-ui/components/u-tr/props.js | 5 + uni_modules/uview-ui/components/u-tr/u-tr.vue | 31 + .../components/u-transition/nvue.ani-map.js | 68 + .../uview-ui/components/u-transition/props.js | 24 + .../components/u-transition/transition.js | 157 + .../components/u-transition/u-transition.vue | 92 + .../u-transition/vue.ani-style.scss | 113 + .../uview-ui/components/u-upload/mixin.js | 21 + .../uview-ui/components/u-upload/props.js | 124 + .../uview-ui/components/u-upload/u-upload.vue | 558 +++ .../uview-ui/components/u-upload/utils.js | 151 + .../uview-ui/components/uview-ui/uview-ui.vue | 15 + uni_modules/uview-ui/index.js | 79 + uni_modules/uview-ui/index.scss | 23 + uni_modules/uview-ui/libs/config/color.js | 17 + uni_modules/uview-ui/libs/config/config.js | 34 + uni_modules/uview-ui/libs/config/props.js | 190 + .../uview-ui/libs/config/props/actionSheet.js | 25 + .../uview-ui/libs/config/props/album.js | 25 + .../uview-ui/libs/config/props/alert.js | 22 + .../uview-ui/libs/config/props/avatar.js | 28 + .../uview-ui/libs/config/props/avatarGroup.js | 23 + .../uview-ui/libs/config/props/backtop.js | 27 + .../uview-ui/libs/config/props/badge.js | 27 + .../uview-ui/libs/config/props/button.js | 42 + .../uview-ui/libs/config/props/calendar.js | 42 + .../uview-ui/libs/config/props/carKeyboard.js | 15 + .../uview-ui/libs/config/props/cell.js | 35 + .../uview-ui/libs/config/props/cellGroup.js | 17 + .../uview-ui/libs/config/props/checkbox.js | 27 + .../libs/config/props/checkboxGroup.js | 29 + .../libs/config/props/circleProgress.js | 15 + .../uview-ui/libs/config/props/code.js | 21 + .../uview-ui/libs/config/props/codeInput.js | 29 + uni_modules/uview-ui/libs/config/props/col.js | 19 + .../uview-ui/libs/config/props/collapse.js | 17 + .../libs/config/props/collapseItem.js | 25 + .../libs/config/props/columnNotice.js | 24 + .../uview-ui/libs/config/props/countDown.js | 18 + .../uview-ui/libs/config/props/countTo.js | 25 + .../libs/config/props/datetimePicker.js | 36 + .../uview-ui/libs/config/props/divider.js | 23 + .../uview-ui/libs/config/props/empty.js | 26 + .../uview-ui/libs/config/props/form.js | 22 + .../uview-ui/libs/config/props/formItem.js | 23 + uni_modules/uview-ui/libs/config/props/gap.js | 19 + .../uview-ui/libs/config/props/grid.js | 17 + .../uview-ui/libs/config/props/gridItem.js | 16 + .../uview-ui/libs/config/props/icon.js | 36 + .../uview-ui/libs/config/props/image.js | 30 + .../uview-ui/libs/config/props/indexAnchor.js | 19 + .../uview-ui/libs/config/props/indexList.js | 19 + .../uview-ui/libs/config/props/input.js | 48 + .../uview-ui/libs/config/props/keyboard.js | 30 + .../uview-ui/libs/config/props/line.js | 20 + .../libs/config/props/lineProgress.js | 19 + .../uview-ui/libs/config/props/link.js | 26 + .../uview-ui/libs/config/props/list.js | 28 + .../uview-ui/libs/config/props/listItem.js | 15 + .../uview-ui/libs/config/props/loadingIcon.js | 30 + .../uview-ui/libs/config/props/loadingPage.js | 23 + .../uview-ui/libs/config/props/loadmore.js | 32 + .../uview-ui/libs/config/props/modal.js | 30 + .../uview-ui/libs/config/props/navbar.js | 32 + .../uview-ui/libs/config/props/noNetwork.js | 18 + .../uview-ui/libs/config/props/noticeBar.js | 27 + .../uview-ui/libs/config/props/notify.js | 22 + .../uview-ui/libs/config/props/numberBox.js | 35 + .../libs/config/props/numberKeyboard.js | 17 + .../uview-ui/libs/config/props/overlay.js | 18 + .../uview-ui/libs/config/props/parse.js | 22 + .../uview-ui/libs/config/props/picker.js | 29 + .../uview-ui/libs/config/props/popup.js | 29 + .../uview-ui/libs/config/props/radio.js | 27 + .../uview-ui/libs/config/props/radioGroup.js | 30 + .../uview-ui/libs/config/props/rate.js | 26 + .../uview-ui/libs/config/props/readMore.js | 22 + uni_modules/uview-ui/libs/config/props/row.js | 17 + .../uview-ui/libs/config/props/rowNotice.js | 21 + .../uview-ui/libs/config/props/scrollList.js | 20 + .../uview-ui/libs/config/props/search.js | 37 + .../uview-ui/libs/config/props/section.js | 24 + .../uview-ui/libs/config/props/skeleton.js | 25 + .../uview-ui/libs/config/props/slider.js | 25 + .../uview-ui/libs/config/props/statusBar.js | 15 + .../uview-ui/libs/config/props/steps.js | 21 + .../uview-ui/libs/config/props/stepsItem.js | 18 + .../uview-ui/libs/config/props/sticky.js | 20 + .../uview-ui/libs/config/props/subsection.js | 23 + .../uview-ui/libs/config/props/swipeAction.js | 15 + .../libs/config/props/swipeActionItem.js | 21 + .../uview-ui/libs/config/props/swiper.js | 39 + .../libs/config/props/swipterIndicator.js | 19 + .../uview-ui/libs/config/props/switch.js | 24 + .../uview-ui/libs/config/props/tabbar.js | 22 + .../uview-ui/libs/config/props/tabbarItem.js | 20 + .../uview-ui/libs/config/props/tabs.js | 32 + uni_modules/uview-ui/libs/config/props/tag.js | 29 + .../uview-ui/libs/config/props/text.js | 38 + .../uview-ui/libs/config/props/textarea.js | 36 + .../uview-ui/libs/config/props/toast.js | 30 + .../uview-ui/libs/config/props/toolbar.js | 21 + .../uview-ui/libs/config/props/tooltip.js | 25 + .../uview-ui/libs/config/props/transition.js | 18 + .../uview-ui/libs/config/props/upload.js | 36 + uni_modules/uview-ui/libs/config/zIndex.js | 20 + uni_modules/uview-ui/libs/css/color.scss | 155 + uni_modules/uview-ui/libs/css/common.scss | 97 + uni_modules/uview-ui/libs/css/components.scss | 15 + uni_modules/uview-ui/libs/css/flex.scss | 257 + uni_modules/uview-ui/libs/css/h5.scss | 0 uni_modules/uview-ui/libs/css/mixin.scss | 8 + uni_modules/uview-ui/libs/css/mp.scss | 0 uni_modules/uview-ui/libs/css/nvue.scss | 0 uni_modules/uview-ui/libs/css/vue.scss | 27 + .../uview-ui/libs/function/colorGradient.js | 134 + .../uview-ui/libs/function/debounce.js | 29 + uni_modules/uview-ui/libs/function/digit.js | 167 + uni_modules/uview-ui/libs/function/index.js | 731 +++ .../uview-ui/libs/function/platform.js | 75 + uni_modules/uview-ui/libs/function/test.js | 288 ++ .../uview-ui/libs/function/throttle.js | 30 + .../libs/luch-request/adapters/index.js | 97 + .../luch-request/core/InterceptorManager.js | 50 + .../libs/luch-request/core/Request.js | 198 + .../libs/luch-request/core/buildFullPath.js | 20 + .../libs/luch-request/core/defaults.js | 29 + .../libs/luch-request/core/dispatchRequest.js | 3 + .../libs/luch-request/core/mergeConfig.js | 103 + .../uview-ui/libs/luch-request/core/settle.js | 16 + .../libs/luch-request/helpers/buildURL.js | 69 + .../libs/luch-request/helpers/combineURLs.js | 14 + .../luch-request/helpers/isAbsoluteURL.js | 14 + .../uview-ui/libs/luch-request/index.d.ts | 116 + .../uview-ui/libs/luch-request/index.js | 3 + .../uview-ui/libs/luch-request/utils.js | 131 + .../uview-ui/libs/luch-request/utils/clone.js | 264 ++ uni_modules/uview-ui/libs/mixin/button.js | 13 + uni_modules/uview-ui/libs/mixin/mixin.js | 160 + uni_modules/uview-ui/libs/mixin/mpMixin.js | 8 + uni_modules/uview-ui/libs/mixin/mpShare.js | 13 + uni_modules/uview-ui/libs/mixin/openType.js | 25 + uni_modules/uview-ui/libs/mixin/style.js | 228 + uni_modules/uview-ui/libs/mixin/touch.js | 59 + .../uview-ui/libs/util/async-validator.js | 1343 ++++++ uni_modules/uview-ui/libs/util/calendar.js | 546 +++ uni_modules/uview-ui/libs/util/dayjs.js | 308 ++ uni_modules/uview-ui/libs/util/emitter.js | 51 + uni_modules/uview-ui/libs/util/route.js | 124 + uni_modules/uview-ui/package.json | 84 + uni_modules/uview-ui/theme.scss | 44 + uni_modules/x-skeleton/changelog.md | 11 + .../components/x-skeleton/x-skeleton copy.vue | 311 ++ .../x-skeleton/x-skeleton-configs.js | 147 + .../components/x-skeleton/x-skeleton.vue | 311 ++ uni_modules/x-skeleton/package.json | 84 + uni_modules/x-skeleton/readme.md | 93 + uni_modules/y-tabs/changelog.md | 69 + uni_modules/y-tabs/components/css/index.less | 505 ++ uni_modules/y-tabs/components/js/const.js | 196 + .../y-tabs/components/js/touchMixin.js | 65 + uni_modules/y-tabs/components/js/uitls.js | 173 + uni_modules/y-tabs/components/js/utilMixin.js | 8 + uni_modules/y-tabs/components/y-tab/y-tab.vue | 238 + .../y-tabs/components/y-tabs/y-tabs.vue | 1256 +++++ uni_modules/y-tabs/package.json | 85 + uni_modules/y-tabs/readme.md | 456 ++ utils/app.js | 122 + utils/h5init.js | 49 + utils/pay.js | 48 + utils/regExp.js | 8 + utils/request.js | 93 + utils/utils.js | 189 + utils/wxConfig.js | 67 + vue.config.js | 15 + 492 files changed, 59548 insertions(+) create mode 100644 .gitignore create mode 100644 App.vue create mode 100644 README.md create mode 100644 api/index.js create mode 100644 api/modules/common.js create mode 100644 api/modules/coupon.js create mode 100644 api/modules/diy.js create mode 100644 api/modules/home.js create mode 100644 api/modules/inPersonToPay.js create mode 100644 api/modules/pay.js create mode 100644 api/modules/payCoupon.js create mode 100644 api/modules/reservation.js create mode 100644 api/modules/transfer.js create mode 100644 api/modules/user.js create mode 100644 components/login/loginPage.vue create mode 100644 components/login/loginPopup.vue create mode 100644 components/login/logins.vue create mode 100644 components/the/the-tabbar.vue create mode 100644 components/tools/isPhone/index.vue create mode 100644 components/tools/tools-number-step/index.vue create mode 100644 env.js create mode 100644 index.html create mode 100644 main.js create mode 100644 manifest.json create mode 100644 mixin/index.js create mode 100644 module/test/test.vue create mode 100644 package.json create mode 100644 pages.json create mode 100644 pages/index/index.vue create mode 100644 pages/my/images/av.png create mode 100644 pages/my/images/xj.png create mode 100644 pages/my/my.vue create mode 100644 static/css/common.scss create mode 100644 static/css/uni.scss create mode 100644 static/h5/jweixin-sdk.js create mode 100644 store/index.js create mode 100644 subPackages/inPersonToPay/compontents/coupons.vue create mode 100644 subPackages/inPersonToPay/compontents/twoGoods.vue create mode 100644 subPackages/inPersonToPay/index/index.vue create mode 100644 subPackages/inPersonToPay/result/index.vue create mode 100644 subPackages/login/forgotPassword/index.vue create mode 100644 subPackages/login/forgotPassword/nuxt.vue create mode 100644 subPackages/login/login/index.vue create mode 100644 subPackages/login/reg/index.vue create mode 100644 subPackages/login/reg/reset.vue create mode 100644 uni.scss create mode 100644 uni_modules/alipayjsapi/alipayjsapi.js create mode 100644 uni_modules/lime-painter/changelog.md create mode 100644 uni_modules/lime-painter/components/common/relation.js create mode 100644 uni_modules/lime-painter/components/l-painter-image/l-painter-image.vue create mode 100644 uni_modules/lime-painter/components/l-painter-qrcode/l-painter-qrcode.vue create mode 100644 uni_modules/lime-painter/components/l-painter-text/l-painter-text.vue create mode 100644 uni_modules/lime-painter/components/l-painter-view/l-painter-view.vue create mode 100644 uni_modules/lime-painter/components/l-painter/l-painter.vue create mode 100644 uni_modules/lime-painter/components/l-painter/nvue.js create mode 100644 uni_modules/lime-painter/components/l-painter/painter.js create mode 100644 uni_modules/lime-painter/components/l-painter/props.js create mode 100644 uni_modules/lime-painter/components/l-painter/utils.js create mode 100644 uni_modules/lime-painter/components/lime-painter/lime-painter.vue create mode 100644 uni_modules/lime-painter/hybrid/html/index.html create mode 100644 uni_modules/lime-painter/hybrid/html/painter.js create mode 100644 uni_modules/lime-painter/hybrid/html/uni.webview.1.5.3.js create mode 100644 uni_modules/lime-painter/package.json create mode 100644 uni_modules/lime-painter/parser.js create mode 100644 uni_modules/lime-painter/readme.md create mode 100644 uni_modules/uni-popup/changelog.md create mode 100644 uni_modules/uni-popup/components/uni-popup-dialog/keypress.js create mode 100644 uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue create mode 100644 uni_modules/uni-popup/components/uni-popup-message/uni-popup-message.vue create mode 100644 uni_modules/uni-popup/components/uni-popup-share/uni-popup-share.vue create mode 100644 uni_modules/uni-popup/components/uni-popup/i18n/en.json create mode 100644 uni_modules/uni-popup/components/uni-popup/i18n/index.js create mode 100644 uni_modules/uni-popup/components/uni-popup/i18n/zh-Hans.json create mode 100644 uni_modules/uni-popup/components/uni-popup/i18n/zh-Hant.json create mode 100644 uni_modules/uni-popup/components/uni-popup/keypress.js create mode 100644 uni_modules/uni-popup/components/uni-popup/popup.js create mode 100644 uni_modules/uni-popup/components/uni-popup/uni-popup.uvue create mode 100644 uni_modules/uni-popup/components/uni-popup/uni-popup.vue create mode 100644 uni_modules/uni-popup/package.json create mode 100644 uni_modules/uni-popup/readme.md create mode 100644 uni_modules/uni-scss/changelog.md create mode 100644 uni_modules/uni-scss/index.scss create mode 100644 uni_modules/uni-scss/package.json create mode 100644 uni_modules/uni-scss/readme.md create mode 100644 uni_modules/uni-scss/styles/index.scss create mode 100644 uni_modules/uni-scss/styles/setting/_border.scss create mode 100644 uni_modules/uni-scss/styles/setting/_color.scss create mode 100644 uni_modules/uni-scss/styles/setting/_radius.scss create mode 100644 uni_modules/uni-scss/styles/setting/_space.scss create mode 100644 uni_modules/uni-scss/styles/setting/_styles.scss create mode 100644 uni_modules/uni-scss/styles/setting/_text.scss create mode 100644 uni_modules/uni-scss/styles/setting/_variables.scss create mode 100644 uni_modules/uni-scss/styles/tools/functions.scss create mode 100644 uni_modules/uni-scss/theme.scss create mode 100644 uni_modules/uni-scss/variables.scss create mode 100644 uni_modules/uni-transition/changelog.md create mode 100644 uni_modules/uni-transition/components/uni-transition/createAnimation.js create mode 100644 uni_modules/uni-transition/components/uni-transition/uni-transition.vue create mode 100644 uni_modules/uni-transition/package.json create mode 100644 uni_modules/uni-transition/readme.md create mode 100644 uni_modules/uview-ui/LICENSE create mode 100644 uni_modules/uview-ui/README.md create mode 100644 uni_modules/uview-ui/changelog.md create mode 100644 uni_modules/uview-ui/components/u--form/u--form.vue create mode 100644 uni_modules/uview-ui/components/u--image/u--image.vue create mode 100644 uni_modules/uview-ui/components/u--input/u--input.vue create mode 100644 uni_modules/uview-ui/components/u--text/u--text.vue create mode 100644 uni_modules/uview-ui/components/u--textarea/u--textarea.vue create mode 100644 uni_modules/uview-ui/components/u-action-sheet/props.js create mode 100644 uni_modules/uview-ui/components/u-action-sheet/u-action-sheet.vue create mode 100644 uni_modules/uview-ui/components/u-album/props.js create mode 100644 uni_modules/uview-ui/components/u-album/u-album.vue create mode 100644 uni_modules/uview-ui/components/u-alert/props.js create mode 100644 uni_modules/uview-ui/components/u-alert/u-alert.vue create mode 100644 uni_modules/uview-ui/components/u-avatar-group/props.js create mode 100644 uni_modules/uview-ui/components/u-avatar-group/u-avatar-group.vue create mode 100644 uni_modules/uview-ui/components/u-avatar/props.js create mode 100644 uni_modules/uview-ui/components/u-avatar/u-avatar.vue create mode 100644 uni_modules/uview-ui/components/u-back-top/props.js create mode 100644 uni_modules/uview-ui/components/u-back-top/u-back-top.vue create mode 100644 uni_modules/uview-ui/components/u-badge/props.js create mode 100644 uni_modules/uview-ui/components/u-badge/u-badge.vue create mode 100644 uni_modules/uview-ui/components/u-button/nvue.scss create mode 100644 uni_modules/uview-ui/components/u-button/props.js create mode 100644 uni_modules/uview-ui/components/u-button/u-button.vue create mode 100644 uni_modules/uview-ui/components/u-button/vue.scss create mode 100644 uni_modules/uview-ui/components/u-calendar/header.vue create mode 100644 uni_modules/uview-ui/components/u-calendar/month.vue create mode 100644 uni_modules/uview-ui/components/u-calendar/props.js create mode 100644 uni_modules/uview-ui/components/u-calendar/u-calendar.vue create mode 100644 uni_modules/uview-ui/components/u-calendar/util.js create mode 100644 uni_modules/uview-ui/components/u-car-keyboard/props.js create mode 100644 uni_modules/uview-ui/components/u-car-keyboard/u-car-keyboard.vue create mode 100644 uni_modules/uview-ui/components/u-cell-group/props.js create mode 100644 uni_modules/uview-ui/components/u-cell-group/u-cell-group.vue create mode 100644 uni_modules/uview-ui/components/u-cell/props.js create mode 100644 uni_modules/uview-ui/components/u-cell/u-cell.vue create mode 100644 uni_modules/uview-ui/components/u-checkbox-group/props.js create mode 100644 uni_modules/uview-ui/components/u-checkbox-group/u-checkbox-group.vue create mode 100644 uni_modules/uview-ui/components/u-checkbox/props.js create mode 100644 uni_modules/uview-ui/components/u-checkbox/u-checkbox.vue create mode 100644 uni_modules/uview-ui/components/u-circle-progress/props.js create mode 100644 uni_modules/uview-ui/components/u-circle-progress/u-circle-progress.vue create mode 100644 uni_modules/uview-ui/components/u-code-input/props.js create mode 100644 uni_modules/uview-ui/components/u-code-input/u-code-input.vue create mode 100644 uni_modules/uview-ui/components/u-code/props.js create mode 100644 uni_modules/uview-ui/components/u-code/u-code.vue create mode 100644 uni_modules/uview-ui/components/u-col/props.js create mode 100644 uni_modules/uview-ui/components/u-col/u-col.vue create mode 100644 uni_modules/uview-ui/components/u-collapse-item/props.js create mode 100644 uni_modules/uview-ui/components/u-collapse-item/u-collapse-item.vue create mode 100644 uni_modules/uview-ui/components/u-collapse/props.js create mode 100644 uni_modules/uview-ui/components/u-collapse/u-collapse.vue create mode 100644 uni_modules/uview-ui/components/u-column-notice/props.js create mode 100644 uni_modules/uview-ui/components/u-column-notice/u-column-notice.vue create mode 100644 uni_modules/uview-ui/components/u-count-down/props.js create mode 100644 uni_modules/uview-ui/components/u-count-down/u-count-down.vue create mode 100644 uni_modules/uview-ui/components/u-count-down/utils.js create mode 100644 uni_modules/uview-ui/components/u-count-to/props.js create mode 100644 uni_modules/uview-ui/components/u-count-to/u-count-to.vue create mode 100644 uni_modules/uview-ui/components/u-datetime-picker/props.js create mode 100644 uni_modules/uview-ui/components/u-datetime-picker/u-datetime-picker.vue create mode 100644 uni_modules/uview-ui/components/u-divider/props.js create mode 100644 uni_modules/uview-ui/components/u-divider/u-divider.vue create mode 100644 uni_modules/uview-ui/components/u-dropdown-item/props.js create mode 100644 uni_modules/uview-ui/components/u-dropdown-item/u-dropdown-item.vue create mode 100644 uni_modules/uview-ui/components/u-dropdown/props.js create mode 100644 uni_modules/uview-ui/components/u-dropdown/u-dropdown.vue create mode 100644 uni_modules/uview-ui/components/u-empty/props.js create mode 100644 uni_modules/uview-ui/components/u-empty/u-empty.vue create mode 100644 uni_modules/uview-ui/components/u-form-item/props.js create mode 100644 uni_modules/uview-ui/components/u-form-item/u-form-item.vue create mode 100644 uni_modules/uview-ui/components/u-form/props.js create mode 100644 uni_modules/uview-ui/components/u-form/u-form.vue create mode 100644 uni_modules/uview-ui/components/u-gap/props.js create mode 100644 uni_modules/uview-ui/components/u-gap/u-gap.vue create mode 100644 uni_modules/uview-ui/components/u-grid-item/props.js create mode 100644 uni_modules/uview-ui/components/u-grid-item/u-grid-item.vue create mode 100644 uni_modules/uview-ui/components/u-grid/props.js create mode 100644 uni_modules/uview-ui/components/u-grid/u-grid.vue create mode 100644 uni_modules/uview-ui/components/u-icon/icons.js create mode 100644 uni_modules/uview-ui/components/u-icon/props.js create mode 100644 uni_modules/uview-ui/components/u-icon/u-icon.vue create mode 100644 uni_modules/uview-ui/components/u-image/props.js create mode 100644 uni_modules/uview-ui/components/u-image/u-image.vue create mode 100644 uni_modules/uview-ui/components/u-index-anchor/props.js create mode 100644 uni_modules/uview-ui/components/u-index-anchor/u-index-anchor.vue create mode 100644 uni_modules/uview-ui/components/u-index-item/props.js create mode 100644 uni_modules/uview-ui/components/u-index-item/u-index-item.vue create mode 100644 uni_modules/uview-ui/components/u-index-list/props.js create mode 100644 uni_modules/uview-ui/components/u-index-list/u-index-list.vue create mode 100644 uni_modules/uview-ui/components/u-input/props.js create mode 100644 uni_modules/uview-ui/components/u-input/u-input.vue create mode 100644 uni_modules/uview-ui/components/u-keyboard/props.js create mode 100644 uni_modules/uview-ui/components/u-keyboard/u-keyboard.vue create mode 100644 uni_modules/uview-ui/components/u-line-progress/props.js create mode 100644 uni_modules/uview-ui/components/u-line-progress/u-line-progress.vue create mode 100644 uni_modules/uview-ui/components/u-line/props.js create mode 100644 uni_modules/uview-ui/components/u-line/u-line.vue create mode 100644 uni_modules/uview-ui/components/u-link/props.js create mode 100644 uni_modules/uview-ui/components/u-link/u-link.vue create mode 100644 uni_modules/uview-ui/components/u-list-item/props.js create mode 100644 uni_modules/uview-ui/components/u-list-item/u-list-item.vue create mode 100644 uni_modules/uview-ui/components/u-list/props.js create mode 100644 uni_modules/uview-ui/components/u-list/u-list.vue create mode 100644 uni_modules/uview-ui/components/u-loading-icon/props.js create mode 100644 uni_modules/uview-ui/components/u-loading-icon/u-loading-icon.vue create mode 100644 uni_modules/uview-ui/components/u-loading-page/props.js create mode 100644 uni_modules/uview-ui/components/u-loading-page/u-loading-page.vue create mode 100644 uni_modules/uview-ui/components/u-loadmore/props.js create mode 100644 uni_modules/uview-ui/components/u-loadmore/u-loadmore.vue create mode 100644 uni_modules/uview-ui/components/u-modal/props.js create mode 100644 uni_modules/uview-ui/components/u-modal/u-modal.vue create mode 100644 uni_modules/uview-ui/components/u-navbar/props.js create mode 100644 uni_modules/uview-ui/components/u-navbar/u-navbar.vue create mode 100644 uni_modules/uview-ui/components/u-no-network/props.js create mode 100644 uni_modules/uview-ui/components/u-no-network/u-no-network.vue create mode 100644 uni_modules/uview-ui/components/u-notice-bar/props.js create mode 100644 uni_modules/uview-ui/components/u-notice-bar/u-notice-bar.vue create mode 100644 uni_modules/uview-ui/components/u-notify/props.js create mode 100644 uni_modules/uview-ui/components/u-notify/u-notify.vue create mode 100644 uni_modules/uview-ui/components/u-number-box/props.js create mode 100644 uni_modules/uview-ui/components/u-number-box/u-number-box.vue create mode 100644 uni_modules/uview-ui/components/u-number-keyboard/props.js create mode 100644 uni_modules/uview-ui/components/u-number-keyboard/u-number-keyboard.vue create mode 100644 uni_modules/uview-ui/components/u-overlay/props.js create mode 100644 uni_modules/uview-ui/components/u-overlay/u-overlay.vue create mode 100644 uni_modules/uview-ui/components/u-parse/node/node.vue create mode 100644 uni_modules/uview-ui/components/u-parse/parser.js create mode 100644 uni_modules/uview-ui/components/u-parse/props.js create mode 100644 uni_modules/uview-ui/components/u-parse/u-parse.vue create mode 100644 uni_modules/uview-ui/components/u-picker-column/props.js create mode 100644 uni_modules/uview-ui/components/u-picker-column/u-picker-column.vue create mode 100644 uni_modules/uview-ui/components/u-picker/props.js create mode 100644 uni_modules/uview-ui/components/u-picker/u-picker.vue create mode 100644 uni_modules/uview-ui/components/u-popup/props.js create mode 100644 uni_modules/uview-ui/components/u-popup/u-popup.vue create mode 100644 uni_modules/uview-ui/components/u-radio-group/props.js create mode 100644 uni_modules/uview-ui/components/u-radio-group/u-radio-group.vue create mode 100644 uni_modules/uview-ui/components/u-radio/props.js create mode 100644 uni_modules/uview-ui/components/u-radio/u-radio.vue create mode 100644 uni_modules/uview-ui/components/u-rate/props.js create mode 100644 uni_modules/uview-ui/components/u-rate/u-rate.vue create mode 100644 uni_modules/uview-ui/components/u-read-more/props.js create mode 100644 uni_modules/uview-ui/components/u-read-more/u-read-more.vue create mode 100644 uni_modules/uview-ui/components/u-row-notice/props.js create mode 100644 uni_modules/uview-ui/components/u-row-notice/u-row-notice.vue create mode 100644 uni_modules/uview-ui/components/u-row/props.js create mode 100644 uni_modules/uview-ui/components/u-row/u-row.vue create mode 100644 uni_modules/uview-ui/components/u-safe-bottom/props.js create mode 100644 uni_modules/uview-ui/components/u-safe-bottom/u-safe-bottom.vue create mode 100644 uni_modules/uview-ui/components/u-scroll-list/nvue.js create mode 100644 uni_modules/uview-ui/components/u-scroll-list/other.js create mode 100644 uni_modules/uview-ui/components/u-scroll-list/props.js create mode 100644 uni_modules/uview-ui/components/u-scroll-list/scrollWxs.wxs create mode 100644 uni_modules/uview-ui/components/u-scroll-list/u-scroll-list.vue create mode 100644 uni_modules/uview-ui/components/u-search/props.js create mode 100644 uni_modules/uview-ui/components/u-search/u-search.vue create mode 100644 uni_modules/uview-ui/components/u-skeleton/props.js create mode 100644 uni_modules/uview-ui/components/u-skeleton/u-skeleton.vue create mode 100644 uni_modules/uview-ui/components/u-slider/mpother.js create mode 100644 uni_modules/uview-ui/components/u-slider/mpwxs.js create mode 100644 uni_modules/uview-ui/components/u-slider/mpwxs.wxs create mode 100644 uni_modules/uview-ui/components/u-slider/nvue - 副本.js create mode 100644 uni_modules/uview-ui/components/u-slider/nvue.js create mode 100644 uni_modules/uview-ui/components/u-slider/props.js create mode 100644 uni_modules/uview-ui/components/u-slider/u-slider.vue create mode 100644 uni_modules/uview-ui/components/u-status-bar/props.js create mode 100644 uni_modules/uview-ui/components/u-status-bar/u-status-bar.vue create mode 100644 uni_modules/uview-ui/components/u-steps-item/props.js create mode 100644 uni_modules/uview-ui/components/u-steps-item/u-steps-item.vue create mode 100644 uni_modules/uview-ui/components/u-steps/props.js create mode 100644 uni_modules/uview-ui/components/u-steps/u-steps.vue create mode 100644 uni_modules/uview-ui/components/u-sticky/props.js create mode 100644 uni_modules/uview-ui/components/u-sticky/u-sticky.vue create mode 100644 uni_modules/uview-ui/components/u-subsection/props.js create mode 100644 uni_modules/uview-ui/components/u-subsection/u-subsection.vue create mode 100644 uni_modules/uview-ui/components/u-swipe-action-item/index - backup.wxs create mode 100644 uni_modules/uview-ui/components/u-swipe-action-item/index.wxs create mode 100644 uni_modules/uview-ui/components/u-swipe-action-item/nvue - backup.js create mode 100644 uni_modules/uview-ui/components/u-swipe-action-item/nvue.js create mode 100644 uni_modules/uview-ui/components/u-swipe-action-item/props.js create mode 100644 uni_modules/uview-ui/components/u-swipe-action-item/u-swipe-action-item.vue create mode 100644 uni_modules/uview-ui/components/u-swipe-action-item/wxs.js create mode 100644 uni_modules/uview-ui/components/u-swipe-action/props.js create mode 100644 uni_modules/uview-ui/components/u-swipe-action/u-swipe-action.vue create mode 100644 uni_modules/uview-ui/components/u-swiper-indicator/props.js create mode 100644 uni_modules/uview-ui/components/u-swiper-indicator/u-swiper-indicator.vue create mode 100644 uni_modules/uview-ui/components/u-swiper/props.js create mode 100644 uni_modules/uview-ui/components/u-swiper/u-swiper.vue create mode 100644 uni_modules/uview-ui/components/u-switch/props.js create mode 100644 uni_modules/uview-ui/components/u-switch/u-switch.vue create mode 100644 uni_modules/uview-ui/components/u-tabbar-item/props.js create mode 100644 uni_modules/uview-ui/components/u-tabbar-item/u-tabbar-item.vue create mode 100644 uni_modules/uview-ui/components/u-tabbar/props.js create mode 100644 uni_modules/uview-ui/components/u-tabbar/u-tabbar.vue create mode 100644 uni_modules/uview-ui/components/u-table/props.js create mode 100644 uni_modules/uview-ui/components/u-table/u-table.vue create mode 100644 uni_modules/uview-ui/components/u-tabs-item/props.js create mode 100644 uni_modules/uview-ui/components/u-tabs-item/u-tabs-item.vue create mode 100644 uni_modules/uview-ui/components/u-tabs/props.js create mode 100644 uni_modules/uview-ui/components/u-tabs/u-tabs.vue create mode 100644 uni_modules/uview-ui/components/u-tag/props.js create mode 100644 uni_modules/uview-ui/components/u-tag/u-tag.vue create mode 100644 uni_modules/uview-ui/components/u-td/props.js create mode 100644 uni_modules/uview-ui/components/u-td/u-td.vue create mode 100644 uni_modules/uview-ui/components/u-text/props.js create mode 100644 uni_modules/uview-ui/components/u-text/u-text.vue create mode 100644 uni_modules/uview-ui/components/u-text/value.js create mode 100644 uni_modules/uview-ui/components/u-textarea/props.js create mode 100644 uni_modules/uview-ui/components/u-textarea/u-textarea.vue create mode 100644 uni_modules/uview-ui/components/u-toast/u-toast.vue create mode 100644 uni_modules/uview-ui/components/u-toolbar/props.js create mode 100644 uni_modules/uview-ui/components/u-toolbar/u-toolbar.vue create mode 100644 uni_modules/uview-ui/components/u-tooltip/clipboard.min.js create mode 100644 uni_modules/uview-ui/components/u-tooltip/props.js create mode 100644 uni_modules/uview-ui/components/u-tooltip/u-tooltip.vue create mode 100644 uni_modules/uview-ui/components/u-tr/props.js create mode 100644 uni_modules/uview-ui/components/u-tr/u-tr.vue create mode 100644 uni_modules/uview-ui/components/u-transition/nvue.ani-map.js create mode 100644 uni_modules/uview-ui/components/u-transition/props.js create mode 100644 uni_modules/uview-ui/components/u-transition/transition.js create mode 100644 uni_modules/uview-ui/components/u-transition/u-transition.vue create mode 100644 uni_modules/uview-ui/components/u-transition/vue.ani-style.scss create mode 100644 uni_modules/uview-ui/components/u-upload/mixin.js create mode 100644 uni_modules/uview-ui/components/u-upload/props.js create mode 100644 uni_modules/uview-ui/components/u-upload/u-upload.vue create mode 100644 uni_modules/uview-ui/components/u-upload/utils.js create mode 100644 uni_modules/uview-ui/components/uview-ui/uview-ui.vue create mode 100644 uni_modules/uview-ui/index.js create mode 100644 uni_modules/uview-ui/index.scss create mode 100644 uni_modules/uview-ui/libs/config/color.js create mode 100644 uni_modules/uview-ui/libs/config/config.js create mode 100644 uni_modules/uview-ui/libs/config/props.js create mode 100644 uni_modules/uview-ui/libs/config/props/actionSheet.js create mode 100644 uni_modules/uview-ui/libs/config/props/album.js create mode 100644 uni_modules/uview-ui/libs/config/props/alert.js create mode 100644 uni_modules/uview-ui/libs/config/props/avatar.js create mode 100644 uni_modules/uview-ui/libs/config/props/avatarGroup.js create mode 100644 uni_modules/uview-ui/libs/config/props/backtop.js create mode 100644 uni_modules/uview-ui/libs/config/props/badge.js create mode 100644 uni_modules/uview-ui/libs/config/props/button.js create mode 100644 uni_modules/uview-ui/libs/config/props/calendar.js create mode 100644 uni_modules/uview-ui/libs/config/props/carKeyboard.js create mode 100644 uni_modules/uview-ui/libs/config/props/cell.js create mode 100644 uni_modules/uview-ui/libs/config/props/cellGroup.js create mode 100644 uni_modules/uview-ui/libs/config/props/checkbox.js create mode 100644 uni_modules/uview-ui/libs/config/props/checkboxGroup.js create mode 100644 uni_modules/uview-ui/libs/config/props/circleProgress.js create mode 100644 uni_modules/uview-ui/libs/config/props/code.js create mode 100644 uni_modules/uview-ui/libs/config/props/codeInput.js create mode 100644 uni_modules/uview-ui/libs/config/props/col.js create mode 100644 uni_modules/uview-ui/libs/config/props/collapse.js create mode 100644 uni_modules/uview-ui/libs/config/props/collapseItem.js create mode 100644 uni_modules/uview-ui/libs/config/props/columnNotice.js create mode 100644 uni_modules/uview-ui/libs/config/props/countDown.js create mode 100644 uni_modules/uview-ui/libs/config/props/countTo.js create mode 100644 uni_modules/uview-ui/libs/config/props/datetimePicker.js create mode 100644 uni_modules/uview-ui/libs/config/props/divider.js create mode 100644 uni_modules/uview-ui/libs/config/props/empty.js create mode 100644 uni_modules/uview-ui/libs/config/props/form.js create mode 100644 uni_modules/uview-ui/libs/config/props/formItem.js create mode 100644 uni_modules/uview-ui/libs/config/props/gap.js create mode 100644 uni_modules/uview-ui/libs/config/props/grid.js create mode 100644 uni_modules/uview-ui/libs/config/props/gridItem.js create mode 100644 uni_modules/uview-ui/libs/config/props/icon.js create mode 100644 uni_modules/uview-ui/libs/config/props/image.js create mode 100644 uni_modules/uview-ui/libs/config/props/indexAnchor.js create mode 100644 uni_modules/uview-ui/libs/config/props/indexList.js create mode 100644 uni_modules/uview-ui/libs/config/props/input.js create mode 100644 uni_modules/uview-ui/libs/config/props/keyboard.js create mode 100644 uni_modules/uview-ui/libs/config/props/line.js create mode 100644 uni_modules/uview-ui/libs/config/props/lineProgress.js create mode 100644 uni_modules/uview-ui/libs/config/props/link.js create mode 100644 uni_modules/uview-ui/libs/config/props/list.js create mode 100644 uni_modules/uview-ui/libs/config/props/listItem.js create mode 100644 uni_modules/uview-ui/libs/config/props/loadingIcon.js create mode 100644 uni_modules/uview-ui/libs/config/props/loadingPage.js create mode 100644 uni_modules/uview-ui/libs/config/props/loadmore.js create mode 100644 uni_modules/uview-ui/libs/config/props/modal.js create mode 100644 uni_modules/uview-ui/libs/config/props/navbar.js create mode 100644 uni_modules/uview-ui/libs/config/props/noNetwork.js create mode 100644 uni_modules/uview-ui/libs/config/props/noticeBar.js create mode 100644 uni_modules/uview-ui/libs/config/props/notify.js create mode 100644 uni_modules/uview-ui/libs/config/props/numberBox.js create mode 100644 uni_modules/uview-ui/libs/config/props/numberKeyboard.js create mode 100644 uni_modules/uview-ui/libs/config/props/overlay.js create mode 100644 uni_modules/uview-ui/libs/config/props/parse.js create mode 100644 uni_modules/uview-ui/libs/config/props/picker.js create mode 100644 uni_modules/uview-ui/libs/config/props/popup.js create mode 100644 uni_modules/uview-ui/libs/config/props/radio.js create mode 100644 uni_modules/uview-ui/libs/config/props/radioGroup.js create mode 100644 uni_modules/uview-ui/libs/config/props/rate.js create mode 100644 uni_modules/uview-ui/libs/config/props/readMore.js create mode 100644 uni_modules/uview-ui/libs/config/props/row.js create mode 100644 uni_modules/uview-ui/libs/config/props/rowNotice.js create mode 100644 uni_modules/uview-ui/libs/config/props/scrollList.js create mode 100644 uni_modules/uview-ui/libs/config/props/search.js create mode 100644 uni_modules/uview-ui/libs/config/props/section.js create mode 100644 uni_modules/uview-ui/libs/config/props/skeleton.js create mode 100644 uni_modules/uview-ui/libs/config/props/slider.js create mode 100644 uni_modules/uview-ui/libs/config/props/statusBar.js create mode 100644 uni_modules/uview-ui/libs/config/props/steps.js create mode 100644 uni_modules/uview-ui/libs/config/props/stepsItem.js create mode 100644 uni_modules/uview-ui/libs/config/props/sticky.js create mode 100644 uni_modules/uview-ui/libs/config/props/subsection.js create mode 100644 uni_modules/uview-ui/libs/config/props/swipeAction.js create mode 100644 uni_modules/uview-ui/libs/config/props/swipeActionItem.js create mode 100644 uni_modules/uview-ui/libs/config/props/swiper.js create mode 100644 uni_modules/uview-ui/libs/config/props/swipterIndicator.js create mode 100644 uni_modules/uview-ui/libs/config/props/switch.js create mode 100644 uni_modules/uview-ui/libs/config/props/tabbar.js create mode 100644 uni_modules/uview-ui/libs/config/props/tabbarItem.js create mode 100644 uni_modules/uview-ui/libs/config/props/tabs.js create mode 100644 uni_modules/uview-ui/libs/config/props/tag.js create mode 100644 uni_modules/uview-ui/libs/config/props/text.js create mode 100644 uni_modules/uview-ui/libs/config/props/textarea.js create mode 100644 uni_modules/uview-ui/libs/config/props/toast.js create mode 100644 uni_modules/uview-ui/libs/config/props/toolbar.js create mode 100644 uni_modules/uview-ui/libs/config/props/tooltip.js create mode 100644 uni_modules/uview-ui/libs/config/props/transition.js create mode 100644 uni_modules/uview-ui/libs/config/props/upload.js create mode 100644 uni_modules/uview-ui/libs/config/zIndex.js create mode 100644 uni_modules/uview-ui/libs/css/color.scss create mode 100644 uni_modules/uview-ui/libs/css/common.scss create mode 100644 uni_modules/uview-ui/libs/css/components.scss create mode 100644 uni_modules/uview-ui/libs/css/flex.scss create mode 100644 uni_modules/uview-ui/libs/css/h5.scss create mode 100644 uni_modules/uview-ui/libs/css/mixin.scss create mode 100644 uni_modules/uview-ui/libs/css/mp.scss create mode 100644 uni_modules/uview-ui/libs/css/nvue.scss create mode 100644 uni_modules/uview-ui/libs/css/vue.scss create mode 100644 uni_modules/uview-ui/libs/function/colorGradient.js create mode 100644 uni_modules/uview-ui/libs/function/debounce.js create mode 100644 uni_modules/uview-ui/libs/function/digit.js create mode 100644 uni_modules/uview-ui/libs/function/index.js create mode 100644 uni_modules/uview-ui/libs/function/platform.js create mode 100644 uni_modules/uview-ui/libs/function/test.js create mode 100644 uni_modules/uview-ui/libs/function/throttle.js create mode 100644 uni_modules/uview-ui/libs/luch-request/adapters/index.js create mode 100644 uni_modules/uview-ui/libs/luch-request/core/InterceptorManager.js create mode 100644 uni_modules/uview-ui/libs/luch-request/core/Request.js create mode 100644 uni_modules/uview-ui/libs/luch-request/core/buildFullPath.js create mode 100644 uni_modules/uview-ui/libs/luch-request/core/defaults.js create mode 100644 uni_modules/uview-ui/libs/luch-request/core/dispatchRequest.js create mode 100644 uni_modules/uview-ui/libs/luch-request/core/mergeConfig.js create mode 100644 uni_modules/uview-ui/libs/luch-request/core/settle.js create mode 100644 uni_modules/uview-ui/libs/luch-request/helpers/buildURL.js create mode 100644 uni_modules/uview-ui/libs/luch-request/helpers/combineURLs.js create mode 100644 uni_modules/uview-ui/libs/luch-request/helpers/isAbsoluteURL.js create mode 100644 uni_modules/uview-ui/libs/luch-request/index.d.ts create mode 100644 uni_modules/uview-ui/libs/luch-request/index.js create mode 100644 uni_modules/uview-ui/libs/luch-request/utils.js create mode 100644 uni_modules/uview-ui/libs/luch-request/utils/clone.js create mode 100644 uni_modules/uview-ui/libs/mixin/button.js create mode 100644 uni_modules/uview-ui/libs/mixin/mixin.js create mode 100644 uni_modules/uview-ui/libs/mixin/mpMixin.js create mode 100644 uni_modules/uview-ui/libs/mixin/mpShare.js create mode 100644 uni_modules/uview-ui/libs/mixin/openType.js create mode 100644 uni_modules/uview-ui/libs/mixin/style.js create mode 100644 uni_modules/uview-ui/libs/mixin/touch.js create mode 100644 uni_modules/uview-ui/libs/util/async-validator.js create mode 100644 uni_modules/uview-ui/libs/util/calendar.js create mode 100644 uni_modules/uview-ui/libs/util/dayjs.js create mode 100644 uni_modules/uview-ui/libs/util/emitter.js create mode 100644 uni_modules/uview-ui/libs/util/route.js create mode 100644 uni_modules/uview-ui/package.json create mode 100644 uni_modules/uview-ui/theme.scss create mode 100644 uni_modules/x-skeleton/changelog.md create mode 100644 uni_modules/x-skeleton/components/x-skeleton/x-skeleton copy.vue create mode 100644 uni_modules/x-skeleton/components/x-skeleton/x-skeleton-configs.js create mode 100644 uni_modules/x-skeleton/components/x-skeleton/x-skeleton.vue create mode 100644 uni_modules/x-skeleton/package.json create mode 100644 uni_modules/x-skeleton/readme.md create mode 100644 uni_modules/y-tabs/changelog.md create mode 100644 uni_modules/y-tabs/components/css/index.less create mode 100644 uni_modules/y-tabs/components/js/const.js create mode 100644 uni_modules/y-tabs/components/js/touchMixin.js create mode 100644 uni_modules/y-tabs/components/js/uitls.js create mode 100644 uni_modules/y-tabs/components/js/utilMixin.js create mode 100644 uni_modules/y-tabs/components/y-tab/y-tab.vue create mode 100644 uni_modules/y-tabs/components/y-tabs/y-tabs.vue create mode 100644 uni_modules/y-tabs/package.json create mode 100644 uni_modules/y-tabs/readme.md create mode 100644 utils/app.js create mode 100644 utils/h5init.js create mode 100644 utils/pay.js create mode 100644 utils/regExp.js create mode 100644 utils/request.js create mode 100644 utils/utils.js create mode 100644 utils/wxConfig.js create mode 100644 vue.config.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c0ca8a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.project +.hbuilderx +.mini-ide +.idea +unpackage +.DS_Store + +node_modules \ No newline at end of file diff --git a/App.vue b/App.vue new file mode 100644 index 0000000..48bb5c7 --- /dev/null +++ b/App.vue @@ -0,0 +1,183 @@ + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..be7edeb --- /dev/null +++ b/README.md @@ -0,0 +1,290 @@ +## 支付宝交易组件 + +``` +第一步 订购插件和关联小程序 +在接入插件之前,确保本账号或者本账号所属的主账号已经订购了本插件,并且已经关联到需要使用本插件的小程序。点击这里查看详细步骤。 + +第二步 配置主体小程序项目 +在小程序开发工具里面打开需要使用插件的项目,然后配置app.json: + +{ + "plugins": { + "tradePay": { + "version": "*",// 目前只支持设置 * 拉取当前上架最新版本 + "provider": "2021003178648009" + } + } +} +注意:请修改上述文件的“tradePay”名称以和使用插件的代码匹配。 + + +uniapp:manifest.json插件配置 + +"mp-alipay" : { + "usingComponents" : true, + "appid" : "2021003197674866", + "plugins": { + "tradePay": { + "version": "*", // 目前只支持设置 * ,自动选择版本 + "provider": "2021003178648009" // 组件Id,固定不变 + }, + } +}, + +uniapp:pages.json,subPackages/order/preview/index,style内增加 +"usingComponents": { + "discount-card": "plugin://tradePay/discountCard" +} + +``` + + +## 商品详情组件插件 + +``` +第一步 订购插件和关联小程序 +在接入插件之前,确保本账号或者本账号所属的主账号已经订购了本插件,并且已经关联到需要使用本插件的小程序。点击这里查看详细步骤。 + +第二步 配置主体小程序项目 +在小程序开发工具里面打开需要使用插件的项目,然后配置app.json: + +{ + "plugins": { + "theGoodsEdit": { + "version": "*",// 目前只支持设置 * 拉取当前上架最新版本 + "provider": "2021003177653028" + } + } +} +注意:请修改上述文件的“tradePay”名称以和使用插件的代码匹配。 + + +uniapp:manifest.json插件配置 + +"mp-alipay" : { + "usingComponents" : true, + "appid" : "2021003197674866", + "plugins": { + "theGoodsEdit": { + "lazy", + "genericsImplementation": { + "goodsDetail": { + "detail-images": "/components/detail-images/detail-images" // 商家可以通过修改 /components/detail-images/detail-images 路径,传入自定义组件 + } + }, + "version": "*", // 目前只支持设置 * ,自动选择版本 + "provider": "2021003177653028" // 组件Id,固定不变 + }, + } +}, + +``` + + +## 本地生活商品插件集成sop +## [文档](https://www.yuque.com/wenheng-68qmd/dthzsu/cnfuc25naz42q61v?singleDoc#OaKw6) + +``` +第一步 订购插件和关联小程序 +在接入插件之前,确保本账号或者本账号所属的主账号已经订购了本插件,并且已经关联到需要使用本插件的小程序。点击这里查看详细步骤。 + +第二步 配置主体小程序项目 +在小程序开发工具里面打开需要使用插件的项目,然后配置app.json: + +{ + "plugins": { + "groupPurchaseoucherPlugin": { + "version": "*", // 目前只支持设置 * ,自动选择版本 + "provider": "2021003190661263" + }, + } +} + + +``` + + +## 商家会员卡 +## [文档](https://opendocs.alipay.com/open/03sx7u?pathHash=1abe9241&ref=api) + +``` +第一步 订购插件和关联小程序 +在接入插件之前,确保本账号或者本账号所属的主账号已经订购了本插件,并且已经关联到需要使用本插件的小程序。点击这里查看详细步骤。 + +第二步 配置主体小程序项目 +在小程序开发工具里面打开需要使用插件的项目,然后配置app.json: + +{ + "plugins": { + "alipassToolKit": { // 请自定义插件名称 + "version": "*", // 目前只支持设置 * 拉取当前上架最新版本 + "provider": "2021001107697072" // 固定值,插件 ID + } + } +} + +装修组件 pages\index\components\TemplateAliMembershipCard.vue + +``` + +## 支付宝支付券(领券组件)插件 + +``` +文档:https://opendocs.alipay.com/open/08b369?pathHash=6f84a8c0 +微信公众平台,小程序设置,增加支付券插件 + +{ + "plugins": { + "couponPlugin": { + "version": "*", // 拉取当前上架最新版本 + "provider": "2021002172680015" // 领券组件插件 ID,固定值 + } + } +} +注意:请修改上述文件的“couponPlugin”名称以和使用插件的代码匹配。 + + +uniapp:manifest.json插件配置 + +"plugins": { + "couponPlugin": { + "version": "*", // 拉取当前上架最新版本 + "provider": "2021002172680015" // 领券组件插件 ID,固定值 + } +} + +uniapp:pages.json,subPackages/pay_coupon/info,style内增加 + +"usingComponents": { + "get-coupon": "plugin://couponPlugin/get-coupon" +} + +``` + + + +## 微信支付券插件 - 暂时废弃 + +``` +文档:https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter9_3_1.shtml +微信公众平台,小程序设置,增加支付券插件 + +{ + "plugins": { + "sendCoupon": { + "version": "1.4.13", + "provider": "wxf3f436ba9bd4be7b" + } + } +} +注意:请修改上述文件的“sendCoupon”名称以和使用插件的代码匹配。 + + +uniapp:manifest.json插件配置 + +"mp-weixin" : { + "plugins": { + "sendCoupon": { + "version": "1.5.0", + "provider": "wxf3f436ba9bd4be7b" + } + } +}, + +uniapp:pages.json,subPackages/pay_coupon/index,style内增加 +"usingComponents": { + "send-coupon": "plugin://sendCoupon/send-coupon" +} + +``` + + +## 微信 H5 支付 +## [参考文档 前端的微信支付(JSSDK支付)](https://juejin.cn/post/6844903954355060749#heading-11) +## [参考文档 JSAPI调起支付API](https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_4.shtml) +## [参考文档 JS-SDK说明文档](https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#59) + +// utils/wxConfig.js + +// 异步获取配置数据 +```JavaScript +async function getConfigData(url) { + // 接口获取签名 + return { + app_id: "", // 必填,公众号的唯一标识 + timestamp: "", // 必填,生成签名的时间戳 + noncestr: "", // 必填,生成签名的随机串 + signature: "", // 必填,签名 + }; +} +``` + - subPackages/pay/index.vue + - 发起一个微信支付请求 `subPackages\pay\index.vue` +```JavaScript +wechatPayNow() // h5 调用 +``` + + +```JavaScript +//发送给朋友 +onShareAppMessage(res) { + if (res.from === 'button') { // 来自页面内分享按钮 + console.log(res.target) + } + return { + title: this.control.titleStyle.name, + path: `/pages/index/index?distributor_id=${this.getUser("id")}`, + summary: "" + } +}, +``` + + · 首页 (分销ID) `/pages/index/index` + + · 商品详情 (商品ID、分销ID) `/subPackages/goods/goods/index` + + · 限时折扣 (折扣ID) `/subPackages/goods/goods/index` + + · 满减优惠 (折扣ID) `/subPackages/goods/goods/index` + + · 套餐列表 `/subPackages/goods/goods/packageList` + + · 套餐详情 (套餐ID、mch_id) `/subPackages/goods/goods/package` + + · 分类页面 `/pages/cat/cat` + + · 附近门店 `/subPackages/stores/index/index` + + · 门店详情 (门店ID) `/subPackages/stores/storesDetails/index` + + · 门店列表 (点餐) `/subPackages/stores/restaurantList/index` + + · 点餐页面 (门店ID) `/subPackages/takeaway/index` + + · 文章列表 `/subPackages/article/index` + + · 文章详情 `/subPackages/article/detail` + + · 领券中心 `/subPackages/coupons/index/index` + + · DIY页面 (页面ID) `/subPackages/diy/index` + + · 预约中心 `/subPackages/reservation/index` + + · 预约服务 `/subPackages/reservation/serve` + + · 预约技师列表 (ID) `/subPackages/reservation/technician` + + · 预约技师 (ID) `/subPackages/reservation/technicianDetali` diff --git a/api/index.js b/api/index.js new file mode 100644 index 0000000..5764708 --- /dev/null +++ b/api/index.js @@ -0,0 +1,13 @@ +const files = require.context("./modules", false, /\.js$/), + api = {}; + +files.keys().forEach((key) => { + const last = key.indexOf(".js"), + name = key.slice(2, last); + + api[name] = files(key).default; +}); + +export default { + ...api, +}; diff --git a/api/modules/common.js b/api/modules/common.js new file mode 100644 index 0000000..3faebb0 --- /dev/null +++ b/api/modules/common.js @@ -0,0 +1,181 @@ +import { + request, + uploadFile +} from "@/utils/request"; + +export default { + /** + * 获取图片库 + */ + getImages(data) { + return request({ + url: "/common/getImages", + method: "GET", + data, + needLogin: true, + }); + }, + + /** + * 获取商城信息 + */ + getStoreDetail(data) { + return request({ + url: "/store_setting/store_detail", + method: "GET", + data, + needLogin: true, + }); + }, + + /** + * 上传图片视频 + */ + upload(data) { + return uploadFile(data); + }, + orderCount(data) { + return request({ + url: "/common/order-count", + method: "GET", + data, + needLogin: true, + }); + }, + + /** + * 获取商品标签信息 + */ + getLable(data) { + return request({ + url: "/common/lable", + method: "GET", + data, + needLogin: true, + }); + }, + + /** + * isPhone + */ + isPhone(data) { + return request({ + url: "/user/is-phone", + method: "GET", + data, + needLogin: true, + }); + }, + + + /** + * 优惠券列表 + */ + list(data) { + return request({ + url: "/common/List", + method: "GET", + data, + needLogin: true, + }); + }, + + + /** + * 获取门店列表 + * @param {String} longitude 经度 + * @param {String} latitude 纬度 + */ + getShopList(data) { + return request({ + url: "/common/getShopList", + method: "POST", + data, + needLogin: true, + }); + }, + + /** + * 折扣信息 + */ + discountsItem(data) { + return request({ + url: "/common/discountsItem", + method: "GET", + data, + needLogin: true, + }); + }, + + /** + * 折扣信息 + */ + packageItem(data) { + return request({ + url: "/common/packageItem", + method: "GET", + data, + needLogin: true, + }); + }, + + /** + * 折扣信息 + */ + redutionItem(data) { + return request({ + url: "/common/redutionItem", + method: "GET", + data, + needLogin: true, + }); + }, + + + /** + * wechatH5 + */ + wechatH5(data) { + return request({ + url: "/common/wechatH5", + method: "GET", + data, + needLogin: true, + }); + }, + + aliH5(data) { + return request({ + url: "/common/aliH5", + method: "GET", + data, + needLogin: true, + }); + }, + + sendSms(data) { + return request({ + url: "/common/sendSms", + method: "GET", + data, + needLogin: true, + }); + }, + + getFlashMch(data) { + return request({ + url: "/common/FlashListMch", + method: "GET", + data, + needLogin: true, + }); + }, + getFlashGoods(data) { + return request({ + url: "/common/FlashListGoods", + method: "GET", + data, + needLogin: true, + }); + }, +}; \ No newline at end of file diff --git a/api/modules/coupon.js b/api/modules/coupon.js new file mode 100644 index 0000000..e10a1a5 --- /dev/null +++ b/api/modules/coupon.js @@ -0,0 +1,39 @@ +import { request } from "@/utils/request"; + +export default { + /** + * 优惠券列表 + */ + list(data) { + return request({ + url: "/Coupon/List", + method: "GET", + data, + needLogin: true, + }); + }, + + /** + * 领取优惠券 + */ + getCoupon(data) { + return request({ + url: "/Coupon/GetCoupon", + method: "GET", + data, + needLogin: true, + }); + }, + + /** + * 已领取优惠券 + */ + getUserCoupon(data) { + return request({ + url: "/Coupon/GetUserCoupon", + method: "GET", + data, + needLogin: true, + }); + }, +}; diff --git a/api/modules/diy.js b/api/modules/diy.js new file mode 100644 index 0000000..42ce637 --- /dev/null +++ b/api/modules/diy.js @@ -0,0 +1,16 @@ +import { request } from "@/utils/request"; + +export default { + /** + * 获取diy模板 + */ + showTemplate(data) { + return request({ + url: "/common/diy-show", + method: "GET", + data, + needLogin: true, + }); + }, + +}; diff --git a/api/modules/home.js b/api/modules/home.js new file mode 100644 index 0000000..6baf76f --- /dev/null +++ b/api/modules/home.js @@ -0,0 +1,63 @@ +import { request } from "@/utils/request"; + +export default { + /** + * 获取轮播图设置 + */ + getStoreSlideShowSetting(data) { + return request({ + url: "/storeSetting/getStoreSlideShowSetting", + method: "GET", + data, + needLogin: true, + }); + }, + + /** + * 获取分类导航设置 + */ + getStoreNavSetting(data) { + return request({ + url: "/storeSetting/GetStoreNavSetting", + method: "GET", + data, + needLogin: true, + }); + }, + + /** + * 获取分类导航设置 + */ + getCateGoods(data) { + return request({ + url: "/storeSetting/GetCateGoods", + method: "GET", + data, + needLogin: true, + }); + }, + + /** + * 获取门店分类&商品 + */ + GetShopGoodsList(data) { + return request({ + url: "/storeSetting/GetShopGoodsList", + method: "GET", + data, + needLogin: true, + }); + }, + + /** + * 获取首页导航设置 + */ + goodsClassify(data) { + return request({ + url: "/goods/classify", + method: "GET", + data, + needLogin: true, + }); + }, +}; diff --git a/api/modules/inPersonToPay.js b/api/modules/inPersonToPay.js new file mode 100644 index 0000000..7389311 --- /dev/null +++ b/api/modules/inPersonToPay.js @@ -0,0 +1,34 @@ +import { request } from "@/utils/request"; + +export default { + /** + * 当面付页面 + */ + storeInfo(data) { + return request({ + url: "/order/PaymentInfo", + method: "POST", + data, + }); + }, + + /** + * 当面付页面 + */ + inpersonPaymentOrder(data) { + return request({ + url: "/order/InpersonPaymentOrder", + method: "POST", + data, + needLogin: true, + }); + }, + + storeInfos(data) { + return request({ + url: "/common/PaymentInfo", + method: "POST", + data, + }); + }, +}; diff --git a/api/modules/pay.js b/api/modules/pay.js new file mode 100644 index 0000000..73371c9 --- /dev/null +++ b/api/modules/pay.js @@ -0,0 +1,33 @@ +import { + request +} from "@/utils/request"; + +export default { + /** + * 收银台页面 + * @param {String} order_no + */ + CheckStand(data) { + return request({ + url: "/PayOrder/CheckStand", + method: "POST", + data, + needLogin: true, + }); + }, + + /** + * 发起支付 + * @param {String} order_no + * @param {String} pay_type // 1商城订单 2秒杀订单 3拼团订单 + * @param {String} order_type 1支付宝 2 微信 3余额 4货到付款 + */ + OrderPayment(data) { + return request({ + url: "/PayOrder/OrderPayment", + method: "POST", + data, + needLogin: true, + }); + }, +}; \ No newline at end of file diff --git a/api/modules/payCoupon.js b/api/modules/payCoupon.js new file mode 100644 index 0000000..6e1d4dd --- /dev/null +++ b/api/modules/payCoupon.js @@ -0,0 +1,56 @@ +import { request } from "@/utils/request"; + +export default { + /** + * 获取列表 + * @param {String} shop_id + */ + getData(data) { + return request({ + url: "/user/getPayCoupon", + method: "POST", + data, + needLogin: true, + }); + }, + sendCoupon(data) { + return request({ + url: "/user/sendCoupon", + method: "POST", + data, + needLogin: true, + }); + }, + getCat(data) { + return request({ + url: "/common/payCouponCatList", + method: "POST", + data, + needLogin: true, + }); + }, + payCouponList(data) { + return request({ + url: "/common/payCouponList", + method: "POST", + data, + needLogin: true, + }); + }, + getCoupon(data) { + return request({ + url: "/common/getPayCoupon", + method: "POST", + data, + needLogin: true, + }); + }, + getBanner(data) { + return request({ + url: "/common/getPayCouponBanner", + method: "POST", + data, + needLogin: true, + }); + }, +}; diff --git a/api/modules/reservation.js b/api/modules/reservation.js new file mode 100644 index 0000000..a385fed --- /dev/null +++ b/api/modules/reservation.js @@ -0,0 +1,240 @@ +import { + request +} from "@/utils/request"; +export default { + classify(data) { + return request({ + url: "/book/client/classify/index", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, + goodsList(data) { + return request({ + url: "/book/client/goods/index", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, + goodsShow(data) { + return request({ + url: "/book/client/goods/show", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, + staffList(data) { + return request({ + url: "/book/client/common/index", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, + staffShow(data) { + return request({ + url: "/book/client/common/show", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, + staffEvaluateList(data) { + return request({ + url: "/book/client/common/evaluateList", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, + getBookOrder(data) { + return request({ + url: "/book/client/orders/getBookOrder", + method: "POST", + data, + needLogin: true, + noclient: true + }); + }, + appointment_time(data) { + return request({ + url: "/book/client/common/appointment_time", + method: "POST", + data, + needLogin: true, + noclient: true + }); + }, + + PlaceOrder(data) { + return request({ + url: "/book/client/orders/PlaceOrder", + method: "POST", + data, + needLogin: true, + noclient: true + }); + }, + appointmenTime(data) { + return request({ + url: "/book/client/common/appointment_time", + method: "POST", + data, + needLogin: true, + noclient: true + }); + }, + userOrderList(data) { + return request({ + url: "/book/client/orders/orderList", + method: "POST", + data, + needLogin: true, + noclient: true + }); + }, + OrderEvaluate(data) { + return request({ + url: "/book/client/orders/OrderEvaluate", + method: "POST", + data, + needLogin: true, + noclient: true + }); + }, + orderCancel(data) { + return request({ + url: "/book/client/orders/orderCancel", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, + orderDetail(data) { + return request({ + url: "/book/client/orders/orderDetail", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, + orderDetails(data) { + return request({ + url: "/book/client/orders/orderDetails", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, + isStaff(data) { + return request({ + url: "/book/client/staff/isStaff", + method: "POST", + data, + needLogin: true, + noclient: true + }); + }, + StaffOrderList(data) { + return request({ + url: "/book/client/orders/StaffOrderList", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, + staffCenter(data) { + return request({ + url: "/book/client/staff/staffCenter", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, + takeOrder(data) { + return request({ + url: "/book/client/orders/takeOrder", + method: "POST", + data, + needLogin: true, + noclient: true + }); + }, + startOrder(data) { + return request({ + url: "/book/client/orders/startOrder", + method: "POST", + data, + needLogin: true, + noclient: true + }); + }, + completeOrder(data) { + return request({ + url: "/book/client/orders/completeOrder", + method: "POST", + data, + needLogin: true, + noclient: true + }); + }, + orderEvaluateList(data) { + return request({ + url: "/book/client/orders/orderEvaluateList", + method: "POST", + data, + needLogin: true, + noclient: true + }); + }, + goodsEvaluate(data) { + return request({ + url: "/book/client/goods/evaluate", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, + showBanner(data) { + return request({ + url: "/book/client/index/show", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, + broker(data) { + return request({ + url: "/book/client/staff/broker", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, + GetSkuList(data) { + return request({ + url: "/book/client/orders/GetSkuList", + method: "GET", + data, + needLogin: true, + noclient: true + }); + }, +}; \ No newline at end of file diff --git a/api/modules/transfer.js b/api/modules/transfer.js new file mode 100644 index 0000000..570cbb5 --- /dev/null +++ b/api/modules/transfer.js @@ -0,0 +1,25 @@ +import { request } from "@/utils/request"; + +export default { + /** + * 获取当前积分 + */ + getIntegral() { + return request({ + url: "/user/integral", + method: "GET", + needLogin: true, + }); + }, + + /** + * 获取当前余额 + */ + getBalance() { + return request({ + url: "/user/balance", + method: "GET", + needLogin: true, + }); + }, +}; diff --git a/api/modules/user.js b/api/modules/user.js new file mode 100644 index 0000000..222b222 --- /dev/null +++ b/api/modules/user.js @@ -0,0 +1,178 @@ +import { + request +} from "@/utils/request"; + +export default { + // 登录 + login(data) { + return request({ + url: "/auth/login", + method: "POST", + data, + }); + }, + // 手机号注册 + regPhone(data) { + return request({ + url: "/auth/regPhone", + method: "POST", + data, + }); + }, + loginPhone(data) { + return request({ + url: "/auth/loginPhone", + method: "POST", + data, + }); + }, + // 测试登录 + testLogin(data) { + return request({ + url: "/auth/testLogin", + method: "POST", + data, + }); + }, + // 置换token + resetToken(data) { + return request({ + url: "/auth/resetToken", + method: "POST", + data, + }); + }, + userInfo(data = {}) { + return request({ + url: "/auth/user", + method: "POST", + data, + needLogin: true, + }); + }, + userMobile(data = {}) { + return request({ + url: "/user/userMobile", + method: "POST", + data, + needLogin: true, + }); + }, + setMobile(data = {}) { + return request({ + url: "/user/setMobile", + method: "POST", + data, + needLogin: true, + }); + }, + setUserInfo(data = {}) { + return request({ + url: "/user/SetUserInfo", + method: "POST", + data, + needLogin: true, + }); + }, + UpdateUser(data = {}) { + return request({ + url: "/user/UpdateUser", + method: "POST", + data, + needLogin: true, + }); + }, + + send(data = {}) { + return request({ + url: "/user/send", + method: "POST", + data, + needLogin: true, + }); + }, + bind_merge(data = {}) { + return request({ + url: "/user/bind_merge", + method: "POST", + data, + needLogin: true, + }); + }, + LevelInfo(data = {}) { + return request({ + url: "/User/LevelInfo", + method: "GET", + data, + needLogin: true, + }); + }, + GetLevelList(data = {}) { + return request({ + url: "/User/GetLevelList", + method: "GET", + data, + needLogin: true, + }); + }, + fix(data = {}) { + return request({ + url: "/User/fix", + method: "GET", + data, + needLogin: true, + }); + }, + + /** + * 访问记录 +*/ + log(data) { + return request({ + url: "/user/log", + method: "GET", + data, + needLogin: true, + }); + }, + isLogin(data = {}) { + return request({ + url: "/auth/isLogin", + method: "GET", + data, + needLogin: true, + }); + }, + taimiInfo(data = {}) { + return request({ + url: "/user/taimiInfo", + method: "GET", + data, + needLogin: true, + }); + }, + taimiSave(data = {}) { + return request({ + url: "/user/taimiSave", + method: "POST", + data, + needLogin: true, + }); + }, + taimiTongbu(data = {}) { + return request({ + url: "/user/taimiTongbu", + method: "POST", + data, + needLogin: true, + }); + }, + createVip(data = {}) { + return request({ + url: "/user/createVip", + method: "POST", + data, + needLogin: true, + }); + } +}; \ No newline at end of file diff --git a/components/login/loginPage.vue b/components/login/loginPage.vue new file mode 100644 index 0000000..a93dad2 --- /dev/null +++ b/components/login/loginPage.vue @@ -0,0 +1,263 @@ + + + + + \ No newline at end of file diff --git a/components/login/loginPopup.vue b/components/login/loginPopup.vue new file mode 100644 index 0000000..7d8da4c --- /dev/null +++ b/components/login/loginPopup.vue @@ -0,0 +1,185 @@ + + + + + + \ No newline at end of file diff --git a/components/login/logins.vue b/components/login/logins.vue new file mode 100644 index 0000000..5d6d8fe --- /dev/null +++ b/components/login/logins.vue @@ -0,0 +1,213 @@ + + + \ No newline at end of file diff --git a/components/the/the-tabbar.vue b/components/the/the-tabbar.vue new file mode 100644 index 0000000..a2a09c7 --- /dev/null +++ b/components/the/the-tabbar.vue @@ -0,0 +1,189 @@ + + + + + diff --git a/components/tools/isPhone/index.vue b/components/tools/isPhone/index.vue new file mode 100644 index 0000000..5836a4d --- /dev/null +++ b/components/tools/isPhone/index.vue @@ -0,0 +1,138 @@ + + + + + \ No newline at end of file diff --git a/components/tools/tools-number-step/index.vue b/components/tools/tools-number-step/index.vue new file mode 100644 index 0000000..51f235c --- /dev/null +++ b/components/tools/tools-number-step/index.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/env.js b/env.js new file mode 100644 index 0000000..21519d4 --- /dev/null +++ b/env.js @@ -0,0 +1,15 @@ +const env = { + host: "https://saasdemo.byin.vip", + NETWORK_TIME_OUT: 15000, + version: "0.1", + store_id: 1, + mini_id: 0 +}; +// #ifdef H5 +// 生产环境 +if (process.env.NODE_ENV === 'production') { + // TODO + env.host = `${window.location.origin}` +} +// #endif +export default env; diff --git a/index.html b/index.html new file mode 100644 index 0000000..c3ff205 --- /dev/null +++ b/index.html @@ -0,0 +1,20 @@ + + + + + + + + + + +
+ + + diff --git a/main.js b/main.js new file mode 100644 index 0000000..182d22f --- /dev/null +++ b/main.js @@ -0,0 +1,52 @@ +import App from "./App"; +import Vue from "vue"; +import mixin from "@/mixin/index.js"; +import utils from "@/utils/utils.js"; +import api from "@/api/index.js"; +import store from "@/store/index.js"; +import uView from "@/uni_modules/uview-ui"; +/* #ifdef H5 */ +import { + h5init +} from "@/utils/h5init"; +h5init() +/* #endif */ + +const globalInformation = new Promise(async (resolve) => { + resolve({ + image: await api.common.getImages(), + storeDetail: await api.common.getStoreDetail(), + }) +}).catch(e => { + console.log(e); +}) + +globalInformation.then(({ + image, + storeDetail +}) => { + store.dispatch("setData", { + key: "$Gimage", + val: image.data + }) + + store.dispatch("setData", { + key: "$GstoreDetail", + val: storeDetail.data + }) +}) + +Vue.use(uView); +Vue.mixin(mixin); +Vue.config.productionTip = false; +App.mpType = "app"; + +Vue.prototype.$utils = utils; +Vue.prototype.$api = api; + +const app = new Vue({ + store, + ...App, +}); + +app.$mount(); \ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..a5dddec --- /dev/null +++ b/manifest.json @@ -0,0 +1,114 @@ +{ + "name" : "佰因商城", + "appid" : "__UNI__730E59B", + "description" : "", + "versionName" : "1.0.0", + "versionCode" : "100", + "transformPx" : false, + "h5" : { + "router" : { + "base" : "/pageh5/", + "mode" : "hash" + } + }, + /* 5+App特有相关 */ + "app-plus" : { + "usingComponents" : true, + "nvueStyleCompiler" : "佰因商城", + "compilerVersion" : 3, + "splashscreen" : { + "alwaysShowBeforeRender" : true, + "waiting" : true, + "autoclose" : true, + "delay" : 0 + }, + /* 模块配置 */ + "modules" : {}, + /* 应用发布信息 */ + "distribute" : { + /* android打包配置 */ + "android" : { + "permissions" : [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] + }, + /* ios打包配置 */ + "ios" : {}, + /* SDK配置 */ + "sdkConfigs" : {} + } + }, + /* 快应用特有相关 */ + "quickapp" : {}, + /* 小程序特有相关 */ + "mp-weixin" : { + "appid" : "wx2efc62ddeef55fb9", + "setting" : { + "urlCheck" : false, + "ignoreDevUnusedFiles" : false, + "postcss" : true + }, + "usingComponents" : true, + "optimization" : { + "subPackages" : true + }, + "permission" : { + "scope.userLocation" : { + "desc" : "同城配送地址查询" + }, + "scope.writePhotosAlbum" : { + "desc" : "保存分享图片" + } + }, + "plugins" : {}, + "requiredPrivateInfos" : [ "getLocation", "chooseAddress" ] + }, + "mp-alipay" : { + "usingComponents" : true, + "appid" : "2021003197674866", + "plugins" : { + // "groupPurchaseoucherPlugin": { + // "version": "*", // 目前只支持设置 * ,自动选择版本 + // "provider": "2021003190661263" + // }, + // "theGoodsEdit": { + // "version": "*", // 目前只支持设置 * ,自动选择版本 + // "provider": "2021003177653028" // 组件Id,固定不变 + // }, + "alipassToolKit" : { + // 请自定义插件名称 + "version" : "*", // 目前只支持设置 * 拉取当前上架最新版本 + "provider" : "2021001107697072" // 固定值,插件 ID + }, + "couponPlugin" : { + "version" : "*", // 拉取当前上架最新版本 + "provider" : "2021002172680015" // 领券组件插件 ID,固定值 + } + } + }, + "mp-baidu" : { + "usingComponents" : true + }, + "mp-toutiao" : { + "usingComponents" : true + }, + "uniStatistics" : { + "enable" : false + }, + "vueVersion" : "2" +} diff --git a/mixin/index.js b/mixin/index.js new file mode 100644 index 0000000..da61b5f --- /dev/null +++ b/mixin/index.js @@ -0,0 +1,162 @@ +import utils from "@/utils/utils.js"; +import wxConfig from '@/utils/wxConfig' + +export default { + data() { + return {} + }, + computed: { + publicImage() { + return this.$store.state.$Gimage || {} + }, + storeDetail() { + return this.$store.state.$GstoreDetail || {} + } + }, + onLoad() { + if (utils.isInWeChatBrowser()) { + if (uni.getStorageSync("sharePage")) { + this.diySharePage(uni.getStorageSync("sharePage")) + } + } + }, + methods: { + // 获取当前登录信息 + getUser(key) { + const user_info = uni.getStorageSync('user_info') + return user_info[key] || user_info || {} + }, + + /** + * 复制文本到剪贴板 + * @param {string} e - 要复制的文本 + * @returns {void} + * @vue/component + */ + copy(e) { + uni.setClipboardData({ + data: e, + showToast: false, + success: () => { + this.$u.toast('复制成功'); + }, + fail: () => { + this.$u.toast('复制失败,请检查权限!'); + } + }); + }, + + + // 领取优惠券 + async getACoupon({ + id + }) { + try { + const res = await this.$api.coupon.getCoupon({ + id + }); + if (res.code != 0) { + throw new Error(res) + } + } catch (error) { + console.log({ + getACoupon: error + }); + } + }, + + // 成为下线的条件 = 首次点击链接 + // 存在推荐人时调用 => 后台去判断成为下线条件 + async initDistributor(id = 0) { + if (!id) { + return + } + try { + setTimeout(async () => { + const res = await this.$api.distSales.ApplyForNext({ + foke_parent_user: id || uni.getStorageSync('distributor_id') || 0 + }) + if (res.code === 0) { + console.log("initDistributor调用成功"); + } + }, 1000) + } catch (e) { + console.log({ + initDistributorError: e + }); + } + }, + + // 访问记录 + async initLog({ + mch_id = 0 + } = {}) { + try { + if (uni.getStorageSync("token")) { + setTimeout(async () => { + const res = await this.$api.user.log({ + mch_id + }) + if (res.code === 0) { + console.log("iinitLog调用成功"); + } + }, 1000) + } + } catch (e) { + console.log({ + initLogError: e + }); + } + }, + + diySharePage(data = {}) { + uni.removeStorageSync('sharePage'); + let base_url = window.location.href; + const that = this + + // 获取用户ID + const userId = this.getUser("id"); + + // 构建基本的查询字符串 + let queryString = `distributor_id=${userId}`; + + // 检查是否已经存在参数 + if (base_url.includes('?')) { + // 如果已经存在参数,在原有参数的基础上添加新参数 + queryString = `${base_url}&${queryString}`; + } else { + // 如果不存在参数,直接添加新参数 + queryString = `${base_url}?${queryString}`; + } + + wxConfig.init(['updateAppMessageShareData', 'updateTimelineShareData']).then(wx => { + wx.updateAppMessageShareData({ + title: data.name || data.title || that.storeDetail.name, // 分享标题 + desc: data.desc || '', // 分享描述 + link: queryString, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 + imgUrl: data.imageUrl ? this.httpToHttps(data.imageUrl) : this.httpToHttps(that + .storeDetail.logo_url), // 分享图标 + success: function() { + // 设置成功 + } + }) + + wx.updateTimelineShareData({ + title: data.name || data.title || that.storeDetail.name, // 分享标题 + desc: data.desc || '', // 分享描述 + link: queryString, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 + imgUrl: data.imageUrl ? this.httpToHttps(data.imageUrl) : this.httpToHttps(that + .storeDetail.logo_url), // 分享图标 + success: function() { + // 设置成功 + } + }) + + }) + }, + + httpToHttps: utils.httpToHttps, + toUrl: utils.toUrl, + kmUnit: utils.kmUnit, + } +}; \ No newline at end of file diff --git a/module/test/test.vue b/module/test/test.vue new file mode 100644 index 0000000..02409e3 --- /dev/null +++ b/module/test/test.vue @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..0db3279 --- /dev/null +++ b/package.json @@ -0,0 +1,3 @@ +{ + +} diff --git a/pages.json b/pages.json new file mode 100644 index 0000000..93089ca --- /dev/null +++ b/pages.json @@ -0,0 +1,110 @@ +{ + "pages": [ + { + "path": "pages/index/index", + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "首页", + "enablePullDownRefresh": true, + "mp-alipay": { + "transparentTitle": "always", + "titlePenetrate": "YES" + } + } + }, + { + "path": "pages/my/my", + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "我的", + "enablePullDownRefresh": true, + "mp-alipay": { + "transparentTitle": "always", + "titlePenetrate": "YES" + } + } + } + ], + "subPackages": [ + { + "root": "subPackages/login", + "pages": [ + // #ifndef MP + { + "path": "reg/index", + "style": { + "navigationBarTitleText": "注册" + } + }, + { + "path": "reg/reset", + "style": { + "navigationBarTitleText": "找回密码" + } + }, + // #endif + { + "path": "login/index", + "style": { + "navigationBarTitleText": "登录" + } + }, + { + "path": "forgotPassword/index", + "style": { + "navigationBarTitleText": "忘记密码" + } + }, + { + "path": "forgotPassword/nuxt", + "style": { + "navigationBarTitleText": "忘记密码" + } + } + ] + }, + { + "root": "subPackages/inPersonToPay", + "pages": [ + { + "path": "index/index", + "style": { + "navigationBarTitleText": "当面付" + } + }, + { + "path": "result/index", + "style": { + "navigationBarTitleText": "支付成功" + } + } + ] + } + ], + "globalStyle": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "uni-app", + "navigationBarBackgroundColor": "#ffffff", + "backgroundColor": "#ffffff", + "h5": { + "navigationStyle": "custom" + } + }, + "uniIdRouter": {}, + "tabBar": { + "color": "#2E2D2D", + "selectedColor": "#E2231A", + "borderStyle": "black", + "backgroundColor": "#fff", + "list": [ + { + "pagePath": "pages/index/index", + "text": "首页" + }, + { + "pagePath": "pages/my/my", + "text": "我的" + } + ] + } +} \ No newline at end of file diff --git a/pages/index/index.vue b/pages/index/index.vue new file mode 100644 index 0000000..6b0afc4 --- /dev/null +++ b/pages/index/index.vue @@ -0,0 +1,79 @@ + + + + + \ No newline at end of file diff --git a/pages/my/images/av.png b/pages/my/images/av.png new file mode 100644 index 0000000000000000000000000000000000000000..35b3aa50a2531ebbdd514c299254be6f8113ff1c GIT binary patch literal 7627 zcmV;+9W>&JP)Py7g-Jv~RCr$PT?up?)s=m(s#=nbEZL6mj(@CxEdBob@7?#W|Nr%0y^p{jOAvVNgYNNSMOkeKgsCLp6qVFTNH`u4 zY5-v@0#*~zbS<4D;zy)X7a)8N1Um_7n}EV+sM6*XsGlgk$<77GR&LXxi_7Rk0QHG; z>7fX`k)Ux3$tMEBaR4|I2xb7nEJu(cSPclR0JIJW-WO4N=kzdccf=N-bjk^$Gmy(W zlBbFw&Q(>K0|=)fz%-pIY!xSfjR5c#lDbM2;Ej3pWov9Tz~h~9f)okho1N4kE9#j5 zbOrz{@_4+{<`XOh#MeocUyB`8-s%gVEOLSqBnPnZPKuE%pN9bF0OAabuy=`CY9)Y| zRf50FkA#-H#36jG`cN|E9tk@u*uc~kb04#JE zf3I}ER3P|GV?=t$OAmEPx$mfT8t{FFl4Iye30Pkpw zNY8r2;=E>hnjkCMX{L(GJ^Xd8ONSxBQUSzU8Y8&Qr4|-7%d-TDCsMZo;GIQ1+sq^#AnYr?lq^4nh_kJ8oojXr0tB!MROJdce%TUm-HP1h}TE!#hcj36x^(-=z0uL9u7PC3u}^#TI4wx_S>tg~lUf9`~}ju3>^ ztt}f-{t_pL6Cw9vpR_i4pzmBKKJT@iAekx z0Kp=wvVbiiNb^7XW`H2BL|(wnNVs_$y$B%gkpyAR+*)kY+q9UxH3Uh>j2!%9r()>y z-%Ue+h*rfSp*f~098hFBLHK8~W`~ID(~5u zbelpDUhz<0D9XjOd`)E<{&LBbFz7SFfb_mzf*t$GKuaf@m{Y;A(G!d#Q5XvPlSf1O)&3jb%w96YL5d?~sS_`;jf;1;mYj`2);e&}0WAbPL z4j-5$yi19}miNg39lKOuvx(auRxmpj4wY1{wj_e^D+mS;5k?BOY??A!aQoOP$-ed5 zyg`t(lcim~V3;5Sm)Cq)64E|t?AO^MUwAg`R6Vp80T4($#^@zJh6xgHmtO#cg+3YM zhTLGpsH+kB_Z2~U-rcM~pW-Qxmqx?VA|n5WuCeu%vs;8X`!%J+&SX19@R)P-l&7vb^=Nx2BJ@?bsR(i%0AI3tBfp;)&Ev z0QeKV9r;22@WZfwNfq?Rn*`}6$q%AoQP&mKx(M=W2UVAYx-p2A*XzFEzgMcXOMnxyOe$Vrp-Tb%pR@2>mo>Vd+J_9yjiPqzsPZN9E#-LUV_$bs%Jxsi1#(s zi$B!rfM$ZkH_}9qmCv*)_KO@R$KXir=qA{(%ew?&-UzZdxv>E?jb+UQX>Ly~M#S&? zW#DV^gOg)8N`4@Sp6eAf5hPtMv|_84LFE@2PLAA>^inQXp|Mydh!bYl;kIJqRTDv) z6REoq@RnlA{PO$cYX7H;7>$+JPSNxEiGcSsg~eNo;ZT$yFSk>9B`S{H&rr+(vwsir z0iYHv{X!7t>qHVOij^=eN|2TgYD6CX1f_(ofs)E?vsIX(oAnFPQ0@cLr&0J5Y;K zXhZ3cx?cldT4|4w4+#P!r|M!2BRX@Tke47W3FTG-x=TBB-jzJ<$bl*f-gUti%RQcl zl@}ufysarL-mQxu@r29{QO4PVyn~(a3|;Nudp!@UfT!D|VQIW(f-L_i)g*|)s8quD z9@+`whcuIX-l_^k=S>f_4E;Ul6013pdH?~h(GHzACHd^3FK&J&2mw793x}@NM38tw z-UI+s^ugynX?`fEFJ^wp!^-V7Zil&b;gLH*Eq zs|A01Wh`DnAP4|n6Ag&YD+Wwub$7kRb8) z(<=V1*40}-!lsuv#^M3Cl${4@ewq8~bMwP3Y%Png29clAci z&uJz@u^@tHViD=mp#fSssg&?>j{w^&+-$6&djq?u%U zojlMx0hhHWXNxGTGzOdZT5*CHi&+o}qL4ZVgLtJgPc_j;k|5<_Wg{aHT!Jkf$_?yO zLw%5WTbd^;>Wg2H^02azVK=H_P`*KDORJhneldA}rzxXw04me#Eb^m+D1Xbq4OJcaRu{8s=tTZ6dg zL^wID4H+Xz$1b&hM)B$M3Y$TEdq~I&!&yIUeLa&PtY({ZU)~_azdN^{9GM>cx`{`` zkJu8+m-8ckQ)M4P{JhliB|-RMpnc@X^yJrccwZ8PFR$z;h+n@rYMz{EHBJ0_NSMLR*974tv6dcwCkI2%x2Y!CLxY`*Odc&jxn%8t35s@ha=xQm zg-^SDnS^mLjOkR94*4yh;8ZlJ5Yzh;Mi!m|U!2nH^=;SUXSc~A~Qo~GBbY&|E^cyUI{_CIvcl|;30I-rE z%9c-I-{QMXAGEm?j=J$y5GPJHy{{l|(Agnj_VovWxj-j-6j}WytLx@#fKn;b2X3}P z427Wjz6VY3Bj_7+0LZ#PCqP%Q4IN2V?nCxJ_De{8_`d0bH(O!onB(BEZ+yq}K7zjg z0LZ?AEkKue4joBW&LYXbuYsQ5{>Jpdo2_uO*n=g{o7?555#bWk(e{8sE0ms!mHp5H$X$+zD!1&Oj# zPJ@wOx!e?8LzVdX`*O{Ik$QbJQr6FfgEPqTj^wEV39B_L@tL62vq=9;^8D|i@6C8g z$d%8H!iWpLQj(5*je~mC+E6@HRAL*z?i_DlHTK?_2 z+T9Jwme-+g^-7?@CcShBho<*3?YbeH2|4^ zEUU>fcL-UTev->Wc|$uWpKJtm=T4yBo_-Om7zsj64Tw{xfm9c<1sFbi9Go+*iH608 za?T)cc2a|^D6O_c#KoOhywIH=C?cdPN5_sTKgfY$H(SQrQ|ke7hTDQ@r#*Hp zwe0kXZ_KrzO|8*z=;&<8VFYPzPc3Gj8fsDJXBj)*YB`M`e`_^30_+>~SU7ZJL4w3P zDF%wN-09%Cp?@n+*xleC-**g-f=)qVxbnVbzauQ_uN2w-3#L|v@ z?Tok$effnX{5y}_gGE&+I&XTYMH4}oP&^@T1AuWhj6KhE;boHe`Ko3U2GI6sSQ?*8 zPtF;H3AQAZTM6hc6FT>m3NO9_=BMO^hadvp))W?V77)lwkmj}nwJ3!)_-b^Uj?;@BIZeDWnC6(qexilI+lzXLl55fdj zY>>}aRamOIs{jhRZ8izYNCx zfXWJIJXBPG{e1wf+ZAUF@L;d(2C1fcv7wOZMF|pbPhJNo-0wmEZ8f>N9AV4|0Yn6- zC*glpsUBXM|xS z2}uB=aOh7llo%P`EE4*mR%>+;WZ65rM~kCIZ3KX7tsMkKjuXTK zkw)Cp2g0;7>#=YtnJiay5rnmiCzP82=qDb4!&VbHL2QNFU}xzo4fHhDO^^YStOuY# z7j_s5GAD?hVdsD>QEN0ZxFCZTD-02&IU!$y08eY_ASg1NAnuMdyVAKaB0a0uN<#!m z&muC<^vyz>6GZROvr&FXwM0EV8z#t#cABZ8@}Zv2{4C1};@;>ABp%Zk!F5I~G)$26 zERwnn0Pi%?vESNog19xJbbB-$GW=z1Nd#e#G$&GP5bzYY!ef_RoFH}~t-T)tdOH>l zm2`n)$pl%kA=RX+yaEa*i1vYNm!u$2w6Sh@r4l{;mrRg>rPiGQc$=P%{U*x^;|C zy~%X%ySvlS^d=AGop0NX@OO3>aE@oeF#u;BXBwP_AlTgvaPN!5^W@q889frPnq{Dwda?=8xmD1uI;8--_CapQW=;XP<3imkO>MAz zJ;2ZZmRse_DFjn%^mWHbGop+UhW$a;&ol(^Xe=yUrO(U4(xwxnpCs+6m54aoOhb+8 z%8+8q=K^GwPeygIc7J_0H)Mxb0sP{MQZ$#|wh%#1t|b^(Vh(m@IW}Re`<7({uqqao z=9G@&U=5ZKr2i^6Rb2^0qs=y0tG>>y+LldP^=0H%{sUo8`YOR;51T>QOybnTmRD?< zmFtN%5FBP=Ng_s;iDOlmIQG!;%qhPKpbJ!GPWIJlX4zs1L6~vzc6lKnuzW4sp3H1v zWcj4k$n~2MKHiyIn(aZ@Uc{;AqMzmNnH7up;xX23#3zm=aCBB7SQL#&mJ~R&j38-} z*i%!>4q{}6-qt+;?`(A6KBUm{YJ4@oNwwAyB!i73L_xehS}*4LtD*G2sw^c4Gp{+3 zT8tJId$5xj8K_xdgje6s51UiVtndB?V8`Cv1LD}J1XISAK3KGBV9T!=Q_1p8JpwIh z8gi$gRvWd-Sx%6F<<^scaG6%4w8*hNhLuaHLN>4&gv}(m9w**r6`DPmjSG$?2#H!y zHCLu~f`xk&gr}nQ($~zjc(^uO2+~iI4*4%YaBis%v00<_lj3I+P3YYep~-irP8 zaC1HEmG6IC2*Cbn^;78073+J>QPh8m?)1Zma#C15cpz!q9$Kqx+T1vQeyuI#aBU+9 z1El3+8bc}hRlOu}!>lnhpj&nWy!&x}`0O|rd3GhhAKuD8)FzDqIQ~fIW{;tkl|Gx$ z+Md3iv(BDbJ&^xkoMu{E+DZ^+)N3Dfk1rch{*qRbu$-uO61JPE3BR?S2-^!3kg;+m zDMk+FK+_C@%5qJv*eb;KCi<6Lv^II5?_4eALd|r>k&&mBByL(#N>#PuuIO2H#I45J2 zm&lQ^x$QHA&h5pA3!6=h5QPzf5hGt3Np{bNl>^M3P9W*e#VqcC1rmiwLO?H1BI(PK zB6oOLVAesEjuIqeMZ80P5(qA1>(~nLkFEB? z%4VPArjn`Gyg7yKiDBigg(sB$ExB3t+Z#y@RzJ5^{#IhM@NjPmyt&o_0Cv*e_G$iu zL=7-#7Kuy%2v2a&S%+rBhX_`LK%Fp_Zoj-qyvL{xE84k^Ak4`pR;CtocMHGU(S?Uw z;j|q(RRU<=g0Mlu=G}-rY}SZOAgFf1DY+5*v)fdSq`k9e2&c`h#kNv)ncd!%1Yu6z z@h6%#v08m@%jd>ZQ_Kd-h(7im`^N3*4SeQ8P9u6UZEC6jrqz%wX)LAKskQCIv9$K8 zGep-G9&{~1G5|laOnH3EF8sPyz}+gxF6CtDDciaVpT6g^pXE~3R1r)ZZQuRtR^!Ot zTunKgmRvSRywU2uO409nf-vWPw>ow9)}6w$dwXzHDbBj7ZC4M#-UIA5$1ad>>%38_8L_q)n(sZAf4ew|2<0(2KG~L&{+pk>I0wd z#0D>d?{}L=jewn}9fk9ZUS8t{d^}B%41iCx&>f%eQ*Y|(K_8q7xM5h7W<$9Isfjgo z@8yl+k4n?zd~072gu%$pO(u_3|8v(KywJ<1@Xikj;})>f@KJ}UuYYfW+ z=^KJ%9DC?hI#xvG7u)v;jpo6`H5EdD?K4JKsw<|C*>~Rj6UXGK_u@?qeMgW?7=9h6 zS*etA|F+%2TyKWP{Z^-I^{Q{qoFrb<*npq8-(vk1`j#LWC>~yxJcU$YN!NZMYDV#D z{Sf=FMgNR(7{pJg#fxXx;Wqzyc*rB)6C~s6k6)sr##O?P_Vv)BuKmC_^9DwBg#;~$uDvkTFmeHEIJt(}##Ymk3r>`N9U!;+ zT@55bGC_W9d8(;b5%1_tLSxr{7`S68XhR^kzZD@+sw<)S=*fNGj5Unt3@R#tCP;SB zpMFceXwQE5{((L`p=&>S?5l2bhHpg(bz?FqT;AJlxg$KI`#H>^<`@`G~*%z2ylXwI23->LMIEPo}m()(%TCsr4$?|3RIQ3 zXT3!Anwztkp-h6kA(6HVB6U`j;j0akgeOi9qeWlEYc|c(f}9{0g^$%A-qBMrH<=WV zPmwyky9bUH5i1a>A}Ql2M34lek?e~?_GB;JGIy3|Oe+sT4-v>^673_xUMZw*BURXU tSUIjLD^uP(d}QyNb{BQF2sYQL{eLo>syCenJy-w$002ovPDHLkV1k+@PP_mB literal 0 HcmV?d00001 diff --git a/pages/my/images/xj.png b/pages/my/images/xj.png new file mode 100644 index 0000000000000000000000000000000000000000..3a838b4ed829883492ab5e60370e8958a95b7f51 GIT binary patch literal 3426 zcmds)`8(9z8^=F0#*nQc+Y~cnDSNV|2s5&bU1MKDlkD3=k*%gEgD{p*q8b_urfiKZ z$`(S4jF2f*mO|OaHu}zUegBK+hjYKrbzkQ`@B6xcIj@syZ)+~dcbE?V06`0^367(E z|1MrAC)T*qN;m?F!kHTbv|*_Q&LJra6O7|kuchL*;f`ZsuiqBKEApW4k3Eu4$F=$> z$OnPO8&pxXDo(DJ^#MH;l|gUtz7^hi++;yE144B?_L$#21XLq(=!ith@f_Y9ag3bU z-Vf)o!KSVg;mc21e#^0Q`Z*Hw%r&O|mnfqLyFXu4@fs-t+>v7T@1T6>8wuP1uRD*Z zxh5D+1_b$lQwCz=)u;u_%Bt1`FzTar8pVD@!66Fu^{W_A3Mf^47Yp2hITm-UHg71sniE z@&Z&vh7W+r+_+tIfe#>^nDRMl0s>^^-$iIygMj~lxxD7PG3RyHDolAJMT1JNzk z(O=u9w{LO%IM<0dgJ6c1UecWzi3nikv5S7N=jsUy8r4}lJ!A$U4$M?IiG7`KqKXz5 z-M8n@q@~lKXsOOG%g$5L6$2DL%~X#HfS6=!RW56_g zHTNJq8xW8sU!g{DqcZ(R1{jPk@$2!}9Pqcmx2Tdy))7qJF z4sPv6*R7y4gb*}|YZqie@?I`{RM&lqc!FTYERAPA1X?qseYf?8OOl<<|HxQGtZn2wK$lMJRy zP(v`CEU~FPv6e%g<3k)th@94#+NJ(|5s#c7YKAVwHvi}%)GW`em+4)s(q4=d|956| z#Z31h5bOH7H(CEDd}{wpDG#d)ad|9^{Kw^IL-_UL=xge~4o^8FRShHCiSTq$1H`=& z$9{UpHza9ytIIdN(axixJ?FHpSwY(FK}O(AhMobd&1z}?N&+yxR!7#Ii%$Mhopm(j zAM7e2qU42pb4m8L${K4YTkl15-*rm=mA&_|(Ur3>0B8J@J*KPH^3M~~FHH8|hQI^# z@%A!!sgxn(5wdMw!d45d`>1JeU>+}gZgm!BWO_bNwMmE`W4PbUBv%!zmD}*=&sDy$ zL57FaoNwA6Y&{*~77QDUCVK*I9J z%ud!nrUv!}8k|Z^Cv@1}QI&*UY?)*84?mBA$KFjg?EDRZ*fDNYc3L?vas2953hSzG zR_0#E{?xGX$x~*x*WgirNM%48;q#7aX$M68OR`PZ{sGfqJWjsm1N61oe^ z1zoXkYWt9gj%GG>aDpTMLMK}yoGpnDBjy89+;sz z+P=sGX=Hug3y2Ef`MzZtD8#rIt6w8g7MBR1+RrUjKGZ|~(5|#Xwn!TvQo2RoR{t_S zow%6CvXK=8uw?|RD!uJBj9Dzzv81iN+{W~_(nqPeq-5o>+F5`Y>rCUB@9tIjfFPLg zVNcy0vco(ad9p|Iv<#JcC9a}EKYPYJb|P=35?5QR^b%42xi_s(5H|bt^p(XOF|Age z2T4~3F{e{9M{|s9sB|?&(>cnqkH#TKltv79eO~!1POdrmbiiwYuVXH0?8Bv}*DlUvxYzN_HW6#Yh7iT}HU%xE)Z7H9 zMrXvm{==ds^{@U6$C=TM-rnpG2ycI9xF1x!x%5;amXYEwXL}9$W~+-EHqvvSC4jCQ z9WtcFd;hG_7)aXHV>wWMI6Q8R9_yXM`;BKL{HY{{Q7Q-;-oa z*7u>D7W~{wWy-@e>l@nJ8(G5+_5G-&aaFGV!r#3;Om>{vtho?X zP$=^m2;!D}Hmc4@E~POmOx+a}8ETq!X`@C**jG5-!@ACFadPtEy-+J$59nZH8|7_~ z&0Ld#Zb<>rW79_myAtN(U1SW<)uG|@N%RA@< z+KhNs+_Na*ml=)_YHSu_`Bk?%{qnC}#ZMt}3q$|7Vx^A5CSzvxJnkyE9Bpx(8ouzB zLF_}3sjtpe9(N9}4~S_VY=VrJ`TCurkyIG!_>x{UrB-yx-w9krBp2Tm$BQdw|jeiKNs$h!@-L;GuDIoA|?$ zk$j&x(0lTh{c(2=#p>-vFgZ+ItCSr1o&&k>r&HEWa?sgECNJF?AP|L&9?&^N9m4n6 zvw?%im$# + + + + + + + + + + + + + + + + + + + + + {{ templateInfo.userInfo.walletName }} + + + + + {{ data.user_info[item.key] || 0 }} + + + + + + {{ item.name }} + + + + + + + + + + 个人中心 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/static/css/common.scss b/static/css/common.scss new file mode 100644 index 0000000..5261b9c --- /dev/null +++ b/static/css/common.scss @@ -0,0 +1,48 @@ +.page-box { + min-height: 100vh !important; +} + +.flex { + display: flex; +} + +.flex-1 { + flex: 1; +} + +.flex-row { + flex-direction: row; +} + +.flex-col { + flex-direction: column; +} + +.justify-around { + justify-content: space-around; +} + +.items-center { + align-items: center; +} + +.flex-x-between { + justify-content: space-between; +} + +.flex-x-end { + justify-content: flex-end; +} + +.flex-x-center { + justify-content: center; +} + +.flex-y-center { + align-items: center; +} + +.mx-auto { + margin-left: auto; + margin-right: auto; +} \ No newline at end of file diff --git a/static/css/uni.scss b/static/css/uni.scss new file mode 100644 index 0000000..66a148b --- /dev/null +++ b/static/css/uni.scss @@ -0,0 +1,78 @@ +/** + * 这里是uni-app内置的常用样式变量 + * + * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量 + * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App + * + */ + +/** + * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能 + * + * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件 + */ + +/* 颜色变量 */ + +/* 行为相关颜色 */ +$uni-color-primary: #007aff; +$uni-color-success: #4cd964; +$uni-color-warning: #f0ad4e; +$uni-color-error: #dd524d; + +/* 文字基本颜色 */ +$uni-text-color:#333;//基本色 +$uni-text-color-inverse:#fff;//反色 +$uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息 +$uni-text-color-placeholder: #808080; +$uni-text-color-disable:#c0c0c0; + +/* 背景颜色 */ +$uni-bg-color:#ffffff; +$uni-bg-color-grey:#f8f8f8; +$uni-bg-color-hover:#f1f1f1;//点击状态颜色 +$uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色 + +/* 边框颜色 */ +$uni-border-color:#c8c7cc; + +/* 尺寸变量 */ + +/* 文字尺寸 */ +$uni-font-size-sm:12px; +$uni-font-size-base:14px; +$uni-font-size-lg:16; + +/* 图片尺寸 */ +$uni-img-size-sm:20px; +$uni-img-size-base:26px; +$uni-img-size-lg:40px; + +/* Border Radius */ +$uni-border-radius-sm: 2px; +$uni-border-radius-base: 3px; +$uni-border-radius-lg: 6px; +$uni-border-radius-circle: 50%; + +/* 水平间距 */ +$uni-spacing-row-sm: 5px; +$uni-spacing-row-base: 10px; +$uni-spacing-row-lg: 15px; + +/* 垂直间距 */ +$uni-spacing-col-sm: 4px; +$uni-spacing-col-base: 8px; +$uni-spacing-col-lg: 12px; + +/* 透明度 */ +$uni-opacity-disabled: 0.3; // 组件禁用态的透明度 + +/* 文章场景相关 */ +$uni-color-title: #2C405A; // 文章标题颜色 +$uni-font-size-title:20px; +$uni-color-subtitle: #555555; // 二级标题颜色 +$uni-font-size-subtitle:26px; +$uni-color-paragraph: #3F536E; // 文章段落颜色 +$uni-font-size-paragraph:15px; + +@import '@/uni_modules/uview-ui/theme.scss'; diff --git a/static/h5/jweixin-sdk.js b/static/h5/jweixin-sdk.js new file mode 100644 index 0000000..f05775d --- /dev/null +++ b/static/h5/jweixin-sdk.js @@ -0,0 +1 @@ +!function (e, n) { "function" == typeof define && (define.amd || define.cmd) ? define(function () { return n(e) }) : n(e, !0) }(window, function (o, e) { if (!o.jWeixin) { var n, c = { config: "preVerifyJSAPI", onMenuShareTimeline: "menu:share:timeline", onMenuShareAppMessage: "menu:share:appmessage", onMenuShareQQ: "menu:share:qq", onMenuShareWeibo: "menu:share:weiboApp", onMenuShareQZone: "menu:share:QZone", previewImage: "imagePreview", getLocation: "geoLocation", openProductSpecificView: "openProductViewWithPid", addCard: "batchAddCard", openCard: "batchViewCard", chooseWXPay: "getBrandWCPayRequest", openEnterpriseRedPacket: "getRecevieBizHongBaoRequest", startSearchBeacons: "startMonitoringBeacons", stopSearchBeacons: "stopMonitoringBeacons", onSearchBeacons: "onBeaconsInRange", consumeAndShareCard: "consumedShareCard", openAddress: "editAddress" }, a = function () { var e = {}; for (var n in c) e[c[n]] = n; return e }(), i = o.document, t = i.title, r = navigator.userAgent.toLowerCase(), s = navigator.platform.toLowerCase(), d = !(!s.match("mac") && !s.match("win")), u = -1 != r.indexOf("wxdebugger"), l = -1 != r.indexOf("micromessenger"), p = -1 != r.indexOf("android"), f = -1 != r.indexOf("iphone") || -1 != r.indexOf("ipad"), m = (n = r.match(/micromessenger\/(\d+\.\d+\.\d+)/) || r.match(/micromessenger\/(\d+\.\d+)/)) ? n[1] : "", g = { initStartTime: L(), initEndTime: 0, preVerifyStartTime: 0, preVerifyEndTime: 0 }, h = { version: 1, appId: "", initTime: 0, preVerifyTime: 0, networkType: "", isPreVerifyOk: 1, systemType: f ? 1 : p ? 2 : -1, clientVersion: m, url: encodeURIComponent(location.href) }, v = {}, S = { _completes: [] }, y = { state: 0, data: {} }; O(function () { g.initEndTime = L() }); var I = !1, _ = [], w = { config: function (e) { B("config", v = e); var t = !1 !== v.check; O(function () { if (t) M(c.config, { verifyJsApiList: C(v.jsApiList), verifyOpenTagList: C(v.openTagList) }, function () { S._complete = function (e) { g.preVerifyEndTime = L(), y.state = 1, y.data = e }, S.success = function (e) { h.isPreVerifyOk = 0 }, S.fail = function (e) { S._fail ? S._fail(e) : y.state = -1 }; var t = S._completes; return t.push(function () { !function () { if (!(d || u || v.debug || m < "6.0.2" || h.systemType < 0)) { var i = new Image; h.appId = v.appId, h.initTime = g.initEndTime - g.initStartTime, h.preVerifyTime = g.preVerifyEndTime - g.preVerifyStartTime, w.getNetworkType({ isInnerInvoke: !0, success: function (e) { h.networkType = e.networkType; var n = "https://open.weixin.qq.com/sdk/report?v=" + h.version + "&o=" + h.isPreVerifyOk + "&s=" + h.systemType + "&c=" + h.clientVersion + "&a=" + h.appId + "&n=" + h.networkType + "&i=" + h.initTime + "&p=" + h.preVerifyTime + "&u=" + h.url; i.src = n } }) } }() }), S.complete = function (e) { for (var n = 0, i = t.length; n < i; ++n)t[n](); S._completes = [] }, S }()), g.preVerifyStartTime = L(); else { y.state = 1; for (var e = S._completes, n = 0, i = e.length; n < i; ++n)e[n](); S._completes = [] } }), w.invoke || (w.invoke = function (e, n, i) { o.WeixinJSBridge && WeixinJSBridge.invoke(e, x(n), i) }, w.on = function (e, n) { o.WeixinJSBridge && WeixinJSBridge.on(e, n) }) }, ready: function (e) { 0 != y.state ? e() : (S._completes.push(e), !l && v.debug && e()) }, error: function (e) { m < "6.0.2" || (-1 == y.state ? e(y.data) : S._fail = e) }, checkJsApi: function (e) { M("checkJsApi", { jsApiList: C(e.jsApiList) }, (e._complete = function (e) { if (p) { var n = e.checkResult; n && (e.checkResult = JSON.parse(n)) } e = function (e) { var n = e.checkResult; for (var i in n) { var t = a[i]; t && (n[t] = n[i], delete n[i]) } return e }(e) }, e)) }, onMenuShareTimeline: function (e) { P(c.onMenuShareTimeline, { complete: function () { M("shareTimeline", { title: e.title || t, desc: e.title || t, img_url: e.imgUrl || "", link: e.link || location.href, type: e.type || "link", data_url: e.dataUrl || "" }, e) } }, e) }, onMenuShareAppMessage: function (n) { P(c.onMenuShareAppMessage, { complete: function (e) { "favorite" === e.scene ? M("sendAppMessage", { title: n.title || t, desc: n.desc || "", link: n.link || location.href, img_url: n.imgUrl || "", type: n.type || "link", data_url: n.dataUrl || "" }) : M("sendAppMessage", { title: n.title || t, desc: n.desc || "", link: n.link || location.href, img_url: n.imgUrl || "", type: n.type || "link", data_url: n.dataUrl || "" }, n) } }, n) }, onMenuShareQQ: function (e) { P(c.onMenuShareQQ, { complete: function () { M("shareQQ", { title: e.title || t, desc: e.desc || "", img_url: e.imgUrl || "", link: e.link || location.href }, e) } }, e) }, onMenuShareWeibo: function (e) { P(c.onMenuShareWeibo, { complete: function () { M("shareWeiboApp", { title: e.title || t, desc: e.desc || "", img_url: e.imgUrl || "", link: e.link || location.href }, e) } }, e) }, onMenuShareQZone: function (e) { P(c.onMenuShareQZone, { complete: function () { M("shareQZone", { title: e.title || t, desc: e.desc || "", img_url: e.imgUrl || "", link: e.link || location.href }, e) } }, e) }, updateTimelineShareData: function (e) { M("updateTimelineShareData", { title: e.title, link: e.link, imgUrl: e.imgUrl }, e) }, updateAppMessageShareData: function (e) { M("updateAppMessageShareData", { title: e.title, desc: e.desc, link: e.link, imgUrl: e.imgUrl }, e) }, startRecord: function (e) { M("startRecord", {}, e) }, stopRecord: function (e) { M("stopRecord", {}, e) }, onVoiceRecordEnd: function (e) { P("onVoiceRecordEnd", e) }, playVoice: function (e) { M("playVoice", { localId: e.localId }, e) }, pauseVoice: function (e) { M("pauseVoice", { localId: e.localId }, e) }, stopVoice: function (e) { M("stopVoice", { localId: e.localId }, e) }, onVoicePlayEnd: function (e) { P("onVoicePlayEnd", e) }, uploadVoice: function (e) { M("uploadVoice", { localId: e.localId, isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 }, e) }, downloadVoice: function (e) { M("downloadVoice", { serverId: e.serverId, isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 }, e) }, translateVoice: function (e) { M("translateVoice", { localId: e.localId, isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 }, e) }, chooseImage: function (e) { M("chooseImage", { scene: "1|2", count: e.count || 9, sizeType: e.sizeType || ["original", "compressed"], sourceType: e.sourceType || ["album", "camera"] }, (e._complete = function (e) { if (p) { var n = e.localIds; try { n && (e.localIds = JSON.parse(n)) } catch (e) { } } }, e)) }, getLocation: function (e) { }, previewImage: function (e) { M(c.previewImage, { current: e.current, urls: e.urls }, e) }, uploadImage: function (e) { M("uploadImage", { localId: e.localId, isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 }, e) }, downloadImage: function (e) { M("downloadImage", { serverId: e.serverId, isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 }, e) }, getLocalImgData: function (e) { !1 === I ? (I = !0, M("getLocalImgData", { localId: e.localId }, (e._complete = function (e) { if (I = !1, 0 < _.length) { var n = _.shift(); wx.getLocalImgData(n) } }, e))) : _.push(e) }, getNetworkType: function (e) { M("getNetworkType", {}, (e._complete = function (e) { e = function (e) { var n = e.errMsg; e.errMsg = "getNetworkType:ok"; var i = e.subtype; if (delete e.subtype, i) e.networkType = i; else { var t = n.indexOf(":"), o = n.substring(t + 1); switch (o) { case "wifi": case "edge": case "wwan": e.networkType = o; break; default: e.errMsg = "getNetworkType:fail" } } return e }(e) }, e)) }, openLocation: function (e) { M("openLocation", { latitude: e.latitude, longitude: e.longitude, name: e.name || "", address: e.address || "", scale: e.scale || 28, infoUrl: e.infoUrl || "" }, e) }, getLocation: function (e) { M(c.getLocation, { type: (e = e || {}).type || "wgs84" }, (e._complete = function (e) { delete e.type }, e)) }, hideOptionMenu: function (e) { M("hideOptionMenu", {}, e) }, showOptionMenu: function (e) { M("showOptionMenu", {}, e) }, closeWindow: function (e) { M("closeWindow", {}, e = e || {}) }, hideMenuItems: function (e) { M("hideMenuItems", { menuList: e.menuList }, e) }, showMenuItems: function (e) { M("showMenuItems", { menuList: e.menuList }, e) }, hideAllNonBaseMenuItem: function (e) { M("hideAllNonBaseMenuItem", {}, e) }, showAllNonBaseMenuItem: function (e) { M("showAllNonBaseMenuItem", {}, e) }, scanQRCode: function (e) { M("scanQRCode", { needResult: (e = e || {}).needResult || 0, scanType: e.scanType || ["qrCode", "barCode"] }, (e._complete = function (e) { if (f) { var n = e.resultStr; if (n) { var i = JSON.parse(n); e.resultStr = i && i.scan_code && i.scan_code.scan_result } } }, e)) }, openAddress: function (e) { M(c.openAddress, {}, (e._complete = function (e) { e = function (e) { return e.postalCode = e.addressPostalCode, delete e.addressPostalCode, e.provinceName = e.proviceFirstStageName, delete e.proviceFirstStageName, e.cityName = e.addressCitySecondStageName, delete e.addressCitySecondStageName, e.countryName = e.addressCountiesThirdStageName, delete e.addressCountiesThirdStageName, e.detailInfo = e.addressDetailInfo, delete e.addressDetailInfo, e }(e) }, e)) }, openProductSpecificView: function (e) { M(c.openProductSpecificView, { pid: e.productId, view_type: e.viewType || 0, ext_info: e.extInfo }, e) }, addCard: function (e) { for (var n = e.cardList, i = [], t = 0, o = n.length; t < o; ++t) { var r = n[t], a = { card_id: r.cardId, card_ext: r.cardExt }; i.push(a) } M(c.addCard, { card_list: i }, (e._complete = function (e) { var n = e.card_list; if (n) { for (var i = 0, t = (n = JSON.parse(n)).length; i < t; ++i) { var o = n[i]; o.cardId = o.card_id, o.cardExt = o.card_ext, o.isSuccess = !!o.is_succ, delete o.card_id, delete o.card_ext, delete o.is_succ } e.cardList = n, delete e.card_list } }, e)) }, chooseCard: function (e) { M("chooseCard", { app_id: v.appId, location_id: e.shopId || "", sign_type: e.signType || "SHA1", card_id: e.cardId || "", card_type: e.cardType || "", card_sign: e.cardSign, time_stamp: e.timestamp + "", nonce_str: e.nonceStr }, (e._complete = function (e) { e.cardList = e.choose_card_info, delete e.choose_card_info }, e)) }, openCard: function (e) { for (var n = e.cardList, i = [], t = 0, o = n.length; t < o; ++t) { var r = n[t], a = { card_id: r.cardId, code: r.code }; i.push(a) } M(c.openCard, { card_list: i }, e) }, consumeAndShareCard: function (e) { M(c.consumeAndShareCard, { consumedCardId: e.cardId, consumedCode: e.code }, e) }, chooseWXPay: function (e) { M(c.chooseWXPay, V(e), e) }, openEnterpriseRedPacket: function (e) { M(c.openEnterpriseRedPacket, V(e), e) }, startSearchBeacons: function (e) { M(c.startSearchBeacons, { ticket: e.ticket }, e) }, stopSearchBeacons: function (e) { M(c.stopSearchBeacons, {}, e) }, onSearchBeacons: function (e) { P(c.onSearchBeacons, e) }, openEnterpriseChat: function (e) { M("openEnterpriseChat", { useridlist: e.userIds, chatname: e.groupName }, e) }, launchMiniProgram: function (e) { M("launchMiniProgram", { targetAppId: e.targetAppId, path: function (e) { if ("string" == typeof e && 0 < e.length) { var n = e.split("?")[0], i = e.split("?")[1]; return n += ".html", void 0 !== i ? n + "?" + i : n } }(e.path), envVersion: e.envVersion }, e) }, openBusinessView: function (e) { M("openBusinessView", { businessType: e.businessType, queryString: e.queryString || "", envVersion: e.envVersion }, (e._complete = function (n) { if (p) { var e = n.extraData; if (e) try { n.extraData = JSON.parse(e) } catch (e) { n.extraData = {} } } }, e)) }, miniProgram: { navigateBack: function (e) { e = e || {}, O(function () { M("invokeMiniProgramAPI", { name: "navigateBack", arg: { delta: e.delta || 1 } }, e) }) }, navigateTo: function (e) { O(function () { M("invokeMiniProgramAPI", { name: "navigateTo", arg: { url: e.url } }, e) }) }, redirectTo: function (e) { O(function () { M("invokeMiniProgramAPI", { name: "redirectTo", arg: { url: e.url } }, e) }) }, switchTab: function (e) { O(function () { M("invokeMiniProgramAPI", { name: "switchTab", arg: { url: e.url } }, e) }) }, reLaunch: function (e) { O(function () { M("invokeMiniProgramAPI", { name: "reLaunch", arg: { url: e.url } }, e) }) }, postMessage: function (e) { O(function () { M("invokeMiniProgramAPI", { name: "postMessage", arg: e.data || {} }, e) }) }, getEnv: function (e) { O(function () { e({ miniprogram: "miniprogram" === o.__wxjs_environment }) }) } } }, T = 1, k = {}; return i.addEventListener("error", function (e) { if (!p) { var n = e.target, i = n.tagName, t = n.src; if ("IMG" == i || "VIDEO" == i || "AUDIO" == i || "SOURCE" == i) if (-1 != t.indexOf("wxlocalresource://")) { e.preventDefault(), e.stopPropagation(); var o = n["wx-id"]; if (o || (o = T++, n["wx-id"] = o), k[o]) return; k[o] = !0, wx.ready(function () { wx.getLocalImgData({ localId: t, success: function (e) { n.src = e.localData } }) }) } } }, !0), i.addEventListener("load", function (e) { if (!p) { var n = e.target, i = n.tagName; n.src; if ("IMG" == i || "VIDEO" == i || "AUDIO" == i || "SOURCE" == i) { var t = n["wx-id"]; t && (k[t] = !1) } } }, !0), e && (o.wx = o.jWeixin = w), w } function M(n, e, i) { o.WeixinJSBridge ? WeixinJSBridge.invoke(n, x(e), function (e) { A(n, e, i) }) : B(n, i) } function P(n, i, t) { o.WeixinJSBridge ? WeixinJSBridge.on(n, function (e) { t && t.trigger && t.trigger(e), A(n, e, i) }) : B(n, t || i) } function x(e) { return (e = e || {}).appId = v.appId, e.verifyAppId = v.appId, e.verifySignType = "sha1", e.verifyTimestamp = v.timestamp + "", e.verifyNonceStr = v.nonceStr, e.verifySignature = v.signature, e } function V(e) { return { timeStamp: e.timestamp + "", nonceStr: e.nonceStr, package: e.package, paySign: e.paySign, signType: e.signType || "SHA1" } } function A(e, n, i) { "openEnterpriseChat" != e && "openBusinessView" !== e || (n.errCode = n.err_code), delete n.err_code, delete n.err_desc, delete n.err_detail; var t = n.errMsg; t || (t = n.err_msg, delete n.err_msg, t = function (e, n) { var i = e, t = a[i]; t && (i = t); var o = "ok"; if (n) { var r = n.indexOf(":"); "confirm" == (o = n.substring(r + 1)) && (o = "ok"), "failed" == o && (o = "fail"), -1 != o.indexOf("failed_") && (o = o.substring(7)), -1 != o.indexOf("fail_") && (o = o.substring(5)), "access denied" != (o = (o = o.replace(/_/g, " ")).toLowerCase()) && "no permission to execute" != o || (o = "permission denied"), "config" == i && "function not exist" == o && (o = "ok"), "" == o && (o = "fail") } return n = i + ":" + o }(e, t), n.errMsg = t), (i = i || {})._complete && (i._complete(n), delete i._complete), t = n.errMsg || "", v.debug && !i.isInnerInvoke && alert(JSON.stringify(n)); var o = t.indexOf(":"); switch (t.substring(o + 1)) { case "ok": i.success && i.success(n); break; case "cancel": i.cancel && i.cancel(n); break; default: i.fail && i.fail(n) }i.complete && i.complete(n) } function C(e) { if (e) { for (var n = 0, i = e.length; n < i; ++n) { var t = e[n], o = c[t]; o && (e[n] = o) } return e } } function B(e, n) { if (!(!v.debug || n && n.isInnerInvoke)) { var i = a[e]; i && (e = i), n && n._complete && delete n._complete, console.log('"' + e + '",', n || "") } } function L() { return (new Date).getTime() } function O(e) { l && (o.WeixinJSBridge ? e() : i.addEventListener && i.addEventListener("WeixinJSBridgeReady", e, !1)) } }); \ No newline at end of file diff --git a/store/index.js b/store/index.js new file mode 100644 index 0000000..bf83ce4 --- /dev/null +++ b/store/index.js @@ -0,0 +1,31 @@ +import Vue from "vue"; +import Vuex from "vuex"; + +Vue.use(Vuex); + +const store = new Vuex.Store({ + state: { + $Gimage: {}, + $GstoreDetail: {}, + // 购物车数量 + cartNum: 0, + }, + getters: { + cartNum: (state) => { + return state.cartNum || 0; + }, + }, + mutations: { + SET: (state, { key, val }) => { + state[key] = val + }, + }, + actions: { + setData({ commit }, { key, val }) { + commit('SET', { key, val }) + } + }, + modules: {}, +}); + +export default store; diff --git a/subPackages/inPersonToPay/compontents/coupons.vue b/subPackages/inPersonToPay/compontents/coupons.vue new file mode 100644 index 0000000..cc72555 --- /dev/null +++ b/subPackages/inPersonToPay/compontents/coupons.vue @@ -0,0 +1,455 @@ + + + + + diff --git a/subPackages/inPersonToPay/compontents/twoGoods.vue b/subPackages/inPersonToPay/compontents/twoGoods.vue new file mode 100644 index 0000000..90d0b08 --- /dev/null +++ b/subPackages/inPersonToPay/compontents/twoGoods.vue @@ -0,0 +1,212 @@ + + + + + diff --git a/subPackages/inPersonToPay/index/index.vue b/subPackages/inPersonToPay/index/index.vue new file mode 100644 index 0000000..f85f736 --- /dev/null +++ b/subPackages/inPersonToPay/index/index.vue @@ -0,0 +1,662 @@ + + + + + + + \ No newline at end of file diff --git a/subPackages/inPersonToPay/result/index.vue b/subPackages/inPersonToPay/result/index.vue new file mode 100644 index 0000000..5a1a84f --- /dev/null +++ b/subPackages/inPersonToPay/result/index.vue @@ -0,0 +1,174 @@ + + + + + \ No newline at end of file diff --git a/subPackages/login/forgotPassword/index.vue b/subPackages/login/forgotPassword/index.vue new file mode 100644 index 0000000..9ee81b6 --- /dev/null +++ b/subPackages/login/forgotPassword/index.vue @@ -0,0 +1,38 @@ + + + + + \ No newline at end of file diff --git a/subPackages/login/forgotPassword/nuxt.vue b/subPackages/login/forgotPassword/nuxt.vue new file mode 100644 index 0000000..dd8d177 --- /dev/null +++ b/subPackages/login/forgotPassword/nuxt.vue @@ -0,0 +1,321 @@ + + + + + diff --git a/subPackages/login/login/index.vue b/subPackages/login/login/index.vue new file mode 100644 index 0000000..f90df75 --- /dev/null +++ b/subPackages/login/login/index.vue @@ -0,0 +1,27 @@ + + + + + \ No newline at end of file diff --git a/subPackages/login/reg/index.vue b/subPackages/login/reg/index.vue new file mode 100644 index 0000000..fc0c9ec --- /dev/null +++ b/subPackages/login/reg/index.vue @@ -0,0 +1,174 @@ + + + + + \ No newline at end of file diff --git a/subPackages/login/reg/reset.vue b/subPackages/login/reg/reset.vue new file mode 100644 index 0000000..7c70cf0 --- /dev/null +++ b/subPackages/login/reg/reset.vue @@ -0,0 +1,161 @@ + + + + + \ No newline at end of file diff --git a/uni.scss b/uni.scss new file mode 100644 index 0000000..66a148b --- /dev/null +++ b/uni.scss @@ -0,0 +1,78 @@ +/** + * 这里是uni-app内置的常用样式变量 + * + * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量 + * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App + * + */ + +/** + * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能 + * + * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件 + */ + +/* 颜色变量 */ + +/* 行为相关颜色 */ +$uni-color-primary: #007aff; +$uni-color-success: #4cd964; +$uni-color-warning: #f0ad4e; +$uni-color-error: #dd524d; + +/* 文字基本颜色 */ +$uni-text-color:#333;//基本色 +$uni-text-color-inverse:#fff;//反色 +$uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息 +$uni-text-color-placeholder: #808080; +$uni-text-color-disable:#c0c0c0; + +/* 背景颜色 */ +$uni-bg-color:#ffffff; +$uni-bg-color-grey:#f8f8f8; +$uni-bg-color-hover:#f1f1f1;//点击状态颜色 +$uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色 + +/* 边框颜色 */ +$uni-border-color:#c8c7cc; + +/* 尺寸变量 */ + +/* 文字尺寸 */ +$uni-font-size-sm:12px; +$uni-font-size-base:14px; +$uni-font-size-lg:16; + +/* 图片尺寸 */ +$uni-img-size-sm:20px; +$uni-img-size-base:26px; +$uni-img-size-lg:40px; + +/* Border Radius */ +$uni-border-radius-sm: 2px; +$uni-border-radius-base: 3px; +$uni-border-radius-lg: 6px; +$uni-border-radius-circle: 50%; + +/* 水平间距 */ +$uni-spacing-row-sm: 5px; +$uni-spacing-row-base: 10px; +$uni-spacing-row-lg: 15px; + +/* 垂直间距 */ +$uni-spacing-col-sm: 4px; +$uni-spacing-col-base: 8px; +$uni-spacing-col-lg: 12px; + +/* 透明度 */ +$uni-opacity-disabled: 0.3; // 组件禁用态的透明度 + +/* 文章场景相关 */ +$uni-color-title: #2C405A; // 文章标题颜色 +$uni-font-size-title:20px; +$uni-color-subtitle: #555555; // 二级标题颜色 +$uni-font-size-subtitle:26px; +$uni-color-paragraph: #3F536E; // 文章段落颜色 +$uni-font-size-paragraph:15px; + +@import '@/uni_modules/uview-ui/theme.scss'; diff --git a/uni_modules/alipayjsapi/alipayjsapi.js b/uni_modules/alipayjsapi/alipayjsapi.js new file mode 100644 index 0000000..a736588 --- /dev/null +++ b/uni_modules/alipayjsapi/alipayjsapi.js @@ -0,0 +1,4183 @@ +/** + * AlipayJSAPI + * @author wangyou.ly + * @version 3.1.1 + * @todo + **/ +;(function (self) { + + function PromisePolyfillImpl() { + /*! + * @overview es6-promise - a tiny implementation of Promises/A+. + * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) + * @license Licensed under MIT license + * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE + * @version 4.1.0+f9a5575b + */ + +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global.ES6Promise = factory()); +}(this, (function () { 'use strict'; + +function objectOrFunction(x) { + return typeof x === 'function' || typeof x === 'object' && x !== null; +} + +function isFunction(x) { + return typeof x === 'function'; +} + +var _isArray = undefined; +if (!Array.isArray) { + _isArray = function (x) { + return Object.prototype.toString.call(x) === '[object Array]'; + }; +} else { + _isArray = Array.isArray; +} + +var isArray = _isArray; + +var len = 0; +var vertxNext = undefined; +var customSchedulerFn = undefined; + +var asap = function asap(callback, arg) { + queue[len] = callback; + queue[len + 1] = arg; + len += 2; + if (len === 2) { + // If len is 2, that means that we need to schedule an async flush. + // If additional callbacks are queued before the queue is flushed, they + // will be processed by this flush that we are scheduling. + if (customSchedulerFn) { + customSchedulerFn(flush); + } else { + scheduleFlush(); + } + } +}; + +function setScheduler(scheduleFn) { + customSchedulerFn = scheduleFn; +} + +function setAsap(asapFn) { + asap = asapFn; +} + +var browserWindow = typeof window !== 'undefined' ? window : undefined; +var browserGlobal = browserWindow || {}; +var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; +var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; + +// test for web worker but not in IE10 +var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; + +// node +function useNextTick() { + // node version 0.10.x displays a deprecation warning when nextTick is used recursively + // see https://github.com/cujojs/when/issues/410 for details + return function () { + return process.nextTick(flush); + }; +} + +// vertx +function useVertxTimer() { + if (typeof vertxNext !== 'undefined') { + return function () { + vertxNext(flush); + }; + } + + return useSetTimeout(); +} + +function useMutationObserver() { + var iterations = 0; + var observer = new BrowserMutationObserver(flush); + var node = document.createTextNode(''); + observer.observe(node, { characterData: true }); + + return function () { + node.data = iterations = ++iterations % 2; + }; +} + +// web worker +function useMessageChannel() { + var channel = new MessageChannel(); + channel.port1.onmessage = flush; + return function () { + return channel.port2.postMessage(0); + }; +} + +function useSetTimeout() { + // Store setTimeout reference so es6-promise will be unaffected by + // other code modifying setTimeout (like sinon.useFakeTimers()) + var globalSetTimeout = setTimeout; + return function () { + return globalSetTimeout(flush, 1); + }; +} + +var queue = new Array(1000); +function flush() { + for (var i = 0; i < len; i += 2) { + var callback = queue[i]; + var arg = queue[i + 1]; + + callback(arg); + + queue[i] = undefined; + queue[i + 1] = undefined; + } + + len = 0; +} + +function attemptVertx() { + try { + var r = require; + var vertx = r('vertx'); + vertxNext = vertx.runOnLoop || vertx.runOnContext; + return useVertxTimer(); + } catch (e) { + return useSetTimeout(); + } +} + +var scheduleFlush = undefined; +// Decide what async method to use to triggering processing of queued callbacks: +if (isNode) { + scheduleFlush = useNextTick(); +} else if (BrowserMutationObserver) { + scheduleFlush = useMutationObserver(); +} else if (isWorker) { + scheduleFlush = useMessageChannel(); +} else if (browserWindow === undefined && typeof require === 'function') { + scheduleFlush = attemptVertx(); +} else { + scheduleFlush = useSetTimeout(); +} + +function then(onFulfillment, onRejection) { + var _arguments = arguments; + + var parent = this; + + var child = new this.constructor(noop); + + if (child[PROMISE_ID] === undefined) { + makePromise(child); + } + + var _state = parent._state; + + if (_state) { + (function () { + var callback = _arguments[_state - 1]; + asap(function () { + return invokeCallback(_state, child, callback, parent._result); + }); + })(); + } else { + subscribe(parent, child, onFulfillment, onRejection); + } + + return child; +} + +/** + `Promise.resolve` returns a promise that will become resolved with the + passed `value`. It is shorthand for the following: + + ```javascript + let promise = new Promise(function(resolve, reject){ + resolve(1); + }); + + promise.then(function(value){ + // value === 1 + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + let promise = Promise.resolve(1); + + promise.then(function(value){ + // value === 1 + }); + ``` + + @method resolve + @static + @param {Any} value value that the returned promise will be resolved with + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` +*/ +function resolve(object) { + /*jshint validthis:true */ + var Constructor = this; + + if (object && typeof object === 'object' && object.constructor === Constructor) { + return object; + } + + var promise = new Constructor(noop); + _resolve(promise, object); + return promise; +} + +var PROMISE_ID = Math.random().toString(36).substring(16); + +function noop() {} + +var PENDING = void 0; +var FULFILLED = 1; +var REJECTED = 2; + +var GET_THEN_ERROR = new ErrorObject(); + +function selfFulfillment() { + return new TypeError("You cannot resolve a promise with itself"); +} + +function cannotReturnOwn() { + return new TypeError('A promises callback cannot return that same promise.'); +} + +function getThen(promise) { + try { + return promise.then; + } catch (error) { + GET_THEN_ERROR.error = error; + return GET_THEN_ERROR; + } +} + +function tryThen(then, value, fulfillmentHandler, rejectionHandler) { + try { + then.call(value, fulfillmentHandler, rejectionHandler); + } catch (e) { + return e; + } +} + +function handleForeignThenable(promise, thenable, then) { + asap(function (promise) { + var sealed = false; + var error = tryThen(then, thenable, function (value) { + if (sealed) { + return; + } + sealed = true; + if (thenable !== value) { + _resolve(promise, value); + } else { + fulfill(promise, value); + } + }, function (reason) { + if (sealed) { + return; + } + sealed = true; + + _reject(promise, reason); + }, 'Settle: ' + (promise._label || ' unknown promise')); + + if (!sealed && error) { + sealed = true; + _reject(promise, error); + } + }, promise); +} + +function handleOwnThenable(promise, thenable) { + if (thenable._state === FULFILLED) { + fulfill(promise, thenable._result); + } else if (thenable._state === REJECTED) { + _reject(promise, thenable._result); + } else { + subscribe(thenable, undefined, function (value) { + return _resolve(promise, value); + }, function (reason) { + return _reject(promise, reason); + }); + } +} + +function handleMaybeThenable(promise, maybeThenable, then$) { + if (maybeThenable.constructor === promise.constructor && then$ === then && maybeThenable.constructor.resolve === resolve) { + handleOwnThenable(promise, maybeThenable); + } else { + if (then$ === GET_THEN_ERROR) { + _reject(promise, GET_THEN_ERROR.error); + GET_THEN_ERROR.error = null; + } else if (then$ === undefined) { + fulfill(promise, maybeThenable); + } else if (isFunction(then$)) { + handleForeignThenable(promise, maybeThenable, then$); + } else { + fulfill(promise, maybeThenable); + } + } +} + +function _resolve(promise, value) { + if (promise === value) { + _reject(promise, selfFulfillment()); + } else if (objectOrFunction(value)) { + handleMaybeThenable(promise, value, getThen(value)); + } else { + fulfill(promise, value); + } +} + +function publishRejection(promise) { + if (promise._onerror) { + promise._onerror(promise._result); + } + + publish(promise); +} + +function fulfill(promise, value) { + if (promise._state !== PENDING) { + return; + } + + promise._result = value; + promise._state = FULFILLED; + + if (promise._subscribers.length !== 0) { + asap(publish, promise); + } +} + +function _reject(promise, reason) { + if (promise._state !== PENDING) { + return; + } + promise._state = REJECTED; + promise._result = reason; + + asap(publishRejection, promise); +} + +function subscribe(parent, child, onFulfillment, onRejection) { + var _subscribers = parent._subscribers; + var length = _subscribers.length; + + parent._onerror = null; + + _subscribers[length] = child; + _subscribers[length + FULFILLED] = onFulfillment; + _subscribers[length + REJECTED] = onRejection; + + if (length === 0 && parent._state) { + asap(publish, parent); + } +} + +function publish(promise) { + var subscribers = promise._subscribers; + var settled = promise._state; + + if (subscribers.length === 0) { + return; + } + + var child = undefined, + callback = undefined, + detail = promise._result; + + for (var i = 0; i < subscribers.length; i += 3) { + child = subscribers[i]; + callback = subscribers[i + settled]; + + if (child) { + invokeCallback(settled, child, callback, detail); + } else { + callback(detail); + } + } + + promise._subscribers.length = 0; +} + +function ErrorObject() { + this.error = null; +} + +var TRY_CATCH_ERROR = new ErrorObject(); + +function tryCatch(callback, detail) { + try { + return callback(detail); + } catch (e) { + TRY_CATCH_ERROR.error = e; + return TRY_CATCH_ERROR; + } +} + +function invokeCallback(settled, promise, callback, detail) { + var hasCallback = isFunction(callback), + value = undefined, + error = undefined, + succeeded = undefined, + failed = undefined; + + if (hasCallback) { + value = tryCatch(callback, detail); + + if (value === TRY_CATCH_ERROR) { + failed = true; + error = value.error; + value.error = null; + } else { + succeeded = true; + } + + if (promise === value) { + _reject(promise, cannotReturnOwn()); + return; + } + } else { + value = detail; + succeeded = true; + } + + if (promise._state !== PENDING) { + // noop + } else if (hasCallback && succeeded) { + _resolve(promise, value); + } else if (failed) { + _reject(promise, error); + } else if (settled === FULFILLED) { + fulfill(promise, value); + } else if (settled === REJECTED) { + _reject(promise, value); + } +} + +function initializePromise(promise, resolver) { + try { + resolver(function resolvePromise(value) { + _resolve(promise, value); + }, function rejectPromise(reason) { + _reject(promise, reason); + }); + } catch (e) { + _reject(promise, e); + } +} + +var id = 0; +function nextId() { + return id++; +} + +function makePromise(promise) { + promise[PROMISE_ID] = id++; + promise._state = undefined; + promise._result = undefined; + promise._subscribers = []; +} + +function Enumerator(Constructor, input) { + this._instanceConstructor = Constructor; + this.promise = new Constructor(noop); + + if (!this.promise[PROMISE_ID]) { + makePromise(this.promise); + } + + if (isArray(input)) { + this._input = input; + this.length = input.length; + this._remaining = input.length; + + this._result = new Array(this.length); + + if (this.length === 0) { + fulfill(this.promise, this._result); + } else { + this.length = this.length || 0; + this._enumerate(); + if (this._remaining === 0) { + fulfill(this.promise, this._result); + } + } + } else { + _reject(this.promise, validationError()); + } +} + +function validationError() { + return new Error('Array Methods must be provided an Array'); +}; + +Enumerator.prototype._enumerate = function () { + var length = this.length; + var _input = this._input; + + for (var i = 0; this._state === PENDING && i < length; i++) { + this._eachEntry(_input[i], i); + } +}; + +Enumerator.prototype._eachEntry = function (entry, i) { + var c = this._instanceConstructor; + var resolve$ = c.resolve; + + if (resolve$ === resolve) { + var _then = getThen(entry); + + if (_then === then && entry._state !== PENDING) { + this._settledAt(entry._state, i, entry._result); + } else if (typeof _then !== 'function') { + this._remaining--; + this._result[i] = entry; + } else if (c === Promise) { + var promise = new c(noop); + handleMaybeThenable(promise, entry, _then); + this._willSettleAt(promise, i); + } else { + this._willSettleAt(new c(function (resolve$) { + return resolve$(entry); + }), i); + } + } else { + this._willSettleAt(resolve$(entry), i); + } +}; + +Enumerator.prototype._settledAt = function (state, i, value) { + var promise = this.promise; + + if (promise._state === PENDING) { + this._remaining--; + + if (state === REJECTED) { + _reject(promise, value); + } else { + this._result[i] = value; + } + } + + if (this._remaining === 0) { + fulfill(promise, this._result); + } +}; + +Enumerator.prototype._willSettleAt = function (promise, i) { + var enumerator = this; + + subscribe(promise, undefined, function (value) { + return enumerator._settledAt(FULFILLED, i, value); + }, function (reason) { + return enumerator._settledAt(REJECTED, i, reason); + }); +}; + +/** + `Promise.all` accepts an array of promises, and returns a new promise which + is fulfilled with an array of fulfillment values for the passed promises, or + rejected with the reason of the first passed promise to be rejected. It casts all + elements of the passed iterable to promises as it runs this algorithm. + + Example: + + ```javascript + let promise1 = resolve(1); + let promise2 = resolve(2); + let promise3 = resolve(3); + let promises = [ promise1, promise2, promise3 ]; + + Promise.all(promises).then(function(array){ + // The array here would be [ 1, 2, 3 ]; + }); + ``` + + If any of the `promises` given to `all` are rejected, the first promise + that is rejected will be given as an argument to the returned promises's + rejection handler. For example: + + Example: + + ```javascript + let promise1 = resolve(1); + let promise2 = reject(new Error("2")); + let promise3 = reject(new Error("3")); + let promises = [ promise1, promise2, promise3 ]; + + Promise.all(promises).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(error) { + // error.message === "2" + }); + ``` + + @method all + @static + @param {Array} entries array of promises + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when all `promises` have been + fulfilled, or rejected if any of them become rejected. + @static +*/ +function all(entries) { + return new Enumerator(this, entries).promise; +} + +/** + `Promise.race` returns a new promise which is settled in the same way as the + first passed promise to settle. + + Example: + + ```javascript + let promise1 = new Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + let promise2 = new Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 2'); + }, 100); + }); + + Promise.race([promise1, promise2]).then(function(result){ + // result === 'promise 2' because it was resolved before promise1 + // was resolved. + }); + ``` + + `Promise.race` is deterministic in that only the state of the first + settled promise matters. For example, even if other promises given to the + `promises` array argument are resolved, but the first settled promise has + become rejected before the other promises became fulfilled, the returned + promise will become rejected: + + ```javascript + let promise1 = new Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + let promise2 = new Promise(function(resolve, reject){ + setTimeout(function(){ + reject(new Error('promise 2')); + }, 100); + }); + + Promise.race([promise1, promise2]).then(function(result){ + // Code here never runs + }, function(reason){ + // reason.message === 'promise 2' because promise 2 became rejected before + // promise 1 became fulfilled + }); + ``` + + An example real-world use case is implementing timeouts: + + ```javascript + Promise.race([ajax('foo.json'), timeout(5000)]) + ``` + + @method race + @static + @param {Array} promises array of promises to observe + Useful for tooling. + @return {Promise} a promise which settles in the same way as the first passed + promise to settle. +*/ +function race(entries) { + /*jshint validthis:true */ + var Constructor = this; + + if (!isArray(entries)) { + return new Constructor(function (_, reject) { + return reject(new TypeError('You must pass an array to race.')); + }); + } else { + return new Constructor(function (resolve, reject) { + var length = entries.length; + for (var i = 0; i < length; i++) { + Constructor.resolve(entries[i]).then(resolve, reject); + } + }); + } +} + +/** + `Promise.reject` returns a promise rejected with the passed `reason`. + It is shorthand for the following: + + ```javascript + let promise = new Promise(function(resolve, reject){ + reject(new Error('WHOOPS')); + }); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + let promise = Promise.reject(new Error('WHOOPS')); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + @method reject + @static + @param {Any} reason value that the returned promise will be rejected with. + Useful for tooling. + @return {Promise} a promise rejected with the given `reason`. +*/ +function reject(reason) { + /*jshint validthis:true */ + var Constructor = this; + var promise = new Constructor(noop); + _reject(promise, reason); + return promise; +} + +function needsResolver() { + throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); +} + +function needsNew() { + throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); +} + +/** + Promise objects represent the eventual result of an asynchronous operation. The + primary way of interacting with a promise is through its `then` method, which + registers callbacks to receive either a promise's eventual value or the reason + why the promise cannot be fulfilled. + + Terminology + ----------- + + - `promise` is an object or function with a `then` method whose behavior conforms to this specification. + - `thenable` is an object or function that defines a `then` method. + - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). + - `exception` is a value that is thrown using the throw statement. + - `reason` is a value that indicates why a promise was rejected. + - `settled` the final resting state of a promise, fulfilled or rejected. + + A promise can be in one of three states: pending, fulfilled, or rejected. + + Promises that are fulfilled have a fulfillment value and are in the fulfilled + state. Promises that are rejected have a rejection reason and are in the + rejected state. A fulfillment value is never a thenable. + + Promises can also be said to *resolve* a value. If this value is also a + promise, then the original promise's settled state will match the value's + settled state. So a promise that *resolves* a promise that rejects will + itself reject, and a promise that *resolves* a promise that fulfills will + itself fulfill. + + + Basic Usage: + ------------ + + ```js + let promise = new Promise(function(resolve, reject) { + // on success + resolve(value); + + // on failure + reject(reason); + }); + + promise.then(function(value) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Advanced Usage: + --------------- + + Promises shine when abstracting away asynchronous interactions such as + `XMLHttpRequest`s. + + ```js + function getJSON(url) { + return new Promise(function(resolve, reject){ + let xhr = new XMLHttpRequest(); + + xhr.open('GET', url); + xhr.onreadystatechange = handler; + xhr.responseType = 'json'; + xhr.setRequestHeader('Accept', 'application/json'); + xhr.send(); + + function handler() { + if (this.readyState === this.DONE) { + if (this.status === 200) { + resolve(this.response); + } else { + reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); + } + } + }; + }); + } + + getJSON('/posts.json').then(function(json) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Unlike callbacks, promises are great composable primitives. + + ```js + Promise.all([ + getJSON('/posts'), + getJSON('/comments') + ]).then(function(values){ + values[0] // => postsJSON + values[1] // => commentsJSON + + return values; + }); + ``` + + @class Promise + @param {function} resolver + Useful for tooling. + @constructor +*/ +function Promise(resolver) { + this[PROMISE_ID] = nextId(); + this._result = this._state = undefined; + this._subscribers = []; + + if (noop !== resolver) { + typeof resolver !== 'function' && needsResolver(); + this instanceof Promise ? initializePromise(this, resolver) : needsNew(); + } +} + +Promise.all = all; +Promise.race = race; +Promise.resolve = resolve; +Promise.reject = reject; +Promise._setScheduler = setScheduler; +Promise._setAsap = setAsap; +Promise._asap = asap; + +Promise.prototype = { + constructor: Promise, + + /** + The primary way of interacting with a promise is through its `then` method, + which registers callbacks to receive either a promise's eventual value or the + reason why the promise cannot be fulfilled. + + ```js + findUser().then(function(user){ + // user is available + }, function(reason){ + // user is unavailable, and you are given the reason why + }); + ``` + + Chaining + -------- + + The return value of `then` is itself a promise. This second, 'downstream' + promise is resolved with the return value of the first promise's fulfillment + or rejection handler, or rejected if the handler throws an exception. + + ```js + findUser().then(function (user) { + return user.name; + }, function (reason) { + return 'default name'; + }).then(function (userName) { + // If `findUser` fulfilled, `userName` will be the user's name, otherwise it + // will be `'default name'` + }); + + findUser().then(function (user) { + throw new Error('Found user, but still unhappy'); + }, function (reason) { + throw new Error('`findUser` rejected and we're unhappy'); + }).then(function (value) { + // never reached + }, function (reason) { + // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. + // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. + }); + ``` + If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. + + ```js + findUser().then(function (user) { + throw new PedagogicalException('Upstream error'); + }).then(function (value) { + // never reached + }).then(function (value) { + // never reached + }, function (reason) { + // The `PedgagocialException` is propagated all the way down to here + }); + ``` + + Assimilation + ------------ + + Sometimes the value you want to propagate to a downstream promise can only be + retrieved asynchronously. This can be achieved by returning a promise in the + fulfillment or rejection handler. The downstream promise will then be pending + until the returned promise is settled. This is called *assimilation*. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // The user's comments are now available + }); + ``` + + If the assimliated promise rejects, then the downstream promise will also reject. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // If `findCommentsByAuthor` fulfills, we'll have the value here + }, function (reason) { + // If `findCommentsByAuthor` rejects, we'll have the reason here + }); + ``` + + Simple Example + -------------- + + Synchronous Example + + ```javascript + let result; + + try { + result = findResult(); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + findResult(function(result, err){ + if (err) { + // failure + } else { + // success + } + }); + ``` + + Promise Example; + + ```javascript + findResult().then(function(result){ + // success + }, function(reason){ + // failure + }); + ``` + + Advanced Example + -------------- + + Synchronous Example + + ```javascript + let author, books; + + try { + author = findAuthor(); + books = findBooksByAuthor(author); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + + function foundBooks(books) { + + } + + function failure(reason) { + + } + + findAuthor(function(author, err){ + if (err) { + failure(err); + // failure + } else { + try { + findBoooksByAuthor(author, function(books, err) { + if (err) { + failure(err); + } else { + try { + foundBooks(books); + } catch(reason) { + failure(reason); + } + } + }); + } catch(error) { + failure(err); + } + // success + } + }); + ``` + + Promise Example; + + ```javascript + findAuthor(). + then(findBooksByAuthor). + then(function(books){ + // found books + }).catch(function(reason){ + // something went wrong + }); + ``` + + @method then + @param {Function} onFulfilled + @param {Function} onRejected + Useful for tooling. + @return {Promise} + */ + then: then, + + /** + `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same + as the catch block of a try/catch statement. + + ```js + function findAuthor(){ + throw new Error('couldn't find that author'); + } + + // synchronous + try { + findAuthor(); + } catch(reason) { + // something went wrong + } + + // async with promises + findAuthor().catch(function(reason){ + // something went wrong + }); + ``` + + @method catch + @param {Function} onRejection + Useful for tooling. + @return {Promise} + */ + 'catch': function _catch(onRejection) { + return this.then(null, onRejection); + } +}; + +function polyfill() { + var local = undefined; + + if (typeof global !== 'undefined') { + local = global; + } else if (typeof self !== 'undefined') { + local = self; + } else { + try { + local = Function('return this')(); + } catch (e) { + throw new Error('polyfill failed because global object is unavailable in this environment'); + } + } + + var P = local.Promise; + + if (P) { + var promiseToString = null; + try { + promiseToString = Object.prototype.toString.call(P.resolve()); + } catch (e) { + // silently ignored + } + + if (promiseToString === '[object Promise]' && !P.cast) { + return; + } + } + + local.Promise = Promise; +} + +// Strange compat.. +Promise.polyfill = polyfill; +Promise.Promise = Promise; + +Promise.polyfill(); + +return Promise; + +}))); + + } + + function shouldIgnorePolyfill(self) { + var isSupport = false; + var P = self.Promise; + + if (P) { + var promise = null; + var then = null; + try { + promise = P.resolve(); + then = promise.then; + } catch (e) { + // silently ignored + } + if (promise instanceof P && typeof then === 'function' && !P.cast) { + isSupport = true; + } + } + return isSupport; + } + + if (!shouldIgnorePolyfill(self)) { + PromisePolyfillImpl(); + } +})(self); +/** + * AP SOURCE + */ +;(function (self) { + 'use strict'; + /********************* JSAPI functions ********************/ + // AlipayJSBridge + + var _JS_BRIDGE_NAME = 'AlipayJSBridge'; + var _JS_BRIDGE = self[_JS_BRIDGE_NAME]; + var _UA = navigator.userAgent || navigator.swuserAgent; + var _MEDIA_BUSINESS = 'apm-h5'; + var _IS_SUPPORT_PROMISE; + var window = self.window; + var document = self.document; + var console = self.console; + var parseInt = self.parseInt; + /** + * 待执行队列,处理 ready 前的接口调用 + */ + var _WAITING_QUEUE = []; + + //缓存 + var _CACHE = { + getBAPSI: { + isListening: false, + lastState: 2, + on: function on() { + if (!_CACHE.getBAPSI.isListening) { + _JS_BRIDGE.call('startMonitorBackgroundAudio'); + _CACHE.getBAPSI.isListening = true; + AP.on('getBackgroundAudioPlayedStateInfo', _CACHE.getBAPSI.listener); + } + }, + off: function off() { + AP.off('getBackgroundAudioPlayedStateInfo', _CACHE.getBAPSI.listener); + _JS_BRIDGE.call('stopMonitorBackgroundAudio'); + _CACHE.getBAPSI.isListening = false; + }, + listener: function listener(evt) { + var data = evt.data || {}; + var state = data.status; + var triggerEvent = ['backgroundAudioPause', 'backgroundAudioPlay', 'backgroundAudioStop'][state]; + if (triggerEvent && state !== _CACHE.getBAPSI.lastState) { + AP.trigger(triggerEvent); + _CACHE.getBAPSI.lastState = state; + } + } + } + }; + /** + * JSAPI å¼‚æ­¥æŽ¥å£åˆ—è¡¨ï¼Œä¸‹é¢æ˜¯åˆ—è¡¨ä¸­å…·ä½“ä»£ç ç»“æž„çš„è¯´æ˜Ž + * @type {Object} + * + * @String m => mapping JSAPI åç§°æ˜ å°„ï¼Œå³å¯¹åº”çš„ AlipayJSBridge 的接口名,方便直接改名 + * @Object e => extra JSAPI æ‰©å±•ä¿¡æ¯ï¼Œæ–¹ä¾¿è¿½åŠ è‡ªå®šä¹‰æ ‡è¯† + * handleResultSuccess: Boolean 是否处理 success 字段 + * handleEventData: Boolean 是否处理事件携带的数据,即过滤掉 event 对象只返回 data + * optionModifier: Function 对原有 option 入参做进一步处理 + * + * @Function b => before(opt, cb) 前置处理,处理入参 + * @param {Object} opt 原始入参,其中 opt._ æ˜¯è°ƒç”¨æŽ¥å£æ—¶å¯ç›´æŽ¥ä¼ å…¥çš„æŸä¸ªå‚æ•° + * @return {Object} 处理过的入参 + * @Function d => doing(_opt, cb, opt) 代替执行,代替原有 api 直接执行,会忽略 AlipayJSBridge.call 接口 + * @param {Object} opt 原始入参 + * @param {Object} _opt before 处理过的入参 + * @param {Function} cb 接口回调函数,已在 AP.call 中处理,所以此处一定是一个 Function æ— éœ€åˆ¤æ–­ + * @Function a => after(res, _opt, opt) 后置处理,处理出参,即接口返回给回调函数的值 + * @param {Object} opt 原始入参 + * @param {Object} _opt 经 before 处理过的入参 + * @param {Object} res JSAPI 接口的原始返回值 + * @return {Object} 处理过的接口返回值 + * + */ + var _JSAPI = { + /************************* alipayjsapi-inc å†…éƒ¨æŽ¥å£ï¼Œä¸‹ä¸ºå ä½ç¬¦ï¼Œå¤–éƒ¨å‘å¸ƒæ—¶ä¼šè¢«åˆ é™¤ *************************/ + + + /** + * 新版蓝牙相关接口 + */ + openBluetoothAdapter: {}, + closeBluetoothAdapter: {}, + getBluetoothAdapterState: {}, + startBluetoothDevicesDiscovery: { + b: function b(opt) { + if (__isString(opt._)) { + opt._ = [opt._]; + } + _mapping(opt, { + _: 'services' + }); + return opt; + } + }, + stopBluetoothDevicesDiscovery: {}, + getBluetoothDevices: { + b: function b(opt) { + if (__isString(opt._)) { + opt._ = [opt._]; + } + _mapping(opt, { + _: 'services' + }); + return opt; + }, + a: function a(res) { + if (__isArray(res.devices)) { + __forEach(res.devices, function (key, val) { + _mapping(val, { + manufacturerData: 'advertisData' + }); + }); + } + + return res; + } + }, + getConnectedBluetoothDevices: { + a: function a(res) { + if (__isArray(res.devices)) { + __forEach(res.devices, function (key, val) { + _mapping(val, { + manufacturerData: 'advertisData' + }); + }); + } + + return res; + } + }, + connectBLEDevice: { + b: function b(opt) { + _mapping(opt, { + _: 'deviceId' + }); + return opt; + } + }, + disconnectBLEDevice: {}, + writeBLECharacteristicValue: {}, + readBLECharacteristicValue: {}, + notifyBLECharacteristicValueChange: {}, + getBLEDeviceServices: { + b: function b(opt) { + _mapping(opt, { + _: 'deviceId' + }); + return opt; + } + }, + getBLEDeviceCharacteristics: {}, + onBLECharacteristicValueChange: { + //çœŸæ­£çš„äº‹ä»¶åï¼Œä¼šæŠŠé¦–å­—æ¯è‡ªåŠ¨è½¬æˆå°å†™ï¼Œå› æ­¤è¿™é‡Œä½¿ç”¨ map 可避免这个问题 + m: 'BLECharacteristicValueChange' + + }, + offBLECharacteristicValueChange: { + m: 'BLECharacteristicValueChange' + }, + onBluetoothAdapterStateChange: {}, + offBluetoothAdapterStateChange: {}, + onBLEConnectionStateChanged: { + m: 'BLEConnectionStateChanged' + + }, + offBLEConnectionStateChanged: { + m: 'BLEConnectionStateChanged' + }, + onBluetoothDeviceFound: { + a: function a(res) { + return _mapping(res, { + manufacturerData: 'advertisData' + }); + } + }, + offBluetoothDeviceFound: {}, + /** + * end 新版蓝牙相关接口 + */ + + pushBizWindow: {}, + compressImage: { + b: function b(opt) { + opt.level = __isUndefined(opt.level) ? 4 : opt.level; + return _mapping(opt, { + _: 'apFilePaths', + level: 'compressLevel%d' + }); + }, + d: function d(_opt, cb) { + if (__isAndroid()) { + _JS_BRIDGE.call('compressImage', _opt, cb); + } else { + _fakeCallBack(cb, { + apFilePaths: _opt.apFilePaths || [] + }); + } + } + }, + + /** + * 获取启动参数,并记录在 AP.launchParams + * @method getLaunchParams + * @param {String} null + * @param {Function} fn 回调 + */ + getLaunchParams: { + d: function d(opt, cb) { + AP.launchParams = window.ALIPAYH5STARTUPPARAMS || _JS_BRIDGE.startupParams || {}; + if (__isFunction(cb)) { + cb(AP.launchParams); + } + } + }, + //旧版蓝牙接口移除 + + onTabClick: {}, + offTabClick: {}, + onShare: { + m: 'onShare' + + }, + offShare: { + m: 'onShare' + }, + connectSocket: { + b: function b(opt) { + return _mapping(opt, { + headers: 'header' + }); + } + }, + sendSocketMessage: { + b: function b(opt) { + return _mapping(opt, { + _: 'data' + }); + } + }, + closeSocket: {}, + onSocketOpen: {}, + offSocketOpen: {}, + onSocketMessage: {}, + offSocketMessage: {}, + onSocketError: {}, + offSocketError: {}, + onSocketClose: {}, + offSocketClose: {}, + + ////////////////////////////// [AlipayJSAPI/ui] //////////////////////////// + /** + * æŽ¥å£å¯ç›´æŽ¥ä¼ å…¥ä¸€ä¸ªå­—ç¬¦ä¸²ï¼ˆopt.content) + * 统一 alert å’Œ confirm 的内容字段为 content + */ + alert: { + b: function b(opt) { + opt = _mapping(opt, { + _: 'content', + content: 'message%s', + buttonText: 'button%s' + }); + if (!__isUndefined(opt.title)) { + opt.title = _toType('%s', opt.title); + } + return opt; + } + }, + /** + * æŽ¥å£å¯ç›´æŽ¥ä¼ å…¥ä¸€ä¸ªå­—ç¬¦ä¸²ï¼ˆopt.content) + * 统一 alert å’Œ confirm 的内容字段为 content + */ + confirm: { + b: function b(opt) { + opt = _mapping(opt, { + _: 'content%s', + content: 'message%s', + confirmButtonText: 'okButton%s', + cancelButtonText: 'cancelButton%s' + }); + if (!__isUndefined(opt.title)) { + opt.title = _toType('%s', opt.title); + } + return opt; + }, + a: function a(res) { + return _mapping(res, { + ok: 'confirm' //更改之前返回值里的 ok 为 confirm + }); + } + }, + /** + * æŽ¥å£å¯ç›´æŽ¥ä¼ å…¥ä¸€ä¸ªå­—ç¬¦ä¸²ï¼ˆopt.content) + */ + showToast: { + m: 'toast', + b: function b(opt) { + //toast 内容字段本来就是 content + _mapping(opt, { + _: 'content%s' + }); + if (!__isString(opt.content)) { + opt.content = _toType('%s', opt.content); + } + //opt.duration = opt.duration || 2000; + return opt; + } + }, + hideToast: {}, + /** + * æŽ¥å£å¯ç›´æŽ¥ä¼ å…¥ä¸€ä¸ªå­—ç¬¦ä¸²ï¼ˆopt.content) + * æŽ¥å£æ”¹é€ opt.content => opt.text + */ + showLoading: { + b: function b(opt) { + return _mapping(opt, { + _: 'content', // %s æ²¡å¿…è¦åŠ ç»™ content, + content: 'text%s' // å› ä¸ºæœ€åŽè°ƒç”¨æŽ¥å£æ—¶çœŸæ­£å…¥å‚æ˜¯ text + }); + } + }, + hideLoading: {}, + showNavigationBarLoading: { + m: 'showTitleLoading' + }, + hideNavigationBarLoading: { + m: 'hideTitleLoading' + }, + /** + * 整合了 setTitle, setTitleColor, setBarBottomLineColor 三个接口 + * @type {Object} + */ + setNavigationBar: { + b: function b(opt) { + // JSAPI åç§°å¤ªé•¿åˆå¤šæ¬¡å¼•ç”¨ï¼Œä¸åˆ©äºŽä»£ç åŽ‹ç¼©ï¼Œå›ºå•ç‹¬è®°å½• + var st = 'setTitle'; + var stc = 'setTitleColor'; + var sblc = 'setBarBottomLineColor'; + var _opt = {}; + + _opt[st] = {}; + _opt[stc] = {}; + _opt[sblc] = {}; + + // æ˜ å°„ä¸åŒ JSAPI 的入参 + _opt[st] = _mapping(_opt[st], { + _: 'title', //æŽ¥å£å¯ç›´æŽ¥ä¼ å…¥ä¸€ä¸ªå­—ç¬¦ä¸²ï¼ˆopt.title) + title: 'title%s', + image: 'image%b' //处理 image 为 base64 的情况,为 native ç§»é™¤æ ¼å¼å¤´ + }, opt); + _opt[stc] = _mapping(_opt[stc], { + backgroundColor: 'color%c', + reset: 'reset' + }, opt); + _opt[sblc] = _mapping(_opt[sblc], { + borderBottomColor: 'color%c' + }, opt); + + return _opt; + }, + d: function d(_opt, cb) { + var st = 'setTitle'; + var stc = 'setTitleColor'; + var sblc = 'setBarBottomLineColor'; + var res = {}; + //setTitle + if (!__isEmptyObject(_opt[st])) { + _JS_BRIDGE.call(st, _opt[st]); + } + //setBarBottomLineColor + if (!__isEmptyObject(_opt[sblc])) { + _JS_BRIDGE.call(sblc, _opt[sblc]); + if (__isNaN(_opt[sblc].color)) { + res.error = 2; + res.errorMessage = '颜色值不合法'; + } + } + //setTitleColor + if (!__isEmptyObject(_opt[stc])) { + _JS_BRIDGE.call(stc, _opt[stc], function (result) { + res = __extend(result, res); + cb(res); + }); + } else { + //setTitle å’Œ setBarBottomLineColor 本身没有回调 + //为保持接口一致性要模拟一个异步回调 + _fakeCallBack(cb, res); + } + } + }, + showTabBar: { + b: function b(opt) { + //创建 tabBar + opt.action = 'create'; + //默认激活第一个 tab + opt.activeIndex = opt.activeIndex || 0; + //å…¶ä»–å±žæ€§æ˜ å°„ + _mapping(opt, { + color: 'textColor%c', + activeColor: 'selectedColor%c', + activeIndex: 'selectedIndex%d' + }); + + if (__isArray(opt.items)) { + var items = opt.items; + //éœ€è¦å¤åˆ¶ä¸€ä»½ï¼Œä¸èƒ½åœ¨åŽŸæ•°ç»„ä¸Šä¿®æ”¹ï¼Œä¼šç ´åç”¨æˆ·æ•°æ® + opt.items = []; + items.forEach(function (item, i) { + item = _mapping(__extend({}, item), { + title: 'name%s', + tag: 'tag%s', + icon: 'icon%b', + activeIcon: 'activeIcon%b', + badge: 'redDot%s' + }, { + tag: i, + // title: item.title, + // icon: item.icon, + // activeIcon: item.activeIcon, + badge: __isUndefined(item.badge) ? '-1' : item.badge + }); + item.icon = _toType('%b', item.icon); + item.activeIcon = _toType('%b', item.activeIcon); + opt.items.push(item); + }); + } + return opt; + }, + d: function d(_opt, cb, opt) { + var apiName = 'showTabBar'; + if (!__isUndefined(_CACHE.showTabBar)) { + console.error(apiName + ' must be called at most once'); + } else { + _CACHE.showTabBar = { + opt: opt + }; + } + //监听点击事件 + AP.on('tabClick', function (evt) { + var res = {}; + _mapping(res, { + tag: 'index%d' + }, { + tag: __isObject(evt.data) && evt.data.tag ? evt.data.tag : '0' + }); + cb(res); + }); + //调用方法 + _JS_BRIDGE.call('tabBar', _opt, function (result) { + //result 并非真正的返回值,但是要处理接口错误 + _handleApiError(apiName, result); + }); + } + }, + setTabBarBadge: { + m: 'tabBar', + b: function b(opt) { + opt.action = 'redDot'; + _mapping(opt, { + index: 'tag%s', + badge: 'redDot%s' + }, { + index: opt.index + }); + return opt; + } + }, + showActionSheet: { + m: 'actionSheet', + b: function b(opt) { + _mapping(opt, { + items: 'btns', + cancelButtonText: 'cancelBtn%s' + }); + //把按钮字段转成字符串,非字符串会导致钱包闪退 + if (__isArray(opt.btns)) { + var btns = opt.btns; + opt.btns = []; + btns.forEach(function (item) { + return opt.btns.push(item + ''); + }); + } + //把取消按钮字段转成字符串,非字符串会导致 actionSheet 全屏 + if (__isUndefined(opt.cancelBtn)) { + opt.cancelBtn = '取消'; + } + + return opt; + }, + a: function a(res, _opt) { + if (__isArray(_opt.btns) && res.index === _opt.btns.length) { + res.index = -1; + } + return res; + } + }, + redirectTo: { + /** + * å¢žåŠ opt.data 作为 queryString 拼在 url 后面 + */ + b: function b(opt) { + //ç›´æŽ¥ä¼ å…¥ä¸€ä¸ªå­—ç¬¦ä¸²æ—¶å½“ä½œ opt.url 参数 + _mapping(opt, { + _: 'url' + }); + //如果有 data å‚æ•°åˆ™æž„é€ æœ‰ queryString çš„ url + if (__isObject(opt.data)) { + opt.url = __buildUrl(opt.url, opt.data); + } + return opt; + }, + d: function d(_opt) { + if (_opt.url) { + window.location.replace(_opt.url); + } + } + }, + pushWindow: { + /** + * å¢žåŠ opt.data 作为 queryString 拼在 url 后面 + */ + b: function b(opt) { + //ç›´æŽ¥ä¼ å…¥ä¸€ä¸ªå­—ç¬¦ä¸²æ—¶å½“ä½œ opt.url 参数 + _mapping(opt, { + _: 'url', + params: 'param' + }); + if (opt.url.indexOf('?') > -1) { + console.warn('try opt.' + 'data' + ' instead of querystring'); + } + if (opt.url.indexOf('__webview_options__') > -1) { + console.warn('try opt.' + 'params' + ' instead of ' + '__webview_options__'); + } + //如果有 data å‚æ•°åˆ™æž„é€ æœ‰ queryString çš„ url + if (__isObject(opt.data)) { + opt.url = __buildUrl(opt.url, opt.data); + delete opt.data; + } + return opt; + } + }, + popWindow: { + b: function b(opt) { + opt = _fixOptData(opt); + if (!__isObject(opt.data)) { + opt.data = { + ___forResume___: opt.data + }; + } + return opt; + } + }, + popTo: { + /** + * æŽ¥å£å¯ç›´æŽ¥ä¼ å…¥ä¸€ä¸ªæ•°å­—ï¼ˆopt.index)或者一个字符串(opt.urlPattern) + */ + b: function b(opt) { + _mapping(opt, { + _: function () { + var key = void 0; + if (__isNumber(opt._)) { + key = 'index'; + } + if (__isString(opt._)) { + key = 'urlPattern'; + } + return key; + }() + }); + if (!__isObject(opt.data)) { + opt.data = { + ___forResume___: opt.data + }; + } + return opt; + } + }, + allowPullDownRefresh: { + d: function d(opt) { + var onPDR = 'onPullDownRefresh'; + _mapping(opt, { + _: 'allow' + }); + opt.allow = __isUndefined(opt.allow) ? true : !!opt.allow; + + if (__isObject(_CACHE[onPDR])) { + _CACHE[onPDR].allow = opt.allow; + } else { + _CACHE[onPDR] = { + allow: opt.allow + }; + //监听事件,通过 event.preventDefault() 阻止下拉刷新 + //满足用户在没有监听事件的情况下调用 AP.allowPullDownRefresh(false) 仍然生效 + AP.onPullDownRefresh(); + } + if (_CACHE[onPDR].allow) { + _JS_BRIDGE.call('restorePullToRefresh'); + } else { + if (_CACHE[onPDR].event) { + _CACHE[onPDR].event.preventDefault(); + } + } + } + }, + + choosePhoneContact: { + m: 'contact' + }, + /** + * 最多选择10个联系人,只露出 count 参数,其他屏蔽 + */ + chooseAlipayContact: { + m: 'chooseContact', + b: function b(opt) { + var multi = 'multi'; + var single = 'single'; + _mapping(opt, { + _: 'count' + }); + if (__isUndefined(opt.count)) { + opt.count = 1; + } + if (opt.count === 1) { + opt.type = single; + } else { + opt.type = multi; + if (opt.count <= 0 || opt.count > 10) { + opt.multiMax = 10; + } else { + opt.multiMax = opt.count; + } + } + delete opt.count; + return opt; + }, + a: function a(res) { + if (__isArray(res.contacts)) { + res.contacts.forEach(function (contact) { + _mapping(contact, { + headImageUrl: 'avatar', + name: 'realName' + }); + delete contact.from; + }); + } + return res; + } + }, + share: { + b: function b(opt) { + var startShareOpt = {}; + var shareToChannelOpt = {}; + startShareOpt.onlySelectChannel = ['ALPContact', 'ALPTimeLine', 'ALPCommunity', 'Weibo', 'DingTalkSession', 'SMS', 'Weixin', 'WeixinTimeLine', 'QQ', 'QQZone']; + if (__hasOwnProperty(opt, 'bizType')) { + startShareOpt.bizType = opt.bizType; + } + + shareToChannelOpt = __extend({}, opt); + delete shareToChannelOpt.bizType; + delete shareToChannelOpt.onlySelectChannel; + _mapping(shareToChannelOpt, { + image: 'imageUrl' + }); + + _CACHE.share = { + startShare: startShareOpt, + shareToChannel: shareToChannelOpt + }; + return opt; + }, + d: function d(opt, cb) { + //隐藏第二行 + if (opt.showToolBar === false) { + _JS_BRIDGE.call('setToolbarMenu', { + menus: [], + override: true + }); + } + //唤起分享面板 + _JS_BRIDGE.call('startShare', _CACHE.share.startShare, function (info) { + var stcOpt = _CACHE.share.shareToChannel; + if (info.channelName) { + _JS_BRIDGE.call('shareToChannel', { + name: info.channelName, + param: stcOpt + }, cb); + } else { + cb(info); + } + }); + } + }, + datePicker: { + b: function b(opt) { + _mapping(opt, { + _: 'formate', + formate: 'mode', + currentDate: 'beginDate', + startDate: 'minDate', + endDate: 'maxDate' + }); + switch (opt.mode) { + case 'HH:mm:ss': + opt.mode = 0; + break; + case 'yyyy-MM-dd': + opt.mode = 1; + break; + case 'yyyy-MM-dd HH:mm:ss': + opt.mode = 2; + break; + default: + opt.mode = 1; + } + return opt; + }, + a: function a(res) { + if (__isString(res.date)) { + //è¿”å›žæ ¼å¼ä¸ºyyyy-MM-dd + res.date = res.date.replace(/\//g, '-').trim(); + } + // if (res.error === 2 ) { + // const currentDate = _opt.currentDate || Date.now(); + // const startDate = _opt.startDate; + // } + return res; + } + }, + chooseCity: { + m: 'getCities', + b: function b(opt) { + var customCities; + var customHotCities; + _mapping(opt, { + showHotCities: 'needHotCity', + cities: 'customCities', + hotCities: 'customHotCities' + }); + //显示定位城市 + if (opt.showLocatedCity === true) { + opt.currentCity = ''; + opt.adcode = ''; + } else { + delete opt.currentCity; + delete opt.adcode; + } + delete opt.showLocatedCity; + + //自定义城市 + customCities = opt.customCities; + if (!__isUndefined(opt.customCities)) { + opt.customCities = mapArray(customCities); + } + //自定义热门城市 + customHotCities = opt.customHotCities; + if (!__isUndefined(opt.customHotCities)) { + opt.customHotCities = mapArray(customHotCities); + } + + function mapArray(arr) { + var tempArr; + if (__isArray(arr)) { + tempArr = []; + arr.forEach(function (city) { + tempArr.push(_mapping({}, { + city: 'name', + adCode: 'adcode%s', + spell: 'pinyin' + }, city)); + }); + arr = tempArr; + } + return arr; + } + + return opt; + }, + a: function a(res) { + _mapping(res, { + adcode: 'adCode' + }); + return res; + } + }, + + ////////////////////////////// 事件 ///////////////////////////////// + onBack: { + a: function a(evt) { + var res = {}; + var onBack = 'onBack'; + if (__isObject(_CACHE[onBack])) { + _CACHE[onBack].event = evt; + } else { + _CACHE[onBack] = { + event: evt, + allowButton: true + }; + } + if (_CACHE[onBack].allowButton === false) { + evt.preventDefault(); + } + res.backAvailable = _CACHE[onBack].allowButton; + return res; + }, + + e: { + handleEventData: false + } + }, + offBack: {}, + + onResume: { + a: function a(evt) { + var res = {}; + if (!__isUndefined(evt.data)) { + res.data = evt.data; + } + if (__hasOwnProperty(evt.data, '___forResume___')) { + res.data = evt.data.___forResume___; + } + return res; + }, + + e: { + handleEventData: false + } + }, + offResume: {}, + + onPause: {}, + offPause: {}, + + onPageResume: { + a: function a(evt) { + var res = {}; + if (!__isUndefined(evt.data)) { + res.data = evt.data; + } + if (__hasOwnProperty(evt.data, '___forResume___')) { + res.data = evt.data.___forResume___; + } + return res; + }, + + e: { + handleEventData: false + } + }, + offPageResume: {}, + onPagePause: {}, + offPagePause: {}, + + onTitleClick: {}, + offTitleClick: {}, + + //onSubTitleClick: {}, + onPullDownRefresh: { + m: 'firePullToRefresh', + a: function a(evt) { + var res = {}; + var onPDR = 'onPullDownRefresh'; + if (__isObject(_CACHE[onPDR])) { + _CACHE[onPDR].event = evt; + } else { + _CACHE[onPDR] = { + event: evt, + allow: true + }; + } + if (_CACHE[onPDR].allow === false) { + _CACHE[onPDR].event.preventDefault(); + } + res.refreshAvailable = _CACHE[onPDR].allow; + return res; + }, + + e: { + handleEventData: false + } + }, + offPullDownRefresh: { + m: 'firePullToRefresh' + }, + + onNetworkChange: { + d: function d(_opt, _cb, opt, cb) { + //直接调用一次 getNetworkType 吐回当前网络状态 + var handler = function handler() { + return AP.getNetworkType(_cb); + }; + _cacheEventHandler('h5NetworkChange', cb, handler); + AP.on('h5NetworkChange', handler); + } + }, + offNetworkChange: { + d: function d(_opt, _cb, opt, cb) { + _removeEventHandler('h5NetworkChange', cb); + } + }, + onAccelerometerChange: { + b: function b() { + _JS_BRIDGE.call('watchShake', { monitorAccelerometer: true }); + }, + a: function a(evt) { + var res = {}; + _mapping(res, { + x: 'x', + y: 'y', + z: 'z' + }, __isObject(evt.data) ? evt.data : evt); + return res; + }, + + e: { + handleEventData: false + } + }, + offAccelerometerChange: { + b: function b() { + _JS_BRIDGE.call('watchShake', { monitorAccelerometer: false }); + } + }, + onCompassChange: { + b: function b() { + _JS_BRIDGE.call('watchShake', { monitorCompass: true }); + }, + a: function a(evt) { + var res = {}; + _mapping(res, { + direction: 'direction' + }, __isObject(evt.data) ? evt.data : evt); + return res; + }, + + e: { + handleEventData: false + } + }, + offCompassChange: { + b: function b() { + _JS_BRIDGE.call('watchShake', { monitorCompass: false }); + } + }, + + onBackgroundAudioPlay: { + b: function b(opt) { + _CACHE.getBAPSI.on(); + return opt; + } + }, + offBackgroundAudioPlay: {}, + + onBackgroundAudioPause: { + b: function b(opt) { + _CACHE.getBAPSI.on(); + return opt; + } + }, + offBackgroundAudioPause: {}, + + onBackgroundAudioStop: { + b: function b(opt) { + _CACHE.getBAPSI.on(); + return opt; + } + }, + offBackgroundAudioStop: {}, + + onAppResume: {}, + offAppResume: {}, + onAppPause: {}, + offAppPause: {}, + + ///////////////////////////// device ///////////////////////////// + getNetworkType: { + a: function a(res) { + if (!__isUndefined(res.networkInfo)) { + res.networkType = __tuc(res.networkInfo); + } + //æ— éœ€è¿™ä¹ˆå¤šå­—æ®µ + delete res.err_msg; + delete res.networkInfo; + return res; + } + }, + scan: { + b: function b(opt) { + _mapping(opt, { + _: 'type' + }); + opt.type = opt.type || 'qr'; + return opt; + }, + a: function a(res) { + if (res.qrCode || res.barCode) { + res.code = res.qrCode || res.barCode; + delete res.qrCode; + delete res.barCode; + } + + return res; + } + }, + watchShake: { + b: function b(opt) { + //ç”¨æˆ·çœŸæ­£ä½¿ç”¨æ­¤æŽ¥å£æ—¶ä¸éœ€è¦ä¼ å…¥ä»»ä½•å‚æ•° + //ç§»é™¤æ‰€æœ‰å…¥å‚ï¼Œå…¥å‚è¢«ä¼ æ„Ÿå™¨äº‹ä»¶ç›‘å¬å¼€å…³å ç”¨ + //如果有入参,ios 不会调用回调,android 会直接调用回调。 + if (__isEmptyObject(opt)) { + opt = null; + } + return opt; + } + }, + getLocation: { + b: function b(opt) { + _mapping(opt, { + accuracy: 'horizontalAccuracy', + type: 'requestType%d' + }); + if (__isUndefined(opt.requestType)) { + opt.requestType = 2; + } + if (__isAndroid()) { + if (__isUndefined(opt.isHighAccuracy)) { + opt.isHighAccuracy = true; + } + if (__isUndefined(opt.isNeedSpeed)) { + opt.isNeedSpeed = true; + } + } + return opt; + }, + a: function a(res) { + _mapping(res, { + citycode: 'cityCode', + adcode: 'adCode' + }); + if (__isUndefined(res.city) && res.province) { + res.city = res.province; + } + if (res.latitude) { + res.latitude = _toType('%s', res.latitude); + } + if (res.longitude) { + res.longitude = _toType('%s', res.longitude); + } + if (res.accuracy) { + res.accuracy = _toType('%f', res.accuracy); + } + if (res.speed) { + res.speed = _toType('%f', res.speed); + } + return res; + } + }, + getSystemInfo: { + a: function a(res) { + var pixelRatio = 'pixelRatio'; + var windowWidth = 'windowWidth'; + var windowHeight = 'windowHeight'; + var language = 'language'; + if (!__hasOwnProperty(res, 'error')) { + res[pixelRatio] = _toType('%f', res[pixelRatio]); + res[windowWidth] = _toType('%d', res[windowWidth]); + res[language] = (res[language] || '').replace(/\s?\w+\/((?:\w|-)+)$/, '$1'); + res[windowHeight] = _toType('%d', res[windowHeight]); + try { + if (__isIOS() && AP.compareVersion('10.0.12') < 0) { + res[windowHeight] = window.screen.height - 64; + } + } catch (err) {} + } + return res; + } + }, + vibrate: {}, + getServerTime: {}, + + /////////////////////////// media ////////////////////////// + previewImage: { + m: 'imageViewer', + /** + * æŽ¥å£æ”¹é€ opt.current => opt.init + * opt.urls => opt.images + * é»˜è®¤æ”¯æŒç›´æŽ¥ä¼ å…¥ä¸€ä¸ªæ•°ç»„ä½œä¸º opt.urls + */ + b: function b(opt) { + _mapping(opt, { + _: 'urls', + current: 'init%d' + }); + //处理默认索引 + if (__isUndefined(opt.init)) { + opt.init = 0; + } + //处理图片链接 + opt.images = []; + (opt.urls || []).forEach(function (url) { + opt.images.push({ + u: url + }); + }); + delete opt.urls; + + return opt; + } + }, + chooseImage: { + b: function b(opt) { + _mapping(opt, { + _: 'count%d' + }); + if (__isUndefined(opt.count)) { + opt.count = 1; + } + if (__isString(opt.sourceType)) { + opt.sourceType = [opt.sourceType]; + } + return opt; + }, + a: function a(res) { + _mapping(res, { + errorCode: 'error', + errorDesc: 'errorMessage', + localIds: 'apFilePaths', + tempFilePaths: 'apFilePaths' + }); + //åˆ é™¤æ— ç”¨å±žæ€§ + delete res.scene; + delete res.localIds; + delete res.tempFilePaths; + + //android 返回字符串 + if (__isString(res.apFilePaths)) { + res.apFilePaths = __parseJSON(res.apFilePaths); + } + + return res; + } + }, + chooseVideo: { + b: function b(opt) { + _mapping(opt, { + _: 'maxDuration%d' + }); + if (__isString(opt.sourceType)) { + opt.sourceType = [opt.sourceType]; + } + if (__isString(opt.camera)) { + opt.camera = [opt.camera]; + } + return opt; + }, + a: function a(res) { + _mapping(res, { + errorCode: 'error', //android errorCode + errorDesc: 'errorMessage', // android errorDesc + msg: 'errorMessage', // ios msg + localId: 'apFilePath', + tempFilePath: 'apFilePath', + tempFile: 'apFilePath' + }); + //åˆ é™¤æ— ç”¨å±žæ€§ + delete res.localId; + delete res.tempFilePath; + delete res.tempFile; + + switch (res.error) { + case 0: + //ios 成功 + delete res.error; + break; + case 1: + //ios 参数出错 + res.error = 2; //é€šç”¨å‚æ•°æ— æ•ˆ + break; + case 2: + //ios 用户取消 + res.error = 10; //android 用户取消 + break; + case 3: + //ios 操作失败 + res.error = 11; //android 操作失败 + break; + case 4: + //ios 数据处理失败 + res.error = 12; + break; + default: + } + + return res; + } + }, + uploadFile: { + b: function b(opt) { + _mapping(opt, { + headers: 'header', + fileName: 'name', + fileType: 'type' + }); + if (_isLocalId(opt.filePath)) { + opt.localId = opt.filePath; + delete opt.filePath; + } + return opt; + }, + a: function a(res) { + if (res.error === 2) { + res.error = 11; + } + return res; + } + }, + saveImage: { + b: function b(opt, cb) { + _mapping(opt, { + _: 'url', + url: 'src' + }); + if (__isFunction(cb)) { + opt.cusHandleResult = true; + } + return opt; + } + }, + downloadFile: { + b: function b(opt) { + _mapping(opt, { + headers: 'header' + }); + return opt; + }, + a: function a(res) { + _mapping(res, { + tempFilePath: 'apFilePath', + errorCode: 'error' + }); + delete res.tempFilePath; + return res; + } + }, + + ///////////////////////////////// 数据 //////////////////////////////// + setSessionData: { + b: function b(opt) { + opt = _fixOptData(opt); + if (!__isObject(opt.data)) { + opt.data = { + data: opt.data + }; + } + __forEach(opt.data, function (key, value) { + opt.data[key] = JSON.stringify(value); + }); + return opt; + } + }, + getSessionData: { + b: function b(opt) { + //ç›´æŽ¥ä¼ å…¥ä¸€ä¸ª key + if (__isString(opt._)) { + opt.keys = [opt._]; + } + //ç›´æŽ¥ä¼ å…¥ä¸€ä¸ªæ•°ç»„ + if (__isArray(opt._)) { + opt.keys = opt._; + } + delete opt._; + return opt; + }, + a: function a(res) { + __forEach(res.data, function (key, value) { + res.data[key] = __parseJSON(value); + }); + return res; + } + }, + ////////////////////////////// 开放接口 //////////////////////////////// + startBizService: { + b: function b(opt) { + _mapping(opt, { + _: 'name', + params: 'param%s' + }); + return opt; + } + }, + tradePay: { + b: function b(opt) { + _mapping(opt, { + _: 'orderStr' + }); + return opt; + } + }, + getAuthCode: { + b: function b(opt) { + _mapping(opt, { + _: 'scopes' + }); + if (__isString(opt.scopes)) { + opt.scopeNicks = [opt.scopes]; + } else if (__isArray(opt.scopes)) { + opt.scopeNicks = opt.scopes; + } else { + opt.scopeNicks = ['auth_base']; + } + delete opt.scopes; + + return opt; + }, + a: function a(res) { + _mapping(res, { + authcode: 'authCode' + }); + return res; + } + }, + getAuthUserInfo: { + a: function a(res) { + _mapping(res, { + nick: 'nickName', + userAvatar: 'avatar' + }); + return res; + } + }, + ////////////////////////// v0.1.3+ /////////////////////////////// + openInBrowser: { + /** + * æŽ¥å£å¯ç›´æŽ¥ä¼ å…¥ä¸€ä¸ªå­—ç¬¦ä¸²ï¼ˆopt.url) + */ + b: function b(opt) { + return _mapping(opt, { + _: 'url' + }); + } + }, + openLocation: { + b: function b(opt) { + if (__isUndefined(opt.scale)) { + opt.scale = 15; //默认缩放15级 + } + return opt; + } + }, + showPopMenu: { + b: function b(opt) { + //å…¶ä»–å±žæ€§æ˜ å°„ + _mapping(opt, { + _: 'items', + items: 'menus' + }); + + //popMenuClick事件只监听一次,防止多次回调 + if (__isObject(_CACHE.showPopMenu)) { + _CACHE.showPopMenu.menus = {}; + } else { + _CACHE.showPopMenu = { + menus: {} + }; + } + if (__isArray(opt.menus)) { + var menus = opt.menus; + //éœ€è¦å¤åˆ¶ä¸€ä»½ï¼Œä¸èƒ½åœ¨åŽŸæ•°ç»„ä¸Šä¿®æ”¹ï¼Œä¼šç ´åç”¨æˆ·æ•°æ® + opt.menus = []; + menus.forEach(function (item, i) { + //支持菜单直接是个字符串数组 + if (__isString(item)) { + item = { + title: item + }; + } + item = _mapping(__extend({}, item), { + title: 'name%s', + tag: 'tag%s', + badge: 'redDot%s' + }, { + tag: i, + title: item.title, + badge: __isUndefined(item.badge) ? '-1' : item.badge + }); + if (!__isUndefined(item.icon)) { + item.icon = _toType('%b', item.icon); + } + opt.menus.push(item); + _CACHE.showPopMenu.menus[item.name] = i; + }); + } + return opt; + }, + d: function d(_opt, cb) { + var apiName = 'showPopMenu'; + if (_CACHE.showPopMenu.onEvent !== true) { + _CACHE.showPopMenu.onEvent = true; + //监听点击事件 + AP.on('popMenuClick', function (evt) { + var res = {}; + _mapping(res, { + title: 'index%d' + }, { + title: __isObject(evt.data) && evt.data.title ? _CACHE.showPopMenu.menus[evt.data.title] : '-1' + }); + cb(res); + }); + } + + //调用方法 + _JS_BRIDGE.call(apiName, _opt, function (result) { + //result 并非真正的返回值,但是要处理接口错误 + _handleApiError(apiName, result); + }); + } + }, + setOptionButton: { + m: 'setOptionMenu', + b: function b(opt) { + if (__isString(opt._)) { + opt.title = opt._; + delete opt._; + } + if (__isArray(opt._)) { + opt.items = opt._; + delete opt._; + } + _mapping(opt, { + items: 'menus', + type: 'iconType', + badge: 'redDot%s' + }); + if (!__isUndefined(opt.icon)) { + opt.icon = _toType('%b', opt.icon); + } + //optionMenu事件只监听一次,防止多次回调 + if (__isObject(_CACHE.setOptionButton)) { + _CACHE.setOptionButton.menus = []; + } else { + _CACHE.setOptionButton = { + menus: [] + }; + } + if (__isArray(opt.menus)) { + var menus = opt.menus; + //éœ€è¦å¤åˆ¶ä¸€ä»½ï¼Œä¸èƒ½åœ¨åŽŸæ•°ç»„ä¸Šä¿®æ”¹ï¼Œä¼šç ´åç”¨æˆ·æ•°æ® + opt.menus = []; + menus.forEach(function (item, i) { + item = _mapping(__extend({}, item), { + type: 'icontype', + badge: 'redDot%s' + }, { + badge: __isUndefined(item.badge) ? '-1' : item.badge + }); + if (!__isUndefined(item.icon)) { + item.icon = _toType('%b', item.icon); + } + opt.menus.unshift(item); + _CACHE.setOptionButton.menus[menus.length - 1 - i] = i; + }); + if (opt.menus.length > 0 && __isUndefined(opt.override)) { + opt.override = true; + } + } + //每次 setOptionMenu 要注册新的事件 + if (__isFunction(_CACHE.setOptionButton.onEvent)) { + AP.off('optionMenu', _CACHE.setOptionButton.onEvent); + } + if (__isFunction(opt.onClick)) { + var onClick = opt.onClick; + var eventHandler = function eventHandler(evt) { + var index = 0; + var res = {}; + if (__isObject(evt.data) && __isNumber(evt.data.index) && _CACHE.setOptionButton.menus.length > 0) { + index = _CACHE.setOptionButton.menus[evt.data.index]; + } + res.index = _toType('%d', index); + onClick(res); + }; + _CACHE.setOptionButton.onEvent = eventHandler; + //监听点击事件 + if (opt.reset !== true) { + AP.on('optionMenu', eventHandler); + } + delete opt.onClick; + } + return opt; + }, + d: function d(_opt, cb) { + _JS_BRIDGE.call('setOptionMenu', _opt, cb); + //iOS 没有回调, 10.0.8 + if (__isIOS()) { + _fakeCallBack(cb, {}); + } + AP.showOptionButton(); + } + }, + showOptionButton: { + m: 'showOptionMenu' + }, + hideOptionButton: { + m: 'hideOptionMenu' + }, + showBackButton: {}, + hideBackButton: {}, + allowBack: { + d: function d(opt) { + var onBack = 'onBack'; + _mapping(opt, { + _: 'allowButton' + }); + opt.allowButton = __isUndefined(opt.allowButton) ? true : !!opt.allowButton; + + if (__isBoolean(opt.allowGesture)) { + _JS_BRIDGE.call('setGestureBack', { + val: opt.allowGesture + }); + } + if (__isObject(_CACHE[onBack])) { + _CACHE[onBack].allowButton = opt.allowButton; + } else { + _CACHE[onBack] = { + allowButton: opt.allowButton + }; + AP.onBack(); + } + if (opt.allowButton === false && _CACHE[onBack].event) { + _CACHE[onBack].event.preventDefault(); + } + } + }, + startRecord: { + m: 'startAudioRecord', + b: function b(opt) { + _mapping(opt, { + maxDuration: 'maxRecordTime%f', + minDuration: 'minRecordTime%f', + bizType: 'business' + }, { + maxDuration: opt.maxDuration || 60, + minDuration: opt.minDuration || 1 + }); + if (__isUndefined(opt.business)) { + opt.business = _MEDIA_BUSINESS; + } + // 10.0.5统一成秒 + // opt.maxRecordTime *= 1000; + // opt.minRecordTime *= 1000; + return opt; + }, + a: function a(res) { + _mapping(res, { + tempFilePath: 'apFilePath', + identifier: 'apFilePath' + }); + return res; + } + }, + stopRecord: { + m: 'stopAudioRecord' + }, + cancelRecord: { + m: 'cancelAudioRecord' + }, + playVoice: { + m: 'startPlayAudio', + b: function b(opt) { + _mapping(opt, { + _: 'filePath', + filePath: 'identifier', + bizType: 'business' + }); + if (__isUndefined(opt.business)) { + opt.business = _MEDIA_BUSINESS; + } + return opt; + }, + a: function a(res) { + _mapping(res, { + identifier: 'filePath' + }); + return res; + } + }, + pauseVoice: { + m: 'pauseAudioPlay' + }, + resumeVoice: { + m: 'resumeAudioPlay' + }, + stopVoice: { + m: 'stopAudioPlay' + }, + makePhoneCall: { + d: function d(opt, cb) { + var url = 'tel:'; + _mapping(opt, { + _: 'number' + }); + url += opt.number; + _JS_BRIDGE.call('openInBrowser', { url: url }, cb); + } + }, + playBackgroundAudio: { + b: function b(opt) { + _mapping(opt, { + _: 'url', + url: 'audioDataUrl%s', + title: 'audioName%s', + singer: 'singerName%s', + describe: 'audioDescribe%s', + logo: 'audioLogoUrl%s', + cover: 'coverImgUrl%s', + bizType: 'business' + }, { + bizType: opt.bizType || _MEDIA_BUSINESS + }); + return opt; + }, + a: function a(res) { + _mapping(res, { + describe: 'errorMessage' + }); + _handleResultSuccess(res, 12, 0); + return res; + } + }, + pauseBackgroundAudio: { + a: function a(res) { + _mapping(res, { + describe: 'errorMessage' + }); + _handleResultSuccess(res, 12, 0); + return res; + } + }, + stopBackgroundAudio: { + a: function a(res) { + _mapping(res, { + describe: 'errorMessage' + }); + _handleResultSuccess(res, 12, 0); + return res; + } + }, + seekBackgroundAudio: { + b: function b(opt) { + _mapping(opt, { + _: 'position', + bizType: 'business' + }, { + bizType: opt.bizType || _MEDIA_BUSINESS + }); + opt.position = _toType('%f', opt.position); + return opt; + }, + a: function a(res) { + _mapping(res, { + describe: 'errorMessage' + }); + _handleResultSuccess(res, 12, 0); + return res; + } + }, + getBackgroundAudioPlayerState: { + a: function a(res) { + _mapping(res, { + audioDataUrl: 'url', + describe: 'errorMessage' + }); + _handleResultSuccess(res, 12, 0); + return res; + } + } + + //////////////////////////// 未开放方法 ////////////////////////////// + + //numInput: {}, + //inputFocus: {}, + //inputBackFill: {}, + //numInputReset: {}, + //inputBlur: {}, + //downloadApp: {}, + //getSwitchControlStatus: {}, + //setToolbarMenu: {}, + + + //uploadImage: {}, ?apFilePath + //downloadImage: {}, ?apFilePath + //saveFile: {}, + //rpc: {}, + //startApp: {}, + //remoteLog: {}, + //getConfig: {}, + //getUserInfo: {}, + //setSharedData: {}, + //getSharedData: {}, + //removeSharedData: {}, + //setClipboard: {}, + //getClipboard: {}, + //login: {}, + //sendSMS: {}, + //isSupportShortCut: {}, + //setShortCut: {}, + //removeShortCut: {}, + //registerSync: {}, + //responseSyncNotify: {}, + //unregisterSync: {}, + //refreshSyncSkey: {}, + //getScreenBrightness: {}, + //setScreenBrightness: {}, + //isInstalledApp: {}, + //getAllContacts: {}, + //preRender: {}, + //finishRender: {}, + //clearRender: {}, + + + //setPullDownText: {}, + //hideTransBack: {}, + //limitAlert: {}, + //startPackage: {}, + //getClientInfo: {}, + //reportData: {}, + //getSceneStackInfo: {}, + //getAppInfo: {}, + //rsa: {}, + //shareToken: {}, + //snapshot: {}, + //getAppToken: {}, + //ping: {}, + //checkJSAPI: {}, + //checkApp: {}, + //commonList: {}, + //beehiveOptionsPicker: {}, + //beehiveGetPOI: {}, + //addEventCal: {}, + //removeEventCal: {}, + //speech: {}, + //selectAddress: {}, + //nfch5plugin: {}, + }; + /********************* AP 对象其他静态属性及同步方法 ************************/ + + //Alipay 缩写 + var AP = { + version: '3.1.1', + ua: _UA, + isAlipay: __inUA(/AlipayClient/), + alipayVersion: function () { + var version = _UA.match(/AlipayClient[a-zA-Z]*\/(\d+(?:\.\d+)+)/); + return version && version.length ? version[1] : ''; + }(), + /////////////////////////////// AP 同步方法 ///////////////////////////// + /** + * 版本比较 + * @method compareVersion + * @param {String} targetVersion ç›®æ ‡ç‰ˆæœ¬ + * @return {Number} 比较结果,1ä»£è¡¨å½“å‰ç‰ˆæœ¬å¤§äºŽç›®æ ‡ç‰ˆæœ¬ï¼Œ-1相反,相同为0 + */ + compareVersion: function compareVersion(targetVersion) { + var alipayVersion = AP.alipayVersion.split('.'); + + targetVersion = targetVersion.split('.'); + for (var i = 0, n1, n2; i < alipayVersion.length; i++) { + n1 = parseInt(targetVersion[i], 10) || 0; + n2 = parseInt(alipayVersion[i], 10) || 0; + if (n1 > n2) return -1; + if (n1 < n2) return 1; + } + return 0; + }, + + /** + * 获取 url ä¸Šçš„å…¨éƒ¨ä¼ å‚å¹¶è½¬æˆå¯¹è±¡ + * @method parseQueryString + * @param {String} queryString + * @return {Object} location.search 对应的键值对象 + */ + parseQueryString: function parseQueryString(queryString) { + var result = {}; + var searchStr = queryString || window.location.search; + var bool = { + true: true, + false: false + }; + var kv; + searchStr = searchStr.indexOf('?') === 0 ? searchStr.substr(1) : searchStr; + searchStr = searchStr ? searchStr.split('&') : ''; + for (var i = 0; i < searchStr.length; i++) { + kv = searchStr[i].split('='); + kv[1] = decodeURIComponent(kv[1]); + //Boolean + kv[1] = __isUndefined(bool[kv[1]]) ? kv[1] : bool[kv[1]]; + //Number + //kv[1] = +kv[1] + '' === kv[1] ? +kv[1] : kv[1]; + result[kv[0]] = kv[1]; + } + _apiRemoteLog('parseQueryString'); + return result; + }, + + /** + * 开启 debug 模式,控制台打印接口调用日志 + * @type {Object} + */ + enableDebug: function enableDebug() { + AP.debug = true; + }, + + + /** + * 绑定全局事件 + * @method on + * @param {String} evts äº‹ä»¶ç±»åž‹ï¼Œå¤šä¸ªäº‹ä»¶ç”¨ç©ºæ ¼åˆ†éš” + * @param {Function} fn 事件回调 + */ + on: function on(evts, fn) { + var isReady = evts === 'ready'; + var isSimple = isReady || evts === 'back'; + + if (isSimple) { + document.addEventListener(isReady ? _JS_BRIDGE_NAME + 'Ready' : evts, fn, false); + } else { + evts = evts.replace(/ready/, _JS_BRIDGE_NAME + 'Ready'); + evts.split(/\s+/g).forEach(function (eventName) { + document.addEventListener(eventName, fn, false); + }); + } + }, + + /** + * 移除事件监听 + * @method off + * @param {String} evt 事件类型 + * @param {Function} fn 事件回调 + */ + off: function off(evt, fn) { + document.removeEventListener(evt, fn, false); + }, + trigger: function trigger(evtName, data) { + var evt = document.createEvent('Events'); + evt.initEvent(evtName, false, true); + evt.data = data || {}; + document.dispatchEvent(evt); + return evt; + }, + + + /** + * ready事件独立方法 + * @method ready + * @param {Function} fn ready 回调 + */ + ready: function ready(fn) { + if (__isSupportPromise()) { + return new Promise(realReady); + } else { + realReady(); + } + + function realReady(resolve) { + if (_isBridgeReady()) { + if (__isFunction(fn)) { + fn(); + } + if (__isFunction(resolve)) { + resolve(); + } + } else { + AP.on('ready', function () { + //防止 jsbridge 晚注入 + _isBridgeReady(); + + if (__isFunction(fn)) { + fn(); + } + if (__isFunction(resolve)) { + resolve(); + } + }); + } + } + }, + + + + /** + * 通用接口,调用方式等同AlipayJSBridge.call + * æ— éœ€è€ƒè™‘readyäº‹ä»¶ï¼Œä¼šè‡ªåŠ¨åŠ å…¥åˆ°å¾…æ‰§è¡Œé˜Ÿåˆ— + * @method call + */ + call: function call() { + var args = __argumentsToArg(arguments); + if (__isSupportPromise()) { + return AP.ready().then(function () { + return new Promise(realCall); + }); + } else { + //å¦‚æžœç›´æŽ¥åŠ åˆ° ready 事件里会有不触发调用的情况 + //AP.ready(realCall); + + if (_isBridgeReady()) { + realCall(); + } else { + //保存在待执行队列 + _WAITING_QUEUE.push(args); + } + } + + function realCall(resolve, reject) { + var apiName; + var opt; //原始 option + var cb; //原始 callback + var _opt; //处理过的 option + var _cbSFC; //不同状态回调 + var _cb; //处理过的 callback + var onEvt; + var offEvt; + var doingFn; + var logOpt; + //强制转为 name + object + function 形式的入参 + apiName = args[0] + ''; + opt = args[1]; + cb = args[2]; + //处理 cb å’Œ opt 的顺序 + if (__isUndefined(cb) && __isFunction(opt)) { + cb = opt; + opt = {}; + } + //接口有非对象入参,设为快捷入参 + if (!__isObject(opt) && args.length >= 2) { + //before、doing、after 方法中直接取 opt._ 作为参数 + opt = { + _: opt + }; + } + //兜底 + if (__isUndefined(opt)) { + opt = {}; + } + + //处理入参 + _opt = _getApiOption(apiName, opt, cb); + + //获取回调 + _cbSFC = _getApiCallBacks(apiName, _opt); + + if (__isUndefined(_opt)) { + console.error('please confirm ' + apiName + '.before() returns the options.'); + } + //获取 api çš„ d 方法 + doingFn = _getApiDoing(apiName); + + //输出入参 + logOpt = __hasOwnProperty(opt, '_') ? opt._ : opt; + _apiLog(apiName, logOpt, _opt); + + //是否是事件监听 + onEvt = _getApiOnEvent(apiName); + //是否是事件移除 + offEvt = _getApiOffEvent(apiName); + + //处理回调 + _cb = function _cb(res) { + var _res = void 0; + res = res || {}; + + if (onEvt && _getApiExtra(apiName, 'handleEventData') !== false) { + _res = _handleEventData(res); + } + + //处理结果 + _res = _getApiResult(apiName, _res || res, _opt, opt, cb); + if (__isUndefined(_res)) { + console.error('please confirm ' + apiName + '.after() returns the result.'); + } + //å¤„ç†é”™è¯¯ç  + _res = _handleApiError(apiName, _res); + //打印 debug 日志 + _apiLog(apiName, logOpt, _opt, res, _res); + + if (__hasOwnProperty(_res, 'error') || __hasOwnProperty(_res, 'errorMessage')) { + if (__isFunction(reject)) { + reject(_res); + } + if (__isFunction(_cbSFC.fail)) { + _cbSFC.fail(_res); + } + } else { + if (__isFunction(resolve)) { + resolve(_res); + } + if (__isFunction(_cbSFC.success)) { + _cbSFC.success(_res); + } + } + if (__isFunction(_cbSFC.complete)) { + _cbSFC.complete(_res); + } + //执行用户的回调 + if (__isFunction(cb)) { + cb(_res); + } + }; + + //如果存在 d 直接执行,否则执行 AlipayJSBridge.call + if (__isFunction(doingFn)) { + doingFn(_opt, _cb, opt, cb); + } else if (onEvt) { + _cacheEventHandler(onEvt, cb, _cb, _cbSFC); + AP.on(onEvt, _cb); + } else if (offEvt) { + _removeEventHandler(offEvt, cb); + } else { + _JS_BRIDGE.call(_getApiName(apiName), _opt, _cb); + } + _apiRemoteLog(apiName); + } + }, + + /** + * 扩展 JSAPI 的接口 + */ + extendJSAPI: function extendJSAPI(JSAPI, isInitAP) { + //如果是字符串,直接当作接口名 + if (!isInitAP && __isString(JSAPI)) { + JSAPI = [JSAPI]; + } + __forEach(JSAPI, function (key) { + var apiName = key; + // å¦‚æžœæ˜¯åˆå§‹åŒ–è°ƒç”¨ï¼Œåˆ™æ— éœ€å†æ³¨å†Œåˆ° _JSAPI 对象上 + if (isInitAP !== true) { + var api = JSAPI[apiName]; + //如果接口定义是一个 function,即作为 doing 方法 + if (__isFunction(api)) { + api = { + doing: api + }; + } + if (__isString(api)) { + apiName = api; + api = {}; + api[apiName] = {}; + } + + _JSAPI[apiName] = _mapping(_JSAPI[apiName] || {}, { + mapping: 'm', + before: 'b', + doing: 'd', + after: 'a' + }, api); + + if (__isObject(api.extra)) { + _JSAPI[apiName].e = _JSAPI[apiName].e || {}; + _JSAPI[apiName].e = __extend(_JSAPI[apiName].e, api.extra); + } + } + + // TODO: 需要验证U3是否支持bind参数 + // AP[apiName] = AP.call.bind(null, apiName); + AP[apiName] = function () { + return AP.call.apply(null, [apiName].concat(__argumentsToArg(arguments))); + }; + }, true); + } + }; + AP.extendJSAPI.mapping = _mapping; + AP.extendJSAPI.toType = _toType; + + if (!AP.isAlipay) { + console.warn('Run ' + 'alipayjsapi' + '.js in ' + 'Alipay' + ' please!'); + } + /*********************** 注册异步 JSAPI ***********************/ + + (function () { + // å°† JSAPI 注册到 AP 上 + AP.extendJSAPI(_JSAPI, true); + //ready 入口 + AP.on('ready', function () { + if (!!_WAITING_QUEUE.length) { + next(); + } + function next() { + __raf(function () { + var args = _WAITING_QUEUE.shift(); + AP.call.apply(null, args); + if (_WAITING_QUEUE.length) next(); + }); + } + }); + })(); + /******************JSAPI 相关辅助处理方法 _ ********************/ + /** + * 是否ready + * @method _isBridgeReady + * @return {Boolean} 是否 可以调用 AlipayJSBridge.call + */ + function _isBridgeReady() { + _JS_BRIDGE = _JS_BRIDGE || self[_JS_BRIDGE_NAME]; + return _JS_BRIDGE && _JS_BRIDGE.call; + } + /** + * 获取缓存相关接口的 business + * @method _getStorageBusiness + * @return {String} business + */ + function _getStorageBusiness() { + var href = self && self.location && self.location.href ? self.location.href : ''; + var business = href.replace(/^(http|https):\/\//i, '').split('/')[0]; + return business; + } + /** + * 假回调,用于没有实现回调的接口 + * @param {Function} cb + * @param {Object} arg + */ + function _fakeCallBack(cb, arg) { + setTimeout(function () { + cb(arg); + }, 1); + } + /** + * 是否是 localId + * @method _isLocalId + * @param {String} localId 资源定位符 + * @return {Boolean} 是否 localId + */ + function _isLocalId(localId) { + return (/^[a-z0-9|]+$/i.test(localId) + ); + } + /** + * 是否是 apFilePath 地址 + * @method _isApFilePath + * @param {String} apFilePath 10.0.2新统一资源定位符 + * @return {Boolean} 是否 apFilePath + */ + // function _isApFilePath(apFilePath) { + // return /^https:\/\/resource\/[a-z0-9|]+\./i.test(apFilePath) + // } + + + /** + * 修复某个快捷入参是对象类型 + * @method _fixOptData + * @param {Object} opt 入参对象 + * @param {String} dataKey 快捷入参的 key + * @return {Object} 对象 + */ + function _fixOptData(opt, dataKey) { + var objectArg = false; + dataKey = dataKey || 'data'; + if (__hasOwnProperty(opt, '_')) { + //入参不是一个对象 + opt[dataKey] = opt._; + delete opt._; + } else { + //入参是一个对象,但可能有除了 data 外的其他 key + __forEach(opt, function (key) { + if (key !== dataKey) { + objectArg = true; + } + }); + if (objectArg) { + objectArg = opt; + opt = {}; + opt[dataKey] = objectArg; + } + } + return opt; + } + + /** + * 判断事件注册监听是否是同一个回调,并返回此回调函数 + * @method _getSameHandlers + * @param {String} evt 事件名 + * @param {Function} cb 相同回调函数 + * @return {Function / false} 是否是回调 + */ + function _getSameHandlers(evt, cb, isRemoveCache) { + var sameHandlers = false; + var sameIndex; + if (!__isUndefined(evt)) { + if (!_CACHE.EVENTS) { + _CACHE.EVENTS = {}; + } + if (!_CACHE.EVENTS[evt]) { + _CACHE.EVENTS[evt] = { + callbacks: [] + }; + } + if (!_CACHE.EVENTS[evt].callbacks) { + _CACHE.EVENTS[evt].callbacks = []; + } + + _CACHE.EVENTS[evt].callbacks.forEach(function (item, i) { + if (item.cb === cb) { + sameHandlers = item; + sameIndex = i; + } + }); + if (isRemoveCache && __isNumber(sameIndex)) { + _CACHE.EVENTS[evt].callbacks.splice(sameIndex, 1); + } + } + return sameHandlers; + } + + function _cacheEventHandler(evt, cb, _cb, _cbSFC) { + var sameCBs = _getSameHandlers(evt, cb); + if (!sameCBs) { + _CACHE.EVENTS[evt].callbacks.push({ + cb: cb, + _cb: _cb, + _cbSFC: _cbSFC + }); + } + } + + function _removeEventHandler(evt, cb) { + var handlers = _getSameHandlers(evt, cb, true); + if (!__isFunction(cb)) { + //移除全部通过 AP.onXXXX注册的监听 + _CACHE.EVENTS[evt].callbacks.forEach(function (item) { + AP.off(evt, item._cb); + }); + _CACHE.EVENTS[evt].callbacks = []; + } else if (handlers) { + AP.off(evt, handlers._cb); + } + } + + /** + * 获取要注册的事件类型 + * @method _getApiOnEvent + * @param {String} apiName API 名称 + * @return {String} 事件类型,如果不是事件类 API 就返回 false + */ + function _getApiOnEvent(apiName) { + return _getApiEvent('on', apiName); + } + + /** + * 获取要移除的事件类型 + * @method _getApiOffEvent + * @param {String} apiName 接口名 + * @return {String} 事件类型,如果不是事件类 API 就返回 false + */ + function _getApiOffEvent(apiName) { + return _getApiEvent('off', apiName); + } + + /** + * 获取事件名 + * @method _getApiEvent + * @param {String} prefix 前缀 + * @param {String} apiName 接口名 + * @return {String} 事件名 + */ + function _getApiEvent(prefix, apiName) { + var jsapi = _JSAPI[apiName]; + var evt = false; + var evtApiPattern = prefix === 'off' ? /^off([A-Z])(\w+)/ : /^on([A-Z])(\w+)/; + + // 以 on、off 开头的 api 是 事件,排除 AP.on、AP.off 方法 + if (jsapi && evtApiPattern.test(apiName)) { + apiName = apiName.match(evtApiPattern); + evt = jsapi.m; + if (!evt && apiName[1] && apiName[2]) { + evt = __tlc(apiName[1]) + apiName[2]; + } + } + return evt; + } + + /** + * 获取接口扩展字段 + * @method _getApiExtra + * @param {String} apiName 接口名 + * @param {String} extraKey 扩展字段的 key + * @return {Any} 返回相应字段值 + */ + function _getApiExtra(apiName, extraKey) { + var jsapi = _JSAPI[apiName] || {}; + var extra = jsapi.e || jsapi.extra || {}; + return extra[extraKey]; + } + /** + * 获取 opt._ï¼Œé€‚é…ç›´æŽ¥ä¼ å…¥æŸä¸ªå‚æ•°çš„åœºæ™¯ï¼Œå³è°ƒç”¨ api æ—¶ç¬¬äºŒä¸ªå‚æ•°ä¼ å…¥çš„ä¸æ˜¯ Object 的情况 + * @method _getObjArg + * @param {Object} opt AP.call 方法的 opt 入参 + * @return {any} 一般是 String,默认是 undefined + */ + // function _getObjArg(opt, optTarget) { + // var arg = optTarget; + // if (!__isUndefined(opt._)) { + // arg = opt._; + // delete opt._; + // } + // return arg; + // } + + /** + * 获取 JSAPI æ˜ å°„æŽ¥å£å + * @method _getApiName + * @param {String} apiName AP 接口名 + * @return {String} AlipayJSBridge 接口名 + */ + function _getApiName(apiName) { + var jsapi = _JSAPI[apiName]; + return jsapi && jsapi.m ? jsapi.m : apiName; + } + + /** + * 处理 JSAPI 的入参 + * @method _getApiOption + * @param {String} apiName JSAPI 名称 + * @param {Object} opt JSAPI 入参 + * @param {Function} cb JSAPI 未处理过的回调函数 + * @return {Object} 处理过的 opt + */ + function _getApiOption(apiName, opt, cb) { + var jsapi = _JSAPI[apiName]; + var finalOpt = jsapi && jsapi.b ? jsapi.b(__extend({}, opt), cb) : opt; + var modifier = _getApiExtra(apiName, 'optionModifier'); + if (__isFunction(modifier)) { + var modifyOpt = modifier(finalOpt, cb); + if (__isObject(modifyOpt)) { + finalOpt = modifyOpt; + } + } + + return finalOpt; + } + /** + * 获取不同状态回调 + * @method _getApiCallBacks + * @param {String} apiName 接口名 + * @param {Object} opt 接口入参 + * @return {Object} 回调对象 + */ + function _getApiCallBacks(apiName, opt) { + var cb = {}; + opt = opt || {}; + if (__isFunction(opt.success)) { + cb.success = opt.success; + delete opt.success; + } + if (__isFunction(opt.fail)) { + cb.fail = opt.fail; + delete opt.fail; + } + if (__isFunction(opt.complete)) { + cb.complete = opt.complete; + delete opt.complete; + } + return cb; + } + + /** + * 获取 API çš„ doing 函数 + * @method _getApiDoing + * @param {String} apiName API 名称 + * @return {function} doing 函数 + */ + function _getApiDoing(apiName) { + var jsapi = _JSAPI[apiName]; + return jsapi && jsapi.d ? jsapi.d : false; + } + + /** + * 处理 JSAPI 的出参 + * @method _getApiResult + * @param {String} apiName JSAPI 接口名 + * @param {Object} opt JSAPI 原始入参 + * @param {Object} _opt JSAPI before方法 处理过的入参 + * @param {Object} res JSAPI 出参 + * @param {Function} cb JSAPI 未处理过的回调函数 + * @return {Object} 处理过的 res + */ + function _getApiResult(apiName, res, _opt, opt, cb) { + var jsapi = _JSAPI[apiName]; + var finalRes = jsapi && jsapi.a ? jsapi.a(__isEvent(res) ? res : __extend({}, res), _opt, opt, cb) : __extend({}, res); + var modifier = _getApiExtra(apiName, 'resultModifier'); + if (__isFunction(modifier)) { + var modifyRes = modifier(finalRes, _opt, opt, cb); + if (__isObject(modifyRes)) { + finalRes = modifyRes; + } + } + return finalRes; + } + /** + * 处理错误信息,转换 error 字段为 Number 类型 + * @method _handleApiError + * @param {String} apiName 接口名 + * @param {Object} res 出参 + * @return {Object} 处理过的 res + */ + function _handleApiError(apiName, res) { + //é”™è¯¯ç å¼ºåˆ¶è½¬æˆæ•°å­— + if (__hasOwnProperty(res, 'error')) { + res.error = parseInt(res.error, 10); + } + //处理 success + if (_getApiExtra(apiName, 'handleResultSuccess') !== false) { + _handleResultSuccess(res); + } + //处理 error: 0 的情况,error 为 0 表示成功 + if (res.error === 0) { + delete res.error; + delete res.errorMessage; + } + + //有些 error 不代表接口异常,而是用户取消操作,不应该统一做报错日志。 + if (res.error > 0 && res.error < 10) { + console.error(apiName, res); + } + return res; + } + /** + * 处理结果中的 success 字段 + * @method _handleResultSuccess + * @param {Object} res 接口返回值 + * @param {Number} errorCode å¯¹åº”é”™è¯¯ç  + * @param {Any} successValue success字段处理值 + * @return {Object} 处理后的 result + */ + function _handleResultSuccess(res, mappingError, successValue) { + successValue = __isUndefined(successValue) ? false : successValue; + if (!__hasOwnProperty(res, 'error') && res.success === successValue) { + res.error = __isNumber(mappingError) ? mappingError : 2; //2 是参数错误 + } + delete res.success; + return res; + } + + //取到 data + function _handleEventData(evtObj) { + var data = {}; + if (!__isUndefined(evtObj.data)) { + data = evtObj.data; + data = __isObject(data) ? data : { data: data }; + } + return data; + } + + /** + * 拆分类型键名里真正的 key 和对应的 type + * @method _separateTypeKey + * @param {String} key å¸¦ç±»åž‹æ ‡è¯†çš„é”®å + * @return {Object} è¿”å›žé”®åå’Œç±»åž‹æ ‡è¯†ä¸¤ä¸ªå­—æ®µï¼Œ + * 如{k: 'content', t: '%s'} + */ + function _separateTypeKey(key) { + var matches = (key || '').match(/(\w+)(%\w)$/i); + var tk = { + k: key + }; + if (matches) { + tk.k = matches[1]; + tk.t = matches[2]; + } + return tk; + } + + /** + * 把值转换成相应类型 + * @method _toType + * @param {String} type ç±»åž‹æ ‡è¯†ï¼Œç›®å‰æ”¯æŒ + * %s(字符串) + * %c(16转10进制颜色) + * %h(10转16进制颜色) + * %b(移除 base64 æ•°æ®æ ¼å¼å¤´) + * %a{mimeType}(æ·»åŠ base64 数据头) + * %d(æ•´æ•°) + * %f(浮点数) + * @param {any} value 待转换值,类型未知 + * @return {any} 转换好的相应类型的 + */ + function _toType(type, value) { + if (type === '%s') value = __superToString(value); + if (type === '%c') value = __h2dColor(value); + //if (type === '%h') value = __d2hColor(value); + if (type === '%b') value = __removeBase64Head(value); + if (type === '%d') value = parseInt(value, 10); + if (type === '%f') value = parseFloat(value); + return value; + } + /** + * å¤„ç†å¯¹è±¡æ˜ å°„å…³ç³» + * @method _mapping + * @param {Object} tObj åŽŸå§‹ç›®æ ‡å¯¹è±¡ + * @param {Object} map æ˜ å°„å…³ç³»ï¼Œå¦‚{content: 'text'}, + * 即把 sObj.content 的值赋给 tObj.text, + * å¹¶åˆ é™¤ tObj çš„ content 属性, + * 所以 content 就是 sKey,text 就是 tKey。 + * 可以把 map 对象中的冒号(:)理解成 to, + * 即 {content to text}。 + * 其中 tKey çš„å€¼çš„æœ€åŽå¯ä»¥åŠ %s ç­‰ç±»åž‹æ ‡è¯†è½¬æ¢æˆç›¸åº”ç±»åž‹ï¼Œ + * æ³¨æ„ï¼šè¦åŠ åˆ°æœ€åŽèµ‹å€¼ç»™ tObj 的那个 tKey 的后面。 + * è¿™ä¹ˆåšæ˜¯å› ä¸ºï¼š + * æœ‰äº›æŽ¥å£çš„å…¥å‚å­—æ®µç›´æŽ¥ä¼ å…¥éžå­—ç¬¦ä¸²å€¼æ—¶ï¼ŒæŽ¥å£å®Œå…¨æ— å“åº”ï¼Œ + * 比如 AlipayJSBridge.call('alert',{message: 12345}) + * + * @param {Object} sObj 参照来源对象 + * @return {Object} å¤„ç†æ˜ å°„åŽçš„ tObj + */ + function _mapping(tObj, map, sObj) { + var typeKey; + sObj = sObj || {}; + __forEach(map, function (sKey, tKey) { + typeKey = _separateTypeKey(map[sKey]); + //ç›®æ ‡ key + tKey = typeKey.k; + //æ˜ å°„æ¡ä»¶ï¼Œå¦åˆ™ä¸èµ‹å€¼ï¼Œé¿å…æ·»åŠ value 为 undefined çš„ key + if (!__isUndefined(tKey) //ç›®æ ‡ key 定义过 + && (__hasOwnProperty(tObj, sKey) || __hasOwnProperty(sObj, sKey)) //源数据至少有一个有效 + && __isUndefined(tObj[tKey]) //ç›®æ ‡æ•°æ®ç©ºç¼ºå¾…èµ‹å€¼ + ) { + //sKey 既可以是 sObj 的,也可以是 tObj 自己的,但sObj 优先级高于原始 tObj + //即 sObj[sKey]的值 会覆盖 tObj[sKey]的值 + //å¹¶ä¸”è¦æ ¹æ® type å ä½ç¬¦åšç›¸åº”ç±»åž‹è½¬æ¢ + tObj[tKey] = _toType(typeKey.t, __isUndefined(sObj[sKey]) ? tObj[sKey] : sObj[sKey]); + // åˆ é™¤åŽŸå§‹ tObj 中的 sKey,tKey å’Œ sKey åŒåæ—¶ä¸åšåˆ é™¤ + if (tKey !== sKey) { + delete tObj[sKey]; + } + } + }); + return tObj; + } + /** + * ap 接口埋点 + * 保证队列里有调用记录时才启动计时器,做到不调用不计时 + * @param {String} apiName 接口名 + */ + var _apiRemoteLog = function () { + var apiInvokeQueue = []; + var timerId = void 0; + var isTimerActived = false; + //发送日志 + function triggerSendLog() { + setTimeout(function () { + if (apiInvokeQueue.length > 0) { + var param1 = apiInvokeQueue.join('|'); + AP.ready(function () { + _JS_BRIDGE.call('remoteLog', { + type: 'monitor', + bizType: 'ALIPAYJSAPI', + logLevel: 1, // 1 - high, 2 - medium, 3 - low + actionId: 'MonitorReport', + seedId: 'ALIPAYJSAPI_INVOKE_COUNTER', + param1: param1 + }); + }); + AP.debug && console.info('REMOTE_LOG_QUEUE>', apiInvokeQueue); + apiInvokeQueue = []; + } + // 停止计时器 + clearTimer(); + }, 0); + } + // 计时器 + function timer() { + // è®¡æ—¶æ¿€æ´»æ ‡è‡´ + isTimerActived = true; + // 启动计时器 + timerId = setTimeout(function () { + // 日志发送 + triggerSendLog(); + }, 5000); // 5 秒上报 + } + // 清除计时器 + function clearTimer() { + !__isUndefined(timerId) && clearTimeout(timerId); + isTimerActived = false; + } + // back 事件上报日志,作为兜底 + AP.on('back', function () { + triggerSendLog(); + }); + + return function (apiName) { + apiInvokeQueue.push(apiName); + // 6 个上报 + if (apiInvokeQueue.length >= 6) { + triggerSendLog(); + } else if (!isTimerActived) { + timer(); + } + }; + }(); + + function _apiLog() { + var args = __argumentsToArg(arguments); + var apiName; + var opt; + var _opt; + var res; + var _res; + var logs; + if (AP.debug) { + apiName = args[0]; + opt = args[1]; + _opt = args[2]; + res = args[3]; + _res = args[4]; + logs = [args.length > 3 ? 'RETURN>' : 'INVOKE>', apiName, __hasOwnProperty(opt, '_') ? opt._ : opt, _opt]; + if (args.length > 3) { + logs.push(res); + } + if (args.length > 4) { + logs.push(_res); + } + console.info(logs); + } + } + /****************** Util方法 __ ***********************/ + /** + * 是否在 UA 中包含某个字符串 + * @method _inUA + * @param {String} keyStr ç›®æ ‡å­—ç¬¦ä¸² + * @return {Boolean} 是否包含 + */ + function __inUA(keyPattern) { + return keyPattern.test(_UA); + } + /** + * 动画帧 + * @method raf + * @param {Function} fn 回调 + * @return {Function} requestAnimationFrame + */ + var __raf = function () { + return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || function (callback, element) { + window.setTimeout(function () { + callback(+new Date(), element); + }, 1000 / 60); + }; + }(); + /** + * 当前环境是否支持 Promise + * @method __supportPromise + * @return {Boolean} 是否支持 + */ + function __isSupportPromise() { + if (_IS_SUPPORT_PROMISE === undefined) { + var isSupport = false; + var P = self.Promise; + + if (P) { + var promise = null; + var then = null; + try { + promise = P.resolve(); + then = promise.then; + } catch (e) { + // silently ignored + } + if (promise instanceof P && __isFunction(then) && !P.cast) { + isSupport = true; + } + } + if (!isSupport) { + console.warn('try callback since no Promise detected'); + } + _IS_SUPPORT_PROMISE = isSupport; + } + return _IS_SUPPORT_PROMISE; + } + + /** + * 超级字符串转换 + * @method __superToString + * @param {Any} content 待转换内容 + * @return {String} 转换后的字符串 + */ + function __superToString(content) { + var str = content; + if (__isObject(content) || __isArray(content)) { + try { + str = JSON.stringify(content); + } catch (e) { + //静默 + } + } else { + str = content + ''; + } + return str; + } + + /** + * 16进制颜色转成10进制数字 + * @method __h2dColor + * @param {String} hex 16进制颜色字符串 + * @return {Number} 10进制数字 + */ + function __h2dColor(hex) { + var dec = '' + hex; + //å¦‚æžœåŠ äº†#号,去掉 + if (dec.indexOf('#') === 0) { + dec = dec.substr(1); + } + //如果是3位简写,补全成6位 + if (dec.length === 3) { + dec = dec.replace(/(.)/g, '$1$1'); + } + dec = parseInt(dec, 16); + if (__isNaN(dec)) { + console.error(hex + ' is invalid hex color.'); + } + return dec; + } + + /** + * 10进制数字转成16进制颜色 + * @method __d2hColor + * @param {Number} dec 10进制数字 + * @return {String} 16进制颜色字符串 + */ + // function __d2hColor(dec) { + // return '#' + dec.toString(16); + // } + /** + * native è¿”å›žçš„æ— å¤´ base64 æ•°æ®ï¼Œæ·»åŠ æµè§ˆå™¨è¯†åˆ«çš„ mimeType çš„ base64数据头 + * @method __addBase64Head + * @param {String} base64 æ— å¤´æ•°æ® + * @param {String} mimeType æ•°æ®æ ¼å¼ + * @return {String} 有头数据 + */ + function __addBase64Head(base64, mimeType) { + if (base64 && mimeType) { + base64 = 'data:' + mimeType + ';base64,' + base64; + } + return base64; + } + + /** + * 移除 base64 数据头,native æŽ¥å£ä¸éœ€è¦ä¼ å…¥å¤´éƒ¨ + * @method __removeBase64Head + * @param {String} base64 有头数据 + * @return {String} æ— å¤´æ•°æ® + */ + function __removeBase64Head(base64) { + if (__isString(base64)) { + base64 = base64.replace(/^data:(\/|\w|\-|\.)+;base64,/i, ''); + } + return base64; + } + + /** + * 把 json 转成 & 相连的请求参数 + * @method __toQueryString + * @param {Object} data key: value参数键值对 + * @return {String} queryString + */ + function __toQueryString(data) { + var result = []; + + __forEach(data, function (key, value) { + result.push(key + '=' + encodeURIComponent(__isUndefined(value) ? '' : value)); + }); + result = result.join('&'); + // var limits = [1024, 2048]; + // var notice; + // notice = 'query string length has more than %d,please use setSessionData interface'; + // if (result.length > limits[1]) { + // console.warn(notice, limits[1]); + // } else if (result.length > limits[0]) { + // console.warn(notice, limits[0]); + // } + return result; + } + + /** + * æž„é€ å¸¦å‚çš„å®Œæ•´ url + * @method __buildUrl + * @param {String} url 原始 url,可能已经有 queryString + * @param {Object} params url 参数对象 + * @return {String} 拼接好的带参 url + */ + function __buildUrl(url, params) { + var qs = params; + if (__isObject(params)) { + qs = __toQueryString(params); + } + if (!/\?/.test(url)) { + qs = '?' + qs; + } else if (!/&$/.test(url) && !/\?$/.test(url)) { + qs = '&' + qs; + } + return url + qs; + } + /** + * 一个对象是否含有某个 key + * @method __hasOwnProperty + * @param {Object} obj 对象或数组 + * @param {String} key 键值 + * @return {Boolean} 是否含有此键值 + */ + function __hasOwnProperty(obj, key) { + if (__isObject(obj) || __isArray(obj)) { + return obj.hasOwnProperty(key); + } + return false; + } + /** + * 遍历对象 + * @method __forEach + * @param {Object} obj 待遍历对象或数组 + * @param {Function} cb 每个 key 的回调 + * 回调入参是 key 和对应的 value + */ + function __forEach(obj, cb, notArray) { + var i; + var key; + if (!notArray && __likeArray(obj)) { + for (i = 0; i < obj.length; i++) { + if (cb(i, obj[i]) === false) { + return obj; + } + } + } else { + for (key in obj) { + if (cb(key, obj[key]) === false) { + return obj; + } + } + } + return obj; + } + /** + * 解析 JSON + * @method __parseJSON + * @param {String} str JSON 字符串 + * @return {Object} JSON 对象 + */ + function __parseJSON(str) { + try { + str = JSON.parse(str); + } catch (err) { + console.warn(err, str); + } + return str; + } + + /** + * 转成小写字母 + * @method __tlc + * @param {String} str 待转换字符串 + * @return {String} 小写字符串 + */ + function __tlc(str) { + if (__isString(str)) { + str = str.toLowerCase(); + } + return str; + } + + /** + * 转成大写字母 + * @method __tuc + * @param {String} str 待转换字符串 + * @return {String} 大写字符串 + */ + function __tuc(str) { + if (__isString(str)) { + str = str.toUpperCase(); + } + return str; + } + + function __isAndroid() { + return __inUA(/android/i); + } + + function __isIOS() { + return __inUA(/iPad|iPod|iPhone|iOS/i); + } + + function __isUndefined(o) { + return __type_original(o) === '[object Undefined]'; + } + + function __isNull(o) { + return __type_original(o) === '[object Null]'; + } + + function __isNaN(num) { + return parseInt(num, 10).toString() === 'NaN'; + } + function __isBoolean(val) { + return typeof val === 'boolean'; + } + + function __isFunction(fn) { + return __type_original(fn) === '[object Function]'; + } + + function __isString(str) { + return typeof str === 'string'; + } + + function __isObject(o) { + return __type_original(o) === '[object Object]'; + } + + function __isNumber(num) { + // 如果用typeof number 会生成SymbolPolyfill + return __type_original(num) === '[object Number]'; + } + + function __isArray(arr) { + return __type_original(arr) === '[object Array]'; + } + + function __likeArray(obj) { + return !!obj && !__isFunction(obj) && (__isArray(obj) || __isNumber(obj.length)); + } + function __isEvent(evt) { + return __type_original(evt) === '[object Event]'; + } + + function __type_original(obj) { + return Object.prototype.toString.call(obj); + } + + function __isEmptyObject(obj) { + for (var name in obj) { + return false; + } + return true; + } + + function __argumentsToArg(_arguments) { + var _startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + + var len = _arguments.length - _startIndex; + var arg = new Array(len); + for (var i = 0; i < len; i++) { + arg[i] = _arguments[i + _startIndex]; + } + return arg; + } + + /** + * 对象扩展 + * @method __extend + * @param {Object} obj 原始对象 + * @param {Object} args 多个继承对象 + * @return {Object} 扩展后对象 + */ + function __extend(obj) { + var args = __argumentsToArg(arguments, 1); + var source; + var prop; + if (!__isObject(obj)) { + return obj; + } + for (var i = 0, length = args.length; i < length; i++) { + source = args[i]; + for (prop in source) { + if (hasOwnProperty.call(source, prop)) { + obj[prop] = source[prop]; + } + } + } + return obj; + } + + /***************** 输出 AP 对象 *******************/ + self._AP = AP; + + if (typeof module !== 'undefined' && module.exports) { + // 兼容 CommonJS + module.exports = AP; + } else if (typeof define === 'function' && (define.amd || define.cmd)) { + // 兼容 AMD / RequireJS / seaJS + define(function () { + return AP; + }); + } else { + // å¦‚æžœä¸ä½¿ç”¨æ¨¡å—åŠ è½½å™¨åˆ™è‡ªåŠ¨ç”Ÿæˆå…¨å±€å˜é‡ + self.ap = self.AP = AP; + } +})(self); \ No newline at end of file diff --git a/uni_modules/lime-painter/changelog.md b/uni_modules/lime-painter/changelog.md new file mode 100644 index 0000000..65a6dd9 --- /dev/null +++ b/uni_modules/lime-painter/changelog.md @@ -0,0 +1,203 @@ +## 1.9.5.7(2023-07-27) +- fix: 去掉多余的方法 +- chore: 更新文档,增加自定义字体说明 +## 1.9.5.6(2023-07-21) +- feat: 有限的支持富文本 +- feat: H5和APP 增加 `hidpi` prop,主要用于大尺寸无法生成图片时用 +- fix: 修复 钉钉小程序 缺少 `measureText` 方法 +- chore: 由于微信小程序 pc 端的 canvas 2d 时不时抽风,故不使用canvas 2d +## 1.9.5.5(2023-06-27) +- fix: 修复把`emoji`表情字符拆分成多个字符的情况 +## 1.9.5.4(2023-06-05) +- fix: 修复因`canvasToTempFilePathSync`监听导致重复调用 +## 1.9.5.3(2023-05-23) +- fix: 因isPc错写成了isPC导致小程序PC不能生成图片 +## 1.9.5.2(2023-05-22) +- feat: 删除多余文件 +## 1.9.5.1(2023-05-22) +- fix: 修复 文字行数与`line-clamp`相同但不满一行时也加了省略号的问题 +## 1.9.5(2023-05-14) +- feat: 增加 `text-indent` 和 `calc` 方法 +- feat: 优化 布局时间 +## 1.9.4.4(2023-04-15) +- fix: 修复无法匹配负值 +- fix: 修复 Nvue IOS getImageInfo `useCORS` 为 undefined +## 1.9.4.3(2023-04-01) +- feat: 增加支持文字描边 `text-stroke: '5rpx #fff'` +## 1.9.4.2(2023-03-30) +- fix: 修复 支付宝小程序 isPC 在手机也为true的问题 +- feat: 由 微信开发工具 3060 版 无法获取图片尺寸,现 微信开发工具 3220 版 修复该问题,故还原上一版的获取图片方式。 +## 1.9.4.1(2023-03-28) +- fix: 修复固定高度不正确问题 +## 1.9.4(2023-03-17) +- fix: nvue ios getImageInfo缺少this报错 +- fix: pathType 非2d无效问题 +- fix: 修复 小米9se 可能会存在多次init 导致画面多次放大 +- fix: 修复 border 分开写 width style无效问题 +- fix: 修复 支付宝小程序IOS 再次进入不渲染的问题 +- fix: 修复 支付宝小程序安卓Zindex排序错乱问题 +- fix: 修复 微信开发工具 3060 版 无法获取图片的问题 +- feat: 把 for in 改为 forEach +- feat: 增加 hidden +- feat: 根节点 box-sizing 默认 `border-box` +- feat: 增加支持 `vw` `wh` +- chore: pathType 取消 默认值,因为字节开发工具不能显示 +- chore: 支付宝小程序开发工具不支持 生成图片 请以真机调试为准 +- bug: 企业微信 2.20.3无法使用 +## 1.9.3.5(2022-06-29) +- feat: justifyContent 增加 `space-around`、`space-between` +- feat: canvas 2d 也使用`getImageInfo` +- fix: 修复 `text`的 `text-decoration`错位 +## 1.9.3.4(2022-06-20) +- fix: 修复 因创建节点速度问题导致顺序出错。 +- fix: 修复 微信小程序 PC 无法显示本地图片 +- fix: 修复 flex-box 对齐问题 +- feat: 增加 `text-shadow` +- feat: 重写 `text` 对齐方式 +- chore: 更新文档 +## 1.9.3.3(2022-06-17) +- fix: 修复 支付宝小程序 canvas 2d 存在ctx.draw问题导致报错 +- fix: 修复 支付宝小程序 toDataURL 存在权限问题改用 `toTempFilePath` +- fix: 修复 支付宝小程序 image size 问题导致 `objectFit` 无效 +## 1.9.3.2(2022-06-14) +- fix: 修复 image 设置背景色不生效问题 +- fix: 修复 nvue 环境判断缺少参数问题 +## 1.9.3.1(2022-06-14) +- fix: 修复 bottom 定位不对问题 +- fix: 修复 因小数导致计算出错换行问题 +- feat: 增加 `useCORS` h5端图片跨域 在设置请求头无效果后试一下设置这个值 +- chore: 更新文档 +## 1.9.3(2022-06-13) +- feat: 增加 `zIndex` +- feat: 增加 `flex-box` 该功能处于原始阶段,非常简陋。 +- tips: QQ小程序 vue3 不支持, 为 uni 官方BUG +## 1.9.2.9(2022-06-10) +- fix: 修复`text-align`及`margin`居中问题 +## 1.9.2.8(2022-06-10) +- fix: 修复 Nvue `canvasToTempFilePathSync` 不生效问题 +## 1.9.2.7(2022-06-10) +- fix: 修复 margin及padding的bug +- fix: 修复 Nvue `isCanvasToTempFilePath` 不生效问题 +## 1.9.2.6(2022-06-09) +- fix: 修复 Nvue 不显示 +- feat: 增加支持字体渐变 +```html + +``` +## 1.9.2.5(2022-06-09) +- chore: 更变获取父级宽度的设定 +- chore: `pathType` 在canvas 2d 默认为 `url` +## 1.9.2.4(2022-06-08) +- fix: 修复 `pathType` 不生效问题 +## 1.9.2.3(2022-06-08) +- fix: 修复 `canvasToTempFilePath` 漏写 `success` 参数 +## 1.9.2.2(2022-06-07) +- chore: 更新文档 +## 1.9.2.1(2022-06-07) +- fix: 修复 vue3 赋值给this再传入导致image无法绘制 +- fix: 修复 `canvasToTempFilePathSync` 时机问题 +- feat: canvas 2d 更改图片生成方式 `toDataURL` +## 1.9.2(2022-05-30) +- fix: 修复 `canvasToTempFilePathSync` 在 vue3 下只生成一次 +## 1.9.1.7(2022-05-28) +- fix: 修复 `qrcode`显示不全问题 +## 1.9.1.6(2022-05-28) +- fix: 修复 `canvasToTempFilePathSync` 会重复多次问题 +- fix: 修复 `view` css `backgroundImage` 图片下载失败导致 子节点不渲染 +## 1.9.1.5(2022-05-27) +- fix: 修正支付宝小程序 canvas 2d版本号 2.7.15 +## 1.9.1.4(2022-05-22) +- fix: 修复字节小程序无法使用xml方式 +- fix: 修复字节小程序无法使用base64(非2D情况下工具上无法显示) +- fix: 修复支付宝小程序 `canvasToTempFilePath` 报错 +## 1.9.1.3(2022-04-29) +- fix: 修复vue3打包后uni对象为空后的报错 +## 1.9.1.2(2022-04-25) +- fix: 删除多余文件 +## 1.9.1.1(2022-04-25) +- fix: 修复图片不显示问题 +## 1.9.1(2022-04-12) +- fix: 因四舍五入导致有些机型错位 +- fix: 修复无views报错 +- chore: nvue下因ios无法读取插件内static文件,改由下载方式 +## 1.9.0(2022-03-20) +- fix: 因无法固定尺寸导致生成图片不全 +- fix: 特定情况下text判断无效 +- chore: 本地化APP Nvue webview +## 1.8.9(2022-02-20) +- fix: 修复 小程序下载最多10次并发的问题 +- fix: 修复 APP端无法获取本地图片 +- fix: 修复 APP Nvue端不执行问题 +- chore: 增加图片缓存机制 +## 1.8.8.8(2022-01-27) +- fix: 修复 主动调用尺寸问题 +## 1.8.8.6(2022-01-26) +- fix: 修复 nvue 下无宽度时获取父级宽度 +- fix: 修复 ios app 无法渲染问题 +## 1.8.8(2022-01-23) +- fix: 修复 主动调用时无节点问题 +- fix: 修复 `box-shadow` 颜色问题 +- fix: 修复 `transform:rotate` 角度位置问题 +- feat: 增加 `overflow:hidden` +## 1.8.7(2022-01-07) +- fix: 修复 image 方向为 `right` 时原始宽高问题 +- feat: 支持 view 设置背景图 `background-image: url(xxx)` +- chore: 去掉可选链 +## 1.8.6(2021-11-28) +- feat: 支持`view`对`inline-block`的子集使用`text-align` +## 1.8.5.5(2021-08-17) +- chore: 更新文档,删除 replace +- fix: 修复 text 值为 number时报错 +## 1.8.5.4(2021-08-16) +- fix: 字节小程序兼容 +## 1.8.5.3(2021-08-15) +- fix: 修复线性渐变与css现实效果不一致的问题 +- chore: 更新文档 +## 1.8.5.2(2021-08-13) +- chore: 增加`background-image`、`background-repeat` 能力,主要用于背景纹理的绘制,并不是代替`image`。例如:大面积的重复平铺的水印 +- 注意:这个功能H5暂时无法使用,因为[官方的API有BUG](https://ask.dcloud.net.cn/question/128793),待官方修复!!! +## 1.8.5.1(2021-08-10) +- fix: 修复因`margin`报错问题 +## 1.8.5(2021-08-09) +- chore: 增加margin支持`auto`,以达到居中效果 +## 1.8.4(2021-08-06) +- chore: 增加判断缓存文件条件 +- fix: 修复css 多余空格报错问题 +## 1.8.3(2021-08-04) +- tips: 1.6.x 以下的版本升级到1.8.x后要为每个元素都加上定位:position: 'absolute' +- fix: 修复只有一个view子元素时不计算高度的问题 +## 1.8.2(2021-08-03) +- fix: 修复 path-type 为 `url` 无效问题 +- fix: 修复 qrcode `text` 为空时报错问题 +- fix: 修复 image `src` 动态设置时不生效问题 +- feat: 增加 css 属性 `min-width` `max-width` +## 1.8.1(2021-08-02) +- fix: 修复无法加载本地图片 +## 1.8.0(2021-08-02) +- chore 文档更新 +- 使用旧版的同学不要升级! +## 1.8.0-beta(2021-07-30) +- ## 全新布局方式 不兼容旧版! +- chore: 布局方式变更 +- tips: 微信canvas 2d 不支持真机调试 +## 1.6.6(2021-07-09) +- chore: 统一命名规范,无须主动引入组件 +## 1.6.5(2021-06-08) +- chore: 去掉console +## 1.6.4(2021-06-07) +- fix: 修复 数字 为纯字符串时不转换的BUG +## 1.6.3(2021-06-06) +- fix: 修复 PC 端放大的BUG +## 1.6.2(2021-05-31) +- fix: 修复 报`adaptor is not a function`错误 +- fix: 修复 text 多行高度 +- fix: 优化 默认文字的基准线 +- feat: `@progress`事件,监听绘制进度 +## 1.6.1(2021-02-28) +- 删除多余节点 +## 1.6.0(2021-02-26) +- 调整为uni_modules目录规范 +- 修复:transform的rotate不能为负数问题 +- 新增:`pathType` 指定生成图片返回的路径类型,可选值有 `base64`、`url` diff --git a/uni_modules/lime-painter/components/common/relation.js b/uni_modules/lime-painter/components/common/relation.js new file mode 100644 index 0000000..6ed37e8 --- /dev/null +++ b/uni_modules/lime-painter/components/common/relation.js @@ -0,0 +1,150 @@ +const styles = (v ='') => v.split(';').filter(v => v && !/^[\n\s]+$/.test(v)).map(v => { + const key = v.slice(0, v.indexOf(':')) + const value = v.slice(v.indexOf(':')+1) + return { + [key + .replace(/-([a-z])/g, function() { return arguments[1].toUpperCase()}) + .replace(/\s+/g, '') + ]: value.replace(/^\s+/, '').replace(/\s+$/, '') || '' + } + }) +export function parent(parent) { + return { + provide() { + return { + [parent]: this + } + }, + data() { + return { + el: { + id: null, + css: {}, + views: [] + }, + } + }, + watch: { + css: { + handler(v) { + if(this.canvasId) { + this.el.css = (typeof v == 'object' ? v : v && Object.assign(...styles(v))) || {} + this.canvasWidth = this.el.css && this.el.css.width || this.canvasWidth + this.canvasHeight = this.el.css && this.el.css.height || this.canvasHeight + } + }, + immediate: true + } + } + } +} +export function children(parent, options = {}) { + const indexKey = options.indexKey || 'index' + return { + inject: { + [parent]: { + default: null + } + }, + watch: { + el: { + handler(v, o) { + if(JSON.stringify(v) != JSON.stringify(o)) + this.bindRelation() + }, + deep: true, + immediate: true + }, + src: { + handler(v, o) { + if(v != o) + this.bindRelation() + }, + immediate: true + }, + text: { + handler(v, o) { + if(v != o) this.bindRelation() + }, + immediate: true + }, + css: { + handler(v, o) { + if(v != o) + this.el.css = (typeof v == 'object' ? v : v && Object.assign(...styles(v))) || {} + }, + immediate: true + }, + replace: { + handler(v, o) { + if(JSON.stringify(v) != JSON.stringify(o)) + this.bindRelation() + }, + deep: true, + immediate: true + } + }, + created() { + if(!this._uid) { + this._uid = this._.uid + } + Object.defineProperty(this, 'parent', { + get: () => this[parent] || [], + }) + Object.defineProperty(this, 'index', { + get: () => { + this.bindRelation(); + const {parent: {el: {views=[]}={}}={}} = this + return views.indexOf(this.el) + }, + }); + this.el.type = this.type + if(this.uid) { + this.el.uid = this.uid + } + this.bindRelation() + }, + // #ifdef VUE3 + beforeUnmount() { + this.removeEl() + }, + // #endif + // #ifdef VUE2 + beforeDestroy() { + this.removeEl() + }, + // #endif + methods: { + removeEl() { + if (this.parent) { + this.parent.el.views = this.parent.el.views.filter( + (item) => item._uid !== this._uid + ); + } + }, + bindRelation() { + if(!this.el._uid) { + this.el._uid = this._uid + } + if(['text','qrcode'].includes(this.type)) { + this.el.text = this.$slots && this.$slots.default && this.$slots.default[0].text || `${this.text || ''}`.replace(/\\n/g, '\n') + } + if(this.type == 'image') { + this.el.src = this.src + } + if (!this.parent) { + return; + } + let views = this.parent.el.views || []; + if(views.indexOf(this.el) !== -1) { + this.parent.el.views = views.map(v => v._uid == this._uid ? this.el : v) + } else { + this.parent.el.views = [...views, this.el]; + } + } + }, + mounted() { + // this.bindRelation() + }, + } +} \ No newline at end of file diff --git a/uni_modules/lime-painter/components/l-painter-image/l-painter-image.vue b/uni_modules/lime-painter/components/l-painter-image/l-painter-image.vue new file mode 100644 index 0000000..e24e3aa --- /dev/null +++ b/uni_modules/lime-painter/components/l-painter-image/l-painter-image.vue @@ -0,0 +1,28 @@ + + + + + diff --git a/uni_modules/lime-painter/components/l-painter-qrcode/l-painter-qrcode.vue b/uni_modules/lime-painter/components/l-painter-qrcode/l-painter-qrcode.vue new file mode 100644 index 0000000..a73e5ed --- /dev/null +++ b/uni_modules/lime-painter/components/l-painter-qrcode/l-painter-qrcode.vue @@ -0,0 +1,27 @@ + + + + + diff --git a/uni_modules/lime-painter/components/l-painter-text/l-painter-text.vue b/uni_modules/lime-painter/components/l-painter-text/l-painter-text.vue new file mode 100644 index 0000000..26abbc4 --- /dev/null +++ b/uni_modules/lime-painter/components/l-painter-text/l-painter-text.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/uni_modules/lime-painter/components/l-painter-view/l-painter-view.vue b/uni_modules/lime-painter/components/l-painter-view/l-painter-view.vue new file mode 100644 index 0000000..a3fbc01 --- /dev/null +++ b/uni_modules/lime-painter/components/l-painter-view/l-painter-view.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/uni_modules/lime-painter/components/l-painter/l-painter.vue b/uni_modules/lime-painter/components/l-painter/l-painter.vue new file mode 100644 index 0000000..ef47270 --- /dev/null +++ b/uni_modules/lime-painter/components/l-painter/l-painter.vue @@ -0,0 +1,445 @@ + + + + diff --git a/uni_modules/lime-painter/components/l-painter/nvue.js b/uni_modules/lime-painter/components/l-painter/nvue.js new file mode 100644 index 0000000..ff58f1c --- /dev/null +++ b/uni_modules/lime-painter/components/l-painter/nvue.js @@ -0,0 +1,190 @@ +// #ifdef APP-NVUE +import { sleep, getImageInfo, isBase64, useNvue, networkReg } from './utils'; +const dom = weex.requireModule('dom') +import { version } from '../../package.json' + +export default { + data() { + return { + tempFilePath: [], + isInitFile: false, + osName: uni.getSystemInfoSync().osName + } + }, + methods: { + getParentWeith() { + return new Promise(resolve => { + dom.getComponentRect(this.$refs.limepainter, (res) => { + this.parentWidth = Math.ceil(res.size.width) + this.canvasWidth = this.canvasWidth || this.parentWidth ||300 + this.canvasHeight = res.size.height || this.canvasHeight||150 + resolve(res.size) + }) + }) + }, + onPageFinish() { + this.webview = this.$refs.webview + this.webview.evalJS(`init(${this.dpr})`) + }, + onMessage(e) { + const res = e.detail.data[0] || null; + if (res.event) { + if (res.event == 'inited') { + this.inited = true + } + if(res.event == 'fail'){ + this.$emit('fail', res) + } + if (res.event == 'layoutChange') { + const data = typeof res.data == 'string' ? JSON.parse(res.data) : res.data + this.canvasWidth = Math.ceil(data.width); + this.canvasHeight = Math.ceil(data.height); + } + if (res.event == 'progressChange') { + this.progress = res.data * 1 + } + if (res.event == 'file') { + this.tempFilePath.push(res.data) + if (this.tempFilePath.length > 7) { + this.tempFilePath.shift() + } + return + } + if (res.event == 'success') { + if (res.data) { + this.tempFilePath.push(res.data) + if (this.tempFilePath.length > 8) { + this.tempFilePath.shift() + } + if (this.isCanvasToTempFilePath) { + this.setFilePath(this.tempFilePath.join(''), {isEmit:true}) + } + } else { + this.$emit('fail', 'canvas no data') + } + return + } + this.$emit(res.event, JSON.parse(res.data)); + } else if (res.file) { + this.file = res.data; + } else{ + console.info(res[0]) + } + }, + getWebViewInited() { + if (this.inited) return Promise.resolve(this.inited); + return new Promise((resolve) => { + this.$watch( + 'inited', + async val => { + if (val) { + resolve(val) + } + }, { + immediate: true + } + ); + }) + }, + getTempFilePath() { + if (this.tempFilePath.length == 8) return Promise.resolve(this.tempFilePath) + return new Promise((resolve) => { + this.$watch( + 'tempFilePath', + async val => { + if (val.length == 8) { + resolve(val.join('')) + } + } + ); + }) + }, + getWebViewDone() { + if (this.progress == 1) return Promise.resolve(this.progress); + return new Promise((resolve) => { + this.$watch( + 'progress', + async val => { + if (val == 1) { + this.$emit('done') + this.done = true + resolve(val) + } + }, { + immediate: true + } + ); + }) + }, + async render(args) { + try { + await this.getSize(args) + const {width} = args.css || args + if(!width && this.parentWidth) { + Object.assign(args, {width: this.parentWidth}) + } + const newNode = await this.calcImage(args); + await this.getWebViewInited() + this.webview.evalJS(`source(${JSON.stringify(newNode)})`) + await this.getWebViewDone() + await sleep(this.afterDelay) + if (this.isCanvasToTempFilePath) { + const params = { + fileType: this.fileType, + quality: this.quality + } + this.webview.evalJS(`save(${JSON.stringify(params)})`) + } + return Promise.resolve() + } catch (e) { + this.$emit('fail', e) + } + }, + async calcImage(args) { + let node = JSON.parse(JSON.stringify(args)) + const urlReg = /url\((.+)\)/ + const {backgroundImage} = node.css||{} + const isBG = backgroundImage && urlReg.exec(backgroundImage)[1] + const url = node.url || node.src || isBG + if(['text', 'qrcode'].includes(node.type)) { + return node + } + if ((node.type === "image" || isBG) && url && !isBase64(url) && (this.osName == 'ios' || !networkReg.test(url))) { + let {path} = await getImageInfo(url, true) + if (isBG) { + node.css.backgroundImage = `url(${path})` + } else { + node.src = path + } + } else if (node.views && node.views.length) { + for (let i = 0; i < node.views.length; i++) { + node.views[i] = await this.calcImage(node.views[i]) + } + } + return node + }, + async canvasToTempFilePath(args = {}) { + if (!this.inited) { + return this.$emit('fail', 'no init') + } + this.tempFilePath = [] + if (args.fileType == 'jpg') { + args.fileType = 'jpeg' + } + this.webview.evalJS(`save(${JSON.stringify(args)})`) + try { + let tempFilePath = await this.getTempFilePath() + tempFilePath = await this.setFilePath(tempFilePath, args) + args.success({ + errMsg: "canvasToTempFilePath:ok", + tempFilePath + }) + } catch (e) { + args.fail({ + error: e + }) + } + } + } +} +// #endif \ No newline at end of file diff --git a/uni_modules/lime-painter/components/l-painter/painter.js b/uni_modules/lime-painter/components/l-painter/painter.js new file mode 100644 index 0000000..e430fe7 --- /dev/null +++ b/uni_modules/lime-painter/components/l-painter/painter.js @@ -0,0 +1 @@ +var t=function(){return(t=Object.assign||function(t){for(var e,i=1,n=arguments.length;i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=360&&(s-=360);s<0&&(s+=360);if(0===(s=Math.round(s)))return{x0:Math.round(e/2)+n,y0:i+r,x1:Math.round(e/2)+n,y1:r};if(180===s)return{x0:Math.round(e/2)+n,y0:r,x1:Math.round(e/2)+n,y1:i+r};if(90===s)return{x0:n,y0:Math.round(i/2)+r,x1:e+n,y1:Math.round(i/2)+r};if(270===s)return{x0:e+n,y0:Math.round(i/2)+r,x1:n,y1:Math.round(i/2)+r};var a=Math.round(180*Math.asin(e/Math.sqrt(Math.pow(e,2)+Math.pow(i,2)))/Math.PI);if(s===a)return{x0:n,y0:i+r,x1:e+n,y1:r};if(s===180-a)return{x0:n,y0:r,x1:e+n,y1:i+r};if(s===180+a)return{x0:e+n,y0:r,x1:n,y1:i+r};if(s===360-a)return{x0:e+n,y0:i+r,x1:n,y1:r};var h=0,d=0,l=0,c=0;if(s180-a&&s<180||s>180&&s<180+a||s>360-a){var f=s*Math.PI/180,u=s360-a?i/2:-i/2,p=Math.tan(f)*u,g=s180-a&&s<180?e/2-p:-e/2-p;h=-(l=p+(v=Math.pow(Math.sin(f),2)*g)),d=-(c=u+v/Math.tan(f))}if(s>a&&s<90||s>90&&s<90+a||s>180+a&&s<270||s>270&&s<360-a){var v;f=(90-s)*Math.PI/180,p=s>a&&s<90||s>90&&s<90+a?e/2:-e/2,u=Math.tan(f)*p,g=s>a&&s<90||s>270&&s<360-a?i/2-u:-i/2-u;h=-(l=p+(v=Math.pow(Math.sin(f),2)*g)/Math.tan(f)),d=-(c=u+v)}return h=Math.round(h+e/2)+n,d=Math.round(i/2-d)+r,l=Math.round(l+e/2)+n,c=Math.round(i/2-c)+r,{x0:h,y0:d,x1:l,y1:c}}(r,t,e,i,n),a=s.x0,h=s.y0,d=s.x1,l=s.y1,c=o.createLinearGradient(a,h,d,l),f=r.match(/linear-gradient\((.+)\)/)[1],u=R(f.substring(f.indexOf(",")+1)),p=0;pt.length)&&(e=t.length);for(var i=0,n=new Array(e);i=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function H(t){return"number"==typeof t}function D(t){return"auto"===t||null===t}function Y(t){return/%$/.test(t)}var $=g,U=p,N=u,X=v,_=x,q=m,G=S;function V(t){return t.replace(/-([a-z])/g,(function(t,e){return e.toUpperCase()}))}function J(t,e){var i,n,r=function(t){var e=t.match(/([a-z]+)/)[1];return[e,V(t.split(e)[1])]}(t),s=r[0],a=r[1],h=e.split(" ");if(a)return(i={})[s+a]=e,i;if(h.length&&!a){var d=h[0],l=h[1],c=h[2],f=h[3];return(n={})[s+o[0]]=d,n[s+o[1]]=l||d,n[s+o[2]]=c||d,n[s+o[3]]=f||l||d,n}}function Q(t){t=t.trim();for(var e=new Array,i="+",n="",r=t.length,o=0;o0;)"("===t[a+=1]&&(s+=1),")"===t[a]&&(s-=1);n=""+Q(t.slice(o+1,a)),o=a}if(isNaN(Number(t[o]))&&"."!==t[o]||o===r-1){var h=parseFloat(n);switch(i){case"+":e.push(h);break;case"-":e.push(-h);break;case"*":e.push(e.pop()*h);break;case"/":e.push(e.pop()/h)}i=t[o],n=""}}for(var d=0;e.length;)d+=e.pop();return d}var Z,K=0,et=function(){function t(){F(this,"elements",[]),F(this,"afterElements",[]),F(this,"beforeElements",[]),F(this,"ids",[]),F(this,"width",0),F(this,"height",0),F(this,"top",0),F(this,"left",0),F(this,"pre",null),F(this,"offsetX",0),F(this,"offsetY",0),K++,this.id=K}var e=t.prototype;return e.fixedBind=function(t,e){void 0===e&&(e=0),this.container=e?t.parent:t.root,this.container.fixedLine=this,this.fixedAdd(t)},e.fixedAdd=function(t){if(!this.ids.includes(t.id)){this.ids.push(t.id),this.elements.push(t);var e=t.computedStyle.zIndex;(void 0===e?0:e)>=0?this.afterElements.push(t):this.beforeElements.push(t),this.refreshLayout()}},e.bind=function(t){this.container=t.parent,this.container.line=null,this.container.lines?(this.container.lines.push(this),this.pre=this.getPreLine(),this.top=this.pre.top+this.pre.height,this.left=this.container.contentSize.left):(this.top=this.container.contentSize.top,this.left=this.container.contentSize.left,this.container.lines=[this]),this.isInline=t.isInline(),this.container.line=this,this.outerWidth=t.parent&&t.parent.contentSize.width?t.parent.contentSize.width:1/0,this.add(t)},e.getPreLine=function(){return this.container.lines[this.container.lines.length-2]},e.canIEnter=function(t){return!((100*t.offsetSize.width+100*this.width)/100>this.outerWidth)||(this.closeLine(),!1)},e.closeLine=function(){delete this.container.line},e.add=function(t){this.ids.includes(t.id)||(this.ids.push(t.id),this.elements.push(t),this.refreshWidthHeight(t))},e.refreshWidthHeight=function(t){t.offsetSize.height>this.height&&(this.height=t.offsetSize.height),this.width+=t.offsetSize.width||0,(this.container.lineMaxWidth||0)this[this.key.height]&&(this.container[this.key.lineMaxHeight]=this[this.key.height]=i),this[this.key.width]+=this.getWidth(t.offsetSize);var n=Math.min(this.getWidth(this),!this.getWidth(this.container.contentSize)&&1/0);(this.container[this.key.lineMaxWidth]||0)1)return 0;var e=t.style.alignSelf,i=this.getHeight(this.container.contentSize),n=i-this.getHeight(t.offsetSize);return"flex-end"===e?n:"center"===e?n/2:"stretch"===e?(n&&t.name==u&&(t.style[this.key.width]=this.getWidth(t.offsetSize),t.style[this.key.height]=i,delete t.line,delete t.lines,t.getBoxWidthHeight()),0):0},r.layout=function(t,e){var i=this;this.refreshXAlign(),this.pre?(this.top=this.pre.top+this.pre.height+this.offsetY,this.left=e+this.offsetX):(this.top=Math.max(this.top,this.container.contentSize.top,t)+this.offsetY,this.left=Math.max(this.left,this.container.contentSize.left,e)+this.offsetX),this.elements.forEach((function(t,e){i.setIndent(t);var n=i.elements[e-1],r=i.getOffsetY(t);t.style[i.key.top]=i[i.key.top]+r,t.style[i.key.left]=n?n.offsetSize[i.key.left]+i.getWidth(n.offsetSize):i[i.key.left],t.getBoxPosition()}))},n}(et),rt=g,ot=p,st=u,at=y,ht=x,dt=w,lt=m,ct=S,ft=0,ut={left:null,top:null,width:null,height:null},pt=new Map,gt=function(){function t(t,e,i,n){var s=this;F(this,"id",ft++),F(this,"style",{left:null,top:null,width:null,height:null}),F(this,"computedStyle",{}),F(this,"originStyle",{}),F(this,"children",{}),F(this,"layoutBox",A({},ut)),F(this,"contentSize",A({},ut)),F(this,"clientSize",A({},ut)),F(this,"borderSize",A({},ut)),F(this,"offsetSize",A({},ut)),this.ctx=n,this.root=i,e&&(this.parent=e),this.name=t.type||t.name,this.attributes=this.getAttributes(t);var a=function(t,e){var i,n=["color","fontSize","lineHeight","verticalAlign","fontWeight","textAlign"],s=t.type,a=void 0===s?N:s,h=t.styles,d=void 0===h?{}:h,l=(e||{}).computedStyle,c=Object.assign({},z);if([U,$,X].includes(a)&&!d.display&&(c.display=_),l)for(var f=0;f=0&&c<0,Y=d>=0&&u<0;return i==h[0]&&(this[i].left=t.left+s+v+j+(D?2*-c:0),this[i].top=t.top+d+x+W+(Y?2*-u:0),this[i].width=t.width+(this[i].widthAdd?0:C),this[i].height=t.height+(this[i].heightAdd?0:H),this[i].widthAdd=C,this[i].heightAdd=H),i==h[1]&&(this[i].left=t.left+s+j+(D<0?-c:0),this[i].top=t.top+d+W+(Y?-u:0),this[i].width=t.width+v+w,this[i].height=t.height+x+S),i==h[2]&&(this[i].left=t.left+s+j/2+(D<0?-c:0),this[i].top=t.top+d+W/2+(Y?-u:0),this[i].width=t.width+v+w+j/2+F/2,this[i].height=t.height+x+S+T/2+W/2),i==h[3]&&(this[i].left=t.left+(D<0?-c:0),this[i].top=t.top+(Y?-u:0),this[i].width=t.width+v+w+j+F+s+c,this[i].height=t.height+x+S+T+W+u+d),this[i]},e.layoutBoxUpdate=function(t,e,i,n){var r=this;if(void 0===i&&(i=-1),"border-box"==e.boxSizing){var o=e||{},s=o.border,a=(s=void 0===s?{}:s).borderWidth,d=void 0===a?0:a,l=o.borderTop,c=(l=void 0===l?{}:l).borderTopWidth,f=void 0===c?d:c,u=o.borderBottom,p=(u=void 0===u?{}:u).borderBottomWidth,g=void 0===p?d:p,v=o.borderRight,y=(v=void 0===v?{}:v).borderRightWidth,x=void 0===y?d:y,b=o.borderLeft,w=(b=void 0===b?{}:b).borderLeftWidth,m=void 0===w?d:w,S=o.padding,z=(S=void 0===S?{}:S).paddingTop,I=void 0===z?0:z,M=S.paddingRight,B=void 0===M?0:M,k=S.paddingBottom,W=void 0===k?0:k,P=S.paddingLeft,O=void 0===P?0:P;i||(t.width-=O+B+x+m),1!==i||n||(t.height-=I+W+f+g)}this.layoutBox&&(h.forEach((function(i){return r.layoutBox[i]=r.getOffsetSize(t,e,i)})),this.layoutBox=Object.assign({},this.layoutBox,this.layoutBox.borderSize))},e.getBoxPosition=function(){var t=this.computedStyle,e=this.fixedLine,i=this.lines,n=t.left,r=void 0===n?0:n,o=t.top,s=void 0===o?0:o,a=t.padding||{},h=a.paddingBottom,d=void 0===h?0:h,l=a.paddingRight,c=void 0===l?0:l,f=A({},this.contentSize,{left:r,top:s}),u=this.contentSize.top-this.offsetSize.top,p=this.contentSize.left-this.offsetSize.left;if(this.root.fixedLine&&!this.root.isDone){this.root.isDone=!0;for(var g,v=C(this.root.fixedLine.elements);!(g=v()).done;){var y=g.value;y.setPosition(y,this.root.offsetSize),y.getBoxPosition()}}if(e)for(var x,b=C(e.elements);!(x=b()).done;){var w=x.value;w.setPosition(w,f),w.style.left+=r+p+c,w.style.top+=s+u+d,w.getBoxPosition()}if(i)for(var m,S=C(i);!(m=S()).done;){m.value.layout(f.top+u,f.left+p)}return this.layoutBoxUpdate(f,t),this.layoutBox},e.getBoxState=function(t,e){return this.isBlock(t)||this.isBlock(e)},e.isBlock=function(t){return void 0===t&&(t=this),t&&t.style.display==at},e.isFlex=function(t){return void 0===t&&(t=this),t&&t.style.display==dt},e.isInFlow=function(){return!(this.isAbsolute||this.isFixed)},e.inFlexBox=function(t){return void 0===t&&(t=this),!!t.isInFlow()&&(!!t.parent&&(!(!t.parent||t.parent.style.display!==dt)||void 0))},e.isInline=function(t){return void 0===t&&(t=this),t&&t.style.display==ht},e.contrastSize=function(t,e,i){var n=t;return i&&(n=Math.min(n,i)),e&&(n=Math.max(n,e)),n},e.measureText=function(t,e){var i=this.ctx.measureText(t),n=i.width,r=i.actualBoundingBoxAscent,o=i.actualBoundingBoxDescent;return{ascent:r,descent:o,width:n,fontHeight:r+o||.7*e+1}},e.getParentSize=function(t,e){if(void 0===t&&(t=this),void 0===e&&(e=!1),t&&t.parent){if(t.parent.contentSize.width)return t.parent.contentSize;if(e)return this.getParentSize(t.parent,e)}return null},e.getBoxWidthHeight=function(){var t=this,e=this.name,i=this.computedStyle,n=this.attributes,r=this.parent,o=void 0===r?{}:r,s=this.ctx,a=this.getChildren(),h=i.left,d=void 0===h?0:h,l=i.top,c=void 0===l?0:l,f=i.bottom,u=i.right,p=i.width,g=void 0===p?0:p,v=i.minWidth,y=i.maxWidth,x=i.minHeight,b=i.maxHeight,w=i.height,m=void 0===w?0:w,S=i.fontSize,z=i.fontWeight,I=i.fontFamily,M=i.fontStyle,B=i.position;i.textIndent;var k=i.lineClamp,W=i.lineHeight,O=i.padding,T=void 0===O?{}:O,L=i.margin,R=void 0===L?{}:L,F=i.border,A=(F=void 0===F?{}:F).borderWidth,E=void 0===A?0:A,j=i.borderRight,C=(j=void 0===j?{}:j).borderRightWidth,H=void 0===C?E:C,$=i.borderLeft,U=($=void 0===$?{}:$).borderLeftWidth,N=void 0===U?E:U,X=o.contentSize&&o.contentSize.width,_=o.contentSize&&o.contentSize.height;if(Y(g)&&X&&(g=P(g,X)),Y(g)&&!X&&(g=null),Y(m)&&_&&(m=P(m,_)),Y(m)&&!_&&(m=null),Y(v)&&X&&(v=P(v,X)),Y(y)&&X&&(y=P(y,X)),Y(x)&&_&&(x=P(x,_)),Y(b)&&_&&(b=P(b,_)),i.padding&&X)for(var q in i.padding)Object.hasOwnProperty.call(T,q)&&(T[q]=P(T[q],X));var G=T.paddingRight,V=void 0===G?0:G,J=T.paddingLeft,Q=void 0===J?0:J;if(i.margin&&[R.marginLeft,R.marginRight].includes("auto"))if(g){var Z=X&&X-g-V-Q-N-H||0;R.marginLeft==R.marginRight?R.marginLeft=R.marginRight=Z/2:D(R.marginLeft)?R.marginLeft=Z:R.marginRight=Z}else R.marginLeft=R.marginRight=0;var K=R.marginRight,tt=void 0===K?0:K,it=R.marginLeft,at={width:g,height:m,left:0,top:0},ht=Q+V+N+H+(void 0===it?0:it)+tt;if(this.offsetWidth=ht,e==ot&&!this.attributes.widths){var dt=n.text||"";s.save(),s.setFonts({fontFamily:I,fontSize:S,fontWeight:z,fontStyle:M}),dt.length,"\n"==dt&&(dt="",this.isBr=!0),(""+dt).split("\n").map((function(e){var i=Array.from(e).map((function(e){var i=""+(/^[\u4e00-\u9fa5]+$/.test(e)?"cn":e)+I+S+z+M,n=pt.get(i);if(n)return{width:n,text:e};var r=t.measureText(e,S).width;return pt.set(i,r),{width:r,text:e}})),n=t.measureText(e,S),r=n.fontHeight,o=n.ascent,s=n.descent;t.attributes.fontHeight=r,t.attributes.ascent=o,t.attributes.descent=s,t.attributes.widths||(t.attributes.widths=[]),t.attributes.widths.push({widths:i,total:i.reduce((function(t,e){return t+e.width}),0)})})),s.restore()}if(e==rt&&null==g){var ct=n.width,ft=n.height;at.width=this.contrastSize(Math.round(ct*m/ft)||0,v,y),this.layoutBoxUpdate(at,i,0)}if(e==ot&&null==g){var ut=this.attributes.widths,gt=Math.max.apply(Math,ut.map((function(t){return t.total})));if(o&&X>0&&(gt>X||this.isBlock(this))&&!this.isAbsolute&&!this.isFixed)gt=X;at.width=this.contrastSize(gt,v,y),this.layoutBoxUpdate(at,i,0)}if(e==ot&&(o.style.flex||!this.attributes.lines)){var vt=this.attributes.widths.length;this.attributes.widths.forEach((function(t){return t.widths.reduce((function(t,e,i){return t+e.width>at.width?(vt++,e.width):t+e.width}),0)})),vt=k&&vt>k?k:vt,this.attributes.lines=vt}if(e==rt&&null==m){var yt=n.width,xt=n.height;n.text,at.height=this.contrastSize(P(at.width*xt/yt)||0,x,b),this.layoutBoxUpdate(at,i,1)}e==ot&&null==m&&(W=P(W,S),at.height=this.contrastSize(P(this.attributes.lines*W),x,b),this.layoutBoxUpdate(at,i,1,!0)),!g&&o&&o.children&&X&&(!this.isFlex(o)||o.isFlexCalc)&&([st,ot].includes(e)&&this.isFlex()||e==st&&this.isBlock(this)&&this.isInFlow())&&(at.width=this.contrastSize(X-(o.isFlexCalc?0:ht),v,y),this.layoutBoxUpdate(at,i)),g&&!Y(g)&&(at.width=this.contrastSize(g,v,y),this.layoutBoxUpdate(at,i,0)),m&&!Y(m)&&(at.height=this.contrastSize(at.height,x,b),this.layoutBoxUpdate(at,i,1));var bt=0;if(a.length){var wt=null,mt=!1;a.forEach((function(e,n){e.getBoxWidthHeight();var r=a[n+1];if(r&&r.isInFlow()&&(e.next=r),e.isInFlow()&&!e.inFlexBox()){var o=t.getBoxState(wt,e);if(e.isBr)return mt=!0;t.line&&t.line.canIEnter(e)&&!o&&!mt?t.line.add(e):(mt=!1,(new et).bind(e)),wt=e}else e.inFlexBox()?t.line&&(t.line.canIEnter(e)||"nowrap"==i.flexWrap)?t.line.add(e):(new nt).bind(e):e.isFixed?t.root.fixedLine?t.root.fixedLine.fixedAdd(e):(new et).fixedBind(e):t.fixedLine?t.fixedLine.fixedAdd(e):(new et).fixedBind(e,1)})),this.lines&&(bt=this.lines.reduce((function(t,e){return t+e.height}),0))}var St=0,zt=0;if(!g&&(this.isAbsolute||this.isFixed)&&X){var It=B==lt?X:this.root.width,Mt=It-(Y(d)?P(d,It):d)-(Y(u)?P(u,It):u);St=i.left?Mt:this.lineMaxWidth}if(!m&&(null!=c?c:this.isAbsolute||this.isFixed&&_)){var Bt=B==lt?_:this.root.height,kt=Bt-(Y(c)?P(c,Bt):c)-(Y(f)?P(f,Bt):f);zt=i.top?kt:0}if(g&&!Y(g)||at.width||(at.width=St||this.contrastSize((this.isBlock(this)&&!this.isInFlow()?X||o.lineMaxWidth:this.lineMaxWidth)||this.lineMaxWidth,v,y),this.layoutBoxUpdate(at,i,0)),m||!bt&&!zt||(at.height=zt||this.contrastSize(bt,x,b),this.layoutBoxUpdate(at,i)),i.borderRadius&&this.borderSize&&this.borderSize.width)for(var Wt in i.borderRadius)Object.hasOwnProperty.call(i.borderRadius,Wt)&&(i.borderRadius[Wt]=P(i.borderRadius[Wt],this.borderSize.width));return this.layoutBox},e.layout=function(){return this.getBoxWidthHeight(),this.root.offsetSize=this.offsetSize,this.root.contentSize=this.contentSize,this.getBoxPosition(),this.offsetSize},t}(),vt=function(){var t,e,i,n,r,o,s=[0,11,15,19,23,27,31,16,18,20,22,24,26,28,20,22,24,24,26,28,28,22,24,24,26,26,28,28,24,24,26,26,26,28,28,24,26,26,26,28,28],a=[3220,1468,2713,1235,3062,1890,2119,1549,2344,2936,1117,2583,1330,2470,1667,2249,2028,3780,481,4011,142,3098,831,3445,592,2517,1776,2234,1951,2827,1070,2660,1345,3177],h=[30660,29427,32170,30877,26159,25368,27713,26998,21522,20773,24188,23371,17913,16590,20375,19104,13663,12392,16177,14854,9396,8579,11994,11245,5769,5054,7399,6608,1890,597,3340,2107],d=[1,0,19,7,1,0,16,10,1,0,13,13,1,0,9,17,1,0,34,10,1,0,28,16,1,0,22,22,1,0,16,28,1,0,55,15,1,0,44,26,2,0,17,18,2,0,13,22,1,0,80,20,2,0,32,18,2,0,24,26,4,0,9,16,1,0,108,26,2,0,43,24,2,2,15,18,2,2,11,22,2,0,68,18,4,0,27,16,4,0,19,24,4,0,15,28,2,0,78,20,4,0,31,18,2,4,14,18,4,1,13,26,2,0,97,24,2,2,38,22,4,2,18,22,4,2,14,26,2,0,116,30,3,2,36,22,4,4,16,20,4,4,12,24,2,2,68,18,4,1,43,26,6,2,19,24,6,2,15,28,4,0,81,20,1,4,50,30,4,4,22,28,3,8,12,24,2,2,92,24,6,2,36,22,4,6,20,26,7,4,14,28,4,0,107,26,8,1,37,22,8,4,20,24,12,4,11,22,3,1,115,30,4,5,40,24,11,5,16,20,11,5,12,24,5,1,87,22,5,5,41,24,5,7,24,30,11,7,12,24,5,1,98,24,7,3,45,28,15,2,19,24,3,13,15,30,1,5,107,28,10,1,46,28,1,15,22,28,2,17,14,28,5,1,120,30,9,4,43,26,17,1,22,28,2,19,14,28,3,4,113,28,3,11,44,26,17,4,21,26,9,16,13,26,3,5,107,28,3,13,41,26,15,5,24,30,15,10,15,28,4,4,116,28,17,0,42,26,17,6,22,28,19,6,16,30,2,7,111,28,17,0,46,28,7,16,24,30,34,0,13,24,4,5,121,30,4,14,47,28,11,14,24,30,16,14,15,30,6,4,117,30,6,14,45,28,11,16,24,30,30,2,16,30,8,4,106,26,8,13,47,28,7,22,24,30,22,13,15,30,10,2,114,28,19,4,46,28,28,6,22,28,33,4,16,30,8,4,122,30,22,3,45,28,8,26,23,30,12,28,15,30,3,10,117,30,3,23,45,28,4,31,24,30,11,31,15,30,7,7,116,30,21,7,45,28,1,37,23,30,19,26,15,30,5,10,115,30,19,10,47,28,15,25,24,30,23,25,15,30,13,3,115,30,2,29,46,28,42,1,24,30,23,28,15,30,17,0,115,30,10,23,46,28,10,35,24,30,19,35,15,30,17,1,115,30,14,21,46,28,29,19,24,30,11,46,15,30,13,6,115,30,14,23,46,28,44,7,24,30,59,1,16,30,12,7,121,30,12,26,47,28,39,14,24,30,22,41,15,30,6,14,121,30,6,34,47,28,46,10,24,30,2,64,15,30,17,4,122,30,29,14,46,28,49,10,24,30,24,46,15,30,4,18,122,30,13,32,46,28,48,14,24,30,42,32,15,30,20,4,117,30,40,7,47,28,43,22,24,30,10,67,15,30,19,6,118,30,18,31,47,28,34,34,24,30,20,61,15,30],l=[255,0,1,25,2,50,26,198,3,223,51,238,27,104,199,75,4,100,224,14,52,141,239,129,28,193,105,248,200,8,76,113,5,138,101,47,225,36,15,33,53,147,142,218,240,18,130,69,29,181,194,125,106,39,249,185,201,154,9,120,77,228,114,166,6,191,139,98,102,221,48,253,226,152,37,179,16,145,34,136,54,208,148,206,143,150,219,189,241,210,19,92,131,56,70,64,30,66,182,163,195,72,126,110,107,58,40,84,250,133,186,61,202,94,155,159,10,21,121,43,78,212,229,172,115,243,167,87,7,112,192,247,140,128,99,13,103,74,222,237,49,197,254,24,227,165,153,119,38,184,180,124,17,68,146,217,35,32,137,46,55,63,209,91,149,188,207,205,144,135,151,178,220,252,190,97,242,86,211,171,20,42,93,158,132,60,57,83,71,109,65,162,31,45,67,216,183,123,164,118,196,23,73,236,127,12,111,246,108,161,59,82,41,157,85,170,251,96,134,177,187,204,62,90,203,89,95,176,156,169,160,81,11,245,22,235,122,117,44,215,79,174,213,233,230,231,173,232,116,214,244,234,168,80,88,175],c=[1,2,4,8,16,32,64,128,29,58,116,232,205,135,19,38,76,152,45,90,180,117,234,201,143,3,6,12,24,48,96,192,157,39,78,156,37,74,148,53,106,212,181,119,238,193,159,35,70,140,5,10,20,40,80,160,93,186,105,210,185,111,222,161,95,190,97,194,153,47,94,188,101,202,137,15,30,60,120,240,253,231,211,187,107,214,177,127,254,225,223,163,91,182,113,226,217,175,67,134,17,34,68,136,13,26,52,104,208,189,103,206,129,31,62,124,248,237,199,147,59,118,236,197,151,51,102,204,133,23,46,92,184,109,218,169,79,158,33,66,132,21,42,84,168,77,154,41,82,164,85,170,73,146,57,114,228,213,183,115,230,209,191,99,198,145,63,126,252,229,215,179,123,246,241,255,227,219,171,75,150,49,98,196,149,55,110,220,165,87,174,65,130,25,50,100,200,141,7,14,28,56,112,224,221,167,83,166,81,162,89,178,121,242,249,239,195,155,43,86,172,69,138,9,18,36,72,144,61,122,244,245,247,243,251,235,203,139,11,22,44,88,176,125,250,233,207,131,27,54,108,216,173,71,142,0],f=[],u=[],p=[],g=[],v=[],y=2;function x(t,e){var i;t>e&&(i=t,t=e,e=i),i=e,i*=e,i+=e,i>>=1,g[i+=t]=1}function b(t,i){var n;for(p[t+e*i]=1,n=-2;n<2;n++)p[t+n+e*(i-2)]=1,p[t-2+e*(i+n+1)]=1,p[t+2+e*(i+n)]=1,p[t+n+1+e*(i+2)]=1;for(n=0;n<2;n++)x(t-1,i+n),x(t+1,i-n),x(t-n,i-1),x(t+n,i+1)}function w(t){for(;t>=255;)t=((t-=255)>>8)+(255&t);return t}var m=[];function S(t,e,i,n){var r,o,s;for(r=0;re&&(i=t,t=e,e=i),i=e,i+=e*e,i>>=1,g[i+=t]}function I(t){var i,n,r,o;switch(t){case 0:for(n=0;n>1&1,i=0;i=5&&(i+=3+v[e]-5);for(e=3;et||3*v[e-3]>=4*v[e]||3*v[e+3]>=4*v[e])&&(i+=40);return i}function B(){var t,i,n,r,o,s=0,a=0;for(i=0;ie*e;)h-=e*e,d++;for(s+=10*d,t=0;t1)for(P=s[t],k=e-7;;){for(M=e-7;M>P-3&&(b(M,k),!(M6)for(P=a[t-7],W=17,M=0;M<6;M++)for(k=0;k<3;k++,W--)1&(W>11?t>>W-12:P>>W)?(p[5-M+e*(2-k+e-11)]=1,p[2-k+e-11+e*(5-M)]=1):(x(5-M,2-k+e-11),x(2-k+e-11,5-M));for(k=0;k=(M=r*(i+n)+n)-2&&(O=M-2,t>9&&O--),T=O,t>9){for(f[T+2]=0,f[T+3]=0;T--;)P=f[T],f[T+3]|=255&P<<4,f[T+2]=P>>4;f[2]|=255&O<<4,f[1]=O>>4,f[0]=64|O>>12}else{for(f[T+1]=0,f[T+2]=0;T--;)P=f[T],f[T+2]|=255&P<<4,f[T+1]=P>>4;f[1]|=255&O<<4,f[0]=64|O>>4}for(T=O+3-(t<10);T0;L--)m[L]=m[L]?m[L-1]^c[w(l[m[L]]+T)]:m[L-1];m[0]=c[w(l[m[0]]+T)]}for(T=0;T<=o;T++)m[T]=l[m[T]];for(W=M,k=0,T=0;T>=1)1&k&&(p[e-1-W+8*e]=1,W<6?p[8+e*W]=1:p[8+e*(W+1)]=1);for(W=0;W<7;W++,k>>=1)1&k&&(p[8+e*(e-7+W)]=1,W?p[6-W+8*e]=1:p[7+8*e]=1);return p}(v)},utf16to8:function(t){var e,i,n,r;for(e="",n=t.length,i=0;i=1&&r<=127?e+=t.charAt(i):r>2047?(e+=String.fromCharCode(224|r>>12&15),e+=String.fromCharCode(128|r>>6&63),e+=String.fromCharCode(128|r>>0&63)):(e+=String.fromCharCode(192|r>>6&31),e+=String.fromCharCode(128|r>>0&63));return e},draw:function(t,i,n,r,o){i.drawView(n,r);var s=i.ctx,a=n.contentSize,h=a.width,d=a.height,l=a.left,c=a.top;r.borderRadius,r.backgroundColor;var f=r.color,u=void 0===f?"#000000":f;r.border,n.contentSize.left,n.borderSize.left,n.contentSize.top,n.borderSize.top;if(y=o||y,s){s.save(),i.setOpacity(r),i.setTransform(n,r);var p=Math.min(h,d);t=this.utf16to8(t);var g=this.getFrame(t),v=p/e;s.setFillStyle(u);for(var x=0;x=s||n==d&&o=s)&&(a=e.width/i.width);var l=i.width*a,c=i.height*a,f=r||[],u=f[0],p=f[1],g=W(u)?P(u,e.width):(e.width-l)*(O(u)?P(u,1):{left:0,center:.5,right:1}[u||"center"]),v=W(p)?P(p,e.height):(e.height-c)*(O(p)?P(p,1):{top:0,center:.5,bottom:1}[p||"center"]),y=function(t,e){return[(t-g)/a,(e-v)/a]},x=y(0,0),b=x[0],w=x[1],m=y(e.width,e.height),S=m[0],z=m[1],I=Math.max,M=Math.min;return{sx:I(b,0),sy:I(w,0),sw:M(S-b,i.width),sh:M(z-w,i.height),dx:I(g,0),dy:I(v,0),dw:M(l,e.width),dh:M(c,e.height)}}({objectFit:u,objectPosition:v},r.contentSize,t),o=i.sx,s=i.sy,a=i.sh,h=i.sw,d=i.dx,l=i.dy,c=i.dh,f=i.dw;M==n.MP_BAIDU?e.drawImage(t.src,d+m,l+S,f,c,o,s,h,a):e.drawImage(t.src,o,s,h,a,d+m,l+S,f,c)}else e.drawImage(t.src,m,S,b,w)},k=function(){e.restore(),T.drawView(r,o,!1,!0,!1),h(1)},function(t){B(t),k()}(t),[2]}))}))}))];case 1:return h.sent(),[2]}}))}))},r.prototype.drawText=function(t,e,i,n){var r=this,o=this.ctx,s=e.borderSize,a=e.contentSize,h=e.left,d=e.top,l=a.width,c=a.height,f=a.left-s.left||0,u=a.top-s.top||0,p=i.color,g=i.lineHeight,v=i.fontSize,y=i.fontWeight,x=i.fontFamily,b=i.fontStyle,w=i.textIndent,m=void 0===w?0:w,S=i.textAlign,z=i.textStroke,I=i.verticalAlign,M=void 0===I?St:I,B=i.backgroundColor,k=i.lineClamp,O=i.backgroundClip,T=i.textShadow,L=i.textDecoration;if(m=W(m)?m:0,this.drawView(e,i,O!=xt),g=P(g,v),t){o.save(),h+=f,d+=u;var R=n.fontHeight,F=n.descent,A=void 0===F?0:F,E=n.ascent,j=A+(void 0===E?0:E);switch(o.setFonts({fontFamily:x,fontSize:v,fontWeight:y,fontStyle:b}),o.setTextBaseline(St),o.setTextAlign(S),O?this.setBackground(B,l,c,h,d):o.setFillStyle(p),S){case It:break;case Mt:h+=.5*l;break;case Bt:h+=l}var C=n.lines*g,H=Math.ceil((c-C)/2);switch(H<0&&(H=0),M){case mt:break;case St:d+=H;break;case zt:d+=2*H}var D=(g-R)/2,Y=g/2,$=function(t){var e=o.measureText(t),i=e.actualBoundingBoxDescent,n=void 0===i?0:i,r=e.actualBoundingBoxAscent;return M==mt?{fix:j?void 0===r?0:r:Y-D/2,lineY:j?0:D-D/2}:M==St?{fix:j?Y+n/4:Y,lineY:j?0:D}:M==zt?{fix:j?g-n:Y+D/2,lineY:j?2*D:D+D/2}:{fix:0,height:0,lineY:0}},U=function(t,e,i){var r=t;switch(S){case It:t=t,r+=i;break;case Mt:r=(t-=i/2)+i;break;case Bt:r=t,t-=i}if(L){o.setLineWidth(v/13),o.beginPath();var s=.1*n.fontHeight;/\bunderline\b/.test(L)&&(o.moveTo(t,e+n.fontHeight+s),o.lineTo(r,e+n.fontHeight+s)),/\boverline\b/.test(L)&&(o.moveTo(t,e-s),o.lineTo(r,e-s)),/\bline-through\b/.test(L)&&(o.moveTo(t,e+.5*n.fontHeight),o.lineTo(r,e+.5*n.fontHeight)),o.closePath(),o.setStrokeStyle(p),o.stroke()}},N=function(t,e,i){var n=function(){o.setLineWidth(z.width),o.setStrokeStyle(z.color),o.strokeText(t,e,i)},s="outset";z&&z.type!==s?(o.save(),r.setShadow({boxShadow:T}),o.fillText(t,e,i),o.restore(),n()):z&&z.type==s?(o.save(),r.setShadow({boxShadow:T}),n(),o.restore(),o.save(),o.fillText(t,e,i),o.restore()):(r.setShadow({boxShadow:T}),o.fillText(t,e,i))};if(!n.widths||1==n.widths.length&&n.widths[0].total+m<=a.width){var X=$(t),_=X.fix,q=void 0===_?0:_,G=X.lineY;return N(t,h+m,d+q),U(h+m,d+G,n&&n.widths&&n.widths[0].total||n.text),d+=g,o.restore(),void this.setBorder(e,i)}for(var V=d,J=h,Q="",Z=0,K=o.measureText("...").width,tt=n.widths,et=0;eta.width){Z>=k&&(Q+="…"),Z++,nt=0;var dt=$(Q);q=dt.fix,G=dt.lineY;N(Q,J,d+q),U(J,d+G,nt),d+=g,Q=""}else if(rt==it.length-1){et!=tt.length-1&&Z==k&&K+ntV+c||Z>k)break}}o.restore()}},r.prototype.source=function(t){return e(this,void 0,void 0,(function(){var e,n,r,o,s=this;return i(this,(function(i){switch(i.label){case 0:if(this.node=null,e=+new Date,"{}"==JSON.stringify(t))return[2];if(!t.type)for(n in t.type=wt,t.styles=t.styles||t.css||{},t)["views","children","type","css","styles"].includes(n)||(t.styles[n]=t[n],delete t[n]);return t.styles.boxSizing||(t.styles.boxSizing="border-box"),[4,this.create(t)];case 1:return(r=i.sent())?(o=r.layout()||{},this.size=o,this.node=r,this.onEffectFinished().then((function(t){return s.lifecycle("onEffectSuccess",t)})).catch((function(t){return s.lifecycle("onEffectFail",t)})),this.performance&&console.log("布局用时:"+(+new Date-e)+"ms"),[2,this.size]):[2,console.warn("no node")]}}))}))},r.prototype.getImageInfo=function(t){return this.imageBus[t]||(this.imageBus[t]=this.createImage(t,this.useCORS)),this.imageBus[t]},r.prototype.create=function(n,r){return e(this,void 0,void 0,(function(){function e(i,n,r){void 0===n&&(n={}),void 0===r&&(r=!0);var o=[];return i.forEach((function(i){var s=i.styles,a=void 0===s?{}:s,h=i.children,d=void 0===h?[]:h,l=i.text,c=void 0===l?"":l,f=i.type,u=void 0===f?"":f,p={};p=t(r?t({},n):{},a);var g={},v={},y={};Object.keys(p).map((function(t){if(t.includes("padding")||t.includes("margin")){var e=J(t,p[t]);Object.keys(e).map((function(t){t.includes("Left")?v[t]=e[t]:t.includes("Right")?y[t]=e[t]:g[t]=e[t]}))}}));if(p.textIndent&&(v.textIndent=p.textIndent,delete n.textIndent),""!==c){var x=Array.from(c);x.forEach((function(t,e){var i=Object.assign({},p,g);0===e?Object.assign(i,v):e==x.length-1&&Object.assign(i,y),delete i.padding,delete i.margin,o.push({type:"text",text:t,styles:i})}))}if(u==yt||u==bt)o.push(i);else if("block"===a.display&&d.length>0){var b=e(d,p,!1);i.children=b,i.flattened=!0,o.push(i)}else if(d.length>0){b=e(d,p,r);o=o.concat(b)}})),o}var o,s,a,h,d,l,c,f,u,p,g,v,y,x,w,m,S,z,I,M,B;return i(this,(function(i){switch(i.label){case 0:if(!n)return[2];if(n.styles||(n.styles=n.css||{}),o=n.type,s=o==yt,a=[xt,bt].includes(o),h="textBox"==o,d=n.styles||{},l=d.backgroundImage,c=d.display,s&&!n.src&&!n.url)return[2];if(c==b)return[2];if(a||h){if(f=n.children,!n.text&&(!f||f&&!f.length))return[2];f&&f.length&&!n.flattened&&(u=e(n.children),n.type="view",n.children=u)}if(!(s||n.type==wt&&l))return[3,4];p=s?n.src:"",g=/url\((.+)\)/.exec(l),l&&g&&g[1]&&(p=g[1]||""),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.getImageInfo(p)];case 2:return v=i.sent(),y=v.width,x=v.height,!(w=v.path)&&s?[2]:(w&&(n.attributes=Object.assign(n.attributes||{},{width:y,height:x,path:w,src:w,naturalSrc:p})),[3,4]);case 3:return m=i.sent(),n.type!=wt?[2]:(this.lifecycle("onEffectFail",t(t({},m),{src:p})),[3,4]);case 4:if(this.count+=1,S=new gt(n,r,this.root,this.ctx),!(z=n.views||n.children))return[3,8];I=0,i.label=5;case 5:return I /^data:image\/(\w+);base64/.test(path); +export function sleep(delay) { + return new Promise(resolve => setTimeout(resolve, delay)) +} +let {platform, SDKVersion} = uni.getSystemInfoSync() +export const isPC = /windows|mac/.test(platform) +// 缓存图片 +let cache = {} +export function isNumber(value) { + return /^-?\d+(\.\d+)?$/.test(value); +} +export function toPx(value, baseSize, isDecimal = false) { + // 如果是数字 + if (typeof value === 'number') { + return value + } + // 如果是字符串数字 + if (isNumber(value)) { + return value * 1 + } + // 如果有单位 + if (typeof value === 'string') { + const reg = /^-?([0-9]+)?([.]{1}[0-9]+){0,1}(em|rpx|px|%)$/g + const results = reg.exec(value); + if (!value || !results) { + return 0; + } + const unit = results[3]; + value = parseFloat(value); + let res = 0; + if (unit === 'rpx') { + res = uni.upx2px(value); + } else if (unit === 'px') { + res = value * 1; + } else if (unit === '%') { + res = value * toPx(baseSize) / 100; + } else if (unit === 'em') { + res = value * toPx(baseSize || 14); + } + return isDecimal ? res.toFixed(2) * 1 : Math.round(res); + } + return 0 +} + +// 计算版本 +export function compareVersion(v1, v2) { + v1 = v1.split('.') + v2 = v2.split('.') + const len = Math.max(v1.length, v2.length) + while (v1.length < len) { + v1.push('0') + } + while (v2.length < len) { + v2.push('0') + } + for (let i = 0; i < len; i++) { + const num1 = parseInt(v1[i], 10) + const num2 = parseInt(v2[i], 10) + + if (num1 > num2) { + return 1 + } else if (num1 < num2) { + return -1 + } + } + return 0 +} + +function gte(version) { + // #ifdef MP-ALIPAY + SDKVersion = my.SDKVersion + // #endif + return compareVersion(SDKVersion, version) >= 0; +} +export function canIUseCanvas2d() { + // #ifdef MP-WEIXIN + return gte('2.9.2'); + // #endif + // #ifdef MP-ALIPAY + return gte('2.7.15'); + // #endif + // #ifdef MP-TOUTIAO + return gte('1.78.0'); + // #endif + return false +} + +// #ifdef MP +export const prefix = () => { + // #ifdef MP-TOUTIAO + return tt + // #endif + // #ifdef MP-WEIXIN + return wx + // #endif + // #ifdef MP-BAIDU + return swan + // #endif + // #ifdef MP-ALIPAY + return my + // #endif + // #ifdef MP-QQ + return qq + // #endif + // #ifdef MP-360 + return qh + // #endif +} +// #endif + + + +/** + * base64转路径 + * @param {Object} base64 + */ +export function base64ToPath(base64) { + const [, format] = /^data:image\/(\w+);base64,/.exec(base64) || []; + + return new Promise((resolve, reject) => { + // #ifdef MP + const fs = uni.getFileSystemManager() + //自定义文件名 + if (!format) { + reject(new Error('ERROR_BASE64SRC_PARSE')) + } + const time = new Date().getTime(); + let pre = prefix() + const filePath = `${pre.env.USER_DATA_PATH}/${time}.${format}` + fs.writeFile({ + filePath, + data: base64.split(',')[1], + encoding: 'base64', + success() { + resolve(filePath) + }, + fail(err) { + console.error(err) + reject(err) + } + }) + // #endif + + // #ifdef H5 + // mime类型 + let mimeString = base64.split(',')[0].split(':')[1].split(';')[0]; + //base64 解码 + let byteString = atob(base64.split(',')[1]); + //创建缓冲数组 + let arrayBuffer = new ArrayBuffer(byteString.length); + //创建视图 + let intArray = new Uint8Array(arrayBuffer); + for (let i = 0; i < byteString.length; i++) { + intArray[i] = byteString.charCodeAt(i); + } + resolve(URL.createObjectURL(new Blob([intArray], { + type: mimeString + }))) + // #endif + + // #ifdef APP-PLUS + const bitmap = new plus.nativeObj.Bitmap('bitmap' + Date.now()) + bitmap.loadBase64Data(base64, () => { + if (!format) { + reject(new Error('ERROR_BASE64SRC_PARSE')) + } + const time = new Date().getTime(); + const filePath = `_doc/uniapp_temp/${time}.${format}` + bitmap.save(filePath, {}, + () => { + bitmap.clear() + resolve(filePath) + }, + (error) => { + bitmap.clear() + reject(error) + }) + }, (error) => { + bitmap.clear() + reject(error) + }) + // #endif + }) +} + +/** + * 路径转base64 + * @param {Object} string + */ +export function pathToBase64(path) { + if (/^data:/.test(path)) return path + return new Promise((resolve, reject) => { + // #ifdef H5 + let image = new Image(); + image.setAttribute("crossOrigin", 'Anonymous'); + image.onload = function() { + let canvas = document.createElement('canvas'); + canvas.width = this.naturalWidth; + canvas.height = this.naturalHeight; + canvas.getContext('2d').drawImage(image, 0, 0); + let result = canvas.toDataURL('image/png') + resolve(result); + canvas.height = canvas.width = 0 + } + image.src = path + '?v=' + Math.random() + image.onerror = (error) => { + reject(error); + }; + // #endif + + // #ifdef MP + if (uni.canIUse('getFileSystemManager')) { + uni.getFileSystemManager().readFile({ + filePath: path, + encoding: 'base64', + success: (res) => { + resolve('data:image/png;base64,' + res.data) + }, + fail: (error) => { + console.error({error, path}) + reject(error) + } + }) + } + // #endif + + // #ifdef APP-PLUS + plus.io.resolveLocalFileSystemURL(getLocalFilePath(path), (entry) => { + entry.file((file) => { + const fileReader = new plus.io.FileReader() + fileReader.onload = (data) => { + resolve(data.target.result) + } + fileReader.onerror = (error) => { + reject(error) + } + fileReader.readAsDataURL(file) + }, reject) + }, reject) + // #endif + }) +} + + + +export function getImageInfo(path, useCORS) { + const isCanvas2D = this && this.canvas && this.canvas.createImage + return new Promise(async (resolve, reject) => { + // let time = +new Date() + let src = path.replace(/^@\//,'/') + if (cache[path] && cache[path].errMsg) { + resolve(cache[path]) + } else { + try { + // #ifdef MP || APP-PLUS + if (isBase64(path) && (isCanvas2D ? isPC : true)) { + src = await base64ToPath(path) + } + // #endif + // #ifdef H5 + if(useCORS) { + src = await pathToBase64(path) + } + // #endif + } catch (error) { + reject({ + ...error, + src + }) + } + // #ifndef APP-NVUE + if(isCanvas2D && !isPC) { + const img = this.canvas.createImage() + img.onload = function() { + const image = { + path: img, + width: img.width, + height: img.height + } + cache[path] = image + resolve(cache[path]) + } + img.onerror = function(err) { + reject({err,path}) + } + img.src = src + return + } + // #endif + uni.getImageInfo({ + src, + success: (image) => { + const localReg = /^\.|^\/(?=[^\/])/; + // #ifdef MP-WEIXIN || MP-BAIDU || MP-QQ || MP-TOUTIAO + image.path = localReg.test(src) ? `/${image.path}` : image.path; + // #endif + if(isCanvas2D) { + const img = this.canvas.createImage() + img.onload = function() { + image.path = img + cache[path] = image + resolve(cache[path]) + } + img.onerror = function(err) { + reject({err,path}) + } + img.src = src + return + } + // #ifdef APP-PLUS + // console.log('getImageInfo', +new Date() - time) + // ios 比较严格 可能需要设置跨域 + if(uni.getSystemInfoSync().osName == 'ios' && useCORS) { + pathToBase64(image.path).then(base64 => { + image.path = base64 + cache[path] = image + resolve(cache[path]) + }).catch(err => { + console.error({err, path}) + reject({err,path}) + }) + return + } + // #endif + cache[path] = image + resolve(cache[path]) + }, + fail(err) { + console.error({err, path}) + reject({err,path}) + } + }) + } + }) +} + + +// #ifdef APP-PLUS +const getLocalFilePath = (path) => { + if (path.indexOf('_www') === 0 || path.indexOf('_doc') === 0 || path.indexOf('_documents') === 0 || path + .indexOf('_downloads') === 0) { + return path + } + if (path.indexOf('file://') === 0) { + return path + } + if (path.indexOf('/storage/emulated/0/') === 0) { + return path + } + if (path.indexOf('/') === 0) { + const localFilePath = plus.io.convertAbsoluteFileSystem(path) + if (localFilePath !== path) { + return localFilePath + } else { + path = path.substr(1) + } + } + return '_www/' + path +} +// #endif + + diff --git a/uni_modules/lime-painter/components/lime-painter/lime-painter.vue b/uni_modules/lime-painter/components/lime-painter/lime-painter.vue new file mode 100644 index 0000000..5d895bd --- /dev/null +++ b/uni_modules/lime-painter/components/lime-painter/lime-painter.vue @@ -0,0 +1,224 @@ + + + + + diff --git a/uni_modules/lime-painter/hybrid/html/index.html b/uni_modules/lime-painter/hybrid/html/index.html new file mode 100644 index 0000000..fdf884e --- /dev/null +++ b/uni_modules/lime-painter/hybrid/html/index.html @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/uni_modules/lime-painter/hybrid/html/painter.js b/uni_modules/lime-painter/hybrid/html/painter.js new file mode 100644 index 0000000..7c1e2bc --- /dev/null +++ b/uni_modules/lime-painter/hybrid/html/painter.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Painter={})}(this,(function(t){"use strict";var e=function(){return(e=Object.assign||function(t){for(var e,i=1,n=arguments.length;i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=360&&(s-=360);s<0&&(s+=360);if(0===(s=Math.round(s)))return{x0:Math.round(e/2)+n,y0:i+r,x1:Math.round(e/2)+n,y1:r};if(180===s)return{x0:Math.round(e/2)+n,y0:r,x1:Math.round(e/2)+n,y1:i+r};if(90===s)return{x0:n,y0:Math.round(i/2)+r,x1:e+n,y1:Math.round(i/2)+r};if(270===s)return{x0:e+n,y0:Math.round(i/2)+r,x1:n,y1:Math.round(i/2)+r};var a=Math.round(180*Math.asin(e/Math.sqrt(Math.pow(e,2)+Math.pow(i,2)))/Math.PI);if(s===a)return{x0:n,y0:i+r,x1:e+n,y1:r};if(s===180-a)return{x0:n,y0:r,x1:e+n,y1:i+r};if(s===180+a)return{x0:e+n,y0:r,x1:n,y1:i+r};if(s===360-a)return{x0:e+n,y0:i+r,x1:n,y1:r};var h=0,d=0,l=0,c=0;if(s180-a&&s<180||s>180&&s<180+a||s>360-a){var f=s*Math.PI/180,u=s360-a?i/2:-i/2,p=Math.tan(f)*u,g=s180-a&&s<180?e/2-p:-e/2-p;h=-(l=p+(v=Math.pow(Math.sin(f),2)*g)),d=-(c=u+v/Math.tan(f))}if(s>a&&s<90||s>90&&s<90+a||s>180+a&&s<270||s>270&&s<360-a){var v;f=(90-s)*Math.PI/180,p=s>a&&s<90||s>90&&s<90+a?e/2:-e/2,u=Math.tan(f)*p,g=s>a&&s<90||s>270&&s<360-a?i/2-u:-i/2-u;h=-(l=p+(v=Math.pow(Math.sin(f),2)*g)/Math.tan(f)),d=-(c=u+v)}return h=Math.round(h+e/2)+n,d=Math.round(i/2-d)+r,l=Math.round(l+e/2)+n,c=Math.round(i/2-c)+r,{x0:h,y0:d,x1:l,y1:c}}(r,t,e,i,n),a=s.x0,h=s.y0,d=s.x1,l=s.y1,c=o.createLinearGradient(a,h,d,l),f=r.match(/linear-gradient\((.+)\)/)[1],u=X(f.substring(f.indexOf(",")+1)),p=0;pt.length)&&(e=t.length);for(var i=0,n=new Array(e);i=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Z(t){return"number"==typeof t}function K(t){return"auto"===t||null===t}function et(t){return/%$/.test(t)}var it=I,nt=z,rt=S,ot=M,st=k,at=O,ht=T;function dt(t){return t.replace(/-([a-z])/g,(function(t,e){return e.toUpperCase()}))}function lt(t,e){var i,n,r=function(t){var e=t.match(/([a-z]+)/)[1];return[e,dt(t.split(e)[1])]}(t),o=r[0],s=r[1],a=e.split(" ");if(s)return(i={})[o+s]=e,i;if(a.length&&!s){var h=a[0],d=a[1],l=a[2],f=a[3];return(n={})[o+c[0]]=h,n[o+c[1]]=d||h,n[o+c[2]]=l||h,n[o+c[3]]=f||d||h,n}}function ct(t){t=t.trim();for(var e=new Array,i="+",n="",r=t.length,o=0;o0;)"("===t[a+=1]&&(s+=1),")"===t[a]&&(s-=1);n=""+ct(t.slice(o+1,a)),o=a}if(isNaN(Number(t[o]))&&"."!==t[o]||o===r-1){var h=parseFloat(n);switch(i){case"+":e.push(h);break;case"-":e.push(-h);break;case"*":e.push(e.pop()*h);break;case"/":e.push(e.pop()/h)}i=t[o],n=""}}for(var d=0;e.length;)d+=e.pop();return d}var ft,ut=0,pt=function(){function t(){q(this,"elements",[]),q(this,"afterElements",[]),q(this,"beforeElements",[]),q(this,"ids",[]),q(this,"width",0),q(this,"height",0),q(this,"top",0),q(this,"left",0),q(this,"pre",null),q(this,"offsetX",0),q(this,"offsetY",0),ut++,this.id=ut}var e=t.prototype;return e.fixedBind=function(t,e){void 0===e&&(e=0),this.container=e?t.parent:t.root,this.container.fixedLine=this,this.fixedAdd(t)},e.fixedAdd=function(t){if(!this.ids.includes(t.id)){this.ids.push(t.id),this.elements.push(t);var e=t.computedStyle.zIndex;(void 0===e?0:e)>=0?this.afterElements.push(t):this.beforeElements.push(t),this.refreshLayout()}},e.bind=function(t){this.container=t.parent,this.container.line=null,this.container.lines?(this.container.lines.push(this),this.pre=this.getPreLine(),this.top=this.pre.top+this.pre.height,this.left=this.container.contentSize.left):(this.top=this.container.contentSize.top,this.left=this.container.contentSize.left,this.container.lines=[this]),this.isInline=t.isInline(),this.container.line=this,this.outerWidth=t.parent&&t.parent.contentSize.width?t.parent.contentSize.width:1/0,this.add(t)},e.getPreLine=function(){return this.container.lines[this.container.lines.length-2]},e.canIEnter=function(t){return!((100*t.offsetSize.width+100*this.width)/100>this.outerWidth)||(this.closeLine(),!1)},e.closeLine=function(){delete this.container.line},e.add=function(t){this.ids.includes(t.id)||(this.ids.push(t.id),this.elements.push(t),this.refreshWidthHeight(t))},e.refreshWidthHeight=function(t){t.offsetSize.height>this.height&&(this.height=t.offsetSize.height),this.width+=t.offsetSize.width||0,(this.container.lineMaxWidth||0)this[this.key.height]&&(this.container[this.key.lineMaxHeight]=this[this.key.height]=i),this[this.key.width]+=this.getWidth(t.offsetSize);var n=Math.min(this.getWidth(this),!this.getWidth(this.container.contentSize)&&1/0);(this.container[this.key.lineMaxWidth]||0)1)return 0;var e=t.style.alignSelf,i=this.getHeight(this.container.contentSize),n=i-this.getHeight(t.offsetSize);return e===l?n:e===h?n/2:"stretch"===e?(n&&t.name==S&&(t.style[this.key.width]=this.getWidth(t.offsetSize),t.style[this.key.height]=i,delete t.line,delete t.lines,t.getBoxWidthHeight()),0):0},r.layout=function(t,e){var i=this;this.refreshXAlign(),this.pre?(this.top=this.pre.top+this.pre.height+this.offsetY,this.left=e+this.offsetX):(this.top=Math.max(this.top,this.container.contentSize.top,t)+this.offsetY,this.left=Math.max(this.left,this.container.contentSize.left,e)+this.offsetX),this.elements.forEach((function(t,e){i.setIndent(t);var n=i.elements[e-1],r=i.getOffsetY(t);t.style[i.key.top]=i[i.key.top]+r,t.style[i.key.left]=n?n.offsetSize[i.key.left]+i.getWidth(n.offsetSize):i[i.key.left],t.getBoxPosition()}))},n}(pt),bt=I,wt=z,mt=S,St=B,zt=k,It=P,Mt=O,Bt=T,kt=0,Wt={left:null,top:null,width:null,height:null},Pt=new Map,Ot=function(){function t(t,e,i,n){var r=this;q(this,"id",kt++),q(this,"style",{left:null,top:null,width:null,height:null}),q(this,"computedStyle",{}),q(this,"originStyle",{}),q(this,"children",{}),q(this,"layoutBox",G({},Wt)),q(this,"contentSize",G({},Wt)),q(this,"clientSize",G({},Wt)),q(this,"borderSize",G({},Wt)),q(this,"offsetSize",G({},Wt)),this.ctx=n,this.root=i,e&&(this.parent=e),this.name=t.type||t.name,this.attributes=this.getAttributes(t);var s=function(t,e){var i,n=["color","fontSize","lineHeight","verticalAlign","fontWeight","textAlign"],r=t.type,s=void 0===r?rt:r,h=t.styles,d=void 0===h?{}:h,l=(e||{}).computedStyle,f=Object.assign({},F);if([nt,it,ot].includes(s)&&!d.display&&(f.display=st),l)for(var u=0;u=0&&l<0,Y=h>=0&&f<0;return i==y[0]&&(this[i].left=t.left+s+g+C+(D?2*-l:0),this[i].top=t.top+h+x+W+(Y?2*-f:0),this[i].width=t.width+(this[i].widthAdd?0:j),this[i].height=t.height+(this[i].heightAdd?0:H),this[i].widthAdd=j,this[i].heightAdd=H),i==y[1]&&(this[i].left=t.left+s+C+(D<0?-l:0),this[i].top=t.top+h+W+(Y?-f:0),this[i].width=t.width+g+w,this[i].height=t.height+x+S),i==y[2]&&(this[i].left=t.left+s+C/2+(D<0?-l:0),this[i].top=t.top+h+W/2+(Y?-f:0),this[i].width=t.width+g+w+C/2+F/2,this[i].height=t.height+x+S+T/2+W/2),i==y[3]&&(this[i].left=t.left+(D<0?-l:0),this[i].top=t.top+(Y?-f:0),this[i].width=t.width+g+w+C+F+s+l,this[i].height=t.height+x+S+T+W+f+h),this[i]},e.layoutBoxUpdate=function(t,e,i,n){var r=this;if(void 0===i&&(i=-1),"border-box"==e.boxSizing){var o=e||{},s=o.border,a=(s=void 0===s?{}:s).borderWidth,h=void 0===a?0:a,d=o.borderTop,l=(d=void 0===d?{}:d).borderTopWidth,c=void 0===l?h:l,f=o.borderBottom,u=(f=void 0===f?{}:f).borderBottomWidth,p=void 0===u?h:u,g=o.borderRight,v=(g=void 0===g?{}:g).borderRightWidth,x=void 0===v?h:v,b=o.borderLeft,w=(b=void 0===b?{}:b).borderLeftWidth,m=void 0===w?h:w,S=o.padding,z=(S=void 0===S?{}:S).paddingTop,I=void 0===z?0:z,M=S.paddingRight,B=void 0===M?0:M,k=S.paddingBottom,W=void 0===k?0:k,P=S.paddingLeft,O=void 0===P?0:P;i||(t.width-=O+B+x+m),1!==i||n||(t.height-=I+W+c+p)}this.layoutBox&&(y.forEach((function(i){return r.layoutBox[i]=r.getOffsetSize(t,e,i)})),this.layoutBox=Object.assign({},this.layoutBox,this.layoutBox.borderSize))},e.getBoxPosition=function(){var t=this.computedStyle,e=this.fixedLine,i=this.lines,n=t.left,r=void 0===n?0:n,o=t.top,s=void 0===o?0:o,a=t.padding||{},h=a.paddingBottom,d=void 0===h?0:h,l=a.paddingRight,c=void 0===l?0:l,f=G({},this.contentSize,{left:r,top:s}),u=this.contentSize.top-this.offsetSize.top,p=this.contentSize.left-this.offsetSize.left;if(this.root.fixedLine&&!this.root.isDone){this.root.isDone=!0;for(var g,v=Q(this.root.fixedLine.elements);!(g=v()).done;){var y=g.value;y.setPosition(y,this.root.offsetSize),y.getBoxPosition()}}if(e)for(var x,b=Q(e.elements);!(x=b()).done;){var w=x.value;w.setPosition(w,f),w.style.left+=r+p+c,w.style.top+=s+u+d,w.getBoxPosition()}if(i)for(var m,S=Q(i);!(m=S()).done;){m.value.layout(f.top+u,f.left+p)}return this.layoutBoxUpdate(f,t),this.layoutBox},e.getBoxState=function(t,e){return this.isBlock(t)||this.isBlock(e)},e.isBlock=function(t){return void 0===t&&(t=this),t&&t.style.display==St},e.isFlex=function(t){return void 0===t&&(t=this),t&&t.style.display==It},e.isInFlow=function(){return!(this.isAbsolute||this.isFixed)},e.inFlexBox=function(t){return void 0===t&&(t=this),!!t.isInFlow()&&(!!t.parent&&(!(!t.parent||t.parent.style.display!==It)||void 0))},e.isInline=function(t){return void 0===t&&(t=this),t&&t.style.display==zt},e.contrastSize=function(t,e,i){var n=t;return i&&(n=Math.min(n,i)),e&&(n=Math.max(n,e)),n},e.measureText=function(t,e){var i=this.ctx.measureText(t),n=i.width,r=i.actualBoundingBoxAscent,o=i.actualBoundingBoxDescent;return{ascent:r,descent:o,width:n,fontHeight:r+o||.7*e+1}},e.getParentSize=function(t,e){if(void 0===t&&(t=this),void 0===e&&(e=!1),t&&t.parent){if(t.parent.contentSize.width)return t.parent.contentSize;if(e)return this.getParentSize(t.parent,e)}return null},e.getBoxWidthHeight=function(){var t=this,e=this.name,i=this.computedStyle,n=this.attributes,r=this.parent,o=void 0===r?{}:r,s=this.ctx,a=this.getChildren(),h=i.left,d=void 0===h?0:h,l=i.top,c=void 0===l?0:l,f=i.bottom,u=i.right,p=i.width,g=void 0===p?0:p,v=i.minWidth,y=i.maxWidth,x=i.minHeight,b=i.maxHeight,w=i.height,m=void 0===w?0:w,S=i.fontSize,z=i.fontWeight,I=i.fontFamily,M=i.fontStyle,B=i.position;i.textIndent;var k=i.lineClamp,W=i.lineHeight,P=i.padding,O=void 0===P?{}:P,T=i.margin,L=void 0===T?{}:T,R=i.border,F=(R=void 0===R?{}:R).borderWidth,A=void 0===F?0:F,E=i.borderRight,C=(E=void 0===E?{}:E).borderRightWidth,j=void 0===C?A:C,H=i.borderLeft,D=(H=void 0===H?{}:H).borderLeftWidth,Y=void 0===D?A:D,U=o.contentSize&&o.contentSize.width,N=o.contentSize&&o.contentSize.height;if(et(g)&&U&&(g=$(g,U)),et(g)&&!U&&(g=null),et(m)&&N&&(m=$(m,N)),et(m)&&!N&&(m=null),et(v)&&U&&(v=$(v,U)),et(y)&&U&&(y=$(y,U)),et(x)&&N&&(x=$(x,N)),et(b)&&N&&(b=$(b,N)),i.padding&&U)for(var _ in i.padding)Object.hasOwnProperty.call(O,_)&&(O[_]=$(O[_],U));var X=O.paddingRight,q=void 0===X?0:X,G=O.paddingLeft,V=void 0===G?0:G;if(i.margin&&[L.marginLeft,L.marginRight].includes("auto"))if(g){var J=U&&U-g-q-V-Y-j||0;L.marginLeft==L.marginRight?L.marginLeft=L.marginRight=J/2:K(L.marginLeft)?L.marginLeft=J:L.marginRight=J}else L.marginLeft=L.marginRight=0;var Q=L.marginRight,Z=void 0===Q?0:Q,tt=L.marginLeft,it={width:g,height:m,left:0,top:0},nt=V+q+Y+j+(void 0===tt?0:tt)+Z;if(this.offsetWidth=nt,e==wt&&!this.attributes.widths){var rt=n.text||"";s.save(),s.setFonts({fontFamily:I,fontSize:S,fontWeight:z,fontStyle:M}),rt.length,"\n"==rt&&(rt="",this.isBr=!0),(""+rt).split("\n").map((function(e){var i=Array.from(e).map((function(e){var i=""+(/^[\u4e00-\u9fa5]+$/.test(e)?"cn":e)+I+S+z+M,n=Pt.get(i);if(n)return{width:n,text:e};var r=t.measureText(e,S).width;return Pt.set(i,r),{width:r,text:e}})),n=t.measureText(e,S),r=n.fontHeight,o=n.ascent,s=n.descent;t.attributes.fontHeight=r,t.attributes.ascent=o,t.attributes.descent=s,t.attributes.widths||(t.attributes.widths=[]),t.attributes.widths.push({widths:i,total:i.reduce((function(t,e){return t+e.width}),0)})})),s.restore()}if(e==bt&&null==g){var ot=n.width,st=n.height;it.width=this.contrastSize(Math.round(ot*m/st)||0,v,y),this.layoutBoxUpdate(it,i,0)}if(e==wt&&null==g){var at=this.attributes.widths,ht=Math.max.apply(Math,at.map((function(t){return t.total})));if(o&&U>0&&(ht>U||this.isBlock(this))&&!this.isAbsolute&&!this.isFixed)ht=U;it.width=this.contrastSize(ht,v,y),this.layoutBoxUpdate(it,i,0)}if(e==wt&&(o.style.flex||!this.attributes.lines)){var dt=this.attributes.widths.length;this.attributes.widths.forEach((function(t){return t.widths.reduce((function(t,e,i){return t+e.width>it.width?(dt++,e.width):t+e.width}),0)})),dt=k&&dt>k?k:dt,this.attributes.lines=dt}if(e==bt&&null==m){var lt=n.width,ct=n.height;n.text,it.height=this.contrastSize($(it.width*ct/lt)||0,x,b),this.layoutBoxUpdate(it,i,1)}e==wt&&null==m&&(W=$(W,S),it.height=this.contrastSize($(this.attributes.lines*W),x,b),this.layoutBoxUpdate(it,i,1,!0)),!g&&o&&o.children&&U&&(!this.isFlex(o)||o.isFlexCalc)&&([mt,wt].includes(e)&&this.isFlex()||e==mt&&this.isBlock(this)&&this.isInFlow())&&(it.width=this.contrastSize(U-(o.isFlexCalc?0:nt),v,y),this.layoutBoxUpdate(it,i)),g&&!et(g)&&(it.width=this.contrastSize(g,v,y),this.layoutBoxUpdate(it,i,0)),m&&!et(m)&&(it.height=this.contrastSize(it.height,x,b),this.layoutBoxUpdate(it,i,1));var ft=0;if(a.length){var ut=null,gt=!1;a.forEach((function(e,n){e.getBoxWidthHeight();var r=a[n+1];if(r&&r.isInFlow()&&(e.next=r),e.isInFlow()&&!e.inFlexBox()){var o=t.getBoxState(ut,e);if(e.isBr)return gt=!0;t.line&&t.line.canIEnter(e)&&!o&&!gt?t.line.add(e):(gt=!1,(new pt).bind(e)),ut=e}else e.inFlexBox()?t.line&&(t.line.canIEnter(e)||"nowrap"==i.flexWrap)?t.line.add(e):(new xt).bind(e):e.isFixed?t.root.fixedLine?t.root.fixedLine.fixedAdd(e):(new pt).fixedBind(e):t.fixedLine?t.fixedLine.fixedAdd(e):(new pt).fixedBind(e,1)})),this.lines&&(ft=this.lines.reduce((function(t,e){return t+e.height}),0))}var vt=0,yt=0;if(!g&&(this.isAbsolute||this.isFixed)&&U){var St=B==Mt?U:this.root.width,zt=St-(et(d)?$(d,St):d)-(et(u)?$(u,St):u);vt=i.left?zt:this.lineMaxWidth}if(!m&&(null!=c?c:this.isAbsolute||this.isFixed&&N)){var It=B==Mt?N:this.root.height,Bt=It-(et(c)?$(c,It):c)-(et(f)?$(f,It):f);yt=i.top?Bt:0}if(g&&!et(g)||it.width||(it.width=vt||this.contrastSize((this.isBlock(this)&&!this.isInFlow()?U||o.lineMaxWidth:this.lineMaxWidth)||this.lineMaxWidth,v,y),this.layoutBoxUpdate(it,i,0)),m||!ft&&!yt||(it.height=yt||this.contrastSize(ft,x,b),this.layoutBoxUpdate(it,i)),i.borderRadius&&this.borderSize&&this.borderSize.width)for(var kt in i.borderRadius)Object.hasOwnProperty.call(i.borderRadius,kt)&&(i.borderRadius[kt]=$(i.borderRadius[kt],this.borderSize.width));return this.layoutBox},e.layout=function(){return this.getBoxWidthHeight(),this.root.offsetSize=this.offsetSize,this.root.contentSize=this.contentSize,this.getBoxPosition(),this.offsetSize},t}(),Tt=function(){var t,e,i,n,r,o,s=[0,11,15,19,23,27,31,16,18,20,22,24,26,28,20,22,24,24,26,28,28,22,24,24,26,26,28,28,24,24,26,26,26,28,28,24,26,26,26,28,28],a=[3220,1468,2713,1235,3062,1890,2119,1549,2344,2936,1117,2583,1330,2470,1667,2249,2028,3780,481,4011,142,3098,831,3445,592,2517,1776,2234,1951,2827,1070,2660,1345,3177],h=[30660,29427,32170,30877,26159,25368,27713,26998,21522,20773,24188,23371,17913,16590,20375,19104,13663,12392,16177,14854,9396,8579,11994,11245,5769,5054,7399,6608,1890,597,3340,2107],d=[1,0,19,7,1,0,16,10,1,0,13,13,1,0,9,17,1,0,34,10,1,0,28,16,1,0,22,22,1,0,16,28,1,0,55,15,1,0,44,26,2,0,17,18,2,0,13,22,1,0,80,20,2,0,32,18,2,0,24,26,4,0,9,16,1,0,108,26,2,0,43,24,2,2,15,18,2,2,11,22,2,0,68,18,4,0,27,16,4,0,19,24,4,0,15,28,2,0,78,20,4,0,31,18,2,4,14,18,4,1,13,26,2,0,97,24,2,2,38,22,4,2,18,22,4,2,14,26,2,0,116,30,3,2,36,22,4,4,16,20,4,4,12,24,2,2,68,18,4,1,43,26,6,2,19,24,6,2,15,28,4,0,81,20,1,4,50,30,4,4,22,28,3,8,12,24,2,2,92,24,6,2,36,22,4,6,20,26,7,4,14,28,4,0,107,26,8,1,37,22,8,4,20,24,12,4,11,22,3,1,115,30,4,5,40,24,11,5,16,20,11,5,12,24,5,1,87,22,5,5,41,24,5,7,24,30,11,7,12,24,5,1,98,24,7,3,45,28,15,2,19,24,3,13,15,30,1,5,107,28,10,1,46,28,1,15,22,28,2,17,14,28,5,1,120,30,9,4,43,26,17,1,22,28,2,19,14,28,3,4,113,28,3,11,44,26,17,4,21,26,9,16,13,26,3,5,107,28,3,13,41,26,15,5,24,30,15,10,15,28,4,4,116,28,17,0,42,26,17,6,22,28,19,6,16,30,2,7,111,28,17,0,46,28,7,16,24,30,34,0,13,24,4,5,121,30,4,14,47,28,11,14,24,30,16,14,15,30,6,4,117,30,6,14,45,28,11,16,24,30,30,2,16,30,8,4,106,26,8,13,47,28,7,22,24,30,22,13,15,30,10,2,114,28,19,4,46,28,28,6,22,28,33,4,16,30,8,4,122,30,22,3,45,28,8,26,23,30,12,28,15,30,3,10,117,30,3,23,45,28,4,31,24,30,11,31,15,30,7,7,116,30,21,7,45,28,1,37,23,30,19,26,15,30,5,10,115,30,19,10,47,28,15,25,24,30,23,25,15,30,13,3,115,30,2,29,46,28,42,1,24,30,23,28,15,30,17,0,115,30,10,23,46,28,10,35,24,30,19,35,15,30,17,1,115,30,14,21,46,28,29,19,24,30,11,46,15,30,13,6,115,30,14,23,46,28,44,7,24,30,59,1,16,30,12,7,121,30,12,26,47,28,39,14,24,30,22,41,15,30,6,14,121,30,6,34,47,28,46,10,24,30,2,64,15,30,17,4,122,30,29,14,46,28,49,10,24,30,24,46,15,30,4,18,122,30,13,32,46,28,48,14,24,30,42,32,15,30,20,4,117,30,40,7,47,28,43,22,24,30,10,67,15,30,19,6,118,30,18,31,47,28,34,34,24,30,20,61,15,30],l=[255,0,1,25,2,50,26,198,3,223,51,238,27,104,199,75,4,100,224,14,52,141,239,129,28,193,105,248,200,8,76,113,5,138,101,47,225,36,15,33,53,147,142,218,240,18,130,69,29,181,194,125,106,39,249,185,201,154,9,120,77,228,114,166,6,191,139,98,102,221,48,253,226,152,37,179,16,145,34,136,54,208,148,206,143,150,219,189,241,210,19,92,131,56,70,64,30,66,182,163,195,72,126,110,107,58,40,84,250,133,186,61,202,94,155,159,10,21,121,43,78,212,229,172,115,243,167,87,7,112,192,247,140,128,99,13,103,74,222,237,49,197,254,24,227,165,153,119,38,184,180,124,17,68,146,217,35,32,137,46,55,63,209,91,149,188,207,205,144,135,151,178,220,252,190,97,242,86,211,171,20,42,93,158,132,60,57,83,71,109,65,162,31,45,67,216,183,123,164,118,196,23,73,236,127,12,111,246,108,161,59,82,41,157,85,170,251,96,134,177,187,204,62,90,203,89,95,176,156,169,160,81,11,245,22,235,122,117,44,215,79,174,213,233,230,231,173,232,116,214,244,234,168,80,88,175],c=[1,2,4,8,16,32,64,128,29,58,116,232,205,135,19,38,76,152,45,90,180,117,234,201,143,3,6,12,24,48,96,192,157,39,78,156,37,74,148,53,106,212,181,119,238,193,159,35,70,140,5,10,20,40,80,160,93,186,105,210,185,111,222,161,95,190,97,194,153,47,94,188,101,202,137,15,30,60,120,240,253,231,211,187,107,214,177,127,254,225,223,163,91,182,113,226,217,175,67,134,17,34,68,136,13,26,52,104,208,189,103,206,129,31,62,124,248,237,199,147,59,118,236,197,151,51,102,204,133,23,46,92,184,109,218,169,79,158,33,66,132,21,42,84,168,77,154,41,82,164,85,170,73,146,57,114,228,213,183,115,230,209,191,99,198,145,63,126,252,229,215,179,123,246,241,255,227,219,171,75,150,49,98,196,149,55,110,220,165,87,174,65,130,25,50,100,200,141,7,14,28,56,112,224,221,167,83,166,81,162,89,178,121,242,249,239,195,155,43,86,172,69,138,9,18,36,72,144,61,122,244,245,247,243,251,235,203,139,11,22,44,88,176,125,250,233,207,131,27,54,108,216,173,71,142,0],f=[],u=[],p=[],g=[],v=[],y=2;function x(t,e){var i;t>e&&(i=t,t=e,e=i),i=e,i*=e,i+=e,i>>=1,g[i+=t]=1}function b(t,i){var n;for(p[t+e*i]=1,n=-2;n<2;n++)p[t+n+e*(i-2)]=1,p[t-2+e*(i+n+1)]=1,p[t+2+e*(i+n)]=1,p[t+n+1+e*(i+2)]=1;for(n=0;n<2;n++)x(t-1,i+n),x(t+1,i-n),x(t-n,i-1),x(t+n,i+1)}function w(t){for(;t>=255;)t=((t-=255)>>8)+(255&t);return t}var m=[];function S(t,e,i,n){var r,o,s;for(r=0;re&&(i=t,t=e,e=i),i=e,i+=e*e,i>>=1,g[i+=t]}function I(t){var i,n,r,o;switch(t){case 0:for(n=0;n>1&1,i=0;i=5&&(i+=3+v[e]-5);for(e=3;et||3*v[e-3]>=4*v[e]||3*v[e+3]>=4*v[e])&&(i+=40);return i}function B(){var t,i,n,r,o,s=0,a=0;for(i=0;ie*e;)h-=e*e,d++;for(s+=10*d,t=0;t1)for(P=s[t],k=e-7;;){for(M=e-7;M>P-3&&(b(M,k),!(M6)for(P=a[t-7],W=17,M=0;M<6;M++)for(k=0;k<3;k++,W--)1&(W>11?t>>W-12:P>>W)?(p[5-M+e*(2-k+e-11)]=1,p[2-k+e-11+e*(5-M)]=1):(x(5-M,2-k+e-11),x(2-k+e-11,5-M));for(k=0;k=(M=r*(i+n)+n)-2&&(O=M-2,t>9&&O--),T=O,t>9){for(f[T+2]=0,f[T+3]=0;T--;)P=f[T],f[T+3]|=255&P<<4,f[T+2]=P>>4;f[2]|=255&O<<4,f[1]=O>>4,f[0]=64|O>>12}else{for(f[T+1]=0,f[T+2]=0;T--;)P=f[T],f[T+2]|=255&P<<4,f[T+1]=P>>4;f[1]|=255&O<<4,f[0]=64|O>>4}for(T=O+3-(t<10);T0;L--)m[L]=m[L]?m[L-1]^c[w(l[m[L]]+T)]:m[L-1];m[0]=c[w(l[m[0]]+T)]}for(T=0;T<=o;T++)m[T]=l[m[T]];for(W=M,k=0,T=0;T>=1)1&k&&(p[e-1-W+8*e]=1,W<6?p[8+e*W]=1:p[8+e*(W+1)]=1);for(W=0;W<7;W++,k>>=1)1&k&&(p[8+e*(e-7+W)]=1,W?p[6-W+8*e]=1:p[7+8*e]=1);return p}(v)},utf16to8:function(t){var e,i,n,r;for(e="",n=t.length,i=0;i=1&&r<=127?e+=t.charAt(i):r>2047?(e+=String.fromCharCode(224|r>>12&15),e+=String.fromCharCode(128|r>>6&63),e+=String.fromCharCode(128|r>>0&63)):(e+=String.fromCharCode(192|r>>6&31),e+=String.fromCharCode(128|r>>0&63));return e},draw:function(t,i,n,r,o){i.drawView(n,r);var s=i.ctx,a=n.contentSize,h=a.width,d=a.height,l=a.left,c=a.top;r.borderRadius,r.backgroundColor;var f=r.color,u=void 0===f?"#000000":f;r.border,n.contentSize.left,n.borderSize.left,n.contentSize.top,n.borderSize.top;if(y=o||y,s){s.save(),i.setOpacity(r),i.setTransform(n,r);var p=Math.min(h,d);t=this.utf16to8(t);var g=this.getFrame(t),v=p/e;s.setFillStyle(u);for(var x=0;x=s||n==d&&o=s)&&(a=e.width/i.width);var l=i.width*a,c=i.height*a,f=r||[],u=f[0],p=f[1],g=Y(u)?$(u,e.width):(e.width-l)*(U(u)?$(u,1):{left:0,center:.5,right:1}[u||"center"]),v=Y(p)?$(p,e.height):(e.height-c)*(U(p)?$(p,1):{top:0,center:.5,bottom:1}[p||"center"]),y=function(t,e){return[(t-g)/a,(e-v)/a]},x=y(0,0),b=x[0],w=x[1],m=y(e.width,e.height),S=m[0],z=m[1],I=Math.max,M=Math.min;return{sx:I(b,0),sy:I(w,0),sw:M(S-b,i.width),sh:M(z-w,i.height),dx:I(g,0),dy:I(v,0),dw:M(l,e.width),dh:M(c,e.height)}}({objectFit:u,objectPosition:v},e.contentSize,t),o=n.sx,s=n.sy,a=n.sh,h=n.sw,d=n.dx,l=n.dy,c=n.dh,f=n.dw;j==r.MP_BAIDU?i.drawImage(t.src,d+m,l+S,f,c,o,s,h,a):i.drawImage(t.src,o,s,h,a,d+m,l+S,f,c)}else i.drawImage(t.src,m,S,b,w)},B=function(){i.restore(),k.drawView(e,o,!1,!0,!1),h(1)},function(t){M(t),B()}(t),[2]}))}))}))];case 1:return h.sent(),[2]}}))}))},t.prototype.drawText=function(t,e,i,n){var r=this,o=this.ctx,s=e.borderSize,a=e.contentSize,h=e.left,d=e.top,l=a.width,c=a.height,f=a.left-s.left||0,u=a.top-s.top||0,p=i.color,g=i.lineHeight,v=i.fontSize,y=i.fontWeight,x=i.fontFamily,b=i.fontStyle,w=i.textIndent,m=void 0===w?0:w,S=i.textAlign,z=i.textStroke,I=i.verticalAlign,M=void 0===I?Ct:I,B=i.backgroundColor,k=i.lineClamp,W=i.backgroundClip,P=i.textShadow,O=i.textDecoration;if(m=Y(m)?m:0,this.drawView(e,i,W!=Rt),g=$(g,v),t){o.save(),h+=f,d+=u;var T=n.fontHeight,L=n.descent,R=void 0===L?0:L,F=n.ascent,A=R+(void 0===F?0:F);switch(o.setFonts({fontFamily:x,fontSize:v,fontWeight:y,fontStyle:b}),o.setTextBaseline(Ct),o.setTextAlign(S),W?this.setBackground(B,l,c,h,d):o.setFillStyle(p),S){case Ht:break;case Dt:h+=.5*l;break;case Yt:h+=l}var E=n.lines*g,C=Math.ceil((c-E)/2);switch(C<0&&(C=0),M){case Et:break;case Ct:d+=C;break;case jt:d+=2*C}var j=(g-T)/2,H=g/2,D=function(t){var e=o.measureText(t),i=e.actualBoundingBoxDescent,n=void 0===i?0:i,r=e.actualBoundingBoxAscent;return M==Et?{fix:A?void 0===r?0:r:H-j/2,lineY:A?0:j-j/2}:M==Ct?{fix:A?H+n/4:H,lineY:A?0:j}:M==jt?{fix:A?g-n:H+j/2,lineY:A?2*j:j+j/2}:{fix:0,height:0,lineY:0}},U=function(t,e,i){var r=t;switch(S){case Ht:t=t,r+=i;break;case Dt:r=(t-=i/2)+i;break;case Yt:r=t,t-=i}if(O){o.setLineWidth(v/13),o.beginPath();var s=.1*n.fontHeight;/\bunderline\b/.test(O)&&(o.moveTo(t,e+n.fontHeight+s),o.lineTo(r,e+n.fontHeight+s)),/\boverline\b/.test(O)&&(o.moveTo(t,e-s),o.lineTo(r,e-s)),/\bline-through\b/.test(O)&&(o.moveTo(t,e+.5*n.fontHeight),o.lineTo(r,e+.5*n.fontHeight)),o.closePath(),o.setStrokeStyle(p),o.stroke()}},N=function(t,e,i){var n=function(){o.setLineWidth(z.width),o.setStrokeStyle(z.color),o.strokeText(t,e,i)},s="outset";z&&z.type!==s?(o.save(),r.setShadow({boxShadow:P}),o.fillText(t,e,i),o.restore(),n()):z&&z.type==s?(o.save(),r.setShadow({boxShadow:P}),n(),o.restore(),o.save(),o.fillText(t,e,i),o.restore()):(r.setShadow({boxShadow:P}),o.fillText(t,e,i))};if(!n.widths||1==n.widths.length&&n.widths[0].total+m<=a.width){var _=D(t),X=_.fix,q=void 0===X?0:X,G=_.lineY;return N(t,h+m,d+q),U(h+m,d+G,n&&n.widths&&n.widths[0].total||n.text),d+=g,o.restore(),void this.setBorder(e,i)}for(var V=d,J=h,Q="",Z=0,K=o.measureText("...").width,tt=n.widths,et=0;eta.width){Z>=k&&(Q+="…"),Z++,nt=0;var dt=D(Q);q=dt.fix,G=dt.lineY;N(Q,J,d+q),U(J,d+G,nt),d+=g,Q=""}else if(rt==it.length-1){et!=tt.length-1&&Z==k&&K+ntV+c||Z>k)break}}o.restore()}},t.prototype.source=function(t){return i(this,void 0,void 0,(function(){var e,i,r,o,s=this;return n(this,(function(n){switch(n.label){case 0:if(this.node=null,e=+new Date,"{}"==JSON.stringify(t))return[2];if(!t.type)for(i in t.type=At,t.styles=t.styles||t.css||{},t)["views","children","type","css","styles"].includes(i)||(t.styles[i]=t[i],delete t[i]);return t.styles.boxSizing||(t.styles.boxSizing="border-box"),[4,this.create(t)];case 1:return(r=n.sent())?(o=r.layout()||{},this.size=o,this.node=r,this.onEffectFinished().then((function(t){return s.lifecycle("onEffectSuccess",t)})).catch((function(t){return s.lifecycle("onEffectFail",t)})),this.performance&&console.log("布局用时:"+(+new Date-e)+"ms"),[2,this.size]):[2,console.warn("no node")]}}))}))},t.prototype.getImageInfo=function(t){return this.imageBus[t]||(this.imageBus[t]=this.createImage(t,this.useCORS)),this.imageBus[t]},t.prototype.create=function(t,r){return i(this,void 0,void 0,(function(){function i(t,n,r){void 0===n&&(n={}),void 0===r&&(r=!0);var o=[];return t.forEach((function(t){var s=t.styles,a=void 0===s?{}:s,h=t.children,d=void 0===h?[]:h,l=t.text,c=void 0===l?"":l,f=t.type,u=void 0===f?"":f,p={};p=e(r?e({},n):{},a);var g={},v={},y={};Object.keys(p).map((function(t){if(t.includes("padding")||t.includes("margin")){var e=lt(t,p[t]);Object.keys(e).map((function(t){t.includes("Left")?v[t]=e[t]:t.includes("Right")?y[t]=e[t]:g[t]=e[t]}))}}));if(p.textIndent&&(v.textIndent=p.textIndent,delete n.textIndent),""!==c){var x=Array.from(c);x.forEach((function(t,e){var i=Object.assign({},p,g);0===e?Object.assign(i,v):e==x.length-1&&Object.assign(i,y),delete i.padding,delete i.margin,o.push({type:"text",text:t,styles:i})}))}if(u==Lt||u==Ft)o.push(t);else if("block"===a.display&&d.length>0){var b=i(d,p,!1);t.children=b,t.flattened=!0,o.push(t)}else if(d.length>0){b=i(d,p,r);o=o.concat(b)}})),o}var o,s,a,h,d,l,c,f,u,p,g,v,y,x,b,w,m,S,z,I,M;return n(this,(function(n){switch(n.label){case 0:if(!t)return[2];if(t.styles||(t.styles=t.css||{}),o=t.type,s=o==Lt,a=[Rt,Ft].includes(o),h="textBox"==o,d=t.styles||{},l=d.backgroundImage,c=d.display,s&&!t.src&&!t.url)return[2];if(c==W)return[2];if(a||h){if(f=t.children,!t.text&&(!f||f&&!f.length))return[2];f&&f.length&&!t.flattened&&(u=i(t.children),t.type="view",t.children=u)}if(!(s||t.type==At&&l))return[3,4];p=s?t.src:"",g=/url\((.+)\)/.exec(l),l&&g&&g[1]&&(p=g[1]||""),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.getImageInfo(p)];case 2:return v=n.sent(),y=v.width,x=v.height,!(b=v.path)&&s?[2]:(b&&(t.attributes=Object.assign(t.attributes||{},{width:y,height:x,path:b,src:b,naturalSrc:p})),[3,4]);case 3:return w=n.sent(),t.type!=At?[2]:(this.lifecycle("onEffectFail",e(e({},w),{src:p})),[3,4]);case 4:if(this.count+=1,m=new Ot(t,r,this.root,this.ctx),!(S=t.views||t.children))return[3,8];z=0,n.label=5;case 5:return z0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;r("navigateTo",{url:encodeURI(n)})},navigateBack:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.delta;r("navigateBack",{delta:parseInt(n)||1})},switchTab:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;r("switchTab",{url:encodeURI(n)})},reLaunch:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;r("reLaunch",{url:encodeURI(n)})},redirectTo:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;r("redirectTo",{url:encodeURI(n)})},getEnv:function(e){o()?e({nvue:!0}):window.plus?e({plus:!0}):e({h5:!0})},postMessage:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r("postMessage",e.data||{})}},d=/uni-app/i.test(navigator.userAgent),s=/Html5Plus/i.test(navigator.userAgent),w=/complete|loaded|interactive/;var u=window.my&&navigator.userAgent.indexOf("AlipayClient")>-1;var g=window.swan&&window.swan.webView&&/swan/i.test(navigator.userAgent);var c=window.qq&&window.qq.miniProgram&&/QQ/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var v=window.tt&&window.tt.miniProgram&&/toutiaomicroapp/i.test(navigator.userAgent);var m=window.wx&&window.wx.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var p=window.qa&&/quickapp/i.test(navigator.userAgent);var f=window.ks&&window.ks.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var l=window.tt&&window.tt.miniProgram&&/Lark|Feishu/i.test(navigator.userAgent);var _=window.jd&&window.jd.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);for(var E,b=function(){window.UniAppJSBridge=!0,document.dispatchEvent(new CustomEvent("UniAppJSBridgeReady",{bubbles:!0,cancelable:!0}))},h=[function(e){if(d||s)return window.__dcloud_weex_postMessage||window.__dcloud_weex_?document.addEventListener("DOMContentLoaded",e):window.plus&&w.test(document.readyState)?setTimeout(e,0):document.addEventListener("plusready",e),a},function(e){if(m)return window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(e,0):document.addEventListener("WeixinJSBridgeReady",e),window.wx.miniProgram},function(e){if(c)return window.QQJSBridge&&window.QQJSBridge.invoke?setTimeout(e,0):document.addEventListener("QQJSBridgeReady",e),window.qq.miniProgram},function(e){if(u){document.addEventListener("DOMContentLoaded",e);var n=window.my;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){if(g)return document.addEventListener("DOMContentLoaded",e),window.swan.webView},function(e){if(v)return document.addEventListener("DOMContentLoaded",e),window.tt.miniProgram},function(e){if(p){window.QaJSBridge&&window.QaJSBridge.invoke?setTimeout(e,0):document.addEventListener("QaJSBridgeReady",e);var n=window.qa;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){if(f)return window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(e,0):document.addEventListener("WeixinJSBridgeReady",e),window.ks.miniProgram},function(e){if(l)return document.addEventListener("DOMContentLoaded",e),window.tt.miniProgram},function(e){if(_)return window.JDJSBridgeReady&&window.JDJSBridgeReady.invoke?setTimeout(e,0):document.addEventListener("JDJSBridgeReady",e),window.jd.miniProgram},function(e){return document.addEventListener("DOMContentLoaded",e),a}],y=0;y\s]+))?)*)\s*(\/?)>/; +var endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/; +var attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g; // Empty Elements - HTML 5 + +var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr'); // Block Elements - HTML 5 +// fixed by xxx 将 ins 标签从块级名单中移除 + +var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); // Inline Elements - HTML 5 + +var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); // Elements that you can, intentionally, leave open +// (and which close themselves) + +var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); // Attributes that have their values filled in disabled="disabled" + +var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); // Special Elements (can contain anything) + +var special = makeMap('script,style'); +function HTMLParser(html, handler) { + var index; + var chars; + var match; + var stack = []; + var last = html; + + stack.last = function () { + return this[this.length - 1]; + }; + + while (html) { + chars = true; // Make sure we're not in a script or style element + + if (!stack.last() || !special[stack.last()]) { + // Comment + if (html.indexOf(''); + + if (index >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index)); + } + + html = html.substring(index + 3); + chars = false; + } // end tag + + } else if (html.indexOf(']*>'), function (all, text) { + text = text.replace(/|/g, '$1$2'); + + if (handler.chars) { + handler.chars(text); + } + + return ''; + }); + parseEndTag('', stack.last()); + } + + if (html == last) { + throw 'Parse Error: ' + html; + } + + last = html; + } // Clean up any remaining tags + + + parseEndTag(); + + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag('', stack.last()); + } + } + + if (closeSelf[tagName] && stack.last() == tagName) { + parseEndTag('', tagName); + } + + unary = empty[tagName] || !!unary; + + if (!unary) { + stack.push(tagName); + } + + if (handler.start) { + var attrs = []; + rest.replace(attr, function (match, name) { + var value = arguments[2] ? arguments[2] : arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : fillAttrs[name] ? name : ''; + attrs.push({ + name: name, + value: value, + escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') // " + + }); + }); + + if (handler.start) { + handler.start(tagName, attrs, unary); + } + } + } + + function parseEndTag(tag, tagName) { + // If no tag name is provided, clean shop + if (!tagName) { + var pos = 0; + } // Find the closest opened tag of the same type + else { + for (var pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] == tagName) { + break; + } + } + } + + if (pos >= 0) { + // Close all the open elements, up the stack + for (var i = stack.length - 1; i >= pos; i--) { + if (handler.end) { + handler.end(stack[i]); + } + } // Remove the open elements from the stack + + + stack.length = pos; + } + } +} + +function makeMap(str) { + var obj = {}; + var items = str.split(','); + + for (var i = 0; i < items.length; i++) { + obj[items[i]] = true; + } + + return obj; +} + +function removeDOCTYPE(html) { + return html.replace(/<\?xml.*\?>\n/, '').replace(/\n/, '').replace(/\n/, ''); +} + +function parseAttrs(attrs) { + return attrs.reduce(function (pre, attr) { + var value = attr.value; + var name = attr.name; + if (pre[name]) { + pre[name] = pre[name] + " " + value; + } else { + pre[name] = value; + } + + return pre; + }, {}); +} +function convertStyleStringToJSON(styleString) { + var styles = styleString.split(";"); // 通过分号将样式字符串分割为多个样式声明 + var result = {}; + + styles.forEach(function(style) { + var styleParts = style.split(":"); // 通过冒号将样式声明分割为属性和值 + var property = styleParts[0].trim(); + var value = styleParts[1] && styleParts[1].trim(); + + if (property && value) { + result[property] = value; // 将属性和值添加到结果对象中 + } + }); + + return result; +} +function parseHtml(html) { + html = removeDOCTYPE(html); + var stacks = []; + var results = { + node: 'root', + children: [] + }; + HTMLParser(html, { + start: function start(tag, attrs, unary) { + var node = { + name: tag + }; + + if (attrs.length !== 0) { + node.attrs = parseAttrs(attrs); + node.styles = node.attrs.style ? convertStyleStringToJSON(node.attrs.style) : {} + } + + if(!node.type) { + if(inline[node.name] && node.name !== 'img' ) { + node.type = 'text'; + if(node.name == 'br') { + node.text = '\n' + } else if(node.name == 'strong'){ + node.styles.fontWeight = 'bold' + } + } else if(node.name == 'img'){ + node.type = 'image' + node.src = node.attrs.src + } else { + node.type = 'view' + if(['h1','h2','h3','h4','h5','h6'].includes(node.name)) { + node.styles.fontWeight = 'bold' + } + } + } + if (unary) { + var parent = stacks[0] || results; + + if (!parent.children) { + parent.children = []; + } + + parent.children.push(node); + } else { + stacks.unshift(node); + } + }, + end: function end(tag) { + var node = stacks.shift(); + if (node.name !== tag) console.error('invalid state: mismatch end tag'); + if (stacks.length === 0) { + results.children.push(node); + } else { + var parent = stacks[0]; + + if (!parent.children) { + parent.children = []; + } + parent.children.push(node); + } + const isTextBox = node.children && node.children.length > 1 && node.children.every(child => { + return ['text','image'].includes(child.type) + }) + if(isTextBox) { + node.type = 'textBox' + } + }, + chars: function chars(text) { + var node = { + type: 'text', + text: text + }; + + if (stacks.length === 0) { + results.children.push(node); + } else { + var parent = stacks[0]; + + if (!parent.children) { + parent.children = []; + } + + parent.children.push(node); + } + }, + comment: function comment(text) { + var node = { + node: 'comment', + text: text + }; + var parent = stacks[0]; + + if (!parent.children) { + parent.children = []; + } + + parent.children.push(node); + } + }); + return results.children; +} + +export default parseHtml; \ No newline at end of file diff --git a/uni_modules/lime-painter/readme.md b/uni_modules/lime-painter/readme.md new file mode 100644 index 0000000..47a14ea --- /dev/null +++ b/uni_modules/lime-painter/readme.md @@ -0,0 +1,963 @@ +# Painter 画板 测试版 + +> uniapp 海报画板,更优雅的海报生成方案 +> [查看更多 站点 1](https://limeui.qcoon.cn/#/painter) +> [查看更多 站点 2](http://liangei.gitee.io/limeui/#/painter) +> Q 群:1169785031 + +## 平台兼容 + +| H5 | 微信小程序 | 支付宝小程序 | 百度小程序 | 头条小程序 | QQ 小程序 | App | +| --- | ---------- | ------------ | ---------- | ---------- | --------- | --- | +| √ | √ | √ | 未测 | √ | √ | √ | + +## 安装 +在市场导入**[海报画板](https://ext.dcloud.net.cn/plugin?id=2389)uni_modules**版本的即可,无需`import` + +## 代码演示 + +### 插件demo +- lime-painter 为 demo +- 位于 uni_modules/lime-painter/components/lime-painter +- 导入插件后直接使用可查看demo +```vue + +``` + + +### 基本用法 + +- 插件提供 JSON 及 Template 的方式绘制海报 +- 参考 css 块状流布局模拟 css schema。 +- 另外flex布局还不是成完善,请谨慎使用,普通的流布局我觉得已经够用了。 + +#### 方式一 Template + +- 提供`l-painter-view`、`l-painter-text`、`l-painter-image`、`l-painter-qrcode`四种类型组件 +- 通过 `css` 属性绘制样式,与 style 使用方式保持一致。 +```html + + //如果使用Template出现顺序错乱,可使用`template` 等所有变量完成再显示 +