From 933673b09214eba3be32413be2f682b1de36fe8e Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Sat, 14 Dec 2019 09:20:48 +0800 Subject: [PATCH 1/3] vant --- utils/dist/action-sheet/index.d.ts | 1 + utils/dist/action-sheet/index.js | 59 ++++ utils/dist/action-sheet/index.json | 8 + utils/dist/action-sheet/index.wxml | 54 ++++ utils/dist/action-sheet/index.wxss | 1 + utils/dist/area/index.d.ts | 1 + utils/dist/area/index.js | 210 +++++++++++++ utils/dist/area/index.json | 6 + utils/dist/area/index.wxml | 18 ++ utils/dist/area/index.wxss | 1 + utils/dist/button/index.d.ts | 1 + utils/dist/button/index.js | 68 +++++ utils/dist/button/index.json | 7 + utils/dist/button/index.wxml | 52 ++++ utils/dist/button/index.wxss | 1 + utils/dist/card/index.d.ts | 1 + utils/dist/card/index.js | 38 +++ utils/dist/card/index.json | 6 + utils/dist/card/index.wxml | 45 +++ utils/dist/card/index.wxss | 1 + utils/dist/cell-group/index.d.ts | 1 + utils/dist/cell-group/index.js | 10 + utils/dist/cell-group/index.json | 3 + utils/dist/cell-group/index.wxml | 9 + utils/dist/cell-group/index.wxss | 1 + utils/dist/cell/index.d.ts | 1 + utils/dist/cell/index.js | 37 +++ utils/dist/cell/index.json | 6 + utils/dist/cell/index.wxml | 45 +++ utils/dist/cell/index.wxss | 1 + utils/dist/checkbox-group/index.d.ts | 1 + utils/dist/checkbox-group/index.js | 39 +++ utils/dist/checkbox-group/index.json | 3 + utils/dist/checkbox-group/index.wxml | 1 + utils/dist/checkbox-group/index.wxss | 1 + utils/dist/checkbox/index.d.ts | 1 + utils/dist/checkbox/index.js | 87 ++++++ utils/dist/checkbox/index.json | 6 + utils/dist/checkbox/index.wxml | 19 ++ utils/dist/checkbox/index.wxss | 1 + utils/dist/circle/index.d.ts | 1 + utils/dist/circle/index.js | 158 ++++++++++ utils/dist/circle/index.json | 3 + utils/dist/circle/index.wxml | 7 + utils/dist/circle/index.wxss | 1 + utils/dist/col/index.d.ts | 1 + utils/dist/col/index.js | 23 ++ utils/dist/col/index.json | 3 + utils/dist/col/index.wxml | 8 + utils/dist/col/index.wxss | 1 + utils/dist/collapse-item/index.d.ts | 1 + utils/dist/collapse-item/index.js | 96 ++++++ utils/dist/collapse-item/index.json | 6 + utils/dist/collapse-item/index.wxml | 44 +++ utils/dist/collapse-item/index.wxss | 1 + utils/dist/collapse/index.d.ts | 1 + utils/dist/collapse/index.js | 50 ++++ utils/dist/collapse/index.json | 3 + utils/dist/collapse/index.wxml | 3 + utils/dist/collapse/index.wxss | 1 + utils/dist/common/color.d.ts | 7 + utils/dist/common/color.js | 7 + utils/dist/common/component.d.ts | 3 + utils/dist/common/component.js | 48 +++ utils/dist/common/index.wxss | 1 + utils/dist/common/style/clearfix.wxss | 1 + utils/dist/common/style/ellipsis.wxss | 1 + utils/dist/common/style/hairline.wxss | 1 + utils/dist/common/style/mixins/clearfix.wxss | 0 utils/dist/common/style/mixins/ellipsis.wxss | 0 utils/dist/common/style/mixins/hairline.wxss | 0 utils/dist/common/style/theme.wxss | 0 utils/dist/common/style/var.wxss | 0 utils/dist/common/utils.d.ts | 8 + utils/dist/common/utils.js | 32 ++ utils/dist/count-down/index.d.ts | 1 + utils/dist/count-down/index.js | 100 +++++++ utils/dist/count-down/index.json | 3 + utils/dist/count-down/index.wxml | 4 + utils/dist/count-down/index.wxss | 1 + utils/dist/count-down/utils.d.ts | 10 + utils/dist/count-down/utils.js | 57 ++++ utils/dist/datetime-picker/index.d.ts | 1 + utils/dist/datetime-picker/index.js | 297 +++++++++++++++++++ utils/dist/datetime-picker/index.json | 6 + utils/dist/datetime-picker/index.wxml | 16 + utils/dist/datetime-picker/index.wxss | 1 + utils/dist/definitions/index.d.ts | 28 ++ utils/dist/definitions/index.js | 0 utils/dist/definitions/weapp.d.ts | 112 +++++++ utils/dist/definitions/weapp.js | 0 utils/dist/dialog/dialog.d.ts | 47 +++ utils/dist/dialog/dialog.js | 63 ++++ utils/dist/dialog/index.d.ts | 1 + utils/dist/dialog/index.js | 119 ++++++++ utils/dist/dialog/index.json | 7 + utils/dist/dialog/index.wxml | 69 +++++ utils/dist/dialog/index.wxss | 1 + utils/dist/divider/index.d.ts | 1 + utils/dist/divider/index.js | 33 +++ utils/dist/divider/index.json | 4 + utils/dist/divider/index.wxml | 8 + utils/dist/divider/index.wxss | 1 + utils/dist/dropdown-item/index.d.ts | 1 + utils/dist/dropdown-item/index.js | 104 +++++++ utils/dist/dropdown-item/index.json | 8 + utils/dist/dropdown-item/index.wxml | 44 +++ utils/dist/dropdown-item/index.wxss | 1 + utils/dist/dropdown-menu/index.d.ts | 1 + utils/dist/dropdown-menu/index.js | 121 ++++++++ utils/dist/dropdown-menu/index.json | 3 + utils/dist/dropdown-menu/index.wxml | 23 ++ utils/dist/dropdown-menu/index.wxs | 16 + utils/dist/dropdown-menu/index.wxss | 1 + utils/dist/field/index.d.ts | 1 + utils/dist/field/index.js | 108 +++++++ utils/dist/field/index.json | 7 + utils/dist/field/index.wxml | 93 ++++++ utils/dist/field/index.wxss | 1 + utils/dist/goods-action-button/index.d.ts | 1 + utils/dist/goods-action-button/index.js | 41 +++ utils/dist/goods-action-button/index.json | 6 + utils/dist/goods-action-button/index.wxml | 28 ++ utils/dist/goods-action-button/index.wxss | 1 + utils/dist/goods-action-icon/index.d.ts | 1 + utils/dist/goods-action-icon/index.js | 22 ++ utils/dist/goods-action-icon/index.json | 7 + utils/dist/goods-action-icon/index.wxml | 38 +++ utils/dist/goods-action-icon/index.wxss | 1 + utils/dist/goods-action/index.d.ts | 1 + utils/dist/goods-action/index.js | 22 ++ utils/dist/goods-action/index.json | 3 + utils/dist/goods-action/index.wxml | 5 + utils/dist/goods-action/index.wxss | 1 + utils/dist/grid-item/index.d.ts | 1 + utils/dist/grid-item/index.js | 68 +++++ utils/dist/grid-item/index.json | 6 + utils/dist/grid-item/index.wxml | 22 ++ utils/dist/grid-item/index.wxss | 1 + utils/dist/grid/index.d.ts | 1 + utils/dist/grid/index.js | 62 ++++ utils/dist/grid/index.json | 3 + utils/dist/grid/index.wxml | 3 + utils/dist/grid/index.wxss | 1 + utils/dist/icon/index.d.ts | 1 + utils/dist/icon/index.js | 39 +++ utils/dist/icon/index.json | 6 + utils/dist/icon/index.wxml | 18 ++ utils/dist/icon/index.wxss | 1 + utils/dist/image/index.d.ts | 1 + utils/dist/image/index.js | 98 ++++++ utils/dist/image/index.json | 7 + utils/dist/image/index.wxml | 33 +++ utils/dist/image/index.wxss | 1 + utils/dist/index-anchor/index.d.ts | 1 + utils/dist/index-anchor/index.js | 22 ++ utils/dist/index-anchor/index.json | 3 + utils/dist/index-anchor/index.wxml | 14 + utils/dist/index-anchor/index.wxss | 1 + utils/dist/index-bar/index.d.ts | 1 + utils/dist/index-bar/index.js | 240 +++++++++++++++ utils/dist/index-bar/index.json | 3 + utils/dist/index-bar/index.wxml | 22 ++ utils/dist/index-bar/index.wxss | 1 + utils/dist/info/index.d.ts | 1 + utils/dist/info/index.js | 8 + utils/dist/info/index.json | 3 + utils/dist/info/index.wxml | 7 + utils/dist/info/index.wxss | 1 + utils/dist/loading/index.d.ts | 1 + utils/dist/loading/index.js | 32 ++ utils/dist/loading/index.json | 3 + utils/dist/loading/index.wxml | 16 + utils/dist/loading/index.wxss | 1 + utils/dist/mixins/basic.d.ts | 1 + utils/dist/mixins/basic.js | 22 ++ utils/dist/mixins/button.d.ts | 1 + utils/dist/mixins/button.js | 18 ++ utils/dist/mixins/link.d.ts | 1 + utils/dist/mixins/link.js | 17 ++ utils/dist/mixins/observer/behavior.d.ts | 1 + utils/dist/mixins/observer/behavior.js | 14 + utils/dist/mixins/observer/index.d.ts | 1 + utils/dist/mixins/observer/index.js | 19 ++ utils/dist/mixins/open-type.d.ts | 1 + utils/dist/mixins/open-type.js | 25 ++ utils/dist/mixins/touch.d.ts | 1 + utils/dist/mixins/touch.js | 35 +++ utils/dist/mixins/transition.d.ts | 1 + utils/dist/mixins/transition.js | 120 ++++++++ utils/dist/nav-bar/index.d.ts | 1 + utils/dist/nav-bar/index.js | 38 +++ utils/dist/nav-bar/index.json | 6 + utils/dist/nav-bar/index.wxml | 37 +++ utils/dist/nav-bar/index.wxss | 1 + utils/dist/notice-bar/index.d.ts | 1 + utils/dist/notice-bar/index.js | 123 ++++++++ utils/dist/notice-bar/index.json | 6 + utils/dist/notice-bar/index.wxml | 37 +++ utils/dist/notice-bar/index.wxss | 1 + utils/dist/notify/index.d.ts | 1 + utils/dist/notify/index.js | 59 ++++ utils/dist/notify/index.json | 6 + utils/dist/notify/index.wxml | 15 + utils/dist/notify/index.wxss | 1 + utils/dist/notify/notify.d.ts | 19 ++ utils/dist/notify/notify.js | 41 +++ utils/dist/overlay/index.d.ts | 1 + utils/dist/overlay/index.js | 22 ++ utils/dist/overlay/index.json | 6 + utils/dist/overlay/index.wxml | 10 + utils/dist/overlay/index.wxss | 1 + utils/dist/panel/index.d.ts | 1 + utils/dist/panel/index.js | 10 + utils/dist/panel/index.json | 6 + utils/dist/panel/index.wxml | 19 ++ utils/dist/panel/index.wxss | 1 + utils/dist/picker-column/index.d.ts | 1 + utils/dist/picker-column/index.js | 119 ++++++++ utils/dist/picker-column/index.json | 3 + utils/dist/picker-column/index.wxml | 22 ++ utils/dist/picker-column/index.wxs | 8 + utils/dist/picker-column/index.wxss | 1 + utils/dist/picker/index.d.ts | 1 + utils/dist/picker/index.js | 135 +++++++++ utils/dist/picker/index.json | 7 + utils/dist/picker/index.wxml | 65 ++++ utils/dist/picker/index.wxss | 1 + utils/dist/picker/shared.d.ts | 21 ++ utils/dist/picker/shared.js | 21 ++ utils/dist/popup/index.d.ts | 1 + utils/dist/popup/index.js | 80 +++++ utils/dist/popup/index.json | 7 + utils/dist/popup/index.wxml | 24 ++ utils/dist/popup/index.wxss | 1 + utils/dist/progress/index.d.ts | 1 + utils/dist/progress/index.js | 38 +++ utils/dist/progress/index.json | 3 + utils/dist/progress/index.wxml | 19 ++ utils/dist/progress/index.wxs | 5 + utils/dist/progress/index.wxss | 1 + utils/dist/radio-group/index.d.ts | 1 + utils/dist/radio-group/index.js | 38 +++ utils/dist/radio-group/index.json | 3 + utils/dist/radio-group/index.wxml | 1 + utils/dist/radio-group/index.wxss | 1 + utils/dist/radio/index.d.ts | 1 + utils/dist/radio/index.js | 60 ++++ utils/dist/radio/index.json | 6 + utils/dist/radio/index.wxml | 29 ++ utils/dist/radio/index.wxss | 1 + utils/dist/rate/index.d.ts | 1 + utils/dist/rate/index.js | 95 ++++++ utils/dist/rate/index.json | 6 + utils/dist/rate/index.wxml | 34 +++ utils/dist/rate/index.wxss | 1 + utils/dist/row/index.d.ts | 1 + utils/dist/row/index.js | 36 +++ utils/dist/row/index.json | 3 + utils/dist/row/index.wxml | 3 + utils/dist/row/index.wxss | 1 + utils/dist/search/index.d.ts | 1 + utils/dist/search/index.js | 73 +++++ utils/dist/search/index.json | 6 + utils/dist/search/index.wxml | 50 ++++ utils/dist/search/index.wxss | 1 + utils/dist/sidebar-item/index.d.ts | 1 + utils/dist/sidebar-item/index.js | 36 +++ utils/dist/sidebar-item/index.json | 6 + utils/dist/sidebar-item/index.wxml | 18 ++ utils/dist/sidebar-item/index.wxss | 1 + utils/dist/sidebar/index.d.ts | 1 + utils/dist/sidebar/index.js | 43 +++ utils/dist/sidebar/index.json | 3 + utils/dist/sidebar/index.wxml | 3 + utils/dist/sidebar/index.wxss | 1 + utils/dist/skeleton/index.d.ts | 1 + utils/dist/skeleton/index.js | 41 +++ utils/dist/skeleton/index.json | 4 + utils/dist/skeleton/index.wxml | 29 ++ utils/dist/skeleton/index.wxss | 1 + utils/dist/slider/index.d.ts | 1 + utils/dist/slider/index.js | 107 +++++++ utils/dist/slider/index.json | 3 + utils/dist/slider/index.wxml | 29 ++ utils/dist/slider/index.wxss | 1 + utils/dist/stepper/index.d.ts | 1 + utils/dist/stepper/index.js | 172 +++++++++++ utils/dist/stepper/index.json | 3 + utils/dist/stepper/index.wxml | 37 +++ utils/dist/stepper/index.wxss | 1 + utils/dist/steps/index.d.ts | 1 + utils/dist/steps/index.js | 22 ++ utils/dist/steps/index.json | 6 + utils/dist/steps/index.wxml | 51 ++++ utils/dist/steps/index.wxss | 1 + utils/dist/sticky/index.d.ts | 1 + utils/dist/sticky/index.js | 140 +++++++++ utils/dist/sticky/index.json | 3 + utils/dist/sticky/index.wxml | 7 + utils/dist/sticky/index.wxss | 1 + utils/dist/submit-bar/index.d.ts | 1 + utils/dist/submit-bar/index.js | 57 ++++ utils/dist/submit-bar/index.json | 7 + utils/dist/submit-bar/index.wxml | 42 +++ utils/dist/submit-bar/index.wxss | 1 + utils/dist/swipe-cell/index.d.ts | 1 + utils/dist/swipe-cell/index.js | 122 ++++++++ utils/dist/swipe-cell/index.json | 3 + utils/dist/swipe-cell/index.wxml | 20 ++ utils/dist/swipe-cell/index.wxss | 1 + utils/dist/switch/index.d.ts | 1 + utils/dist/switch/index.js | 51 ++++ utils/dist/switch/index.json | 6 + utils/dist/switch/index.wxml | 11 + utils/dist/switch/index.wxss | 1 + utils/dist/tab/index.d.ts | 1 + utils/dist/tab/index.js | 56 ++++ utils/dist/tab/index.json | 3 + utils/dist/tab/index.wxml | 8 + utils/dist/tab/index.wxss | 1 + utils/dist/tabbar-item/index.d.ts | 1 + utils/dist/tabbar-item/index.js | 47 +++ utils/dist/tabbar-item/index.json | 7 + utils/dist/tabbar-item/index.wxml | 30 ++ utils/dist/tabbar-item/index.wxss | 1 + utils/dist/tabbar/index.d.ts | 1 + utils/dist/tabbar/index.js | 65 ++++ utils/dist/tabbar/index.json | 3 + utils/dist/tabbar/index.wxml | 8 + utils/dist/tabbar/index.wxss | 1 + utils/dist/tabs/index.d.ts | 1 + utils/dist/tabs/index.js | 289 ++++++++++++++++++ utils/dist/tabs/index.json | 7 + utils/dist/tabs/index.wxml | 60 ++++ utils/dist/tabs/index.wxs | 55 ++++ utils/dist/tabs/index.wxss | 1 + utils/dist/tag/index.d.ts | 1 + utils/dist/tag/index.js | 21 ++ utils/dist/tag/index.json | 3 + utils/dist/tag/index.wxml | 14 + utils/dist/tag/index.wxss | 1 + utils/dist/toast/index.d.ts | 1 + utils/dist/toast/index.js | 29 ++ utils/dist/toast/index.json | 9 + utils/dist/toast/index.wxml | 33 +++ utils/dist/toast/index.wxss | 1 + utils/dist/toast/toast.d.ts | 26 ++ utils/dist/toast/toast.js | 66 +++++ utils/dist/transition/index.d.ts | 1 + utils/dist/transition/index.js | 13 + utils/dist/transition/index.json | 3 + utils/dist/transition/index.wxml | 8 + utils/dist/transition/index.wxss | 1 + utils/dist/tree-select/index.d.ts | 1 + utils/dist/tree-select/index.js | 74 +++++ utils/dist/tree-select/index.json | 8 + utils/dist/tree-select/index.wxml | 39 +++ utils/dist/tree-select/index.wxs | 12 + utils/dist/tree-select/index.wxss | 1 + utils/dist/uploader/index.d.ts | 1 + utils/dist/uploader/index.js | 151 ++++++++++ utils/dist/uploader/index.json | 6 + utils/dist/uploader/index.wxml | 57 ++++ utils/dist/uploader/index.wxss | 1 + utils/dist/uploader/utils.d.ts | 12 + utils/dist/uploader/utils.js | 16 + utils/dist/wxs/array.wxs | 5 + utils/dist/wxs/bem.wxs | 38 +++ utils/dist/wxs/memoize.wxs | 54 ++++ utils/dist/wxs/object.wxs | 13 + utils/dist/wxs/utils.wxs | 7 + 372 files changed, 8090 insertions(+) create mode 100644 utils/dist/action-sheet/index.d.ts create mode 100644 utils/dist/action-sheet/index.js create mode 100644 utils/dist/action-sheet/index.json create mode 100644 utils/dist/action-sheet/index.wxml create mode 100644 utils/dist/action-sheet/index.wxss create mode 100644 utils/dist/area/index.d.ts create mode 100644 utils/dist/area/index.js create mode 100644 utils/dist/area/index.json create mode 100644 utils/dist/area/index.wxml create mode 100644 utils/dist/area/index.wxss create mode 100644 utils/dist/button/index.d.ts create mode 100644 utils/dist/button/index.js create mode 100644 utils/dist/button/index.json create mode 100644 utils/dist/button/index.wxml create mode 100644 utils/dist/button/index.wxss create mode 100644 utils/dist/card/index.d.ts create mode 100644 utils/dist/card/index.js create mode 100644 utils/dist/card/index.json create mode 100644 utils/dist/card/index.wxml create mode 100644 utils/dist/card/index.wxss create mode 100644 utils/dist/cell-group/index.d.ts create mode 100644 utils/dist/cell-group/index.js create mode 100644 utils/dist/cell-group/index.json create mode 100644 utils/dist/cell-group/index.wxml create mode 100644 utils/dist/cell-group/index.wxss create mode 100644 utils/dist/cell/index.d.ts create mode 100644 utils/dist/cell/index.js create mode 100644 utils/dist/cell/index.json create mode 100644 utils/dist/cell/index.wxml create mode 100644 utils/dist/cell/index.wxss create mode 100644 utils/dist/checkbox-group/index.d.ts create mode 100644 utils/dist/checkbox-group/index.js create mode 100644 utils/dist/checkbox-group/index.json create mode 100644 utils/dist/checkbox-group/index.wxml create mode 100644 utils/dist/checkbox-group/index.wxss create mode 100644 utils/dist/checkbox/index.d.ts create mode 100644 utils/dist/checkbox/index.js create mode 100644 utils/dist/checkbox/index.json create mode 100644 utils/dist/checkbox/index.wxml create mode 100644 utils/dist/checkbox/index.wxss create mode 100644 utils/dist/circle/index.d.ts create mode 100644 utils/dist/circle/index.js create mode 100644 utils/dist/circle/index.json create mode 100644 utils/dist/circle/index.wxml create mode 100644 utils/dist/circle/index.wxss create mode 100644 utils/dist/col/index.d.ts create mode 100644 utils/dist/col/index.js create mode 100644 utils/dist/col/index.json create mode 100644 utils/dist/col/index.wxml create mode 100644 utils/dist/col/index.wxss create mode 100644 utils/dist/collapse-item/index.d.ts create mode 100644 utils/dist/collapse-item/index.js create mode 100644 utils/dist/collapse-item/index.json create mode 100644 utils/dist/collapse-item/index.wxml create mode 100644 utils/dist/collapse-item/index.wxss create mode 100644 utils/dist/collapse/index.d.ts create mode 100644 utils/dist/collapse/index.js create mode 100644 utils/dist/collapse/index.json create mode 100644 utils/dist/collapse/index.wxml create mode 100644 utils/dist/collapse/index.wxss create mode 100644 utils/dist/common/color.d.ts create mode 100644 utils/dist/common/color.js create mode 100644 utils/dist/common/component.d.ts create mode 100644 utils/dist/common/component.js create mode 100644 utils/dist/common/index.wxss create mode 100644 utils/dist/common/style/clearfix.wxss create mode 100644 utils/dist/common/style/ellipsis.wxss create mode 100644 utils/dist/common/style/hairline.wxss create mode 100644 utils/dist/common/style/mixins/clearfix.wxss create mode 100644 utils/dist/common/style/mixins/ellipsis.wxss create mode 100644 utils/dist/common/style/mixins/hairline.wxss create mode 100644 utils/dist/common/style/theme.wxss create mode 100644 utils/dist/common/style/var.wxss create mode 100644 utils/dist/common/utils.d.ts create mode 100644 utils/dist/common/utils.js create mode 100644 utils/dist/count-down/index.d.ts create mode 100644 utils/dist/count-down/index.js create mode 100644 utils/dist/count-down/index.json create mode 100644 utils/dist/count-down/index.wxml create mode 100644 utils/dist/count-down/index.wxss create mode 100644 utils/dist/count-down/utils.d.ts create mode 100644 utils/dist/count-down/utils.js create mode 100644 utils/dist/datetime-picker/index.d.ts create mode 100644 utils/dist/datetime-picker/index.js create mode 100644 utils/dist/datetime-picker/index.json create mode 100644 utils/dist/datetime-picker/index.wxml create mode 100644 utils/dist/datetime-picker/index.wxss create mode 100644 utils/dist/definitions/index.d.ts create mode 100644 utils/dist/definitions/index.js create mode 100644 utils/dist/definitions/weapp.d.ts create mode 100644 utils/dist/definitions/weapp.js create mode 100644 utils/dist/dialog/dialog.d.ts create mode 100644 utils/dist/dialog/dialog.js create mode 100644 utils/dist/dialog/index.d.ts create mode 100644 utils/dist/dialog/index.js create mode 100644 utils/dist/dialog/index.json create mode 100644 utils/dist/dialog/index.wxml create mode 100644 utils/dist/dialog/index.wxss create mode 100644 utils/dist/divider/index.d.ts create mode 100644 utils/dist/divider/index.js create mode 100644 utils/dist/divider/index.json create mode 100644 utils/dist/divider/index.wxml create mode 100644 utils/dist/divider/index.wxss create mode 100644 utils/dist/dropdown-item/index.d.ts create mode 100644 utils/dist/dropdown-item/index.js create mode 100644 utils/dist/dropdown-item/index.json create mode 100644 utils/dist/dropdown-item/index.wxml create mode 100644 utils/dist/dropdown-item/index.wxss create mode 100644 utils/dist/dropdown-menu/index.d.ts create mode 100644 utils/dist/dropdown-menu/index.js create mode 100644 utils/dist/dropdown-menu/index.json create mode 100644 utils/dist/dropdown-menu/index.wxml create mode 100644 utils/dist/dropdown-menu/index.wxs create mode 100644 utils/dist/dropdown-menu/index.wxss create mode 100644 utils/dist/field/index.d.ts create mode 100644 utils/dist/field/index.js create mode 100644 utils/dist/field/index.json create mode 100644 utils/dist/field/index.wxml create mode 100644 utils/dist/field/index.wxss create mode 100644 utils/dist/goods-action-button/index.d.ts create mode 100644 utils/dist/goods-action-button/index.js create mode 100644 utils/dist/goods-action-button/index.json create mode 100644 utils/dist/goods-action-button/index.wxml create mode 100644 utils/dist/goods-action-button/index.wxss create mode 100644 utils/dist/goods-action-icon/index.d.ts create mode 100644 utils/dist/goods-action-icon/index.js create mode 100644 utils/dist/goods-action-icon/index.json create mode 100644 utils/dist/goods-action-icon/index.wxml create mode 100644 utils/dist/goods-action-icon/index.wxss create mode 100644 utils/dist/goods-action/index.d.ts create mode 100644 utils/dist/goods-action/index.js create mode 100644 utils/dist/goods-action/index.json create mode 100644 utils/dist/goods-action/index.wxml create mode 100644 utils/dist/goods-action/index.wxss create mode 100644 utils/dist/grid-item/index.d.ts create mode 100644 utils/dist/grid-item/index.js create mode 100644 utils/dist/grid-item/index.json create mode 100644 utils/dist/grid-item/index.wxml create mode 100644 utils/dist/grid-item/index.wxss create mode 100644 utils/dist/grid/index.d.ts create mode 100644 utils/dist/grid/index.js create mode 100644 utils/dist/grid/index.json create mode 100644 utils/dist/grid/index.wxml create mode 100644 utils/dist/grid/index.wxss create mode 100644 utils/dist/icon/index.d.ts create mode 100644 utils/dist/icon/index.js create mode 100644 utils/dist/icon/index.json create mode 100644 utils/dist/icon/index.wxml create mode 100644 utils/dist/icon/index.wxss create mode 100644 utils/dist/image/index.d.ts create mode 100644 utils/dist/image/index.js create mode 100644 utils/dist/image/index.json create mode 100644 utils/dist/image/index.wxml create mode 100644 utils/dist/image/index.wxss create mode 100644 utils/dist/index-anchor/index.d.ts create mode 100644 utils/dist/index-anchor/index.js create mode 100644 utils/dist/index-anchor/index.json create mode 100644 utils/dist/index-anchor/index.wxml create mode 100644 utils/dist/index-anchor/index.wxss create mode 100644 utils/dist/index-bar/index.d.ts create mode 100644 utils/dist/index-bar/index.js create mode 100644 utils/dist/index-bar/index.json create mode 100644 utils/dist/index-bar/index.wxml create mode 100644 utils/dist/index-bar/index.wxss create mode 100644 utils/dist/info/index.d.ts create mode 100644 utils/dist/info/index.js create mode 100644 utils/dist/info/index.json create mode 100644 utils/dist/info/index.wxml create mode 100644 utils/dist/info/index.wxss create mode 100644 utils/dist/loading/index.d.ts create mode 100644 utils/dist/loading/index.js create mode 100644 utils/dist/loading/index.json create mode 100644 utils/dist/loading/index.wxml create mode 100644 utils/dist/loading/index.wxss create mode 100644 utils/dist/mixins/basic.d.ts create mode 100644 utils/dist/mixins/basic.js create mode 100644 utils/dist/mixins/button.d.ts create mode 100644 utils/dist/mixins/button.js create mode 100644 utils/dist/mixins/link.d.ts create mode 100644 utils/dist/mixins/link.js create mode 100644 utils/dist/mixins/observer/behavior.d.ts create mode 100644 utils/dist/mixins/observer/behavior.js create mode 100644 utils/dist/mixins/observer/index.d.ts create mode 100644 utils/dist/mixins/observer/index.js create mode 100644 utils/dist/mixins/open-type.d.ts create mode 100644 utils/dist/mixins/open-type.js create mode 100644 utils/dist/mixins/touch.d.ts create mode 100644 utils/dist/mixins/touch.js create mode 100644 utils/dist/mixins/transition.d.ts create mode 100644 utils/dist/mixins/transition.js create mode 100644 utils/dist/nav-bar/index.d.ts create mode 100644 utils/dist/nav-bar/index.js create mode 100644 utils/dist/nav-bar/index.json create mode 100644 utils/dist/nav-bar/index.wxml create mode 100644 utils/dist/nav-bar/index.wxss create mode 100644 utils/dist/notice-bar/index.d.ts create mode 100644 utils/dist/notice-bar/index.js create mode 100644 utils/dist/notice-bar/index.json create mode 100644 utils/dist/notice-bar/index.wxml create mode 100644 utils/dist/notice-bar/index.wxss create mode 100644 utils/dist/notify/index.d.ts create mode 100644 utils/dist/notify/index.js create mode 100644 utils/dist/notify/index.json create mode 100644 utils/dist/notify/index.wxml create mode 100644 utils/dist/notify/index.wxss create mode 100644 utils/dist/notify/notify.d.ts create mode 100644 utils/dist/notify/notify.js create mode 100644 utils/dist/overlay/index.d.ts create mode 100644 utils/dist/overlay/index.js create mode 100644 utils/dist/overlay/index.json create mode 100644 utils/dist/overlay/index.wxml create mode 100644 utils/dist/overlay/index.wxss create mode 100644 utils/dist/panel/index.d.ts create mode 100644 utils/dist/panel/index.js create mode 100644 utils/dist/panel/index.json create mode 100644 utils/dist/panel/index.wxml create mode 100644 utils/dist/panel/index.wxss create mode 100644 utils/dist/picker-column/index.d.ts create mode 100644 utils/dist/picker-column/index.js create mode 100644 utils/dist/picker-column/index.json create mode 100644 utils/dist/picker-column/index.wxml create mode 100644 utils/dist/picker-column/index.wxs create mode 100644 utils/dist/picker-column/index.wxss create mode 100644 utils/dist/picker/index.d.ts create mode 100644 utils/dist/picker/index.js create mode 100644 utils/dist/picker/index.json create mode 100644 utils/dist/picker/index.wxml create mode 100644 utils/dist/picker/index.wxss create mode 100644 utils/dist/picker/shared.d.ts create mode 100644 utils/dist/picker/shared.js create mode 100644 utils/dist/popup/index.d.ts create mode 100644 utils/dist/popup/index.js create mode 100644 utils/dist/popup/index.json create mode 100644 utils/dist/popup/index.wxml create mode 100644 utils/dist/popup/index.wxss create mode 100644 utils/dist/progress/index.d.ts create mode 100644 utils/dist/progress/index.js create mode 100644 utils/dist/progress/index.json create mode 100644 utils/dist/progress/index.wxml create mode 100644 utils/dist/progress/index.wxs create mode 100644 utils/dist/progress/index.wxss create mode 100644 utils/dist/radio-group/index.d.ts create mode 100644 utils/dist/radio-group/index.js create mode 100644 utils/dist/radio-group/index.json create mode 100644 utils/dist/radio-group/index.wxml create mode 100644 utils/dist/radio-group/index.wxss create mode 100644 utils/dist/radio/index.d.ts create mode 100644 utils/dist/radio/index.js create mode 100644 utils/dist/radio/index.json create mode 100644 utils/dist/radio/index.wxml create mode 100644 utils/dist/radio/index.wxss create mode 100644 utils/dist/rate/index.d.ts create mode 100644 utils/dist/rate/index.js create mode 100644 utils/dist/rate/index.json create mode 100644 utils/dist/rate/index.wxml create mode 100644 utils/dist/rate/index.wxss create mode 100644 utils/dist/row/index.d.ts create mode 100644 utils/dist/row/index.js create mode 100644 utils/dist/row/index.json create mode 100644 utils/dist/row/index.wxml create mode 100644 utils/dist/row/index.wxss create mode 100644 utils/dist/search/index.d.ts create mode 100644 utils/dist/search/index.js create mode 100644 utils/dist/search/index.json create mode 100644 utils/dist/search/index.wxml create mode 100644 utils/dist/search/index.wxss create mode 100644 utils/dist/sidebar-item/index.d.ts create mode 100644 utils/dist/sidebar-item/index.js create mode 100644 utils/dist/sidebar-item/index.json create mode 100644 utils/dist/sidebar-item/index.wxml create mode 100644 utils/dist/sidebar-item/index.wxss create mode 100644 utils/dist/sidebar/index.d.ts create mode 100644 utils/dist/sidebar/index.js create mode 100644 utils/dist/sidebar/index.json create mode 100644 utils/dist/sidebar/index.wxml create mode 100644 utils/dist/sidebar/index.wxss create mode 100644 utils/dist/skeleton/index.d.ts create mode 100644 utils/dist/skeleton/index.js create mode 100644 utils/dist/skeleton/index.json create mode 100644 utils/dist/skeleton/index.wxml create mode 100644 utils/dist/skeleton/index.wxss create mode 100644 utils/dist/slider/index.d.ts create mode 100644 utils/dist/slider/index.js create mode 100644 utils/dist/slider/index.json create mode 100644 utils/dist/slider/index.wxml create mode 100644 utils/dist/slider/index.wxss create mode 100644 utils/dist/stepper/index.d.ts create mode 100644 utils/dist/stepper/index.js create mode 100644 utils/dist/stepper/index.json create mode 100644 utils/dist/stepper/index.wxml create mode 100644 utils/dist/stepper/index.wxss create mode 100644 utils/dist/steps/index.d.ts create mode 100644 utils/dist/steps/index.js create mode 100644 utils/dist/steps/index.json create mode 100644 utils/dist/steps/index.wxml create mode 100644 utils/dist/steps/index.wxss create mode 100644 utils/dist/sticky/index.d.ts create mode 100644 utils/dist/sticky/index.js create mode 100644 utils/dist/sticky/index.json create mode 100644 utils/dist/sticky/index.wxml create mode 100644 utils/dist/sticky/index.wxss create mode 100644 utils/dist/submit-bar/index.d.ts create mode 100644 utils/dist/submit-bar/index.js create mode 100644 utils/dist/submit-bar/index.json create mode 100644 utils/dist/submit-bar/index.wxml create mode 100644 utils/dist/submit-bar/index.wxss create mode 100644 utils/dist/swipe-cell/index.d.ts create mode 100644 utils/dist/swipe-cell/index.js create mode 100644 utils/dist/swipe-cell/index.json create mode 100644 utils/dist/swipe-cell/index.wxml create mode 100644 utils/dist/swipe-cell/index.wxss create mode 100644 utils/dist/switch/index.d.ts create mode 100644 utils/dist/switch/index.js create mode 100644 utils/dist/switch/index.json create mode 100644 utils/dist/switch/index.wxml create mode 100644 utils/dist/switch/index.wxss create mode 100644 utils/dist/tab/index.d.ts create mode 100644 utils/dist/tab/index.js create mode 100644 utils/dist/tab/index.json create mode 100644 utils/dist/tab/index.wxml create mode 100644 utils/dist/tab/index.wxss create mode 100644 utils/dist/tabbar-item/index.d.ts create mode 100644 utils/dist/tabbar-item/index.js create mode 100644 utils/dist/tabbar-item/index.json create mode 100644 utils/dist/tabbar-item/index.wxml create mode 100644 utils/dist/tabbar-item/index.wxss create mode 100644 utils/dist/tabbar/index.d.ts create mode 100644 utils/dist/tabbar/index.js create mode 100644 utils/dist/tabbar/index.json create mode 100644 utils/dist/tabbar/index.wxml create mode 100644 utils/dist/tabbar/index.wxss create mode 100644 utils/dist/tabs/index.d.ts create mode 100644 utils/dist/tabs/index.js create mode 100644 utils/dist/tabs/index.json create mode 100644 utils/dist/tabs/index.wxml create mode 100644 utils/dist/tabs/index.wxs create mode 100644 utils/dist/tabs/index.wxss create mode 100644 utils/dist/tag/index.d.ts create mode 100644 utils/dist/tag/index.js create mode 100644 utils/dist/tag/index.json create mode 100644 utils/dist/tag/index.wxml create mode 100644 utils/dist/tag/index.wxss create mode 100644 utils/dist/toast/index.d.ts create mode 100644 utils/dist/toast/index.js create mode 100644 utils/dist/toast/index.json create mode 100644 utils/dist/toast/index.wxml create mode 100644 utils/dist/toast/index.wxss create mode 100644 utils/dist/toast/toast.d.ts create mode 100644 utils/dist/toast/toast.js create mode 100644 utils/dist/transition/index.d.ts create mode 100644 utils/dist/transition/index.js create mode 100644 utils/dist/transition/index.json create mode 100644 utils/dist/transition/index.wxml create mode 100644 utils/dist/transition/index.wxss create mode 100644 utils/dist/tree-select/index.d.ts create mode 100644 utils/dist/tree-select/index.js create mode 100644 utils/dist/tree-select/index.json create mode 100644 utils/dist/tree-select/index.wxml create mode 100644 utils/dist/tree-select/index.wxs create mode 100644 utils/dist/tree-select/index.wxss create mode 100644 utils/dist/uploader/index.d.ts create mode 100644 utils/dist/uploader/index.js create mode 100644 utils/dist/uploader/index.json create mode 100644 utils/dist/uploader/index.wxml create mode 100644 utils/dist/uploader/index.wxss create mode 100644 utils/dist/uploader/utils.d.ts create mode 100644 utils/dist/uploader/utils.js create mode 100644 utils/dist/wxs/array.wxs create mode 100644 utils/dist/wxs/bem.wxs create mode 100644 utils/dist/wxs/memoize.wxs create mode 100644 utils/dist/wxs/object.wxs create mode 100644 utils/dist/wxs/utils.wxs diff --git a/utils/dist/action-sheet/index.d.ts b/utils/dist/action-sheet/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/action-sheet/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/action-sheet/index.js b/utils/dist/action-sheet/index.js new file mode 100644 index 0000000..8065c83 --- /dev/null +++ b/utils/dist/action-sheet/index.js @@ -0,0 +1,59 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + show: Boolean, + title: String, + cancelText: String, + description: String, + round: { + type: Boolean, + value: true + }, + zIndex: { + type: Number, + value: 100 + }, + actions: { + type: Array, + value: [] + }, + overlay: { + type: Boolean, + value: true + }, + closeOnClickOverlay: { + type: Boolean, + value: true + }, + closeOnClickAction: { + type: Boolean, + value: true + }, + safeAreaInsetBottom: { + type: Boolean, + value: true + } + }, + methods: { + onSelect(event) { + const { index } = event.currentTarget.dataset; + const item = this.data.actions[index]; + if (item && !item.disabled && !item.loading) { + this.$emit('select', item); + if (this.data.closeOnClickAction) { + this.onClose(); + } + } + }, + onCancel() { + this.$emit('cancel'); + }, + onClose() { + this.$emit('close'); + }, + onClickOverlay() { + this.$emit('click-overlay'); + this.onClose(); + } + } +}); diff --git a/utils/dist/action-sheet/index.json b/utils/dist/action-sheet/index.json new file mode 100644 index 0000000..19bf989 --- /dev/null +++ b/utils/dist/action-sheet/index.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-popup": "../popup/index", + "van-loading": "../loading/index" + } +} diff --git a/utils/dist/action-sheet/index.wxml b/utils/dist/action-sheet/index.wxml new file mode 100644 index 0000000..bed9b06 --- /dev/null +++ b/utils/dist/action-sheet/index.wxml @@ -0,0 +1,54 @@ + + + + + {{ title }} + + + + {{ description }} + + + + + + + + {{ cancelText }} + + diff --git a/utils/dist/action-sheet/index.wxss b/utils/dist/action-sheet/index.wxss new file mode 100644 index 0000000..dc54840 --- /dev/null +++ b/utils/dist/action-sheet/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-action-sheet{max-height:90%!important;max-height:var(--action-sheet-max-height,90%)!important;color:#323233;color:var(--action-sheet-item-text-color,#323233)}.van-action-sheet__cancel,.van-action-sheet__item{text-align:center;font-size:16px;font-size:var(--action-sheet-item-font-size,16px);line-height:50px;line-height:var(--action-sheet-item-height,50px);background-color:#fff;background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__cancel--hover,.van-action-sheet__item--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-action-sheet__cancel:before{display:block;content:" ";height:8px;height:var(--action-sheet-cancel-padding-top,8px);background-color:#f7f8fa;background-color:var(--action-sheet-cancel-padding-color,#f7f8fa)}.van-action-sheet__item--disabled{color:#c8c9cc;color:var(--action-sheet-item-disabled-text-color,#c8c9cc)}.van-action-sheet__item--disabled.van-action-sheet__item--hover{background-color:#fff;background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__subname{margin-left:4px;margin-left:var(--padding-base,4px);font-size:12px;font-size:var(--action-sheet-subname-font-size,12px);color:#646566;color:var(--action-sheet-subname-color,#646566)}.van-action-sheet__header{text-align:center;font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--action-sheet-header-font-size,16px);line-height:44px;line-height:var(--action-sheet-header-height,44px)}.van-action-sheet__description{text-align:center;padding:16px;padding:var(--padding-md,16px);color:#646566;color:var(--action-sheet-description-color,#646566);font-size:14px;font-size:var(--action-sheet-description-font-size,14px);line-height:20px;line-height:var(--action-sheet-description-line-height,20px)}.van-action-sheet__close{position:absolute!important;top:0;right:0;line-height:inherit!important;padding:0 12px;padding:var(--action-sheet-close-icon-padding,0 12px);font-size:18px!important;font-size:var(--action-sheet-close-icon-size,18px)!important;color:#969799;color:var(--action-sheet-close-icon-color,#969799)}.van-action-sheet__loading{display:-webkit-flex!important;display:flex!important;height:50px;height:var(--action-sheet-item-height,50px)} \ No newline at end of file diff --git a/utils/dist/area/index.d.ts b/utils/dist/area/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/area/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/area/index.js b/utils/dist/area/index.js new file mode 100644 index 0000000..5601d77 --- /dev/null +++ b/utils/dist/area/index.js @@ -0,0 +1,210 @@ +import { VantComponent } from '../common/component'; +import { pickerProps } from '../picker/shared'; +const COLUMNSPLACEHOLDERCODE = '000000'; +VantComponent({ + classes: ['active-class', 'toolbar-class', 'column-class'], + props: Object.assign(Object.assign({}, pickerProps), { value: String, areaList: { + type: Object, + value: {} + }, columnsNum: { + type: null, + value: 3 + }, columnsPlaceholder: { + type: Array, + observer(val) { + this.setData({ + typeToColumnsPlaceholder: { + province: val[0] || '', + city: val[1] || '', + county: val[2] || '', + } + }); + } + } }), + data: { + columns: [{ values: [] }, { values: [] }, { values: [] }], + displayColumns: [{ values: [] }, { values: [] }, { values: [] }], + typeToColumnsPlaceholder: {} + }, + watch: { + value(value) { + this.code = value; + this.setValues(); + }, + areaList: 'setValues', + columnsNum(value) { + this.setData({ + displayColumns: this.data.columns.slice(0, +value) + }); + } + }, + mounted() { + setTimeout(() => { + this.setValues(); + }, 0); + }, + methods: { + getPicker() { + if (this.picker == null) { + this.picker = this.selectComponent('.van-area__picker'); + } + return this.picker; + }, + onCancel(event) { + this.emit('cancel', event.detail); + }, + onConfirm(event) { + const { index } = event.detail; + let { value } = event.detail; + value = this.parseOutputValues(value); + this.emit('confirm', { value, index }); + }, + emit(type, detail) { + detail.values = detail.value; + delete detail.value; + this.$emit(type, detail); + }, + // parse output columns data + parseOutputValues(values) { + const { columnsPlaceholder } = this.data; + return values.map((value, index) => { + // save undefined value + if (!value) + return value; + value = JSON.parse(JSON.stringify(value)); + if (!value.code || value.name === columnsPlaceholder[index]) { + value.code = ''; + value.name = ''; + } + return value; + }); + }, + onChange(event) { + const { index, picker, value } = event.detail; + this.code = value[index].code; + this.setValues().then(() => { + this.$emit('change', { + picker, + values: this.parseOutputValues(picker.getValues()), + index + }); + }); + }, + getConfig(type) { + const { areaList } = this.data; + return (areaList && areaList[`${type}_list`]) || {}; + }, + getList(type, code) { + const { typeToColumnsPlaceholder } = this.data; + let result = []; + if (type !== 'province' && !code) { + return result; + } + const list = this.getConfig(type); + result = Object.keys(list).map(code => ({ + code, + name: list[code] + })); + if (code) { + // oversea code + if (code[0] === '9' && type === 'city') { + code = '9'; + } + result = result.filter(item => item.code.indexOf(code) === 0); + } + if (typeToColumnsPlaceholder[type] && result.length) { + // set columns placeholder + const codeFill = type === 'province' ? '' : type === 'city' ? COLUMNSPLACEHOLDERCODE.slice(2, 4) : COLUMNSPLACEHOLDERCODE.slice(4, 6); + result.unshift({ + code: `${code}${codeFill}`, + name: typeToColumnsPlaceholder[type] + }); + } + return result; + }, + getIndex(type, code) { + let compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6; + const list = this.getList(type, code.slice(0, compareNum - 2)); + // oversea code + if (code[0] === '9' && type === 'province') { + compareNum = 1; + } + code = code.slice(0, compareNum); + for (let i = 0; i < list.length; i++) { + if (list[i].code.slice(0, compareNum) === code) { + return i; + } + } + return 0; + }, + setValues() { + const county = this.getConfig('county'); + let { code } = this; + if (!code) { + if (this.data.columnsPlaceholder.length) { + code = COLUMNSPLACEHOLDERCODE; + } + else if (Object.keys(county)[0]) { + code = Object.keys(county)[0]; + } + else { + code = ''; + } + } + const province = this.getList('province'); + const city = this.getList('city', code.slice(0, 2)); + const picker = this.getPicker(); + if (!picker) { + return; + } + const stack = []; + stack.push(picker.setColumnValues(0, province, false)); + stack.push(picker.setColumnValues(1, city, false)); + if (city.length && code.slice(2, 4) === '00') { + [{ code }] = city; + } + stack.push(picker.setColumnValues(2, this.getList('county', code.slice(0, 4)), false)); + return Promise.all(stack) + .catch(() => { }) + .then(() => picker.setIndexes([ + this.getIndex('province', code), + this.getIndex('city', code), + this.getIndex('county', code) + ])) + .catch(() => { }); + }, + getValues() { + const picker = this.getPicker(); + return picker ? picker.getValues().filter(value => !!value) : []; + }, + getDetail() { + const values = this.getValues(); + const area = { + code: '', + country: '', + province: '', + city: '', + county: '' + }; + if (!values.length) { + return area; + } + const names = values.map((item) => item.name); + area.code = values[values.length - 1].code; + if (area.code[0] === '9') { + area.country = names[1] || ''; + area.province = names[2] || ''; + } + else { + area.province = names[0] || ''; + area.city = names[1] || ''; + area.county = names[2] || ''; + } + return area; + }, + reset(code) { + this.code = code || ''; + return this.setValues(); + } + } +}); diff --git a/utils/dist/area/index.json b/utils/dist/area/index.json new file mode 100644 index 0000000..a778e91 --- /dev/null +++ b/utils/dist/area/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-picker": "../picker/index" + } +} diff --git a/utils/dist/area/index.wxml b/utils/dist/area/index.wxml new file mode 100644 index 0000000..6075794 --- /dev/null +++ b/utils/dist/area/index.wxml @@ -0,0 +1,18 @@ + diff --git a/utils/dist/area/index.wxss b/utils/dist/area/index.wxss new file mode 100644 index 0000000..99694d6 --- /dev/null +++ b/utils/dist/area/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss'; \ No newline at end of file diff --git a/utils/dist/button/index.d.ts b/utils/dist/button/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/button/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/button/index.js b/utils/dist/button/index.js new file mode 100644 index 0000000..e32509e --- /dev/null +++ b/utils/dist/button/index.js @@ -0,0 +1,68 @@ +import { VantComponent } from '../common/component'; +import { button } from '../mixins/button'; +import { openType } from '../mixins/open-type'; +VantComponent({ + mixins: [button, openType], + classes: ['hover-class', 'loading-class'], + data: { + style: '' + }, + props: { + icon: String, + plain: Boolean, + block: Boolean, + round: Boolean, + square: Boolean, + loading: Boolean, + hairline: Boolean, + disabled: Boolean, + loadingText: String, + customStyle: String, + loadingType: { + type: String, + value: 'circular' + }, + type: { + type: String, + value: 'default' + }, + size: { + type: String, + value: 'normal' + }, + loadingSize: { + type: String, + value: '20px' + }, + color: { + type: String, + observer(color) { + let style = ''; + if (color) { + style += `color: ${this.data.plain ? color : 'white'};`; + if (!this.data.plain) { + // Use background instead of backgroundColor to make linear-gradient work + style += `background: ${color};`; + } + // hide border when color is linear-gradient + if (color.indexOf('gradient') !== -1) { + style += 'border: 0;'; + } + else { + style += `border-color: ${color};`; + } + } + if (style !== this.data.style) { + this.setData({ style }); + } + } + } + }, + methods: { + onClick() { + if (!this.data.disabled && !this.data.loading) { + this.$emit('click'); + } + } + } +}); diff --git a/utils/dist/button/index.json b/utils/dist/button/index.json new file mode 100644 index 0000000..e00a588 --- /dev/null +++ b/utils/dist/button/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-loading": "../loading/index" + } +} diff --git a/utils/dist/button/index.wxml b/utils/dist/button/index.wxml new file mode 100644 index 0000000..77b4942 --- /dev/null +++ b/utils/dist/button/index.wxml @@ -0,0 +1,52 @@ + + + diff --git a/utils/dist/button/index.wxss b/utils/dist/button/index.wxss new file mode 100644 index 0000000..0d302cb --- /dev/null +++ b/utils/dist/button/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;line-height:20px;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background-color:#fff;background-color:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:1px solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background-color:#07c160;background-color:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:1px solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background-color:#1989fa;background-color:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:1px solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background-color:#ee0a24;background-color:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:1px solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background-color:#ff976a;background-color:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:1px solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background-color:#fff;background-color:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/utils/dist/card/index.d.ts b/utils/dist/card/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/card/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/card/index.js b/utils/dist/card/index.js new file mode 100644 index 0000000..ae64151 --- /dev/null +++ b/utils/dist/card/index.js @@ -0,0 +1,38 @@ +import { link } from '../mixins/link'; +import { VantComponent } from '../common/component'; +VantComponent({ + classes: [ + 'num-class', + 'desc-class', + 'thumb-class', + 'title-class', + 'price-class', + 'origin-price-class', + ], + mixins: [link], + props: { + tag: String, + num: String, + desc: String, + thumb: String, + title: String, + price: String, + centered: Boolean, + lazyLoad: Boolean, + thumbLink: String, + originPrice: String, + thumbMode: { + type: String, + value: 'aspectFit' + }, + currency: { + type: String, + value: '¥' + } + }, + methods: { + onClickThumb() { + this.jumpLink('thumbLink'); + } + } +}); diff --git a/utils/dist/card/index.json b/utils/dist/card/index.json new file mode 100644 index 0000000..e917407 --- /dev/null +++ b/utils/dist/card/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-tag": "../tag/index" + } +} diff --git a/utils/dist/card/index.wxml b/utils/dist/card/index.wxml new file mode 100644 index 0000000..a17b1d6 --- /dev/null +++ b/utils/dist/card/index.wxml @@ -0,0 +1,45 @@ + + + + + + + + + {{ tag }} + + + + + {{ title }} + + + {{ desc }} + + + + + + {{ currency }} {{ price }} + {{ currency }} {{ originPrice }} + x {{ num }} + + + + + + + + + diff --git a/utils/dist/card/index.wxss b/utils/dist/card/index.wxss new file mode 100644 index 0000000..8e86e45 --- /dev/null +++ b/utils/dist/card/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-card{position:relative;box-sizing:border-box;padding:8px 16px;padding:var(--card-padding,8px 16px);font-size:12px;font-size:var(--card-font-size,12px);color:#323233;color:var(--card-text-color,#323233);background-color:#fafafa;background-color:var(--card-background-color,#fafafa)}.van-card__header{display:-webkit-flex;display:flex}.van-card__header--center{-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-card__thumb{position:relative;-webkit-flex:none;flex:none;width:90px;width:var(--card-thumb-size,90px);height:90px;height:var(--card-thumb-size,90px);margin-right:8px;margin-right:var(--padding-xs,8px)}.van-card__thumb:empty{display:none}.van-card__img{width:100%;height:100%}.van-card__content{position:relative;-webkit-flex:1;flex:1;min-width:0}.van-card__desc,.van-card__title{word-wrap:break-word}.van-card__title{font-weight:700;line-height:16px;line-height:var(--card-title-line-height,16px)}.van-card__desc{line-height:20px;line-height:var(--card-desc-line-height,20px);color:#646566;color:var(--card-desc-color,#646566)}.van-card__bottom{line-height:20px}.van-card__price{display:inline-block;font-weight:700;color:#ee0a24;color:var(--card-price-color,#ee0a24)}.van-card__origin-price{display:inline-block;margin-left:5px;text-decoration:line-through;font-size:10px;font-size:var(--card-origin-price-font-size,10px);color:#646566;color:var(--card-origin-price-color,#646566)}.van-card__num{float:right}.van-card__tag{position:absolute;top:2px;left:0}.van-card__footer{-webkit-flex:none;flex:none;width:100%;text-align:right} \ No newline at end of file diff --git a/utils/dist/cell-group/index.d.ts b/utils/dist/cell-group/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/cell-group/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/cell-group/index.js b/utils/dist/cell-group/index.js new file mode 100644 index 0000000..3611e09 --- /dev/null +++ b/utils/dist/cell-group/index.js @@ -0,0 +1,10 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + title: String, + border: { + type: Boolean, + value: true + } + } +}); diff --git a/utils/dist/cell-group/index.json b/utils/dist/cell-group/index.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/utils/dist/cell-group/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/utils/dist/cell-group/index.wxml b/utils/dist/cell-group/index.wxml new file mode 100644 index 0000000..6e0b471 --- /dev/null +++ b/utils/dist/cell-group/index.wxml @@ -0,0 +1,9 @@ + + {{ title }} + + + + diff --git a/utils/dist/cell-group/index.wxss b/utils/dist/cell-group/index.wxss new file mode 100644 index 0000000..edbccd5 --- /dev/null +++ b/utils/dist/cell-group/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-cell-group__title{padding:16px 16px 8px;padding:var(--cell-group-title-padding,16px 16px 8px);font-size:14px;font-size:var(--cell-group-title-font-size,14px);line-height:16px;line-height:var(--cell-group-title-line-height,16px);color:#969799;color:var(--cell-group-title-color,#969799)} \ No newline at end of file diff --git a/utils/dist/cell/index.d.ts b/utils/dist/cell/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/cell/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/cell/index.js b/utils/dist/cell/index.js new file mode 100644 index 0000000..11cd042 --- /dev/null +++ b/utils/dist/cell/index.js @@ -0,0 +1,37 @@ +import { link } from '../mixins/link'; +import { VantComponent } from '../common/component'; +VantComponent({ + classes: [ + 'title-class', + 'label-class', + 'value-class', + 'right-icon-class', + 'hover-class' + ], + mixins: [link], + props: { + title: null, + value: null, + icon: String, + size: String, + label: String, + center: Boolean, + isLink: Boolean, + required: Boolean, + clickable: Boolean, + titleWidth: String, + customStyle: String, + arrowDirection: String, + useLabelSlot: Boolean, + border: { + type: Boolean, + value: true + } + }, + methods: { + onClick(event) { + this.$emit('click', event.detail); + this.jumpLink(); + } + } +}); diff --git a/utils/dist/cell/index.json b/utils/dist/cell/index.json new file mode 100644 index 0000000..a9ab393 --- /dev/null +++ b/utils/dist/cell/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} \ No newline at end of file diff --git a/utils/dist/cell/index.wxml b/utils/dist/cell/index.wxml new file mode 100644 index 0000000..afaaaf8 --- /dev/null +++ b/utils/dist/cell/index.wxml @@ -0,0 +1,45 @@ + + + + + + + + {{ title }} + + + + + {{ label }} + + + + + {{ value }} + + + + + + + + diff --git a/utils/dist/cell/index.wxss b/utils/dist/cell/index.wxss new file mode 100644 index 0000000..f0bdd3a --- /dev/null +++ b/utils/dist/cell/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-cell{position:relative;display:-webkit-flex;display:flex;box-sizing:border-box;width:100%;padding:10px 16px;padding:var(--cell-vertical-padding,10px) var(--cell-horizontal-padding,16px);font-size:14px;font-size:var(--cell-font-size,14px);line-height:24px;line-height:var(--cell-line-height,24px);color:#323233;color:var(--cell-text-color,#323233);background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:auto;right:0;bottom:0;left:16px;border-bottom:1px solid #ebedf0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-cell--borderless:after{display:none}.van-cell-group{background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell__label{margin-top:3px;margin-top:var(--cell-label-margin-top,3px);font-size:12px;font-size:var(--cell-label-font-size,12px);line-height:18px;line-height:var(--cell-label-line-height,18px);color:#969799;color:var(--cell-label-color,#969799)}.van-cell__value{overflow:hidden;text-align:right;vertical-align:middle;color:#969799;color:var(--cell-value-color,#969799)}.van-cell__title,.van-cell__value{-webkit-flex:1;flex:1}.van-cell__title:empty,.van-cell__value:empty{display:none}.van-cell__left-icon-wrap,.van-cell__right-icon-wrap{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;height:24px;height:var(--cell-line-height,24px);font-size:16px;font-size:var(--cell-icon-size,16px)}.van-cell__left-icon-wrap{margin-right:5px}.van-cell__right-icon-wrap{margin-left:5px;color:#969799;color:var(--cell-right-icon-color,#969799)}.van-cell__left-icon{vertical-align:middle}.van-cell__left-icon,.van-cell__right-icon{line-height:24px;line-height:var(--cell-line-height,24px)}.van-cell--clickable.van-cell--hover{background-color:#f2f3f5;background-color:var(--cell-active-color,#f2f3f5)}.van-cell--required{overflow:visible}.van-cell--required:before{position:absolute;content:"*";left:8px;left:var(--padding-xs,8px);font-size:14px;font-size:var(--cell-font-size,14px);color:#ee0a24;color:var(--cell-required-color,#ee0a24)}.van-cell--center{-webkit-align-items:center;align-items:center}.van-cell--large{padding-top:12px;padding-top:var(--cell-large-vertical-padding,12px);padding-bottom:12px;padding-bottom:var(--cell-large-vertical-padding,12px)}.van-cell--large .van-cell__title{font-size:16px;font-size:var(--cell-large-title-font-size,16px)}.van-cell--large .van-cell__label{font-size:14px;font-size:var(--cell-large-label-font-size,14px)} \ No newline at end of file diff --git a/utils/dist/checkbox-group/index.d.ts b/utils/dist/checkbox-group/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/checkbox-group/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/checkbox-group/index.js b/utils/dist/checkbox-group/index.js new file mode 100644 index 0000000..92438e7 --- /dev/null +++ b/utils/dist/checkbox-group/index.js @@ -0,0 +1,39 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + field: true, + relation: { + name: 'checkbox', + type: 'descendant', + linked(target) { + this.children = this.children || []; + this.children.push(target); + this.updateChild(target); + }, + unlinked(target) { + this.children = this.children.filter((child) => child !== target); + } + }, + props: { + max: Number, + value: { + type: Array, + observer: 'updateChildren' + }, + disabled: { + type: Boolean, + observer: 'updateChildren' + } + }, + methods: { + updateChildren() { + (this.children || []).forEach((child) => this.updateChild(child)); + }, + updateChild(child) { + const { value, disabled } = this.data; + child.setData({ + value: value.indexOf(child.data.name) !== -1, + disabled: disabled || child.data.disabled + }); + } + } +}); diff --git a/utils/dist/checkbox-group/index.json b/utils/dist/checkbox-group/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/checkbox-group/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/checkbox-group/index.wxml b/utils/dist/checkbox-group/index.wxml new file mode 100644 index 0000000..4fa864c --- /dev/null +++ b/utils/dist/checkbox-group/index.wxml @@ -0,0 +1 @@ + diff --git a/utils/dist/checkbox-group/index.wxss b/utils/dist/checkbox-group/index.wxss new file mode 100644 index 0000000..99694d6 --- /dev/null +++ b/utils/dist/checkbox-group/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss'; \ No newline at end of file diff --git a/utils/dist/checkbox/index.d.ts b/utils/dist/checkbox/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/checkbox/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/checkbox/index.js b/utils/dist/checkbox/index.js new file mode 100644 index 0000000..4491e3b --- /dev/null +++ b/utils/dist/checkbox/index.js @@ -0,0 +1,87 @@ +import { VantComponent } from '../common/component'; +import { addUnit } from '../common/utils'; +function emit(target, value) { + target.$emit('input', value); + target.$emit('change', value); +} +VantComponent({ + field: true, + relation: { + name: 'checkbox-group', + type: 'ancestor', + linked(target) { + this.parent = target; + }, + unlinked() { + this.parent = null; + } + }, + classes: ['icon-class', 'label-class'], + props: { + value: Boolean, + disabled: Boolean, + useIconSlot: Boolean, + checkedColor: String, + labelPosition: String, + labelDisabled: Boolean, + shape: { + type: String, + value: 'round' + }, + iconSize: { + type: null, + observer: 'setSizeWithUnit' + } + }, + data: { + sizeWithUnit: '20px' + }, + methods: { + emitChange(value) { + if (this.parent) { + this.setParentValue(this.parent, value); + } + else { + emit(this, value); + } + }, + toggle() { + const { disabled, value } = this.data; + if (!disabled) { + this.emitChange(!value); + } + }, + onClickLabel() { + const { labelDisabled, disabled, value } = this.data; + if (!disabled && !labelDisabled) { + this.emitChange(!value); + } + }, + setParentValue(parent, value) { + const parentValue = parent.data.value.slice(); + const { name } = this.data; + const { max } = parent.data; + if (value) { + if (max && parentValue.length >= max) { + return; + } + if (parentValue.indexOf(name) === -1) { + parentValue.push(name); + emit(parent, parentValue); + } + } + else { + const index = parentValue.indexOf(name); + if (index !== -1) { + parentValue.splice(index, 1); + emit(parent, parentValue); + } + } + }, + setSizeWithUnit(size) { + this.set({ + sizeWithUnit: addUnit(size) + }); + }, + } +}); diff --git a/utils/dist/checkbox/index.json b/utils/dist/checkbox/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/utils/dist/checkbox/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/utils/dist/checkbox/index.wxml b/utils/dist/checkbox/index.wxml new file mode 100644 index 0000000..65124a1 --- /dev/null +++ b/utils/dist/checkbox/index.wxml @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/utils/dist/checkbox/index.wxss b/utils/dist/checkbox/index.wxss new file mode 100644 index 0000000..d217597 --- /dev/null +++ b/utils/dist/checkbox/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-checkbox{display:-webkit-flex;display:flex;overflow:hidden;-webkit-user-select:none;user-select:none}.van-checkbox__icon-wrap,.van-checkbox__label{line-height:20px;line-height:var(--checkbox-size,20px)}.van-checkbox__icon-wrap{-webkit-flex:none;flex:none}.van-checkbox__icon{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:1em;height:1em;color:transparent;text-align:center;transition-property:color,border-color,background-color;font-size:20px;font-size:var(--checkbox-size,20px);border:1px solid #c8c9cc;border:1px solid var(--checkbox-border-color,#c8c9cc);transition-duration:.2s;transition-duration:var(--checkbox-transition-duration,.2s)}.van-checkbox__icon--round{border-radius:100%}.van-checkbox__icon--checked{color:#fff;color:var(--white,#fff);background-color:#1989fa;background-color:var(--checkbox-checked-icon-color,#1989fa);border-color:#1989fa;border-color:var(--checkbox-checked-icon-color,#1989fa)}.van-checkbox__icon--disabled{background-color:#ebedf0;background-color:var(--checkbox-disabled-background-color,#ebedf0);border-color:#c8c9cc;border-color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__icon--disabled.van-checkbox__icon--checked{color:#c8c9cc;color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__label{word-wrap:break-word;margin-left:10px;margin-left:var(--checkbox-label-margin,10px);color:#323233;color:var(--checkbox-label-color,#323233)}.van-checkbox__label--left{float:left;margin:0 10px 0 0;margin:0 var(--checkbox-label-margin,10px) 0 0}.van-checkbox__label--disabled{color:#c8c9cc;color:var(--checkbox-disabled-label-color,#c8c9cc)}.van-checkbox__label:empty{margin:0} \ No newline at end of file diff --git a/utils/dist/circle/index.d.ts b/utils/dist/circle/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/circle/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/circle/index.js b/utils/dist/circle/index.js new file mode 100644 index 0000000..08c7eb4 --- /dev/null +++ b/utils/dist/circle/index.js @@ -0,0 +1,158 @@ +import { VantComponent } from '../common/component'; +import { isObj } from '../common/utils'; +import { BLUE, WHITE } from '../common/color'; +function format(rate) { + return Math.min(Math.max(rate, 0), 100); +} +const PERIMETER = 2 * Math.PI; +const BEGIN_ANGLE = -Math.PI / 2; +const STEP = 1; +VantComponent({ + props: { + text: String, + lineCap: { + type: String, + value: 'round' + }, + value: { + type: Number, + value: 0, + observer: 'reRender' + }, + speed: { + type: Number, + value: 50 + }, + size: { + type: Number, + value: 100, + observer: 'setStyle' + }, + fill: String, + layerColor: { + type: String, + value: WHITE + }, + color: { + type: [String, Object], + value: BLUE, + observer: 'setHoverColor' + }, + strokeWidth: { + type: Number, + value: 4 + }, + clockwise: { + type: Boolean, + value: true + } + }, + data: { + style: 'width: 100px; height: 100px;', + hoverColor: BLUE + }, + methods: { + getContext() { + if (!this.ctx) { + this.ctx = wx.createCanvasContext('van-circle', this); + } + return this.ctx; + }, + setHoverColor() { + const context = this.getContext(); + const { color, size } = this.data; + let hoverColor = color; + if (isObj(color)) { + const LinearColor = context.createLinearGradient(size, 0, 0, 0); + Object.keys(color) + .sort((a, b) => parseFloat(a) - parseFloat(b)) + .map(key => LinearColor.addColorStop(parseFloat(key) / 100, color[key])); + hoverColor = LinearColor; + } + this.setData({ hoverColor }); + }, + setStyle() { + const { size } = this.data; + const style = `width: ${size}px; height: ${size}px;`; + this.setData({ style }); + }, + presetCanvas(context, strokeStyle, beginAngle, endAngle, fill) { + const { strokeWidth, lineCap, clockwise, size } = this.data; + const position = size / 2; + const radius = position - strokeWidth / 2; + context.setStrokeStyle(strokeStyle); + context.setLineWidth(strokeWidth); + context.setLineCap(lineCap); + context.beginPath(); + context.arc(position, position, radius, beginAngle, endAngle, !clockwise); + context.stroke(); + if (fill) { + context.setFillStyle(fill); + context.fill(); + } + }, + renderLayerCircle(context) { + const { layerColor, fill } = this.data; + this.presetCanvas(context, layerColor, 0, PERIMETER, fill); + }, + renderHoverCircle(context, formatValue) { + const { clockwise, hoverColor } = this.data; + // 结束角度 + const progress = PERIMETER * (formatValue / 100); + const endAngle = clockwise + ? BEGIN_ANGLE + progress + : 3 * Math.PI - (BEGIN_ANGLE + progress); + this.presetCanvas(context, hoverColor, BEGIN_ANGLE, endAngle); + }, + drawCircle(currentValue) { + const context = this.getContext(); + const { size } = this.data; + context.clearRect(0, 0, size, size); + this.renderLayerCircle(context); + const formatValue = format(currentValue); + if (formatValue !== 0) { + this.renderHoverCircle(context, formatValue); + } + context.draw(); + }, + reRender() { + // tofector 动画暂时没有想到好的解决方案 + const { value, speed } = this.data; + if (speed <= 0 || speed > 1000) { + this.drawCircle(value); + return; + } + this.clearInterval(); + this.currentValue = this.currentValue || 0; + this.interval = setInterval(() => { + if (this.currentValue !== value) { + if (this.currentValue < value) { + this.currentValue += STEP; + } + else { + this.currentValue -= STEP; + } + this.drawCircle(this.currentValue); + } + else { + this.clearInterval(); + } + }, 1000 / speed); + }, + clearInterval() { + if (this.interval) { + clearInterval(this.interval); + this.interval = null; + } + } + }, + created() { + const { value } = this.data; + this.currentValue = value; + this.drawCircle(value); + }, + destroyed() { + this.ctx = null; + this.clearInterval(); + } +}); diff --git a/utils/dist/circle/index.json b/utils/dist/circle/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/circle/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/circle/index.wxml b/utils/dist/circle/index.wxml new file mode 100644 index 0000000..215122f --- /dev/null +++ b/utils/dist/circle/index.wxml @@ -0,0 +1,7 @@ + + + + + + {{ text }} + \ No newline at end of file diff --git a/utils/dist/circle/index.wxss b/utils/dist/circle/index.wxss new file mode 100644 index 0000000..3ab63df --- /dev/null +++ b/utils/dist/circle/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-circle{position:relative;display:inline-block;text-align:center}.van-circle__text{position:absolute;top:50%;left:0;width:100%;-webkit-transform:translateY(-50%);transform:translateY(-50%);color:#323233;color:var(--circle-text-color,#323233)} \ No newline at end of file diff --git a/utils/dist/col/index.d.ts b/utils/dist/col/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/col/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/col/index.js b/utils/dist/col/index.js new file mode 100644 index 0000000..2d1d85e --- /dev/null +++ b/utils/dist/col/index.js @@ -0,0 +1,23 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + relation: { + name: 'row', + type: 'ancestor' + }, + props: { + span: Number, + offset: Number + }, + data: { + style: '' + }, + methods: { + setGutter(gutter) { + const padding = `${gutter / 2}px`; + const style = gutter ? `padding-left: ${padding}; padding-right: ${padding};` : ''; + if (style !== this.data.style) { + this.setData({ style }); + } + } + } +}); diff --git a/utils/dist/col/index.json b/utils/dist/col/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/col/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/col/index.wxml b/utils/dist/col/index.wxml new file mode 100644 index 0000000..a759aac --- /dev/null +++ b/utils/dist/col/index.wxml @@ -0,0 +1,8 @@ + + + + + diff --git a/utils/dist/col/index.wxss b/utils/dist/col/index.wxss new file mode 100644 index 0000000..44c896a --- /dev/null +++ b/utils/dist/col/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-col{float:left;box-sizing:border-box}.van-col--1{width:4.16666667%}.van-col--offset-1{margin-left:4.16666667%}.van-col--2{width:8.33333333%}.van-col--offset-2{margin-left:8.33333333%}.van-col--3{width:12.5%}.van-col--offset-3{margin-left:12.5%}.van-col--4{width:16.66666667%}.van-col--offset-4{margin-left:16.66666667%}.van-col--5{width:20.83333333%}.van-col--offset-5{margin-left:20.83333333%}.van-col--6{width:25%}.van-col--offset-6{margin-left:25%}.van-col--7{width:29.16666667%}.van-col--offset-7{margin-left:29.16666667%}.van-col--8{width:33.33333333%}.van-col--offset-8{margin-left:33.33333333%}.van-col--9{width:37.5%}.van-col--offset-9{margin-left:37.5%}.van-col--10{width:41.66666667%}.van-col--offset-10{margin-left:41.66666667%}.van-col--11{width:45.83333333%}.van-col--offset-11{margin-left:45.83333333%}.van-col--12{width:50%}.van-col--offset-12{margin-left:50%}.van-col--13{width:54.16666667%}.van-col--offset-13{margin-left:54.16666667%}.van-col--14{width:58.33333333%}.van-col--offset-14{margin-left:58.33333333%}.van-col--15{width:62.5%}.van-col--offset-15{margin-left:62.5%}.van-col--16{width:66.66666667%}.van-col--offset-16{margin-left:66.66666667%}.van-col--17{width:70.83333333%}.van-col--offset-17{margin-left:70.83333333%}.van-col--18{width:75%}.van-col--offset-18{margin-left:75%}.van-col--19{width:79.16666667%}.van-col--offset-19{margin-left:79.16666667%}.van-col--20{width:83.33333333%}.van-col--offset-20{margin-left:83.33333333%}.van-col--21{width:87.5%}.van-col--offset-21{margin-left:87.5%}.van-col--22{width:91.66666667%}.van-col--offset-22{margin-left:91.66666667%}.van-col--23{width:95.83333333%}.van-col--offset-23{margin-left:95.83333333%}.van-col--24{width:100%}.van-col--offset-24{margin-left:100%} \ No newline at end of file diff --git a/utils/dist/collapse-item/index.d.ts b/utils/dist/collapse-item/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/collapse-item/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/collapse-item/index.js b/utils/dist/collapse-item/index.js new file mode 100644 index 0000000..a869be0 --- /dev/null +++ b/utils/dist/collapse-item/index.js @@ -0,0 +1,96 @@ +import { VantComponent } from '../common/component'; +const nextTick = () => new Promise(resolve => setTimeout(resolve, 20)); +VantComponent({ + classes: ['title-class', 'content-class'], + relation: { + name: 'collapse', + type: 'ancestor', + linked(parent) { + this.parent = parent; + } + }, + props: { + name: null, + title: null, + value: null, + icon: String, + label: String, + disabled: Boolean, + clickable: Boolean, + border: { + type: Boolean, + value: true + }, + isLink: { + type: Boolean, + value: true + } + }, + data: { + contentHeight: 0, + expanded: false, + transition: false + }, + mounted() { + this.updateExpanded() + .then(nextTick) + .then(() => { + const data = { transition: true }; + if (this.data.expanded) { + data.contentHeight = 'auto'; + } + this.setData(data); + }); + }, + methods: { + updateExpanded() { + if (!this.parent) { + return Promise.resolve(); + } + const { value, accordion } = this.parent.data; + const { children = [] } = this.parent; + const { name } = this.data; + const index = children.indexOf(this); + const currentName = name == null ? index : name; + const expanded = accordion + ? value === currentName + : (value || []).some((name) => name === currentName); + const stack = []; + if (expanded !== this.data.expanded) { + stack.push(this.updateStyle(expanded)); + } + stack.push(this.set({ index, expanded })); + return Promise.all(stack); + }, + updateStyle(expanded) { + return this.getRect('.van-collapse-item__content') + .then((rect) => rect.height) + .then((height) => { + if (expanded) { + return this.set({ + contentHeight: height ? `${height}px` : 'auto' + }); + } + return this.set({ contentHeight: `${height}px` }) + .then(nextTick) + .then(() => this.set({ contentHeight: 0 })); + }); + }, + onClick() { + if (this.data.disabled) { + return; + } + const { name, expanded } = this.data; + const index = this.parent.children.indexOf(this); + const currentName = name == null ? index : name; + this.parent.switch(currentName, !expanded); + }, + onTransitionEnd() { + if (this.data.expanded) { + this.setData({ + contentHeight: 'auto' + }); + } + } + } +}); diff --git a/utils/dist/collapse-item/index.json b/utils/dist/collapse-item/index.json new file mode 100644 index 0000000..0e5425c --- /dev/null +++ b/utils/dist/collapse-item/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-cell": "../cell/index" + } +} diff --git a/utils/dist/collapse-item/index.wxml b/utils/dist/collapse-item/index.wxml new file mode 100644 index 0000000..91afbc2 --- /dev/null +++ b/utils/dist/collapse-item/index.wxml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + diff --git a/utils/dist/collapse-item/index.wxss b/utils/dist/collapse-item/index.wxss new file mode 100644 index 0000000..6ca214e --- /dev/null +++ b/utils/dist/collapse-item/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-collapse-item__title .van-cell__right-icon{-webkit-transform:rotate(90deg);transform:rotate(90deg);transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s;transition:-webkit-transform var(--collapse-item-transition-duration,.3s);transition:transform var(--collapse-item-transition-duration,.3s);transition:transform var(--collapse-item-transition-duration,.3s),-webkit-transform var(--collapse-item-transition-duration,.3s)}.van-collapse-item__title--expanded .van-cell__right-icon{-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.van-collapse-item__title--disabled .van-cell,.van-collapse-item__title--disabled .van-cell__right-icon{color:#c8c9cc!important;color:var(--collapse-item-title-disabled-color,#c8c9cc)!important}.van-collapse-item__title--disabled .van-cell--hover{background-color:#fff!important;background-color:var(--white,#fff)!important}.van-collapse-item__wrapper{overflow:hidden}.van-collapse-item__wrapper--transition{transition:height .3s ease-in-out}.van-collapse-item__content{padding:15px;padding:var(--collapse-item-content-padding,15px);color:#969799;color:var(--collapse-item-content-text-color,#969799);font-size:13px;font-size:var(--collapse-item-content-font-size,13px);line-height:1.5;line-height:var(--collapse-item-content-line-height,1.5);background-color:#fff;background-color:var(--collapse-item-content-background-color,#fff)} \ No newline at end of file diff --git a/utils/dist/collapse/index.d.ts b/utils/dist/collapse/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/collapse/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/collapse/index.js b/utils/dist/collapse/index.js new file mode 100644 index 0000000..c6efb6a --- /dev/null +++ b/utils/dist/collapse/index.js @@ -0,0 +1,50 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + relation: { + name: 'collapse-item', + type: 'descendant', + linked(child) { + this.children.push(child); + }, + unlinked(child) { + this.children = this.children.filter((item) => item !== child); + } + }, + props: { + value: { + type: null, + observer: 'updateExpanded' + }, + accordion: { + type: Boolean, + observer: 'updateExpanded' + }, + border: { + type: Boolean, + value: true + } + }, + beforeCreate() { + this.children = []; + }, + methods: { + updateExpanded() { + this.children.forEach((child) => { + child.updateExpanded(); + }); + }, + switch(name, expanded) { + const { accordion, value } = this.data; + if (!accordion) { + name = expanded + ? (value || []).concat(name) + : (value || []).filter((activeName) => activeName !== name); + } + else { + name = expanded ? name : ''; + } + this.$emit('change', name); + this.$emit('input', name); + } + } +}); diff --git a/utils/dist/collapse/index.json b/utils/dist/collapse/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/collapse/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/collapse/index.wxml b/utils/dist/collapse/index.wxml new file mode 100644 index 0000000..fd4e171 --- /dev/null +++ b/utils/dist/collapse/index.wxml @@ -0,0 +1,3 @@ + + + diff --git a/utils/dist/collapse/index.wxss b/utils/dist/collapse/index.wxss new file mode 100644 index 0000000..99694d6 --- /dev/null +++ b/utils/dist/collapse/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss'; \ No newline at end of file diff --git a/utils/dist/common/color.d.ts b/utils/dist/common/color.d.ts new file mode 100644 index 0000000..386f307 --- /dev/null +++ b/utils/dist/common/color.d.ts @@ -0,0 +1,7 @@ +export declare const RED = "#ee0a24"; +export declare const BLUE = "#1989fa"; +export declare const WHITE = "#fff"; +export declare const GREEN = "#07c160"; +export declare const ORANGE = "#ff976a"; +export declare const GRAY = "#323233"; +export declare const GRAY_DARK = "#969799"; diff --git a/utils/dist/common/color.js b/utils/dist/common/color.js new file mode 100644 index 0000000..6b285bd --- /dev/null +++ b/utils/dist/common/color.js @@ -0,0 +1,7 @@ +export const RED = '#ee0a24'; +export const BLUE = '#1989fa'; +export const WHITE = '#fff'; +export const GREEN = '#07c160'; +export const ORANGE = '#ff976a'; +export const GRAY = '#323233'; +export const GRAY_DARK = '#969799'; diff --git a/utils/dist/common/component.d.ts b/utils/dist/common/component.d.ts new file mode 100644 index 0000000..307a96c --- /dev/null +++ b/utils/dist/common/component.d.ts @@ -0,0 +1,3 @@ +import { VantComponentOptions, CombinedComponentInstance } from '../definitions/index'; +declare function VantComponent(vantOptions?: VantComponentOptions>): void; +export { VantComponent }; diff --git a/utils/dist/common/component.js b/utils/dist/common/component.js new file mode 100644 index 0000000..63ef1a9 --- /dev/null +++ b/utils/dist/common/component.js @@ -0,0 +1,48 @@ +import { basic } from '../mixins/basic'; +import { observe } from '../mixins/observer/index'; +function mapKeys(source, target, map) { + Object.keys(map).forEach(key => { + if (source[key]) { + target[map[key]] = source[key]; + } + }); +} +function VantComponent(vantOptions = {}) { + const options = {}; + mapKeys(vantOptions, options, { + data: 'data', + props: 'properties', + mixins: 'behaviors', + methods: 'methods', + beforeCreate: 'created', + created: 'attached', + mounted: 'ready', + relations: 'relations', + destroyed: 'detached', + classes: 'externalClasses' + }); + const { relation } = vantOptions; + if (relation) { + options.relations = Object.assign(options.relations || {}, { + [`../${relation.name}/index`]: relation + }); + } + // add default externalClasses + options.externalClasses = options.externalClasses || []; + options.externalClasses.push('custom-class'); + // add default behaviors + options.behaviors = options.behaviors || []; + options.behaviors.push(basic); + // map field to form-field behavior + if (vantOptions.field) { + options.behaviors.push('wx://form-field'); + } + // add default options + options.options = { + multipleSlots: true, + addGlobalClass: true + }; + observe(vantOptions, options); + Component(options); +} +export { VantComponent }; diff --git a/utils/dist/common/index.wxss b/utils/dist/common/index.wxss new file mode 100644 index 0000000..6e6891f --- /dev/null +++ b/utils/dist/common/index.wxss @@ -0,0 +1 @@ +.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3}.van-clearfix:after{display:table;clear:both;content:""}.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #eee;-webkit-transform:scale(.5);transform:scale(.5)}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px} \ No newline at end of file diff --git a/utils/dist/common/style/clearfix.wxss b/utils/dist/common/style/clearfix.wxss new file mode 100644 index 0000000..a0ca838 --- /dev/null +++ b/utils/dist/common/style/clearfix.wxss @@ -0,0 +1 @@ +.van-clearfix:after{display:table;clear:both;content:""} \ No newline at end of file diff --git a/utils/dist/common/style/ellipsis.wxss b/utils/dist/common/style/ellipsis.wxss new file mode 100644 index 0000000..1e9dbc9 --- /dev/null +++ b/utils/dist/common/style/ellipsis.wxss @@ -0,0 +1 @@ +.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3} \ No newline at end of file diff --git a/utils/dist/common/style/hairline.wxss b/utils/dist/common/style/hairline.wxss new file mode 100644 index 0000000..f64e2f8 --- /dev/null +++ b/utils/dist/common/style/hairline.wxss @@ -0,0 +1 @@ +.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #eee;-webkit-transform:scale(.5);transform:scale(.5)}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px} \ No newline at end of file diff --git a/utils/dist/common/style/mixins/clearfix.wxss b/utils/dist/common/style/mixins/clearfix.wxss new file mode 100644 index 0000000..e69de29 diff --git a/utils/dist/common/style/mixins/ellipsis.wxss b/utils/dist/common/style/mixins/ellipsis.wxss new file mode 100644 index 0000000..e69de29 diff --git a/utils/dist/common/style/mixins/hairline.wxss b/utils/dist/common/style/mixins/hairline.wxss new file mode 100644 index 0000000..e69de29 diff --git a/utils/dist/common/style/theme.wxss b/utils/dist/common/style/theme.wxss new file mode 100644 index 0000000..e69de29 diff --git a/utils/dist/common/style/var.wxss b/utils/dist/common/style/var.wxss new file mode 100644 index 0000000..e69de29 diff --git a/utils/dist/common/utils.d.ts b/utils/dist/common/utils.d.ts new file mode 100644 index 0000000..9fad27d --- /dev/null +++ b/utils/dist/common/utils.d.ts @@ -0,0 +1,8 @@ +/// +export declare function isDef(value: any): boolean; +export declare function isObj(x: any): boolean; +export declare function isNumber(value: any): boolean; +export declare function range(num: number, min: number, max: number): number; +export declare function nextTick(fn: Function): void; +export declare function getSystemInfoSync(): WechatMiniprogram.GetSystemInfoSuccessCallbackResult; +export declare function addUnit(value?: string | number): string | undefined; diff --git a/utils/dist/common/utils.js b/utils/dist/common/utils.js new file mode 100644 index 0000000..cc0f8f1 --- /dev/null +++ b/utils/dist/common/utils.js @@ -0,0 +1,32 @@ +export function isDef(value) { + return value !== undefined && value !== null; +} +export function isObj(x) { + const type = typeof x; + return x !== null && (type === 'object' || type === 'function'); +} +export function isNumber(value) { + return /^\d+(\.\d+)?$/.test(value); +} +export function range(num, min, max) { + return Math.min(Math.max(num, min), max); +} +export function nextTick(fn) { + setTimeout(() => { + fn(); + }, 1000 / 30); +} +let systemInfo = null; +export function getSystemInfoSync() { + if (systemInfo == null) { + systemInfo = wx.getSystemInfoSync(); + } + return systemInfo; +} +export function addUnit(value) { + if (!isDef(value)) { + return undefined; + } + value = String(value); + return isNumber(value) ? `${value}px` : value; +} diff --git a/utils/dist/count-down/index.d.ts b/utils/dist/count-down/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/count-down/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/count-down/index.js b/utils/dist/count-down/index.js new file mode 100644 index 0000000..54a01fe --- /dev/null +++ b/utils/dist/count-down/index.js @@ -0,0 +1,100 @@ +import { VantComponent } from '../common/component'; +import { isSameSecond, parseFormat, parseTimeData } from './utils'; +function simpleTick(fn) { + return setTimeout(fn, 30); +} +VantComponent({ + props: { + useSlot: Boolean, + millisecond: Boolean, + time: { + type: Number, + observer: 'reset' + }, + format: { + type: String, + value: 'HH:mm:ss' + }, + autoStart: { + type: Boolean, + value: true + } + }, + data: { + timeData: parseTimeData(0), + formattedTime: '0' + }, + destroyed() { + clearTimeout(this.tid); + this.tid = null; + }, + methods: { + // 开始 + start() { + if (this.counting) { + return; + } + this.counting = true; + this.endTime = Date.now() + this.remain; + this.tick(); + }, + // 暂停 + pause() { + this.counting = false; + clearTimeout(this.tid); + }, + // 重置 + reset() { + this.pause(); + this.remain = this.data.time; + this.setRemain(this.remain); + if (this.data.autoStart) { + this.start(); + } + }, + tick() { + if (this.data.millisecond) { + this.microTick(); + } + else { + this.macroTick(); + } + }, + microTick() { + this.tid = simpleTick(() => { + this.setRemain(this.getRemain()); + if (this.remain !== 0) { + this.microTick(); + } + }); + }, + macroTick() { + this.tid = simpleTick(() => { + const remain = this.getRemain(); + if (!isSameSecond(remain, this.remain) || remain === 0) { + this.setRemain(remain); + } + if (this.remain !== 0) { + this.macroTick(); + } + }); + }, + getRemain() { + return Math.max(this.endTime - Date.now(), 0); + }, + setRemain(remain) { + this.remain = remain; + const timeData = parseTimeData(remain); + if (this.data.useSlot) { + this.$emit('change', timeData); + } + this.setData({ + formattedTime: parseFormat(this.data.format, timeData) + }); + if (remain === 0) { + this.pause(); + this.$emit('finish'); + } + } + } +}); diff --git a/utils/dist/count-down/index.json b/utils/dist/count-down/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/count-down/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/count-down/index.wxml b/utils/dist/count-down/index.wxml new file mode 100644 index 0000000..e206e16 --- /dev/null +++ b/utils/dist/count-down/index.wxml @@ -0,0 +1,4 @@ + + + {{ formattedTime }} + diff --git a/utils/dist/count-down/index.wxss b/utils/dist/count-down/index.wxss new file mode 100644 index 0000000..bc33f5d --- /dev/null +++ b/utils/dist/count-down/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-count-down{color:#323233;color:var(--count-down-text-color,#323233);font-size:14px;font-size:var(--count-down-font-size,14px);line-height:20px;line-height:var(--count-down-line-height,20px)} \ No newline at end of file diff --git a/utils/dist/count-down/utils.d.ts b/utils/dist/count-down/utils.d.ts new file mode 100644 index 0000000..e4a58dd --- /dev/null +++ b/utils/dist/count-down/utils.d.ts @@ -0,0 +1,10 @@ +export declare type TimeData = { + days: number; + hours: number; + minutes: number; + seconds: number; + milliseconds: number; +}; +export declare function parseTimeData(time: number): TimeData; +export declare function parseFormat(format: string, timeData: TimeData): string; +export declare function isSameSecond(time1: number, time2: number): boolean; diff --git a/utils/dist/count-down/utils.js b/utils/dist/count-down/utils.js new file mode 100644 index 0000000..3237988 --- /dev/null +++ b/utils/dist/count-down/utils.js @@ -0,0 +1,57 @@ +function padZero(num, targetLength = 2) { + let str = num + ''; + while (str.length < targetLength) { + str = '0' + str; + } + return str; +} +const SECOND = 1000; +const MINUTE = 60 * SECOND; +const HOUR = 60 * MINUTE; +const DAY = 24 * HOUR; +export function parseTimeData(time) { + const days = Math.floor(time / DAY); + const hours = Math.floor((time % DAY) / HOUR); + const minutes = Math.floor((time % HOUR) / MINUTE); + const seconds = Math.floor((time % MINUTE) / SECOND); + const milliseconds = Math.floor(time % SECOND); + return { + days, + hours, + minutes, + seconds, + milliseconds + }; +} +export function parseFormat(format, timeData) { + const { days } = timeData; + let { hours, minutes, seconds, milliseconds } = timeData; + if (format.indexOf('DD') === -1) { + hours += days * 24; + } + else { + format = format.replace('DD', padZero(days)); + } + if (format.indexOf('HH') === -1) { + minutes += hours * 60; + } + else { + format = format.replace('HH', padZero(hours)); + } + if (format.indexOf('mm') === -1) { + seconds += minutes * 60; + } + else { + format = format.replace('mm', padZero(minutes)); + } + if (format.indexOf('ss') === -1) { + milliseconds += seconds * 1000; + } + else { + format = format.replace('ss', padZero(seconds)); + } + return format.replace('SSS', padZero(milliseconds, 3)); +} +export function isSameSecond(time1, time2) { + return Math.floor(time1 / 1000) === Math.floor(time2 / 1000); +} diff --git a/utils/dist/datetime-picker/index.d.ts b/utils/dist/datetime-picker/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/datetime-picker/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/datetime-picker/index.js b/utils/dist/datetime-picker/index.js new file mode 100644 index 0000000..d350d11 --- /dev/null +++ b/utils/dist/datetime-picker/index.js @@ -0,0 +1,297 @@ +import { VantComponent } from '../common/component'; +import { isDef } from '../common/utils'; +import { pickerProps } from '../picker/shared'; +const currentYear = new Date().getFullYear(); +function isValidDate(date) { + return isDef(date) && !isNaN(new Date(date).getTime()); +} +function range(num, min, max) { + return Math.min(Math.max(num, min), max); +} +function padZero(val) { + return `00${val}`.slice(-2); +} +function times(n, iteratee) { + let index = -1; + const result = Array(n < 0 ? 0 : n); + while (++index < n) { + result[index] = iteratee(index); + } + return result; +} +function getTrueValue(formattedValue) { + if (!formattedValue) + return; + while (isNaN(parseInt(formattedValue, 10))) { + formattedValue = formattedValue.slice(1); + } + return parseInt(formattedValue, 10); +} +function getMonthEndDay(year, month) { + return 32 - new Date(year, month - 1, 32).getDate(); +} +const defaultFormatter = (_, value) => value; +VantComponent({ + classes: ['active-class', 'toolbar-class', 'column-class'], + props: Object.assign(Object.assign({}, pickerProps), { value: null, filter: null, type: { + type: String, + value: 'datetime' + }, showToolbar: { + type: Boolean, + value: true + }, formatter: { + type: null, + value: defaultFormatter + }, minDate: { + type: Number, + value: new Date(currentYear - 10, 0, 1).getTime() + }, maxDate: { + type: Number, + value: new Date(currentYear + 10, 11, 31).getTime() + }, minHour: { + type: Number, + value: 0 + }, maxHour: { + type: Number, + value: 23 + }, minMinute: { + type: Number, + value: 0 + }, maxMinute: { + type: Number, + value: 59 + } }), + data: { + innerValue: Date.now(), + columns: [] + }, + watch: { + value: 'updateValue', + type: 'updateValue', + minDate: 'updateValue', + maxDate: 'updateValue', + minHour: 'updateValue', + maxHour: 'updateValue', + minMinute: 'updateValue', + maxMinute: 'updateValue' + }, + methods: { + updateValue() { + const { data } = this; + const val = this.correctValue(this.data.value); + const isEqual = val === data.innerValue; + if (!isEqual) { + this.updateColumnValue(val).then(() => { + this.$emit('input', val); + }); + } + else { + this.updateColumns(); + } + }, + getPicker() { + if (this.picker == null) { + this.picker = this.selectComponent('.van-datetime-picker'); + const { picker } = this; + const { setColumnValues } = picker; + picker.setColumnValues = (...args) => setColumnValues.apply(picker, [...args, false]); + } + return this.picker; + }, + updateColumns() { + const { formatter = defaultFormatter } = this.data; + const results = this.getOriginColumns().map(column => ({ + values: column.values.map(value => formatter(column.type, value)) + })); + return this.set({ columns: results }); + }, + getOriginColumns() { + const { filter } = this.data; + const results = this.getRanges().map(({ type, range }) => { + let values = times(range[1] - range[0] + 1, index => { + let value = range[0] + index; + value = type === 'year' ? `${value}` : padZero(value); + return value; + }); + if (filter) { + values = filter(type, values); + } + return { type, values }; + }); + return results; + }, + getRanges() { + const { data } = this; + if (data.type === 'time') { + return [ + { + type: 'hour', + range: [data.minHour, data.maxHour] + }, + { + type: 'minute', + range: [data.minMinute, data.maxMinute] + } + ]; + } + const { maxYear, maxDate, maxMonth, maxHour, maxMinute } = this.getBoundary('max', data.innerValue); + const { minYear, minDate, minMonth, minHour, minMinute } = this.getBoundary('min', data.innerValue); + const result = [ + { + type: 'year', + range: [minYear, maxYear] + }, + { + type: 'month', + range: [minMonth, maxMonth] + }, + { + type: 'day', + range: [minDate, maxDate] + }, + { + type: 'hour', + range: [minHour, maxHour] + }, + { + type: 'minute', + range: [minMinute, maxMinute] + } + ]; + if (data.type === 'date') + result.splice(3, 2); + if (data.type === 'year-month') + result.splice(2, 3); + return result; + }, + correctValue(value) { + const { data } = this; + // validate value + const isDateType = data.type !== 'time'; + if (isDateType && !isValidDate(value)) { + value = data.minDate; + } + else if (!isDateType && !value) { + const { minHour } = data; + value = `${padZero(minHour)}:00`; + } + // time type + if (!isDateType) { + let [hour, minute] = value.split(':'); + hour = padZero(range(hour, data.minHour, data.maxHour)); + minute = padZero(range(minute, data.minMinute, data.maxMinute)); + return `${hour}:${minute}`; + } + // date type + value = Math.max(value, data.minDate); + value = Math.min(value, data.maxDate); + return value; + }, + getBoundary(type, innerValue) { + const value = new Date(innerValue); + const boundary = new Date(this.data[`${type}Date`]); + const year = boundary.getFullYear(); + let month = 1; + let date = 1; + let hour = 0; + let minute = 0; + if (type === 'max') { + month = 12; + date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1); + hour = 23; + minute = 59; + } + if (value.getFullYear() === year) { + month = boundary.getMonth() + 1; + if (value.getMonth() + 1 === month) { + date = boundary.getDate(); + if (value.getDate() === date) { + hour = boundary.getHours(); + if (value.getHours() === hour) { + minute = boundary.getMinutes(); + } + } + } + } + return { + [`${type}Year`]: year, + [`${type}Month`]: month, + [`${type}Date`]: date, + [`${type}Hour`]: hour, + [`${type}Minute`]: minute + }; + }, + onCancel() { + this.$emit('cancel'); + }, + onConfirm() { + this.$emit('confirm', this.data.innerValue); + }, + onChange() { + const { data } = this; + let value; + const picker = this.getPicker(); + if (data.type === 'time') { + const indexes = picker.getIndexes(); + value = `${+data.columns[0].values[indexes[0]]}:${+data.columns[1].values[indexes[1]]}`; + } + else { + const values = picker.getValues(); + const year = getTrueValue(values[0]); + const month = getTrueValue(values[1]); + const maxDate = getMonthEndDay(year, month); + let date = getTrueValue(values[2]); + if (data.type === 'year-month') { + date = 1; + } + date = date > maxDate ? maxDate : date; + let hour = 0; + let minute = 0; + if (data.type === 'datetime') { + hour = getTrueValue(values[3]); + minute = getTrueValue(values[4]); + } + value = new Date(year, month - 1, date, hour, minute); + } + value = this.correctValue(value); + this.updateColumnValue(value).then(() => { + this.$emit('input', value); + this.$emit('change', picker); + }); + }, + updateColumnValue(value) { + let values = []; + const { type, formatter = defaultFormatter } = this.data; + const picker = this.getPicker(); + if (type === 'time') { + const pair = value.split(':'); + values = [ + formatter('hour', pair[0]), + formatter('minute', pair[1]) + ]; + } + else { + const date = new Date(value); + values = [ + formatter('year', `${date.getFullYear()}`), + formatter('month', padZero(date.getMonth() + 1)) + ]; + if (type === 'date') { + values.push(formatter('day', padZero(date.getDate()))); + } + if (type === 'datetime') { + values.push(formatter('day', padZero(date.getDate())), formatter('hour', padZero(date.getHours())), formatter('minute', padZero(date.getMinutes()))); + } + } + return this.set({ innerValue: value }) + .then(() => this.updateColumns()) + .then(() => picker.setValues(values)); + } + }, + created() { + const innerValue = this.correctValue(this.data.value); + this.updateColumnValue(innerValue).then(() => { + this.$emit('input', innerValue); + }); + } +}); diff --git a/utils/dist/datetime-picker/index.json b/utils/dist/datetime-picker/index.json new file mode 100644 index 0000000..a778e91 --- /dev/null +++ b/utils/dist/datetime-picker/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-picker": "../picker/index" + } +} diff --git a/utils/dist/datetime-picker/index.wxml b/utils/dist/datetime-picker/index.wxml new file mode 100644 index 0000000..ade2202 --- /dev/null +++ b/utils/dist/datetime-picker/index.wxml @@ -0,0 +1,16 @@ + diff --git a/utils/dist/datetime-picker/index.wxss b/utils/dist/datetime-picker/index.wxss new file mode 100644 index 0000000..99694d6 --- /dev/null +++ b/utils/dist/datetime-picker/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss'; \ No newline at end of file diff --git a/utils/dist/definitions/index.d.ts b/utils/dist/definitions/index.d.ts new file mode 100644 index 0000000..3a8fc16 --- /dev/null +++ b/utils/dist/definitions/index.d.ts @@ -0,0 +1,28 @@ +/// +import { Weapp } from './weapp'; +declare type RecordToAny = { + [K in keyof T]: any; +}; +export declare type CombinedComponentInstance = Methods & WechatMiniprogram.Component.TrivialInstance & Weapp.FormField & { + data: Data & RecordToAny; +}; +export interface VantComponentOptions { + data?: Data; + field?: boolean; + classes?: string[]; + mixins?: string[]; + props?: Props & Weapp.PropertyOption; + watch?: Weapp.WatchOption; + relation?: Weapp.RelationOption & { + name: string; + }; + relations?: { + [componentName: string]: Weapp.RelationOption; + }; + methods?: Methods & Weapp.MethodOption; + beforeCreate?: (this: Instance) => void; + created?: (this: Instance) => void; + mounted?: (this: Instance) => void; + destroyed?: (this: Instance) => void; +} +export {}; diff --git a/utils/dist/definitions/index.js b/utils/dist/definitions/index.js new file mode 100644 index 0000000..e69de29 diff --git a/utils/dist/definitions/weapp.d.ts b/utils/dist/definitions/weapp.d.ts new file mode 100644 index 0000000..5fb0060 --- /dev/null +++ b/utils/dist/definitions/weapp.d.ts @@ -0,0 +1,112 @@ +/// +export declare namespace Weapp { + export interface FormField { + data: { + name: string; + value: any; + }; + } + interface Target { + id: string; + tagName: string; + dataset: { + [key: string]: any; + }; + } + export interface Event { + /** + * 代表事件的类型。 + */ + type: string; + /** + * 页面打开到触发事件所经过的毫秒数。 + */ + timeStamp: number; + /** + * 触发事件的源组件。 + */ + target: Target; + /** + * 事件绑定的当前组件。 + */ + currentTarget: Target; + /** + * 额外的信息 + */ + detail: any; + } + interface Touch { + /** + * 触摸点的标识符 + */ + identifier: number; + /** + * 距离文档左上角的距离,文档的左上角为原点 ,横向为X轴,纵向为Y轴 + */ + pageX: number; + /** + * 距离文档左上角的距离,文档的左上角为原点 ,横向为X轴,纵向为Y轴 + */ + pageY: number; + /** + * 距离页面可显示区域(屏幕除去导航条)左上角距离,横向为X轴,纵向为Y轴 + */ + clientX: number; + /** + * 距离页面可显示区域(屏幕除去导航条)左上角距离,横向为X轴,纵向为Y轴 + */ + clientY: number; + } + export interface TouchEvent extends Event { + touches: Array; + changedTouches: Array; + } + /** + * relation定义,miniprogram-api-typings缺少this定义 + */ + export interface RelationOption { + /** 目标组件的相对关系 */ + type: 'parent' | 'child' | 'ancestor' | 'descendant'; + /** 关系生命周期函数,当关系被建立在页面节点树中时触发,触发时机在组件attached生命周期之后 */ + linked?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void; + /** 关系生命周期函数,当关系在页面节点树中发生改变时触发,触发时机在组件moved生命周期之后 */ + linkChanged?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void; + /** 关系生命周期函数,当关系脱离页面节点树时触发,触发时机在组件detached生命周期之后 */ + unlinked?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void; + /** 如果这一项被设置,则它表示关联的目标节点所应具有的behavior,所有拥有这一behavior的组件节点都会被关联 */ + target?: string; + } + /** + * obverser定义,miniprogram-api-typings缺少this定义 + */ + type Observer = (this: Instance, newVal: T, oldVal: T, changedPath: Array) => void; + /** + * watch定义 + */ + export interface WatchOption { + [name: string]: string | Observer; + } + /** + * methods定义,miniprogram-api-typings缺少this定义 + */ + export interface MethodOption { + [name: string]: (this: Instance, ...args: any[]) => any; + } + export interface ComputedOption { + [name: string]: (this: Instance) => any; + } + type PropertyType = StringConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor | ObjectConstructor | FunctionConstructor | null; + export interface PropertyOption { + [name: string]: PropertyType | PropertyType[] | { + /** 属性类型 */ + type: PropertyType | PropertyType[]; + /** 属性初始值 */ + value?: any; + /** 属性值被更改时的响应函数 */ + observer?: string | Observer; + /** 属性的类型(可以指定多个) */ + optionalTypes?: PropertyType[]; + }; + } + export {}; +} diff --git a/utils/dist/definitions/weapp.js b/utils/dist/definitions/weapp.js new file mode 100644 index 0000000..e69de29 diff --git a/utils/dist/dialog/dialog.d.ts b/utils/dist/dialog/dialog.d.ts new file mode 100644 index 0000000..66769a6 --- /dev/null +++ b/utils/dist/dialog/dialog.d.ts @@ -0,0 +1,47 @@ +/// +declare type DialogAction = 'confirm' | 'cancel'; +declare type DialogOptions = { + lang?: string; + show?: boolean; + title?: string; + width?: string | number; + zIndex?: number; + context?: WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance; + message?: string; + overlay?: boolean; + selector?: string; + ariaLabel?: string; + className?: string; + customStyle?: string; + transition?: string; + asyncClose?: boolean; + businessId?: number; + sessionFrom?: string; + overlayStyle?: string; + appParameter?: string; + messageAlign?: string; + sendMessageImg?: string; + showMessageCard?: boolean; + sendMessagePath?: string; + sendMessageTitle?: string; + confirmButtonText?: string; + cancelButtonText?: string; + showConfirmButton?: boolean; + showCancelButton?: boolean; + closeOnClickOverlay?: boolean; + confirmButtonOpenType?: string; +}; +interface Dialog { + (options: DialogOptions): Promise; + alert?: (options: DialogOptions) => Promise; + confirm?: (options: DialogOptions) => Promise; + close?: () => void; + stopLoading?: () => void; + install?: () => void; + setDefaultOptions?: (options: DialogOptions) => void; + resetDefaultOptions?: () => void; + defaultOptions?: DialogOptions; + currentOptions?: DialogOptions; +} +declare const Dialog: Dialog; +export default Dialog; diff --git a/utils/dist/dialog/dialog.js b/utils/dist/dialog/dialog.js new file mode 100644 index 0000000..4c4f7e4 --- /dev/null +++ b/utils/dist/dialog/dialog.js @@ -0,0 +1,63 @@ +let queue = []; +function getContext() { + const pages = getCurrentPages(); + return pages[pages.length - 1]; +} +const Dialog = options => { + options = Object.assign(Object.assign({}, Dialog.currentOptions), options); + return new Promise((resolve, reject) => { + const context = options.context || getContext(); + const dialog = context.selectComponent(options.selector); + delete options.context; + delete options.selector; + if (dialog) { + dialog.setData(Object.assign({ onCancel: reject, onConfirm: resolve }, options)); + queue.push(dialog); + } + else { + console.warn('未找到 van-dialog 节点,请确认 selector 及 context 是否正确'); + } + }); +}; +Dialog.defaultOptions = { + show: true, + title: '', + width: null, + message: '', + zIndex: 100, + overlay: true, + selector: '#van-dialog', + className: '', + asyncClose: false, + transition: 'scale', + customStyle: '', + messageAlign: '', + overlayStyle: '', + confirmButtonText: '确认', + cancelButtonText: '取消', + showConfirmButton: true, + showCancelButton: false, + closeOnClickOverlay: false, + confirmButtonOpenType: '' +}; +Dialog.alert = Dialog; +Dialog.confirm = options => Dialog(Object.assign({ showCancelButton: true }, options)); +Dialog.close = () => { + queue.forEach(dialog => { + dialog.close(); + }); + queue = []; +}; +Dialog.stopLoading = () => { + queue.forEach(dialog => { + dialog.stopLoading(); + }); +}; +Dialog.setDefaultOptions = options => { + Object.assign(Dialog.currentOptions, options); +}; +Dialog.resetDefaultOptions = () => { + Dialog.currentOptions = Object.assign({}, Dialog.defaultOptions); +}; +Dialog.resetDefaultOptions(); +export default Dialog; diff --git a/utils/dist/dialog/index.d.ts b/utils/dist/dialog/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/dialog/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/dialog/index.js b/utils/dist/dialog/index.js new file mode 100644 index 0000000..85d6c3c --- /dev/null +++ b/utils/dist/dialog/index.js @@ -0,0 +1,119 @@ +import { VantComponent } from '../common/component'; +import { button } from '../mixins/button'; +import { openType } from '../mixins/open-type'; +import { addUnit } from '../common/utils'; +import { GRAY, BLUE } from '../common/color'; +VantComponent({ + mixins: [button, openType], + props: { + show: Boolean, + title: String, + message: String, + useSlot: Boolean, + className: String, + customStyle: String, + asyncClose: Boolean, + messageAlign: String, + overlayStyle: String, + useTitleSlot: Boolean, + showCancelButton: Boolean, + closeOnClickOverlay: Boolean, + confirmButtonOpenType: String, + width: { + type: null, + observer: 'setWidthWithUnit' + }, + zIndex: { + type: Number, + value: 2000 + }, + confirmButtonText: { + type: String, + value: '确认' + }, + cancelButtonText: { + type: String, + value: '取消' + }, + confirmButtonColor: { + type: String, + value: BLUE + }, + cancelButtonColor: { + type: String, + value: GRAY + }, + showConfirmButton: { + type: Boolean, + value: true + }, + overlay: { + type: Boolean, + value: true + }, + transition: { + type: String, + value: 'scale' + } + }, + data: { + loading: { + confirm: false, + cancel: false + } + }, + watch: { + show(show) { + !show && this.stopLoading(); + } + }, + methods: { + onConfirm() { + this.handleAction('confirm'); + }, + onCancel() { + this.handleAction('cancel'); + }, + onClickOverlay() { + this.onClose('overlay'); + }, + handleAction(action) { + if (this.data.asyncClose) { + this.setData({ + [`loading.${action}`]: true + }); + } + this.onClose(action); + }, + close() { + this.setData({ + show: false + }); + }, + stopLoading() { + this.setData({ + loading: { + confirm: false, + cancel: false + } + }); + }, + onClose(action) { + if (!this.data.asyncClose) { + this.close(); + } + this.$emit('close', action); + // 把 dialog 实例传递出去,可以通过 stopLoading() 在外部关闭按钮的 loading + this.$emit(action, { dialog: this }); + const callback = this.data[action === 'confirm' ? 'onConfirm' : 'onCancel']; + if (callback) { + callback(this); + } + }, + setWidthWithUnit(val) { + this.setData({ + widthWithUnit: addUnit(val) + }); + } + } +}); diff --git a/utils/dist/dialog/index.json b/utils/dist/dialog/index.json new file mode 100644 index 0000000..e2ee09a --- /dev/null +++ b/utils/dist/dialog/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-popup": "../popup/index", + "van-button": "../button/index" + } +} diff --git a/utils/dist/dialog/index.wxml b/utils/dist/dialog/index.wxml new file mode 100644 index 0000000..854e8a1 --- /dev/null +++ b/utils/dist/dialog/index.wxml @@ -0,0 +1,69 @@ + + + + {{ title }} + + + + + {{ message }} + + + + + {{ cancelButtonText }} + + + {{ confirmButtonText }} + + + diff --git a/utils/dist/dialog/index.wxss b/utils/dist/dialog/index.wxss new file mode 100644 index 0000000..e5f6cbb --- /dev/null +++ b/utils/dist/dialog/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-dialog{top:45%!important;overflow:hidden;width:320px;width:var(--dialog-width,320px);font-size:16px;font-size:var(--dialog-font-size,16px);border-radius:16px;border-radius:var(--dialog-border-radius,16px);background-color:#fff;background-color:var(--dialog-background-color,#fff)}@media (max-width:321px){.van-dialog{width:90%;width:var(--dialog-small-screen-width,90%)}}.van-dialog__header{text-align:center;padding-top:24px;padding-top:var(--dialog-header-padding-top,24px);font-weight:500;font-weight:var(--dialog-header-font-weight,500);line-height:24px;line-height:var(--dialog-header-line-height,24px)}.van-dialog__header--isolated{padding:24px 0;padding:var(--dialog-header-isolated-padding,24px 0)}.van-dialog__message{overflow-y:auto;text-align:center;-webkit-overflow-scrolling:touch;font-size:14px;font-size:var(--dialog-message-font-size,14px);line-height:20px;line-height:var(--dialog-message-line-height,20px);max-height:60vh;max-height:var(--dialog-message-max-height,60vh);padding:24px;padding:var(--dialog-message-padding,24px)}.van-dialog__message-text{word-wrap:break-word}.van-dialog__message--has-title{padding-top:12px;padding-top:var(--dialog-has-title-message-padding-top,12px);color:#646566;color:var(--dialog-has-title-message-text-color,#646566)}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__footer{display:-webkit-flex;display:flex}.van-dialog__button{-webkit-flex:1;flex:1}.van-dialog__cancel,.van-dialog__confirm{border:0!important}.van-dialog-bounce-enter{-webkit-transform:translate3d(-50%,-50%,0) scale(.7);transform:translate3d(-50%,-50%,0) scale(.7);opacity:0}.van-dialog-bounce-leave-active{-webkit-transform:translate3d(-50%,-50%,0) scale(.9);transform:translate3d(-50%,-50%,0) scale(.9);opacity:0} \ No newline at end of file diff --git a/utils/dist/divider/index.d.ts b/utils/dist/divider/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/divider/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/divider/index.js b/utils/dist/divider/index.js new file mode 100644 index 0000000..73f833d --- /dev/null +++ b/utils/dist/divider/index.js @@ -0,0 +1,33 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + dashed: { + type: Boolean, + value: false + }, + hairline: { + type: Boolean, + value: false + }, + contentPosition: { + type: String, + value: '' + }, + fontSize: { + type: Number, + value: '' + }, + borderColor: { + type: String, + value: '' + }, + textColor: { + type: String, + value: '' + }, + customStyle: { + type: String, + value: '' + } + } +}); diff --git a/utils/dist/divider/index.json b/utils/dist/divider/index.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/utils/dist/divider/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/utils/dist/divider/index.wxml b/utils/dist/divider/index.wxml new file mode 100644 index 0000000..412e73f --- /dev/null +++ b/utils/dist/divider/index.wxml @@ -0,0 +1,8 @@ + + + + + diff --git a/utils/dist/divider/index.wxss b/utils/dist/divider/index.wxss new file mode 100644 index 0000000..c055e3a --- /dev/null +++ b/utils/dist/divider/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-divider{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;margin:16px 0;margin:var(--divider-margin,16px 0);color:#969799;color:var(--divider-text-color,#969799);font-size:14px;font-size:var(--divider-font-size,14px);line-height:24px;line-height:var(--divider-line-height,24px);border:0 solid #ebedf0;border-color:var(--divider-border-color,#ebedf0)}.van-divider:after,.van-divider:before{display:block;-webkit-flex:1;flex:1;box-sizing:border-box;height:1px;border-color:inherit;border-style:inherit;border-width:1px 0 0}.van-divider:before{content:""}.van-divider--hairline:after,.van-divider--hairline:before{-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-divider--dashed{border-style:dashed}.van-divider--center:before,.van-divider--left:before,.van-divider--right:before{margin-right:16px;margin-right:var(--divider-content-padding,16px)}.van-divider--center:after,.van-divider--left:after,.van-divider--right:after{content:"";margin-left:16px;margin-left:var(--divider-content-padding,16px)}.van-divider--left:before{max-width:10%;max-width:var(--divider-content-left-width,10%)}.van-divider--right:after{max-width:10%;max-width:var(--divider-content-right-width,10%)} \ No newline at end of file diff --git a/utils/dist/dropdown-item/index.d.ts b/utils/dist/dropdown-item/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/dropdown-item/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/dropdown-item/index.js b/utils/dist/dropdown-item/index.js new file mode 100644 index 0000000..f2b6c48 --- /dev/null +++ b/utils/dist/dropdown-item/index.js @@ -0,0 +1,104 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + field: true, + relation: { + name: 'dropdown-menu', + type: 'ancestor', + linked(target) { + this.parent = target; + this.updateDataFromParent(); + }, + unlinked() { + this.parent = null; + } + }, + props: { + value: { + type: null, + observer: 'rerender' + }, + title: { + type: String, + observer: 'rerender' + }, + disabled: Boolean, + titleClass: { + type: String, + observer: 'rerender' + }, + options: { + type: Array, + value: [], + observer: 'rerender' + } + }, + data: { + transition: true, + showPopup: false, + showWrapper: false, + displayTitle: '' + }, + methods: { + rerender() { + wx.nextTick(() => { + this.parent && this.parent.updateItemListData(); + }); + }, + updateDataFromParent() { + if (this.parent) { + const { overlay, duration, activeColor, closeOnClickOverlay, direction } = this.parent.data; + this.setData({ + overlay, + duration, + activeColor, + closeOnClickOverlay, + direction + }); + } + }, + onClickOverlay() { + this.toggle(); + this.$emit('close'); + }, + onOptionTap(event) { + const { option } = event.currentTarget.dataset; + const { value } = option; + const shouldEmitChange = this.data.value !== value; + this.setData({ showPopup: false, value }); + setTimeout(() => { + this.setData({ showWrapper: false }); + }, this.data.duration || 0); + this.rerender(); + if (shouldEmitChange) { + this.$emit('change', value); + } + }, + toggle(show, options = {}) { + const { showPopup, duration } = this.data; + if (show == null) { + show = !showPopup; + } + if (show === showPopup) { + return; + } + if (!show) { + const time = options.immediate ? 0 : duration; + this.setData({ transition: !options.immediate, showPopup: show }); + setTimeout(() => { + this.setData({ showWrapper: false }); + }, time); + this.rerender(); + return; + } + this.parent.getChildWrapperStyle().then((wrapperStyle = '') => { + this.setData({ + transition: !options.immediate, + showPopup: show, + wrapperStyle, + showWrapper: true + }); + this.rerender(); + }); + } + } +}); diff --git a/utils/dist/dropdown-item/index.json b/utils/dist/dropdown-item/index.json new file mode 100644 index 0000000..88d5409 --- /dev/null +++ b/utils/dist/dropdown-item/index.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": { + "van-popup": "../popup/index", + "van-cell": "../cell/index", + "van-icon": "../icon/index" + } +} diff --git a/utils/dist/dropdown-item/index.wxml b/utils/dist/dropdown-item/index.wxml new file mode 100644 index 0000000..07bca8d --- /dev/null +++ b/utils/dist/dropdown-item/index.wxml @@ -0,0 +1,44 @@ + + + + + + + {{ item.text }} + + + + + + + diff --git a/utils/dist/dropdown-item/index.wxss b/utils/dist/dropdown-item/index.wxss new file mode 100644 index 0000000..e06c287 --- /dev/null +++ b/utils/dist/dropdown-item/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-dropdown-item{position:fixed;right:0;left:0;overflow:hidden}.van-dropdown-item__option{text-align:left}.van-dropdown-item__option--active .van-dropdown-item__icon,.van-dropdown-item__option--active .van-dropdown-item__title{color:#1989fa;color:var(--dropdown-menu-option-active-color,#1989fa)}.van-dropdown-item--up{top:0}.van-dropdown-item--down{bottom:0}.van-dropdown-item__icon{display:block;line-height:inherit} \ No newline at end of file diff --git a/utils/dist/dropdown-menu/index.d.ts b/utils/dist/dropdown-menu/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/dropdown-menu/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/dropdown-menu/index.js b/utils/dist/dropdown-menu/index.js new file mode 100644 index 0000000..889387b --- /dev/null +++ b/utils/dist/dropdown-menu/index.js @@ -0,0 +1,121 @@ +import { VantComponent } from '../common/component'; +import { addUnit } from '../common/utils'; +let ARRAY = []; +VantComponent({ + field: true, + relation: { + name: 'dropdown-item', + type: 'descendant', + linked(target) { + this.children.push(target); + this.updateItemListData(); + }, + unlinked(target) { + this.children = this.children.filter((child) => child !== target); + this.updateItemListData(); + } + }, + props: { + activeColor: { + type: String, + observer: 'updateChildrenData' + }, + overlay: { + type: Boolean, + value: true, + observer: 'updateChildrenData' + }, + zIndex: { + type: Number, + value: 10 + }, + duration: { + type: Number, + value: 200, + observer: 'updateChildrenData' + }, + direction: { + type: String, + value: 'down', + observer: 'updateChildrenData' + }, + closeOnClickOverlay: { + type: Boolean, + value: true, + observer: 'updateChildrenData' + }, + closeOnClickOutside: { + type: Boolean, + value: true + } + }, + data: { + itemListData: [] + }, + beforeCreate() { + const { windowHeight } = wx.getSystemInfoSync(); + this.windowHeight = windowHeight; + this.children = []; + ARRAY.push(this); + }, + destroyed() { + ARRAY = ARRAY.filter(item => item !== this); + }, + methods: { + updateItemListData() { + this.setData({ + itemListData: this.children.map((child) => child.data) + }); + }, + updateChildrenData() { + this.children.forEach((child) => { + child.updateDataFromParent(); + }); + }, + toggleItem(active) { + this.children.forEach((item, index) => { + const { showPopup } = item.data; + if (index === active) { + item.toggle(); + } + else if (showPopup) { + item.toggle(false, { immediate: true }); + } + }); + }, + close() { + this.children.forEach((child) => { + child.toggle(false, { immediate: true }); + }); + }, + getChildWrapperStyle() { + const { zIndex, direction } = this.data; + return this.getRect('.van-dropdown-menu').then((rect) => { + const { top = 0, bottom = 0 } = rect; + const offset = direction === 'down' ? bottom : this.windowHeight - top; + let wrapperStyle = `z-index: ${zIndex};`; + if (direction === 'down') { + wrapperStyle += `top: ${addUnit(offset)};`; + } + else { + wrapperStyle += `bottom: ${addUnit(offset)};`; + } + return wrapperStyle; + }); + }, + onTitleTap(event) { + const { index } = event.currentTarget.dataset; + const child = this.children[index]; + if (!child.data.disabled) { + ARRAY.forEach(menuItem => { + if (menuItem && + menuItem.data.closeOnClickOutside && + menuItem !== this) { + menuItem.close(); + } + }); + this.toggleItem(index); + } + } + } +}); diff --git a/utils/dist/dropdown-menu/index.json b/utils/dist/dropdown-menu/index.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/utils/dist/dropdown-menu/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/utils/dist/dropdown-menu/index.wxml b/utils/dist/dropdown-menu/index.wxml new file mode 100644 index 0000000..037ac3b --- /dev/null +++ b/utils/dist/dropdown-menu/index.wxml @@ -0,0 +1,23 @@ + + + + + + + + {{ computed.displayTitle(item) }} + + + + + + diff --git a/utils/dist/dropdown-menu/index.wxs b/utils/dist/dropdown-menu/index.wxs new file mode 100644 index 0000000..6538854 --- /dev/null +++ b/utils/dist/dropdown-menu/index.wxs @@ -0,0 +1,16 @@ +/* eslint-disable */ +function displayTitle(item) { + if (item.title) { + return item.title; + } + + var match = item.options.filter(function(option) { + return option.value === item.value; + }); + var displayTitle = match.length ? match[0].text : ''; + return displayTitle; +} + +module.exports = { + displayTitle: displayTitle +}; diff --git a/utils/dist/dropdown-menu/index.wxss b/utils/dist/dropdown-menu/index.wxss new file mode 100644 index 0000000..43efd77 --- /dev/null +++ b/utils/dist/dropdown-menu/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-dropdown-menu{display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none;height:50px;height:var(--dropdown-menu-height,50px);background-color:#fff;background-color:var(--dropdown-menu-background-color,#fff)}.van-dropdown-menu__item{display:-webkit-flex;display:flex;-webkit-flex:1;flex:1;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;min-width:0}.van-dropdown-menu__item:active{opacity:.7}.van-dropdown-menu__item--disabled:active{opacity:1}.van-dropdown-menu__item--disabled .van-dropdown-menu__title{color:#969799;color:var(--dropdown-menu-title-disabled-text-color,#969799)}.van-dropdown-menu__title{position:relative;box-sizing:border-box;max-width:100%;padding:0 8px;padding:var(--dropdown-menu-title-padding,0 8px);color:#323233;color:var(--dropdown-menu-title-text-color,#323233);font-size:15px;font-size:var(--dropdown-menu-title-font-size,15px);line-height:18px;line-height:var(--dropdown-menu-title-line-height,18px)}.van-dropdown-menu__title:after{position:absolute;top:50%;right:-4px;margin-top:-5px;border-color:transparent transparent currentcolor currentcolor;border-style:solid;border-width:3px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg);opacity:.8;content:""}.van-dropdown-menu__title--active{color:#1989fa;color:var(--dropdown-menu-title-active-text-color,#1989fa)}.van-dropdown-menu__title--down:after{margin-top:-1px;-webkit-transform:rotate(135deg);transform:rotate(135deg)} \ No newline at end of file diff --git a/utils/dist/field/index.d.ts b/utils/dist/field/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/field/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/field/index.js b/utils/dist/field/index.js new file mode 100644 index 0000000..35dc34c --- /dev/null +++ b/utils/dist/field/index.js @@ -0,0 +1,108 @@ +import { VantComponent } from '../common/component'; +import { getSystemInfoSync } from '../common/utils'; +VantComponent({ + field: true, + classes: ['input-class', 'right-icon-class'], + props: { + size: String, + icon: String, + label: String, + error: Boolean, + fixed: Boolean, + focus: Boolean, + center: Boolean, + isLink: Boolean, + leftIcon: String, + rightIcon: String, + disabled: Boolean, + autosize: Boolean, + readonly: Boolean, + required: Boolean, + password: Boolean, + iconClass: String, + clearable: Boolean, + clickable: Boolean, + inputAlign: String, + placeholder: String, + customStyle: String, + confirmType: String, + confirmHold: Boolean, + holdKeyboard: Boolean, + errorMessage: String, + arrowDirection: String, + placeholderStyle: String, + errorMessageAlign: String, + selectionEnd: { + type: Number, + value: -1 + }, + selectionStart: { + type: Number, + value: -1 + }, + showConfirmBar: { + type: Boolean, + value: true + }, + adjustPosition: { + type: Boolean, + value: true + }, + cursorSpacing: { + type: Number, + value: 50 + }, + maxlength: { + type: Number, + value: -1 + }, + type: { + type: String, + value: 'text' + }, + border: { + type: Boolean, + value: true + }, + titleWidth: { + type: String, + value: '90px' + } + }, + data: { + focused: false, + system: getSystemInfoSync().system.split(' ').shift().toLowerCase() + }, + methods: { + onInput(event) { + const { value = '' } = event.detail || {}; + this.setData({ value }, () => { + this.emitChange(value); + }); + }, + onFocus(event) { + this.setData({ focused: true }); + this.$emit('focus', event.detail); + }, + onBlur(event) { + this.setData({ focused: false }); + this.$emit('blur', event.detail); + }, + onClickIcon() { + this.$emit('click-icon'); + }, + onClear() { + this.setData({ value: '' }, () => { + this.emitChange(''); + this.$emit('clear', ''); + }); + }, + onConfirm() { + this.$emit('confirm', this.data.value); + }, + emitChange(value) { + this.$emit('input', value); + this.$emit('change', value); + } + } +}); diff --git a/utils/dist/field/index.json b/utils/dist/field/index.json new file mode 100644 index 0000000..8809c46 --- /dev/null +++ b/utils/dist/field/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-cell": "../cell/index", + "van-icon": "../icon/index" + } +} \ No newline at end of file diff --git a/utils/dist/field/index.wxml b/utils/dist/field/index.wxml new file mode 100644 index 0000000..6490178 --- /dev/null +++ b/utils/dist/field/index.wxml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + {{ errorMessage }} + + diff --git a/utils/dist/field/index.wxss b/utils/dist/field/index.wxss new file mode 100644 index 0000000..9297f8d --- /dev/null +++ b/utils/dist/field/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-field__body{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center}.van-field__body--textarea{line-height:1.2em;min-height:24px;min-height:var(--cell-line-height,24px)}.van-field__body--textarea.van-field__body--ios{margin-top:-4.5px}.van-field__input{position:relative;display:block;box-sizing:border-box;width:100%;margin:0;padding:0;line-height:inherit;text-align:left;background-color:initial;border:0;resize:none;color:#323233;color:var(--field-input-text-color,#323233);height:24px;height:var(--cell-line-height,24px);min-height:24px;min-height:var(--cell-line-height,24px)}.van-field__input--textarea{height:18px;height:var(--field-text-area-min-height,18px);min-height:18px;min-height:var(--field-text-area-min-height,18px)}.van-field__input--error{color:#ee0a24;color:var(--field-input-error-text-color,#ee0a24)}.van-field__input--disabled{background-color:initial;opacity:1;color:#969799;color:var(--field-input-disabled-text-color,#969799)}.van-field__input--center{text-align:center}.van-field__input--right{text-align:right}.van-field__placeholder{position:absolute;top:0;right:0;left:0;pointer-events:none;color:#969799;color:var(--field-placeholder-text-color,#969799)}.van-field__placeholder--error{color:#ee0a24;color:var(--field-error-message-color,#ee0a24)}.van-field__icon-root{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;min-height:24px;min-height:var(--cell-line-height,24px)}.van-field__clear-root,.van-field__icon-container{line-height:inherit;vertical-align:middle;padding:0 8px;padding:0 var(--padding-xs,8px);margin-right:-8px;margin-right:-var(--padding-xs,8px)}.van-field__button,.van-field__clear-root,.van-field__icon-container{-webkit-flex-shrink:0;flex-shrink:0}.van-field__clear-root{color:#c8c9cc;color:var(--field-clear-icon-color,#c8c9cc)}.van-field__icon-container{color:#969799;color:var(--field-icon-container-color,#969799)}.van-field__icon-container:empty{display:none}.van-field__button{padding-left:8px;padding-left:var(--padding-xs,8px)}.van-field__button:empty{display:none}.van-field__error-message{text-align:left;font-size:12px;font-size:var(--field-error-message-text-font-size,12px);color:#ee0a24;color:var(--field-error-message-color,#ee0a24)}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right} \ No newline at end of file diff --git a/utils/dist/goods-action-button/index.d.ts b/utils/dist/goods-action-button/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/goods-action-button/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/goods-action-button/index.js b/utils/dist/goods-action-button/index.js new file mode 100644 index 0000000..8eed4a3 --- /dev/null +++ b/utils/dist/goods-action-button/index.js @@ -0,0 +1,41 @@ +import { VantComponent } from '../common/component'; +import { link } from '../mixins/link'; +import { button } from '../mixins/button'; +import { openType } from '../mixins/open-type'; +VantComponent({ + mixins: [link, button, openType], + relation: { + type: 'ancestor', + name: 'goods-action', + linked(parent) { + this.parent = parent; + } + }, + props: { + text: String, + color: String, + loading: Boolean, + disabled: Boolean, + type: { + type: String, + value: 'danger' + } + }, + mounted() { + this.updateStyle(); + }, + methods: { + onClick(event) { + this.$emit('click', event.detail); + this.jumpLink(); + }, + updateStyle() { + const { children = [] } = this.parent; + const index = children.indexOf(this); + this.setData({ + isFirst: index === 0, + isLast: index === children.length - 1 + }); + } + } +}); diff --git a/utils/dist/goods-action-button/index.json b/utils/dist/goods-action-button/index.json new file mode 100644 index 0000000..b567686 --- /dev/null +++ b/utils/dist/goods-action-button/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-button": "../button/index" + } +} diff --git a/utils/dist/goods-action-button/index.wxml b/utils/dist/goods-action-button/index.wxml new file mode 100644 index 0000000..d6d2daa --- /dev/null +++ b/utils/dist/goods-action-button/index.wxml @@ -0,0 +1,28 @@ + + + {{ text }} + diff --git a/utils/dist/goods-action-button/index.wxss b/utils/dist/goods-action-button/index.wxss new file mode 100644 index 0000000..5b603f1 --- /dev/null +++ b/utils/dist/goods-action-button/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-goods-action-button{border:none!important;height:40px!important;height:var(--goods-action-button-height,40px)!important;font-weight:500!important;font-weight:var(--font-weight-bold,500)!important;line-height:40px!important;line-height:var(--goods-action-button-height,40px)!important}.van-goods-action-button--first{display:block!important;margin-left:5px;border-top-left-radius:20px!important;border-top-left-radius:var(--goods-action-button-border-radius,20px)!important;border-bottom-left-radius:20px!important;border-bottom-left-radius:var(--goods-action-button-border-radius,20px)!important}.van-goods-action-button--last{display:block!important;margin-right:5px;border-top-right-radius:20px!important;border-top-right-radius:var(--goods-action-button-border-radius,20px)!important;border-bottom-right-radius:20px!important;border-bottom-right-radius:var(--goods-action-button-border-radius,20px)!important}.van-goods-action-button--warning{background:linear-gradient(90deg,#ffd01e,#ff8917);background:var(--goods-action-button-warning-color,linear-gradient(90deg,#ffd01e,#ff8917))}.van-goods-action-button--danger{background:linear-gradient(90deg,#ff6034,#ee0a24);background:var(--goods-action-button-danger-color,linear-gradient(90deg,#ff6034,#ee0a24))}@media (max-width:321px){.van-goods-action-button{font-size:13px}} \ No newline at end of file diff --git a/utils/dist/goods-action-icon/index.d.ts b/utils/dist/goods-action-icon/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/goods-action-icon/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/goods-action-icon/index.js b/utils/dist/goods-action-icon/index.js new file mode 100644 index 0000000..5a32e70 --- /dev/null +++ b/utils/dist/goods-action-icon/index.js @@ -0,0 +1,22 @@ +import { VantComponent } from '../common/component'; +import { link } from '../mixins/link'; +import { button } from '../mixins/button'; +import { openType } from '../mixins/open-type'; +VantComponent({ + classes: ['icon-class', 'text-class'], + mixins: [link, button, openType], + props: { + text: String, + dot: Boolean, + info: String, + icon: String, + disabled: Boolean, + loading: Boolean + }, + methods: { + onClick(event) { + this.$emit('click', event.detail); + this.jumpLink(); + } + } +}); diff --git a/utils/dist/goods-action-icon/index.json b/utils/dist/goods-action-icon/index.json new file mode 100644 index 0000000..93bfe8a --- /dev/null +++ b/utils/dist/goods-action-icon/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-button": "../button/index" + } +} diff --git a/utils/dist/goods-action-icon/index.wxml b/utils/dist/goods-action-icon/index.wxml new file mode 100644 index 0000000..f3f0052 --- /dev/null +++ b/utils/dist/goods-action-icon/index.wxml @@ -0,0 +1,38 @@ + + + + + {{ text }} + + diff --git a/utils/dist/goods-action-icon/index.wxss b/utils/dist/goods-action-icon/index.wxss new file mode 100644 index 0000000..30fff3d --- /dev/null +++ b/utils/dist/goods-action-icon/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-goods-action-icon{border:none!important;width:50px!important;width:var(--goods-action-icon-height,50px)!important}.van-goods-action-icon__content{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center;justify-content:center;height:100%;line-height:1;font-size:10px;font-size:var(--goods-action-icon-font-size,10px);color:#646566;color:var(--goods-action-icon-text-color,#646566)}.van-goods-action-icon__icon{margin-bottom:4px} \ No newline at end of file diff --git a/utils/dist/goods-action/index.d.ts b/utils/dist/goods-action/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/goods-action/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/goods-action/index.js b/utils/dist/goods-action/index.js new file mode 100644 index 0000000..4a07ba8 --- /dev/null +++ b/utils/dist/goods-action/index.js @@ -0,0 +1,22 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + relation: { + type: 'descendant', + name: 'goods-action-button', + linked(child) { + this.children.push(child); + }, + unlinked(child) { + this.children = this.children.filter((item) => item !== child); + } + }, + beforeCreate() { + this.children = []; + }, + props: { + safeAreaInsetBottom: { + type: Boolean, + value: true + } + } +}); diff --git a/utils/dist/goods-action/index.json b/utils/dist/goods-action/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/goods-action/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/goods-action/index.wxml b/utils/dist/goods-action/index.wxml new file mode 100644 index 0000000..569450c --- /dev/null +++ b/utils/dist/goods-action/index.wxml @@ -0,0 +1,5 @@ + + + + + diff --git a/utils/dist/goods-action/index.wxss b/utils/dist/goods-action/index.wxss new file mode 100644 index 0000000..22b779e --- /dev/null +++ b/utils/dist/goods-action/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-goods-action{position:fixed;right:0;bottom:0;left:0;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;background-color:#fff;background-color:var(--goods-action-background-color,#fff)}.van-goods-action--safe{padding-bottom:env(safe-area-inset-bottom)} \ No newline at end of file diff --git a/utils/dist/grid-item/index.d.ts b/utils/dist/grid-item/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/grid-item/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/grid-item/index.js b/utils/dist/grid-item/index.js new file mode 100644 index 0000000..756996c --- /dev/null +++ b/utils/dist/grid-item/index.js @@ -0,0 +1,68 @@ +import { link } from '../mixins/link'; +import { VantComponent } from '../common/component'; +import { addUnit } from '../common/utils'; +VantComponent({ + relation: { + name: 'grid', + type: 'ancestor', + linked(parent) { + this.parent = parent; + } + }, + mixins: [link], + props: { + icon: String, + dot: Boolean, + info: null, + text: String, + useSlot: Boolean + }, + mounted() { + this.updateStyle(); + }, + methods: { + updateStyle() { + if (!this.parent) { + return; + } + const { data, children } = this.parent; + const { columnNum, border, square, gutter, clickable, center } = data; + const width = `${100 / columnNum}%`; + const styleWrapper = []; + styleWrapper.push(`width: ${width}`); + if (square) { + styleWrapper.push(`padding-top: ${width}`); + } + if (gutter) { + const gutterValue = addUnit(gutter); + styleWrapper.push(`padding-right: ${gutterValue}`); + const index = children.indexOf(this); + if (index >= columnNum) { + styleWrapper.push(`margin-top: ${gutterValue}`); + } + } + let contentStyle = ''; + if (square && gutter) { + const gutterValue = addUnit(gutter); + contentStyle = ` + right: ${gutterValue}; + bottom: ${gutterValue}; + height: auto; + `; + } + this.setData({ + style: styleWrapper.join('; '), + contentStyle, + center, + border, + square, + gutter, + clickable + }); + }, + onClick() { + this.$emit('click'); + this.jumpLink(); + } + } +}); diff --git a/utils/dist/grid-item/index.json b/utils/dist/grid-item/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/utils/dist/grid-item/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/utils/dist/grid-item/index.wxml b/utils/dist/grid-item/index.wxml new file mode 100644 index 0000000..2fb189b --- /dev/null +++ b/utils/dist/grid-item/index.wxml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + {{ text }} + + + + + diff --git a/utils/dist/grid-item/index.wxss b/utils/dist/grid-item/index.wxss new file mode 100644 index 0000000..7f2e818 --- /dev/null +++ b/utils/dist/grid-item/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-grid-item{position:relative;float:left;box-sizing:border-box}.van-grid-item--square{height:0}.van-grid-item__content{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;box-sizing:border-box;height:100%;padding:16px 8px;padding:var(--grid-item-content-padding,16px 8px);background-color:#fff;background-color:var(--grid-item-content-background-color,#fff)}.van-grid-item__content:after{z-index:1;border-width:0 1px 1px 0;border-bottom-width:var(--border-width-base,1px);border-right-width:var(--border-width-base,1px);border-top-width:0}.van-grid-item__content--surround:after{border-width:1px;border-width:var(--border-width-base,1px)}.van-grid-item__content--center{-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-grid-item__content--square{position:absolute;top:0;right:0;left:0}.van-grid-item__content--clickable:active{background-color:#f2f3f5;background-color:var(--grid-item-content-active-color,#f2f3f5)}.van-grid-item__icon{font-size:26px;font-size:var(--grid-item-icon-size,26px)}.van-grid-item__text{word-wrap:break-word;color:#646566;color:var(--grid-item-text-color,#646566);font-size:12px;font-size:var(--grid-item-text-font-size,12px)} \ No newline at end of file diff --git a/utils/dist/grid/index.d.ts b/utils/dist/grid/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/grid/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/grid/index.js b/utils/dist/grid/index.js new file mode 100644 index 0000000..97f3eb0 --- /dev/null +++ b/utils/dist/grid/index.js @@ -0,0 +1,62 @@ +import { VantComponent } from '../common/component'; +import { addUnit } from '../common/utils'; +VantComponent({ + relation: { + name: 'grid-item', + type: 'descendant', + linked(child) { + this.children.push(child); + }, + unlinked(child) { + this.children = this.children.filter((item) => item !== child); + } + }, + props: { + square: { + type: Boolean, + observer: 'updateChildren' + }, + gutter: { + type: [Number, String], + value: 0, + observer: 'updateChildren' + }, + clickable: { + type: Boolean, + observer: 'updateChildren' + }, + columnNum: { + type: Number, + value: 4, + observer: 'updateChildren' + }, + center: { + type: Boolean, + value: true, + observer: 'updateChildren' + }, + border: { + type: Boolean, + value: true, + observer: 'updateChildren' + } + }, + beforeCreate() { + this.children = []; + }, + created() { + const { gutter } = this.data; + if (gutter) { + this.setData({ + style: `padding-left: ${addUnit(gutter)}` + }); + } + }, + methods: { + updateChildren() { + this.children.forEach((child) => { + child.updateStyle(); + }); + } + } +}); diff --git a/utils/dist/grid/index.json b/utils/dist/grid/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/grid/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/grid/index.wxml b/utils/dist/grid/index.wxml new file mode 100644 index 0000000..fc76cc3 --- /dev/null +++ b/utils/dist/grid/index.wxml @@ -0,0 +1,3 @@ + + + diff --git a/utils/dist/grid/index.wxss b/utils/dist/grid/index.wxss new file mode 100644 index 0000000..327fc5e --- /dev/null +++ b/utils/dist/grid/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-grid{position:relative;box-sizing:border-box;overflow:hidden} \ No newline at end of file diff --git a/utils/dist/icon/index.d.ts b/utils/dist/icon/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/icon/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/icon/index.js b/utils/dist/icon/index.js new file mode 100644 index 0000000..8d83ff1 --- /dev/null +++ b/utils/dist/icon/index.js @@ -0,0 +1,39 @@ +import { VantComponent } from '../common/component'; +import { addUnit } from '../common/utils'; +VantComponent({ + props: { + dot: Boolean, + info: null, + size: { + type: null, + observer: 'setSizeWithUnit' + }, + color: String, + customStyle: String, + classPrefix: { + type: String, + value: 'van-icon' + }, + name: { + type: String, + observer(val) { + this.setData({ + isImageName: val.indexOf('/') !== -1 + }); + } + } + }, + data: { + sizeWithUnit: null, + }, + methods: { + onClick() { + this.$emit('click'); + }, + setSizeWithUnit(size) { + this.setData({ + sizeWithUnit: addUnit(size) + }); + } + } +}); diff --git a/utils/dist/icon/index.json b/utils/dist/icon/index.json new file mode 100644 index 0000000..bf0ebe0 --- /dev/null +++ b/utils/dist/icon/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-info": "../info/index" + } +} diff --git a/utils/dist/icon/index.wxml b/utils/dist/icon/index.wxml new file mode 100644 index 0000000..c568b58 --- /dev/null +++ b/utils/dist/icon/index.wxml @@ -0,0 +1,18 @@ + + + + diff --git a/utils/dist/icon/index.wxss b/utils/dist/icon/index.wxss new file mode 100644 index 0000000..8fa5efc --- /dev/null +++ b/utils/dist/icon/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';@font-face{font-weight:400;font-family:vant-icon;font-style:normal;font-display:auto;src:url(https://img.yzcdn.cn/vant/vant-icon-0bc654.woff2) format("woff2"),url(https://img.yzcdn.cn/vant/vant-icon-0bc654.woff) format("woff"),url(https://img.yzcdn.cn/vant/vant-icon-0bc654.ttf) format("truetype")}.van-icon{position:relative;font:normal normal normal 14px/1 vant-icon;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased}.van-icon,.van-icon:before{display:inline-block}.van-icon-add-o:before{content:"\F000"}.van-icon-add-square:before{content:"\F001"}.van-icon-add:before{content:"\F002"}.van-icon-after-sale:before{content:"\F003"}.van-icon-aim:before{content:"\F004"}.van-icon-alipay:before{content:"\F005"}.van-icon-apps-o:before{content:"\F006"}.van-icon-arrow-down:before{content:"\F007"}.van-icon-arrow-left:before{content:"\F008"}.van-icon-arrow-up:before{content:"\F009"}.van-icon-arrow:before{content:"\F00A"}.van-icon-ascending:before{content:"\F00B"}.van-icon-audio:before{content:"\F00C"}.van-icon-award-o:before{content:"\F00D"}.van-icon-award:before{content:"\F00E"}.van-icon-bag-o:before{content:"\F00F"}.van-icon-bag:before{content:"\F010"}.van-icon-balance-list-o:before{content:"\F011"}.van-icon-balance-list:before{content:"\F012"}.van-icon-balance-o:before{content:"\F013"}.van-icon-balance-pay:before{content:"\F014"}.van-icon-bar-chart-o:before{content:"\F015"}.van-icon-bars:before{content:"\F016"}.van-icon-bell:before{content:"\F017"}.van-icon-bill-o:before{content:"\F018"}.van-icon-bill:before{content:"\F019"}.van-icon-birthday-cake-o:before{content:"\F01A"}.van-icon-bookmark-o:before{content:"\F01B"}.van-icon-bookmark:before{content:"\F01C"}.van-icon-browsing-history-o:before{content:"\F01D"}.van-icon-browsing-history:before{content:"\F01E"}.van-icon-brush-o:before{content:"\F01F"}.van-icon-bulb-o:before{content:"\F020"}.van-icon-bullhorn-o:before{content:"\F021"}.van-icon-calender-o:before{content:"\F022"}.van-icon-card:before{content:"\F023"}.van-icon-cart-circle-o:before{content:"\F024"}.van-icon-cart-circle:before{content:"\F025"}.van-icon-cart-o:before{content:"\F026"}.van-icon-cart:before{content:"\F027"}.van-icon-cash-back-record:before{content:"\F028"}.van-icon-cash-on-deliver:before{content:"\F029"}.van-icon-cashier-o:before{content:"\F02A"}.van-icon-certificate:before{content:"\F02B"}.van-icon-chart-trending-o:before{content:"\F02C"}.van-icon-chat-o:before{content:"\F02D"}.van-icon-chat:before{content:"\F02E"}.van-icon-checked:before{content:"\F02F"}.van-icon-circle:before{content:"\F030"}.van-icon-clear:before{content:"\F031"}.van-icon-clock-o:before{content:"\F032"}.van-icon-clock:before{content:"\F033"}.van-icon-close:before{content:"\F034"}.van-icon-closed-eye:before{content:"\F035"}.van-icon-cluster-o:before{content:"\F036"}.van-icon-cluster:before{content:"\F037"}.van-icon-column:before{content:"\F038"}.van-icon-comment-circle-o:before{content:"\F039"}.van-icon-comment-circle:before{content:"\F03A"}.van-icon-comment-o:before{content:"\F03B"}.van-icon-comment:before{content:"\F03C"}.van-icon-completed:before{content:"\F03D"}.van-icon-contact:before{content:"\F03E"}.van-icon-coupon-o:before{content:"\F03F"}.van-icon-coupon:before{content:"\F040"}.van-icon-credit-pay:before{content:"\F041"}.van-icon-cross:before{content:"\F042"}.van-icon-debit-pay:before{content:"\F043"}.van-icon-delete:before{content:"\F044"}.van-icon-descending:before{content:"\F045"}.van-icon-description:before{content:"\F046"}.van-icon-desktop-o:before{content:"\F047"}.van-icon-diamond-o:before{content:"\F048"}.van-icon-diamond:before{content:"\F049"}.van-icon-discount:before{content:"\F04A"}.van-icon-down:before{content:"\F04B"}.van-icon-ecard-pay:before{content:"\F04C"}.van-icon-edit:before{content:"\F04D"}.van-icon-ellipsis:before{content:"\F04E"}.van-icon-empty:before{content:"\F04F"}.van-icon-envelop-o:before{content:"\F050"}.van-icon-exchange:before{content:"\F051"}.van-icon-expand-o:before{content:"\F052"}.van-icon-expand:before{content:"\F053"}.van-icon-eye-o:before{content:"\F054"}.van-icon-eye:before{content:"\F055"}.van-icon-fail:before{content:"\F056"}.van-icon-failure:before{content:"\F057"}.van-icon-filter-o:before{content:"\F058"}.van-icon-fire-o:before{content:"\F059"}.van-icon-fire:before{content:"\F05A"}.van-icon-flag-o:before{content:"\F05B"}.van-icon-flower-o:before{content:"\F05C"}.van-icon-free-postage:before{content:"\F05D"}.van-icon-friends-o:before{content:"\F05E"}.van-icon-friends:before{content:"\F05F"}.van-icon-gem-o:before{content:"\F060"}.van-icon-gem:before{content:"\F061"}.van-icon-gift-card-o:before{content:"\F062"}.van-icon-gift-card:before{content:"\F063"}.van-icon-gift-o:before{content:"\F064"}.van-icon-gift:before{content:"\F065"}.van-icon-gold-coin-o:before{content:"\F066"}.van-icon-gold-coin:before{content:"\F067"}.van-icon-good-job-o:before{content:"\F068"}.van-icon-good-job:before{content:"\F069"}.van-icon-goods-collect-o:before{content:"\F06A"}.van-icon-goods-collect:before{content:"\F06B"}.van-icon-graphic:before{content:"\F06C"}.van-icon-home-o:before{content:"\F06D"}.van-icon-hot-o:before{content:"\F06E"}.van-icon-hot-sale-o:before{content:"\F06F"}.van-icon-hot-sale:before{content:"\F070"}.van-icon-hot:before{content:"\F071"}.van-icon-hotel-o:before{content:"\F072"}.van-icon-idcard:before{content:"\F073"}.van-icon-info-o:before{content:"\F074"}.van-icon-info:before{content:"\F075"}.van-icon-invition:before{content:"\F076"}.van-icon-label-o:before{content:"\F077"}.van-icon-label:before{content:"\F078"}.van-icon-like-o:before{content:"\F079"}.van-icon-like:before{content:"\F07A"}.van-icon-live:before{content:"\F07B"}.van-icon-location-o:before{content:"\F07C"}.van-icon-location:before{content:"\F07D"}.van-icon-lock:before{content:"\F07E"}.van-icon-logistics:before{content:"\F07F"}.van-icon-manager-o:before{content:"\F080"}.van-icon-manager:before{content:"\F081"}.van-icon-map-marked:before{content:"\F082"}.van-icon-medel-o:before{content:"\F083"}.van-icon-medel:before{content:"\F084"}.van-icon-more-o:before{content:"\F085"}.van-icon-more:before{content:"\F086"}.van-icon-music-o:before{content:"\F087"}.van-icon-music:before{content:"\F088"}.van-icon-new-arrival-o:before{content:"\F089"}.van-icon-new-arrival:before{content:"\F08A"}.van-icon-new-o:before{content:"\F08B"}.van-icon-new:before{content:"\F08C"}.van-icon-newspaper-o:before{content:"\F08D"}.van-icon-notes-o:before{content:"\F08E"}.van-icon-orders-o:before{content:"\F08F"}.van-icon-other-pay:before{content:"\F090"}.van-icon-paid:before{content:"\F091"}.van-icon-passed:before{content:"\F092"}.van-icon-pause-circle-o:before{content:"\F093"}.van-icon-pause-circle:before{content:"\F094"}.van-icon-pause:before{content:"\F095"}.van-icon-peer-pay:before{content:"\F096"}.van-icon-pending-payment:before{content:"\F097"}.van-icon-phone-circle-o:before{content:"\F098"}.van-icon-phone-circle:before{content:"\F099"}.van-icon-phone-o:before{content:"\F09A"}.van-icon-phone:before{content:"\F09B"}.van-icon-photo-o:before{content:"\F09C"}.van-icon-photo:before{content:"\F09D"}.van-icon-photograph:before{content:"\F09E"}.van-icon-play-circle-o:before{content:"\F09F"}.van-icon-play-circle:before{content:"\F0A0"}.van-icon-play:before{content:"\F0A1"}.van-icon-plus:before{content:"\F0A2"}.van-icon-point-gift-o:before{content:"\F0A3"}.van-icon-point-gift:before{content:"\F0A4"}.van-icon-points:before{content:"\F0A5"}.van-icon-printer:before{content:"\F0A6"}.van-icon-qr-invalid:before{content:"\F0A7"}.van-icon-qr:before{content:"\F0A8"}.van-icon-question-o:before{content:"\F0A9"}.van-icon-question:before{content:"\F0AA"}.van-icon-records:before{content:"\F0AB"}.van-icon-refund-o:before{content:"\F0AC"}.van-icon-replay:before{content:"\F0AD"}.van-icon-scan:before{content:"\F0AE"}.van-icon-search:before{content:"\F0AF"}.van-icon-send-gift-o:before{content:"\F0B0"}.van-icon-send-gift:before{content:"\F0B1"}.van-icon-service-o:before{content:"\F0B2"}.van-icon-service:before{content:"\F0B3"}.van-icon-setting-o:before{content:"\F0B4"}.van-icon-setting:before{content:"\F0B5"}.van-icon-share:before{content:"\F0B6"}.van-icon-shop-collect-o:before{content:"\F0B7"}.van-icon-shop-collect:before{content:"\F0B8"}.van-icon-shop-o:before{content:"\F0B9"}.van-icon-shop:before{content:"\F0BA"}.van-icon-shopping-cart-o:before{content:"\F0BB"}.van-icon-shopping-cart:before{content:"\F0BC"}.van-icon-shrink:before{content:"\F0BD"}.van-icon-sign:before{content:"\F0BE"}.van-icon-smile-comment-o:before{content:"\F0BF"}.van-icon-smile-comment:before{content:"\F0C0"}.van-icon-smile-o:before{content:"\F0C1"}.van-icon-smile:before{content:"\F0C2"}.van-icon-star-o:before{content:"\F0C3"}.van-icon-star:before{content:"\F0C4"}.van-icon-stop-circle-o:before{content:"\F0C5"}.van-icon-stop-circle:before{content:"\F0C6"}.van-icon-stop:before{content:"\F0C7"}.van-icon-success:before{content:"\F0C8"}.van-icon-thumb-circle-o:before{content:"\F0C9"}.van-icon-thumb-circle:before{content:"\F0CA"}.van-icon-todo-list-o:before{content:"\F0CB"}.van-icon-todo-list:before{content:"\F0CC"}.van-icon-tosend:before{content:"\F0CD"}.van-icon-tv-o:before{content:"\F0CE"}.van-icon-umbrella-circle:before{content:"\F0CF"}.van-icon-underway-o:before{content:"\F0D0"}.van-icon-underway:before{content:"\F0D1"}.van-icon-upgrade:before{content:"\F0D2"}.van-icon-user-circle-o:before{content:"\F0D3"}.van-icon-user-o:before{content:"\F0D4"}.van-icon-video-o:before{content:"\F0D5"}.van-icon-video:before{content:"\F0D6"}.van-icon-vip-card-o:before{content:"\F0D7"}.van-icon-vip-card:before{content:"\F0D8"}.van-icon-volume-o:before{content:"\F0D9"}.van-icon-volume:before{content:"\F0DA"}.van-icon-wap-home-o:before{content:"\F0DB"}.van-icon-wap-home:before{content:"\F0DC"}.van-icon-wap-nav:before{content:"\F0DD"}.van-icon-warn-o:before{content:"\F0DE"}.van-icon-warning-o:before{content:"\F0DF"}.van-icon-warning:before{content:"\F0E0"}.van-icon-weapp-nav:before{content:"\F0E1"}.van-icon-wechat:before{content:"\F0E2"}.van-icon-youzan-shield:before{content:"\F0E3"}:host{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-icon--image{width:1em;height:1em}.van-icon__image{width:100%;height:100%}.van-icon__info{z-index:1} \ No newline at end of file diff --git a/utils/dist/image/index.d.ts b/utils/dist/image/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/image/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/image/index.js b/utils/dist/image/index.js new file mode 100644 index 0000000..95650f7 --- /dev/null +++ b/utils/dist/image/index.js @@ -0,0 +1,98 @@ +import { addUnit, isDef } from '../common/utils'; +import { VantComponent } from '../common/component'; +import { button } from '../mixins/button'; +import { openType } from '../mixins/open-type'; +const FIT_MODE_MAP = { + none: 'center', + fill: 'scaleToFill', + cover: 'aspectFill', + contain: 'aspectFit' +}; +VantComponent({ + mixins: [button, openType], + classes: ['custom-class', 'loading-class', 'error-class', 'image-class'], + props: { + src: String, + round: Boolean, + width: { + type: null, + observer: 'setStyle' + }, + height: { + type: null, + observer: 'setStyle' + }, + radius: null, + lazyLoad: Boolean, + useErrorSlot: Boolean, + useLoadingSlot: Boolean, + showMenuByLongpress: Boolean, + fit: { + type: String, + value: 'fill', + observer: 'setMode' + }, + showError: { + type: Boolean, + value: true + }, + showLoading: { + type: Boolean, + value: true + } + }, + data: { + error: false, + loading: true + }, + watch: { + src() { + this.setData({ + error: false, + loading: true + }); + } + }, + mounted() { + this.setMode(); + this.setStyle(); + }, + methods: { + setMode() { + this.setData({ + mode: FIT_MODE_MAP[this.data.fit], + }); + }, + setStyle() { + const { width, height, radius } = this.data; + let style = ''; + if (isDef(width)) { + style += `width: ${addUnit(width)};`; + } + if (isDef(height)) { + style += `height: ${addUnit(height)};`; + } + if (isDef(radius)) { + style += 'overflow: hidden;'; + style += `border-radius: ${addUnit(radius)};`; + } + this.setData({ style }); + }, + onLoad(event) { + this.setData({ + loading: false + }); + this.$emit('load', event.detail); + }, + onError(event) { + this.setData({ + loading: false, + error: true + }); + this.$emit('error', event.detail); + }, + onClick(event) { + this.$emit('click', event.detail); + } + } +}); diff --git a/utils/dist/image/index.json b/utils/dist/image/index.json new file mode 100644 index 0000000..e00a588 --- /dev/null +++ b/utils/dist/image/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-loading": "../loading/index" + } +} diff --git a/utils/dist/image/index.wxml b/utils/dist/image/index.wxml new file mode 100644 index 0000000..4724ca2 --- /dev/null +++ b/utils/dist/image/index.wxml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/utils/dist/image/index.wxss b/utils/dist/image/index.wxss new file mode 100644 index 0000000..e5f1637 --- /dev/null +++ b/utils/dist/image/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-image{position:relative;display:inline-block}.van-image--round{overflow:hidden;border-radius:50%}.van-image--round .van-image__img{border-radius:inherit}.van-image__error,.van-image__img,.van-image__loading{display:block;width:100%;height:100%}.van-image__error,.van-image__loading{position:absolute;top:0;left:0;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;color:#969799;color:var(--image-placeholder-text-color,#969799);font-size:14px;font-size:var(--image-placeholder-font-size,14px);background-color:#f7f8fa;background-color:var(--image-placeholder-background-color,#f7f8fa)} \ No newline at end of file diff --git a/utils/dist/index-anchor/index.d.ts b/utils/dist/index-anchor/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/index-anchor/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/index-anchor/index.js b/utils/dist/index-anchor/index.js new file mode 100644 index 0000000..caaf191 --- /dev/null +++ b/utils/dist/index-anchor/index.js @@ -0,0 +1,22 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + relation: { + name: 'index-bar', + type: 'ancestor', + linked(target) { + this.parent = target; + }, + unlinked() { + this.parent = null; + } + }, + props: { + useSlot: Boolean, + index: null + }, + data: { + active: false, + wrapperStyle: '', + anchorStyle: '' + } +}); diff --git a/utils/dist/index-anchor/index.json b/utils/dist/index-anchor/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/index-anchor/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/index-anchor/index.wxml b/utils/dist/index-anchor/index.wxml new file mode 100644 index 0000000..49affa7 --- /dev/null +++ b/utils/dist/index-anchor/index.wxml @@ -0,0 +1,14 @@ + + + + + {{ index }} + + + diff --git a/utils/dist/index-anchor/index.wxss b/utils/dist/index-anchor/index.wxss new file mode 100644 index 0000000..b8c3c0a --- /dev/null +++ b/utils/dist/index-anchor/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-index-anchor{padding:0 16px;padding:var(--index-anchor-padding,0 16px);color:#323233;color:var(--index-anchor-text-color,#323233);font-weight:500;font-weight:var(--index-anchor-font-weight,500);font-size:14px;font-size:var(--index-anchor-font-size,14px);line-height:32px;line-height:var(--index-anchor-line-height,32px);background-color:initial;background-color:var(--index-anchor-background-color,transparent)}.van-index-anchor--active{right:0;left:0;color:#07c160;color:var(--index-anchor-active-text-color,#07c160);background-color:#fff;background-color:var(--index-anchor-active-background-color,#fff)} \ No newline at end of file diff --git a/utils/dist/index-bar/index.d.ts b/utils/dist/index-bar/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/index-bar/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/index-bar/index.js b/utils/dist/index-bar/index.js new file mode 100644 index 0000000..ec8e8e7 --- /dev/null +++ b/utils/dist/index-bar/index.js @@ -0,0 +1,240 @@ +import { VantComponent } from '../common/component'; +import { GREEN } from '../common/color'; +const indexList = () => { + const indexList = []; + const charCodeOfA = 'A'.charCodeAt(0); + for (let i = 0; i < 26; i++) { + indexList.push(String.fromCharCode(charCodeOfA + i)); + } + return indexList; +}; +VantComponent({ + relation: { + name: 'index-anchor', + type: 'descendant', + linked() { + this.updateData(); + }, + linkChanged() { + this.updateData(); + }, + unlinked() { + this.updateData(); + } + }, + props: { + sticky: { + type: Boolean, + value: true + }, + zIndex: { + type: Number, + value: 1 + }, + highlightColor: { + type: String, + value: GREEN + }, + scrollTop: { + type: Number, + value: 0, + observer: 'onScroll' + }, + stickyOffsetTop: { + type: Number, + value: 0 + }, + indexList: { + type: Array, + value: indexList() + } + }, + data: { + activeAnchorIndex: null, + showSidebar: false + }, + methods: { + updateData() { + this.timer && clearTimeout(this.timer); + this.timer = setTimeout(() => { + this.children = this.getRelationNodes('../index-anchor/index'); + this.setData({ + showSidebar: !!this.children.length + }); + this.setRect().then(() => { + this.onScroll(); + }); + }, 0); + }, + setRect() { + return Promise.all([ + this.setAnchorsRect(), + this.setListRect(), + this.setSiderbarRect() + ]); + }, + setAnchorsRect() { + return Promise.all(this.children.map(anchor => (anchor.getRect('.van-index-anchor-wrapper').then((rect) => { + Object.assign(anchor, { + height: rect.height, + top: rect.top + this.data.scrollTop + }); + })))); + }, + setListRect() { + return this.getRect('.van-index-bar').then((rect) => { + Object.assign(this, { + height: rect.height, + top: rect.top + this.data.scrollTop + }); + }); + }, + setSiderbarRect() { + return this.getRect('.van-index-bar__sidebar').then(res => { + this.sidebar = { + height: res.height, + top: res.top + }; + }); + }, + setDiffData({ target, data }) { + const diffData = {}; + Object.keys(data).forEach(key => { + if (target.data[key] !== data[key]) { + diffData[key] = data[key]; + } + }); + if (Object.keys(diffData).length) { + target.setData(diffData); + } + }, + getAnchorRect(anchor) { + return anchor.getRect('.van-index-anchor-wrapper').then((rect) => ({ + height: rect.height, + top: rect.top + })); + }, + getActiveAnchorIndex() { + const { children } = this; + const { sticky, scrollTop, stickyOffsetTop } = this.data; + for (let i = this.children.length - 1; i >= 0; i--) { + const preAnchorHeight = i > 0 ? children[i - 1].height : 0; + const reachTop = sticky ? preAnchorHeight + stickyOffsetTop : 0; + if (reachTop + scrollTop >= children[i].top) { + return i; + } + } + return -1; + }, + onScroll() { + const { children = [] } = this; + if (!children.length) { + return; + } + const { sticky, stickyOffsetTop, zIndex, highlightColor, scrollTop } = this.data; + const active = this.getActiveAnchorIndex(); + this.setDiffData({ + target: this, + data: { + activeAnchorIndex: active + } + }); + if (sticky) { + let isActiveAnchorSticky = false; + if (active !== -1) { + isActiveAnchorSticky = children[active].top <= stickyOffsetTop + scrollTop; + } + children.forEach((item, index) => { + if (index === active) { + let wrapperStyle = ''; + let anchorStyle = ` + color: ${highlightColor}; + `; + if (isActiveAnchorSticky) { + wrapperStyle = ` + height: ${children[index].height}px; + `; + anchorStyle = ` + position: fixed; + top: ${stickyOffsetTop}px; + z-index: ${zIndex}; + color: ${highlightColor}; + `; + } + this.setDiffData({ + target: item, + data: { + active: true, + anchorStyle, + wrapperStyle + } + }); + } + else if (index === active - 1) { + const currentAnchor = children[index]; + const currentOffsetTop = currentAnchor.top; + const targetOffsetTop = index === children.length - 1 + ? this.top + : children[index + 1].top; + const parentOffsetHeight = targetOffsetTop - currentOffsetTop; + const translateY = parentOffsetHeight - currentAnchor.height; + const anchorStyle = ` + position: relative; + transform: translate3d(0, ${translateY}px, 0); + z-index: ${zIndex}; + color: ${highlightColor}; + `; + this.setDiffData({ + target: item, + data: { + active: true, + anchorStyle + } + }); + } + else { + this.setDiffData({ + target: item, + data: { + active: false, + anchorStyle: '', + wrapperStyle: '', + } + }); + } + }); + } + }, + onClick(event) { + this.scrollToAnchor(event.target.dataset.index); + }, + onTouchMove(event) { + const sidebarLength = this.children.length; + const touch = event.touches[0]; + const itemHeight = this.sidebar.height / sidebarLength; + let index = Math.floor((touch.clientY - this.sidebar.top) / itemHeight); + if (index < 0) { + index = 0; + } + else if (index > sidebarLength - 1) { + index = sidebarLength - 1; + } + this.scrollToAnchor(index); + }, + onTouchStop() { + this.scrollToAnchorIndex = null; + }, + scrollToAnchor(index) { + if (typeof index !== 'number' || this.scrollToAnchorIndex === index) { + return; + } + this.scrollToAnchorIndex = index; + const anchor = this.children.filter(item => item.data.index === this.data.indexList[index])[0]; + this.$emit('select', anchor.data.index); + anchor && wx.pageScrollTo({ + duration: 0, + scrollTop: anchor.top + }); + } + } +}); diff --git a/utils/dist/index-bar/index.json b/utils/dist/index-bar/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/index-bar/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/index-bar/index.wxml b/utils/dist/index-bar/index.wxml new file mode 100644 index 0000000..19a59cf --- /dev/null +++ b/utils/dist/index-bar/index.wxml @@ -0,0 +1,22 @@ + + + + + + {{ item }} + + + diff --git a/utils/dist/index-bar/index.wxss b/utils/dist/index-bar/index.wxss new file mode 100644 index 0000000..dba5dc0 --- /dev/null +++ b/utils/dist/index-bar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-index-bar{position:relative}.van-index-bar__sidebar{position:fixed;top:50%;right:0;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;text-align:center;-webkit-transform:translateY(-50%);transform:translateY(-50%);-webkit-user-select:none;user-select:none}.van-index-bar__index{font-weight:500;padding:0 4px 0 16px;padding:0 var(--padding-base,4px) 0 var(--padding-md,16px);font-size:10px;font-size:var(--index-bar-index-font-size,10px);line-height:14px;line-height:var(--index-bar-index-line-height,14px)} \ No newline at end of file diff --git a/utils/dist/info/index.d.ts b/utils/dist/info/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/info/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/info/index.js b/utils/dist/info/index.js new file mode 100644 index 0000000..8e34c0f --- /dev/null +++ b/utils/dist/info/index.js @@ -0,0 +1,8 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + dot: Boolean, + info: null, + customStyle: String + } +}); diff --git a/utils/dist/info/index.json b/utils/dist/info/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/info/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/info/index.wxml b/utils/dist/info/index.wxml new file mode 100644 index 0000000..3112dfc --- /dev/null +++ b/utils/dist/info/index.wxml @@ -0,0 +1,7 @@ + + +{{ dot ? '' : info }} diff --git a/utils/dist/info/index.wxss b/utils/dist/info/index.wxss new file mode 100644 index 0000000..16e3f32 --- /dev/null +++ b/utils/dist/info/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-info{position:absolute;top:0;right:0;box-sizing:border-box;white-space:nowrap;text-align:center;-webkit-transform:translate(50%,-50%);transform:translate(50%,-50%);-webkit-transform-origin:100%;transform-origin:100%;min-width:16px;min-width:var(--info-size,16px);padding:0 3px;padding:var(--info-padding,0 3px);color:#fff;color:var(--info-color,#fff);font-weight:500;font-weight:var(--info-font-weight,500);font-size:12px;font-size:var(--info-font-size,12px);font-family:PingFang SC,Helvetica Neue,Arial,sans-serif;font-family:var(--info-font-family,PingFang SC,Helvetica Neue,Arial,sans-serif);line-height:14px;line-height:calc(var(--info-size, 16px) - var(--info-border-width, 1px)*2);background-color:#ee0a24;background-color:var(--info-background-color,#ee0a24);border:1px solid #fff;border:var(--info-border-width,1px) solid var(--white,#fff);border-radius:16px;border-radius:var(--info-size,16px)}.van-info--dot{min-width:0;border-radius:100%;width:8px;width:var(--info-dot-size,8px);height:8px;height:var(--info-dot-size,8px);background-color:#ee0a24;background-color:var(--info-dot-color,#ee0a24)} \ No newline at end of file diff --git a/utils/dist/loading/index.d.ts b/utils/dist/loading/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/loading/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/loading/index.js b/utils/dist/loading/index.js new file mode 100644 index 0000000..af510c8 --- /dev/null +++ b/utils/dist/loading/index.js @@ -0,0 +1,32 @@ +import { VantComponent } from '../common/component'; +import { addUnit } from '../common/utils'; +VantComponent({ + props: { + color: String, + vertical: Boolean, + type: { + type: String, + value: 'circular' + }, + size: { + type: String, + observer: 'setSizeWithUnit' + }, + textSize: { + type: String, + observer: 'setTextSizeWithUnit' + } + }, + methods: { + setSizeWithUnit(size) { + this.setData({ + sizeWithUnit: addUnit(size) + }); + }, + setTextSizeWithUnit(size) { + this.set({ + textSizeWithUnit: addUnit(size) + }); + } + } +}); diff --git a/utils/dist/loading/index.json b/utils/dist/loading/index.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/utils/dist/loading/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/utils/dist/loading/index.wxml b/utils/dist/loading/index.wxml new file mode 100644 index 0000000..5229d04 --- /dev/null +++ b/utils/dist/loading/index.wxml @@ -0,0 +1,16 @@ + + + + + + + + diff --git a/utils/dist/loading/index.wxss b/utils/dist/loading/index.wxss new file mode 100644 index 0000000..f28a6b4 --- /dev/null +++ b/utils/dist/loading/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';:host{font-size:0;line-height:1}.van-loading{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;color:#c8c9cc;color:var(--loading-spinner-color,#c8c9cc)}.van-loading__spinner{position:relative;box-sizing:border-box;width:30px;width:var(--loading-spinner-size,30px);max-width:100%;max-height:100%;height:30px;height:var(--loading-spinner-size,30px);-webkit-animation:van-rotate .8s linear infinite;animation:van-rotate .8s linear infinite;-webkit-animation:van-rotate var(--loading-spinner-animation-duration,.8s) linear infinite;animation:van-rotate var(--loading-spinner-animation-duration,.8s) linear infinite}.van-loading__spinner--spinner{-webkit-animation-timing-function:steps(12);animation-timing-function:steps(12)}.van-loading__spinner--circular{border:1px solid transparent;border-top-color:initial;border-radius:100%}.van-loading__text{margin-left:8px;margin-left:var(--padding-xs,8px);color:#969799;color:var(--loading-text-color,#969799);font-size:14px;font-size:var(--loading-text-font-size,14px);line-height:20px;line-height:var(--loading-text-line-height,20px)}.van-loading__text:empty{display:none}.van-loading--vertical{-webkit-flex-direction:column;flex-direction:column}.van-loading--vertical .van-loading__text{margin:8px 0 0;margin:var(--padding-xs,8px) 0 0}.van-loading__dot{position:absolute;top:0;left:0;width:100%;height:100%}.van-loading__dot:before{display:block;width:2px;height:25%;margin:0 auto;background-color:currentColor;border-radius:40%;content:" "}.van-loading__dot:first-of-type{-webkit-transform:rotate(30deg);transform:rotate(30deg);opacity:1}.van-loading__dot:nth-of-type(2){-webkit-transform:rotate(60deg);transform:rotate(60deg);opacity:.9375}.van-loading__dot:nth-of-type(3){-webkit-transform:rotate(90deg);transform:rotate(90deg);opacity:.875}.van-loading__dot:nth-of-type(4){-webkit-transform:rotate(120deg);transform:rotate(120deg);opacity:.8125}.van-loading__dot:nth-of-type(5){-webkit-transform:rotate(150deg);transform:rotate(150deg);opacity:.75}.van-loading__dot:nth-of-type(6){-webkit-transform:rotate(180deg);transform:rotate(180deg);opacity:.6875}.van-loading__dot:nth-of-type(7){-webkit-transform:rotate(210deg);transform:rotate(210deg);opacity:.625}.van-loading__dot:nth-of-type(8){-webkit-transform:rotate(240deg);transform:rotate(240deg);opacity:.5625}.van-loading__dot:nth-of-type(9){-webkit-transform:rotate(270deg);transform:rotate(270deg);opacity:.5}.van-loading__dot:nth-of-type(10){-webkit-transform:rotate(300deg);transform:rotate(300deg);opacity:.4375}.van-loading__dot:nth-of-type(11){-webkit-transform:rotate(330deg);transform:rotate(330deg);opacity:.375}.van-loading__dot:nth-of-type(12){-webkit-transform:rotate(1turn);transform:rotate(1turn);opacity:.3125}@-webkit-keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}} \ No newline at end of file diff --git a/utils/dist/mixins/basic.d.ts b/utils/dist/mixins/basic.d.ts new file mode 100644 index 0000000..b273369 --- /dev/null +++ b/utils/dist/mixins/basic.d.ts @@ -0,0 +1 @@ +export declare const basic: string; diff --git a/utils/dist/mixins/basic.js b/utils/dist/mixins/basic.js new file mode 100644 index 0000000..2fdd634 --- /dev/null +++ b/utils/dist/mixins/basic.js @@ -0,0 +1,22 @@ +export const basic = Behavior({ + methods: { + $emit(...args) { + this.triggerEvent(...args); + }, + getRect(selector, all) { + return new Promise(resolve => { + wx.createSelectorQuery() + .in(this)[all ? 'selectAll' : 'select'](selector) + .boundingClientRect(rect => { + if (all && Array.isArray(rect) && rect.length) { + resolve(rect); + } + if (!all && rect) { + resolve(rect); + } + }) + .exec(); + }); + } + } +}); diff --git a/utils/dist/mixins/button.d.ts b/utils/dist/mixins/button.d.ts new file mode 100644 index 0000000..b51db87 --- /dev/null +++ b/utils/dist/mixins/button.d.ts @@ -0,0 +1 @@ +export declare const button: string; diff --git a/utils/dist/mixins/button.js b/utils/dist/mixins/button.js new file mode 100644 index 0000000..5d3b4dc --- /dev/null +++ b/utils/dist/mixins/button.js @@ -0,0 +1,18 @@ +export const button = Behavior({ + externalClasses: ['hover-class'], + properties: { + id: String, + lang: { + type: String, + value: 'en' + }, + businessId: Number, + sessionFrom: String, + sendMessageTitle: String, + sendMessagePath: String, + sendMessageImg: String, + showMessageCard: Boolean, + appParameter: String, + ariaLabel: String + } +}); diff --git a/utils/dist/mixins/link.d.ts b/utils/dist/mixins/link.d.ts new file mode 100644 index 0000000..d58043b --- /dev/null +++ b/utils/dist/mixins/link.d.ts @@ -0,0 +1 @@ +export declare const link: string; diff --git a/utils/dist/mixins/link.js b/utils/dist/mixins/link.js new file mode 100644 index 0000000..d7aed0c --- /dev/null +++ b/utils/dist/mixins/link.js @@ -0,0 +1,17 @@ +export const link = Behavior({ + properties: { + url: String, + linkType: { + type: String, + value: 'navigateTo' + } + }, + methods: { + jumpLink(urlKey = 'url') { + const url = this.data[urlKey]; + if (url) { + wx[this.data.linkType]({ url }); + } + } + } +}); diff --git a/utils/dist/mixins/observer/behavior.d.ts b/utils/dist/mixins/observer/behavior.d.ts new file mode 100644 index 0000000..3da2a64 --- /dev/null +++ b/utils/dist/mixins/observer/behavior.d.ts @@ -0,0 +1 @@ +export declare const behavior: string; diff --git a/utils/dist/mixins/observer/behavior.js b/utils/dist/mixins/observer/behavior.js new file mode 100644 index 0000000..948f446 --- /dev/null +++ b/utils/dist/mixins/observer/behavior.js @@ -0,0 +1,14 @@ +export const behavior = Behavior({ + methods: { + set(data, callback) { + return new Promise(resolve => { + this.setData(data, () => { + if (callback && typeof callback === 'function') { + callback.call(this); + } + resolve(); + }); + }); + } + } +}); diff --git a/utils/dist/mixins/observer/index.d.ts b/utils/dist/mixins/observer/index.d.ts new file mode 100644 index 0000000..4e54b2e --- /dev/null +++ b/utils/dist/mixins/observer/index.d.ts @@ -0,0 +1 @@ +export declare function observe(vantOptions: any, options: any): void; diff --git a/utils/dist/mixins/observer/index.js b/utils/dist/mixins/observer/index.js new file mode 100644 index 0000000..d6f608d --- /dev/null +++ b/utils/dist/mixins/observer/index.js @@ -0,0 +1,19 @@ +import { behavior } from './behavior'; +export function observe(vantOptions, options) { + const { watch } = vantOptions; + options.behaviors.push(behavior); + if (watch) { + const props = options.properties || {}; + Object.keys(watch).forEach(key => { + if (key in props) { + let prop = props[key]; + if (prop === null || !('type' in prop)) { + prop = { type: prop }; + } + prop.observer = watch[key]; + props[key] = prop; + } + }); + options.properties = props; + } +} diff --git a/utils/dist/mixins/open-type.d.ts b/utils/dist/mixins/open-type.d.ts new file mode 100644 index 0000000..64b023d --- /dev/null +++ b/utils/dist/mixins/open-type.d.ts @@ -0,0 +1 @@ +export declare const openType: string; diff --git a/utils/dist/mixins/open-type.js b/utils/dist/mixins/open-type.js new file mode 100644 index 0000000..514517e --- /dev/null +++ b/utils/dist/mixins/open-type.js @@ -0,0 +1,25 @@ +export const openType = Behavior({ + properties: { + openType: String + }, + methods: { + bindGetUserInfo(event) { + this.$emit('getuserinfo', event.detail); + }, + bindContact(event) { + this.$emit('contact', event.detail); + }, + bindGetPhoneNumber(event) { + this.$emit('getphonenumber', event.detail); + }, + bindError(event) { + this.$emit('error', event.detail); + }, + bindLaunchApp(event) { + this.$emit('launchapp', event.detail); + }, + bindOpenSetting(event) { + this.$emit('opensetting', event.detail); + }, + } +}); diff --git a/utils/dist/mixins/touch.d.ts b/utils/dist/mixins/touch.d.ts new file mode 100644 index 0000000..35ee831 --- /dev/null +++ b/utils/dist/mixins/touch.d.ts @@ -0,0 +1 @@ +export declare const touch: string; diff --git a/utils/dist/mixins/touch.js b/utils/dist/mixins/touch.js new file mode 100644 index 0000000..2a79426 --- /dev/null +++ b/utils/dist/mixins/touch.js @@ -0,0 +1,35 @@ +const MIN_DISTANCE = 10; +function getDirection(x, y) { + if (x > y && x > MIN_DISTANCE) { + return 'horizontal'; + } + if (y > x && y > MIN_DISTANCE) { + return 'vertical'; + } + return ''; +} +export const touch = Behavior({ + methods: { + resetTouchStatus() { + this.direction = ''; + this.deltaX = 0; + this.deltaY = 0; + this.offsetX = 0; + this.offsetY = 0; + }, + touchStart(event) { + this.resetTouchStatus(); + const touch = event.touches[0]; + this.startX = touch.clientX; + this.startY = touch.clientY; + }, + touchMove(event) { + const touch = event.touches[0]; + this.deltaX = touch.clientX - this.startX; + this.deltaY = touch.clientY - this.startY; + this.offsetX = Math.abs(this.deltaX); + this.offsetY = Math.abs(this.deltaY); + this.direction = this.direction || getDirection(this.offsetX, this.offsetY); + } + } +}); diff --git a/utils/dist/mixins/transition.d.ts b/utils/dist/mixins/transition.d.ts new file mode 100644 index 0000000..ee7b6ca --- /dev/null +++ b/utils/dist/mixins/transition.d.ts @@ -0,0 +1 @@ +export declare const transition: (showDefaultValue: boolean) => any; diff --git a/utils/dist/mixins/transition.js b/utils/dist/mixins/transition.js new file mode 100644 index 0000000..a64df6a --- /dev/null +++ b/utils/dist/mixins/transition.js @@ -0,0 +1,120 @@ +import { isObj } from '../common/utils'; +const getClassNames = (name) => ({ + enter: `van-${name}-enter van-${name}-enter-active enter-class enter-active-class`, + 'enter-to': `van-${name}-enter-to van-${name}-enter-active enter-to-class enter-active-class`, + leave: `van-${name}-leave van-${name}-leave-active leave-class leave-active-class`, + 'leave-to': `van-${name}-leave-to van-${name}-leave-active leave-to-class leave-active-class` +}); +const nextTick = () => new Promise(resolve => setTimeout(resolve, 1000 / 30)); +export const transition = function (showDefaultValue) { + return Behavior({ + properties: { + customStyle: String, + // @ts-ignore + show: { + type: Boolean, + value: showDefaultValue, + observer: 'observeShow' + }, + // @ts-ignore + duration: { + type: null, + value: 300, + observer: 'observeDuration' + }, + name: { + type: String, + value: 'fade' + } + }, + data: { + type: '', + inited: false, + display: false + }, + attached() { + if (this.data.show) { + this.enter(); + } + }, + methods: { + observeShow(value) { + value ? this.enter() : this.leave(); + }, + enter() { + const { duration, name } = this.data; + const classNames = getClassNames(name); + const currentDuration = isObj(duration) ? duration.enter : duration; + this.status = 'enter'; + this.$emit('before-enter'); + Promise.resolve() + .then(nextTick) + .then(() => { + this.checkStatus('enter'); + this.$emit('enter'); + this.setData({ + inited: true, + display: true, + classes: classNames.enter, + currentDuration + }); + }) + .then(nextTick) + .then(() => { + this.checkStatus('enter'); + this.transitionEnded = false; + this.setData({ + classes: classNames['enter-to'] + }); + }) + .catch(() => { }); + }, + leave() { + if (!this.data.display) { + return; + } + const { duration, name } = this.data; + const classNames = getClassNames(name); + const currentDuration = isObj(duration) ? duration.leave : duration; + this.status = 'leave'; + this.$emit('before-leave'); + Promise.resolve() + .then(nextTick) + .then(() => { + this.checkStatus('leave'); + this.$emit('leave'); + this.setData({ + classes: classNames.leave, + currentDuration + }); + }) + .then(nextTick) + .then(() => { + this.checkStatus('leave'); + this.transitionEnded = false; + setTimeout(() => this.onTransitionEnd(), currentDuration); + this.setData({ + classes: classNames['leave-to'] + }); + }) + .catch(() => { }); + }, + checkStatus(status) { + if (status !== this.status) { + throw new Error(`incongruent status: ${status}`); + } + }, + onTransitionEnd() { + if (this.transitionEnded) { + return; + } + this.transitionEnded = true; + this.$emit(`after-${this.status}`); + const { show, display } = this.data; + if (!show && display) { + this.setData({ display: false }); + } + } + } + }); +}; diff --git a/utils/dist/nav-bar/index.d.ts b/utils/dist/nav-bar/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/nav-bar/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/nav-bar/index.js b/utils/dist/nav-bar/index.js new file mode 100644 index 0000000..3acf41a --- /dev/null +++ b/utils/dist/nav-bar/index.js @@ -0,0 +1,38 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + classes: ['title-class'], + props: { + title: String, + fixed: Boolean, + leftText: String, + rightText: String, + leftArrow: Boolean, + border: { + type: Boolean, + value: true + }, + zIndex: { + type: Number, + value: 1 + }, + safeAreaInsetTop: { + type: Boolean, + value: true + }, + }, + data: { + statusBarHeight: 0 + }, + created() { + const { statusBarHeight } = wx.getSystemInfoSync(); + this.setData({ statusBarHeight }); + }, + methods: { + onClickLeft() { + this.$emit('click-left'); + }, + onClickRight() { + this.$emit('click-right'); + } + } +}); diff --git a/utils/dist/nav-bar/index.json b/utils/dist/nav-bar/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/utils/dist/nav-bar/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/utils/dist/nav-bar/index.wxml b/utils/dist/nav-bar/index.wxml new file mode 100644 index 0000000..9ed4446 --- /dev/null +++ b/utils/dist/nav-bar/index.wxml @@ -0,0 +1,37 @@ + + + + + + + {{ leftText }} + + + + + {{ title }} + + + + {{ rightText }} + + + diff --git a/utils/dist/nav-bar/index.wxss b/utils/dist/nav-bar/index.wxss new file mode 100644 index 0000000..be4ebb5 --- /dev/null +++ b/utils/dist/nav-bar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-nav-bar{position:relative;text-align:center;-webkit-user-select:none;user-select:none;height:44px;height:var(--nav-bar-height,44px);line-height:44px;line-height:var(--nav-bar-height,44px);background-color:#fff;background-color:var(--nav-bar-background-color,#fff)}.van-nav-bar__text{display:inline-block;vertical-align:middle;margin:0 -16px;margin:0 -var(--padding-md,16px);padding:0 16px;padding:0 var(--padding-md,16px);color:#1989fa;color:var(--nav-bar-text-color,#1989fa)}.van-nav-bar__text--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-nav-bar__arrow{vertical-align:middle;font-size:16px;font-size:var(--nav-bar-arrow-size,16px);color:#1989fa;color:var(--nav-bar-text-color,#1989fa)}.van-nav-bar__arrow+.van-nav-bar__text{margin-left:-20px;padding-left:25px}.van-nav-bar--fixed{position:fixed;top:0;left:0;width:100%}.van-nav-bar__title{max-width:60%;margin:0 auto;color:#323233;color:var(--nav-bar-title-text-color,#323233);font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--nav-bar-title-font-size,16px)}.van-nav-bar__left,.van-nav-bar__right{position:absolute;bottom:0;font-size:14px;font-size:var(--font-size-md,14px)}.van-nav-bar__left{left:16px;left:var(--padding-md,16px)}.van-nav-bar__right{right:16px;right:var(--padding-md,16px)} \ No newline at end of file diff --git a/utils/dist/notice-bar/index.d.ts b/utils/dist/notice-bar/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/notice-bar/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/notice-bar/index.js b/utils/dist/notice-bar/index.js new file mode 100644 index 0000000..faf3567 --- /dev/null +++ b/utils/dist/notice-bar/index.js @@ -0,0 +1,123 @@ +import { VantComponent } from '../common/component'; +const FONT_COLOR = '#ed6a0c'; +const BG_COLOR = '#fffbe8'; +VantComponent({ + props: { + text: { + type: String, + value: '' + }, + mode: { + type: String, + value: '' + }, + url: { + type: String, + value: '' + }, + openType: { + type: String, + value: 'navigate' + }, + delay: { + type: Number, + value: 1 + }, + speed: { + type: Number, + value: 50 + }, + scrollable: { + type: Boolean, + value: true + }, + leftIcon: { + type: String, + value: '' + }, + color: { + type: String, + value: FONT_COLOR + }, + backgroundColor: { + type: String, + value: BG_COLOR + }, + wrapable: Boolean + }, + data: { + show: true + }, + watch: { + text() { + this.setData({}, this.init); + } + }, + created() { + this.resetAnimation = wx.createAnimation({ + duration: 0, + timingFunction: 'linear' + }); + }, + destroyed() { + this.timer && clearTimeout(this.timer); + }, + methods: { + init() { + Promise.all([ + this.getRect('.van-notice-bar__content'), + this.getRect('.van-notice-bar__wrap') + ]).then((rects) => { + const [contentRect, wrapRect] = rects; + if (contentRect == null || + wrapRect == null || + !contentRect.width || + !wrapRect.width) { + return; + } + const { speed, scrollable, delay } = this.data; + if (scrollable && wrapRect.width < contentRect.width) { + const duration = (contentRect.width / speed) * 1000; + this.wrapWidth = wrapRect.width; + this.contentWidth = contentRect.width; + this.duration = duration; + this.animation = wx.createAnimation({ + duration, + timingFunction: 'linear', + delay + }); + this.scroll(); + } + }); + }, + scroll() { + this.timer && clearTimeout(this.timer); + this.timer = null; + this.setData({ + animationData: this.resetAnimation + .translateX(this.wrapWidth) + .step() + .export() + }); + setTimeout(() => { + this.setData({ + animationData: this.animation + .translateX(-this.contentWidth) + .step() + .export() + }); + }, 20); + this.timer = setTimeout(() => { + this.scroll(); + }, this.duration); + }, + onClickIcon() { + this.timer && clearTimeout(this.timer); + this.timer = null; + this.setData({ show: false }); + }, + onClick(event) { + this.$emit('click', event); + } + } +}); diff --git a/utils/dist/notice-bar/index.json b/utils/dist/notice-bar/index.json new file mode 100644 index 0000000..a9ab393 --- /dev/null +++ b/utils/dist/notice-bar/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} \ No newline at end of file diff --git a/utils/dist/notice-bar/index.wxml b/utils/dist/notice-bar/index.wxml new file mode 100644 index 0000000..eb0851c --- /dev/null +++ b/utils/dist/notice-bar/index.wxml @@ -0,0 +1,37 @@ + + + + + + + + + {{ text }} + + + + + + + + + diff --git a/utils/dist/notice-bar/index.wxss b/utils/dist/notice-bar/index.wxss new file mode 100644 index 0000000..6a49858 --- /dev/null +++ b/utils/dist/notice-bar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-notice-bar{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;height:40px;height:var(--notice-bar-height,40px);padding:0 16px;padding:var(--notice-bar-padding,0 16px);font-size:14px;font-size:var(--notice-bar-font-size,14px);color:#ed6a0c;color:var(--notice-bar-text-color,#ed6a0c);line-height:24px;line-height:var(--notice-bar-line-height,24px);background-color:#fffbe8;background-color:var(--notice-bar-background-color,#fffbe8)}.van-notice-bar--withicon{position:relative;padding-right:40px}.van-notice-bar--wrapable{height:auto;padding:8px 16px;padding:var(--notice-bar-wrapable-padding,8px 16px)}.van-notice-bar--wrapable .van-notice-bar__wrap{height:auto}.van-notice-bar--wrapable .van-notice-bar__content{position:relative;white-space:normal}.van-notice-bar__left-icon{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;margin-right:4px;vertical-align:middle}.van-notice-bar__left-icon,.van-notice-bar__right-icon{font-size:16px;font-size:var(--notice-bar-icon-size,16px);min-width:22px;min-width:var(--notice-bar-icon-min-width,22px)}.van-notice-bar__right-icon{position:absolute;top:10px;right:15px}.van-notice-bar__wrap{position:relative;-webkit-flex:1;flex:1;overflow:hidden;height:24px;height:var(--notice-bar-line-height,24px)}.van-notice-bar__content{position:absolute;white-space:nowrap}.van-notice-bar__content.van-ellipsis{max-width:100%} \ No newline at end of file diff --git a/utils/dist/notify/index.d.ts b/utils/dist/notify/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/notify/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/notify/index.js b/utils/dist/notify/index.js new file mode 100644 index 0000000..db9ba76 --- /dev/null +++ b/utils/dist/notify/index.js @@ -0,0 +1,59 @@ +import { VantComponent } from '../common/component'; +import { WHITE } from '../common/color'; +VantComponent({ + props: { + message: String, + background: String, + type: { + type: String, + value: 'danger' + }, + color: { + type: String, + value: WHITE + }, + duration: { + type: Number, + value: 3000 + }, + zIndex: { + type: Number, + value: 110 + }, + safeAreaInsetTop: { + type: Boolean, + value: false + } + }, + created() { + const { statusBarHeight } = wx.getSystemInfoSync(); + this.setData({ statusBarHeight }); + }, + methods: { + show() { + const { duration, onOpened } = this.data; + clearTimeout(this.timer); + this.setData({ + show: true + }, onOpened); + if (duration > 0 && duration !== Infinity) { + this.timer = setTimeout(() => { + this.hide(); + }, duration); + } + }, + hide() { + const { onClose } = this.data; + clearTimeout(this.timer); + this.setData({ + show: false + }, onClose); + }, + onTap(event) { + const { onClick } = this.data; + if (onClick) { + onClick(event.detail); + } + } + } +}); diff --git a/utils/dist/notify/index.json b/utils/dist/notify/index.json new file mode 100644 index 0000000..c14a65f --- /dev/null +++ b/utils/dist/notify/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-transition": "../transition/index" + } +} diff --git a/utils/dist/notify/index.wxml b/utils/dist/notify/index.wxml new file mode 100644 index 0000000..552b8e3 --- /dev/null +++ b/utils/dist/notify/index.wxml @@ -0,0 +1,15 @@ + + + + {{ message }} + + diff --git a/utils/dist/notify/index.wxss b/utils/dist/notify/index.wxss new file mode 100644 index 0000000..3b4aba6 --- /dev/null +++ b/utils/dist/notify/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-notify{text-align:center;word-wrap:break-word;padding:6px 15px;padding:var(--notify-padding,6px 15px);font-size:14px;font-size:var(--notify-font-size,14px);line-height:20px;line-height:var(--notify-line-height,20px)}.van-notify__container{position:fixed;top:0;box-sizing:border-box;width:100%}.van-notify--primary{background-color:#1989fa;background-color:var(--notify-primary-background-color,#1989fa)}.van-notify--success{background-color:#07c160;background-color:var(--notify-success-background-color,#07c160)}.van-notify--danger{background-color:#ee0a24;background-color:var(--notify-danger-background-color,#ee0a24)}.van-notify--warning{background-color:#ff976a;background-color:var(--notify-warning-background-color,#ff976a)} \ No newline at end of file diff --git a/utils/dist/notify/notify.d.ts b/utils/dist/notify/notify.d.ts new file mode 100644 index 0000000..671195a --- /dev/null +++ b/utils/dist/notify/notify.d.ts @@ -0,0 +1,19 @@ +interface NotifyOptions { + type?: 'primary' | 'success' | 'danger' | 'warning'; + color?: string; + zIndex?: number; + message: string; + context?: any; + duration?: number; + selector?: string; + background?: string; + safeAreaInsetTop?: boolean; + onClick?: () => void; + onOpened?: () => void; + onClose?: () => void; +} +declare function Notify(options: NotifyOptions | string): any; +declare namespace Notify { + var clear: (options?: NotifyOptions) => void; +} +export default Notify; diff --git a/utils/dist/notify/notify.js b/utils/dist/notify/notify.js new file mode 100644 index 0000000..140690b --- /dev/null +++ b/utils/dist/notify/notify.js @@ -0,0 +1,41 @@ +import { WHITE } from '../common/color'; +const defaultOptions = { + selector: '#van-notify', + type: 'danger', + message: '', + background: '', + duration: 3000, + zIndex: 110, + color: WHITE, + onClick: () => { }, + onOpened: () => { }, + onClose: () => { } +}; +function parseOptions(message) { + return typeof message === 'string' ? { message } : message; +} +function getContext() { + const pages = getCurrentPages(); + return pages[pages.length - 1]; +} +export default function Notify(options) { + options = Object.assign({}, defaultOptions, parseOptions(options)); + const context = options.context || getContext(); + const notify = context.selectComponent(options.selector); + delete options.context; + delete options.selector; + if (notify) { + notify.set(options); + notify.show(); + return notify; + } + console.warn('未找到 van-notify 节点,请确认 selector 及 context 是否正确'); +} +Notify.clear = function (options) { + options = Object.assign({}, defaultOptions, parseOptions(options)); + const context = options.context || getContext(); + const notify = context.selectComponent(options.selector); + if (notify) { + notify.hide(); + } +}; diff --git a/utils/dist/overlay/index.d.ts b/utils/dist/overlay/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/overlay/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/overlay/index.js b/utils/dist/overlay/index.js new file mode 100644 index 0000000..f579113 --- /dev/null +++ b/utils/dist/overlay/index.js @@ -0,0 +1,22 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + show: Boolean, + customStyle: String, + duration: { + type: null, + value: 300 + }, + zIndex: { + type: Number, + value: 1 + } + }, + methods: { + onClick() { + this.$emit('click'); + }, + // for prevent touchmove + noop() { } + } +}); diff --git a/utils/dist/overlay/index.json b/utils/dist/overlay/index.json new file mode 100644 index 0000000..c14a65f --- /dev/null +++ b/utils/dist/overlay/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-transition": "../transition/index" + } +} diff --git a/utils/dist/overlay/index.wxml b/utils/dist/overlay/index.wxml new file mode 100644 index 0000000..9212348 --- /dev/null +++ b/utils/dist/overlay/index.wxml @@ -0,0 +1,10 @@ + + + diff --git a/utils/dist/overlay/index.wxss b/utils/dist/overlay/index.wxss new file mode 100644 index 0000000..0f9df0e --- /dev/null +++ b/utils/dist/overlay/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-overlay{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.7);background-color:var(--overlay-background-color,rgba(0,0,0,.7))} \ No newline at end of file diff --git a/utils/dist/panel/index.d.ts b/utils/dist/panel/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/panel/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/panel/index.js b/utils/dist/panel/index.js new file mode 100644 index 0000000..e624d5e --- /dev/null +++ b/utils/dist/panel/index.js @@ -0,0 +1,10 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + classes: ['header-class', 'footer-class'], + props: { + desc: String, + title: String, + status: String, + useFooterSlot: Boolean + } +}); diff --git a/utils/dist/panel/index.json b/utils/dist/panel/index.json new file mode 100644 index 0000000..0e5425c --- /dev/null +++ b/utils/dist/panel/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-cell": "../cell/index" + } +} diff --git a/utils/dist/panel/index.wxml b/utils/dist/panel/index.wxml new file mode 100644 index 0000000..3f135d2 --- /dev/null +++ b/utils/dist/panel/index.wxml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/utils/dist/panel/index.wxss b/utils/dist/panel/index.wxss new file mode 100644 index 0000000..ffd9df9 --- /dev/null +++ b/utils/dist/panel/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-panel{background:#fff;background:var(--panel-background-color,#fff)}.van-panel__header-value{color:#ee0a24;color:var(--panel-header-value-color,#ee0a24)}.van-panel__footer{padding:8px 16px;padding:var(--panel-footer-padding,8px 16px)} \ No newline at end of file diff --git a/utils/dist/picker-column/index.d.ts b/utils/dist/picker-column/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/picker-column/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/picker-column/index.js b/utils/dist/picker-column/index.js new file mode 100644 index 0000000..4a78299 --- /dev/null +++ b/utils/dist/picker-column/index.js @@ -0,0 +1,119 @@ +import { VantComponent } from '../common/component'; +import { isObj, range } from '../common/utils'; +const DEFAULT_DURATION = 200; +VantComponent({ + classes: ['active-class'], + props: { + valueKey: String, + className: String, + itemHeight: Number, + visibleItemCount: Number, + initialOptions: { + type: Array, + value: [] + }, + defaultIndex: { + type: Number, + value: 0 + } + }, + data: { + startY: 0, + offset: 0, + duration: 0, + startOffset: 0, + options: [], + currentIndex: 0 + }, + created() { + const { defaultIndex, initialOptions } = this.data; + this.set({ + currentIndex: defaultIndex, + options: initialOptions + }).then(() => { + this.setIndex(defaultIndex); + }); + }, + watch: { + defaultIndex(value) { + this.setIndex(value); + } + }, + methods: { + getCount() { + return this.data.options.length; + }, + onTouchStart(event) { + this.setData({ + startY: event.touches[0].clientY, + startOffset: this.data.offset, + duration: 0 + }); + }, + onTouchMove(event) { + const { data } = this; + const deltaY = event.touches[0].clientY - data.startY; + this.setData({ + offset: range(data.startOffset + deltaY, -(this.getCount() * data.itemHeight), data.itemHeight) + }); + }, + onTouchEnd() { + const { data } = this; + if (data.offset !== data.startOffset) { + this.setData({ duration: DEFAULT_DURATION }); + const index = range(Math.round(-data.offset / data.itemHeight), 0, this.getCount() - 1); + this.setIndex(index, true); + } + }, + onClickItem(event) { + const { index } = event.currentTarget.dataset; + this.setIndex(index, true); + }, + adjustIndex(index) { + const { data } = this; + const count = this.getCount(); + index = range(index, 0, count); + for (let i = index; i < count; i++) { + if (!this.isDisabled(data.options[i])) + return i; + } + for (let i = index - 1; i >= 0; i--) { + if (!this.isDisabled(data.options[i])) + return i; + } + }, + isDisabled(option) { + return isObj(option) && option.disabled; + }, + getOptionText(option) { + const { data } = this; + return isObj(option) && data.valueKey in option + ? option[data.valueKey] + : option; + }, + setIndex(index, userAction) { + const { data } = this; + index = this.adjustIndex(index) || 0; + const offset = -index * data.itemHeight; + if (index !== data.currentIndex) { + return this.set({ offset, currentIndex: index }).then(() => { + userAction && this.$emit('change', index); + }); + } + return this.set({ offset }); + }, + setValue(value) { + const { options } = this.data; + for (let i = 0; i < options.length; i++) { + if (this.getOptionText(options[i]) === value) { + return this.setIndex(i); + } + } + return Promise.resolve(); + }, + getValue() { + const { data } = this; + return data.options[data.currentIndex]; + } + } +}); diff --git a/utils/dist/picker-column/index.json b/utils/dist/picker-column/index.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/utils/dist/picker-column/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/utils/dist/picker-column/index.wxml b/utils/dist/picker-column/index.wxml new file mode 100644 index 0000000..f052ed9 --- /dev/null +++ b/utils/dist/picker-column/index.wxml @@ -0,0 +1,22 @@ + + + + + {{ getOptionText(option, valueKey) }} + + diff --git a/utils/dist/picker-column/index.wxs b/utils/dist/picker-column/index.wxs new file mode 100644 index 0000000..3c8fc68 --- /dev/null +++ b/utils/dist/picker-column/index.wxs @@ -0,0 +1,8 @@ +function isObj(x) { + var type = typeof x; + return x !== null && (type === 'object' || type === 'function'); +} + +module.exports = function (option, valueKey) { + return isObj(option) && option[valueKey] != null ? option[valueKey] : option; +} diff --git a/utils/dist/picker-column/index.wxss b/utils/dist/picker-column/index.wxss new file mode 100644 index 0000000..c5c6910 --- /dev/null +++ b/utils/dist/picker-column/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-picker-column{overflow:hidden;text-align:center;color:#000;color:var(--picker-option-text-color,#000);font-size:16px;font-size:var(--picker-option-font-size,16px)}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{font-weight:500;font-weight:var(--font-weight-bold,500);color:#323233;color:var(--picker-option-selected-text-color,#323233)}.van-picker-column__item--disabled{opacity:.3;opacity:var(--picker-option-disabled-opacity,.3)} \ No newline at end of file diff --git a/utils/dist/picker/index.d.ts b/utils/dist/picker/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/picker/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/picker/index.js b/utils/dist/picker/index.js new file mode 100644 index 0000000..8e78e66 --- /dev/null +++ b/utils/dist/picker/index.js @@ -0,0 +1,135 @@ +import { VantComponent } from '../common/component'; +import { pickerProps } from './shared'; +VantComponent({ + classes: ['active-class', 'toolbar-class', 'column-class'], + props: Object.assign(Object.assign({}, pickerProps), { valueKey: { + type: String, + value: 'text' + }, toolbarPosition: { + type: String, + value: 'top' + }, defaultIndex: { + type: Number, + value: 0 + }, columns: { + type: Array, + value: [], + observer(columns = []) { + this.simple = columns.length && !columns[0].values; + this.children = this.selectAllComponents('.van-picker__column'); + if (Array.isArray(this.children) && this.children.length) { + this.setColumns().catch(() => { }); + } + } + } }), + beforeCreate() { + this.children = []; + }, + methods: { + noop() { }, + setColumns() { + const { data } = this; + const columns = this.simple ? [{ values: data.columns }] : data.columns; + const stack = columns.map((column, index) => this.setColumnValues(index, column.values)); + return Promise.all(stack); + }, + emit(event) { + const { type } = event.currentTarget.dataset; + if (this.simple) { + this.$emit(type, { + value: this.getColumnValue(0), + index: this.getColumnIndex(0) + }); + } + else { + this.$emit(type, { + value: this.getValues(), + index: this.getIndexes() + }); + } + }, + onChange(event) { + if (this.simple) { + this.$emit('change', { + picker: this, + value: this.getColumnValue(0), + index: this.getColumnIndex(0) + }); + } + else { + this.$emit('change', { + picker: this, + value: this.getValues(), + index: event.currentTarget.dataset.index + }); + } + }, + // get column instance by index + getColumn(index) { + return this.children[index]; + }, + // get column value by index + getColumnValue(index) { + const column = this.getColumn(index); + return column && column.getValue(); + }, + // set column value by index + setColumnValue(index, value) { + const column = this.getColumn(index); + if (column == null) { + return Promise.reject(new Error('setColumnValue: 对应列不存在')); + } + return column.setValue(value); + }, + // get column option index by column index + getColumnIndex(columnIndex) { + return (this.getColumn(columnIndex) || {}).data.currentIndex; + }, + // set column option index by column index + setColumnIndex(columnIndex, optionIndex) { + const column = this.getColumn(columnIndex); + if (column == null) { + return Promise.reject(new Error('setColumnIndex: 对应列不存在')); + } + return column.setIndex(optionIndex); + }, + // get options of column by index + getColumnValues(index) { + return (this.children[index] || {}).data.options; + }, + // set options of column by index + setColumnValues(index, options, needReset = true) { + const column = this.children[index]; + if (column == null) { + return Promise.reject(new Error('setColumnValues: 对应列不存在')); + } + const isSame = JSON.stringify(column.data.options) === JSON.stringify(options); + if (isSame) { + return Promise.resolve(); + } + return column.set({ options }).then(() => { + if (needReset) { + column.setIndex(0); + } + }); + }, + // get values of all columns + getValues() { + return this.children.map((child) => child.getValue()); + }, + // set values of all columns + setValues(values) { + const stack = values.map((value, index) => this.setColumnValue(index, value)); + return Promise.all(stack); + }, + // get indexes of all columns + getIndexes() { + return this.children.map((child) => child.data.currentIndex); + }, + // set indexes of all columns + setIndexes(indexes) { + const stack = indexes.map((optionIndex, columnIndex) => this.setColumnIndex(columnIndex, optionIndex)); + return Promise.all(stack); + } + } +}); diff --git a/utils/dist/picker/index.json b/utils/dist/picker/index.json new file mode 100644 index 0000000..2fcec89 --- /dev/null +++ b/utils/dist/picker/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "picker-column": "../picker-column/index", + "loading": "../loading/index" + } +} diff --git a/utils/dist/picker/index.wxml b/utils/dist/picker/index.wxml new file mode 100644 index 0000000..6631a73 --- /dev/null +++ b/utils/dist/picker/index.wxml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + function isSimple(columns) { + return columns.length && !columns[0].values; + } + module.exports = isSimple; + diff --git a/utils/dist/picker/index.wxss b/utils/dist/picker/index.wxss new file mode 100644 index 0000000..f23a940 --- /dev/null +++ b/utils/dist/picker/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-picker{position:relative;overflow:hidden;-webkit-text-size-adjust:100%;-webkit-user-select:none;user-select:none;background-color:#fff;background-color:var(--picker-background-color,#fff)}.van-picker__toolbar{display:-webkit-flex;display:flex;-webkit-justify-content:space-between;justify-content:space-between;height:44px;height:var(--picker-toolbar-height,44px);line-height:44px;line-height:var(--picker-toolbar-height,44px)}.van-picker__cancel,.van-picker__confirm{padding:0 16px;padding:var(--picker-action-padding,0 16px);font-size:14px;font-size:var(--picker-action-font-size,14px);color:#1989fa;color:var(--picker-action-text-color,#1989fa)}.van-picker__cancel--hover,.van-picker__confirm--hover{background-color:#f2f3f5;background-color:var(--picker-action-active-color,#f2f3f5)}.van-picker__title{max-width:50%;text-align:center;font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--picker-option-font-size,16px)}.van-picker__columns{position:relative;display:-webkit-flex;display:flex}.van-picker__column{-webkit-flex:1 1;flex:1 1;width:0}.van-picker__loading{position:absolute;top:0;right:0;bottom:0;left:0;z-index:4;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;background-color:hsla(0,0%,100%,.9);background-color:var(--picker-loading-mask-color,hsla(0,0%,100%,.9))}.van-picker__frame,.van-picker__loading .van-loading{position:absolute;top:50%;left:0;z-index:1;width:100%;-webkit-transform:translateY(-50%);transform:translateY(-50%);pointer-events:none} \ No newline at end of file diff --git a/utils/dist/picker/shared.d.ts b/utils/dist/picker/shared.d.ts new file mode 100644 index 0000000..c548045 --- /dev/null +++ b/utils/dist/picker/shared.d.ts @@ -0,0 +1,21 @@ +export declare const pickerProps: { + title: StringConstructor; + loading: BooleanConstructor; + showToolbar: BooleanConstructor; + cancelButtonText: { + type: StringConstructor; + value: string; + }; + confirmButtonText: { + type: StringConstructor; + value: string; + }; + visibleItemCount: { + type: NumberConstructor; + value: number; + }; + itemHeight: { + type: NumberConstructor; + value: number; + }; +}; diff --git a/utils/dist/picker/shared.js b/utils/dist/picker/shared.js new file mode 100644 index 0000000..cf57d1d --- /dev/null +++ b/utils/dist/picker/shared.js @@ -0,0 +1,21 @@ +export const pickerProps = { + title: String, + loading: Boolean, + showToolbar: Boolean, + cancelButtonText: { + type: String, + value: '取消' + }, + confirmButtonText: { + type: String, + value: '确认' + }, + visibleItemCount: { + type: Number, + value: 5 + }, + itemHeight: { + type: Number, + value: 44 + } +}; diff --git a/utils/dist/popup/index.d.ts b/utils/dist/popup/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/popup/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/popup/index.js b/utils/dist/popup/index.js new file mode 100644 index 0000000..4a2e7af --- /dev/null +++ b/utils/dist/popup/index.js @@ -0,0 +1,80 @@ +import { VantComponent } from '../common/component'; +import { transition } from '../mixins/transition'; +VantComponent({ + classes: [ + 'enter-class', + 'enter-active-class', + 'enter-to-class', + 'leave-class', + 'leave-active-class', + 'leave-to-class' + ], + mixins: [transition(false)], + props: { + round: Boolean, + closeable: Boolean, + customStyle: String, + overlayStyle: String, + transition: { + type: String, + observer: 'observeClass' + }, + zIndex: { + type: Number, + value: 100 + }, + overlay: { + type: Boolean, + value: true + }, + closeIcon: { + type: String, + value: 'cross' + }, + closeIconPosition: { + type: String, + value: 'top-right' + }, + closeOnClickOverlay: { + type: Boolean, + value: true + }, + position: { + type: String, + value: 'center', + observer: 'observeClass' + }, + safeAreaInsetBottom: { + type: Boolean, + value: true + }, + safeAreaInsetTop: { + type: Boolean, + value: false + } + }, + created() { + this.observeClass(); + }, + methods: { + onClickCloseIcon() { + this.$emit('close'); + }, + onClickOverlay() { + this.$emit('click-overlay'); + if (this.data.closeOnClickOverlay) { + this.$emit('close'); + } + }, + observeClass() { + const { transition, position } = this.data; + const updateData = { + name: transition || position + }; + if (transition === 'none') { + updateData.duration = 0; + } + this.setData(updateData); + } + } +}); diff --git a/utils/dist/popup/index.json b/utils/dist/popup/index.json new file mode 100644 index 0000000..88a6eab --- /dev/null +++ b/utils/dist/popup/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-overlay": "../overlay/index" + } +} diff --git a/utils/dist/popup/index.wxml b/utils/dist/popup/index.wxml new file mode 100644 index 0000000..a384686 --- /dev/null +++ b/utils/dist/popup/index.wxml @@ -0,0 +1,24 @@ + + + + + + + diff --git a/utils/dist/popup/index.wxss b/utils/dist/popup/index.wxss new file mode 100644 index 0000000..6e477ac --- /dev/null +++ b/utils/dist/popup/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-popup{position:fixed;box-sizing:border-box;max-height:100%;overflow-y:auto;transition-timing-function:ease;-webkit-animation:ease both;animation:ease both;-webkit-overflow-scrolling:touch;background-color:#fff;background-color:var(--popup-background-color,#fff)}.van-popup--center{top:50%;left:50%;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0)}.van-popup--center.van-popup--round{border-radius:20px;border-radius:var(--popup-round-border-radius,20px)}.van-popup--top{top:0;left:0;width:100%}.van-popup--top.van-popup--round{border-radius:0 0 20px 20px;border-radius:0 0 var(--popup-round-border-radius,20px) var(--popup-round-border-radius,20px)}.van-popup--right{top:50%;right:0;-webkit-transform:translate3d(0,-50%,0);transform:translate3d(0,-50%,0)}.van-popup--right.van-popup--round{border-radius:20px 0 0 20px;border-radius:var(--popup-round-border-radius,20px) 0 0 var(--popup-round-border-radius,20px)}.van-popup--bottom{bottom:0;left:0;width:100%}.van-popup--bottom.van-popup--round{border-radius:20px 20px 0 0;border-radius:var(--popup-round-border-radius,20px) var(--popup-round-border-radius,20px) 0 0}.van-popup--left{top:50%;left:0;-webkit-transform:translate3d(0,-50%,0);transform:translate3d(0,-50%,0)}.van-popup--left.van-popup--round{border-radius:0 20px 20px 0;border-radius:0 var(--popup-round-border-radius,20px) var(--popup-round-border-radius,20px) 0}.van-popup--bottom.van-popup--safe{padding-bottom:env(safe-area-inset-bottom)}.van-popup--safeTop{padding-top:env(safe-area-inset-top)}.van-popup__close-icon{position:absolute;z-index:1;z-index:var(--popup-close-icon-z-index,1);color:#969799;color:var(--popup-close-icon-color,#969799);font-size:18px;font-size:var(--popup-close-icon-size,18px)}.van-popup__close-icon--top-left{top:16px;top:var(--popup-close-icon-margin,16px);left:16px;left:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--top-right{top:16px;top:var(--popup-close-icon-margin,16px);right:16px;right:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--bottom-left{bottom:16px;bottom:var(--popup-close-icon-margin,16px);left:16px;left:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--bottom-right{right:16px;right:var(--popup-close-icon-margin,16px);bottom:16px;bottom:var(--popup-close-icon-margin,16px)}.van-popup__close-icon:active{opacity:.6}.van-scale-enter-active,.van-scale-leave-active{transition-property:opacity,-webkit-transform;transition-property:opacity,transform;transition-property:opacity,transform,-webkit-transform}.van-scale-enter,.van-scale-leave-to{-webkit-transform:translate3d(-50%,-50%,0) scale(.7);transform:translate3d(-50%,-50%,0) scale(.7);opacity:0}.van-fade-enter-active,.van-fade-leave-active{transition-property:opacity}.van-fade-enter,.van-fade-leave-to{opacity:0}.van-center-enter-active,.van-center-leave-active{transition-property:opacity}.van-center-enter,.van-center-leave-to{opacity:0}.van-bottom-enter-active,.van-bottom-leave-active,.van-left-enter-active,.van-left-leave-active,.van-right-enter-active,.van-right-leave-active,.van-top-enter-active,.van-top-leave-active{transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform}.van-bottom-enter,.van-bottom-leave-to{-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0)}.van-top-enter,.van-top-leave-to{-webkit-transform:translate3d(0,-100%,0);transform:translate3d(0,-100%,0)}.van-left-enter,.van-left-leave-to{-webkit-transform:translate3d(-100%,-50%,0);transform:translate3d(-100%,-50%,0)}.van-right-enter,.van-right-leave-to{-webkit-transform:translate3d(100%,-50%,0);transform:translate3d(100%,-50%,0)} \ No newline at end of file diff --git a/utils/dist/progress/index.d.ts b/utils/dist/progress/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/progress/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/progress/index.js b/utils/dist/progress/index.js new file mode 100644 index 0000000..6ca67bd --- /dev/null +++ b/utils/dist/progress/index.js @@ -0,0 +1,38 @@ +import { VantComponent } from '../common/component'; +import { BLUE } from '../common/color'; +import { addUnit } from '../common/utils'; +VantComponent({ + props: { + inactive: Boolean, + percentage: Number, + pivotText: String, + pivotColor: String, + trackColor: String, + showPivot: { + type: Boolean, + value: true + }, + color: { + type: String, + value: BLUE + }, + textColor: { + type: String, + value: '#fff' + }, + strokeWidth: { + type: null, + observer: 'setStrokeWidthUnit' + } + }, + data: { + strokeWidthUnit: '4px' + }, + methods: { + setStrokeWidthUnit(val) { + this.setData({ + strokeWidthUnit: addUnit(val) + }); + } + } +}); diff --git a/utils/dist/progress/index.json b/utils/dist/progress/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/progress/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/progress/index.wxml b/utils/dist/progress/index.wxml new file mode 100644 index 0000000..5d27517 --- /dev/null +++ b/utils/dist/progress/index.wxml @@ -0,0 +1,19 @@ + + + + + + {{ getters.text(pivotText, percentage) }} + + + diff --git a/utils/dist/progress/index.wxs b/utils/dist/progress/index.wxs new file mode 100644 index 0000000..d685345 --- /dev/null +++ b/utils/dist/progress/index.wxs @@ -0,0 +1,5 @@ +module.exports = { + text: function(pivotText, percentage) { + return pivotText || percentage + '%'; + } +}; diff --git a/utils/dist/progress/index.wxss b/utils/dist/progress/index.wxss new file mode 100644 index 0000000..33c62c7 --- /dev/null +++ b/utils/dist/progress/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-progress{position:relative;height:4px;height:var(--progress-height,4px);border-radius:4px;border-radius:var(--progress-height,4px);background:#ebedf0;background:var(--progress-background-color,#ebedf0)}.van-progress__portion{position:absolute;left:0;height:100%;border-radius:inherit;background:#1989fa;background:var(--progress-color,#1989fa)}.van-progress__pivot{position:absolute;top:50%;right:0;box-sizing:border-box;min-width:2em;text-align:center;word-break:keep-all;border-radius:1em;-webkit-transform:translateY(-50%);transform:translateY(-50%);color:#fff;color:var(--progress-pivot-text-color,#fff);padding:0 5px;padding:var(--progress-pivot-padding,0 5px);font-size:10px;font-size:var(--progress-pivot-font-size,10px);line-height:1.6;line-height:var(--progress-pivot-line-height,1.6);background-color:#1989fa;background-color:var(--progress-pivot-background-color,#1989fa)} \ No newline at end of file diff --git a/utils/dist/radio-group/index.d.ts b/utils/dist/radio-group/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/radio-group/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/radio-group/index.js b/utils/dist/radio-group/index.js new file mode 100644 index 0000000..e4c69e3 --- /dev/null +++ b/utils/dist/radio-group/index.js @@ -0,0 +1,38 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + field: true, + relation: { + name: 'radio', + type: 'descendant', + linked(target) { + this.children = this.children || []; + this.children.push(target); + this.updateChild(target); + }, + unlinked(target) { + this.children = this.children.filter((child) => child !== target); + } + }, + props: { + value: { + type: null, + observer: 'updateChildren' + }, + disabled: { + type: Boolean, + observer: 'updateChildren' + } + }, + methods: { + updateChildren() { + (this.children || []).forEach((child) => this.updateChild(child)); + }, + updateChild(child) { + const { value, disabled } = this.data; + child.setData({ + value, + disabled: disabled || child.data.disabled + }); + } + } +}); diff --git a/utils/dist/radio-group/index.json b/utils/dist/radio-group/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/radio-group/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/radio-group/index.wxml b/utils/dist/radio-group/index.wxml new file mode 100644 index 0000000..4fa864c --- /dev/null +++ b/utils/dist/radio-group/index.wxml @@ -0,0 +1 @@ + diff --git a/utils/dist/radio-group/index.wxss b/utils/dist/radio-group/index.wxss new file mode 100644 index 0000000..99694d6 --- /dev/null +++ b/utils/dist/radio-group/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss'; \ No newline at end of file diff --git a/utils/dist/radio/index.d.ts b/utils/dist/radio/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/radio/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/radio/index.js b/utils/dist/radio/index.js new file mode 100644 index 0000000..c3b5165 --- /dev/null +++ b/utils/dist/radio/index.js @@ -0,0 +1,60 @@ +import { VantComponent } from '../common/component'; +import { addUnit } from '../common/utils'; +VantComponent({ + field: true, + relation: { + name: 'radio-group', + type: 'ancestor', + linked(target) { + this.parent = target; + }, + unlinked() { + this.parent = null; + } + }, + classes: ['icon-class', 'label-class'], + props: { + value: null, + disabled: Boolean, + useIconSlot: Boolean, + checkedColor: String, + labelPosition: { + type: String, + value: 'right' + }, + labelDisabled: Boolean, + shape: { + type: String, + value: 'round' + }, + iconSize: { + type: null, + observer: 'setIconSizeUnit' + } + }, + data: { + iconSizeWithUnit: '20px' + }, + methods: { + setIconSizeUnit(val) { + this.setData({ + iconSizeWithUnit: addUnit(val) + }); + }, + emitChange(value) { + const instance = this.parent || this; + instance.$emit('input', value); + instance.$emit('change', value); + }, + onChange(event) { + console.log(event); + this.emitChange(this.data.name); + }, + onClickLabel() { + const { disabled, labelDisabled, name } = this.data; + if (!disabled && !labelDisabled) { + this.emitChange(name); + } + } + } +}); diff --git a/utils/dist/radio/index.json b/utils/dist/radio/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/utils/dist/radio/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/utils/dist/radio/index.wxml b/utils/dist/radio/index.wxml new file mode 100644 index 0000000..3b64f3f --- /dev/null +++ b/utils/dist/radio/index.wxml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + diff --git a/utils/dist/radio/index.wxss b/utils/dist/radio/index.wxss new file mode 100644 index 0000000..7fbec3e --- /dev/null +++ b/utils/dist/radio/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-radio{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;overflow:hidden;-webkit-user-select:none;user-select:none}.van-radio__icon-wrap{-webkit-flex:none;flex:none}.van-radio__icon{display:block;box-sizing:border-box;width:1em;height:1em;color:transparent;text-align:center;transition-property:color,border-color,background-color;border:1px solid #c8c9cc;border:1px solid var(--radio-border-color,#c8c9cc);font-size:20px;font-size:var(--radio-size,20px);transition-duration:.2s;transition-duration:var(--radio-transition-duration,.2s)}.van-radio__icon--round{border-radius:100%}.van-radio__icon--checked{color:#fff;color:var(--white,#fff);background-color:#1989fa;background-color:var(--radio-checked-icon-color,#1989fa);border-color:#1989fa;border-color:var(--radio-checked-icon-color,#1989fa)}.van-radio__icon--disabled{background-color:#ebedf0;background-color:var(--radio-disabled-background-color,#ebedf0);border-color:#c8c9cc;border-color:var(--radio-disabled-icon-color,#c8c9cc)}.van-radio__icon--disabled.van-radio__icon--checked{color:#c8c9cc;color:var(--radio-disabled-icon-color,#c8c9cc)}.van-radio__label{word-wrap:break-word;margin-left:10px;margin-left:var(--radio-label-margin,10px);color:#323233;color:var(--radio-label-color,#323233);line-height:20px;line-height:var(--radio-size,20px)}.van-radio__label--left{float:left;margin:0 10px 0 0;margin:0 var(--radio-label-margin,10px) 0 0}.van-radio__label--disabled{color:#c8c9cc;color:var(--radio-disabled-label-color,#c8c9cc)}.van-radio__label:empty{margin:0} \ No newline at end of file diff --git a/utils/dist/rate/index.d.ts b/utils/dist/rate/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/rate/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/rate/index.js b/utils/dist/rate/index.js new file mode 100644 index 0000000..288ec71 --- /dev/null +++ b/utils/dist/rate/index.js @@ -0,0 +1,95 @@ +import { VantComponent } from '../common/component'; +import { addUnit } from '../common/utils'; +VantComponent({ + field: true, + classes: ['icon-class'], + props: { + value: Number, + readonly: Boolean, + disabled: Boolean, + allowHalf: Boolean, + size: { + type: null, + observer: 'setSizeWithUnit' + }, + icon: { + type: String, + value: 'star' + }, + voidIcon: { + type: String, + value: 'star-o' + }, + color: { + type: String, + value: '#ffd21e' + }, + voidColor: { + type: String, + value: '#c7c7c7' + }, + disabledColor: { + type: String, + value: '#bdbdbd' + }, + count: { + type: Number, + value: 5 + }, + gutter: { + type: null, + observer: 'setGutterWithUnit' + }, + touchable: { + type: Boolean, + value: true + } + }, + data: { + innerValue: 0, + gutterWithUnit: undefined, + sizeWithUnit: null + }, + watch: { + value(value) { + if (value !== this.data.innerValue) { + this.setData({ innerValue: value }); + } + } + }, + methods: { + setGutterWithUnit(val) { + this.setData({ + gutterWithUnit: addUnit(val) + }); + }, + setSizeWithUnit(size) { + this.setData({ + sizeWithUnit: addUnit(size) + }); + }, + onSelect(event) { + const { data } = this; + const { score } = event.currentTarget.dataset; + if (!data.disabled && !data.readonly) { + this.setData({ innerValue: score + 1 }); + this.$emit('input', score + 1); + this.$emit('change', score + 1); + } + }, + onTouchMove(event) { + const { touchable } = this.data; + if (!touchable) + return; + const { clientX } = event.touches[0]; + this.getRect('.van-rate__icon', true).then((list) => { + const target = list + .sort(item => item.right - item.left) + .find(item => clientX >= item.left && clientX <= item.right); + if (target != null) { + this.onSelect(Object.assign(Object.assign({}, event), { currentTarget: target })); + } + }); + } + } +}); diff --git a/utils/dist/rate/index.json b/utils/dist/rate/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/utils/dist/rate/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/utils/dist/rate/index.wxml b/utils/dist/rate/index.wxml new file mode 100644 index 0000000..72defd6 --- /dev/null +++ b/utils/dist/rate/index.wxml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/utils/dist/rate/index.wxss b/utils/dist/rate/index.wxss new file mode 100644 index 0000000..6fd3435 --- /dev/null +++ b/utils/dist/rate/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-rate{display:-webkit-inline-flex;display:inline-flex;-webkit-user-select:none;user-select:none}.van-rate__item{position:relative;padding:0 2px;padding:0 var(--rate-horizontal-padding,2px)}.van-rate__icon{display:block;height:1em;font-size:20px;font-size:var(--rate-icon-size,20px)}.van-rate__icon--half{position:absolute;top:0;width:.5em;overflow:hidden;left:2px;left:var(--rate-horizontal-padding,2px)} \ No newline at end of file diff --git a/utils/dist/row/index.d.ts b/utils/dist/row/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/row/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/row/index.js b/utils/dist/row/index.js new file mode 100644 index 0000000..d7c8ba4 --- /dev/null +++ b/utils/dist/row/index.js @@ -0,0 +1,36 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + relation: { + name: 'col', + type: 'descendant', + linked(target) { + if (this.data.gutter) { + target.setGutter(this.data.gutter); + } + } + }, + props: { + gutter: Number + }, + watch: { + gutter: 'setGutter' + }, + mounted() { + if (this.data.gutter) { + this.setGutter(); + } + }, + methods: { + setGutter() { + const { gutter } = this.data; + const margin = `-${Number(gutter) / 2}px`; + const style = gutter + ? `margin-right: ${margin}; margin-left: ${margin};` + : ''; + this.setData({ style }); + this.getRelationNodes('../col/index').forEach(col => { + col.setGutter(this.data.gutter); + }); + } + } +}); diff --git a/utils/dist/row/index.json b/utils/dist/row/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/row/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/row/index.wxml b/utils/dist/row/index.wxml new file mode 100644 index 0000000..20c5366 --- /dev/null +++ b/utils/dist/row/index.wxml @@ -0,0 +1,3 @@ + + + diff --git a/utils/dist/row/index.wxss b/utils/dist/row/index.wxss new file mode 100644 index 0000000..32a098b --- /dev/null +++ b/utils/dist/row/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-row:after{display:table;clear:both;content:""} \ No newline at end of file diff --git a/utils/dist/search/index.d.ts b/utils/dist/search/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/search/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/search/index.js b/utils/dist/search/index.js new file mode 100644 index 0000000..931dd6c --- /dev/null +++ b/utils/dist/search/index.js @@ -0,0 +1,73 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + field: true, + classes: ['field-class', 'input-class', 'cancel-class'], + props: { + label: String, + focus: Boolean, + error: Boolean, + disabled: Boolean, + readonly: Boolean, + inputAlign: String, + showAction: Boolean, + useActionSlot: Boolean, + useLeftIconSlot: Boolean, + useRightIconSlot: Boolean, + leftIcon: { + type: String, + value: 'search' + }, + rightIcon: String, + placeholder: String, + placeholderStyle: String, + actionText: { + type: String, + value: '取消' + }, + background: { + type: String, + value: '#ffffff' + }, + maxlength: { + type: Number, + value: -1 + }, + shape: { + type: String, + value: 'square' + }, + clearable: { + type: Boolean, + value: true + } + }, + methods: { + onChange(event) { + this.setData({ value: event.detail }); + this.$emit('change', event.detail); + }, + onCancel() { + /** + * 修复修改输入框值时,输入框失焦和赋值同时触发,赋值失效 + * https://github.com/youzan/@vant/weapp/issues/1768 + */ + setTimeout(() => { + this.setData({ value: '' }); + this.$emit('cancel'); + this.$emit('change', ''); + }, 200); + }, + onSearch() { + this.$emit('search', this.data.value); + }, + onFocus() { + this.$emit('focus'); + }, + onBlur() { + this.$emit('blur'); + }, + onClear() { + this.$emit('clear'); + }, + } +}); diff --git a/utils/dist/search/index.json b/utils/dist/search/index.json new file mode 100644 index 0000000..b4cfe91 --- /dev/null +++ b/utils/dist/search/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-field": "../field/index" + } +} diff --git a/utils/dist/search/index.wxml b/utils/dist/search/index.wxml new file mode 100644 index 0000000..1d0e6f1 --- /dev/null +++ b/utils/dist/search/index.wxml @@ -0,0 +1,50 @@ + + + + + {{ label }} + + + + + + + + + + + {{ actionText }} + + diff --git a/utils/dist/search/index.wxss b/utils/dist/search/index.wxss new file mode 100644 index 0000000..32247c5 --- /dev/null +++ b/utils/dist/search/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-search{-webkit-align-items:center;align-items:center;box-sizing:border-box;padding:10px 12px;padding:var(--search-padding,10px 12px)}.van-search,.van-search__content{display:-webkit-flex;display:flex}.van-search__content{-webkit-flex:1;flex:1;padding-left:8px;padding-left:var(--padding-xs,8px);border-radius:2px;border-radius:var(--border-radius-sm,2px);background-color:#f7f8fa;background-color:var(--search-background-color,#f7f8fa)}.van-search__content--round{border-radius:17px;border-radius:calc(var(--search-input-height, 34px)/2)}.van-search__label{padding:0 5px;padding:var(--search-label-padding,0 5px);font-size:14px;font-size:var(--search-label-font-size,14px);line-height:34px;line-height:var(--search-input-height,34px);color:#323233;color:var(--search-label-color,#323233)}.van-search__field{-webkit-flex:1;flex:1}.van-search__field__left-icon{color:#969799;color:var(--search-left-icon-color,#969799)}.van-search--withaction{padding-right:0}.van-search__action{padding:0 8px;padding:var(--search-action-padding,0 8px);font-size:14px;font-size:var(--search-action-font-size,14px);line-height:34px;line-height:var(--search-input-height,34px);color:#323233;color:var(--search-action-text-color,#323233)}.van-search__action--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)} \ No newline at end of file diff --git a/utils/dist/sidebar-item/index.d.ts b/utils/dist/sidebar-item/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/sidebar-item/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/sidebar-item/index.js b/utils/dist/sidebar-item/index.js new file mode 100644 index 0000000..ecdaa08 --- /dev/null +++ b/utils/dist/sidebar-item/index.js @@ -0,0 +1,36 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + classes: [ + 'active-class', + 'disabled-class', + ], + relation: { + type: 'ancestor', + name: 'sidebar', + linked(target) { + this.parent = target; + } + }, + props: { + dot: Boolean, + info: null, + title: String, + disabled: Boolean + }, + methods: { + onClick() { + const { parent } = this; + if (!parent || this.data.disabled) { + return; + } + const index = parent.children.indexOf(this); + parent.setActive(index).then(() => { + this.$emit('click', index); + parent.$emit('change', index); + }); + }, + setActive(selected) { + return this.setData({ selected }); + } + } +}); diff --git a/utils/dist/sidebar-item/index.json b/utils/dist/sidebar-item/index.json new file mode 100644 index 0000000..bf0ebe0 --- /dev/null +++ b/utils/dist/sidebar-item/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-info": "../info/index" + } +} diff --git a/utils/dist/sidebar-item/index.wxml b/utils/dist/sidebar-item/index.wxml new file mode 100644 index 0000000..f68e864 --- /dev/null +++ b/utils/dist/sidebar-item/index.wxml @@ -0,0 +1,18 @@ + + + + + + {{ title }} + + diff --git a/utils/dist/sidebar-item/index.wxss b/utils/dist/sidebar-item/index.wxss new file mode 100644 index 0000000..36d2bf4 --- /dev/null +++ b/utils/dist/sidebar-item/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-sidebar-item{display:block;box-sizing:border-box;overflow:hidden;word-wrap:break-word;border-left:3px solid transparent;-webkit-user-select:none;user-select:none;padding:20px 12px 20px 8px;padding:var(--sidebar-padding,20px 12px 20px 8px);font-size:14px;font-size:var(--sidebar-font-size,14px);line-height:20px;line-height:var(--sidebar-line-height,20px);color:#323233;color:var(--sidebar-text-color,#323233);background-color:#fafafa;background-color:var(--sidebar-background-color,#fafafa)}.van-sidebar-item__text{position:relative;display:inline-block}.van-sidebar-item--hover:not(.van-sidebar-item--disabled){background-color:#f2f3f5;background-color:var(--sidebar-active-color,#f2f3f5)}.van-sidebar-item:after{border-bottom-width:1px}.van-sidebar-item--selected{color:#323233;color:var(--sidebar-selected-text-color,#323233);font-weight:500;font-weight:var(--sidebar-selected-font-weight,500);border-color:#ee0a24;border-color:var(--sidebar-selected-border-color,#ee0a24)}.van-sidebar-item--selected:after{border-right-width:1px}.van-sidebar-item--selected,.van-sidebar-item--selected.van-sidebar-item--hover{background-color:#fff;background-color:var(--sidebar-selected-background-color,#fff)}.van-sidebar-item--disabled{color:#c8c9cc;color:var(--sidebar-disabled-text-color,#c8c9cc)} \ No newline at end of file diff --git a/utils/dist/sidebar/index.d.ts b/utils/dist/sidebar/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/sidebar/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/sidebar/index.js b/utils/dist/sidebar/index.js new file mode 100644 index 0000000..326faf5 --- /dev/null +++ b/utils/dist/sidebar/index.js @@ -0,0 +1,43 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + relation: { + name: 'sidebar-item', + type: 'descendant', + linked(target) { + this.children.push(target); + this.setActive(this.data.activeKey); + }, + unlinked(target) { + this.children = this.children.filter((item) => item !== target); + this.setActive(this.data.activeKey); + } + }, + props: { + activeKey: { + type: Number, + value: 0, + observer: 'setActive' + } + }, + beforeCreate() { + this.children = []; + this.currentActive = -1; + }, + methods: { + setActive(activeKey) { + const { children, currentActive } = this; + if (!children.length) { + return Promise.resolve(); + } + this.currentActive = activeKey; + const stack = []; + if (currentActive !== activeKey && children[currentActive]) { + stack.push(children[currentActive].setActive(false)); + } + if (children[activeKey]) { + stack.push(children[activeKey].setActive(true)); + } + return Promise.all(stack); + } + } +}); diff --git a/utils/dist/sidebar/index.json b/utils/dist/sidebar/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/sidebar/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/sidebar/index.wxml b/utils/dist/sidebar/index.wxml new file mode 100644 index 0000000..e64c19c --- /dev/null +++ b/utils/dist/sidebar/index.wxml @@ -0,0 +1,3 @@ + + + diff --git a/utils/dist/sidebar/index.wxss b/utils/dist/sidebar/index.wxss new file mode 100644 index 0000000..ba3ba94 --- /dev/null +++ b/utils/dist/sidebar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-sidebar{width:85px;width:var(--sidebar-width,85px)} \ No newline at end of file diff --git a/utils/dist/skeleton/index.d.ts b/utils/dist/skeleton/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/skeleton/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/skeleton/index.js b/utils/dist/skeleton/index.js new file mode 100644 index 0000000..4092bbd --- /dev/null +++ b/utils/dist/skeleton/index.js @@ -0,0 +1,41 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + row: { + type: Number, + value: 0 + }, + title: Boolean, + avatar: Boolean, + loading: { + type: Boolean, + value: true + }, + animate: { + type: Boolean, + value: true + }, + avatarSize: { + type: String, + value: '32px' + }, + avatarShape: { + type: String, + value: 'round' + }, + titleWidth: { + type: String, + value: '40%' + }, + rowWidth: { + type: null, + value: '100%', + observer(val) { + this.setData({ isArray: val instanceof Array }); + } + } + }, + data: { + isArray: false + } +}); diff --git a/utils/dist/skeleton/index.json b/utils/dist/skeleton/index.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/utils/dist/skeleton/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/utils/dist/skeleton/index.wxml b/utils/dist/skeleton/index.wxml new file mode 100644 index 0000000..1177370 --- /dev/null +++ b/utils/dist/skeleton/index.wxml @@ -0,0 +1,29 @@ + + + + + + + + + + + + diff --git a/utils/dist/skeleton/index.wxss b/utils/dist/skeleton/index.wxss new file mode 100644 index 0000000..565b26e --- /dev/null +++ b/utils/dist/skeleton/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-skeleton{display:-webkit-flex;display:flex;box-sizing:border-box;width:100%;padding:0 16px;padding:var(--skeleton-padding,0 16px)}.van-skeleton__avatar{-webkit-flex-shrink:0;flex-shrink:0;margin-right:16px;margin-right:var(--padding-md,16px);background-color:#f2f3f5;background-color:var(--skeleton-avatar-background-color,#f2f3f5)}.van-skeleton__avatar--round{border-radius:100%}.van-skeleton__content{-webkit-flex:1;flex:1}.van-skeleton__avatar+.van-skeleton__content{padding-top:8px;padding-top:var(--padding-xs,8px)}.van-skeleton__row,.van-skeleton__title{height:16px;height:var(--skeleton-row-height,16px);background-color:#f2f3f5;background-color:var(--skeleton-row-background-color,#f2f3f5)}.van-skeleton__title{margin:0}.van-skeleton__row:not(:first-child){margin-top:12px;margin-top:var(--skeleton-row-margin-top,12px)}.van-skeleton__title+.van-skeleton__row{margin-top:20px}.van-skeleton--animate{-webkit-animation:van-skeleton-blink 1.2s ease-in-out infinite;animation:van-skeleton-blink 1.2s ease-in-out infinite}@-webkit-keyframes van-skeleton-blink{50%{opacity:.6}}@keyframes van-skeleton-blink{50%{opacity:.6}} \ No newline at end of file diff --git a/utils/dist/slider/index.d.ts b/utils/dist/slider/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/slider/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/slider/index.js b/utils/dist/slider/index.js new file mode 100644 index 0000000..971e15e --- /dev/null +++ b/utils/dist/slider/index.js @@ -0,0 +1,107 @@ +import { VantComponent } from '../common/component'; +import { touch } from '../mixins/touch'; +import { addUnit } from '../common/utils'; +VantComponent({ + mixins: [touch], + props: { + disabled: Boolean, + useButtonSlot: Boolean, + activeColor: String, + inactiveColor: String, + max: { + type: Number, + value: 100 + }, + min: { + type: Number, + value: 0 + }, + step: { + type: Number, + value: 1 + }, + value: { + type: Number, + value: 0 + }, + barHeight: { + type: null, + value: '2px' + } + }, + watch: { + value(value) { + this.updateValue(value, false); + } + }, + created() { + this.updateValue(this.data.value); + }, + methods: { + onTouchStart(event) { + if (this.data.disabled) + return; + this.touchStart(event); + this.startValue = this.format(this.data.value); + this.dragStatus = 'start'; + }, + onTouchMove(event) { + if (this.data.disabled) + return; + if (this.dragStatus === 'start') { + this.$emit('drag-start'); + } + this.touchMove(event); + this.dragStatus = 'draging'; + this.getRect('.van-slider').then((rect) => { + const diff = this.deltaX / rect.width * 100; + this.newValue = this.startValue + diff; + this.updateValue(this.newValue, false, true); + }); + }, + onTouchEnd() { + if (this.data.disabled) + return; + if (this.dragStatus === 'draging') { + this.updateValue(this.newValue, true); + this.$emit('drag-end'); + } + }, + onClick(event) { + if (this.data.disabled) + return; + const { min } = this.data; + this.getRect('.van-slider').then((rect) => { + const value = (event.detail.x - rect.left) / rect.width * this.getRange() + min; + this.updateValue(value, true); + }); + }, + updateValue(value, end, drag) { + value = this.format(value); + const { barHeight, min } = this.data; + const width = `${((value - min) * 100) / this.getRange()}%`; + this.setData({ + value, + barStyle: ` + width: ${width}; + height: ${addUnit(barHeight)}; + ${drag ? 'transition: none;' : ''} + `, + }); + if (drag) { + this.$emit('drag', { value }); + } + if (end) { + this.$emit('change', value); + } + }, + getRange() { + const { max, min } = this.data; + return max - min; + }, + format(value) { + const { max, min, step } = this.data; + return Math.round(Math.max(min, Math.min(value, max)) / step) * step; + } + } +}); diff --git a/utils/dist/slider/index.json b/utils/dist/slider/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/slider/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/slider/index.wxml b/utils/dist/slider/index.wxml new file mode 100644 index 0000000..d30d078 --- /dev/null +++ b/utils/dist/slider/index.wxml @@ -0,0 +1,29 @@ + + + + + + + + + + diff --git a/utils/dist/slider/index.wxss b/utils/dist/slider/index.wxss new file mode 100644 index 0000000..7886b60 --- /dev/null +++ b/utils/dist/slider/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-slider{position:relative;border-radius:999px;border-radius:var(--border-radius-max,999px);background-color:#ebedf0;background-color:var(--slider-inactive-background-color,#ebedf0)}.van-slider:before{position:absolute;right:0;left:0;content:"";top:-8px;top:-var(--padding-xs,8px);bottom:-8px;bottom:-var(--padding-xs,8px)}.van-slider__bar{position:relative;border-radius:inherit;transition:width .2s;transition:width var(--animation-duration-fast,.2s);background-color:#1989fa;background-color:var(--slider-active-background-color,#1989fa)}.van-slider__button{width:24px;height:24px;border-radius:50%;box-shadow:0 1px 2px rgba(0,0,0,.5);background-color:#fff;background-color:var(--slider-button-background-color,#fff)}.van-slider__button-wrapper{position:absolute;top:50%;right:0;-webkit-transform:translate3d(50%,-50%,0);transform:translate3d(50%,-50%,0)}.van-slider--disabled{opacity:.5} \ No newline at end of file diff --git a/utils/dist/stepper/index.d.ts b/utils/dist/stepper/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/stepper/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/stepper/index.js b/utils/dist/stepper/index.js new file mode 100644 index 0000000..c242588 --- /dev/null +++ b/utils/dist/stepper/index.js @@ -0,0 +1,172 @@ +import { VantComponent } from '../common/component'; +import { addUnit, isDef } from '../common/utils'; +const LONG_PRESS_START_TIME = 600; +const LONG_PRESS_INTERVAL = 200; +// add num and avoid float number +function add(num1, num2) { + const cardinal = Math.pow(10, 10); + return Math.round((num1 + num2) * cardinal) / cardinal; +} +VantComponent({ + field: true, + classes: ['input-class', 'plus-class', 'minus-class'], + props: { + value: null, + integer: Boolean, + disabled: Boolean, + inputWidth: null, + buttonSize: null, + asyncChange: Boolean, + disableInput: Boolean, + decimalLength: { + type: Number, + value: null + }, + min: { + type: null, + value: 1 + }, + max: { + type: null, + value: Number.MAX_SAFE_INTEGER + }, + step: { + type: null, + value: 1 + }, + showPlus: { + type: Boolean, + value: true + }, + showMinus: { + type: Boolean, + value: true + }, + disablePlus: Boolean, + disableMinus: Boolean + }, + watch: { + value(value) { + if (value === '') { + return; + } + const newValue = this.range(value); + if (typeof newValue === 'number' && +this.data.value !== newValue) { + this.setData({ value: newValue }); + } + }, + inputWidth() { + this.set({ + inputStyle: this.computeInputStyle() + }); + }, + buttonSize() { + this.set({ + inputStyle: this.computeInputStyle(), + buttonStyle: this.computeButtonStyle() + }); + } + }, + data: { + focus: false, + inputStyle: '', + buttonStyle: '' + }, + created() { + this.setData({ + value: this.range(this.data.value) + }); + }, + methods: { + isDisabled(type) { + if (type === 'plus') { + return this.data.disabled || this.data.disablePlus || this.data.value >= this.data.max; + } + return this.data.disabled || this.data.disableMinus || this.data.value <= this.data.min; + }, + onFocus(event) { + this.$emit('focus', event.detail); + }, + onBlur(event) { + const value = this.range(this.data.value); + this.triggerInput(value); + this.$emit('blur', event.detail); + }, + // limit value range + range(value) { + value = String(value).replace(/[^0-9.-]/g, ''); + // format range + value = value === '' ? 0 : +value; + value = Math.max(Math.min(this.data.max, value), this.data.min); + // format decimal + if (isDef(this.data.decimalLength)) { + value = value.toFixed(this.data.decimalLength); + } + return value; + }, + onInput(event) { + const { value = '' } = event.detail || {}; + this.triggerInput(value); + }, + onChange() { + const { type } = this; + if (this.isDisabled(type)) { + this.$emit('overlimit', type); + return; + } + const diff = type === 'minus' ? -this.data.step : +this.data.step; + const value = add(+this.data.value, diff); + this.triggerInput(this.range(value)); + this.$emit(type); + }, + longPressStep() { + this.longPressTimer = setTimeout(() => { + this.onChange(); + this.longPressStep(); + }, LONG_PRESS_INTERVAL); + }, + onTap(event) { + const { type } = event.currentTarget.dataset; + this.type = type; + this.onChange(); + }, + onTouchStart(event) { + clearTimeout(this.longPressTimer); + const { type } = event.currentTarget.dataset; + this.type = type; + this.isLongPress = false; + this.longPressTimer = setTimeout(() => { + this.isLongPress = true; + this.onChange(); + this.longPressStep(); + }, LONG_PRESS_START_TIME); + }, + onTouchEnd() { + clearTimeout(this.longPressTimer); + }, + triggerInput(value) { + this.setData({ + value: this.data.asyncChange ? this.data.value : value + }); + this.$emit('change', value); + }, + computeInputStyle() { + let style = ''; + if (this.data.inputWidth) { + style = `width: ${addUnit(this.data.inputWidth)};`; + } + if (this.data.buttonSize) { + style += `height: ${addUnit(this.data.buttonSize)};`; + } + return style; + }, + computeButtonStyle() { + let style = ''; + const size = addUnit(this.data.buttonSize); + if (this.data.buttonSize) { + style = `width: ${size};height: ${size};`; + } + return style; + } + } +}); diff --git a/utils/dist/stepper/index.json b/utils/dist/stepper/index.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/utils/dist/stepper/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/utils/dist/stepper/index.wxml b/utils/dist/stepper/index.wxml new file mode 100644 index 0000000..456ccce --- /dev/null +++ b/utils/dist/stepper/index.wxml @@ -0,0 +1,37 @@ + + + + + + + diff --git a/utils/dist/stepper/index.wxss b/utils/dist/stepper/index.wxss new file mode 100644 index 0000000..5da5b79 --- /dev/null +++ b/utils/dist/stepper/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-stepper{font-size:0}.van-stepper__minus,.van-stepper__plus{position:relative;display:inline-block;box-sizing:border-box;margin:1px;vertical-align:middle;border:0;background-color:#f2f3f5;background-color:var(--stepper-background-color,#f2f3f5);color:#323233;color:var(--stepper-button-icon-color,#323233);width:28px;width:var(--stepper-input-height,28px);height:28px;height:var(--stepper-input-height,28px);padding:4px;padding:var(--padding-base,4px)}.van-stepper__minus:before,.van-stepper__plus:before{width:9px;height:1px}.van-stepper__minus:after,.van-stepper__plus:after{width:1px;height:9px}.van-stepper__minus:after,.van-stepper__minus:before,.van-stepper__plus:after,.van-stepper__plus:before{position:absolute;top:0;right:0;bottom:0;left:0;margin:auto;background-color:currentColor;content:""}.van-stepper__minus--hover,.van-stepper__plus--hover{background-color:#e8e8e8;background-color:var(--stepper-active-color,#e8e8e8)}.van-stepper__minus--disabled,.van-stepper__plus--disabled{color:#c8c9cc;color:var(--stepper-button-disabled-icon-color,#c8c9cc)}.van-stepper__minus--disabled,.van-stepper__minus--disabled.van-stepper__minus--hover,.van-stepper__minus--disabled.van-stepper__plus--hover,.van-stepper__plus--disabled,.van-stepper__plus--disabled.van-stepper__minus--hover,.van-stepper__plus--disabled.van-stepper__plus--hover{background-color:#f7f8fa;background-color:var(--stepper-button-disabled-color,#f7f8fa)}.van-stepper__minus{border-radius:4px 0 0 4px;border-radius:var(--stepper-border-radius,4px) 0 0 var(--stepper-border-radius,4px)}.van-stepper__minus:after{display:none}.van-stepper__plus{border-radius:0 4px 4px 0;border-radius:0 var(--stepper-border-radius,4px) var(--stepper-border-radius,4px) 0}.van-stepper__input{display:inline-block;box-sizing:border-box;min-height:0;margin:1px;padding:1px;text-align:center;vertical-align:middle;border:0;border-width:1px 0;border-radius:0;-webkit-appearance:none;font-size:14px;font-size:var(--stepper-input-font-size,14px);color:#323233;color:var(--stepper-input-text-color,#323233);background-color:#f2f3f5;background-color:var(--stepper-background-color,#f2f3f5);width:32px;width:var(--stepper-input-width,32px);height:28px;height:var(--stepper-input-height,28px)}.van-stepper__input--disabled{color:#c8c9cc;color:var(--stepper-input-disabled-text-color,#c8c9cc);background-color:#f2f3f5;background-color:var(--stepper-input-disabled-background-color,#f2f3f5)} \ No newline at end of file diff --git a/utils/dist/steps/index.d.ts b/utils/dist/steps/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/steps/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/steps/index.js b/utils/dist/steps/index.js new file mode 100644 index 0000000..14b5f30 --- /dev/null +++ b/utils/dist/steps/index.js @@ -0,0 +1,22 @@ +import { VantComponent } from '../common/component'; +import { GREEN } from '../common/color'; +VantComponent({ + props: { + icon: String, + steps: Array, + active: Number, + direction: { + type: String, + value: 'horizontal' + }, + activeColor: { + type: String, + value: GREEN + }, + activeIcon: { + type: String, + value: 'checked' + }, + inactiveIcon: String + } +}); diff --git a/utils/dist/steps/index.json b/utils/dist/steps/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/utils/dist/steps/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/utils/dist/steps/index.wxml b/utils/dist/steps/index.wxml new file mode 100644 index 0000000..9e280d8 --- /dev/null +++ b/utils/dist/steps/index.wxml @@ -0,0 +1,51 @@ + + + + + + + {{ item.text }} + {{ item.desc }} + + + + + + + + + + + + + + + +function get(index, active) { + if (index < active) { + return 'finish'; + } else if (index === active) { + return 'process'; + } + + return ''; +} + +module.exports = get; + diff --git a/utils/dist/steps/index.wxss b/utils/dist/steps/index.wxss new file mode 100644 index 0000000..2c50b1a --- /dev/null +++ b/utils/dist/steps/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-steps{overflow:hidden;background-color:#fff;background-color:var(--steps-background-color,#fff)}.van-steps--horizontal{padding:10px}.van-steps--horizontal .van-step__wrapper{position:relative;display:-webkit-flex;display:flex;overflow:hidden}.van-steps--vertical{padding-left:10px}.van-steps--vertical .van-step__wrapper{padding:0 0 0 20px}.van-step{position:relative;-webkit-flex:1;flex:1;font-size:14px;font-size:var(--step-font-size,14px);color:#969799;color:var(--step-text-color,#969799)}.van-step--finish{color:#323233;color:var(--step-finish-text-color,#323233)}.van-step__circle{border-radius:50%;width:5px;width:var(--step-circle-size,5px);height:5px;height:var(--step-circle-size,5px);background-color:#969799;background-color:var(--step-circle-color,#969799)}.van-step--horizontal{padding-bottom:14px}.van-step--horizontal:first-child .van-step__title{-webkit-transform:none;transform:none}.van-step--horizontal:first-child .van-step__circle-container{padding:0 8px 0 0;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0)}.van-step--horizontal:last-child{position:absolute;right:0;width:auto}.van-step--horizontal:last-child .van-step__title{text-align:right;-webkit-transform:none;transform:none}.van-step--horizontal:last-child .van-step__circle-container{right:0;padding:0 0 0 8px;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0)}.van-step--horizontal .van-step__circle-container{position:absolute;bottom:6px;z-index:1;-webkit-transform:translate3d(-50%,50%,0);transform:translate3d(-50%,50%,0);background-color:#fff;background-color:var(--white,#fff);padding:0 8px;padding:0 var(--padding-xs,8px)}.van-step--horizontal .van-step__title{display:inline-block;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0);font-size:12px;font-size:var(--step-horizontal-title-font-size,12px)}.van-step--horizontal .van-step__line{position:absolute;right:0;bottom:6px;left:0;height:1px;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0);background-color:#ebedf0;background-color:var(--step-line-color,#ebedf0)}.van-step--horizontal.van-step--process{color:#323233;color:var(--step-process-text-color,#323233)}.van-step--horizontal.van-step--process .van-step__icon{display:block;line-height:1;font-size:12px;font-size:var(--step-icon-size,12px)}.van-step--vertical{padding:10px 10px 10px 0;line-height:18px}.van-step--vertical:after{border-bottom-width:1px}.van-step--vertical:last-child:after{border-bottom-width:none}.van-step--vertical:first-child:before{position:absolute;top:0;left:-15px;z-index:1;width:1px;height:20px;content:"";background-color:#fff;background-color:var(--white,#fff)}.van-step--vertical .van-step__circle,.van-step--vertical .van-step__icon,.van-step--vertical .van-step__line{position:absolute;top:19px;left:-14px;z-index:2;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0)}.van-step--vertical .van-step__icon{line-height:1;font-size:12px;font-size:var(--step-icon-size,12px)}.van-step--vertical .van-step__line{z-index:1;width:1px;height:100%;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0);background-color:#ebedf0;background-color:var(--step-line-color,#ebedf0)} \ No newline at end of file diff --git a/utils/dist/sticky/index.d.ts b/utils/dist/sticky/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/sticky/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/sticky/index.js b/utils/dist/sticky/index.js new file mode 100644 index 0000000..6b904a9 --- /dev/null +++ b/utils/dist/sticky/index.js @@ -0,0 +1,140 @@ +import { VantComponent } from '../common/component'; +const ROOT_ELEMENT = '.van-sticky'; +VantComponent({ + props: { + zIndex: { + type: Number, + value: 99 + }, + offsetTop: { + type: Number, + value: 0, + observer: 'observeContent' + }, + disabled: { + type: Boolean, + observer(value) { + if (!this.mounted) { + return; + } + value ? this.disconnectObserver() : this.initObserver(); + } + }, + container: { + type: null, + observer(target) { + if (typeof target !== 'function' || !this.data.height) { + return; + } + this.observeContainer(); + } + } + }, + data: { + wrapStyle: '', + containerStyle: '' + }, + methods: { + setStyle() { + const { offsetTop, height, fixed, zIndex } = this.data; + if (fixed) { + this.setData({ + wrapStyle: `top: ${offsetTop}px;`, + containerStyle: `height: ${height}px; z-index: ${zIndex};` + }); + } + else { + this.setData({ + wrapStyle: '', + containerStyle: '' + }); + } + }, + getContainerRect() { + const nodesRef = this.data.container(); + return new Promise(resolve => nodesRef.boundingClientRect(resolve).exec()); + }, + initObserver() { + this.disconnectObserver(); + this.getRect(ROOT_ELEMENT).then((rect) => { + this.setData({ height: rect.height }); + wx.nextTick(() => { + this.observeContent(); + this.observeContainer(); + }); + }); + }, + disconnectObserver(observerName) { + if (observerName) { + const observer = this[observerName]; + observer && observer.disconnect(); + } + else { + this.contentObserver && this.contentObserver.disconnect(); + this.containerObserver && this.containerObserver.disconnect(); + } + }, + observeContent() { + const { offsetTop } = this.data; + this.disconnectObserver('contentObserver'); + const contentObserver = this.createIntersectionObserver({ + thresholds: [0, 1] + }); + this.contentObserver = contentObserver; + contentObserver.relativeToViewport({ top: -offsetTop }); + contentObserver.observe(ROOT_ELEMENT, res => { + if (this.data.disabled) { + return; + } + this.setFixed(res.boundingClientRect.top); + }); + }, + observeContainer() { + if (typeof this.data.container !== 'function') { + return; + } + const { height } = this.data; + this.getContainerRect().then((rect) => { + this.containerHeight = rect.height; + this.disconnectObserver('containerObserver'); + const containerObserver = this.createIntersectionObserver({ + thresholds: [0, 1] + }); + this.containerObserver = containerObserver; + containerObserver.relativeToViewport({ + top: this.containerHeight - height + }); + containerObserver.observe(ROOT_ELEMENT, res => { + if (this.data.disabled) { + return; + } + this.setFixed(res.boundingClientRect.top); + }); + }); + }, + setFixed(top) { + const { offsetTop, height } = this.data; + const { containerHeight } = this; + const fixed = containerHeight && height + ? top > height - containerHeight && top < offsetTop + : top < offsetTop; + this.$emit('scroll', { + scrollTop: top, + isFixed: fixed + }); + this.setData({ fixed }); + wx.nextTick(() => { + this.setStyle(); + }); + } + }, + mounted() { + this.mounted = true; + if (!this.data.disabled) { + this.initObserver(); + } + }, + destroyed() { + this.disconnectObserver(); + } +}); diff --git a/utils/dist/sticky/index.json b/utils/dist/sticky/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/sticky/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/sticky/index.wxml b/utils/dist/sticky/index.wxml new file mode 100644 index 0000000..2f95359 --- /dev/null +++ b/utils/dist/sticky/index.wxml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/utils/dist/sticky/index.wxss b/utils/dist/sticky/index.wxss new file mode 100644 index 0000000..5269387 --- /dev/null +++ b/utils/dist/sticky/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-sticky{position:relative}.van-sticky-wrap--fixed{position:fixed;right:0;left:0} \ No newline at end of file diff --git a/utils/dist/submit-bar/index.d.ts b/utils/dist/submit-bar/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/submit-bar/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/submit-bar/index.js b/utils/dist/submit-bar/index.js new file mode 100644 index 0000000..23a34da --- /dev/null +++ b/utils/dist/submit-bar/index.js @@ -0,0 +1,57 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + classes: [ + 'bar-class', + 'price-class', + 'button-class' + ], + props: { + tip: { + type: null, + observer: 'updateTip' + }, + tipIcon: String, + type: Number, + price: { + type: null, + observer: 'updatePrice' + }, + label: String, + loading: Boolean, + disabled: Boolean, + buttonText: String, + currency: { + type: String, + value: '¥' + }, + buttonType: { + type: String, + value: 'danger' + }, + decimalLength: { + type: Number, + value: 2, + observer: 'updatePrice' + }, + suffixLabel: String, + safeAreaInsetBottom: { + type: Boolean, + value: true + } + }, + methods: { + updatePrice() { + const { price, decimalLength } = this.data; + this.setData({ + hasPrice: typeof price === 'number', + priceStr: (price / 100).toFixed(decimalLength) + }); + }, + updateTip() { + this.setData({ hasTip: typeof this.data.tip === 'string' }); + }, + onSubmit(event) { + this.$emit('submit', event.detail); + } + } +}); diff --git a/utils/dist/submit-bar/index.json b/utils/dist/submit-bar/index.json new file mode 100644 index 0000000..bda9b8d --- /dev/null +++ b/utils/dist/submit-bar/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-button": "../button/index", + "van-icon": "../icon/index" + } +} diff --git a/utils/dist/submit-bar/index.wxml b/utils/dist/submit-bar/index.wxml new file mode 100644 index 0000000..4cdbd18 --- /dev/null +++ b/utils/dist/submit-bar/index.wxml @@ -0,0 +1,42 @@ + + + + + + + + + {{ tip }} + + + + + + + + {{ label || '合计:' }} + + {{ currency }} + {{ priceStr }} + + {{ suffixLabel }} + + + {{ loading ? '' : buttonText }} + + + diff --git a/utils/dist/submit-bar/index.wxss b/utils/dist/submit-bar/index.wxss new file mode 100644 index 0000000..c21838e --- /dev/null +++ b/utils/dist/submit-bar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-submit-bar{position:fixed;bottom:0;left:0;width:100%;-webkit-user-select:none;user-select:none;z-index:100;z-index:var(--submit-bar-z-index,100);background-color:#fff;background-color:var(--submit-bar-background-color,#fff)}.van-submit-bar__tip{padding:10px;padding:var(--submit-bar-tip-padding,10px);color:#f56723;color:var(--submit-bar-tip-color,#f56723);font-size:12px;font-size:var(--submit-bar-tip-font-size,12px);line-height:1.5;line-height:var(--submit-bar-tip-line-height,1.5);background-color:#fff7cc;background-color:var(--submit-bar-tip-background-color,#fff7cc)}.van-submit-bar__tip:empty{display:none}.van-submit-bar__tip-icon{width:12px;height:12px;margin-right:4px;vertical-align:middle;font-size:12px;font-size:var(--submit-bar-tip-icon-size,12px);min-width:18px;min-width:calc(var(--submit-bar-tip-icon-size, 12px)*1.5)}.van-submit-bar__tip-text{display:inline;vertical-align:middle}.van-submit-bar__bar{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:flex-end;justify-content:flex-end;height:50px;height:var(--submit-bar-height,50px);font-size:14px;font-size:var(--submit-bar-text-font-size,14px);background-color:#fff;background-color:var(--submit-bar-background-color,#fff)}.van-submit-bar__bar--safe{padding-bottom:env(safe-area-inset-bottom)}.van-submit-bar__text{-webkit-flex:1;flex:1;text-align:right;color:#323233;color:var(--submit-bar-text-color,#323233);padding-right:12px;padding-right:var(--padding-sm,12px);font-weight:500;font-weight:var(--font-weight-bold,500)}.van-submit-bar__price{color:#ee0a24;color:var(--submit-bar-price-color,#ee0a24);font-size:18px;font-size:var(--submit-bar-price-font-size,18px)}.van-submit-bar__currency{font-size:14px;font-size:var(--submit-bar-currency-font-size,14px)}.van-submit-bar__suffix-label{margin-left:5px}.van-submit-bar__button{width:110px;width:var(--submit-bar-button-width,110px)} \ No newline at end of file diff --git a/utils/dist/swipe-cell/index.d.ts b/utils/dist/swipe-cell/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/swipe-cell/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/swipe-cell/index.js b/utils/dist/swipe-cell/index.js new file mode 100644 index 0000000..fa2e349 --- /dev/null +++ b/utils/dist/swipe-cell/index.js @@ -0,0 +1,122 @@ +import { VantComponent } from '../common/component'; +import { touch } from '../mixins/touch'; +import { range } from '../common/utils'; +const THRESHOLD = 0.3; +let ARRAY = []; +VantComponent({ + props: { + disabled: Boolean, + leftWidth: { + type: Number, + value: 0 + }, + rightWidth: { + type: Number, + value: 0 + }, + asyncClose: Boolean, + name: { + type: [Number, String], + value: '' + } + }, + mixins: [touch], + data: { + catchMove: false + }, + created() { + this.offset = 0; + ARRAY.push(this); + }, + destroyed() { + ARRAY = ARRAY.filter(item => item !== this); + }, + methods: { + open(position) { + const { leftWidth, rightWidth } = this.data; + const offset = position === 'left' ? leftWidth : -rightWidth; + this.swipeMove(offset); + this.$emit('open', { + position, + name: this.data.name + }); + }, + close() { + this.swipeMove(0); + }, + swipeMove(offset = 0) { + this.offset = range(offset, -this.data.rightWidth, this.data.leftWidth); + const transform = `translate3d(${this.offset}px, 0, 0)`; + const transition = this.dragging + ? 'none' + : 'transform .6s cubic-bezier(0.18, 0.89, 0.32, 1)'; + this.setData({ + wrapperStyle: ` + -webkit-transform: ${transform}; + -webkit-transition: ${transition}; + transform: ${transform}; + transition: ${transition}; + ` + }); + }, + swipeLeaveTransition() { + const { leftWidth, rightWidth } = this.data; + const { offset } = this; + if (rightWidth > 0 && -offset > rightWidth * THRESHOLD) { + this.open('right'); + } + else if (leftWidth > 0 && offset > leftWidth * THRESHOLD) { + this.open('left'); + } + else { + this.swipeMove(0); + } + this.setData({ catchMove: false }); + }, + startDrag(event) { + if (this.data.disabled) { + return; + } + this.startOffset = this.offset; + this.touchStart(event); + }, + noop() { }, + onDrag(event) { + if (this.data.disabled) { + return; + } + this.touchMove(event); + if (this.direction !== 'horizontal') { + return; + } + this.dragging = true; + ARRAY.filter(item => item !== this).forEach(item => item.close()); + this.setData({ catchMove: true }); + this.swipeMove(this.startOffset + this.deltaX); + }, + endDrag() { + if (this.data.disabled) { + return; + } + this.dragging = false; + this.swipeLeaveTransition(); + }, + onClick(event) { + const { key: position = 'outside' } = event.currentTarget.dataset; + this.$emit('click', position); + if (!this.offset) { + return; + } + if (this.data.asyncClose) { + this.$emit('close', { + position, + instance: this, + name: this.data.name + }); + } + else { + this.swipeMove(0); + } + } + } +}); diff --git a/utils/dist/swipe-cell/index.json b/utils/dist/swipe-cell/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/swipe-cell/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/swipe-cell/index.wxml b/utils/dist/swipe-cell/index.wxml new file mode 100644 index 0000000..7293619 --- /dev/null +++ b/utils/dist/swipe-cell/index.wxml @@ -0,0 +1,20 @@ + + + + + + + + + + + diff --git a/utils/dist/swipe-cell/index.wxss b/utils/dist/swipe-cell/index.wxss new file mode 100644 index 0000000..d615270 --- /dev/null +++ b/utils/dist/swipe-cell/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-swipe-cell{position:relative;overflow:hidden}.van-swipe-cell__left,.van-swipe-cell__right{position:absolute;top:0;height:100%}.van-swipe-cell__left{left:0;-webkit-transform:translate3d(-100%,0,0);transform:translate3d(-100%,0,0)}.van-swipe-cell__right{right:0;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0)} \ No newline at end of file diff --git a/utils/dist/switch/index.d.ts b/utils/dist/switch/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/switch/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/switch/index.js b/utils/dist/switch/index.js new file mode 100644 index 0000000..4009817 --- /dev/null +++ b/utils/dist/switch/index.js @@ -0,0 +1,51 @@ +import { VantComponent } from '../common/component'; +import { BLUE, GRAY_DARK } from '../common/color'; +VantComponent({ + field: true, + classes: ['node-class'], + props: { + checked: null, + loading: Boolean, + disabled: Boolean, + activeColor: String, + inactiveColor: String, + size: { + type: String, + value: '30px' + }, + activeValue: { + type: null, + value: true + }, + inactiveValue: { + type: null, + value: false + } + }, + watch: { + checked(value) { + const loadingColor = this.getLoadingColor(value); + this.setData({ value, loadingColor }); + } + }, + created() { + const { checked: value } = this.data; + const loadingColor = this.getLoadingColor(value); + this.setData({ value, loadingColor }); + }, + methods: { + getLoadingColor(checked) { + const { activeColor, inactiveColor } = this.data; + return checked ? activeColor || BLUE : inactiveColor || GRAY_DARK; + }, + onClick() { + const { activeValue, inactiveValue } = this.data; + if (!this.data.disabled && !this.data.loading) { + const checked = this.data.checked === activeValue; + const value = checked ? inactiveValue : activeValue; + this.$emit('input', value); + this.$emit('change', value); + } + } + } +}); diff --git a/utils/dist/switch/index.json b/utils/dist/switch/index.json new file mode 100644 index 0000000..01077f5 --- /dev/null +++ b/utils/dist/switch/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-loading": "../loading/index" + } +} diff --git a/utils/dist/switch/index.wxml b/utils/dist/switch/index.wxml new file mode 100644 index 0000000..31a104d --- /dev/null +++ b/utils/dist/switch/index.wxml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/utils/dist/switch/index.wxss b/utils/dist/switch/index.wxss new file mode 100644 index 0000000..e32a72a --- /dev/null +++ b/utils/dist/switch/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-switch{position:relative;display:inline-block;box-sizing:initial;width:2em;width:var(--switch-width,2em);height:1em;height:var(--switch-height,1em);background-color:#fff;background-color:var(--switch-background-color,#fff);border:1px solid rgba(0,0,0,.1);border:var(--switch-border,1px solid rgba(0,0,0,.1));border-radius:1em;border-radius:var(--switch-node-size,1em);transition:background-color .3s;transition:background-color var(--switch-transition-duration,.3s)}.van-switch__node{position:absolute;top:0;left:0;border-radius:100%;z-index:1;z-index:var(--switch-node-z-index,1);width:1em;width:var(--switch-node-size,1em);height:1em;height:var(--switch-node-size,1em);background-color:#fff;background-color:var(--switch-node-background-color,#fff);box-shadow:0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05);box-shadow:var(--switch-node-box-shadow,0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05));transition:-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05),-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:-webkit-transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);transition:transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);transition:transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05),-webkit-transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05)}.van-switch__loading{position:absolute!important;top:25%;left:25%;width:50%;height:50%}.van-switch--on{background-color:#1989fa;background-color:var(--switch-on-background-color,#1989fa)}.van-switch--on .van-switch__node{-webkit-transform:translateX(1em);transform:translateX(1em);-webkit-transform:translateX(calc(var(--switch-width, 2em) - var(--switch-node-size, 1em)));transform:translateX(calc(var(--switch-width, 2em) - var(--switch-node-size, 1em)))}.van-switch--disabled{opacity:.4;opacity:var(--switch-disabled-opacity,.4)} \ No newline at end of file diff --git a/utils/dist/tab/index.d.ts b/utils/dist/tab/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/tab/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/tab/index.js b/utils/dist/tab/index.js new file mode 100644 index 0000000..555086b --- /dev/null +++ b/utils/dist/tab/index.js @@ -0,0 +1,56 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + relation: { + name: 'tabs', + type: 'ancestor', + linked(target) { + this.parent = target; + }, + unlinked() { + this.parent = null; + } + }, + props: { + dot: Boolean, + info: null, + title: String, + disabled: Boolean, + titleStyle: String, + name: { + type: [Number, String], + value: '', + } + }, + data: { + active: false + }, + watch: { + title: 'update', + disabled: 'update', + dot: 'update', + info: 'update', + titleStyle: 'update' + }, + methods: { + getComputedName() { + if (this.data.name !== '') { + return this.data.name; + } + return this.index; + }, + updateRender(active, parent) { + const { data: parentData } = parent; + this.inited = this.inited || active; + this.setData({ + active, + shouldRender: this.inited || !parentData.lazyRender, + shouldShow: active || parentData.animated + }); + }, + update() { + if (this.parent) { + this.parent.updateTabs(); + } + } + } +}); diff --git a/utils/dist/tab/index.json b/utils/dist/tab/index.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/utils/dist/tab/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/utils/dist/tab/index.wxml b/utils/dist/tab/index.wxml new file mode 100644 index 0000000..f5e99f2 --- /dev/null +++ b/utils/dist/tab/index.wxml @@ -0,0 +1,8 @@ + + + + + diff --git a/utils/dist/tab/index.wxss b/utils/dist/tab/index.wxss new file mode 100644 index 0000000..b4e61b0 --- /dev/null +++ b/utils/dist/tab/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';:host{-webkit-flex-shrink:0;flex-shrink:0;width:100%}.van-tab__pane,:host{box-sizing:border-box}.van-tab__pane{overflow-y:auto}.van-tab__pane--active{height:auto}.van-tab__pane--inactive{height:0;overflow:visible} \ No newline at end of file diff --git a/utils/dist/tabbar-item/index.d.ts b/utils/dist/tabbar-item/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/tabbar-item/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/tabbar-item/index.js b/utils/dist/tabbar-item/index.js new file mode 100644 index 0000000..bd5fccf --- /dev/null +++ b/utils/dist/tabbar-item/index.js @@ -0,0 +1,47 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + info: null, + name: null, + icon: String, + dot: Boolean + }, + relation: { + name: 'tabbar', + type: 'ancestor' + }, + data: { + active: false + }, + methods: { + onClick() { + if (this.parent) { + this.parent.onChange(this); + } + this.$emit('click'); + }, + updateFromParent() { + const { parent } = this; + if (!parent) { + return; + } + const index = parent.children.indexOf(this); + const parentData = parent.data; + const { data } = this; + const active = (data.name || index) === parentData.active; + const patch = {}; + if (active !== data.active) { + patch.active = active; + } + if (parentData.activeColor !== data.activeColor) { + patch.activeColor = parentData.activeColor; + } + if (parentData.inactiveColor !== data.inactiveColor) { + patch.inactiveColor = parentData.inactiveColor; + } + return Object.keys(patch).length > 0 + ? this.set(patch) + : Promise.resolve(); + } + } +}); diff --git a/utils/dist/tabbar-item/index.json b/utils/dist/tabbar-item/index.json new file mode 100644 index 0000000..16f174c --- /dev/null +++ b/utils/dist/tabbar-item/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-info": "../info/index" + } +} diff --git a/utils/dist/tabbar-item/index.wxml b/utils/dist/tabbar-item/index.wxml new file mode 100644 index 0000000..d83b061 --- /dev/null +++ b/utils/dist/tabbar-item/index.wxml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + diff --git a/utils/dist/tabbar-item/index.wxss b/utils/dist/tabbar-item/index.wxss new file mode 100644 index 0000000..85bb21c --- /dev/null +++ b/utils/dist/tabbar-item/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-tabbar-item{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;height:100%;color:#646566;color:var(--tabbar-item-text-color,#646566);font-size:12px;font-size:var(--tabbar-item-font-size,12px);line-height:1;line-height:var(--tabbar-item-line-height,1)}.van-tabbar-item__icon{position:relative;margin-bottom:5px;margin-bottom:var(--tabbar-item-margin-bottom,5px);font-size:18px;font-size:var(--tabbar-item-icon-size,18px)}.van-tabbar-item__icon__inner{display:block;min-width:1em}.van-tabbar-item--active{color:#1989fa;color:var(--tabbar-item-active-color,#1989fa)}.van-tabbar-item__info{margin-top:2px} \ No newline at end of file diff --git a/utils/dist/tabbar/index.d.ts b/utils/dist/tabbar/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/tabbar/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/tabbar/index.js b/utils/dist/tabbar/index.js new file mode 100644 index 0000000..b227644 --- /dev/null +++ b/utils/dist/tabbar/index.js @@ -0,0 +1,65 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + relation: { + name: 'tabbar-item', + type: 'descendant', + linked(target) { + this.children.push(target); + target.parent = this; + target.updateFromParent(); + }, + unlinked(target) { + this.children = this.children.filter((item) => item !== target); + this.updateChildren(); + } + }, + props: { + active: { + type: null, + observer: 'updateChildren' + }, + activeColor: { + type: String, + observer: 'updateChildren' + }, + inactiveColor: { + type: String, + observer: 'updateChildren' + }, + fixed: { + type: Boolean, + value: true + }, + border: { + type: Boolean, + value: true + }, + zIndex: { + type: Number, + value: 1 + }, + safeAreaInsetBottom: { + type: Boolean, + value: true + } + }, + beforeCreate() { + this.children = []; + }, + methods: { + updateChildren() { + const { children } = this; + if (!Array.isArray(children) || !children.length) { + return Promise.resolve(); + } + return Promise.all(children.map((child) => child.updateFromParent())); + }, + onChange(child) { + const index = this.children.indexOf(child); + const active = child.data.name || index; + if (active !== this.data.active) { + this.$emit('change', active); + } + } + } +}); diff --git a/utils/dist/tabbar/index.json b/utils/dist/tabbar/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/utils/dist/tabbar/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/utils/dist/tabbar/index.wxml b/utils/dist/tabbar/index.wxml new file mode 100644 index 0000000..c49b9d9 --- /dev/null +++ b/utils/dist/tabbar/index.wxml @@ -0,0 +1,8 @@ + + + + + diff --git a/utils/dist/tabbar/index.wxss b/utils/dist/tabbar/index.wxss new file mode 100644 index 0000000..65fad1e --- /dev/null +++ b/utils/dist/tabbar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-tabbar{display:-webkit-flex;display:flex;width:100%;height:50px;height:var(--tabbar-height,50px);background-color:#fff;background-color:var(--tabbar-background-color,#fff)}.van-tabbar--fixed{position:fixed;bottom:0;left:0}.van-tabbar--safe{padding-bottom:env(safe-area-inset-bottom)} \ No newline at end of file diff --git a/utils/dist/tabs/index.d.ts b/utils/dist/tabs/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/tabs/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/tabs/index.js b/utils/dist/tabs/index.js new file mode 100644 index 0000000..8ba4002 --- /dev/null +++ b/utils/dist/tabs/index.js @@ -0,0 +1,289 @@ +import { VantComponent } from '../common/component'; +import { touch } from '../mixins/touch'; +import { isDef, addUnit } from '../common/utils'; +VantComponent({ + mixins: [touch], + classes: ['nav-class', 'tab-class', 'tab-active-class', 'line-class'], + relation: { + name: 'tab', + type: 'descendant', + linked(target) { + target.index = this.children.length; + this.children.push(target); + this.updateTabs(); + }, + unlinked(target) { + this.children = this.children + .filter((child) => child !== target) + .map((child, index) => { + child.index = index; + return child; + }); + this.updateTabs(); + } + }, + props: { + color: { + type: String, + observer: 'setLine' + }, + sticky: Boolean, + animated: { + type: Boolean, + observer() { + this.setTrack(); + this.children.forEach((child) => child.updateRender()); + } + }, + swipeable: Boolean, + lineWidth: { + type: [String, Number], + value: -1, + observer: 'setLine' + }, + lineHeight: { + type: [String, Number], + value: -1, + observer: 'setLine' + }, + titleActiveColor: String, + titleInactiveColor: String, + active: { + type: [String, Number], + value: 0, + observer(name) { + if (name !== this.getCurrentName()) { + this.setCurrentIndexByName(name); + } + } + }, + type: { + type: String, + value: 'line' + }, + border: { + type: Boolean, + value: true + }, + ellipsis: { + type: Boolean, + value: true + }, + duration: { + type: Number, + value: 0.3 + }, + zIndex: { + type: Number, + value: 1 + }, + swipeThreshold: { + type: Number, + value: 4, + observer(value) { + this.setData({ + scrollable: this.children.length > value || !this.data.ellipsis + }); + } + }, + offsetTop: { + type: Number, + value: 0 + }, + lazyRender: { + type: Boolean, + value: true + }, + }, + data: { + tabs: [], + lineStyle: '', + scrollLeft: 0, + scrollable: false, + trackStyle: '', + currentIndex: null, + container: null + }, + beforeCreate() { + this.children = []; + }, + mounted() { + this.setData({ + container: () => this.createSelectorQuery().select('.van-tabs') + }); + this.setLine(true); + this.setTrack(); + this.scrollIntoView(); + }, + methods: { + updateTabs() { + const { children = [], data } = this; + this.setData({ + tabs: children.map((child) => child.data), + scrollable: this.children.length > data.swipeThreshold || !data.ellipsis + }); + this.setCurrentIndexByName(this.getCurrentName() || data.active); + }, + trigger(eventName) { + const { currentIndex } = this.data; + const child = this.children[currentIndex]; + if (!isDef(child)) { + return; + } + this.$emit(eventName, { + index: currentIndex, + name: child.getComputedName(), + title: child.data.title + }); + }, + onTap(event) { + const { index } = event.currentTarget.dataset; + const child = this.children[index]; + if (child.data.disabled) { + this.trigger('disabled'); + } + else { + this.setCurrentIndex(index); + wx.nextTick(() => { + this.trigger('click'); + }); + } + }, + // correct the index of active tab + setCurrentIndexByName(name) { + const { children = [] } = this; + const matched = children.filter((child) => child.getComputedName() === name); + if (matched.length) { + this.setCurrentIndex(matched[0].index); + } + }, + setCurrentIndex(currentIndex) { + const { data, children = [] } = this; + if (!isDef(currentIndex) || + currentIndex >= children.length || + currentIndex < 0) { + return; + } + children.forEach((item, index) => { + const active = index === currentIndex; + if (active !== item.data.active || !item.inited) { + item.updateRender(active, this); + } + }); + if (currentIndex === data.currentIndex) { + return; + } + const shouldEmitChange = data.currentIndex !== null; + this.setData({ currentIndex }); + wx.nextTick(() => { + this.setLine(); + this.setTrack(); + this.scrollIntoView(); + this.trigger('input'); + if (shouldEmitChange) { + this.trigger('change'); + } + }); + }, + getCurrentName() { + const activeTab = this.children[this.data.currentIndex]; + if (activeTab) { + return activeTab.getComputedName(); + } + }, + setLine(skipTransition) { + if (this.data.type !== 'line') { + return; + } + const { color, duration, currentIndex, lineWidth, lineHeight } = this.data; + this.getRect('.van-tab', true).then((rects = []) => { + const rect = rects[currentIndex]; + if (rect == null) { + return; + } + const width = lineWidth !== -1 ? lineWidth : rect.width / 2; + const height = lineHeight !== -1 + ? `height: ${addUnit(lineHeight)}; border-radius: ${addUnit(lineHeight)};` + : ''; + let left = rects + .slice(0, currentIndex) + .reduce((prev, curr) => prev + curr.width, 0); + left += (rect.width - width) / 2; + const transition = skipTransition + ? '' + : `transition-duration: ${duration}s; -webkit-transition-duration: ${duration}s;`; + this.setData({ + lineStyle: ` + ${height} + width: ${addUnit(width)}; + background-color: ${color}; + -webkit-transform: translateX(${left}px); + transform: translateX(${left}px); + ${transition} + ` + }); + }); + }, + setTrack() { + const { animated, duration, currentIndex } = this.data; + if (!animated) { + return; + } + this.setData({ + trackStyle: ` + transform: translate3d(${-100 * currentIndex}%, 0, 0); + -webkit-transition-duration: ${duration}s; + transition-duration: ${duration}s; + ` + }); + }, + // scroll active tab into view + scrollIntoView() { + const { currentIndex, scrollable } = this.data; + if (!scrollable) { + return; + } + Promise.all([ + this.getRect('.van-tab', true), + this.getRect('.van-tabs__nav') + ]).then(([tabRects, navRect]) => { + const tabRect = tabRects[currentIndex]; + const offsetLeft = tabRects + .slice(0, currentIndex) + .reduce((prev, curr) => prev + curr.width, 0); + this.setData({ + scrollLeft: offsetLeft - (navRect.width - tabRect.width) / 2 + }); + }); + }, + onTouchScroll(event) { + this.$emit('scroll', event.detail); + }, + onTouchStart(event) { + if (!this.data.swipeable) + return; + this.touchStart(event); + }, + onTouchMove(event) { + if (!this.data.swipeable) + return; + this.touchMove(event); + }, + // watch swipe touch end + onTouchEnd() { + if (!this.data.swipeable) + return; + const { tabs, currentIndex } = this.data; + const { direction, deltaX, offsetX } = this; + const minSwipeDistance = 50; + if (direction === 'horizontal' && offsetX >= minSwipeDistance) { + if (deltaX > 0 && currentIndex !== 0) { + this.setCurrentIndex(currentIndex - 1); + } + else if (deltaX < 0 && currentIndex !== tabs.length - 1) { + this.setCurrentIndex(currentIndex + 1); + } + } + } + } +}); diff --git a/utils/dist/tabs/index.json b/utils/dist/tabs/index.json new file mode 100644 index 0000000..19c0bc3 --- /dev/null +++ b/utils/dist/tabs/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-info": "../info/index", + "van-sticky": "../sticky/index" + } +} diff --git a/utils/dist/tabs/index.wxml b/utils/dist/tabs/index.wxml new file mode 100644 index 0000000..ed8f0d9 --- /dev/null +++ b/utils/dist/tabs/index.wxml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + {{ item.title }} + + + + + + + + + + + + + + + + diff --git a/utils/dist/tabs/index.wxs b/utils/dist/tabs/index.wxs new file mode 100644 index 0000000..aa117ce --- /dev/null +++ b/utils/dist/tabs/index.wxs @@ -0,0 +1,55 @@ +/* eslint-disable */ +function tabClass(active, ellipsis) { + var classes = ['tab-class']; + + if (active) { + classes.push('tab-active-class'); + } + + if (ellipsis) { + classes.push('van-ellipsis'); + } + + return classes.join(' '); +} + +function tabStyle( + active, + ellipsis, + color, + type, + disabled, + activeColor, + inactiveColor, + swipeThreshold, + scrollable +) { + var styles = []; + var isCard = type === 'card'; + // card theme color + if (color && isCard) { + styles.push('border-color:' + color); + + if (!disabled) { + if (active) { + styles.push('background-color:' + color); + } else { + styles.push('color:' + color); + } + } + } + + var titleColor = active ? activeColor : inactiveColor; + if (titleColor) { + styles.push('color:' + titleColor); + } + + if (scrollable && ellipsis) { + styles.push('flex-basis:' + 88 / swipeThreshold + '%'); + } + + return styles.join(';'); +} + +module.exports.tabClass = tabClass; +module.exports.tabStyle = tabStyle; diff --git a/utils/dist/tabs/index.wxss b/utils/dist/tabs/index.wxss new file mode 100644 index 0000000..1bb6922 --- /dev/null +++ b/utils/dist/tabs/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-tabs{position:relative;-webkit-tap-highlight-color:transparent}.van-tabs__wrap{display:-webkit-flex;display:flex;overflow:hidden}.van-tabs__wrap--scrollable .van-tab{-webkit-flex:0 0 22%;flex:0 0 22%}.van-tabs__scroll{background-color:#fff;background-color:var(--tabs-nav-background-color,#fff)}.van-tabs__scroll--line{box-sizing:initial;height:calc(100% + 15px)}.van-tabs__scroll--card{margin:0 16px;margin:0 var(--padding-md,16px)}.van-tabs__nav{position:relative;display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none}.van-tabs__nav--card{box-sizing:border-box;height:30px;height:var(--tabs-card-height,30px);border:1px solid #ee0a24;border:var(--border-width-base,1px) solid var(--tabs-default-color,#ee0a24);border-radius:2px;border-radius:var(--border-radius-sm,2px)}.van-tabs__nav--card .van-tab{color:#ee0a24;color:var(--tabs-default-color,#ee0a24);line-height:28px;line-height:calc(var(--tabs-card-height, 30px) - 2*var(--border-width-base, 1px));border-right:1px solid #ee0a24;border-right:var(--border-width-base,1px) solid var(--tabs-default-color,#ee0a24)}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{color:#fff;color:var(--white,#fff);background-color:#ee0a24;background-color:var(--tabs-default-color,#ee0a24)}.van-tabs__nav--card .van-tab--disabled{color:#c8c9cc;color:var(--tab-disabled-text-color,#c8c9cc)}.van-tabs__line{position:absolute;bottom:0;left:0;z-index:1;height:3px;height:var(--tabs-bottom-bar-height,3px);border-radius:3px;border-radius:var(--tabs-bottom-bar-height,3px);background-color:#ee0a24;background-color:var(--tabs-bottom-bar-color,#ee0a24)}.van-tabs__track{position:relative;width:100%;height:100%}.van-tabs__track--animated{display:-webkit-flex;display:flex;transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform}.van-tabs__content{overflow:hidden}.van-tabs--line .van-tabs__wrap{height:44px;height:var(--tabs-line-height,44px)}.van-tabs--card .van-tabs__wrap{height:30px;height:var(--tabs-card-height,30px)}.van-tab{position:relative;-webkit-flex:1;flex:1;box-sizing:border-box;min-width:0;padding:0 5px;text-align:center;cursor:pointer;color:#646566;color:var(--tab-text-color,#646566);font-size:14px;font-size:var(--tab-font-size,14px);line-height:44px;line-height:var(--tabs-line-height,44px)}.van-tab--active{font-weight:500;font-weight:var(--font-weight-bold,500);color:#323233;color:var(--tab-active-text-color,#323233)}.van-tab--disabled{color:#c8c9cc;color:var(--tab-disabled-text-color,#c8c9cc)}.van-tab--complete{-webkit-flex:1 0 auto!important;flex:1 0 auto!important}.van-tab__title__info{position:relative!important;top:-1px!important;display:inline-block;-webkit-transform:translateX(0)!important;transform:translateX(0)!important} \ No newline at end of file diff --git a/utils/dist/tag/index.d.ts b/utils/dist/tag/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/tag/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/tag/index.js b/utils/dist/tag/index.js new file mode 100644 index 0000000..093acb5 --- /dev/null +++ b/utils/dist/tag/index.js @@ -0,0 +1,21 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + size: String, + mark: Boolean, + color: String, + plain: Boolean, + round: Boolean, + textColor: String, + type: { + type: String, + value: 'default' + }, + closeable: Boolean + }, + methods: { + onClose() { + this.$emit('close'); + } + } +}); diff --git a/utils/dist/tag/index.json b/utils/dist/tag/index.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/utils/dist/tag/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/utils/dist/tag/index.wxml b/utils/dist/tag/index.wxml new file mode 100644 index 0000000..8c78686 --- /dev/null +++ b/utils/dist/tag/index.wxml @@ -0,0 +1,14 @@ + + + + + + diff --git a/utils/dist/tag/index.wxss b/utils/dist/tag/index.wxss new file mode 100644 index 0000000..211e376 --- /dev/null +++ b/utils/dist/tag/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-tag{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;line-height:normal;padding:.2em .5em;padding:var(--tag-padding,.2em .5em);color:#fff;color:var(--tag-text-color,#fff);font-size:10px;font-size:var(--tag-font-size,10px);border-radius:.2em;border-radius:var(--tag-border-radius,.2em)}.van-tag:after{border-color:currentColor;border-radius:.2em * 2;border-radius:var(--tag-border-radius,.2em) * 2}.van-tag--default{background-color:#969799;background-color:var(--tag-default-color,#969799)}.van-tag--default.van-tag--plain{color:#969799;color:var(--tag-default-color,#969799)}.van-tag--danger{background-color:#ee0a24;background-color:var(--tag-dander-color,#ee0a24)}.van-tag--danger.van-tag--plain{color:#ee0a24;color:var(--tag-dander-color,#ee0a24)}.van-tag--primary{background-color:#1989fa;background-color:var(--tag-primary-color,#1989fa)}.van-tag--primary.van-tag--plain{color:#1989fa;color:var(--tag-primary-color,#1989fa)}.van-tag--success{background-color:#07c160;background-color:var(--tag-success-color,#07c160)}.van-tag--success.van-tag--plain{color:#07c160;color:var(--tag-success-color,#07c160)}.van-tag--warning{background-color:#ff976a;background-color:var(--tag-warning-color,#ff976a)}.van-tag--warning.van-tag--plain{color:#ff976a;color:var(--tag-warning-color,#ff976a)}.van-tag--plain{background-color:#fff;background-color:var(--tag-plain-background-color,#fff)}.van-tag--mark{padding-right:.7em}.van-tag--mark,.van-tag--mark:after{border-radius:0 999px 999px 0;border-radius:0 var(--tag-round-border-radius,999px) var(--tag-round-border-radius,999px) 0}.van-tag--round,.van-tag--round:after{border-radius:999px;border-radius:var(--tag-round-border-radius,999px)}.van-tag--medium{font-size:12px;font-size:var(--tag-medium-font-size,12px)}.van-tag--large{font-size:14px;font-size:var(--tag-large-font-size,14px)}.van-tag__close{margin-left:2px} \ No newline at end of file diff --git a/utils/dist/toast/index.d.ts b/utils/dist/toast/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/toast/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/toast/index.js b/utils/dist/toast/index.js new file mode 100644 index 0000000..a9fe162 --- /dev/null +++ b/utils/dist/toast/index.js @@ -0,0 +1,29 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + show: Boolean, + mask: Boolean, + message: String, + forbidClick: Boolean, + zIndex: { + type: Number, + value: 1000 + }, + type: { + type: String, + value: 'text' + }, + loadingType: { + type: String, + value: 'circular' + }, + position: { + type: String, + value: 'middle' + } + }, + methods: { + // for prevent touchmove + noop() { } + } +}); diff --git a/utils/dist/toast/index.json b/utils/dist/toast/index.json new file mode 100644 index 0000000..9b1b78c --- /dev/null +++ b/utils/dist/toast/index.json @@ -0,0 +1,9 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-loading": "../loading/index", + "van-overlay": "../overlay/index", + "van-transition": "../transition/index" + } +} diff --git a/utils/dist/toast/index.wxml b/utils/dist/toast/index.wxml new file mode 100644 index 0000000..635e7d6 --- /dev/null +++ b/utils/dist/toast/index.wxml @@ -0,0 +1,33 @@ + + + + + {{ message }} + + + + + + {{ message }} + + + + + diff --git a/utils/dist/toast/index.wxss b/utils/dist/toast/index.wxss new file mode 100644 index 0000000..da946c9 --- /dev/null +++ b/utils/dist/toast/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-toast{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:initial;color:#fff;color:var(--toast-text-color,#fff);font-size:14px;font-size:var(--toast-font-size,14px);line-height:20px;line-height:var(--toast-line-height,20px);white-space:pre-wrap;word-wrap:break-word;background-color:rgba(50,50,51,.88);background-color:var(--toast-background-color,rgba(50,50,51,.88));border-radius:4px;border-radius:var(--toast-border-radius,4px)}.van-toast__container{position:fixed;top:50%;left:50%;width:-webkit-fit-content;width:fit-content;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);max-width:70%;max-width:var(--toast-max-width,70%)}.van-toast--text{min-width:96px;min-width:var(--toast-text-min-width,96px);padding:8px 12px;padding:var(--toast-text-padding,8px 12px)}.van-toast--icon{width:90px;width:var(--toast-default-width,90px);min-height:90px;min-height:var(--toast-default-min-height,90px);padding:16px;padding:var(--toast-default-padding,16px)}.van-toast--icon .van-toast__icon{font-size:48px;font-size:var(--toast-icon-size,48px)}.van-toast--icon .van-toast__text{padding-top:8px}.van-toast__loading{margin:10px 0}.van-toast--top{-webkit-transform:translateY(-30vh);transform:translateY(-30vh)}.van-toast--bottom{-webkit-transform:translateY(30vh);transform:translateY(30vh)} \ No newline at end of file diff --git a/utils/dist/toast/toast.d.ts b/utils/dist/toast/toast.d.ts new file mode 100644 index 0000000..f7148a0 --- /dev/null +++ b/utils/dist/toast/toast.d.ts @@ -0,0 +1,26 @@ +/// +declare type ToastMessage = string | number; +interface ToastOptions { + show?: boolean; + type?: string; + mask?: boolean; + zIndex?: number; + context?: WechatMiniprogram.Component.TrivialInstance | WechatMiniprogram.Page.TrivialInstance; + position?: string; + duration?: number; + selector?: string; + forbidClick?: boolean; + loadingType?: string; + message?: ToastMessage; + onClose?: () => void; +} +declare function Toast(toastOptions: ToastOptions | ToastMessage): WechatMiniprogram.Component.TrivialInstance; +declare namespace Toast { + var loading: (options: string | number | ToastOptions) => WechatMiniprogram.Component.Instance, Record, Record>; + var success: (options: string | number | ToastOptions) => WechatMiniprogram.Component.Instance, Record, Record>; + var fail: (options: string | number | ToastOptions) => WechatMiniprogram.Component.Instance, Record, Record>; + var clear: () => void; + var setDefaultOptions: (options: ToastOptions) => void; + var resetDefaultOptions: () => void; +} +export default Toast; diff --git a/utils/dist/toast/toast.js b/utils/dist/toast/toast.js new file mode 100644 index 0000000..ed5a894 --- /dev/null +++ b/utils/dist/toast/toast.js @@ -0,0 +1,66 @@ +import { isObj } from '../common/utils'; +const defaultOptions = { + type: 'text', + mask: false, + message: '', + show: true, + zIndex: 1000, + duration: 2000, + position: 'middle', + forbidClick: false, + loadingType: 'circular', + selector: '#van-toast' +}; +let queue = []; +let currentOptions = Object.assign({}, defaultOptions); +function parseOptions(message) { + return isObj(message) ? message : { message }; +} +function getContext() { + const pages = getCurrentPages(); + return pages[pages.length - 1]; +} +function Toast(toastOptions) { + const options = Object.assign(Object.assign({}, currentOptions), parseOptions(toastOptions)); + const context = options.context || getContext(); + const toast = context.selectComponent(options.selector); + if (!toast) { + console.warn('未找到 van-toast 节点,请确认 selector 及 context 是否正确'); + return; + } + delete options.context; + delete options.selector; + toast.clear = () => { + toast.setData({ show: false }); + if (options.onClose) { + options.onClose(); + } + }; + queue.push(toast); + toast.setData(options); + clearTimeout(toast.timer); + if (options.duration > 0) { + toast.timer = setTimeout(() => { + toast.clear(); + queue = queue.filter(item => item !== toast); + }, options.duration); + } + return toast; +} +const createMethod = (type) => (options) => Toast(Object.assign({ type }, parseOptions(options))); +Toast.loading = createMethod('loading'); +Toast.success = createMethod('success'); +Toast.fail = createMethod('fail'); +Toast.clear = () => { + queue.forEach(toast => { + toast.clear(); + }); + queue = []; +}; +Toast.setDefaultOptions = (options) => { + Object.assign(currentOptions, options); +}; +Toast.resetDefaultOptions = () => { + currentOptions = Object.assign({}, defaultOptions); +}; +export default Toast; diff --git a/utils/dist/transition/index.d.ts b/utils/dist/transition/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/transition/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/transition/index.js b/utils/dist/transition/index.js new file mode 100644 index 0000000..a920f1f --- /dev/null +++ b/utils/dist/transition/index.js @@ -0,0 +1,13 @@ +import { VantComponent } from '../common/component'; +import { transition } from '../mixins/transition'; +VantComponent({ + classes: [ + 'enter-class', + 'enter-active-class', + 'enter-to-class', + 'leave-class', + 'leave-active-class', + 'leave-to-class' + ], + mixins: [transition(true)] +}); diff --git a/utils/dist/transition/index.json b/utils/dist/transition/index.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/utils/dist/transition/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/utils/dist/transition/index.wxml b/utils/dist/transition/index.wxml new file mode 100644 index 0000000..412e8af --- /dev/null +++ b/utils/dist/transition/index.wxml @@ -0,0 +1,8 @@ + + + diff --git a/utils/dist/transition/index.wxss b/utils/dist/transition/index.wxss new file mode 100644 index 0000000..d459f5c --- /dev/null +++ b/utils/dist/transition/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-transition{transition-timing-function:ease}.van-fade-enter-active,.van-fade-leave-active{transition-property:opacity}.van-fade-enter,.van-fade-leave-to{opacity:0}.van-fade-down-enter-active,.van-fade-down-leave-active,.van-fade-left-enter-active,.van-fade-left-leave-active,.van-fade-right-enter-active,.van-fade-right-leave-active,.van-fade-up-enter-active,.van-fade-up-leave-active{transition-property:opacity,-webkit-transform;transition-property:opacity,transform;transition-property:opacity,transform,-webkit-transform}.van-fade-up-enter,.van-fade-up-leave-to{-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0);opacity:0}.van-fade-down-enter,.van-fade-down-leave-to{-webkit-transform:translate3d(0,-100%,0);transform:translate3d(0,-100%,0);opacity:0}.van-fade-left-enter,.van-fade-left-leave-to{-webkit-transform:translate3d(-100%,0,0);transform:translate3d(-100%,0,0);opacity:0}.van-fade-right-enter,.van-fade-right-leave-to{-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0);opacity:0}.van-slide-down-enter-active,.van-slide-down-leave-active,.van-slide-left-enter-active,.van-slide-left-leave-active,.van-slide-right-enter-active,.van-slide-right-leave-active,.van-slide-up-enter-active,.van-slide-up-leave-active{transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform}.van-slide-up-enter,.van-slide-up-leave-to{-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0)}.van-slide-down-enter,.van-slide-down-leave-to{-webkit-transform:translate3d(0,-100%,0);transform:translate3d(0,-100%,0)}.van-slide-left-enter,.van-slide-left-leave-to{-webkit-transform:translate3d(-100%,0,0);transform:translate3d(-100%,0,0)}.van-slide-right-enter,.van-slide-right-leave-to{-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0)} \ No newline at end of file diff --git a/utils/dist/tree-select/index.d.ts b/utils/dist/tree-select/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/tree-select/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/tree-select/index.js b/utils/dist/tree-select/index.js new file mode 100644 index 0000000..bf82410 --- /dev/null +++ b/utils/dist/tree-select/index.js @@ -0,0 +1,74 @@ +import { VantComponent } from '../common/component'; +import { addUnit } from '../common/utils'; +VantComponent({ + classes: [ + 'main-item-class', + 'content-item-class', + 'main-active-class', + 'content-active-class', + 'main-disabled-class', + 'content-disabled-class' + ], + props: { + items: { + type: Array, + observer: 'updateSubItems' + }, + activeId: null, + mainActiveIndex: { + type: Number, + value: 0, + observer: 'updateSubItems' + }, + height: { + type: [Number, String], + value: 300, + observer: 'updateHeight' + }, + max: { + type: Number, + value: Infinity + } + }, + data: { + subItems: [] + }, + created() { + this.updateHeight(); + }, + methods: { + // 当一个子项被选择时 + onSelectItem(event) { + const { item } = event.currentTarget.dataset; + const isArray = Array.isArray(this.data.activeId); + // 判断有没有超出右侧选择的最大数 + const isOverMax = isArray && this.data.activeId.length >= this.data.max; + // 判断该项有没有被选中, 如果有被选中,则忽视是否超出的条件 + const isSelected = isArray + ? this.data.activeId.indexOf(item.id) > -1 + : this.data.activeId === item.id; + if (!item.disabled && (!isOverMax || isSelected)) { + this.$emit('click-item', item); + } + }, + // 当一个导航被点击时 + onClickNav(event) { + const index = event.detail; + const item = this.data.items[index]; + if (!item.disabled) { + this.$emit('click-nav', { index }); + } + }, + // 更新子项列表 + updateSubItems() { + const { items, mainActiveIndex } = this.data; + const { children = [] } = items[mainActiveIndex] || {}; + return this.set({ subItems: children }); + }, + updateHeight() { + this.setData({ + innerHeight: addUnit(this.data.height) + }); + } + } +}); diff --git a/utils/dist/tree-select/index.json b/utils/dist/tree-select/index.json new file mode 100644 index 0000000..42991a2 --- /dev/null +++ b/utils/dist/tree-select/index.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-sidebar": "../sidebar/index", + "van-sidebar-item": "../sidebar-item/index" + } +} diff --git a/utils/dist/tree-select/index.wxml b/utils/dist/tree-select/index.wxml new file mode 100644 index 0000000..d6f95a8 --- /dev/null +++ b/utils/dist/tree-select/index.wxml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + {{ item.text }} + + + + diff --git a/utils/dist/tree-select/index.wxs b/utils/dist/tree-select/index.wxs new file mode 100644 index 0000000..b1cbb39 --- /dev/null +++ b/utils/dist/tree-select/index.wxs @@ -0,0 +1,12 @@ +/* eslint-disable */ +var array = require('../wxs/array.wxs'); + +function isActive (activeList, itemId) { + if (array.isArray(activeList)) { + return activeList.indexOf(itemId) > -1; + } + + return activeList === itemId; +} + +module.exports.isActive = isActive; diff --git a/utils/dist/tree-select/index.wxss b/utils/dist/tree-select/index.wxss new file mode 100644 index 0000000..654e55a --- /dev/null +++ b/utils/dist/tree-select/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-tree-select{position:relative;display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none;font-size:14px;font-size:var(--tree-select-font-size,14px)}.van-tree-select__nav{-webkit-flex:1;flex:1;background-color:#fafafa;background-color:var(--tree-select-nav-background-color,#fafafa);--sidebar-padding:12px 8px 12px 12px}.van-tree-select__nav__inner{width:100%!important;height:100%}.van-tree-select__content{-webkit-flex:2;flex:2;background-color:#fff;background-color:var(--tree-select-content-background-color,#fff)}.van-tree-select__item{position:relative;font-weight:700;padding:0 32px 0 16px;padding:0 32px 0 var(--padding-md,16px);line-height:44px;line-height:var(--tree-select-item-height,44px)}.van-tree-select__item--active{color:#ee0a24;color:var(--tree-select-item-active-color,#ee0a24)}.van-tree-select__item--disabled{color:#c8c9cc;color:var(--tree-select-item-disabled-color,#c8c9cc)}.van-tree-select__selected{position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);right:16px;right:var(--padding-md,16px)} \ No newline at end of file diff --git a/utils/dist/uploader/index.d.ts b/utils/dist/uploader/index.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/utils/dist/uploader/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/utils/dist/uploader/index.js b/utils/dist/uploader/index.js new file mode 100644 index 0000000..9cc5def --- /dev/null +++ b/utils/dist/uploader/index.js @@ -0,0 +1,151 @@ +import { VantComponent } from '../common/component'; +import { isImageFile } from './utils'; +import { addUnit } from '../common/utils'; +VantComponent({ + props: { + disabled: Boolean, + multiple: Boolean, + uploadText: String, + useSlot: Boolean, + useBeforeRead: Boolean, + previewSize: { + type: null, + value: 90, + observer: 'setComputedPreviewSize' + }, + name: { + type: [Number, String], + value: '' + }, + accept: { + type: String, + value: 'image' + }, + fileList: { + type: Array, + value: [], + observer: 'formatFileList' + }, + maxSize: { + type: Number, + value: Number.MAX_VALUE + }, + maxCount: { + type: Number, + value: 100 + }, + deletable: { + type: Boolean, + value: true + }, + previewImage: { + type: Boolean, + value: true + }, + previewFullImage: { + type: Boolean, + value: true + }, + imageFit: { + type: String, + value: 'scaleToFill' + } + }, + data: { + lists: [], + computedPreviewSize: '', + isInCount: true + }, + methods: { + formatFileList() { + const { fileList = [], maxCount } = this.data; + const lists = fileList.map(item => (Object.assign(Object.assign({}, item), { isImage: typeof item.isImage === 'undefined' ? isImageFile(item) : item.isImage }))); + this.setData({ lists, isInCount: lists.length < maxCount }); + }, + setComputedPreviewSize(val) { + this.setData({ + computedPreviewSize: addUnit(val) + }); + }, + startUpload() { + if (this.data.disabled) + return; + const { name = '', capture = ['album', 'camera'], maxCount = 100, multiple = false, maxSize, accept, lists, useBeforeRead = false // 是否定义了 beforeRead + } = this.data; + let chooseFile = null; + const newMaxCount = maxCount - lists.length; + // 设置为只选择图片的时候使用 chooseImage 来实现 + if (accept === 'image') { + chooseFile = new Promise((resolve, reject) => { + wx.chooseImage({ + count: multiple ? (newMaxCount > 9 ? 9 : newMaxCount) : 1, + sourceType: capture, + success: resolve, + fail: reject + }); + }); + } + else { + chooseFile = new Promise((resolve, reject) => { + wx.chooseMessageFile({ + count: multiple ? newMaxCount : 1, + type: 'file', + success: resolve, + fail: reject + }); + }); + } + chooseFile.then((res) => { + const file = multiple ? res.tempFiles : res.tempFiles[0]; + // 检查文件大小 + if (file instanceof Array) { + const sizeEnable = file.every(item => item.size <= maxSize); + if (!sizeEnable) { + this.$emit('oversize', { name }); + return; + } + } + else if (file.size > maxSize) { + this.$emit('oversize', { name }); + return; + } + // 触发上传之前的钩子函数 + if (useBeforeRead) { + this.$emit('before-read', { + file, + name, + callback: (result) => { + if (result) { + // 开始上传 + this.$emit('after-read', { file, name }); + } + } + }); + } + else { + this.$emit('after-read', { file, name }); + } + }); + }, + deleteItem(event) { + const { index } = event.currentTarget.dataset; + this.$emit('delete', { index, name: this.data.name }); + }, + doPreviewImage(event) { + if (!this.data.previewFullImage) + return; + const curUrl = event.currentTarget.dataset.url; + const images = this.data.lists + .filter(item => item.isImage) + .map(item => item.url || item.path); + this.$emit('click-preview', { url: curUrl, name: this.data.name }); + wx.previewImage({ + urls: images, + current: curUrl, + fail() { + wx.showToast({ title: '预览图片失败', icon: 'none' }); + } + }); + } + } +}); diff --git a/utils/dist/uploader/index.json b/utils/dist/uploader/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/utils/dist/uploader/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/utils/dist/uploader/index.wxml b/utils/dist/uploader/index.wxml new file mode 100644 index 0000000..02546aa --- /dev/null +++ b/utils/dist/uploader/index.wxml @@ -0,0 +1,57 @@ + + + + + + + {{ item.name || ('图片' + index) }} + + + {{ item.name || item.url || item.path }} + + + + + + + + + + + + + + {{ uploadText }} + + + + diff --git a/utils/dist/uploader/index.wxss b/utils/dist/uploader/index.wxss new file mode 100644 index 0000000..ed70582 --- /dev/null +++ b/utils/dist/uploader/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-uploader{position:relative;display:inline-block}.van-uploader__wrapper{display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap}.van-uploader__upload{position:relative;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:80px;height:80px;margin:0 8px 8px 0;background-color:#fff;border:1px dashed #ebedf0;border-radius:4px}.van-uploader__upload-icon{display:inline-block;width:24px;height:24px;color:#969799;font-size:24px}.van-uploader__upload-text{margin-top:8px;color:#969799;font-size:12px}.van-uploader__preview{position:relative;margin:0 8px 8px 0}.van-uploader__preview-image{display:block;width:80px;height:80px;border-radius:4px}.van-uploader__preview-delete{position:absolute;top:-8px;right:-8px;color:#969799;font-size:18px;background-color:#fff;border-radius:100%}.van-uploader__file{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;width:80px;height:80px;background-color:#f7f8fa;border-radius:4px}.van-uploader__file-icon{display:inline-block;width:20px;height:20px;color:#646566;font-size:20px}.van-uploader__file-name{box-sizing:border-box;width:100%;margin-top:8px;padding:0 5px;color:#646566;font-size:12px;text-align:center} \ No newline at end of file diff --git a/utils/dist/uploader/utils.d.ts b/utils/dist/uploader/utils.d.ts new file mode 100644 index 0000000..d3bb3b5 --- /dev/null +++ b/utils/dist/uploader/utils.d.ts @@ -0,0 +1,12 @@ +interface File { + path: string; + url: string; + size: number; + name: string; + type: string; + time: number; + image: boolean; +} +export declare function isImageUrl(url: string): boolean; +export declare function isImageFile(item: File): boolean; +export {}; diff --git a/utils/dist/uploader/utils.js b/utils/dist/uploader/utils.js new file mode 100644 index 0000000..aa59dc1 --- /dev/null +++ b/utils/dist/uploader/utils.js @@ -0,0 +1,16 @@ +const IMAGE_EXT = ['jpeg', 'jpg', 'gif', 'png', 'svg']; +export function isImageUrl(url) { + return IMAGE_EXT.some(ext => url.indexOf(`.${ext}`) !== -1); +} +export function isImageFile(item) { + if (item.type) { + return item.type.indexOf('image') === 0; + } + if (item.path) { + return isImageUrl(item.path); + } + if (item.url) { + return isImageUrl(item.url); + } + return false; +} diff --git a/utils/dist/wxs/array.wxs b/utils/dist/wxs/array.wxs new file mode 100644 index 0000000..610089c --- /dev/null +++ b/utils/dist/wxs/array.wxs @@ -0,0 +1,5 @@ +function isArray(array) { + return array && array.constructor === 'Array'; +} + +module.exports.isArray = isArray; diff --git a/utils/dist/wxs/bem.wxs b/utils/dist/wxs/bem.wxs new file mode 100644 index 0000000..93b2777 --- /dev/null +++ b/utils/dist/wxs/bem.wxs @@ -0,0 +1,38 @@ +var array = require('./array.wxs'); +var object = require('./object.wxs'); +var PREFIX = 'van-'; + +function join(name, mods) { + name = PREFIX + name; + mods = mods.map(function(mod) { + return name + '--' + mod; + }); + mods.unshift(name); + return mods.join(' '); +} + +function traversing(mods, conf) { + if (!conf) { + return; + } + + if (typeof conf === 'string' || typeof conf === 'number') { + mods.push(conf); + } else if (array.isArray(conf)) { + conf.forEach(function(item) { + traversing(mods, item); + }); + } else if (typeof conf === 'object') { + object.keys(conf).forEach(function(key) { + conf[key] && mods.push(key); + }); + } +} + +function bem(name, conf) { + var mods = []; + traversing(mods, conf); + return join(name, mods); +} + +module.exports.bem = bem; diff --git a/utils/dist/wxs/memoize.wxs b/utils/dist/wxs/memoize.wxs new file mode 100644 index 0000000..261ae67 --- /dev/null +++ b/utils/dist/wxs/memoize.wxs @@ -0,0 +1,54 @@ +/** + * Simple memoize + * wxs doesn't support fn.apply, so this memoize only support up to 2 args + */ + +function isPrimitive(value) { + var type = typeof value; + return ( + type === 'boolean' || + type === 'number' || + type === 'string' || + type === 'undefined' || + value === null + ); +} + +// mock simple fn.call in wxs +function call(fn, args) { + if (args.length === 2) { + return fn(args[0], args[1]); + } + + if (args.length === 1) { + return fn(args[0]); + } + + return fn(); +} + +function serializer(args) { + if (args.length === 1 && isPrimitive(args[0])) { + return args[0]; + } + var obj = {}; + for (var i = 0; i < args.length; i++) { + obj['key' + i] = args[i]; + } + return JSON.stringify(obj); +} + +function memoize(fn) { + var cache = {}; + + return function() { + var key = serializer(arguments); + if (cache[key] === undefined) { + cache[key] = call(fn, arguments); + } + + return cache[key]; + }; +} + +module.exports.memoize = memoize; diff --git a/utils/dist/wxs/object.wxs b/utils/dist/wxs/object.wxs new file mode 100644 index 0000000..e077107 --- /dev/null +++ b/utils/dist/wxs/object.wxs @@ -0,0 +1,13 @@ +/* eslint-disable */ +var REGEXP = getRegExp('{|}|"', 'g'); + +function keys(obj) { + return JSON.stringify(obj) + .replace(REGEXP, '') + .split(',') + .map(function(item) { + return item.split(':')[0]; + }); +} + +module.exports.keys = keys; diff --git a/utils/dist/wxs/utils.wxs b/utils/dist/wxs/utils.wxs new file mode 100644 index 0000000..a18662d --- /dev/null +++ b/utils/dist/wxs/utils.wxs @@ -0,0 +1,7 @@ +var bem = require('./bem.wxs').bem; +var memoize = require('./memoize.wxs').memoize; + +module.exports = { + bem: memoize(bem), + memoize: memoize +}; From f625f398c7bcf6f827000d0a457f9e5bcac49bba Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Sat, 14 Dec 2019 09:57:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + app.json | 1 + pages/order/order.js | 66 +++++++++++++++++++ pages/order/order.json | 6 ++ pages/order/order.scss | 92 +++++++++++++++++++++++++++ pages/order/order.wxml | 141 +++++++++++++++++++++++++++++++++++++++++ pages/order/order.wxss | 1 + 7 files changed, 308 insertions(+) create mode 100644 pages/order/order.js create mode 100644 pages/order/order.json create mode 100644 pages/order/order.scss create mode 100644 pages/order/order.wxml create mode 100644 pages/order/order.wxss diff --git a/README.md b/README.md index 5d30550..048a2f6 100644 --- a/README.md +++ b/README.md @@ -33,3 +33,4 @@ - orderconfirm/chooseway 选择方式 - orderconfirm/ordershopinfo 顶部的商品信息 - orderconfirm/orderyf 运费 + - pages/order/order 订单列表 diff --git a/app.json b/app.json index 772589e..9441bb2 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,6 @@ { "pages": [ + "pages/order/order", "pages/orderconfirm/orderconfirm", "pages/message/message", "pages/personal/personal", diff --git a/pages/order/order.js b/pages/order/order.js new file mode 100644 index 0000000..8e1eeab --- /dev/null +++ b/pages/order/order.js @@ -0,0 +1,66 @@ +// pages/order/order.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/order/order.json b/pages/order/order.json new file mode 100644 index 0000000..bb72bac --- /dev/null +++ b/pages/order/order.json @@ -0,0 +1,6 @@ +{ + "usingComponents": { + "van-tab": "../utils/dist/tab/index", + "van-tabs": "../utils/dist/tabs/index" + } +} \ No newline at end of file diff --git a/pages/order/order.scss b/pages/order/order.scss new file mode 100644 index 0000000..f2e63ec --- /dev/null +++ b/pages/order/order.scss @@ -0,0 +1,92 @@ +.box { + display: flex; + flex-direction: column; + align-items: center; + .tab { + width: 100%; + .commodity { + margin-top: 20rpx; + background-color: #fff; + .message { + padding: 35rpx; + display: flex; + align-items: center; + border-bottom: 1rpx solid #F2F2F2; + .image { + width: 141rpx; + height: 150rpx; + background-color: #000; + margin-left: 34rpx; + } + .introduce { + margin-left: 32rpx; + height: 120rpx; + display: flex; + flex-direction: column; + justify-content: space-between; + width: 362rpx; + .title { + font-size: 28rpx; + color: #333; + } + .count { + font-size: 24rpx; + color: #999; + display: flex; + > view { + margin-right: 27rpx; + } + } + } + .parameter { + width: 150rpx; + height: 120rpx; + display: flex; + flex-direction: column; + justify-content: space-between; + align-items: flex-end; + } + } + .aggregate{ + display: flex; + box-sizing: border-box; + padding: 30rpx; + justify-content: flex-end; + font-size: 22rpx; + color: #999; + height: 78rpx; + border-bottom: 1rpx solid #F2F2F2; + + >text{ + color: #333; + margin: 0 5rpx; + } + } + .operation{ + height: 84rpx; + display: flex; + justify-content: flex-end; + padding:0 30rpx; + align-items: center; + .button{ + width: 133rpx; + height: 51rpx; + border:2rpx solid #999999; + border-radius: 26rpx; + text-align: center; + font-size: 22rpx; + color:#999999; + line-height: 51rpx; + margin-right: 8rpx; + } + .hlight{ + border:2rpx solid rgba(71,200,119,1); + color: #47C877; + } + } + } + } +} +page { + background-color: #efefef; +} diff --git a/pages/order/order.wxml b/pages/order/order.wxml new file mode 100644 index 0000000..2d3df92 --- /dev/null +++ b/pages/order/order.wxml @@ -0,0 +1,141 @@ + + + + + + + + 001|德国双心药房版 胶原蛋白美容口服液养颜 + + 30只 + 1.0356kg + + + + ¥29.80 + x2 + + + + 共计1件商品 合计: + ¥29.80 + (含运费¥0.00) + + + 评价 + + 评价 + + + + + + + + + 001|德国双心药房版 胶原蛋白美容口服液养颜 + + 30只 + 1.0356kg + + + + ¥29.80 + x2 + + + + 共计1件商品 合计: + ¥29.80 + (含运费¥0.00) + + + 评价 + + 评价 + + + + + + + + 001|德国双心药房版 胶原蛋白美容口服液养颜 + + 30只 + 1.0356kg + + + + ¥29.80 + x2 + + + + 共计1件商品 合计: + ¥29.80 + (含运费¥0.00) + + + 评价 + + 评价 + + + + + + + + 001|德国双心药房版 胶原蛋白美容口服液养颜 + + 30只 + 1.0356kg + + + + ¥29.80 + x2 + + + + 共计1件商品 合计: + ¥29.80 + (含运费¥0.00) + + + 评价 + + 评价 + + + + + + + + 001|德国双心药房版 胶原蛋白美容口服液养颜 + + 30只 + 1.0356kg + + + + ¥29.80 + x2 + + + + 共计1件商品 合计: + ¥29.80 + (含运费¥0.00) + + + 评价 + + 评价 + + + + + \ No newline at end of file diff --git a/pages/order/order.wxss b/pages/order/order.wxss new file mode 100644 index 0000000..25f60da --- /dev/null +++ b/pages/order/order.wxss @@ -0,0 +1 @@ +.box{display:flex;flex-direction:column;align-items:center}.box .tab{width:100%}.box .tab .commodity{margin-top:20rpx;background-color:#fff}.box .tab .commodity .message{padding:35rpx;display:flex;align-items:center;border-bottom:1rpx solid #F2F2F2}.box .tab .commodity .message .image{width:141rpx;height:150rpx;background-color:#000;margin-left:34rpx}.box .tab .commodity .message .introduce{margin-left:32rpx;height:120rpx;display:flex;flex-direction:column;justify-content:space-between;width:362rpx}.box .tab .commodity .message .introduce .title{font-size:28rpx;color:#333}.box .tab .commodity .message .introduce .count{font-size:24rpx;color:#999;display:flex}.box .tab .commodity .message .introduce .count>view{margin-right:27rpx}.box .tab .commodity .message .parameter{width:150rpx;height:120rpx;display:flex;flex-direction:column;justify-content:space-between;align-items:flex-end}.box .tab .commodity .aggregate{display:flex;box-sizing:border-box;padding:30rpx;justify-content:flex-end;font-size:22rpx;color:#999;height:78rpx;border-bottom:1rpx solid #F2F2F2}.box .tab .commodity .aggregate>text{color:#333;margin:0 5rpx}.box .tab .commodity .operation{height:84rpx;display:flex;justify-content:flex-end;padding:0 30rpx;align-items:center}.box .tab .commodity .operation .button{width:133rpx;height:51rpx;border:2rpx solid #999999;border-radius:26rpx;text-align:center;font-size:22rpx;color:#999999;line-height:51rpx;margin-right:8rpx}.box .tab .commodity .operation .hlight{border:2rpx solid #47c877;color:#47C877}page{background-color:#efefef} From 10d81f738daab1da5e8b384a3ef13835f40ab294 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Sat, 14 Dec 2019 10:25:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +- components/order/commodity/index.js | 8 ++ components/order/commodity/index.json | 6 ++ components/order/commodity/index.scss | 81 +++++++++++++++ components/order/commodity/index.wxml | 14 +++ components/order/commodity/index.wxss | 1 + components/order/message/index.js | 8 ++ components/order/message/index.json | 3 + components/order/message/index.scss | 40 ++++++++ components/order/message/index.wxml | 14 +++ components/order/message/index.wxss | 1 + components/order/tab/index.js | 8 ++ components/order/tab/index.json | 8 ++ components/order/tab/index.scss | 3 + components/order/tab/index.wxml | 9 ++ components/order/tab/index.wxss | 1 + pages/order/order.json | 3 +- pages/order/order.scss | 85 +--------------- pages/order/order.wxml | 140 +------------------------- pages/order/order.wxss | 2 +- 20 files changed, 214 insertions(+), 227 deletions(-) create mode 100644 components/order/commodity/index.js create mode 100644 components/order/commodity/index.json create mode 100644 components/order/commodity/index.scss create mode 100644 components/order/commodity/index.wxml create mode 100644 components/order/commodity/index.wxss create mode 100644 components/order/message/index.js create mode 100644 components/order/message/index.json create mode 100644 components/order/message/index.scss create mode 100644 components/order/message/index.wxml create mode 100644 components/order/message/index.wxss create mode 100644 components/order/tab/index.js create mode 100644 components/order/tab/index.json create mode 100644 components/order/tab/index.scss create mode 100644 components/order/tab/index.wxml create mode 100644 components/order/tab/index.wxss diff --git a/README.md b/README.md index 048a2f6..82b7dd4 100644 --- a/README.md +++ b/README.md @@ -33,4 +33,8 @@ - orderconfirm/chooseway 选择方式 - orderconfirm/ordershopinfo 顶部的商品信息 - orderconfirm/orderyf 运费 - - pages/order/order 订单列表 +- pages/order/order 订单列表
+ 组件 + - order/tab 切换列表 + - order/commodity 商品信息操作 + - order/message 商品信息 diff --git a/components/order/commodity/index.js b/components/order/commodity/index.js new file mode 100644 index 0000000..9f59aa7 --- /dev/null +++ b/components/order/commodity/index.js @@ -0,0 +1,8 @@ +Component({ + properties: { + }, + data: { + }, + methods: { + } +}) \ No newline at end of file diff --git a/components/order/commodity/index.json b/components/order/commodity/index.json new file mode 100644 index 0000000..9800f6a --- /dev/null +++ b/components/order/commodity/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "message":"../message/index" + } +} \ No newline at end of file diff --git a/components/order/commodity/index.scss b/components/order/commodity/index.scss new file mode 100644 index 0000000..e558039 --- /dev/null +++ b/components/order/commodity/index.scss @@ -0,0 +1,81 @@ +.commodity { + margin-top: 20rpx; + background-color: #fff; + .message { + padding: 35rpx; + display: flex; + align-items: center; + border-bottom: 1rpx solid #F2F2F2; + .image { + width: 141rpx; + height: 150rpx; + background-color: #000; + margin-left: 34rpx; + } + .introduce { + margin-left: 32rpx; + height: 120rpx; + display: flex; + flex-direction: column; + justify-content: space-between; + width: 362rpx; + .title { + font-size: 28rpx; + color: #333; + } + .count { + font-size: 24rpx; + color: #999; + display: flex; + > view { + margin-right: 27rpx; + } + } + } + .parameter { + width: 150rpx; + height: 120rpx; + display: flex; + flex-direction: column; + justify-content: space-between; + align-items: flex-end; + } + } + .aggregate{ + display: flex; + box-sizing: border-box; + padding: 30rpx; + justify-content: flex-end; + font-size: 22rpx; + color: #999; + height: 78rpx; + border-bottom: 1rpx solid #F2F2F2; + + >text{ + color: #333; + margin: 0 5rpx; + } + } + .operation{ + height: 84rpx; + display: flex; + justify-content: flex-end; + padding:0 30rpx; + align-items: center; + .button{ + width: 133rpx; + height: 51rpx; + border:2rpx solid #999999; + border-radius: 26rpx; + text-align: center; + font-size: 22rpx; + color:#999999; + line-height: 51rpx; + margin-right: 8rpx; + } + .hlight{ + border:2rpx solid rgba(71,200,119,1); + color: #47C877; + } + } +} \ No newline at end of file diff --git a/components/order/commodity/index.wxml b/components/order/commodity/index.wxml new file mode 100644 index 0000000..e7264f2 --- /dev/null +++ b/components/order/commodity/index.wxml @@ -0,0 +1,14 @@ + + + + 共计1件商品 合计: + ¥29.80 + (含运费¥0.00) + + + 评价 + + 评价 + + + \ No newline at end of file diff --git a/components/order/commodity/index.wxss b/components/order/commodity/index.wxss new file mode 100644 index 0000000..e025d4a --- /dev/null +++ b/components/order/commodity/index.wxss @@ -0,0 +1 @@ +.commodity{margin-top:20rpx;background-color:#fff}.commodity .message{padding:35rpx;display:flex;align-items:center;border-bottom:1rpx solid #F2F2F2}.commodity .message .image{width:141rpx;height:150rpx;background-color:#000;margin-left:34rpx}.commodity .message .introduce{margin-left:32rpx;height:120rpx;display:flex;flex-direction:column;justify-content:space-between;width:362rpx}.commodity .message .introduce .title{font-size:28rpx;color:#333}.commodity .message .introduce .count{font-size:24rpx;color:#999;display:flex}.commodity .message .introduce .count>view{margin-right:27rpx}.commodity .message .parameter{width:150rpx;height:120rpx;display:flex;flex-direction:column;justify-content:space-between;align-items:flex-end}.commodity .aggregate{display:flex;box-sizing:border-box;padding:30rpx;justify-content:flex-end;font-size:22rpx;color:#999;height:78rpx;border-bottom:1rpx solid #F2F2F2}.commodity .aggregate>text{color:#333;margin:0 5rpx}.commodity .operation{height:84rpx;display:flex;justify-content:flex-end;padding:0 30rpx;align-items:center}.commodity .operation .button{width:133rpx;height:51rpx;border:2rpx solid #999999;border-radius:26rpx;text-align:center;font-size:22rpx;color:#999999;line-height:51rpx;margin-right:8rpx}.commodity .operation .hlight{border:2rpx solid #47c877;color:#47C877} diff --git a/components/order/message/index.js b/components/order/message/index.js new file mode 100644 index 0000000..9f59aa7 --- /dev/null +++ b/components/order/message/index.js @@ -0,0 +1,8 @@ +Component({ + properties: { + }, + data: { + }, + methods: { + } +}) \ No newline at end of file diff --git a/components/order/message/index.json b/components/order/message/index.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/components/order/message/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/components/order/message/index.scss b/components/order/message/index.scss new file mode 100644 index 0000000..cfa585f --- /dev/null +++ b/components/order/message/index.scss @@ -0,0 +1,40 @@ +.message { + padding: 35rpx; +display: flex; +align-items: center; +border-bottom: 1rpx solid #F2F2F2; +.image { + width: 141rpx; + height: 150rpx; + background-color: #000; + margin-left: 34rpx; +} +.introduce { + margin-left: 32rpx; + height: 120rpx; + display: flex; + flex-direction: column; + justify-content: space-between; + width: 362rpx; + .title { + font-size: 28rpx; + color: #333; + } + .count { + font-size: 24rpx; + color: #999; + display: flex; + > view { + margin-right: 27rpx; + } + } +} +.parameter { + width: 150rpx; + height: 120rpx; + display: flex; + flex-direction: column; + justify-content: space-between; + align-items: flex-end; +} +} \ No newline at end of file diff --git a/components/order/message/index.wxml b/components/order/message/index.wxml new file mode 100644 index 0000000..055d05c --- /dev/null +++ b/components/order/message/index.wxml @@ -0,0 +1,14 @@ + + + + 001|德国双心药房版 胶原蛋白美容口服液养颜 + + 30只 + 1.0356kg + + + + ¥29.80 + x2 + + \ No newline at end of file diff --git a/components/order/message/index.wxss b/components/order/message/index.wxss new file mode 100644 index 0000000..6221a43 --- /dev/null +++ b/components/order/message/index.wxss @@ -0,0 +1 @@ +.message{padding:35rpx;display:flex;align-items:center;border-bottom:1rpx solid #F2F2F2}.message .image{width:141rpx;height:150rpx;background-color:#000;margin-left:34rpx}.message .introduce{margin-left:32rpx;height:120rpx;display:flex;flex-direction:column;justify-content:space-between;width:362rpx}.message .introduce .title{font-size:28rpx;color:#333}.message .introduce .count{font-size:24rpx;color:#999;display:flex}.message .introduce .count>view{margin-right:27rpx}.message .parameter{width:150rpx;height:120rpx;display:flex;flex-direction:column;justify-content:space-between;align-items:flex-end} diff --git a/components/order/tab/index.js b/components/order/tab/index.js new file mode 100644 index 0000000..9f59aa7 --- /dev/null +++ b/components/order/tab/index.js @@ -0,0 +1,8 @@ +Component({ + properties: { + }, + data: { + }, + methods: { + } +}) \ No newline at end of file diff --git a/components/order/tab/index.json b/components/order/tab/index.json new file mode 100644 index 0000000..86d254c --- /dev/null +++ b/components/order/tab/index.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": { + "commodity":"../commodity/index", + "van-tab": "../utils/dist/tab/index", + "van-tabs": "../utils/dist/tabs/index" + } +} \ No newline at end of file diff --git a/components/order/tab/index.scss b/components/order/tab/index.scss new file mode 100644 index 0000000..5003c84 --- /dev/null +++ b/components/order/tab/index.scss @@ -0,0 +1,3 @@ +.tab { + width: 750rpx; +} \ No newline at end of file diff --git a/components/order/tab/index.wxml b/components/order/tab/index.wxml new file mode 100644 index 0000000..332394c --- /dev/null +++ b/components/order/tab/index.wxml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/components/order/tab/index.wxss b/components/order/tab/index.wxss new file mode 100644 index 0000000..77cc1ab --- /dev/null +++ b/components/order/tab/index.wxss @@ -0,0 +1 @@ +.tab{width:750rpx} diff --git a/pages/order/order.json b/pages/order/order.json index bb72bac..f3c80a3 100644 --- a/pages/order/order.json +++ b/pages/order/order.json @@ -1,6 +1,5 @@ { "usingComponents": { - "van-tab": "../utils/dist/tab/index", - "van-tabs": "../utils/dist/tabs/index" + "tab":"../components/order/tab/index" } } \ No newline at end of file diff --git a/pages/order/order.scss b/pages/order/order.scss index f2e63ec..ffb81b1 100644 --- a/pages/order/order.scss +++ b/pages/order/order.scss @@ -2,90 +2,7 @@ display: flex; flex-direction: column; align-items: center; - .tab { - width: 100%; - .commodity { - margin-top: 20rpx; - background-color: #fff; - .message { - padding: 35rpx; - display: flex; - align-items: center; - border-bottom: 1rpx solid #F2F2F2; - .image { - width: 141rpx; - height: 150rpx; - background-color: #000; - margin-left: 34rpx; - } - .introduce { - margin-left: 32rpx; - height: 120rpx; - display: flex; - flex-direction: column; - justify-content: space-between; - width: 362rpx; - .title { - font-size: 28rpx; - color: #333; - } - .count { - font-size: 24rpx; - color: #999; - display: flex; - > view { - margin-right: 27rpx; - } - } - } - .parameter { - width: 150rpx; - height: 120rpx; - display: flex; - flex-direction: column; - justify-content: space-between; - align-items: flex-end; - } - } - .aggregate{ - display: flex; - box-sizing: border-box; - padding: 30rpx; - justify-content: flex-end; - font-size: 22rpx; - color: #999; - height: 78rpx; - border-bottom: 1rpx solid #F2F2F2; - - >text{ - color: #333; - margin: 0 5rpx; - } - } - .operation{ - height: 84rpx; - display: flex; - justify-content: flex-end; - padding:0 30rpx; - align-items: center; - .button{ - width: 133rpx; - height: 51rpx; - border:2rpx solid #999999; - border-radius: 26rpx; - text-align: center; - font-size: 22rpx; - color:#999999; - line-height: 51rpx; - margin-right: 8rpx; - } - .hlight{ - border:2rpx solid rgba(71,200,119,1); - color: #47C877; - } - } - } - } + width: 100%; } page { background-color: #efefef; diff --git a/pages/order/order.wxml b/pages/order/order.wxml index 2d3df92..388926d 100644 --- a/pages/order/order.wxml +++ b/pages/order/order.wxml @@ -1,141 +1,3 @@ - - - - - - - 001|德国双心药房版 胶原蛋白美容口服液养颜 - - 30只 - 1.0356kg - - - - ¥29.80 - x2 - - - - 共计1件商品 合计: - ¥29.80 - (含运费¥0.00) - - - 评价 - - 评价 - - - - - - - - - 001|德国双心药房版 胶原蛋白美容口服液养颜 - - 30只 - 1.0356kg - - - - ¥29.80 - x2 - - - - 共计1件商品 合计: - ¥29.80 - (含运费¥0.00) - - - 评价 - - 评价 - - - - - - - - 001|德国双心药房版 胶原蛋白美容口服液养颜 - - 30只 - 1.0356kg - - - - ¥29.80 - x2 - - - - 共计1件商品 合计: - ¥29.80 - (含运费¥0.00) - - - 评价 - - 评价 - - - - - - - - 001|德国双心药房版 胶原蛋白美容口服液养颜 - - 30只 - 1.0356kg - - - - ¥29.80 - x2 - - - - 共计1件商品 合计: - ¥29.80 - (含运费¥0.00) - - - 评价 - - 评价 - - - - - - - - 001|德国双心药房版 胶原蛋白美容口服液养颜 - - 30只 - 1.0356kg - - - - ¥29.80 - x2 - - - - 共计1件商品 合计: - ¥29.80 - (含运费¥0.00) - - - 评价 - - 评价 - - - - + \ No newline at end of file diff --git a/pages/order/order.wxss b/pages/order/order.wxss index 25f60da..069fac9 100644 --- a/pages/order/order.wxss +++ b/pages/order/order.wxss @@ -1 +1 @@ -.box{display:flex;flex-direction:column;align-items:center}.box .tab{width:100%}.box .tab .commodity{margin-top:20rpx;background-color:#fff}.box .tab .commodity .message{padding:35rpx;display:flex;align-items:center;border-bottom:1rpx solid #F2F2F2}.box .tab .commodity .message .image{width:141rpx;height:150rpx;background-color:#000;margin-left:34rpx}.box .tab .commodity .message .introduce{margin-left:32rpx;height:120rpx;display:flex;flex-direction:column;justify-content:space-between;width:362rpx}.box .tab .commodity .message .introduce .title{font-size:28rpx;color:#333}.box .tab .commodity .message .introduce .count{font-size:24rpx;color:#999;display:flex}.box .tab .commodity .message .introduce .count>view{margin-right:27rpx}.box .tab .commodity .message .parameter{width:150rpx;height:120rpx;display:flex;flex-direction:column;justify-content:space-between;align-items:flex-end}.box .tab .commodity .aggregate{display:flex;box-sizing:border-box;padding:30rpx;justify-content:flex-end;font-size:22rpx;color:#999;height:78rpx;border-bottom:1rpx solid #F2F2F2}.box .tab .commodity .aggregate>text{color:#333;margin:0 5rpx}.box .tab .commodity .operation{height:84rpx;display:flex;justify-content:flex-end;padding:0 30rpx;align-items:center}.box .tab .commodity .operation .button{width:133rpx;height:51rpx;border:2rpx solid #999999;border-radius:26rpx;text-align:center;font-size:22rpx;color:#999999;line-height:51rpx;margin-right:8rpx}.box .tab .commodity .operation .hlight{border:2rpx solid #47c877;color:#47C877}page{background-color:#efefef} +.box{display:flex;flex-direction:column;align-items:center;width:100%}page{background-color:#efefef}