默认提交
Showing
258 changed files
with
3949 additions
and
1445 deletions
... | @@ -11,7 +11,7 @@ module.exports = { | ... | @@ -11,7 +11,7 @@ module.exports = { |
11 | "enabledQcloud": false, //是否开启腾讯云COS 上传功能 | 11 | "enabledQcloud": false, //是否开启腾讯云COS 上传功能 |
12 | // 腾讯云COS 上传功能配置表 | 12 | // 腾讯云COS 上传功能配置表 |
13 | "qcloud": { | 13 | "qcloud": { |
14 | "appid": "1111111", | 14 | "appid": "wxd5e3b4b2e7ce2c1a", |
15 | "secretId": "xxx", | 15 | "secretId": "xxx", |
16 | "secretKey": "xxxxx", | 16 | "secretKey": "xxxxx", |
17 | "bucket": "xxxx", | 17 | "bucket": "xxxx", | ... | ... |
... | @@ -8,7 +8,7 @@ | ... | @@ -8,7 +8,7 @@ |
8 | "minified": true, | 8 | "minified": true, |
9 | "newFeature": true | 9 | "newFeature": true |
10 | }, | 10 | }, |
11 | "appid": "wxc57ed87f2569f701", | 11 | "appid": "wxd5e3b4b2e7ce2c1a", |
12 | "projectname": "gulp-example", | 12 | "projectname": "gulp-example", |
13 | "condition": {} | 13 | "condition": {} |
14 | } | 14 | } | ... | ... |
1 | { | 1 | { |
2 | "pages": [ | 2 | "pages": [ |
3 | "pages/index/index", | 3 | "pages/index/index", |
4 | "pages/detail/detail", | ||
4 | "pages/more/more", | 5 | "pages/more/more", |
5 | "pages/poster-example/poster-example", | 6 | "pages/poster-example/poster-example", |
6 | "pages/authorize/authorize", | 7 | "pages/authorize/authorize", |
... | @@ -9,31 +10,15 @@ | ... | @@ -9,31 +10,15 @@ |
9 | "window": { | 10 | "window": { |
10 | "backgroundTextStyle": "light", | 11 | "backgroundTextStyle": "light", |
11 | "navigationBarBackgroundColor": "#fff", | 12 | "navigationBarBackgroundColor": "#fff", |
12 | "navigationBarTitleText": "mp-gulp-framework", | 13 | "navigationBarTitleText": "家有儿孙", |
13 | "navigationBarTextStyle": "black" | 14 | "navigationBarTextStyle": "black" |
14 | }, | 15 | }, |
15 | "tabBar": { | ||
16 | "color": "#7A7E83", | ||
17 | "selectedColor": "#CF4646", | ||
18 | "borderStyle": "black", | ||
19 | "backgroundColor": "#ffffff", | ||
20 | "list": [{ | ||
21 | "pagePath": "pages/index/index", | ||
22 | "iconPath": "image/tabbar/home_D.png", | ||
23 | "selectedIconPath": "image/tabbar/home.png", | ||
24 | "text": "介绍" | ||
25 | }, | ||
26 | { | ||
27 | "pagePath": "pages/more/more", | ||
28 | "iconPath": "image/tabbar/set_D.png", | ||
29 | "selectedIconPath": "image/tabbar/set.png", | ||
30 | "text": "更多" | ||
31 | } | ||
32 | ] | ||
33 | }, | ||
34 | "usingComponents": { | 16 | "usingComponents": { |
35 | "authorize-comp": "../../component/authorize-comp/authorize-comp", | 17 | "authorize-comp": "../../component/authorize-comp/authorize-comp", |
36 | "empty-tips": "../../component/empty-tips/empty-tips", | 18 | "empty-tips": "../../component/empty-tips/empty-tips", |
37 | "van-popup": "../../ui/vant-weapp/popup/index" | 19 | "van-popup": "../../ui/vant-weapp/popup/index", |
20 | "van-sticky": "../../ui/vant-weapp/sticky/index", | ||
21 | "van-tab": "../../ui/vant-weapp/tab/index", | ||
22 | "van-tabs": "../../ui/vant-weapp/tabs/index" | ||
38 | } | 23 | } |
39 | } | 24 | } | ... | ... |
... | @@ -30,6 +30,15 @@ | ... | @@ -30,6 +30,15 @@ |
30 | font-family: -apple-system-font, Helvetica Neue, Helvetica, sans-serif, FZY3JW-GB1-0; | 30 | font-family: -apple-system-font, Helvetica Neue, Helvetica, sans-serif, FZY3JW-GB1-0; |
31 | } | 31 | } |
32 | 32 | ||
33 | button::after { | ||
34 | border: none; | ||
35 | } | ||
36 | |||
37 | button { | ||
38 | background-color: #fff; | ||
39 | border-radius: 0; | ||
40 | } | ||
41 | |||
33 | .app__width { | 42 | .app__width { |
34 | width: 750px; | 43 | width: 750px; |
35 | } | 44 | } |
... | @@ -88,7 +97,11 @@ | ... | @@ -88,7 +97,11 @@ |
88 | 97 | ||
89 | @font-face { | 98 | @font-face { |
90 | font-family: "iconfont"; | 99 | font-family: "iconfont"; |
91 | src:url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAOsAAsAAAAAB6gAAANdAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCDBgqDDIJmATYCJAMMCwgABCAFhG0HORuvBsgOJUHBwIABAAlgPHyN/f7c3UVEk0mi+3QSQxJNJCoexUrxUhhKIyT4UsKbL89+kizTNWb3wyt7UkR96ayA4xev1q04fZzIa32ey/Gt5wc26luWy5iT9qKFAcYBBbQ3RgEFWiAJesPYlRdxn0C9YccRqxl5ZcBCYSwLxJFS3gwsUk6lpj7UCtUle4t4Yqo2XaeXAHj0vx//QUhYkFRlxtq1w/Q2kPRz+iOmhipDoM51Gx7PD3aIjBlAITZLgxuoMDODUq8YTerLqxUhjRU3GgFfqeqrzT88kiCqGbWNYAJlEz+nbQmJP1h91rUZVMPcGeAZM51XhqohJw97O/vO23paqy3T6coNhsqQ1esr3nVWF19mTZ3YnOwtWwPk5bvMfvYCQV11V+xUzZx02tPO6H02TtP0y4dn5a7M9ravfPvs/poNl43TTmVrW87O66dcKzd3myo2Tjo5rW07l6+fcXXd3KmUDdBKXH240GtvAAw49qfa2BeatkTevUsumTJX5pzRRVy781FXe+YP15YALi0+kkDHQRm8OLz2sP/U1NGjIPxKdyVpafxHpKWvbajtddvnaxmZHLP0XGY1d2wvLarJWrd3LMD6Q1DiSPHusrPgvOxtlAKDyt7bk32nH3emP+npcwo2dKU/Vj040Jn2+HTvAU5VFtOf5vZDf683NVrpbEvIO7N3IX421A40MRbmdVIPQGXQhMi7/+o3vjanTBtt4/7Vygr4/p/GIHW7aqBWorXqz7QVQMVYCK4xXLnISlup57Ntpvcth3Ju8j8aod2b/tauu8+FWl0xkhpDyGqNEIWZQZUG86hWawH1pmUebtBBQolShynjAKHVFSTNPpG1ekUU5jWqdPuGaq1Bod56OJ7ZYCyUdKqEmjFqgy3dUNkqCozlwXRQX4Lk7VyzlNT4XAWSNMo4DA4IyuYzkYCkMTZoOuQhGDOQkUQeZoDHEMeJUC2JKtSKAxQYq2MCA5myFwW0ijygrZAgzTCkDdSiG6TUSiRg3MEYnft8CUSuHaeZVNNTka6ASDSUo0PBAgS1IDKNQquea3lGo4NcCAxjQAyJiAdlgFkIhyOC1OWzVJBWWABFj5RajECzH9PWGDC/mX++Q1DPGJsjRY6i5hgx1hSNwhTxatwNAAAAAA==') format('woff2'), | 100 | src: url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAABTsAAsAAAAALaAAABScAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCJcgq/PLNKATYCJAOBdAt8AAQgBYRtB4Y7G2kmRaQTm1WdEZWaUvb/IUGTuBaufhBBFWHkjBhGq1XHMYj3XX3n8jL/xx++kcFdLHHdXKhfbgLXxFTYg41wpQSLre+6iIcMpYT4Z63N3zMRFvMjdFqmFFomlnnwwP+9u381F7bFxxLqeAn9woQ+YaD5JnsEwGG7n7TmwlERRQElFABG++f5bfXnvgcKFhaIyQMTdTDrrhg99kRZICjGRyaMWZiohHEi0nnMToXOOrvN4K+JiH1tDqiIfr6c5s9Ydto3SqwFQaDlhIvkpAwDoW1sXmQVpFsrtWzzLtu8BCDJRbj2w4kHTjcaf6L3b3nIEQws3VAYnOHb+204RQiGeMx0eiAZkP2U1ucMa4YxISBO5VyAAhh/gajnQmN30cRUJ5e9GwteghJi/0+nrsSFGWHDt/+MhXG4k+lOkFrhCyspOS5IYaVEjksIk6FgFe20PAFvHTsyvr3bzuNYl/tnovP/4MBXzdYaxmYNMLbWw1wzhbawP/IzAsrGZgL3nJcxqEgF1wLiTR0LgMpDLy2IQqUqEd6GRR8yleA9vgXwm/4+/omOKiSykODu9+szYbD+gkdvUsgpEzd5C8B7hwykkCXJELcRk+RjKqR2/E7YHwD6UkJKXzwANfHFS6S24/9/CoFNEJNIvhQswygMauH7iIuI3risonpe19DU0vb+npeWkZWTV1BUUlZRVVPX0NTS1tHV0zcwNDI2MTUzt7C0sraxtbN3cHRydnEVFUuJKLRfBZJPsLsggNNbAQLIIQQZxCGQgAKSUEQKSkhDGVmoIA9VFKCGItRRggbK0EQFWqhCGzXooA5dNKCHJvTRggHaMEQHRujCGD2YoA9TDGCGIcwxggXGsMQEVpjCGjPYYA5bLGCHJeyxggPWcMQGTtjCGTu4wh5SHOAaR7jBCW5xhjtc4B5XeMANHnGHJzzgGU94wQte8YY3fOAdP/CBX/jEP+T5/7UkoHhBtuLmX/GLH/ij9AJqNwi2ZsRPalp7WCQO8zIpbloiIgTugdo+hxAEO+VOlIBAqxYXCw4nd7MSBUaCfXRvhRwgLgICfR92FpA1cRQLSpN4ukKXyYEfxYlHeCoZe5I0KRl8jENkJKwYOo2C6AP8FX9FPF7vlHNQAPGBYfbpSSHmuopMCZUaQS4LI3lCIDo4gYVWcRgGs1CWWFsWlW46B4WTd4cdEf3WhZ7lQW4wKgCcZlnYtkm9zhxnVJRm+L6WZY0kDRFTX35ZkwiOaxVTYSRh1nSZspS+6ICDeLjcfDilaftwE6dyCPzCvIvncC010TwaF+MGcnAc5UqTSQinzabFFV1qypRU6zds/07qfzLnj0kIaMgwPgRgVG++GceBS6vw480a5FQ+4OygkReXWYZzQ7KIULHaxnK8YLaQTLl9OCkniyKOpyUpUVBYKuenybwoxjMSSZQUJZVlvAA91KsyipcBEPiYsR1X9KvmZe0SrXvYYMINK0O8fpn1tvUVtr8m9W+Z803IcB5hu/liWb+jIKxFP7zs0n1GJ8v4y3o37YfDjjOL9eMLzrMc+oxNsI+dt5/hY1nHL9tAa3krd7DrraI6zigDt2ZtE2z0CO7G1mU+1lSpMM/nD+vZopFPg8xusxbUMgWzlIPZqlGeQVplTIBebhfBW5RD/vKueO8auHkdye/T9psH9QOLkMuiiw7QQVu7Lu0CGpMsARwXQ5lAaxSFauoamwCmeD18URavCqw3m0F0F4yPiwY9fcgol7VKhS+VTw3xGUSpgJleRV6KgJkENxBtGkFUw/w8RCO10GHHmUMP1mGzzPUJYNYHCD8ejmOQETwihQZgaijhoW0YBryKgAn7YoDnRr0eUWObGgyHVC0t5lHxQKuS22vubknM/OTqB7scjSamd8VyfklHIgNcnbGndcjY1R6UekGhwm7ePHtwbWu2t3oGHbNu0lr8Wc+r7WfMs32BNHj9jTeucUInnFvW1p87bt+8yhpuf8OhfLsYb8ftedSZlDtpMbZjubmvK2htZdlWmGujbVsHFJJSlFIXU7q6FKmjApKCJBU6mNQjZVoSUgteGgDWCknz3KNiJIt+XlmimM2CvWZiIeWzR3qrvbgoXrXDuC/fjqWh5e7yoWYWFtckbm3mcE+lhxXkKh3bzQcVIRmQWl/taFuuTfUCAwXMZvvYNP++kIGoCrwQgRgO92MOuehjEWF8+Q4H/KGsDIMwKcfLZ69SSoEhmCIC9E4r4U+zHsP0gAPr9cEJPJDV+jZa1Kdm314ZMSsVrVxG9qhITtZvXeM827laFfximCdVxgJwO+SSp+A6gOsu882c5Z5L5WQKF4+6Rhm0fP17oCOxKLCkCj70Y9TZsNMvezPWP99XdQtV/PQBk/DDbn5iYMMdXbBLXIFtz6tgJYBcAhe0bDnQGPFywhjNjMGXenwZabDAo0rxMOYEtxcyQq3H2zD+GmzMgGFmTa/i5epmMC6SMJWYKxgVFo/3jBtzC57BRq6JNQIDm1wIGE+sQ5zmfm0f9YRnuoafpIxHrssVezy+H668+iC//fL1wJpqGzpmCGcHd4Npqfq8DeYX1ytDGGAU9IWZ5w10Z9ZjFPczOkCYD4/liRoC+2gyfYzE+gtkjF0d9jEyQFlI4GwxnzNOVb2MIo6nxapeM0fERImqMspziOXb0mgeQJDfeVW/8gDcduk6dKGQpnCVhSVM79ump45KkochgfLdGAa12qX7EDCwxZnjhNTJQ6WPXA9qx6Z4l8CpcNUZCifDOPi+xnR16ssskzWnWjLKuxCpQlmI0uyGEaMr7O4grLSXHzl6bV3z8LZT3ZguKqbWL+mJxGpTgy4irFHGVPR/zBGCGaGMUjxiSkMBMyHioURcDvrjSWWEJlN8aCSl+rzhuhgunWXT1rHIrGgsl4SituVDNkY/jLJpYiswMg/TWcA5UwBBrEfFsVGbv7IaqLti1kgc8XxXDQo4Dp3Jt5LguJRIKEwqHOfNkmLb5ORzJKGYSkqmF+szUbuxo7PTEDFLyUPOvMafUAvEpetfTIoovw3ZpkizqPwbscjAuy7dZgGDLzrxbCdmDtTrd26sP1rnTWK/cZkUgwWKq9lWXrZ7yarHD71MKDr2tEWdJ6uOXu87yurEDeGJig20xV3abr6gpGCu2j6UlmTlZLsGkdx4VLNa0v9DL331FWeyZmMw1k2190PXli0ukA8XBjYkS98tq3RugM403pt5Bn/NZnp8+jPXoUOuz4iCHMRiuPmjG2YPtb2ij7wJprs+/dQ1yHQgBHv/SPctH3zQ2wvuC/zLd+3SNWsOHnzz0D/b+CDfm98Aj0585N/+7/1XdnKe982fRxZ/YQoNT3y5EW3YME46f+x1ufvae/9mDU9cAG7i3jjmbvC4j7uPNTQcc99oAxzteIPnFs+GDfO/DMH9ur1x2PHSWS8TuCJeDO8MzhFxE24PS2/YO8jCNmYl1sxAG8Nkjg8jM6aXbVjGb+UvO4baiMjKBy5Ez44rk7OvdvW4ZwZTsq80XQycnHVlR3egpolU/OsOTQBYty8pTbuAFz1kMxSdjhDjDIyoqvKwq5B/5HDUKCRHwdFYN3Vfr9Pvj+PjO7vXKVe39/G+ObAyiTJLH+92NGAm3DOGmj9+fFcksz5yZ0NDVsrwNvD8ZjpzqgwC6Y8/LrfyJXHl0kymT0db/XX08K2aGolWOiRoK7yRs4vlrxkKG5HGHg3rx+/5/+5qSEwAnFycMHZQGMD8UHmu0WhZtdqN8LrjMhxPaLw0JxzJ3SG70932Kfx2AUa6BhuE1DN7q5rxEqOTYijFeeedQlNMfPgegKjAlNNcmracOC5aOHhr28Wk9rG+fWP1Qf72LbLd6kBGYcAGM5igYAxzQFR4wDNjS0r73zqMemyo8YfVQGw8pHRWr3S2PGsGfHZj5mWUlXZ8gD53GXCUOA64bLMC4KLfAjGPqGi6x9roj79GrNfiH5aKXuBznhOeFHojhpHObzBjM9D0TBpnVnE3zxfD7twJDVAmEnOOHZtjQuwMYg4sTlQG9P5XwABY5eAVVuvy5W2/9Sb28nJclbQa5nnNo+m1Xmvnznv+HGITMOMVXI6Fw11RNv+BcV/aYAMxxKrp/LHLQWCKsbMNlkX7JpAZf1bdq0nAqQxxDank7J5gdxecw64/nNlkwrAoWXD6SeEhXvg+T3dPN5h3SOibWHR1bNtId4FPaV4eW1An2ckPFV0Ju+uUikL5kp31fODwEbj/l5cVAsMUWFJ1XHoZam5GJmUbA9stYN0mWWHUJ4FPk3yFd/vQXfkryHktn/9s9u5f0J3TMzVhd0dJiT+Lw/I/IXVEcfubvf/8HFWk8mladpF69YpyKWsg+BRVKGv2bhQYTdPGFm00YoLDIcTudS8aO3r0xe4F/RtbI6PK7k36QdJwvfkj3OYKuBWVmr20V15wpdbPW+qnvTrIzmIPXl3Hlnpr/SqD873O79VUVNL0/XlvU9vnGjD+qnXimuXR47f4H2aW+LgWFwyE1cCQl+fPSJgPxb7uou0MSr8dPUL6v6H+OuDieM7RZcBQD7cDPQI6Q0VGBjOuVFGSkeTZM4uQDx81xt6o8491ly/POzS3v1/lM9GjMtzftUxY0eDznRzQc/I6bzFc/ft+rhN5jx/vjS57NVQJ9PtCGteubQz+64GgutZrNayTLmM3xrIXo6pqyTSDf3Xaxcvh0vUQ2rRnAjcnXx+f6dO74t2BaCdG03LUk+z6x5cXZldh+gixAKVrCo/8+AD+mXN9lk/tsTCM5ef/jKl8oJphxzhqieut5OL8E1ylCUegcrXoONnwUJdnbkfFHaCNJlSq0ZSaoI1ATDXQbLIaa3RWExgnYApnWLEJg74wkQie4+fgM6jS9PTsVWIjRz2yM9oebUDZO/17THg6e7EZAKy0k4u3q4+rt4uj/rsJLsUGVerpiawf1O8rL98RFY2ZikG/wtUkgzGn08yQ4dxBAAy9go23+z1c98lBuLISowGhcxiEc7bLl0HVyPm+QNVu2Zf6+WwofZYCWzc65oZNBV5bc/Q5rjQ6I5rKhPyiIKbnrA/KLCY6e3s7iVKYVlw0Y5dTQ+t57pqV5JUr5MpI4UjlsOGbx9fBRQVXHljWrgO14NS1+byE0xWYrMP/JesYOKXTsmN7TraFbc4Bb01CfH7g4Jkd2y1TOoWelg/p1ZsXKuk+P5vOYAqL2iL3hMDJWxnBwhvbX060lWMDNWjsBkgGB/8AIoKr4WZXjXyJy1Ap/hfc7ndldl+XOMmsJB1zVGMD6lAGLF+YXcXdjQZWBgM8MRp6Mrcx6o33omtcwMjAkqAlSWZ85ecGDxxIeTobmc3HZmvZgWwe8DBG79n/fsceAjAaa1Ctfm0vZOfllhlMTvODYpFJWPbliS20fz1einw4q76ObPVD/+8QeB46wv0LnowNvH2VFISh0mYNWM2fw2Ee68GvNdi3ZZ7st9MtRFGZ5t3yGH8ZQY3Ltwma5igS26ZkDdE4jL9TTqwdX1K+k4/DhuisFFuReJqjAKiEKlPiNoLj4q7uwhnh5pJHRR6ziUXAV6DoLADxtx9VAOZnmW95nwdHVM/kNhTQ5wyyJr0wTK70cpNWdZPP14vwDAwH+Z2d9Pbt2dk0fFWlB1J2O4kzySHUXSn98D9Q5fQNVHhl8dwbvOpntxNNW1ZOsWd7t99aPBdtIPoPkTNzsjvlkaIxniPKDdETk/6zKsHH7n/RVKmxXgWl7dGRkkibmElSfsHGVHULx+au8MpEfxtxhdQdS2f3VHWR7YdWzCImogOTPcZ12/RuJqp8B9fPDvl7kQSzFI88NGhZJzFmoDRAg1rQ8i5itCx+hPqjWe6V5WjMwwdH/ctzAyUdOCSzJOioBBdmTsWS5qWqJVJhyb9mZCZqq0Nqq0vEBaLuIF4++pnjfC3odPsHoSDaReLkXlXlPaYhju0bXQ75Szl1oMgtM1f3rXi/XJzvXw7Dj5Iscd84fmaAQ1epUOrBp572ubrdFE8scf7rjOPuv5yHYvyy7gH12uN4+oarU9ZVOgD6EFT+BABIwz9Ea5PVxK8AjJljRQzAXOB+StscpLtkmVPvRmQdjWj+rxeG9B10PuZMJIBFL5AUb94QV/NIh2RzKI8hp9FYQcHnZI7ORQwkqgKmlWbKiDg2dtXMRVaA43Eg1p23hvRAUg2tuxrZSzETZhkcsJDq11R9iqQIkrnJJojhIibiAuiCuc+dJMVRVgxyPQgZGEB0E2seIz2ibtgJA8eBzUhEQDRImCb3IxGpc7AbkRKmeCuy/J/cN9zkhX6dIKS+59izAA7849NaNcR01n6VOOIo2pn+By6k0zCbhU7WgKadf6IA+2UYQACQ5jzYnh0EANiFRQAMKHJ1v5ss/+c1xZTzYPY6EGALvh1I4EBAOCs6vAMb7CG2gw1wIKODHYTJPbM9uNEiAbG4ABBq1qYDAmcHOxDgBDQlSdG3KQtEWzqwQeA5sUFyRHawg+rILUh7CIrUdnKtolanaKDqOil1fVurUlk6u6x6uaJxoqZWC63O8aoV2g51WysVJYu8DMtVtCq0Mgw6JjVG63RKSqlta6FyNgEUGk0b1a5ta1LU62QqDG1PjohQbq9CVt/WAnYgp6VQS0ehAaVOZ9yjWr02rZRL1rF7efrlFBpNpFFLWzDeY4/VFLQ6qPecEkUmkiI8V2ilGm9VvHeYpFE0HR0lYkra49AWlBzIFDRHZxtKO9lfE4V6OjIqDke7ZBGhOyWtINMvtUxTAQbfBINTp0UEIhELsZENskUcxP1v36PngByRE+IhZ+SCXJEbckd8JEAeSIg8kRfyRj7IF/khEaKQGEmQPwpAgSgIBaMQJEWhKAyFo2FIhiJQJIpC0SgGxaI4FI8SUCJKQskoBaWiNJQONvWatg5FlK1WodQ1dahYqrYWBbtdU9uqsJ2ibu1StDayFS3tuk7uiOg/TKfoGEWm3IUoFwAEAQ0GmGA1vo5Z63RhQaAwsOGAE66xdUIgEAgEAoFAIFAoFAqFQqFQKAwMDAwMDAwMDAxs313uosj9fs+/L4okaRsAAA==') format('woff2'), |
101 | } | ||
102 | |||
103 | .drop-down-item :last-child { | ||
104 | border-bottom: none; | ||
92 | } | 105 | } |
93 | 106 | ||
94 | .iconfont { | 107 | .iconfont { |
... | @@ -97,16 +110,244 @@ | ... | @@ -97,16 +110,244 @@ |
97 | font-style: normal; | 110 | font-style: normal; |
98 | -webkit-font-smoothing: antialiased; | 111 | -webkit-font-smoothing: antialiased; |
99 | -moz-osx-font-smoothing: grayscale; | 112 | -moz-osx-font-smoothing: grayscale; |
100 | } | 113 | } |
114 | |||
115 | .iconclose1:before { | ||
116 | content: "\e615"; | ||
117 | } | ||
101 | 118 | ||
102 | .iconrefresh:before { | 119 | .iconrefresh:before { |
103 | content: "\e874"; | 120 | content: "\e874"; |
104 | } | 121 | } |
105 | 122 | ||
123 | .iconhome:before { | ||
124 | content: "\e610"; | ||
125 | } | ||
126 | |||
127 | .iconplane:before { | ||
128 | content: "\e8c2"; | ||
129 | } | ||
130 | |||
131 | .iconxinzeng:before { | ||
132 | content: "\e606"; | ||
133 | } | ||
134 | |||
106 | .iconempty:before { | 135 | .iconempty:before { |
107 | content: "\e6a6"; | 136 | content: "\e6a6"; |
108 | } | 137 | } |
109 | 138 | ||
110 | .drop-down-item :last-child { | 139 | .iconicon-test:before { |
111 | border-bottom: none; | 140 | content: "\e633"; |
141 | } | ||
142 | |||
143 | .iconicon-test1:before { | ||
144 | content: "\e634"; | ||
145 | } | ||
146 | |||
147 | .iconicon-test2:before { | ||
148 | content: "\e635"; | ||
149 | } | ||
150 | |||
151 | .iconicon-test3:before { | ||
152 | content: "\e636"; | ||
153 | } | ||
154 | |||
155 | .iconicon-test4:before { | ||
156 | content: "\e638"; | ||
157 | } | ||
158 | |||
159 | .iconicon-test5:before { | ||
160 | content: "\e63a"; | ||
161 | } | ||
162 | |||
163 | .iconicon-test6:before { | ||
164 | content: "\e63b"; | ||
165 | } | ||
166 | |||
167 | .iconicon-test7:before { | ||
168 | content: "\e63c"; | ||
169 | } | ||
170 | |||
171 | .iconicon-test8:before { | ||
172 | content: "\e63d"; | ||
173 | } | ||
174 | |||
175 | .iconicon-test9:before { | ||
176 | content: "\e63e"; | ||
177 | } | ||
178 | |||
179 | .iconicon-test10:before { | ||
180 | content: "\e63f"; | ||
181 | } | ||
182 | |||
183 | .iconicon-test11:before { | ||
184 | content: "\e640"; | ||
185 | } | ||
186 | |||
187 | .iconicon-test12:before { | ||
188 | content: "\e641"; | ||
189 | } | ||
190 | |||
191 | .iconicon-test13:before { | ||
192 | content: "\e642"; | ||
193 | } | ||
194 | |||
195 | .iconicon-test14:before { | ||
196 | content: "\e643"; | ||
197 | } | ||
198 | |||
199 | .iconicon-test15:before { | ||
200 | content: "\e644"; | ||
201 | } | ||
202 | |||
203 | .iconicon-test16:before { | ||
204 | content: "\e645"; | ||
205 | } | ||
206 | |||
207 | .iconicon-test17:before { | ||
208 | content: "\e646"; | ||
209 | } | ||
210 | |||
211 | .iconicon-test18:before { | ||
212 | content: "\e647"; | ||
213 | } | ||
214 | |||
215 | .iconicon-test19:before { | ||
216 | content: "\e648"; | ||
217 | } | ||
218 | |||
219 | .iconicon-test20:before { | ||
220 | content: "\e649"; | ||
221 | } | ||
222 | |||
223 | .iconicon-test21:before { | ||
224 | content: "\e64a"; | ||
225 | } | ||
226 | |||
227 | .iconicon-test22:before { | ||
228 | content: "\e64b"; | ||
229 | } | ||
230 | |||
231 | .iconicon-test23:before { | ||
232 | content: "\e64c"; | ||
233 | } | ||
234 | |||
235 | .iconicon-test24:before { | ||
236 | content: "\e64d"; | ||
237 | } | ||
238 | |||
239 | .iconicon-test25:before { | ||
240 | content: "\e64e"; | ||
241 | } | ||
242 | |||
243 | .iconicon-test26:before { | ||
244 | content: "\e64f"; | ||
245 | } | ||
246 | |||
247 | .iconicon-test27:before { | ||
248 | content: "\e650"; | ||
249 | } | ||
250 | |||
251 | .iconicon-test28:before { | ||
252 | content: "\e651"; | ||
253 | } | ||
254 | |||
255 | .iconicon-test29:before { | ||
256 | content: "\e652"; | ||
257 | } | ||
258 | |||
259 | .iconicon-test30:before { | ||
260 | content: "\e653"; | ||
261 | } | ||
262 | |||
263 | .iconicon-test31:before { | ||
264 | content: "\e654"; | ||
265 | } | ||
266 | |||
267 | .iconicon-test32:before { | ||
268 | content: "\e655"; | ||
269 | } | ||
270 | |||
271 | .iconicon-test33:before { | ||
272 | content: "\e656"; | ||
273 | } | ||
274 | |||
275 | .iconicon-test34:before { | ||
276 | content: "\e657"; | ||
277 | } | ||
278 | |||
279 | .iconicon-test35:before { | ||
280 | content: "\e658"; | ||
281 | } | ||
282 | |||
283 | .iconicon-test36:before { | ||
284 | content: "\e659"; | ||
285 | } | ||
286 | |||
287 | .iconicon-test37:before { | ||
288 | content: "\e65a"; | ||
289 | } | ||
290 | |||
291 | .iconicon-test38:before { | ||
292 | content: "\e65b"; | ||
293 | } | ||
294 | |||
295 | .iconicon-test39:before { | ||
296 | content: "\e65c"; | ||
297 | } | ||
298 | |||
299 | .iconicon-test40:before { | ||
300 | content: "\e65d"; | ||
301 | } | ||
302 | |||
303 | .iconicon-test41:before { | ||
304 | content: "\e65e"; | ||
305 | } | ||
306 | |||
307 | .iconicon-test42:before { | ||
308 | content: "\e65f"; | ||
309 | } | ||
310 | |||
311 | .iconicon-test43:before { | ||
312 | content: "\e660"; | ||
313 | } | ||
314 | |||
315 | .iconicon-test44:before { | ||
316 | content: "\e661"; | ||
317 | } | ||
318 | |||
319 | .iconicon-test45:before { | ||
320 | content: "\e662"; | ||
321 | } | ||
322 | |||
323 | .iconicon-test46:before { | ||
324 | content: "\e663"; | ||
325 | } | ||
326 | |||
327 | .iconicon-test47:before { | ||
328 | content: "\e664"; | ||
329 | } | ||
330 | |||
331 | .iconicon-test48:before { | ||
332 | content: "\e665"; | ||
333 | } | ||
334 | |||
335 | .iconicon-test49:before { | ||
336 | content: "\e666"; | ||
337 | } | ||
338 | |||
339 | .iconicon-test50:before { | ||
340 | content: "\e667"; | ||
341 | } | ||
342 | |||
343 | .iconicon-test51:before { | ||
344 | content: "\e668"; | ||
345 | } | ||
346 | |||
347 | .iconwe_chat:before { | ||
348 | content: "\e669"; | ||
349 | } | ||
350 | |||
351 | .iconwechat:before { | ||
352 | content: "\e600"; | ||
112 | } | 353 | } | ... | ... |
1 | @import "support"; | 1 | @import "support"; |
2 | 2 | ||
3 | // // Margin | ||
4 | // .u-mt-smaller { | ||
5 | // margin-top: $marginTopSmaller; | ||
6 | // } | ||
7 | |||
8 | // .u-mt-small { | ||
9 | // margin-top: $marginTopSmall; | ||
10 | // } | ||
11 | |||
12 | // .u-mt-medium { | ||
13 | // margin-top: $marginTopMedium; | ||
14 | // } | ||
15 | |||
16 | // .u-mt-large { | ||
17 | // margin-top: $marginTopLarge; | ||
18 | // } | ||
19 | |||
20 | // .u-mt-larger { | ||
21 | // margin-top: $marginTopLarger; | ||
22 | // } | ||
23 | |||
24 | // .u-mb-smaller { | ||
25 | // margin-bottom: $marginTopSmaller; | ||
26 | // } | ||
27 | |||
28 | // .u-mb-small { | ||
29 | // margin-bottom: $marginTopSmall; | ||
30 | // } | ||
31 | |||
32 | // .u-mb-medium { | ||
33 | // margin-bottom: $marginTopMedium; | ||
34 | // } | ||
35 | |||
36 | // .u-mb-large { | ||
37 | // margin-bottom: $marginTopLarge; | ||
38 | // } | ||
39 | |||
40 | // .u-mb-larger { | ||
41 | // margin-bottom: $marginTopLarger; | ||
42 | // } | ||
43 | |||
44 | // // Padding | ||
45 | // .u-pt-smaller { | ||
46 | // padding-top: $paddingTopSmaller; | ||
47 | // } | ||
48 | |||
49 | // .u-pt-small { | ||
50 | // padding-top: $paddingTopSmall; | ||
51 | // } | ||
52 | |||
53 | // .u-pt-medium { | ||
54 | // padding-top: $paddingTopMedium; | ||
55 | // } | ||
56 | |||
57 | // .u-pt-large { | ||
58 | // padding-top: $paddingTopLarge; | ||
59 | // } | ||
60 | |||
61 | // .u-pt-larger { | ||
62 | // padding-top: $paddingTopLarger; | ||
63 | // } | ||
64 | |||
65 | // .u-pb-smaller { | ||
66 | // padding-bottom: $paddingTopSmaller; | ||
67 | // } | ||
68 | |||
69 | // .u-pb-small { | ||
70 | // padding-bottom: $paddingTopSmall; | ||
71 | // } | ||
72 | |||
73 | // .u-pb-medium { | ||
74 | // padding-bottom: $paddingTopMedium; | ||
75 | // } | ||
76 | |||
77 | // .u-pb-large { | ||
78 | // padding-bottom: $paddingTopLarge; | ||
79 | // } | ||
80 | |||
81 | // .u-pb-larger { | ||
82 | // padding-bottom: $paddingTopLarger; | ||
83 | // } | ||
84 | |||
85 | // // 布局方位 | ||
86 | // .u-ta-c { | ||
87 | // text-align: center !important; | ||
88 | // } | ||
89 | |||
90 | // .u-ta-l { | ||
91 | // text-align: left !important; | ||
92 | // } | ||
93 | |||
94 | // .u-ta-r { | ||
95 | // text-align: right !important; | ||
96 | // } | ||
97 | |||
98 | // .u-fl-l { | ||
99 | // float: left; | ||
100 | // } | ||
101 | |||
102 | // .u-fl-n { | ||
103 | // float: none; | ||
104 | // } | ||
105 | |||
106 | // .u-fl-r { | ||
107 | // float: right; | ||
108 | // } | ||
109 | |||
110 | // .u-d-b { | ||
111 | // display: block; | ||
112 | // } | ||
113 | |||
114 | // .u-d-i { | ||
115 | // display: inline !important; | ||
116 | // } | ||
117 | |||
118 | // .u-d-ib { | ||
119 | // display: inline-block !important; | ||
120 | // } | ||
121 | |||
122 | // .u-d-n { | ||
123 | // display: none !important; | ||
124 | // } | ||
125 | |||
126 | // .u-d-t { | ||
127 | // display: table; | ||
128 | // table-layout: fixed; | ||
129 | // } | ||
130 | |||
131 | // .u-d-tc { | ||
132 | // display: table-cell; | ||
133 | // } | ||
134 | |||
135 | // .u-va-b { | ||
136 | // vertical-align: bottom; | ||
137 | // } | ||
138 | |||
139 | // .u-va-m { | ||
140 | // vertical-align: middle; | ||
141 | // } | ||
142 | |||
143 | // .u-va-t { | ||
144 | // vertical-align: top; | ||
145 | // } | ||
146 | |||
147 | // // clearfix | ||
148 | // .u-clearfix { | ||
149 | // @include clearfix; | ||
150 | // } | ||
151 | |||
152 | // // 虚拟格式 | ||
153 | // .u-cur-d { | ||
154 | // cursor: default; | ||
155 | // } | ||
156 | |||
157 | // .u-cur-p { | ||
158 | // cursor: pointer; | ||
159 | // } | ||
160 | |||
161 | // // flex | ||
162 | // .u-flex { | ||
163 | // display: -webkit-box; | ||
164 | // display: -webkit-flex; | ||
165 | // display: flex; | ||
166 | // } | ||
167 | |||
168 | // .u-flex-item { | ||
169 | // -webkit-box-flex: 1; | ||
170 | // -webkit-flex: 1; | ||
171 | // flex: 1; | ||
172 | // } | ||
173 | |||
174 | // // 小程序中模拟ul、li | ||
175 | // .u-ul { | ||
176 | // padding-left: 30px; | ||
177 | // text-align: left; | ||
178 | // display: block; | ||
179 | // } | ||
180 | |||
181 | // .u-li { | ||
182 | // position: relative; | ||
183 | // font-size: $fontSizeSmall; | ||
184 | // line-height: $fontSizeSmall + 4px; | ||
185 | // margin-bottom: $marginTopSmall; | ||
186 | // &:before { | ||
187 | // position: absolute; | ||
188 | // content: " "; | ||
189 | // top: 14px; | ||
190 | // left: -20px; | ||
191 | // width: 8px; | ||
192 | // height: 8px; | ||
193 | // border-radius: 8px; | ||
194 | // background-color: $colorBlack; | ||
195 | // } | ||
196 | // } | ||
197 | |||
198 | |||
199 | |||
200 | .bis { | 3 | .bis { |
201 | background-repeat: no-repeat; | 4 | background-repeat: no-repeat; |
202 | background-size: 100% 100%; | 5 | background-size: 100% 100%; |
... | @@ -213,8 +16,6 @@ | ... | @@ -213,8 +16,6 @@ |
213 | justify-content: space-between; | 16 | justify-content: space-between; |
214 | } | 17 | } |
215 | 18 | ||
216 | |||
217 | |||
218 | .fje { | 19 | .fje { |
219 | display: flex; | 20 | display: flex; |
220 | justify-content: flex-end; | 21 | justify-content: flex-end; | ... | ... |
1 | 1 | // Color | |
2 | |||
3 | // // Margin | ||
4 | // $marginTopSmaller: 20px; | ||
5 | // $marginTopSmall: 30px; | ||
6 | // $marginTopMedium: 40px; | ||
7 | // $marginTopLarge: 60px; | ||
8 | // $marginTopLarger: 80px; | ||
9 | |||
10 | // // Padding | ||
11 | // $paddingTopSmaller: 20px; | ||
12 | // $paddingTopSmall: 30px; | ||
13 | // $paddingTopMedium: 40px; | ||
14 | // $paddingTopLarge: 60px; | ||
15 | // $paddingTopLarger: 80px; | ||
16 | |||
17 | // // Color | ||
18 | $colorBlue: #20A0FF; | 2 | $colorBlue: #20A0FF; |
19 | $colorGreen: #13CE66; | 3 | $colorGreen: #13CE66; |
20 | $colorGray: #475669; | 4 | $colorGray: #475669; |
... | @@ -39,3 +23,4 @@ $fontSizeLarger: 44px; | ... | @@ -39,3 +23,4 @@ $fontSizeLarger: 44px; |
39 | $colorMain:#3680EB; | 23 | $colorMain:#3680EB; |
40 | 24 | ||
41 | $pageBottom:80px; | 25 | $pageBottom:80px; |
26 | $contentWidth:690px; | ... | ... |
src/pages/detail/detail.js
0 → 100755
1 | import { | ||
2 | getBindtapData | ||
3 | } from '../../utils/util'; | ||
4 | |||
5 | let app = getApp(); | ||
6 | Page({ | ||
7 | data: { | ||
8 | authorizeVisible: false, | ||
9 | total: 0, | ||
10 | page: 1, | ||
11 | size: 10, | ||
12 | productList: [], // 产品列表 | ||
13 | indexInfo: {}, | ||
14 | userInfo: {}, | ||
15 | }, | ||
16 | onShareAppMessage() {}, | ||
17 | showAuth() { | ||
18 | this.setData({ | ||
19 | authorizeVisible: true | ||
20 | }) | ||
21 | }, | ||
22 | onLoad(options) {}, | ||
23 | |||
24 | /** | ||
25 | * 基础方法 | ||
26 | * 授权完毕重拉数据用 | ||
27 | */ | ||
28 | initData() { | ||
29 | |||
30 | }, | ||
31 | /** | ||
32 | * 到达底部 | ||
33 | * 做加载更多操作 | ||
34 | */ | ||
35 | onReachBottom() { | ||
36 | if (this.data.dataList.length < this.data.total) { | ||
37 | this.setData({ | ||
38 | page: this.data.page + 1 | ||
39 | }); | ||
40 | this.queryDataList(); | ||
41 | } | ||
42 | }, | ||
43 | |||
44 | // 重置页面列表 点击搜索条件时需要 | ||
45 | resetPage() { | ||
46 | this.setData({ | ||
47 | page: 1, | ||
48 | dataList: [] | ||
49 | }) | ||
50 | }, | ||
51 | |||
52 | /** | ||
53 | * 请求DataList | ||
54 | */ | ||
55 | queryDataList() { | ||
56 | return; | ||
57 | return new Promise((resolve, reject) => { | ||
58 | app.post({ | ||
59 | sid: false, | ||
60 | url: app.api.dataList, | ||
61 | data: { | ||
62 | page: this.data.page, | ||
63 | size: this.data.size, | ||
64 | }, | ||
65 | }).then((result) => { | ||
66 | let dataList = result.list; | ||
67 | dataList = this.data.dataList.concat(dataList); | ||
68 | this.setData({ | ||
69 | dataList: dataList, | ||
70 | total: result.total | ||
71 | }) | ||
72 | resolve(); | ||
73 | }) | ||
74 | }); | ||
75 | }, | ||
76 | |||
77 | /** | ||
78 | * 隐藏蒙层 | ||
79 | */ | ||
80 | hideMask() { | ||
81 | this.setData({ | ||
82 | productDetailVisible: false, | ||
83 | authorizeVisible: false, | ||
84 | }) | ||
85 | }, | ||
86 | /** | ||
87 | * 子组件事件 | ||
88 | * @param {*} evt | ||
89 | */ | ||
90 | evtcomp(evt) { | ||
91 | let { | ||
92 | name, | ||
93 | data | ||
94 | } = evt.detail; | ||
95 | switch (name) { | ||
96 | |||
97 | // 隐藏蒙层 | ||
98 | case "_evt_hide_mask": | ||
99 | this.hideMask(); | ||
100 | break; | ||
101 | |||
102 | /** | ||
103 | * 重拉数据已在 | ||
104 | */ | ||
105 | case "_evt_auth_complete": | ||
106 | // this.initData(); | ||
107 | this.hideMask(); | ||
108 | break; | ||
109 | |||
110 | default: | ||
111 | break; | ||
112 | } | ||
113 | }, | ||
114 | }) |
src/pages/detail/detail.json
0 → 100755
src/pages/detail/detail.scss
0 → 100755
1 | @import '../../assets/scss/mixins'; | ||
2 | @import '../../assets/scss/utils'; | ||
3 | |||
4 | .page { | ||
5 | .bgc {} | ||
6 | |||
7 | .bg {} | ||
8 | |||
9 | .main { | ||
10 | .top-space { | ||
11 | height: 0px; | ||
12 | } | ||
13 | |||
14 | .content { | ||
15 | position: relative; | ||
16 | } | ||
17 | } | ||
18 | |||
19 | .detail { | ||
20 | position: relative; | ||
21 | width: 100%; | ||
22 | height: 944px; | ||
23 | background-color: #333333; | ||
24 | |||
25 | .vid { | ||
26 | margin: 232px auto 0; | ||
27 | width: 100%; | ||
28 | height: 360px; | ||
29 | } | ||
30 | |||
31 | .btn-wrap { | ||
32 | color: #ffffff; | ||
33 | margin: 142px auto 0; | ||
34 | display: flex; | ||
35 | |||
36 | .btn { | ||
37 | width: 312px; | ||
38 | height: 94px; | ||
39 | font-size: 30px; | ||
40 | background-color: #3ec03c; | ||
41 | border-radius: 8px; | ||
42 | display: flex; | ||
43 | justify-content: center; | ||
44 | align-items: center; | ||
45 | color: #ffffff; | ||
46 | |||
47 | .iconfont { | ||
48 | font-size: 48px; | ||
49 | } | ||
50 | |||
51 | .t1 { | ||
52 | padding: 0 6px; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | .btn2 { | ||
57 | background-color: #ae3f48; | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | |||
62 | .func { | ||
63 | position: relative; | ||
64 | @extend .bb; | ||
65 | padding: 24px 24px; | ||
66 | display: flex; | ||
67 | justify-content: space-between; | ||
68 | align-items: center; | ||
69 | |||
70 | .user { | ||
71 | display: flex; | ||
72 | align-items: center; | ||
73 | flex: 1; | ||
74 | |||
75 | .portrait { | ||
76 | width: 72px; | ||
77 | height: 72px; | ||
78 | border-radius: 72px; | ||
79 | } | ||
80 | |||
81 | .desc { | ||
82 | @extend .bb; | ||
83 | padding-left: 24px; | ||
84 | display: flex; | ||
85 | align-items: center; | ||
86 | align-content: center; | ||
87 | flex-wrap: wrap; | ||
88 | |||
89 | .t1 { | ||
90 | width: 100%; | ||
91 | } | ||
92 | |||
93 | .name { | ||
94 | font-size: 28px; | ||
95 | } | ||
96 | |||
97 | .num { | ||
98 | font-size: 24px; | ||
99 | color: #8d8d8d; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | } | ||
104 | |||
105 | .btn-wrap { | ||
106 | display: flex; | ||
107 | |||
108 | .btn { | ||
109 | margin-right: 24px; | ||
110 | width: 180px; | ||
111 | height: 68px; | ||
112 | font-size: 24px; | ||
113 | background-color: #3ec03c; | ||
114 | border-radius: 8px; | ||
115 | display: flex; | ||
116 | justify-content: center; | ||
117 | align-items: center; | ||
118 | color: #ffffff; | ||
119 | |||
120 | .iconfont { | ||
121 | font-size: 32px; | ||
122 | } | ||
123 | |||
124 | .t1 { | ||
125 | padding: 0 6px; | ||
126 | } | ||
127 | |||
128 | &:last-child { | ||
129 | margin-right: 0; | ||
130 | } | ||
131 | } | ||
132 | |||
133 | .btn2 { | ||
134 | background-color: #fecd9f; | ||
135 | color: #7f776e; | ||
136 | } | ||
137 | |||
138 | |||
139 | } | ||
140 | |||
141 | } | ||
142 | |||
143 | .tit{ | ||
144 | @extend .bb; | ||
145 | padding: 0 24px; | ||
146 | } | ||
147 | } |
src/pages/detail/detail.wxml
0 → 100755
1 | <view class="page"> | ||
2 | <view class="app__bgc bgc"></view> | ||
3 | <view class="app__bg bg"></view> | ||
4 | <view class="app__content main"> | ||
5 | <view class="top-space"></view> | ||
6 | <view class="content"> | ||
7 | <view class="detail"> | ||
8 | <video objectFit="cover" class="vid" src="https://kd.cdn.xyiyang.com/pro/mzczcradmin/7e91e8a4c7b84e6fa4bada7c8617c9cf.mp4" /> | ||
9 | <view class="btn-wrap"> | ||
10 | <button class="btn"> | ||
11 | <span class="t1 iconfont iconplane"></span> | ||
12 | <span class="t1">分享给好友</span> | ||
13 | </button> | ||
14 | <button class="btn btn2"> | ||
15 | <span class="t1 iconfont iconplane"></span> | ||
16 | <span class="t1">分享到群</span> | ||
17 | </button> | ||
18 | </view> | ||
19 | </view> | ||
20 | <view class="func"> | ||
21 | <view class="user"> | ||
22 | <image class="portrait" mode="aspectFill" src="https://kd.cdn.xyiyang.com/pro/mzczcradmin/008194acee794506aac4c7200ce654dc.jpg" /> | ||
23 | <view class="desc"> | ||
24 | <view class="t1 name">我爱我家</view> | ||
25 | <view class="t1 num">280个视频</view> | ||
26 | </view> | ||
27 | </view> | ||
28 | <view class="btn-wrap"> | ||
29 | <view class="btn btn2"> | ||
30 | <span>更多推荐</span> | ||
31 | </view> | ||
32 | <view class="btn"> | ||
33 | <span class="t1 iconfont iconhome"></span> | ||
34 | <span>返回首页</span> | ||
35 | </view> | ||
36 | </view> | ||
37 | </view> | ||
38 | <view class="tit">超有创意的全家福,看了你也想拍!</view> | ||
39 | </view> | ||
40 | </view> | ||
41 | </view> |
1 | import { | ||
2 | getBindtapData | ||
3 | } from '../../utils/util' | ||
4 | |||
1 | let app = getApp(); | 5 | let app = getApp(); |
2 | Page({ | 6 | Page({ |
3 | data: {}, | 7 | data: { |
4 | onLoad(options) { | 8 | active: 0 |
9 | }, | ||
10 | onLoad(options) {}, | ||
11 | initData() { | ||
12 | |||
13 | }, | ||
14 | onChange(event) { | ||
15 | wx.showToast({ | ||
16 | title: `切换到标签 ${event.detail.name}`, | ||
17 | icon: 'none' | ||
18 | }); | ||
19 | }, | ||
20 | onVanTabsHandler(event) { | ||
21 | console.log("event:", event); | ||
22 | let { | ||
23 | index, | ||
24 | title | ||
25 | } = event.detail; | ||
26 | }, | ||
27 | onVideoHandler(evt) { | ||
28 | let curItem = getBindtapData(evt); | ||
29 | let curIndex = getBindtapData(evt, "index"); | ||
30 | app.router.push({ | ||
31 | path: "detail", | ||
32 | query: { | ||
33 | c: curIndex + "" | ||
34 | } | ||
35 | }) | ||
36 | console.log("curItem:", curItem); | ||
37 | console.log("curIndex:", curIndex); | ||
38 | }, | ||
39 | /** | ||
40 | * 获取列列表 | ||
41 | */ | ||
42 | queryList() { | ||
43 | |||
5 | } | 44 | } |
6 | }) | 45 | }) | ... | ... |
... | @@ -2,7 +2,12 @@ | ... | @@ -2,7 +2,12 @@ |
2 | @import '../../assets/scss/utils'; | 2 | @import '../../assets/scss/utils'; |
3 | 3 | ||
4 | .page { | 4 | .page { |
5 | .bgc {} | 5 | color: #333333; |
6 | font-size: 24px; | ||
7 | |||
8 | .bgc { | ||
9 | background-color: #efefef; | ||
10 | } | ||
6 | 11 | ||
7 | .bg {} | 12 | .bg {} |
8 | 13 | ||
... | @@ -14,5 +19,101 @@ | ... | @@ -14,5 +19,101 @@ |
14 | .content { | 19 | .content { |
15 | position: relative; | 20 | position: relative; |
16 | } | 21 | } |
22 | |||
23 | .list { | ||
24 | position: relative; | ||
25 | margin: 0 auto; | ||
26 | width: $contentWidth; | ||
27 | |||
28 | &-item { | ||
29 | position: relative; | ||
30 | background-color: #ffffff; | ||
31 | border-radius: 16px; | ||
32 | margin: 24px auto; | ||
33 | |||
34 | &-video { | ||
35 | display: flex; | ||
36 | justify-content: center; | ||
37 | position: relative; | ||
38 | width: $contentWidth; | ||
39 | |||
40 | .vid { | ||
41 | @include border-top-radius(16px); | ||
42 | width: $contentWidth; | ||
43 | pointer-events: none; | ||
44 | } | ||
45 | |||
46 | .tit { | ||
47 | color: #ffffff; | ||
48 | @extend .bb; | ||
49 | padding: 0 24px; | ||
50 | position: absolute; | ||
51 | width: 100%; | ||
52 | height: 64px; | ||
53 | line-height: 64px; | ||
54 | bottom: 0; | ||
55 | background-color: rgba($color: #000000, $alpha: 0.6); | ||
56 | @include border-top-radius(8px); | ||
57 | @include ellipsis(1); | ||
58 | |||
59 | } | ||
60 | } | ||
61 | |||
62 | &-func { | ||
63 | @extend .bb; | ||
64 | padding: 24px 24px; | ||
65 | height: 80px; | ||
66 | display: flex; | ||
67 | justify-content: space-between; | ||
68 | align-items: center; | ||
69 | |||
70 | .user { | ||
71 | display: flex; | ||
72 | align-items: center; | ||
73 | |||
74 | .portrait { | ||
75 | width: 48px; | ||
76 | height: 48px; | ||
77 | border-radius: 48px; | ||
78 | } | ||
79 | |||
80 | .name { | ||
81 | padding-left: 12px; | ||
82 | } | ||
83 | } | ||
84 | |||
85 | .share { | ||
86 | font-size: 24px; | ||
87 | display: flex; | ||
88 | justify-content: center; | ||
89 | align-items: center; | ||
90 | // width: 132px; | ||
91 | height: 48px; | ||
92 | color: #ffffff; | ||
93 | background-color: #3ec03c; | ||
94 | border-radius: 8px; | ||
95 | margin: 0; | ||
96 | |||
97 | .iconfont { | ||
98 | font-size: 32px; | ||
99 | } | ||
100 | |||
101 | .t1 { | ||
102 | padding: 0 6px; | ||
103 | } | ||
104 | } | ||
105 | } | ||
106 | |||
107 | } | ||
108 | } | ||
109 | } | ||
110 | |||
111 | |||
112 | .van-tab--active { | ||
113 | color: #fc464a; | ||
114 | } | ||
115 | |||
116 | .van-hairline--top-bottom:after { | ||
117 | border-width: 0; | ||
17 | } | 118 | } |
18 | } | 119 | } | ... | ... |
... | @@ -4,6 +4,33 @@ | ... | @@ -4,6 +4,33 @@ |
4 | <!-- <view class="app__top-shadow"></view> --> | 4 | <!-- <view class="app__top-shadow"></view> --> |
5 | <view class="app__content main"> | 5 | <view class="app__content main"> |
6 | <view class="top-space"></view> | 6 | <view class="top-space"></view> |
7 | <view class="content">index</view> | 7 | <van-sticky> |
8 | <van-tabs active="{{ active }}" bind:click="onVanTabsHandler"> | ||
9 | <van-tab title="精彩推荐"></van-tab> | ||
10 | <van-tab title="一起旅行"></van-tab> | ||
11 | <van-tab title="齐家欢乐"></van-tab> | ||
12 | <van-tab title="童趣无限"></van-tab> | ||
13 | </van-tabs> | ||
14 | </van-sticky> | ||
15 | <view class="content"> | ||
16 | <view class="list"> | ||
17 | <view bindtap="onVideoHandler" wx:for="{{8}}" wx:key="index" data-data="{{item}}" data-index="{{index}}" class="list-item"> | ||
18 | <view class="list-item-video"> | ||
19 | <video objectFit="cover" class="vid" poster="https://kd.cdn.xyiyang.com/pro/mzczcradmin/008194acee794506aac4c7200ce654dc.jpg" src="https://kd.cdn.xyiyang.com/pro/mzczcradmin/7e91e8a4c7b84e6fa4bada7c8617c9cf.mp4" /> | ||
20 | <view class="tit">这是一个视频</view> | ||
21 | </view> | ||
22 | <view class="list-item-func"> | ||
23 | <view class="user"> | ||
24 | <image class="portrait" mode="aspectFill" src="https://kd.cdn.xyiyang.com/pro/mzczcradmin/008194acee794506aac4c7200ce654dc.jpg" /> | ||
25 | <text class="name">我爱我家</text> | ||
26 | </view> | ||
27 | <button class="share"> | ||
28 | <span class="t1 iconfont iconwechat"></span> | ||
29 | <span class="t1">分享</span> | ||
30 | </button> | ||
31 | </view> | ||
32 | </view> | ||
33 | </view> | ||
34 | </view> | ||
8 | </view> | 35 | </view> |
9 | </view> | 36 | </view> | ... | ... |
1 | const routerPath = { | 1 | const routerPath = { |
2 | index: '/pages/index/index', | 2 | index: '/pages/index/index', |
3 | detail: '/pages/detail/detail', | ||
3 | authorize: '/pages/authorize/authorize', // 授权 | 4 | authorize: '/pages/authorize/authorize', // 授权 |
4 | example: '/pages/example/example', | 5 | example: '/pages/example/example', |
5 | more: '/pages/more/more', | 6 | more: '/pages/more/more', | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { safeArea } from '../mixins/safe-area'; | ||
3 | VantComponent({ | 2 | VantComponent({ |
4 | mixins: [safeArea()], | ||
5 | props: { | 3 | props: { |
6 | show: Boolean, | 4 | show: Boolean, |
7 | title: String, | 5 | title: String, |
8 | cancelText: String, | 6 | cancelText: String, |
7 | description: String, | ||
8 | round: { | ||
9 | type: Boolean, | ||
10 | value: true | ||
11 | }, | ||
9 | zIndex: { | 12 | zIndex: { |
10 | type: Number, | 13 | type: Number, |
11 | value: 100 | 14 | value: 100 |
... | @@ -21,6 +24,14 @@ VantComponent({ | ... | @@ -21,6 +24,14 @@ VantComponent({ |
21 | closeOnClickOverlay: { | 24 | closeOnClickOverlay: { |
22 | type: Boolean, | 25 | type: Boolean, |
23 | value: true | 26 | value: true |
27 | }, | ||
28 | closeOnClickAction: { | ||
29 | type: Boolean, | ||
30 | value: true | ||
31 | }, | ||
32 | safeAreaInsetBottom: { | ||
33 | type: Boolean, | ||
34 | value: true | ||
24 | } | 35 | } |
25 | }, | 36 | }, |
26 | methods: { | 37 | methods: { |
... | @@ -29,6 +40,9 @@ VantComponent({ | ... | @@ -29,6 +40,9 @@ VantComponent({ |
29 | const item = this.data.actions[index]; | 40 | const item = this.data.actions[index]; |
30 | if (item && !item.disabled && !item.loading) { | 41 | if (item && !item.disabled && !item.loading) { |
31 | this.$emit('select', item); | 42 | this.$emit('select', item); |
43 | if (this.data.closeOnClickAction) { | ||
44 | this.onClose(); | ||
45 | } | ||
32 | } | 46 | } |
33 | }, | 47 | }, |
34 | onCancel() { | 48 | onCancel() { |
... | @@ -36,6 +50,10 @@ VantComponent({ | ... | @@ -36,6 +50,10 @@ VantComponent({ |
36 | }, | 50 | }, |
37 | onClose() { | 51 | onClose() { |
38 | this.$emit('close'); | 52 | this.$emit('close'); |
53 | }, | ||
54 | onClickOverlay() { | ||
55 | this.$emit('click-overlay'); | ||
56 | this.onClose(); | ||
39 | } | 57 | } |
40 | } | 58 | } |
41 | }); | 59 | }); | ... | ... |
... | @@ -3,12 +3,13 @@ | ... | @@ -3,12 +3,13 @@ |
3 | <van-popup | 3 | <van-popup |
4 | show="{{ show }}" | 4 | show="{{ show }}" |
5 | position="bottom" | 5 | position="bottom" |
6 | round="{{ round }}" | ||
6 | z-index="{{ zIndex }}" | 7 | z-index="{{ zIndex }}" |
7 | overlay="{{ overlay }}" | 8 | overlay="{{ overlay }}" |
8 | custom-class="van-action-sheet" | 9 | custom-class="van-action-sheet" |
9 | safe-area-inset-bottom="{{ safeAreaInsetBottom }}" | 10 | safe-area-inset-bottom="{{ safeAreaInsetBottom }}" |
10 | close-on-click-overlay="{{ closeOnClickOverlay }}" | 11 | close-on-click-overlay="{{ closeOnClickOverlay }}" |
11 | bind:close="onClose" | 12 | bind:close="onClickOverlay" |
12 | > | 13 | > |
13 | <view wx:if="{{ title }}" class="van-hairline--bottom van-action-sheet__header"> | 14 | <view wx:if="{{ title }}" class="van-hairline--bottom van-action-sheet__header"> |
14 | {{ title }} | 15 | {{ title }} |
... | @@ -18,12 +19,16 @@ | ... | @@ -18,12 +19,16 @@ |
18 | bind:click="onClose" | 19 | bind:click="onClose" |
19 | /> | 20 | /> |
20 | </view> | 21 | </view> |
22 | <view wx:if="{{ description }}" class="van-action-sheet__description"> | ||
23 | {{ description }} | ||
24 | </view> | ||
21 | <view wx:if="{{ actions && actions.length }}"> | 25 | <view wx:if="{{ actions && actions.length }}"> |
22 | <!-- button外包一层view,防止actions动态变化,导致渲染时button被打散 --> | 26 | <!-- button外包一层view,防止actions动态变化,导致渲染时button被打散 --> |
23 | <button | 27 | <button |
24 | wx:for="{{ actions }}" | 28 | wx:for="{{ actions }}" |
25 | wx:key="index" | 29 | wx:key="index" |
26 | open-type="{{ item.openType }}" | 30 | open-type="{{ item.openType }}" |
31 | style="{{ item.color ? 'color: ' + item.color : '' }}" | ||
27 | class="{{ utils.bem('action-sheet__item', { disabled: item.disabled || item.loading }) }} van-hairline--top {{ item.className || '' }}" | 32 | class="{{ utils.bem('action-sheet__item', { disabled: item.disabled || item.loading }) }} van-hairline--top {{ item.className || '' }}" |
28 | hover-class="van-action-sheet__item--hover" | 33 | hover-class="van-action-sheet__item--hover" |
29 | data-index="{{ index }}" | 34 | data-index="{{ index }}" |
... | @@ -33,7 +38,7 @@ | ... | @@ -33,7 +38,7 @@ |
33 | {{ item.name }} | 38 | {{ item.name }} |
34 | <text wx:if="{{ item.subname }}" class="van-action-sheet__subname" >{{ item.subname }}</text> | 39 | <text wx:if="{{ item.subname }}" class="van-action-sheet__subname" >{{ item.subname }}</text> |
35 | </block> | 40 | </block> |
36 | <van-loading wx:else size="20px" /> | 41 | <van-loading wx:else custom-class="van-action-sheet__loading" size="20px" /> |
37 | </button> | 42 | </button> |
38 | </view> | 43 | </view> |
39 | <slot /> | 44 | <slot /> | ... | ... |
1 | @import '../common/index.wxss';.van-action-sheet{max-height:90%!important;color:#333}.van-action-sheet__cancel,.van-action-sheet__item{height:50px;font-size:16px;line-height:50px;text-align:center;background-color:#fff}.van-action-sheet__cancel--hover,.van-action-sheet__item--hover{background-color:#f2f3f5}.van-action-sheet__cancel{height:60px}.van-action-sheet__cancel:before{display:block;height:10px;background-color:#f8f8f8;content:" "}.van-action-sheet__item--disabled{color:#c9c9c9}.van-action-sheet__item--disabled.van-action-sheet__item--hover{background-color:#fff}.van-action-sheet__subname{margin-left:5px;font-size:12px;color:#7d7e80}.van-action-sheet__header{font-size:16px;font-weight:500;line-height:44px;text-align:center}.van-action-sheet__close{position:absolute!important;top:0;right:0;padding:0 15px;font-size:18px!important;line-height:inherit!important;color:#999} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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:#f8f8f8;background-color:var(--action-sheet-cancel-padding-color,#f8f8f8)}.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:#7d7e80;color:var(--action-sheet-subname-color,#7d7e80)}.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:#7d7e80;color:var(--action-sheet-description-color,#7d7e80);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 | ... | \ No newline at end of file | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { pickerProps } from '../picker/shared'; | ||
3 | const COLUMNSPLACEHOLDERCODE = '000000'; | ||
2 | VantComponent({ | 4 | VantComponent({ |
3 | classes: ['active-class', 'toolbar-class', 'column-class'], | 5 | classes: ['active-class', 'toolbar-class', 'column-class'], |
4 | props: { | 6 | props: Object.assign(Object.assign({}, pickerProps), { value: String, areaList: { |
5 | title: String, | ||
6 | value: String, | ||
7 | loading: Boolean, | ||
8 | cancelButtonText: String, | ||
9 | confirmButtonText: String, | ||
10 | itemHeight: { | ||
11 | type: Number, | ||
12 | value: 44 | ||
13 | }, | ||
14 | visibleItemCount: { | ||
15 | type: Number, | ||
16 | value: 5 | ||
17 | }, | ||
18 | columnsNum: { | ||
19 | type: [String, Number], | ||
20 | value: 3 | ||
21 | }, | ||
22 | areaList: { | ||
23 | type: Object, | 7 | type: Object, |
24 | value: {} | 8 | value: {} |
9 | }, columnsNum: { | ||
10 | type: null, | ||
11 | value: 3 | ||
12 | }, columnsPlaceholder: { | ||
13 | type: Array, | ||
14 | observer(val) { | ||
15 | this.setData({ | ||
16 | typeToColumnsPlaceholder: { | ||
17 | province: val[0] || '', | ||
18 | city: val[1] || '', | ||
19 | county: val[2] || '', | ||
25 | } | 20 | } |
26 | }, | 21 | }); |
22 | } | ||
23 | } }), | ||
27 | data: { | 24 | data: { |
28 | columns: [{ values: [] }, { values: [] }, { values: [] }], | 25 | columns: [{ values: [] }, { values: [] }, { values: [] }], |
29 | displayColumns: [{ values: [] }, { values: [] }, { values: [] }] | 26 | displayColumns: [{ values: [] }, { values: [] }, { values: [] }], |
27 | typeToColumnsPlaceholder: {} | ||
30 | }, | 28 | }, |
31 | watch: { | 29 | watch: { |
32 | value(value) { | 30 | value(value) { |
... | @@ -35,11 +33,16 @@ VantComponent({ | ... | @@ -35,11 +33,16 @@ VantComponent({ |
35 | }, | 33 | }, |
36 | areaList: 'setValues', | 34 | areaList: 'setValues', |
37 | columnsNum(value) { | 35 | columnsNum(value) { |
38 | this.set({ | 36 | this.setData({ |
39 | displayColumns: this.data.columns.slice(0, +value) | 37 | displayColumns: this.data.columns.slice(0, +value) |
40 | }); | 38 | }); |
41 | } | 39 | } |
42 | }, | 40 | }, |
41 | mounted() { | ||
42 | setTimeout(() => { | ||
43 | this.setValues(); | ||
44 | }, 0); | ||
45 | }, | ||
43 | methods: { | 46 | methods: { |
44 | getPicker() { | 47 | getPicker() { |
45 | if (this.picker == null) { | 48 | if (this.picker == null) { |
... | @@ -51,20 +54,40 @@ VantComponent({ | ... | @@ -51,20 +54,40 @@ VantComponent({ |
51 | this.emit('cancel', event.detail); | 54 | this.emit('cancel', event.detail); |
52 | }, | 55 | }, |
53 | onConfirm(event) { | 56 | onConfirm(event) { |
54 | this.emit('confirm', event.detail); | 57 | const { index } = event.detail; |
58 | let { value } = event.detail; | ||
59 | value = this.parseOutputValues(value); | ||
60 | this.emit('confirm', { value, index }); | ||
55 | }, | 61 | }, |
56 | emit(type, detail) { | 62 | emit(type, detail) { |
57 | detail.values = detail.value; | 63 | detail.values = detail.value; |
58 | delete detail.value; | 64 | delete detail.value; |
59 | this.$emit(type, detail); | 65 | this.$emit(type, detail); |
60 | }, | 66 | }, |
67 | // parse output columns data | ||
68 | parseOutputValues(values) { | ||
69 | const { columnsPlaceholder } = this.data; | ||
70 | return values.map((value, index) => { | ||
71 | // save undefined value | ||
72 | if (!value) | ||
73 | return value; | ||
74 | value = JSON.parse(JSON.stringify(value)); | ||
75 | if (!value.code || value.name === columnsPlaceholder[index]) { | ||
76 | value.code = ''; | ||
77 | value.name = ''; | ||
78 | } | ||
79 | return value; | ||
80 | }); | ||
81 | }, | ||
61 | onChange(event) { | 82 | onChange(event) { |
62 | const { index, picker, value } = event.detail; | 83 | const { index, picker, value } = event.detail; |
63 | this.code = value[index].code; | 84 | this.code = value[index].code; |
85 | let getValues = picker.getValues(); | ||
86 | getValues = this.parseOutputValues(getValues); | ||
64 | this.setValues().then(() => { | 87 | this.setValues().then(() => { |
65 | this.$emit('change', { | 88 | this.$emit('change', { |
66 | picker, | 89 | picker, |
67 | values: picker.getValues(), | 90 | values: getValues, |
68 | index | 91 | index |
69 | }); | 92 | }); |
70 | }); | 93 | }); |
... | @@ -74,6 +97,7 @@ VantComponent({ | ... | @@ -74,6 +97,7 @@ VantComponent({ |
74 | return (areaList && areaList[`${type}_list`]) || {}; | 97 | return (areaList && areaList[`${type}_list`]) || {}; |
75 | }, | 98 | }, |
76 | getList(type, code) { | 99 | getList(type, code) { |
100 | const { typeToColumnsPlaceholder } = this.data; | ||
77 | let result = []; | 101 | let result = []; |
78 | if (type !== 'province' && !code) { | 102 | if (type !== 'province' && !code) { |
79 | return result; | 103 | return result; |
... | @@ -90,6 +114,14 @@ VantComponent({ | ... | @@ -90,6 +114,14 @@ VantComponent({ |
90 | } | 114 | } |
91 | result = result.filter(item => item.code.indexOf(code) === 0); | 115 | result = result.filter(item => item.code.indexOf(code) === 0); |
92 | } | 116 | } |
117 | if (typeToColumnsPlaceholder[type] && result.length) { | ||
118 | // set columns placeholder | ||
119 | const codeFill = type === 'province' ? '' : type === 'city' ? COLUMNSPLACEHOLDERCODE.slice(2, 4) : COLUMNSPLACEHOLDERCODE.slice(4, 6); | ||
120 | result.unshift({ | ||
121 | code: `${code}${codeFill}`, | ||
122 | name: typeToColumnsPlaceholder[type] | ||
123 | }); | ||
124 | } | ||
93 | return result; | 125 | return result; |
94 | }, | 126 | }, |
95 | getIndex(type, code) { | 127 | getIndex(type, code) { |
... | @@ -109,7 +141,18 @@ VantComponent({ | ... | @@ -109,7 +141,18 @@ VantComponent({ |
109 | }, | 141 | }, |
110 | setValues() { | 142 | setValues() { |
111 | const county = this.getConfig('county'); | 143 | const county = this.getConfig('county'); |
112 | let code = this.code || Object.keys(county)[0] || ''; | 144 | let { code } = this; |
145 | if (!code) { | ||
146 | if (this.data.columnsPlaceholder.length) { | ||
147 | code = COLUMNSPLACEHOLDERCODE; | ||
148 | } | ||
149 | else if (Object.keys(county)[0]) { | ||
150 | code = Object.keys(county)[0]; | ||
151 | } | ||
152 | else { | ||
153 | code = ''; | ||
154 | } | ||
155 | } | ||
113 | const province = this.getList('province'); | 156 | const province = this.getList('province'); |
114 | const city = this.getList('city', code.slice(0, 2)); | 157 | const city = this.getList('city', code.slice(0, 2)); |
115 | const picker = this.getPicker(); | 158 | const picker = this.getPicker(); |
... | @@ -120,7 +163,6 @@ VantComponent({ | ... | @@ -120,7 +163,6 @@ VantComponent({ |
120 | stack.push(picker.setColumnValues(0, province, false)); | 163 | stack.push(picker.setColumnValues(0, province, false)); |
121 | stack.push(picker.setColumnValues(1, city, false)); | 164 | stack.push(picker.setColumnValues(1, city, false)); |
122 | if (city.length && code.slice(2, 4) === '00') { | 165 | if (city.length && code.slice(2, 4) === '00') { |
123 | ; | ||
124 | [{ code }] = city; | 166 | [{ code }] = city; |
125 | } | 167 | } |
126 | stack.push(picker.setColumnValues(2, this.getList('county', code.slice(0, 4)), false)); | 168 | stack.push(picker.setColumnValues(2, this.getList('county', code.slice(0, 4)), false)); |
... | @@ -162,8 +204,8 @@ VantComponent({ | ... | @@ -162,8 +204,8 @@ VantComponent({ |
162 | } | 204 | } |
163 | return area; | 205 | return area; |
164 | }, | 206 | }, |
165 | reset() { | 207 | reset(code) { |
166 | this.code = ''; | 208 | this.code = code || ''; |
167 | return this.setValues(); | 209 | return this.setValues(); |
168 | } | 210 | } |
169 | } | 211 | } | ... | ... |
1 | @import '../common/index.wxss';.van-badge-group{width:85px} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
src/ui/vant-weapp/badge/index.wxss
deleted
100755 → 0
1 | @import '../common/index.wxss';.van-badge{display:block;padding:20px 12px 20px 9px;overflow:hidden;font-size:14px;line-height:1.4;color:#7d7e80;word-break:break-all;background-color:#f8f8f8;border-left:3px solid transparent;box-sizing:border-box;-webkit-user-select:none;user-select:none}.van-badge--hover{background-color:#f2f3f5}.van-badge:after{border-bottom-width:1px}.van-badge--active{font-weight:700;color:#333;border-color:#f44}.van-badge--active:after{border-right-width:1px}.van-badge--active,.van-badge--active.van-badge--hover{background-color:#fff}.van-badge__text{position:relative} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -4,7 +4,11 @@ import { openType } from '../mixins/open-type'; | ... | @@ -4,7 +4,11 @@ import { openType } from '../mixins/open-type'; |
4 | VantComponent({ | 4 | VantComponent({ |
5 | mixins: [button, openType], | 5 | mixins: [button, openType], |
6 | classes: ['hover-class', 'loading-class'], | 6 | classes: ['hover-class', 'loading-class'], |
7 | data: { | ||
8 | style: '' | ||
9 | }, | ||
7 | props: { | 10 | props: { |
11 | icon: String, | ||
8 | plain: Boolean, | 12 | plain: Boolean, |
9 | block: Boolean, | 13 | block: Boolean, |
10 | round: Boolean, | 14 | round: Boolean, |
... | @@ -13,6 +17,11 @@ VantComponent({ | ... | @@ -13,6 +17,11 @@ VantComponent({ |
13 | hairline: Boolean, | 17 | hairline: Boolean, |
14 | disabled: Boolean, | 18 | disabled: Boolean, |
15 | loadingText: String, | 19 | loadingText: String, |
20 | customStyle: String, | ||
21 | loadingType: { | ||
22 | type: String, | ||
23 | value: 'circular' | ||
24 | }, | ||
16 | type: { | 25 | type: { |
17 | type: String, | 26 | type: String, |
18 | value: 'default' | 27 | value: 'default' |
... | @@ -24,6 +33,29 @@ VantComponent({ | ... | @@ -24,6 +33,29 @@ VantComponent({ |
24 | loadingSize: { | 33 | loadingSize: { |
25 | type: String, | 34 | type: String, |
26 | value: '20px' | 35 | value: '20px' |
36 | }, | ||
37 | color: { | ||
38 | type: String, | ||
39 | observer(color) { | ||
40 | let style = ''; | ||
41 | if (color) { | ||
42 | style += `color: ${this.data.plain ? color : 'white'};`; | ||
43 | if (!this.data.plain) { | ||
44 | // Use background instead of backgroundColor to make linear-gradient work | ||
45 | style += `background: ${color};`; | ||
46 | } | ||
47 | // hide border when color is linear-gradient | ||
48 | if (color.indexOf('gradient') !== -1) { | ||
49 | style += 'border: 0;'; | ||
50 | } | ||
51 | else { | ||
52 | style += `border-color: ${color};`; | ||
53 | } | ||
54 | } | ||
55 | if (style !== this.data.style) { | ||
56 | this.setData({ style }); | ||
57 | } | ||
58 | } | ||
27 | } | 59 | } |
28 | }, | 60 | }, |
29 | methods: { | 61 | methods: { | ... | ... |
... | @@ -3,9 +3,10 @@ | ... | @@ -3,9 +3,10 @@ |
3 | <button | 3 | <button |
4 | id="{{ id }}" | 4 | id="{{ id }}" |
5 | class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}" | 5 | class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}" |
6 | open-type="{{ openType }}" | ||
7 | hover-class="van-button--active hover-class" | 6 | hover-class="van-button--active hover-class" |
8 | lang="{{ lang }}" | 7 | lang="{{ lang }}" |
8 | style="{{ style }} {{ customStyle }}" | ||
9 | open-type="{{ openType }}" | ||
9 | business-id="{{ businessId }}" | 10 | business-id="{{ businessId }}" |
10 | session-from="{{ sessionFrom }}" | 11 | session-from="{{ sessionFrom }}" |
11 | send-message-title="{{ sendMessageTitle }}" | 12 | send-message-title="{{ sendMessageTitle }}" |
... | @@ -26,7 +27,8 @@ | ... | @@ -26,7 +27,8 @@ |
26 | <van-loading | 27 | <van-loading |
27 | custom-class="loading-class" | 28 | custom-class="loading-class" |
28 | size="{{ loadingSize }}" | 29 | size="{{ loadingSize }}" |
29 | color="{{ type === 'default' ? '#c9c9c9' : '' }}" | 30 | type="{{ loadingType }}" |
31 | color="{{ type === 'default' ? '#c9c9c9' : 'white' }}" | ||
30 | /> | 32 | /> |
31 | <view | 33 | <view |
32 | wx:if="{{ loadingText }}" | 34 | wx:if="{{ loadingText }}" |
... | @@ -35,5 +37,16 @@ | ... | @@ -35,5 +37,16 @@ |
35 | {{ loadingText }} | 37 | {{ loadingText }} |
36 | </view> | 38 | </view> |
37 | </block> | 39 | </block> |
38 | <slot wx:else /> | 40 | <block wx:else> |
41 | <van-icon | ||
42 | wx:if="{{ icon }}" | ||
43 | size="1.2em" | ||
44 | name="{{ icon }}" | ||
45 | class="van-button__icon" | ||
46 | custom-style="line-height: inherit;" | ||
47 | /> | ||
48 | <view class="van-button__text"> | ||
49 | <slot /> | ||
50 | </view> | ||
51 | </block> | ||
39 | </button> | 52 | </button> | ... | ... |
1 | @import '../common/index.wxss';.van-button{position:relative;display:inline-block;height:44px;padding:0;font-size:16px;line-height:42px;text-align:center;vertical-align:middle;box-sizing:border-box;border-radius:2px;-webkit-appearance:none;-webkit-text-size-adjust:100%}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;background-color:#000;border:inherit;border-color:#000;border-radius:inherit;content:" ";opacity:0;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#333;background-color:#fff;border:1px solid #eee}.van-button--primary{color:#fff;background-color:#07c160;border:1px solid #07c160}.van-button--info{color:#fff;background-color:#1989fa;border:1px solid #1989fa}.van-button--danger{color:#fff;background-color:#f44;border:1px solid #f44}.van-button--warning{color:#fff;background-color:#ff976a;border:1px solid #ff976a}.van-button--plain{background-color:#fff}.van-button--plain.van-button--primary{color:#07c160}.van-button--plain.van-button--info{color:#1989fa}.van-button--plain.van-button--danger{color:#f44}.van-button--plain.van-button--warning{color:#ff976a}.van-button--large{width:100%;height:50px;line-height:48px}.van-button--normal{padding:0 15px;font-size:14px}.van-button--small{height:30px;min-width:60px;padding:0 8px;font-size:12px;line-height:28px}.van-button--mini{display:inline-block;width:50px;height:22px;font-size:10px;line-height:20px}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:block;width:100%}.van-button--round{border-radius:10em}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5}.van-button__loading-text{margin-left:5px;display:inline-block;vertical-align:middle}.van-button--hairline{border-width:0;padding-top:1px}.van-button--hairline:after{border-width:1px;border-color:inherit;border-radius:4px}.van-button--hairline.van-button--round:after{border-radius:10em}.van-button--hairline.van-button--square:after{border-radius:0} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
... | @@ -34,6 +34,7 @@ | ... | @@ -34,6 +34,7 @@ |
34 | <view wx:if="{{ price || price === 0 }}" class="van-card__price price-class">{{ currency }} {{ price }}</view> | 34 | <view wx:if="{{ price || price === 0 }}" class="van-card__price price-class">{{ currency }} {{ price }}</view> |
35 | <view wx:if="{{ originPrice || originPrice === 0 }}" class="van-card__origin-price origin-price-class">{{ currency }} {{ originPrice }}</view> | 35 | <view wx:if="{{ originPrice || originPrice === 0 }}" class="van-card__origin-price origin-price-class">{{ currency }} {{ originPrice }}</view> |
36 | <view wx:if="{{ num }}" class="van-card__num num-class">x {{ num }}</view> | 36 | <view wx:if="{{ num }}" class="van-card__num num-class">x {{ num }}</view> |
37 | <slot name="bottom" /> | ||
37 | </view> | 38 | </view> |
38 | </view> | 39 | </view> |
39 | </view> | 40 | </view> | ... | ... |
1 | @import '../common/index.wxss';.van-card{position:relative;padding:5px 15px;font-size:12px;color:#333;background-color:#fafafa;box-sizing:border-box}.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;width:90px;height:90px;margin-right:10px;-webkit-flex:none;flex:none}.van-card__thumb:empty{display:none}.van-card__img{width:100%;height:100%}.van-card__content{position:relative;min-width:0;-webkit-flex:1;flex:1}.van-card__desc,.van-card__title{word-break:break-all}.van-card__title{font-weight:700;line-height:16px}.van-card__desc{color:#7d7e80}.van-card__bottom,.van-card__desc{line-height:20px}.van-card__price{display:inline-block;font-weight:700;color:#f44}.van-card__origin-price{display:inline-block;margin-left:5px;font-size:10px;color:#7d7e80;text-decoration:line-through}.van-card__num{float:right}.van-card__tag{position:absolute;top:2px;left:0}.van-card__footer{width:100%;text-align:right;-webkit-flex:none;flex:none} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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:#7d7e80;color:var(--card-desc-color,#7d7e80)}.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:#7d7e80;color:var(--card-origin-price-color,#7d7e80)}.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 | ... | \ No newline at end of file | ... | ... |
1 | @import '../common/index.wxss';.van-cell-group__title{font-size:14px;padding:15px 15px 5px;color:#999;line-height:16px} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
... | @@ -22,6 +22,7 @@ VantComponent({ | ... | @@ -22,6 +22,7 @@ VantComponent({ |
22 | titleWidth: String, | 22 | titleWidth: String, |
23 | customStyle: String, | 23 | customStyle: String, |
24 | arrowDirection: String, | 24 | arrowDirection: String, |
25 | useLabelSlot: Boolean, | ||
25 | border: { | 26 | border: { |
26 | type: Boolean, | 27 | type: Boolean, |
27 | value: true | 28 | value: true | ... | ... |
... | @@ -19,11 +19,13 @@ | ... | @@ -19,11 +19,13 @@ |
19 | style="{{ titleWidth ? 'max-width:' + titleWidth + ';min-width:' + titleWidth : '' }}" | 19 | style="{{ titleWidth ? 'max-width:' + titleWidth + ';min-width:' + titleWidth : '' }}" |
20 | class="van-cell__title title-class" | 20 | class="van-cell__title title-class" |
21 | > | 21 | > |
22 | <block wx:if="{{ title }}"> | 22 | <block wx:if="{{ title }}">{{ title }}</block> |
23 | {{ title }} | ||
24 | <view wx:if="{{ label }}" class="van-cell__label label-class">{{ label }}</view> | ||
25 | </block> | ||
26 | <slot wx:else name="title" /> | 23 | <slot wx:else name="title" /> |
24 | |||
25 | <view wx:if="{{ label || useLabelSlot }}" class="van-cell__label label-class"> | ||
26 | <slot wx:if="{{ useLabelSlot }}" name="label" /> | ||
27 | <block wx:elif="{{ label }}">{{ label }}</block> | ||
28 | </view> | ||
27 | </view> | 29 | </view> |
28 | 30 | ||
29 | <view class="van-cell__value value-class"> | 31 | <view class="van-cell__value value-class"> | ... | ... |
1 | @import '../common/index.wxss';.van-cell{position:relative;display:-webkit-flex;display:flex;width:100%;padding:10px 15px;font-size:14px;line-height:24px;color:#333;background-color:#fff;box-sizing:border-box}.van-cell:after{content:" ";position:absolute;pointer-events:none;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;top:auto;left:15px;right:0;bottom:0;-webkit-transform:scaleY(.5);transform:scaleY(.5);border-bottom:1px solid #eee}.van-cell--borderless:after{display:none}.van-cell-group{background-color:#fff}.van-cell__label{margin-top:3px;font-size:12px;line-height:18px;color:#999}.van-cell__value{overflow:hidden;color:#999;text-align:right;vertical-align:middle}.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;height:24px;font-size:16px;-webkit-align-items:center;align-items:center}.van-cell__left-icon-wrap{margin-right:5px}.van-cell__right-icon-wrap{margin-left:5px;color:#999}.van-cell__left-icon{line-height:24px;vertical-align:middle}.van-cell__right-icon{line-height:24px}.van-cell--clickable.van-cell--hover{background-color:#f2f3f5}.van-cell--required{overflow:visible}.van-cell--required:before{position:absolute;left:7px;font-size:14px;color:#f44;content:"*"}.van-cell--center{-webkit-align-items:center;align-items:center}.van-cell--large{padding-top:12px;padding-bottom:12px}.van-cell--large .van-cell__title{font-size:16px}.van-cell--large .van-cell__label{font-size:14px} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
... | @@ -5,29 +5,34 @@ VantComponent({ | ... | @@ -5,29 +5,34 @@ VantComponent({ |
5 | name: 'checkbox', | 5 | name: 'checkbox', |
6 | type: 'descendant', | 6 | type: 'descendant', |
7 | linked(target) { | 7 | linked(target) { |
8 | const { value, disabled } = this.data; | 8 | this.children = this.children || []; |
9 | target.set({ | 9 | this.children.push(target); |
10 | value: value.indexOf(target.data.name) !== -1, | 10 | this.updateChild(target); |
11 | disabled: disabled || target.data.disabled | 11 | }, |
12 | }); | 12 | unlinked(target) { |
13 | this.children = this.children.filter((child) => child !== target); | ||
13 | } | 14 | } |
14 | }, | 15 | }, |
15 | props: { | 16 | props: { |
16 | max: Number, | 17 | max: Number, |
17 | value: Array, | 18 | value: { |
18 | disabled: Boolean | 19 | type: Array, |
20 | observer: 'updateChildren' | ||
19 | }, | 21 | }, |
20 | watch: { | 22 | disabled: { |
21 | value(value) { | 23 | type: Boolean, |
22 | const children = this.getRelationNodes('../checkbox/index'); | 24 | observer: 'updateChildren' |
23 | children.forEach(child => { | 25 | } |
24 | child.set({ value: value.indexOf(child.data.name) !== -1 }); | 26 | }, |
25 | }); | 27 | methods: { |
28 | updateChildren() { | ||
29 | (this.children || []).forEach((child) => this.updateChild(child)); | ||
26 | }, | 30 | }, |
27 | disabled(disabled) { | 31 | updateChild(child) { |
28 | const children = this.getRelationNodes('../checkbox/index'); | 32 | const { value, disabled } = this.data; |
29 | children.forEach(child => { | 33 | child.setData({ |
30 | child.set({ disabled: disabled || child.data.disabled }); | 34 | value: value.indexOf(child.data.name) !== -1, |
35 | disabled: disabled || child.data.disabled | ||
31 | }); | 36 | }); |
32 | } | 37 | } |
33 | } | 38 | } | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { addUnit } from '../common/utils'; | ||
3 | function emit(target, value) { | ||
4 | target.$emit('input', value); | ||
5 | target.$emit('change', value); | ||
6 | } | ||
2 | VantComponent({ | 7 | VantComponent({ |
3 | field: true, | 8 | field: true, |
4 | relation: { | 9 | relation: { |
5 | name: 'checkbox-group', | 10 | name: 'checkbox-group', |
6 | type: 'ancestor' | 11 | type: 'ancestor', |
12 | linked(target) { | ||
13 | this.parent = target; | ||
14 | }, | ||
15 | unlinked() { | ||
16 | this.parent = null; | ||
17 | } | ||
7 | }, | 18 | }, |
8 | classes: ['icon-class', 'label-class'], | 19 | classes: ['icon-class', 'label-class'], |
9 | props: { | 20 | props: { |
10 | value: null, | 21 | value: Boolean, |
11 | disabled: Boolean, | 22 | disabled: Boolean, |
12 | useIconSlot: Boolean, | 23 | useIconSlot: Boolean, |
13 | checkedColor: String, | 24 | checkedColor: String, |
... | @@ -16,52 +27,61 @@ VantComponent({ | ... | @@ -16,52 +27,61 @@ VantComponent({ |
16 | shape: { | 27 | shape: { |
17 | type: String, | 28 | type: String, |
18 | value: 'round' | 29 | value: 'round' |
30 | }, | ||
31 | iconSize: { | ||
32 | type: null, | ||
33 | observer: 'setSizeWithUnit' | ||
19 | } | 34 | } |
20 | }, | 35 | }, |
36 | data: { | ||
37 | sizeWithUnit: '20px' | ||
38 | }, | ||
21 | methods: { | 39 | methods: { |
22 | emitChange(value) { | 40 | emitChange(value) { |
23 | const parent = this.getRelationNodes('../checkbox-group/index')[0]; | 41 | if (this.parent) { |
24 | if (parent) { | 42 | this.setParentValue(this.parent, value); |
25 | this.setParentValue(parent, value); | ||
26 | } | 43 | } |
27 | else { | 44 | else { |
28 | this.$emit('input', value); | 45 | emit(this, value); |
29 | this.$emit('change', value); | ||
30 | } | 46 | } |
31 | }, | 47 | }, |
32 | toggle() { | 48 | toggle() { |
33 | if (!this.data.disabled) { | 49 | const { disabled, value } = this.data; |
34 | this.emitChange(!this.data.value); | 50 | if (!disabled) { |
51 | this.emitChange(!value); | ||
35 | } | 52 | } |
36 | }, | 53 | }, |
37 | onClickLabel() { | 54 | onClickLabel() { |
38 | if (!this.data.disabled && !this.data.labelDisabled) { | 55 | const { labelDisabled, disabled, value } = this.data; |
39 | this.emitChange(!this.data.value); | 56 | if (!disabled && !labelDisabled) { |
57 | this.emitChange(!value); | ||
40 | } | 58 | } |
41 | }, | 59 | }, |
42 | setParentValue(parent, value) { | 60 | setParentValue(parent, value) { |
43 | const parentValue = parent.data.value.slice(); | 61 | const parentValue = parent.data.value.slice(); |
44 | const { name } = this.data; | 62 | const { name } = this.data; |
63 | const { max } = parent.data; | ||
45 | if (value) { | 64 | if (value) { |
46 | if (parent.data.max && parentValue.length >= parent.data.max) { | 65 | if (max && parentValue.length >= max) { |
47 | return; | 66 | return; |
48 | } | 67 | } |
49 | /* istanbul ignore else */ | ||
50 | if (parentValue.indexOf(name) === -1) { | 68 | if (parentValue.indexOf(name) === -1) { |
51 | parentValue.push(name); | 69 | parentValue.push(name); |
52 | parent.$emit('input', parentValue); | 70 | emit(parent, parentValue); |
53 | parent.$emit('change', parentValue); | ||
54 | } | 71 | } |
55 | } | 72 | } |
56 | else { | 73 | else { |
57 | const index = parentValue.indexOf(name); | 74 | const index = parentValue.indexOf(name); |
58 | /* istanbul ignore else */ | ||
59 | if (index !== -1) { | 75 | if (index !== -1) { |
60 | parentValue.splice(index, 1); | 76 | parentValue.splice(index, 1); |
61 | parent.$emit('input', parentValue); | 77 | emit(parent, parentValue); |
62 | parent.$emit('change', parentValue); | ||
63 | } | ||
64 | } | 78 | } |
65 | } | 79 | } |
80 | }, | ||
81 | setSizeWithUnit(size) { | ||
82 | this.set({ | ||
83 | sizeWithUnit: addUnit(size) | ||
84 | }); | ||
85 | }, | ||
66 | } | 86 | } |
67 | }); | 87 | }); | ... | ... |
... | @@ -6,10 +6,11 @@ | ... | @@ -6,10 +6,11 @@ |
6 | <van-icon | 6 | <van-icon |
7 | wx:else | 7 | wx:else |
8 | name="success" | 8 | name="success" |
9 | size="0.8em" | ||
9 | class="{{ utils.bem('checkbox__icon', [shape, { disabled, checked: value }]) }}" | 10 | class="{{ utils.bem('checkbox__icon', [shape, { disabled, checked: value }]) }}" |
10 | style="{{ checkedColor && value && !disabled ? 'border-color:' + checkedColor + '; background-color:' + checkedColor : '' }}" | 11 | style="font-size: {{ sizeWithUnit }};{{ checkedColor && value && !disabled ? 'border-color:' + checkedColor + '; background-color:' + checkedColor : '' }}" |
11 | custom-class="icon-class" | 12 | custom-class="icon-class" |
12 | custom-style="line-height: 20px;" | 13 | custom-style="line-height: 1.25em;" |
13 | /> | 14 | /> |
14 | </view> | 15 | </view> |
15 | <view class="label-class {{ utils.bem('checkbox__label', [labelPosition, { disabled }]) }}" bindtap="onClickLabel"> | 16 | <view class="label-class {{ utils.bem('checkbox__label', [labelPosition, { disabled }]) }}" bindtap="onClickLabel"> | ... | ... |
1 | @import '../common/index.wxss';.van-checkbox{overflow:hidden;-webkit-user-select:none;user-select:none}.van-checkbox__icon-wrap,.van-checkbox__label{display:inline-block;line-height:20px;vertical-align:middle}.van-checkbox__icon{display:block;font-size:14px;width:20px;height:20px;color:transparent;text-align:center;box-sizing:border-box;border:1px solid #e5e5e5;transition:.2s}.van-checkbox__icon--round{border-radius:100%}.van-checkbox__icon--checked{color:#fff;border-color:#1989fa;background-color:#1989fa}.van-checkbox__icon--disabled{border-color:#c9c9c9;background-color:#eee}.van-checkbox__icon--disabled.van-checkbox__icon--checked{color:#c9c9c9}.van-checkbox__label{color:#333;margin-left:10px}.van-checkbox__label--left{float:left;margin:0 10px 0 0}.van-checkbox__label--disabled{color:#c9c9c9}.van-checkbox__label:empty{margin:0} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 #e5e5e5;border:1px solid var(--checkbox-border-color,#e5e5e5);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 | ... | \ No newline at end of file | ... | ... |
src/ui/vant-weapp/circle/index.js
0 → 100755
1 | import { VantComponent } from '../common/component'; | ||
2 | import { isObj } from '../common/utils'; | ||
3 | import { BLUE, WHITE } from '../common/color'; | ||
4 | function format(rate) { | ||
5 | return Math.min(Math.max(rate, 0), 100); | ||
6 | } | ||
7 | const PERIMETER = 2 * Math.PI; | ||
8 | const BEGIN_ANGLE = -Math.PI / 2; | ||
9 | const STEP = 1; | ||
10 | VantComponent({ | ||
11 | props: { | ||
12 | text: String, | ||
13 | lineCap: { | ||
14 | type: String, | ||
15 | value: 'round' | ||
16 | }, | ||
17 | value: { | ||
18 | type: Number, | ||
19 | value: 0, | ||
20 | observer: 'reRender' | ||
21 | }, | ||
22 | speed: { | ||
23 | type: Number, | ||
24 | value: 50 | ||
25 | }, | ||
26 | size: { | ||
27 | type: Number, | ||
28 | value: 100, | ||
29 | observer: 'setStyle' | ||
30 | }, | ||
31 | fill: String, | ||
32 | layerColor: { | ||
33 | type: String, | ||
34 | value: WHITE | ||
35 | }, | ||
36 | color: { | ||
37 | type: [String, Object], | ||
38 | value: BLUE, | ||
39 | observer: 'setHoverColor' | ||
40 | }, | ||
41 | strokeWidth: { | ||
42 | type: Number, | ||
43 | value: 4 | ||
44 | }, | ||
45 | clockwise: { | ||
46 | type: Boolean, | ||
47 | value: true | ||
48 | } | ||
49 | }, | ||
50 | data: { | ||
51 | style: 'width: 100px; height: 100px;', | ||
52 | hoverColor: BLUE | ||
53 | }, | ||
54 | methods: { | ||
55 | getContext() { | ||
56 | if (!this.ctx) { | ||
57 | this.ctx = wx.createCanvasContext('van-circle', this); | ||
58 | } | ||
59 | return this.ctx; | ||
60 | }, | ||
61 | setHoverColor() { | ||
62 | const context = this.getContext(); | ||
63 | const { color, size } = this.data; | ||
64 | let hoverColor = color; | ||
65 | if (isObj(color)) { | ||
66 | const LinearColor = context.createLinearGradient(size, 0, 0, 0); | ||
67 | Object.keys(color) | ||
68 | .sort((a, b) => parseFloat(a) - parseFloat(b)) | ||
69 | .map(key => LinearColor.addColorStop(parseFloat(key) / 100, color[key])); | ||
70 | hoverColor = LinearColor; | ||
71 | } | ||
72 | this.setData({ hoverColor }); | ||
73 | }, | ||
74 | setStyle() { | ||
75 | const { size } = this.data; | ||
76 | const style = `width: ${size}px; height: ${size}px;`; | ||
77 | this.setData({ style }); | ||
78 | }, | ||
79 | presetCanvas(context, strokeStyle, beginAngle, endAngle, fill) { | ||
80 | const { strokeWidth, lineCap, clockwise, size } = this.data; | ||
81 | const position = size / 2; | ||
82 | const radius = position - strokeWidth / 2; | ||
83 | context.setStrokeStyle(strokeStyle); | ||
84 | context.setLineWidth(strokeWidth); | ||
85 | context.setLineCap(lineCap); | ||
86 | context.beginPath(); | ||
87 | context.arc(position, position, radius, beginAngle, endAngle, !clockwise); | ||
88 | context.stroke(); | ||
89 | if (fill) { | ||
90 | context.setFillStyle(fill); | ||
91 | context.fill(); | ||
92 | } | ||
93 | }, | ||
94 | renderLayerCircle(context) { | ||
95 | const { layerColor, fill } = this.data; | ||
96 | this.presetCanvas(context, layerColor, 0, PERIMETER, fill); | ||
97 | }, | ||
98 | renderHoverCircle(context, formatValue) { | ||
99 | const { clockwise, hoverColor } = this.data; | ||
100 | // 结束角度 | ||
101 | const progress = PERIMETER * (formatValue / 100); | ||
102 | const endAngle = clockwise | ||
103 | ? BEGIN_ANGLE + progress | ||
104 | : 3 * Math.PI - (BEGIN_ANGLE + progress); | ||
105 | this.presetCanvas(context, hoverColor, BEGIN_ANGLE, endAngle); | ||
106 | }, | ||
107 | drawCircle(currentValue) { | ||
108 | const context = this.getContext(); | ||
109 | const { size } = this.data; | ||
110 | context.clearRect(0, 0, size, size); | ||
111 | this.renderLayerCircle(context); | ||
112 | const formatValue = format(currentValue); | ||
113 | if (formatValue !== 0) { | ||
114 | this.renderHoverCircle(context, formatValue); | ||
115 | } | ||
116 | context.draw(); | ||
117 | }, | ||
118 | reRender() { | ||
119 | // tofector 动画暂时没有想到好的解决方案 | ||
120 | const { value, speed } = this.data; | ||
121 | if (speed <= 0 || speed > 1000) { | ||
122 | this.drawCircle(value); | ||
123 | return; | ||
124 | } | ||
125 | this.clearInterval(); | ||
126 | this.currentValue = this.currentValue || 0; | ||
127 | this.interval = setInterval(() => { | ||
128 | if (this.currentValue !== value) { | ||
129 | if (this.currentValue < value) { | ||
130 | this.currentValue += STEP; | ||
131 | } | ||
132 | else { | ||
133 | this.currentValue -= STEP; | ||
134 | } | ||
135 | this.drawCircle(this.currentValue); | ||
136 | } | ||
137 | else { | ||
138 | this.clearInterval(); | ||
139 | } | ||
140 | }, 1000 / speed); | ||
141 | }, | ||
142 | clearInterval() { | ||
143 | if (this.interval) { | ||
144 | clearInterval(this.interval); | ||
145 | this.interval = null; | ||
146 | } | ||
147 | } | ||
148 | }, | ||
149 | created() { | ||
150 | const { value } = this.data; | ||
151 | this.currentValue = value; | ||
152 | this.drawCircle(value); | ||
153 | }, | ||
154 | destroyed() { | ||
155 | this.ctx = null; | ||
156 | this.clearInterval(); | ||
157 | } | ||
158 | }); |
src/ui/vant-weapp/circle/index.wxml
0 → 100755
1 | <view class="van-circle"> | ||
2 | <canvas class="van-circle__canvas" style="{{ style }}" canvas-id="van-circle"></canvas> | ||
3 | <view wx:if="{{ !text }}" class="van-circle__text"> | ||
4 | <slot></slot> | ||
5 | </view> | ||
6 | <cover-view wx:else class="van-circle__text">{{ text }}</cover-view> | ||
7 | </view> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
src/ui/vant-weapp/circle/index.wxss
0 → 100755
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 | ... | \ No newline at end of file |
... | @@ -16,7 +16,7 @@ VantComponent({ | ... | @@ -16,7 +16,7 @@ VantComponent({ |
16 | const padding = `${gutter / 2}px`; | 16 | const padding = `${gutter / 2}px`; |
17 | const style = gutter ? `padding-left: ${padding}; padding-right: ${padding};` : ''; | 17 | const style = gutter ? `padding-left: ${padding}; padding-right: ${padding};` : ''; |
18 | if (style !== this.data.style) { | 18 | if (style !== this.data.style) { |
19 | this.set({ style }); | 19 | this.setData({ style }); |
20 | } | 20 | } |
21 | } | 21 | } |
22 | } | 22 | } | ... | ... |
... | @@ -16,6 +16,7 @@ VantComponent({ | ... | @@ -16,6 +16,7 @@ VantComponent({ |
16 | icon: String, | 16 | icon: String, |
17 | label: String, | 17 | label: String, |
18 | disabled: Boolean, | 18 | disabled: Boolean, |
19 | clickable: Boolean, | ||
19 | border: { | 20 | border: { |
20 | type: Boolean, | 21 | type: Boolean, |
21 | value: true | 22 | value: true |
... | @@ -34,7 +35,11 @@ VantComponent({ | ... | @@ -34,7 +35,11 @@ VantComponent({ |
34 | this.updateExpanded() | 35 | this.updateExpanded() |
35 | .then(nextTick) | 36 | .then(nextTick) |
36 | .then(() => { | 37 | .then(() => { |
37 | this.set({ transition: true }); | 38 | const data = { transition: true }; |
39 | if (this.data.expanded) { | ||
40 | data.contentHeight = 'auto'; | ||
41 | } | ||
42 | this.setData(data); | ||
38 | }); | 43 | }); |
39 | }, | 44 | }, |
40 | methods: { | 45 | methods: { |
... | @@ -66,11 +71,9 @@ VantComponent({ | ... | @@ -66,11 +71,9 @@ VantComponent({ |
66 | contentHeight: height ? `${height}px` : 'auto' | 71 | contentHeight: height ? `${height}px` : 'auto' |
67 | }); | 72 | }); |
68 | } | 73 | } |
69 | else { | ||
70 | return this.set({ contentHeight: `${height}px` }) | 74 | return this.set({ contentHeight: `${height}px` }) |
71 | .then(nextTick) | 75 | .then(nextTick) |
72 | .then(() => this.set({ contentHeight: 0 })); | 76 | .then(() => this.set({ contentHeight: 0 })); |
73 | } | ||
74 | }); | 77 | }); |
75 | }, | 78 | }, |
76 | onClick() { | 79 | onClick() { |
... | @@ -84,7 +87,7 @@ VantComponent({ | ... | @@ -84,7 +87,7 @@ VantComponent({ |
84 | }, | 87 | }, |
85 | onTransitionEnd() { | 88 | onTransitionEnd() { |
86 | if (this.data.expanded) { | 89 | if (this.data.expanded) { |
87 | this.set({ | 90 | this.setData({ |
88 | contentHeight: 'auto' | 91 | contentHeight: 'auto' |
89 | }); | 92 | }); |
90 | } | 93 | } | ... | ... |
... | @@ -5,9 +5,10 @@ | ... | @@ -5,9 +5,10 @@ |
5 | title="{{ title }}" | 5 | title="{{ title }}" |
6 | title-class="title-class" | 6 | title-class="title-class" |
7 | icon="{{ icon }}" | 7 | icon="{{ icon }}" |
8 | is-link="{{ isLink }}" | ||
9 | value="{{ value }}" | 8 | value="{{ value }}" |
10 | label="{{ label }}" | 9 | label="{{ label }}" |
10 | is-link="{{ isLink }}" | ||
11 | clickable="{{ clickable }}" | ||
11 | border="{{ border && expanded }}" | 12 | border="{{ border && expanded }}" |
12 | class="{{ utils.bem('collapse-item__title', { disabled, expanded }) }}" | 13 | class="{{ utils.bem('collapse-item__title', { disabled, expanded }) }}" |
13 | right-icon-class="van-cell__right-icon" | 14 | right-icon-class="van-cell__right-icon" | ... | ... |
1 | @import '../common/index.wxss';.van-collapse-item__title .van-cell__right-icon{-webkit-transform:rotate(90deg);transform:rotate(90deg);transition:.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:#c9c9c9!important}.van-collapse-item__title--disabled .van-cell--hover{background-color:#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;font-size:13px;line-height:1.5;color:#999;background-color:#fff} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
... | @@ -5,6 +5,9 @@ VantComponent({ | ... | @@ -5,6 +5,9 @@ VantComponent({ |
5 | type: 'descendant', | 5 | type: 'descendant', |
6 | linked(child) { | 6 | linked(child) { |
7 | this.children.push(child); | 7 | this.children.push(child); |
8 | }, | ||
9 | unlinked(child) { | ||
10 | this.children = this.children.filter((item) => item !== child); | ||
8 | } | 11 | } |
9 | }, | 12 | }, |
10 | props: { | 13 | props: { | ... | ... |
1 | export declare const RED = "#f44"; | 1 | export declare const RED = "#ee0a24"; |
2 | export declare const BLUE = "#1989fa"; | 2 | export declare const BLUE = "#1989fa"; |
3 | export declare const WHITE = "#fff"; | ||
3 | export declare const GREEN = "#07c160"; | 4 | export declare const GREEN = "#07c160"; |
5 | export declare const ORANGE = "#ff976a"; | ||
6 | export declare const GRAY = "#323233"; | ||
7 | export declare const GRAY_DARK = "#969799"; | ... | ... |
1 | export const RED = '#f44'; | 1 | export const RED = '#ee0a24'; |
2 | export const BLUE = '#1989fa'; | 2 | export const BLUE = '#1989fa'; |
3 | export const WHITE = '#fff'; | ||
3 | export const GREEN = '#07c160'; | 4 | export const GREEN = '#07c160'; |
5 | export const ORANGE = '#ff976a'; | ||
6 | export const GRAY = '#323233'; | ||
7 | export const GRAY_DARK = '#969799'; | ... | ... |
1 | declare function VantComponent<Data, Props, Watch, Methods, Computed>(vantOptions?: VantComponentOptions<Data, Props, Watch, Methods, Computed, CombinedComponentInstance<Data, Props, Watch, Methods, Computed>>): void; | 1 | import { VantComponentOptions, CombinedComponentInstance } from '../definitions/index'; |
2 | declare function VantComponent<Data, Props, Methods>(vantOptions?: VantComponentOptions<Data, Props, Methods, CombinedComponentInstance<Data, Props, Methods>>): void; | ||
2 | export { VantComponent }; | 3 | export { VantComponent }; | ... | ... |
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{overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3}.van-clearfix:after{content:"";display:table;clear:both}.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{content:" ";position:absolute;pointer-events:none;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;top:-50%;left:-50%;right:-50%;bottom:-50%;-webkit-transform:scale(.5);transform:scale(.5);border:0 solid #eee}.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 | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
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{overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
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{content:" ";position:absolute;pointer-events:none;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;top:-50%;left:-50%;right:-50%;bottom:-50%;-webkit-transform:scale(.5);transform:scale(.5);border:0 solid #eee}.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 | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
src/ui/vant-weapp/common/style/theme.wxss
0 → 100755
File mode changed
1 | declare function isDef(value: any): boolean; | 1 | /// <reference types="miniprogram-api-typings" /> |
2 | declare function isObj(x: any): boolean; | 2 | export declare function isDef(value: any): boolean; |
3 | declare function isNumber(value: any): boolean; | 3 | export declare function isObj(x: any): boolean; |
4 | declare function range(num: number, min: number, max: number): number; | 4 | export declare function isNumber(value: any): boolean; |
5 | export { isObj, isDef, isNumber, range }; | 5 | export declare function range(num: number, min: number, max: number): number; |
6 | export declare function nextTick(fn: Function): void; | ||
7 | export declare function getSystemInfoSync(): WechatMiniprogram.GetSystemInfoSuccessCallbackResult; | ||
8 | export declare function addUnit(value?: string | number): string | undefined; | ... | ... |
1 | function isDef(value) { | 1 | export function isDef(value) { |
2 | return value !== undefined && value !== null; | 2 | return value !== undefined && value !== null; |
3 | } | 3 | } |
4 | function isObj(x) { | 4 | export function isObj(x) { |
5 | const type = typeof x; | 5 | const type = typeof x; |
6 | return x !== null && (type === 'object' || type === 'function'); | 6 | return x !== null && (type === 'object' || type === 'function'); |
7 | } | 7 | } |
8 | function isNumber(value) { | 8 | export function isNumber(value) { |
9 | return /^\d+$/.test(value); | 9 | return /^\d+(\.\d+)?$/.test(value); |
10 | } | 10 | } |
11 | function range(num, min, max) { | 11 | export function range(num, min, max) { |
12 | return Math.min(Math.max(num, min), max); | 12 | return Math.min(Math.max(num, min), max); |
13 | } | 13 | } |
14 | export { isObj, isDef, isNumber, range }; | 14 | export function nextTick(fn) { |
15 | setTimeout(() => { | ||
16 | fn(); | ||
17 | }, 1000 / 30); | ||
18 | } | ||
19 | let systemInfo = null; | ||
20 | export function getSystemInfoSync() { | ||
21 | if (systemInfo == null) { | ||
22 | systemInfo = wx.getSystemInfoSync(); | ||
23 | } | ||
24 | return systemInfo; | ||
25 | } | ||
26 | export function addUnit(value) { | ||
27 | if (!isDef(value)) { | ||
28 | return undefined; | ||
29 | } | ||
30 | value = String(value); | ||
31 | return isNumber(value) ? `${value}px` : value; | ||
32 | } | ... | ... |
src/ui/vant-weapp/count-down/index.js
0 → 100755
1 | import { VantComponent } from '../common/component'; | ||
2 | import { isSameSecond, parseFormat, parseTimeData } from './utils'; | ||
3 | function simpleTick(fn) { | ||
4 | return setTimeout(fn, 30); | ||
5 | } | ||
6 | VantComponent({ | ||
7 | props: { | ||
8 | useSlot: Boolean, | ||
9 | millisecond: Boolean, | ||
10 | time: { | ||
11 | type: Number, | ||
12 | observer: 'reset' | ||
13 | }, | ||
14 | format: { | ||
15 | type: String, | ||
16 | value: 'HH:mm:ss' | ||
17 | }, | ||
18 | autoStart: { | ||
19 | type: Boolean, | ||
20 | value: true | ||
21 | } | ||
22 | }, | ||
23 | data: { | ||
24 | timeData: parseTimeData(0), | ||
25 | formattedTime: '0' | ||
26 | }, | ||
27 | destroyed() { | ||
28 | clearTimeout(this.tid); | ||
29 | this.tid = null; | ||
30 | }, | ||
31 | methods: { | ||
32 | // 开始 | ||
33 | start() { | ||
34 | if (this.counting) { | ||
35 | return; | ||
36 | } | ||
37 | this.counting = true; | ||
38 | this.endTime = Date.now() + this.remain; | ||
39 | this.tick(); | ||
40 | }, | ||
41 | // 暂停 | ||
42 | pause() { | ||
43 | this.counting = false; | ||
44 | clearTimeout(this.tid); | ||
45 | }, | ||
46 | // 重置 | ||
47 | reset() { | ||
48 | this.pause(); | ||
49 | this.remain = this.data.time; | ||
50 | this.setRemain(this.remain); | ||
51 | if (this.data.autoStart) { | ||
52 | this.start(); | ||
53 | } | ||
54 | }, | ||
55 | tick() { | ||
56 | if (this.data.millisecond) { | ||
57 | this.microTick(); | ||
58 | } | ||
59 | else { | ||
60 | this.macroTick(); | ||
61 | } | ||
62 | }, | ||
63 | microTick() { | ||
64 | this.tid = simpleTick(() => { | ||
65 | this.setRemain(this.getRemain()); | ||
66 | if (this.remain !== 0) { | ||
67 | this.microTick(); | ||
68 | } | ||
69 | }); | ||
70 | }, | ||
71 | macroTick() { | ||
72 | this.tid = simpleTick(() => { | ||
73 | const remain = this.getRemain(); | ||
74 | if (!isSameSecond(remain, this.remain) || remain === 0) { | ||
75 | this.setRemain(remain); | ||
76 | } | ||
77 | if (this.remain !== 0) { | ||
78 | this.macroTick(); | ||
79 | } | ||
80 | }); | ||
81 | }, | ||
82 | getRemain() { | ||
83 | return Math.max(this.endTime - Date.now(), 0); | ||
84 | }, | ||
85 | setRemain(remain) { | ||
86 | this.remain = remain; | ||
87 | const timeData = parseTimeData(remain); | ||
88 | if (this.data.useSlot) { | ||
89 | this.$emit('change', timeData); | ||
90 | } | ||
91 | this.setData({ | ||
92 | formattedTime: parseFormat(this.data.format, timeData) | ||
93 | }); | ||
94 | if (remain === 0) { | ||
95 | this.pause(); | ||
96 | this.$emit('finish'); | ||
97 | } | ||
98 | } | ||
99 | } | ||
100 | }); |
src/ui/vant-weapp/count-down/index.json
0 → 100755
src/ui/vant-weapp/count-down/index.wxml
0 → 100755
src/ui/vant-weapp/count-down/index.wxss
0 → 100755
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 | ... | \ No newline at end of file |
src/ui/vant-weapp/count-down/utils.d.ts
0 → 100755
1 | export declare type TimeData = { | ||
2 | days: number; | ||
3 | hours: number; | ||
4 | minutes: number; | ||
5 | seconds: number; | ||
6 | milliseconds: number; | ||
7 | }; | ||
8 | export declare function parseTimeData(time: number): TimeData; | ||
9 | export declare function parseFormat(format: string, timeData: TimeData): string; | ||
10 | export declare function isSameSecond(time1: number, time2: number): boolean; |
src/ui/vant-weapp/count-down/utils.js
0 → 100755
1 | function padZero(num, targetLength = 2) { | ||
2 | let str = num + ''; | ||
3 | while (str.length < targetLength) { | ||
4 | str = '0' + str; | ||
5 | } | ||
6 | return str; | ||
7 | } | ||
8 | const SECOND = 1000; | ||
9 | const MINUTE = 60 * SECOND; | ||
10 | const HOUR = 60 * MINUTE; | ||
11 | const DAY = 24 * HOUR; | ||
12 | export function parseTimeData(time) { | ||
13 | const days = Math.floor(time / DAY); | ||
14 | const hours = Math.floor((time % DAY) / HOUR); | ||
15 | const minutes = Math.floor((time % HOUR) / MINUTE); | ||
16 | const seconds = Math.floor((time % MINUTE) / SECOND); | ||
17 | const milliseconds = Math.floor(time % SECOND); | ||
18 | return { | ||
19 | days, | ||
20 | hours, | ||
21 | minutes, | ||
22 | seconds, | ||
23 | milliseconds | ||
24 | }; | ||
25 | } | ||
26 | export function parseFormat(format, timeData) { | ||
27 | const { days } = timeData; | ||
28 | let { hours, minutes, seconds, milliseconds } = timeData; | ||
29 | if (format.indexOf('DD') === -1) { | ||
30 | hours += days * 24; | ||
31 | } | ||
32 | else { | ||
33 | format = format.replace('DD', padZero(days)); | ||
34 | } | ||
35 | if (format.indexOf('HH') === -1) { | ||
36 | minutes += hours * 60; | ||
37 | } | ||
38 | else { | ||
39 | format = format.replace('HH', padZero(hours)); | ||
40 | } | ||
41 | if (format.indexOf('mm') === -1) { | ||
42 | seconds += minutes * 60; | ||
43 | } | ||
44 | else { | ||
45 | format = format.replace('mm', padZero(minutes)); | ||
46 | } | ||
47 | if (format.indexOf('ss') === -1) { | ||
48 | milliseconds += seconds * 1000; | ||
49 | } | ||
50 | else { | ||
51 | format = format.replace('ss', padZero(seconds)); | ||
52 | } | ||
53 | return format.replace('SSS', padZero(milliseconds, 3)); | ||
54 | } | ||
55 | export function isSameSecond(time1, time2) { | ||
56 | return Math.floor(time1 / 1000) === Math.floor(time2 / 1000); | ||
57 | } |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { isDef } from '../common/utils'; | 2 | import { isDef } from '../common/utils'; |
3 | import { pickerProps } from '../picker/shared'; | ||
3 | const currentYear = new Date().getFullYear(); | 4 | const currentYear = new Date().getFullYear(); |
4 | function isValidDate(date) { | 5 | function isValidDate(date) { |
5 | return isDef(date) && !isNaN(new Date(date).getTime()); | 6 | return isDef(date) && !isNaN(new Date(date).getTime()); |
... | @@ -12,7 +13,7 @@ function padZero(val) { | ... | @@ -12,7 +13,7 @@ function padZero(val) { |
12 | } | 13 | } |
13 | function times(n, iteratee) { | 14 | function times(n, iteratee) { |
14 | let index = -1; | 15 | let index = -1; |
15 | const result = Array(n); | 16 | const result = Array(n < 0 ? 0 : n); |
16 | while (++index < n) { | 17 | while (++index < n) { |
17 | result[index] = iteratee(index); | 18 | result[index] = iteratee(index); |
18 | } | 19 | } |
... | @@ -29,100 +30,95 @@ function getTrueValue(formattedValue) { | ... | @@ -29,100 +30,95 @@ function getTrueValue(formattedValue) { |
29 | function getMonthEndDay(year, month) { | 30 | function getMonthEndDay(year, month) { |
30 | return 32 - new Date(year, month - 1, 32).getDate(); | 31 | return 32 - new Date(year, month - 1, 32).getDate(); |
31 | } | 32 | } |
33 | const defaultFormatter = (_, value) => value; | ||
32 | VantComponent({ | 34 | VantComponent({ |
33 | props: { | 35 | classes: ['active-class', 'toolbar-class', 'column-class'], |
34 | value: null, | 36 | props: Object.assign(Object.assign({}, pickerProps), { value: null, filter: null, type: { |
35 | title: String, | ||
36 | loading: Boolean, | ||
37 | itemHeight: { | ||
38 | type: Number, | ||
39 | value: 44 | ||
40 | }, | ||
41 | visibleItemCount: { | ||
42 | type: Number, | ||
43 | value: 5 | ||
44 | }, | ||
45 | confirmButtonText: { | ||
46 | type: String, | ||
47 | value: '确认' | ||
48 | }, | ||
49 | cancelButtonText: { | ||
50 | type: String, | ||
51 | value: '取消' | ||
52 | }, | ||
53 | type: { | ||
54 | type: String, | 37 | type: String, |
55 | value: 'datetime' | 38 | value: 'datetime' |
56 | }, | 39 | }, showToolbar: { |
57 | showToolbar: { | ||
58 | type: Boolean, | 40 | type: Boolean, |
59 | value: true | 41 | value: true |
60 | }, | 42 | }, formatter: { |
61 | minDate: { | 43 | type: null, |
44 | value: defaultFormatter | ||
45 | }, minDate: { | ||
62 | type: Number, | 46 | type: Number, |
63 | value: new Date(currentYear - 10, 0, 1).getTime() | 47 | value: new Date(currentYear - 10, 0, 1).getTime() |
64 | }, | 48 | }, maxDate: { |
65 | maxDate: { | ||
66 | type: Number, | 49 | type: Number, |
67 | value: new Date(currentYear + 10, 11, 31).getTime() | 50 | value: new Date(currentYear + 10, 11, 31).getTime() |
68 | }, | 51 | }, minHour: { |
69 | minHour: { | ||
70 | type: Number, | 52 | type: Number, |
71 | value: 0 | 53 | value: 0 |
72 | }, | 54 | }, maxHour: { |
73 | maxHour: { | ||
74 | type: Number, | 55 | type: Number, |
75 | value: 23 | 56 | value: 23 |
76 | }, | 57 | }, minMinute: { |
77 | minMinute: { | ||
78 | type: Number, | 58 | type: Number, |
79 | value: 0 | 59 | value: 0 |
80 | }, | 60 | }, maxMinute: { |
81 | maxMinute: { | ||
82 | type: Number, | 61 | type: Number, |
83 | value: 59 | 62 | value: 59 |
84 | } | 63 | } }), |
85 | }, | ||
86 | data: { | 64 | data: { |
87 | innerValue: Date.now(), | 65 | innerValue: Date.now(), |
88 | columns: [] | 66 | columns: [] |
89 | }, | 67 | }, |
90 | watch: { | 68 | watch: { |
91 | value(val) { | 69 | value: 'updateValue', |
70 | type: 'updateValue', | ||
71 | minDate: 'updateValue', | ||
72 | maxDate: 'updateValue', | ||
73 | minHour: 'updateValue', | ||
74 | maxHour: 'updateValue', | ||
75 | minMinute: 'updateValue', | ||
76 | maxMinute: 'updateValue' | ||
77 | }, | ||
78 | methods: { | ||
79 | updateValue() { | ||
92 | const { data } = this; | 80 | const { data } = this; |
93 | val = this.correctValue(val); | 81 | const val = this.correctValue(this.data.value); |
94 | const isEqual = val === data.innerValue; | 82 | const isEqual = val === data.innerValue; |
95 | if (!isEqual) { | 83 | if (!isEqual) { |
96 | this.updateColumnValue(val).then(() => { | 84 | this.updateColumnValue(val).then(() => { |
97 | this.$emit('input', val); | 85 | this.$emit('input', val); |
98 | }); | 86 | }); |
99 | } | 87 | } |
88 | else { | ||
89 | this.updateColumns(); | ||
90 | } | ||
100 | }, | 91 | }, |
101 | type: 'updateColumns', | ||
102 | minHour: 'updateColumns', | ||
103 | maxHour: 'updateColumns', | ||
104 | minMinute: 'updateColumns', | ||
105 | maxMinute: 'updateColumns' | ||
106 | }, | ||
107 | methods: { | ||
108 | getPicker() { | 92 | getPicker() { |
109 | if (this.picker == null) { | 93 | if (this.picker == null) { |
110 | const picker = this.picker = this.selectComponent('.van-datetime-picker'); | 94 | this.picker = this.selectComponent('.van-datetime-picker'); |
95 | const { picker } = this; | ||
111 | const { setColumnValues } = picker; | 96 | const { setColumnValues } = picker; |
112 | picker.setColumnValues = (...args) => setColumnValues.apply(picker, [...args, false]); | 97 | picker.setColumnValues = (...args) => setColumnValues.apply(picker, [...args, false]); |
113 | } | 98 | } |
114 | return this.picker; | 99 | return this.picker; |
115 | }, | 100 | }, |
116 | updateColumns() { | 101 | updateColumns() { |
117 | const results = this.getRanges().map(({ type, range }, index) => { | 102 | const { formatter = defaultFormatter } = this.data; |
118 | const values = times(range[1] - range[0] + 1, index => { | 103 | const results = this.getOriginColumns().map(column => ({ |
104 | values: column.values.map(value => formatter(column.type, value)) | ||
105 | })); | ||
106 | return this.set({ columns: results }); | ||
107 | }, | ||
108 | getOriginColumns() { | ||
109 | const { filter } = this.data; | ||
110 | const results = this.getRanges().map(({ type, range }) => { | ||
111 | let values = times(range[1] - range[0] + 1, index => { | ||
119 | let value = range[0] + index; | 112 | let value = range[0] + index; |
120 | value = type === 'year' ? `${value}` : padZero(value); | 113 | value = type === 'year' ? `${value}` : padZero(value); |
121 | return value; | 114 | return value; |
122 | }); | 115 | }); |
123 | return { values }; | 116 | if (filter) { |
117 | values = filter(type, values); | ||
118 | } | ||
119 | return { type, values }; | ||
124 | }); | 120 | }); |
125 | return this.set({ columns: results }); | 121 | return results; |
126 | }, | 122 | }, |
127 | getRanges() { | 123 | getRanges() { |
128 | const { data } = this; | 124 | const { data } = this; |
... | @@ -237,7 +233,7 @@ VantComponent({ | ... | @@ -237,7 +233,7 @@ VantComponent({ |
237 | const picker = this.getPicker(); | 233 | const picker = this.getPicker(); |
238 | if (data.type === 'time') { | 234 | if (data.type === 'time') { |
239 | const indexes = picker.getIndexes(); | 235 | const indexes = picker.getIndexes(); |
240 | value = `${indexes[0] + data.minHour}:${indexes[1] + data.minMinute}`; | 236 | value = `${+data.columns[0].values[indexes[0]]}:${+data.columns[1].values[indexes[1]]}`; |
241 | } | 237 | } |
242 | else { | 238 | else { |
243 | const values = picker.getValues(); | 239 | const values = picker.getValues(); |
... | @@ -265,20 +261,26 @@ VantComponent({ | ... | @@ -265,20 +261,26 @@ VantComponent({ |
265 | }, | 261 | }, |
266 | updateColumnValue(value) { | 262 | updateColumnValue(value) { |
267 | let values = []; | 263 | let values = []; |
268 | const { data } = this; | 264 | const { type, formatter = defaultFormatter } = this.data; |
269 | const picker = this.getPicker(); | 265 | const picker = this.getPicker(); |
270 | if (data.type === 'time') { | 266 | if (type === 'time') { |
271 | const pair = value.split(':'); | 267 | const pair = value.split(':'); |
272 | values = [pair[0], pair[1]]; | 268 | values = [ |
269 | formatter('hour', pair[0]), | ||
270 | formatter('minute', pair[1]) | ||
271 | ]; | ||
273 | } | 272 | } |
274 | else { | 273 | else { |
275 | const date = new Date(value); | 274 | const date = new Date(value); |
276 | values = [`${date.getFullYear()}`, padZero(date.getMonth() + 1)]; | 275 | values = [ |
277 | if (data.type === 'date') { | 276 | formatter('year', `${date.getFullYear()}`), |
278 | values.push(padZero(date.getDate())); | 277 | formatter('month', padZero(date.getMonth() + 1)) |
278 | ]; | ||
279 | if (type === 'date') { | ||
280 | values.push(formatter('day', padZero(date.getDate()))); | ||
279 | } | 281 | } |
280 | if (data.type === 'datetime') { | 282 | if (type === 'datetime') { |
281 | values.push(padZero(date.getDate()), padZero(date.getHours()), padZero(date.getMinutes())); | 283 | values.push(formatter('day', padZero(date.getDate())), formatter('hour', padZero(date.getHours())), formatter('minute', padZero(date.getMinutes()))); |
282 | } | 284 | } |
283 | } | 285 | } |
284 | return this.set({ innerValue: value }) | 286 | return this.set({ innerValue: value }) | ... | ... |
1 | <van-picker | 1 | <van-picker |
2 | class="van-datetime-picker" | 2 | class="van-datetime-picker" |
3 | active-class="active-class" | ||
4 | toolbar-class="toolbar-class" | ||
5 | column-class="column-class" | ||
3 | title="{{ title }}" | 6 | title="{{ title }}" |
4 | columns="{{ columns }}" | 7 | columns="{{ columns }}" |
5 | item-height="{{ itemHeight }}" | 8 | item-height="{{ itemHeight }}" | ... | ... |
src/ui/vant-weapp/definitions/index.d.ts
0 → 100755
1 | /// <reference types="miniprogram-api-typings" /> | ||
2 | import { Weapp } from './weapp'; | ||
3 | declare type RecordToAny<T> = { | ||
4 | [K in keyof T]: any; | ||
5 | }; | ||
6 | export declare type CombinedComponentInstance<Data, Props, Methods> = Methods & WechatMiniprogram.Component.TrivialInstance & Weapp.FormField & { | ||
7 | data: Data & RecordToAny<Props>; | ||
8 | }; | ||
9 | export interface VantComponentOptions<Data, Props, Methods, Instance> { | ||
10 | data?: Data; | ||
11 | field?: boolean; | ||
12 | classes?: string[]; | ||
13 | mixins?: string[]; | ||
14 | props?: Props & Weapp.PropertyOption; | ||
15 | watch?: Weapp.WatchOption<Instance>; | ||
16 | relation?: Weapp.RelationOption<Instance> & { | ||
17 | name: string; | ||
18 | }; | ||
19 | relations?: { | ||
20 | [componentName: string]: Weapp.RelationOption<Instance>; | ||
21 | }; | ||
22 | methods?: Methods & Weapp.MethodOption<Instance>; | ||
23 | beforeCreate?: (this: Instance) => void; | ||
24 | created?: (this: Instance) => void; | ||
25 | mounted?: (this: Instance) => void; | ||
26 | destroyed?: (this: Instance) => void; | ||
27 | } | ||
28 | export {}; |
src/ui/vant-weapp/definitions/index.js
0 → 100755
File mode changed
src/ui/vant-weapp/definitions/weapp.d.ts
0 → 100755
1 | /// <reference types="miniprogram-api-typings" /> | ||
2 | export declare namespace Weapp { | ||
3 | export interface FormField { | ||
4 | data: { | ||
5 | name: string; | ||
6 | value: any; | ||
7 | }; | ||
8 | } | ||
9 | interface Target { | ||
10 | id: string; | ||
11 | tagName: string; | ||
12 | dataset: { | ||
13 | [key: string]: any; | ||
14 | }; | ||
15 | } | ||
16 | export interface Event { | ||
17 | /** | ||
18 | * 代表事件的类型。 | ||
19 | */ | ||
20 | type: string; | ||
21 | /** | ||
22 | * 页面打开到触发事件所经过的毫秒数。 | ||
23 | */ | ||
24 | timeStamp: number; | ||
25 | /** | ||
26 | * 触发事件的源组件。 | ||
27 | */ | ||
28 | target: Target; | ||
29 | /** | ||
30 | * 事件绑定的当前组件。 | ||
31 | */ | ||
32 | currentTarget: Target; | ||
33 | /** | ||
34 | * 额外的信息 | ||
35 | */ | ||
36 | detail: any; | ||
37 | } | ||
38 | interface Touch { | ||
39 | /** | ||
40 | * 触摸点的标识符 | ||
41 | */ | ||
42 | identifier: number; | ||
43 | /** | ||
44 | * 距离文档左上角的距离,文档的左上角为原点 ,横向为X轴,纵向为Y轴 | ||
45 | */ | ||
46 | pageX: number; | ||
47 | /** | ||
48 | * 距离文档左上角的距离,文档的左上角为原点 ,横向为X轴,纵向为Y轴 | ||
49 | */ | ||
50 | pageY: number; | ||
51 | /** | ||
52 | * 距离页面可显示区域(屏幕除去导航条)左上角距离,横向为X轴,纵向为Y轴 | ||
53 | */ | ||
54 | clientX: number; | ||
55 | /** | ||
56 | * 距离页面可显示区域(屏幕除去导航条)左上角距离,横向为X轴,纵向为Y轴 | ||
57 | */ | ||
58 | clientY: number; | ||
59 | } | ||
60 | export interface TouchEvent extends Event { | ||
61 | touches: Array<Touch>; | ||
62 | changedTouches: Array<Touch>; | ||
63 | } | ||
64 | /** | ||
65 | * relation定义,miniprogram-api-typings缺少this定义 | ||
66 | */ | ||
67 | export interface RelationOption<Instance> { | ||
68 | /** 目标组件的相对关系 */ | ||
69 | type: 'parent' | 'child' | 'ancestor' | 'descendant'; | ||
70 | /** 关系生命周期函数,当关系被建立在页面节点树中时触发,触发时机在组件attached生命周期之后 */ | ||
71 | linked?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void; | ||
72 | /** 关系生命周期函数,当关系在页面节点树中发生改变时触发,触发时机在组件moved生命周期之后 */ | ||
73 | linkChanged?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void; | ||
74 | /** 关系生命周期函数,当关系脱离页面节点树时触发,触发时机在组件detached生命周期之后 */ | ||
75 | unlinked?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void; | ||
76 | /** 如果这一项被设置,则它表示关联的目标节点所应具有的behavior,所有拥有这一behavior的组件节点都会被关联 */ | ||
77 | target?: string; | ||
78 | } | ||
79 | /** | ||
80 | * obverser定义,miniprogram-api-typings缺少this定义 | ||
81 | */ | ||
82 | type Observer<Instance, T> = (this: Instance, newVal: T, oldVal: T, changedPath: Array<string | number>) => void; | ||
83 | /** | ||
84 | * watch定义 | ||
85 | */ | ||
86 | export interface WatchOption<Instance> { | ||
87 | [name: string]: string | Observer<Instance, any>; | ||
88 | } | ||
89 | /** | ||
90 | * methods定义,miniprogram-api-typings缺少this定义 | ||
91 | */ | ||
92 | export interface MethodOption<Instance> { | ||
93 | [name: string]: (this: Instance, ...args: any[]) => any; | ||
94 | } | ||
95 | export interface ComputedOption<Instance> { | ||
96 | [name: string]: (this: Instance) => any; | ||
97 | } | ||
98 | type PropertyType = StringConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor | ObjectConstructor | FunctionConstructor | null; | ||
99 | export interface PropertyOption { | ||
100 | [name: string]: PropertyType | PropertyType[] | { | ||
101 | /** 属性类型 */ | ||
102 | type: PropertyType | PropertyType[]; | ||
103 | /** 属性初始值 */ | ||
104 | value?: any; | ||
105 | /** 属性值被更改时的响应函数 */ | ||
106 | observer?: string | Observer<WechatMiniprogram.Component.TrivialInstance, any>; | ||
107 | /** 属性的类型(可以指定多个) */ | ||
108 | optionalTypes?: PropertyType[]; | ||
109 | }; | ||
110 | } | ||
111 | export {}; | ||
112 | } |
src/ui/vant-weapp/definitions/weapp.js
0 → 100755
File mode changed
1 | /// <reference types="miniprogram-api-typings" /> | ||
1 | declare type DialogAction = 'confirm' | 'cancel'; | 2 | declare type DialogAction = 'confirm' | 'cancel'; |
2 | declare type DialogOptions = { | 3 | declare type DialogOptions = { |
3 | lang?: string; | 4 | lang?: string; |
4 | show?: boolean; | 5 | show?: boolean; |
5 | title?: string; | 6 | title?: string; |
7 | width?: string | number; | ||
6 | zIndex?: number; | 8 | zIndex?: number; |
7 | context?: any; | 9 | context?: WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance; |
8 | message?: string; | 10 | message?: string; |
9 | overlay?: boolean; | 11 | overlay?: boolean; |
10 | selector?: string; | 12 | selector?: string; |
11 | ariaLabel?: string; | 13 | ariaLabel?: string; |
14 | className?: string; | ||
15 | customStyle?: string; | ||
12 | transition?: string; | 16 | transition?: string; |
13 | asyncClose?: boolean; | 17 | asyncClose?: boolean; |
14 | businessId?: number; | 18 | businessId?: number; |
15 | sessionFrom?: string; | 19 | sessionFrom?: string; |
20 | overlayStyle?: string; | ||
16 | appParameter?: string; | 21 | appParameter?: string; |
17 | messageAlign?: string; | 22 | messageAlign?: string; |
18 | sendMessageImg?: string; | 23 | sendMessageImg?: string; | ... | ... |
... | @@ -4,13 +4,14 @@ function getContext() { | ... | @@ -4,13 +4,14 @@ function getContext() { |
4 | return pages[pages.length - 1]; | 4 | return pages[pages.length - 1]; |
5 | } | 5 | } |
6 | const Dialog = options => { | 6 | const Dialog = options => { |
7 | options = Object.assign({}, Dialog.currentOptions, options); | 7 | options = Object.assign(Object.assign({}, Dialog.currentOptions), options); |
8 | return new Promise((resolve, reject) => { | 8 | return new Promise((resolve, reject) => { |
9 | const context = options.context || getContext(); | 9 | const context = options.context || getContext(); |
10 | const dialog = context.selectComponent(options.selector); | 10 | const dialog = context.selectComponent(options.selector); |
11 | delete options.context; | ||
11 | delete options.selector; | 12 | delete options.selector; |
12 | if (dialog) { | 13 | if (dialog) { |
13 | dialog.set(Object.assign({ onCancel: reject, onConfirm: resolve }, options)); | 14 | dialog.setData(Object.assign({ onCancel: reject, onConfirm: resolve }, options)); |
14 | queue.push(dialog); | 15 | queue.push(dialog); |
15 | } | 16 | } |
16 | else { | 17 | else { |
... | @@ -21,13 +22,17 @@ const Dialog = options => { | ... | @@ -21,13 +22,17 @@ const Dialog = options => { |
21 | Dialog.defaultOptions = { | 22 | Dialog.defaultOptions = { |
22 | show: true, | 23 | show: true, |
23 | title: '', | 24 | title: '', |
25 | width: null, | ||
24 | message: '', | 26 | message: '', |
25 | zIndex: 100, | 27 | zIndex: 100, |
26 | overlay: true, | 28 | overlay: true, |
29 | selector: '#van-dialog', | ||
30 | className: '', | ||
27 | asyncClose: false, | 31 | asyncClose: false, |
28 | messageAlign: '', | ||
29 | transition: 'scale', | 32 | transition: 'scale', |
30 | selector: '#van-dialog', | 33 | customStyle: '', |
34 | messageAlign: '', | ||
35 | overlayStyle: '', | ||
31 | confirmButtonText: '确认', | 36 | confirmButtonText: '确认', |
32 | cancelButtonText: '取消', | 37 | cancelButtonText: '取消', |
33 | showConfirmButton: true, | 38 | showConfirmButton: true, | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { button } from '../mixins/button'; | 2 | import { button } from '../mixins/button'; |
3 | import { openType } from '../mixins/open-type'; | 3 | import { openType } from '../mixins/open-type'; |
4 | import { addUnit } from '../common/utils'; | ||
5 | import { GRAY, BLUE } from '../common/color'; | ||
4 | VantComponent({ | 6 | VantComponent({ |
5 | mixins: [button, openType], | 7 | mixins: [button, openType], |
6 | props: { | 8 | props: { |
... | @@ -8,11 +10,19 @@ VantComponent({ | ... | @@ -8,11 +10,19 @@ VantComponent({ |
8 | title: String, | 10 | title: String, |
9 | message: String, | 11 | message: String, |
10 | useSlot: Boolean, | 12 | useSlot: Boolean, |
13 | className: String, | ||
14 | customStyle: String, | ||
11 | asyncClose: Boolean, | 15 | asyncClose: Boolean, |
12 | messageAlign: String, | 16 | messageAlign: String, |
17 | overlayStyle: String, | ||
18 | useTitleSlot: Boolean, | ||
13 | showCancelButton: Boolean, | 19 | showCancelButton: Boolean, |
14 | closeOnClickOverlay: Boolean, | 20 | closeOnClickOverlay: Boolean, |
15 | confirmButtonOpenType: String, | 21 | confirmButtonOpenType: String, |
22 | width: { | ||
23 | type: null, | ||
24 | observer: 'setWidthWithUnit' | ||
25 | }, | ||
16 | zIndex: { | 26 | zIndex: { |
17 | type: Number, | 27 | type: Number, |
18 | value: 2000 | 28 | value: 2000 |
... | @@ -25,6 +35,14 @@ VantComponent({ | ... | @@ -25,6 +35,14 @@ VantComponent({ |
25 | type: String, | 35 | type: String, |
26 | value: '取消' | 36 | value: '取消' |
27 | }, | 37 | }, |
38 | confirmButtonColor: { | ||
39 | type: String, | ||
40 | value: BLUE | ||
41 | }, | ||
42 | cancelButtonColor: { | ||
43 | type: String, | ||
44 | value: GRAY | ||
45 | }, | ||
28 | showConfirmButton: { | 46 | showConfirmButton: { |
29 | type: Boolean, | 47 | type: Boolean, |
30 | value: true | 48 | value: true |
... | @@ -61,19 +79,19 @@ VantComponent({ | ... | @@ -61,19 +79,19 @@ VantComponent({ |
61 | }, | 79 | }, |
62 | handleAction(action) { | 80 | handleAction(action) { |
63 | if (this.data.asyncClose) { | 81 | if (this.data.asyncClose) { |
64 | this.set({ | 82 | this.setData({ |
65 | [`loading.${action}`]: true | 83 | [`loading.${action}`]: true |
66 | }); | 84 | }); |
67 | } | 85 | } |
68 | this.onClose(action); | 86 | this.onClose(action); |
69 | }, | 87 | }, |
70 | close() { | 88 | close() { |
71 | this.set({ | 89 | this.setData({ |
72 | show: false | 90 | show: false |
73 | }); | 91 | }); |
74 | }, | 92 | }, |
75 | stopLoading() { | 93 | stopLoading() { |
76 | this.set({ | 94 | this.setData({ |
77 | loading: { | 95 | loading: { |
78 | confirm: false, | 96 | confirm: false, |
79 | cancel: false | 97 | cancel: false |
... | @@ -85,12 +103,17 @@ VantComponent({ | ... | @@ -85,12 +103,17 @@ VantComponent({ |
85 | this.close(); | 103 | this.close(); |
86 | } | 104 | } |
87 | this.$emit('close', action); | 105 | this.$emit('close', action); |
88 | //把 dialog 实例传递出去,可以通过 stopLoading() 在外部关闭按钮的 loading | 106 | // 把 dialog 实例传递出去,可以通过 stopLoading() 在外部关闭按钮的 loading |
89 | this.$emit(action, { dialog: this }); | 107 | this.$emit(action, { dialog: this }); |
90 | const callback = this.data[action === 'confirm' ? 'onConfirm' : 'onCancel']; | 108 | const callback = this.data[action === 'confirm' ? 'onConfirm' : 'onCancel']; |
91 | if (callback) { | 109 | if (callback) { |
92 | callback(this); | 110 | callback(this); |
93 | } | 111 | } |
112 | }, | ||
113 | setWidthWithUnit(val) { | ||
114 | this.setData({ | ||
115 | widthWithUnit: addUnit(val) | ||
116 | }); | ||
94 | } | 117 | } |
95 | } | 118 | } |
96 | }); | 119 | }); | ... | ... |
... | @@ -2,16 +2,19 @@ | ... | @@ -2,16 +2,19 @@ |
2 | show="{{ show }}" | 2 | show="{{ show }}" |
3 | z-index="{{ zIndex }}" | 3 | z-index="{{ zIndex }}" |
4 | overlay="{{ overlay }}" | 4 | overlay="{{ overlay }}" |
5 | custom-class="van-dialog" | ||
6 | transition="{{ transition }}" | 5 | transition="{{ transition }}" |
6 | custom-class="van-dialog {{ className }}" | ||
7 | custom-style="{{ widthWithUnit ? 'width: ' + widthWithUnit + ';' : '' }}{{ customStyle }}" | ||
8 | overlay-style="{{ overlayStyle }}" | ||
7 | close-on-click-overlay="{{ closeOnClickOverlay }}" | 9 | close-on-click-overlay="{{ closeOnClickOverlay }}" |
8 | bind:close="onClickOverlay" | 10 | bind:close="onClickOverlay" |
9 | > | 11 | > |
10 | <view | 12 | <view |
11 | wx:if="{{ title }}" | 13 | wx:if="{{ title || useTitleSlot }}" |
12 | class="van-dialog__header {{ message || useSlot ? '' : 'van-dialog--isolated' }}" | 14 | class="van-dialog__header {{ message || useSlot ? '' : 'van-dialog--isolated' }}" |
13 | > | 15 | > |
14 | {{ title }} | 16 | <slot wx:if="{{ useTitleSlot }}" name="title" /> |
17 | <block wx:elif="{{ title }}"> {{ title }}</block> | ||
15 | </view> | 18 | </view> |
16 | 19 | ||
17 | <slot wx:if="{{ useSlot }}" /> | 20 | <slot wx:if="{{ useSlot }}" /> |
... | @@ -19,7 +22,7 @@ | ... | @@ -19,7 +22,7 @@ |
19 | wx:elif="{{ message }}" | 22 | wx:elif="{{ message }}" |
20 | class="van-dialog__message {{ title ? 'van-dialog__message--has-title' : '' }} {{ messageAlign ? 'van-dialog__message--' + messageAlign : '' }}" | 23 | class="van-dialog__message {{ title ? 'van-dialog__message--has-title' : '' }} {{ messageAlign ? 'van-dialog__message--' + messageAlign : '' }}" |
21 | > | 24 | > |
22 | <text>{{ message }}</text> | 25 | <text class="van-dialog__message-text">{{ message }}</text> |
23 | </view> | 26 | </view> |
24 | 27 | ||
25 | <view class="van-hairline--top van-dialog__footer"> | 28 | <view class="van-hairline--top van-dialog__footer"> |
... | @@ -29,6 +32,7 @@ | ... | @@ -29,6 +32,7 @@ |
29 | loading="{{ loading.cancel }}" | 32 | loading="{{ loading.cancel }}" |
30 | class="van-dialog__button van-hairline--right" | 33 | class="van-dialog__button van-hairline--right" |
31 | custom-class="van-dialog__cancel" | 34 | custom-class="van-dialog__cancel" |
35 | custom-style="color: {{ cancelButtonColor }}" | ||
32 | bind:click="onCancel" | 36 | bind:click="onCancel" |
33 | > | 37 | > |
34 | {{ cancelButtonText }} | 38 | {{ cancelButtonText }} |
... | @@ -39,6 +43,7 @@ | ... | @@ -39,6 +43,7 @@ |
39 | class="van-dialog__button" | 43 | class="van-dialog__button" |
40 | loading="{{ loading.confirm }}" | 44 | loading="{{ loading.confirm }}" |
41 | custom-class="van-dialog__confirm" | 45 | custom-class="van-dialog__confirm" |
46 | custom-style="color: {{ confirmButtonColor }}" | ||
42 | 47 | ||
43 | open-type="{{ confirmButtonOpenType }}" | 48 | open-type="{{ confirmButtonOpenType }}" |
44 | lang="{{ lang }}" | 49 | lang="{{ lang }}" | ... | ... |
1 | @import '../common/index.wxss';.van-dialog{width:85%;overflow:hidden;font-size:16px;background-color:#fff;border-radius:4px}.van-dialog__header{padding-top:25px;font-weight:500;text-align:center}.van-dialog__header--isolated{padding:25px 0}.van-dialog__message{max-height:60vh;padding:25px;overflow-y:auto;font-size:14px;line-height:1.5;text-align:center;-webkit-overflow-scrolling:touch}.van-dialog__message--has-title{padding-top:12px;color:#7d7e80}.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__confirm{color:#1989fa!important}.van-dialog-bounce-enter{opacity:0;-webkit-transform:translate3d(-50%,-50%,0) scale(.7);transform:translate3d(-50%,-50%,0) scale(.7)}.van-dialog-bounce-leave-active{opacity:0;-webkit-transform:translate3d(-50%,-50%,0) scale(.9);transform:translate3d(-50%,-50%,0) scale(.9)} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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:#7d7e80;color:var(--dialog-has-title-message-text-color,#7d7e80)}.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 | ... | \ No newline at end of file | ... | ... |
src/ui/vant-weapp/divider/index.js
0 → 100755
1 | import { VantComponent } from '../common/component'; | ||
2 | VantComponent({ | ||
3 | props: { | ||
4 | dashed: { | ||
5 | type: Boolean, | ||
6 | value: false | ||
7 | }, | ||
8 | hairline: { | ||
9 | type: Boolean, | ||
10 | value: false | ||
11 | }, | ||
12 | contentPosition: { | ||
13 | type: String, | ||
14 | value: '' | ||
15 | }, | ||
16 | fontSize: { | ||
17 | type: Number, | ||
18 | value: '' | ||
19 | }, | ||
20 | borderColor: { | ||
21 | type: String, | ||
22 | value: '' | ||
23 | }, | ||
24 | textColor: { | ||
25 | type: String, | ||
26 | value: '' | ||
27 | }, | ||
28 | customStyle: { | ||
29 | type: String, | ||
30 | value: '' | ||
31 | } | ||
32 | } | ||
33 | }); |
src/ui/vant-weapp/divider/index.json
0 → 100755
src/ui/vant-weapp/divider/index.wxml
0 → 100755
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | |||
3 | <view | ||
4 | class="custom-class {{ utils.bem('divider', [{dashed, hairline}, contentPosition]) }}" | ||
5 | style="{{ borderColor ? 'border-color: ' + borderColor + ';' : '' }}{{ textColor ? 'color: ' + textColor + ';' : '' }} {{ fontSize ? 'font-size: ' + fontSize + 'px;' : '' }} {{ customStyle }}" | ||
6 | > | ||
7 | <slot /> | ||
8 | </view> |
src/ui/vant-weapp/divider/index.wxss
0 → 100755
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 | ... | \ No newline at end of file |
src/ui/vant-weapp/dropdown-item/index.d.ts
0 → 100755
1 | export {}; |
src/ui/vant-weapp/dropdown-item/index.js
0 → 100755
1 | import { VantComponent } from '../common/component'; | ||
2 | VantComponent({ | ||
3 | field: true, | ||
4 | relation: { | ||
5 | name: 'dropdown-menu', | ||
6 | type: 'ancestor', | ||
7 | linked(target) { | ||
8 | this.parent = target; | ||
9 | }, | ||
10 | unlinked() { | ||
11 | this.parent = null; | ||
12 | } | ||
13 | }, | ||
14 | props: { | ||
15 | value: null, | ||
16 | title: String, | ||
17 | disabled: Boolean, | ||
18 | titleClass: String, | ||
19 | options: { | ||
20 | type: Array, | ||
21 | value: [] | ||
22 | } | ||
23 | }, | ||
24 | data: { | ||
25 | transition: true, | ||
26 | showPopup: false, | ||
27 | showWrapper: false, | ||
28 | displayTitle: '' | ||
29 | }, | ||
30 | created() { | ||
31 | this.setData({ displayTitle: this.computedDisplayTitle(this.data.value) }); | ||
32 | }, | ||
33 | methods: { | ||
34 | computedDisplayTitle(curValue) { | ||
35 | const { title, options } = this.data; | ||
36 | if (title) { | ||
37 | return title; | ||
38 | } | ||
39 | const match = options.filter(option => option.value === curValue); | ||
40 | const displayTitle = match.length ? match[0].text : ''; | ||
41 | return displayTitle; | ||
42 | }, | ||
43 | onClickOverlay() { | ||
44 | this.toggle(); | ||
45 | this.$emit('close'); | ||
46 | }, | ||
47 | onOptionTap(event) { | ||
48 | let { value, displayTitle } = this.data; | ||
49 | const { option } = event.currentTarget.dataset; | ||
50 | const { value: optionValue } = option; | ||
51 | if (optionValue !== value) { | ||
52 | value = optionValue; | ||
53 | displayTitle = this.computedDisplayTitle(optionValue); | ||
54 | this.$emit('change', optionValue); | ||
55 | } | ||
56 | this.setData({ showPopup: false, value, displayTitle }); | ||
57 | const time = this.data.duration || 0; | ||
58 | setTimeout(() => { | ||
59 | this.setData({ showWrapper: false }); | ||
60 | }, time); | ||
61 | // parent 中的 itemListData 是 children 上的数据的集合 | ||
62 | // 数据的更新由 children 各自维护,但是模板的更新需要额外触发 parent 的 setData | ||
63 | this.parent.setData({ itemListData: this.parent.data.itemListData }); | ||
64 | }, | ||
65 | toggle() { | ||
66 | const { childIndex } = this.data; | ||
67 | this.parent.toggleItem(childIndex); | ||
68 | } | ||
69 | } | ||
70 | }); |
src/ui/vant-weapp/dropdown-item/index.wxml
0 → 100755
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | |||
3 | <view | ||
4 | wx:if="{{ showWrapper }}" | ||
5 | class="{{ utils.bem('dropdown-item', direction) }}" | ||
6 | style="{{ wrapperStyle }}" | ||
7 | > | ||
8 | <van-popup | ||
9 | show="{{ showPopup }}" | ||
10 | custom-style="position: absolute;" | ||
11 | overlay-style="position: absolute;" | ||
12 | overlay="{{ overlay }}" | ||
13 | position="{{ direction === 'down' ? 'top' : 'bottom' }}" | ||
14 | duration="{{ transition ? duration : 0 }}" | ||
15 | close-on-click-overlay="{{ closeOnClickOverlay }}" | ||
16 | bind:close="onClickOverlay" | ||
17 | > | ||
18 | <van-cell | ||
19 | wx:for="{{ options }}" | ||
20 | wx:key="{{ item.value }}" | ||
21 | data-option="{{ item }}" | ||
22 | class="{{ utils.bem('dropdown-item__option', { active: item.value === value } ) }}" | ||
23 | clickable | ||
24 | icon="{{ item.icon }}" | ||
25 | bind:tap="onOptionTap" | ||
26 | > | ||
27 | <view | ||
28 | slot="title" | ||
29 | class="van-dropdown-item__title" | ||
30 | style="{{ item.value === value ? 'color:' + activeColor : '' }}" | ||
31 | > | ||
32 | {{ item.text }} | ||
33 | </view> | ||
34 | <van-icon | ||
35 | wx:if="{{ item.value === value }}" | ||
36 | name="success" | ||
37 | class="van-dropdown-item__icon" | ||
38 | color="{{ activeColor }}" | ||
39 | /> | ||
40 | </van-cell> | ||
41 | |||
42 | <slot /> | ||
43 | </van-popup> | ||
44 | </view> |
src/ui/vant-weapp/dropdown-item/index.wxss
0 → 100755
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 | ... | \ No newline at end of file |
src/ui/vant-weapp/dropdown-menu/index.d.ts
0 → 100755
1 | export {}; |
src/ui/vant-weapp/dropdown-menu/index.js
0 → 100755
1 | import { VantComponent } from '../common/component'; | ||
2 | import { addUnit } from '../common/utils'; | ||
3 | let ARRAY = []; | ||
4 | VantComponent({ | ||
5 | field: true, | ||
6 | relation: { | ||
7 | name: 'dropdown-item', | ||
8 | type: 'descendant', | ||
9 | linked(target) { | ||
10 | this.children = this.children || []; | ||
11 | // 透传 props 给 dropdown-item | ||
12 | const { overlay, duration, activeColor, closeOnClickOverlay, direction } = this.data; | ||
13 | this.updateChildData(target, { | ||
14 | overlay, | ||
15 | duration, | ||
16 | activeColor, | ||
17 | closeOnClickOverlay, | ||
18 | direction, | ||
19 | childIndex: this.children.length | ||
20 | }); | ||
21 | this.children.push(target); | ||
22 | // 收集 dropdown-item 的 data 挂在 data 上 | ||
23 | target && | ||
24 | this.setData({ | ||
25 | itemListData: this.data.itemListData.concat([target.data]) | ||
26 | }); | ||
27 | }, | ||
28 | unlinked(target) { | ||
29 | this.children = this.children.filter((child) => child !== target); | ||
30 | } | ||
31 | }, | ||
32 | props: { | ||
33 | activeColor: String, | ||
34 | overlay: { | ||
35 | type: Boolean, | ||
36 | value: true | ||
37 | }, | ||
38 | zIndex: { | ||
39 | type: Number, | ||
40 | value: 10 | ||
41 | }, | ||
42 | duration: { | ||
43 | type: Number, | ||
44 | value: 200 | ||
45 | }, | ||
46 | direction: { | ||
47 | type: String, | ||
48 | value: 'down' | ||
49 | }, | ||
50 | closeOnClickOverlay: { | ||
51 | type: Boolean, | ||
52 | value: true | ||
53 | }, | ||
54 | closeOnClickOutside: { | ||
55 | type: Boolean, | ||
56 | value: true | ||
57 | } | ||
58 | }, | ||
59 | data: { | ||
60 | itemListData: [] | ||
61 | }, | ||
62 | created() { | ||
63 | ARRAY.push(this); | ||
64 | }, | ||
65 | destroyed() { | ||
66 | ARRAY = ARRAY.filter(item => item !== this); | ||
67 | }, | ||
68 | methods: { | ||
69 | updateChildData(childItem, newData, needRefreshList = false) { | ||
70 | childItem.setData(newData); | ||
71 | if (needRefreshList) { | ||
72 | // dropdown-item data 更新,涉及到 title 的展示,触发模板更新 | ||
73 | this.setData({ itemListData: this.data.itemListData }); | ||
74 | } | ||
75 | }, | ||
76 | toggleItem(active) { | ||
77 | this.children.forEach((item, index) => { | ||
78 | const { showPopup } = item.data; | ||
79 | if (index === active) { | ||
80 | this.toggleChildItem(item); | ||
81 | } | ||
82 | else if (showPopup) { | ||
83 | this.toggleChildItem(item, false, { immediate: true }); | ||
84 | } | ||
85 | }); | ||
86 | }, | ||
87 | toggleChildItem(childItem, show, options = {}) { | ||
88 | const { showPopup, duration } = childItem.data; | ||
89 | if (show === undefined) | ||
90 | show = !showPopup; | ||
91 | if (show === showPopup) { | ||
92 | return; | ||
93 | } | ||
94 | const newChildData = { transition: !options.immediate, showPopup: show }; | ||
95 | if (!show) { | ||
96 | const time = options.immediate ? 0 : duration; | ||
97 | this.updateChildData(childItem, Object.assign({}, newChildData), true); | ||
98 | setTimeout(() => { | ||
99 | this.updateChildData(childItem, { showWrapper: false }, true); | ||
100 | }, time); | ||
101 | return; | ||
102 | } | ||
103 | this.getChildWrapperStyle().then((wrapperStyle = '') => { | ||
104 | this.updateChildData(childItem, Object.assign(Object.assign({}, newChildData), { wrapperStyle, showWrapper: true }), true); | ||
105 | }); | ||
106 | }, | ||
107 | close() { | ||
108 | this.children.forEach((item) => { | ||
109 | this.toggleChildItem(item, false, { immediate: true }); | ||
110 | }); | ||
111 | }, | ||
112 | getChildWrapperStyle() { | ||
113 | const { windowHeight } = wx.getSystemInfoSync(); | ||
114 | const { zIndex, direction } = this.data; | ||
115 | let offset = 0; | ||
116 | return this.getRect('.van-dropdown-menu').then(rect => { | ||
117 | const { top = 0, bottom = 0 } = rect; | ||
118 | if (direction === 'down') { | ||
119 | offset = bottom; | ||
120 | } | ||
121 | else { | ||
122 | offset = windowHeight - top; | ||
123 | } | ||
124 | let wrapperStyle = `z-index: ${zIndex};`; | ||
125 | if (direction === 'down') { | ||
126 | wrapperStyle += `top: ${addUnit(offset)};`; | ||
127 | } | ||
128 | else { | ||
129 | wrapperStyle += `bottom: ${addUnit(offset)};`; | ||
130 | } | ||
131 | return Promise.resolve(wrapperStyle); | ||
132 | }); | ||
133 | }, | ||
134 | onTitleTap(event) { | ||
135 | // item ---> dropdown-item | ||
136 | const { item, index } = event.currentTarget.dataset; | ||
137 | if (!item.disabled) { | ||
138 | // menuItem ---> dropdown-menu | ||
139 | ARRAY.forEach(menuItem => { | ||
140 | if (menuItem && menuItem.data.closeOnClickOutside && menuItem !== this) { | ||
141 | menuItem.close(); | ||
142 | } | ||
143 | }); | ||
144 | this.toggleItem(index); | ||
145 | } | ||
146 | } | ||
147 | } | ||
148 | }); |
src/ui/vant-weapp/dropdown-menu/index.json
0 → 100755
src/ui/vant-weapp/dropdown-menu/index.wxml
0 → 100755
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | |||
3 | <view class="van-dropdown-menu van-dropdown-menu--top-bottom"> | ||
4 | <view | ||
5 | wx:for="{{ itemListData }}" | ||
6 | wx:key="index" | ||
7 | data-item="{{ item }}" | ||
8 | data-index="{{ index }}" | ||
9 | class="{{ utils.bem('dropdown-menu__item', { disabled: item.disabled }) }}" | ||
10 | bind:tap="onTitleTap" | ||
11 | > | ||
12 | <view | ||
13 | class="{{ item.titleClass }} {{ utils.bem('dropdown-menu__title', { active: item.showPopup, down: item.showPopup === (direction === 'down') }) }}" | ||
14 | style="{{ item.showPopup ? 'color:' + activeColor : '' }}" | ||
15 | > | ||
16 | <view class="van-ellipsis"> | ||
17 | {{item.displayTitle}} | ||
18 | </view> | ||
19 | </view> | ||
20 | </view> | ||
21 | |||
22 | <slot /> | ||
23 | </view> |
src/ui/vant-weapp/dropdown-menu/index.wxss
0 → 100755
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 | ... | \ No newline at end of file |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { getSystemInfoSync } from '../common/utils'; | ||
2 | VantComponent({ | 3 | VantComponent({ |
3 | field: true, | 4 | field: true, |
4 | classes: ['input-class'], | 5 | classes: ['input-class', 'right-icon-class'], |
5 | props: { | 6 | props: { |
6 | size: String, | 7 | size: String, |
7 | icon: String, | 8 | icon: String, |
... | @@ -12,27 +13,37 @@ VantComponent({ | ... | @@ -12,27 +13,37 @@ VantComponent({ |
12 | center: Boolean, | 13 | center: Boolean, |
13 | isLink: Boolean, | 14 | isLink: Boolean, |
14 | leftIcon: String, | 15 | leftIcon: String, |
16 | rightIcon: String, | ||
15 | disabled: Boolean, | 17 | disabled: Boolean, |
16 | autosize: Boolean, | 18 | autosize: Boolean, |
17 | readonly: Boolean, | 19 | readonly: Boolean, |
18 | required: Boolean, | 20 | required: Boolean, |
21 | password: Boolean, | ||
19 | iconClass: String, | 22 | iconClass: String, |
20 | clearable: Boolean, | 23 | clearable: Boolean, |
24 | clickable: Boolean, | ||
21 | inputAlign: String, | 25 | inputAlign: String, |
22 | errorMessageAlign: String, | 26 | placeholder: String, |
23 | customClass: String, | 27 | customStyle: String, |
24 | confirmType: String, | 28 | confirmType: String, |
25 | confirmHold: Boolean, | 29 | confirmHold: Boolean, |
30 | holdKeyboard: Boolean, | ||
26 | errorMessage: String, | 31 | errorMessage: String, |
27 | placeholder: String, | 32 | arrowDirection: String, |
28 | customStyle: String, | 33 | placeholderStyle: String, |
29 | useIconSlot: Boolean, | 34 | errorMessageAlign: String, |
30 | useButtonSlot: Boolean, | 35 | selectionEnd: { |
36 | type: Number, | ||
37 | value: -1 | ||
38 | }, | ||
39 | selectionStart: { | ||
40 | type: Number, | ||
41 | value: -1 | ||
42 | }, | ||
31 | showConfirmBar: { | 43 | showConfirmBar: { |
32 | type: Boolean, | 44 | type: Boolean, |
33 | value: true | 45 | value: true |
34 | }, | 46 | }, |
35 | placeholderStyle: String, | ||
36 | adjustPosition: { | 47 | adjustPosition: { |
37 | type: Boolean, | 48 | type: Boolean, |
38 | value: true | 49 | value: true |
... | @@ -59,63 +70,29 @@ VantComponent({ | ... | @@ -59,63 +70,29 @@ VantComponent({ |
59 | } | 70 | } |
60 | }, | 71 | }, |
61 | data: { | 72 | data: { |
62 | showClear: false | 73 | focused: false, |
63 | }, | 74 | system: getSystemInfoSync().system.split(' ').shift().toLowerCase() |
64 | beforeCreate() { | ||
65 | this.focused = false; | ||
66 | }, | 75 | }, |
67 | methods: { | 76 | methods: { |
68 | onInput(event) { | 77 | onInput(event) { |
69 | const { value = '' } = event.detail || {}; | 78 | const { value = '' } = event.detail || {}; |
70 | this.set({ | 79 | this.setData({ value }, () => { |
71 | value, | ||
72 | showClear: this.getShowClear(value) | ||
73 | }, () => { | ||
74 | this.emitChange(value); | 80 | this.emitChange(value); |
75 | }); | 81 | }); |
76 | }, | 82 | }, |
77 | onFocus(event) { | 83 | onFocus(event) { |
78 | const { value = '', height = 0 } = event.detail || {}; | 84 | this.setData({ focused: true }); |
79 | this.$emit('focus', { value, height }); | 85 | this.$emit('focus', event.detail); |
80 | this.focused = true; | ||
81 | this.blurFromClear = false; | ||
82 | this.set({ | ||
83 | showClear: this.getShowClear() | ||
84 | }); | ||
85 | }, | 86 | }, |
86 | onBlur(event) { | 87 | onBlur(event) { |
87 | const { value = '', cursor = 0 } = event.detail || {}; | 88 | this.setData({ focused: false }); |
88 | this.$emit('blur', { value, cursor }); | 89 | this.$emit('blur', event.detail); |
89 | this.focused = false; | ||
90 | const showClear = this.getShowClear(); | ||
91 | if (this.data.value === value) { | ||
92 | this.set({ | ||
93 | showClear | ||
94 | }); | ||
95 | } | ||
96 | else if (!this.blurFromClear) { | ||
97 | // fix: the handwritten keyboard does not trigger input change | ||
98 | this.set({ | ||
99 | value, | ||
100 | showClear | ||
101 | }, () => { | ||
102 | this.emitChange(value); | ||
103 | }); | ||
104 | } | ||
105 | }, | 90 | }, |
106 | onClickIcon() { | 91 | onClickIcon() { |
107 | this.$emit('click-icon'); | 92 | this.$emit('click-icon'); |
108 | }, | 93 | }, |
109 | getShowClear(value) { | ||
110 | value = value === undefined ? this.data.value : value; | ||
111 | return (this.data.clearable && this.focused && value && !this.data.readonly); | ||
112 | }, | ||
113 | onClear() { | 94 | onClear() { |
114 | this.blurFromClear = true; | 95 | this.setData({ value: '' }, () => { |
115 | this.set({ | ||
116 | value: '', | ||
117 | showClear: this.getShowClear('') | ||
118 | }, () => { | ||
119 | this.emitChange(''); | 96 | this.emitChange(''); |
120 | this.$emit('clear', ''); | 97 | this.$emit('clear', ''); |
121 | }); | 98 | }); | ... | ... |
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | 1 | <wxs src="../wxs/utils.wxs" module="utils" /> |
2 | 2 | ||
3 | <van-cell | 3 | <van-cell |
4 | size="{{ size }}" | ||
4 | icon="{{ leftIcon }}" | 5 | icon="{{ leftIcon }}" |
5 | title="{{ label }}" | 6 | title="{{ label }}" |
6 | center="{{ center }}" | 7 | center="{{ center }}" |
7 | border="{{ border }}" | 8 | border="{{ border }}" |
8 | is-link="{{ isLink }}" | 9 | is-link="{{ isLink }}" |
9 | required="{{ required }}" | 10 | required="{{ required }}" |
10 | custom-style="{{ customStyle }}" | 11 | clickable="{{ clickable }}" |
11 | title-width="{{ titleWidth }}" | 12 | title-width="{{ titleWidth }}" |
13 | custom-style="{{ customStyle }}" | ||
14 | arrow-direction="{{ arrowDirection }}" | ||
12 | custom-class="van-field" | 15 | custom-class="van-field" |
13 | size="{{ size }}" | ||
14 | > | 16 | > |
15 | <slot name="left-icon" slot="icon" /> | 17 | <slot name="left-icon" slot="icon" /> |
16 | <slot name="label" slot="title" /> | 18 | <slot name="label" slot="title" /> |
17 | <view class="van-field__body {{ type === 'textarea' ? 'van-field__body--textarea' : '' }}"> | 19 | <view class="{{ utils.bem('field__body', [type, system]) }}"> |
18 | <textarea | 20 | <textarea |
19 | wx:if="{{ type === 'textarea' }}" | 21 | wx:if="{{ type === 'textarea' }}" |
20 | class="input-class {{ utils.bem('field__input', [inputAlign, { disabled, error }]) }}" | 22 | class="input-class {{ utils.bem('field__input', [inputAlign, type, { disabled, error }]) }}" |
21 | fixed="{{ fixed }}" | 23 | fixed="{{ fixed }}" |
22 | focus="{{ focus }}" | 24 | focus="{{ focus }}" |
23 | value="{{ value }}" | 25 | value="{{ value }}" |
24 | disabled="{{ disabled || readonly }}" | 26 | disabled="{{ disabled || readonly }}" |
25 | maxlength="{{ maxlength }}" | 27 | maxlength="{{ maxlength }}" |
26 | auto-height="{{ autosize }}" | ||
27 | placeholder="{{ placeholder }}" | 28 | placeholder="{{ placeholder }}" |
28 | placeholder-style="{{ placeholderStyle }}" | 29 | placeholder-style="{{ placeholderStyle }}" |
29 | placeholder-class="{{ error ? 'van-field__input--error' : 'van-field__placeholder' }}" | 30 | placeholder-class="{{ utils.bem('field__placeholder', { error }) }}" |
31 | auto-height="{{ autosize }}" | ||
30 | cursor-spacing="{{ cursorSpacing }}" | 32 | cursor-spacing="{{ cursorSpacing }}" |
31 | adjust-position="{{ adjustPosition }}" | 33 | adjust-position="{{ adjustPosition }}" |
32 | show-confirm-bar="{{ showConfirmBar }}" | 34 | show-confirm-bar="{{ showConfirmBar }}" |
35 | hold-keyboard="{{ holdKeyboard }}" | ||
36 | selection-end="{{ selectionEnd }}" | ||
37 | selection-start="{{ selectionStart }}" | ||
33 | bindinput="onInput" | 38 | bindinput="onInput" |
34 | bind:blur="onBlur" | 39 | bind:blur="onBlur" |
35 | bind:focus="onFocus" | 40 | bind:focus="onFocus" |
36 | bind:confirm="onConfirm" | 41 | bind:confirm="onConfirm" |
37 | /> | 42 | > |
43 | </textarea> | ||
38 | <input | 44 | <input |
39 | wx:else | 45 | wx:else |
40 | class="input-class {{ utils.bem('field__input', [inputAlign, { disabled, error }]) }}" | 46 | class="input-class {{ utils.bem('field__input', [inputAlign, { disabled, error }]) }}" |
... | @@ -45,34 +51,39 @@ | ... | @@ -45,34 +51,39 @@ |
45 | maxlength="{{ maxlength }}" | 51 | maxlength="{{ maxlength }}" |
46 | placeholder="{{ placeholder }}" | 52 | placeholder="{{ placeholder }}" |
47 | placeholder-style="{{ placeholderStyle }}" | 53 | placeholder-style="{{ placeholderStyle }}" |
48 | placeholder-class="{{ error ? 'van-field__input--error' : 'van-field__placeholder' }}" | 54 | placeholder-class="{{ utils.bem('field__placeholder', { error }) }}" |
49 | confirm-type="{{ confirmType }}" | 55 | confirm-type="{{ confirmType }}" |
50 | confirm-hold="{{ confirmHold }}" | 56 | confirm-hold="{{ confirmHold }}" |
57 | hold-keyboard="{{ holdKeyboard }}" | ||
51 | cursor-spacing="{{ cursorSpacing }}" | 58 | cursor-spacing="{{ cursorSpacing }}" |
52 | adjust-position="{{ adjustPosition }}" | 59 | adjust-position="{{ adjustPosition }}" |
60 | selection-end="{{ selectionEnd }}" | ||
61 | selection-start="{{ selectionStart }}" | ||
62 | password="{{ password || type === 'password' }}" | ||
53 | bindinput="onInput" | 63 | bindinput="onInput" |
54 | bind:blur="onBlur" | 64 | bind:blur="onBlur" |
55 | bind:focus="onFocus" | 65 | bind:focus="onFocus" |
56 | bind:confirm="onConfirm" | 66 | bind:confirm="onConfirm" |
57 | /> | 67 | /> |
58 | <van-icon | 68 | <van-icon |
59 | wx:if="{{ showClear }}" | 69 | wx:if="{{ clearable && focused && value && !readonly }}" |
60 | size="16px" | 70 | size="16px" |
61 | name="clear" | 71 | name="clear" |
62 | class="van-field__clear-root" | 72 | class="van-field__clear-root van-field__icon-root" |
63 | custom-class="van-field__clear" | 73 | bindtouchstart="onClear" |
64 | bind:touchstart="onClear" | ||
65 | /> | 74 | /> |
66 | <view class="van-field__icon-container" wx:if="{{ icon || useIconSlot }}" bind:tap="onClickIcon"> | 75 | <view class="van-field__icon-container" bind:tap="onClickIcon"> |
67 | <van-icon | 76 | <van-icon |
68 | wx:if="{{ icon }}" | 77 | wx:if="{{ rightIcon || icon }}" |
69 | size="16px" | 78 | size="16px" |
70 | name="{{ icon }}" | 79 | name="{{ rightIcon || icon }}" |
71 | custom-class="van-field__icon {{ iconClass }}" | 80 | class="van-field__icon-root {{ iconClass }}" |
81 | custom-class="right-icon-class" | ||
72 | /> | 82 | /> |
73 | <slot wx:else name="icon" /> | 83 | <slot name="right-icon" /> |
84 | <slot name="icon" /> | ||
74 | </view> | 85 | </view> |
75 | <view wx:if="{{ useButtonSlot }}" class="van-field__button"> | 86 | <view class="van-field__button"> |
76 | <slot name="button" /> | 87 | <slot name="button" /> |
77 | </view> | 88 | </view> |
78 | </view> | 89 | </view> | ... | ... |
1 | @import '../common/index.wxss';.van-field__body{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center}.van-field__body--textarea{min-height:24px}.van-field__input{display:block;width:100%;height:24px;min-height:24px;padding:0;margin:0;line-height:inherit;color:#333;text-align:left;background-color:initial;border:0;box-sizing:border-box;resize:none}.van-field__input--disabled{color:#999;background-color:initial;opacity:1}.van-field__input--center{text-align:center}.van-field__input--right{text-align:right}.van-field__input--error{color:#f44}.van-field__placeholder{color:#999}.van-field__clear-root{display:-webkit-flex;display:flex;height:24px;-webkit-align-items:center;align-items:center}.van-field__button,.van-field__clear,.van-field__icon-container{-webkit-flex-shrink:0;flex-shrink:0}.van-field__clear,.van-field__icon-container{padding:0 10px;margin-right:-10px;line-height:inherit;vertical-align:middle}.van-field__clear{color:#c9c9c9}.van-field__icon-container{color:#999}.van-field__icon{display:block!important}.van-field__button{padding-left:10px}.van-field__error-message{font-size:12px;color:#f44;text-align:left}.van-field__error--center{text-align:center}.van-field__error--right{text-align:right} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
... | @@ -4,8 +4,16 @@ import { button } from '../mixins/button'; | ... | @@ -4,8 +4,16 @@ import { button } from '../mixins/button'; |
4 | import { openType } from '../mixins/open-type'; | 4 | import { openType } from '../mixins/open-type'; |
5 | VantComponent({ | 5 | VantComponent({ |
6 | mixins: [link, button, openType], | 6 | mixins: [link, button, openType], |
7 | relation: { | ||
8 | type: 'ancestor', | ||
9 | name: 'goods-action', | ||
10 | linked(parent) { | ||
11 | this.parent = parent; | ||
12 | } | ||
13 | }, | ||
7 | props: { | 14 | props: { |
8 | text: String, | 15 | text: String, |
16 | color: String, | ||
9 | loading: Boolean, | 17 | loading: Boolean, |
10 | disabled: Boolean, | 18 | disabled: Boolean, |
11 | type: { | 19 | type: { |
... | @@ -13,10 +21,21 @@ VantComponent({ | ... | @@ -13,10 +21,21 @@ VantComponent({ |
13 | value: 'danger' | 21 | value: 'danger' |
14 | } | 22 | } |
15 | }, | 23 | }, |
24 | mounted() { | ||
25 | this.updateStyle(); | ||
26 | }, | ||
16 | methods: { | 27 | methods: { |
17 | onClick(event) { | 28 | onClick(event) { |
18 | this.$emit('click', event.detail); | 29 | this.$emit('click', event.detail); |
19 | this.jumpLink(); | 30 | this.jumpLink(); |
31 | }, | ||
32 | updateStyle() { | ||
33 | const { children = [] } = this.parent; | ||
34 | const index = children.indexOf(this); | ||
35 | this.setData({ | ||
36 | isFirst: index === 0, | ||
37 | isLast: index === children.length - 1 | ||
38 | }); | ||
20 | } | 39 | } |
21 | } | 40 | } |
22 | }); | 41 | }); | ... | ... |
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | ||
1 | <van-button | 2 | <van-button |
2 | square | 3 | square |
3 | id="{{ id }}" | 4 | id="{{ id }}" |
4 | size="large" | ||
5 | lang="{{ lang }}" | 5 | lang="{{ lang }}" |
6 | type="{{ type }}" | 6 | type="{{ type }}" |
7 | color="{{ color }}" | ||
7 | loading="{{ loading }}" | 8 | loading="{{ loading }}" |
8 | disabled="{{ disabled }}" | 9 | disabled="{{ disabled }}" |
9 | open-type="{{ openType }}" | 10 | open-type="{{ openType }}" |
10 | custom-class="custom-class" | 11 | custom-class="{{ utils.bem('goods-action-button', [type, { first: isFirst, last: isLast }]) }}" |
11 | business-id="{{ businessId }}" | 12 | business-id="{{ businessId }}" |
12 | session-from="{{ sessionFrom }}" | 13 | session-from="{{ sessionFrom }}" |
13 | app-parameter="{{ appParameter }}" | 14 | app-parameter="{{ appParameter }}" | ... | ... |
1 | @import '../common/index.wxss';:host{-webkit-flex:1;flex:1} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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:40px/2!important;border-top-left-radius:var(--goods-action-button-height,40px)/2!important;border-bottom-left-radius:40px/2!important;border-bottom-left-radius:var(--goods-action-button-height,40px)/2!important}.van-goods-action-button--last{display:block!important;margin-right:5px;border-top-right-radius:40px/2!important;border-top-right-radius:var(--goods-action-button-height,40px)/2!important;border-bottom-right-radius:40px/2!important;border-bottom-right-radius:var(--goods-action-button-height,40px)/2!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 | ... | \ No newline at end of file | ... | ... |
... | @@ -7,6 +7,7 @@ VantComponent({ | ... | @@ -7,6 +7,7 @@ VantComponent({ |
7 | mixins: [link, button, openType], | 7 | mixins: [link, button, openType], |
8 | props: { | 8 | props: { |
9 | text: String, | 9 | text: String, |
10 | dot: Boolean, | ||
10 | info: String, | 11 | info: String, |
11 | icon: String, | 12 | icon: String, |
12 | disabled: Boolean, | 13 | disabled: Boolean, | ... | ... |
... | @@ -22,14 +22,17 @@ | ... | @@ -22,14 +22,17 @@ |
22 | bindgetphonenumber="bindGetPhoneNumber" | 22 | bindgetphonenumber="bindGetPhoneNumber" |
23 | bindlaunchapp="bindLaunchApp" | 23 | bindlaunchapp="bindLaunchApp" |
24 | > | 24 | > |
25 | <view class="van-goods-action-icon__content van-hairline--right"> | 25 | <view class="van-goods-action-icon__content"> |
26 | <van-icon | 26 | <van-icon |
27 | wx:if="{{ icon }}" | ||
27 | size="20px" | 28 | size="20px" |
28 | name="{{ icon }}" | 29 | name="{{ icon }}" |
30 | dot="{{ dot }}" | ||
29 | info="{{ info }}" | 31 | info="{{ info }}" |
30 | class="van-goods-action-icon__icon" | 32 | class="van-goods-action-icon__icon" |
31 | custom-class="icon-class" | 33 | custom-class="icon-class" |
32 | /> | 34 | /> |
35 | <slot name="icon" /> | ||
33 | <text class="text-class">{{ text }}</text> | 36 | <text class="text-class">{{ text }}</text> |
34 | </view> | 37 | </view> |
35 | </van-button> | 38 | </van-button> | ... | ... |
1 | @import '../common/index.wxss';.van-goods-action-icon{width:50px!important;border:none!important}.van-goods-action-icon__content{display:-webkit-flex;display:flex;height:100%;font-size:10px;line-height:1;color:#7d7e80;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center;justify-content:center}.van-goods-action-icon__icon{margin-bottom:4px} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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:#7d7e80;color:var(--goods-action-icon-text-color,#7d7e80)}.van-goods-action-icon__icon{margin-bottom:4px} | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { safeArea } from '../mixins/safe-area'; | ||
3 | VantComponent({ | 2 | VantComponent({ |
4 | mixins: [safeArea()] | 3 | relation: { |
4 | type: 'descendant', | ||
5 | name: 'goods-action-button', | ||
6 | linked(child) { | ||
7 | this.children.push(child); | ||
8 | }, | ||
9 | unlinked(child) { | ||
10 | this.children = this.children.filter((item) => item !== child); | ||
11 | } | ||
12 | }, | ||
13 | beforeCreate() { | ||
14 | this.children = []; | ||
15 | }, | ||
16 | props: { | ||
17 | safeAreaInsetBottom: { | ||
18 | type: Boolean, | ||
19 | value: true | ||
20 | } | ||
21 | } | ||
5 | }); | 22 | }); | ... | ... |
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | 1 | <wxs src="../wxs/utils.wxs" module="utils" /> |
2 | 2 | ||
3 | <view class="custom-class {{ utils.bem('goods-action', { safe: isIPhoneX && safeAreaInsetBottom }) }}"> | 3 | <view class="custom-class {{ utils.bem('goods-action', { safe: safeAreaInsetBottom }) }}"> |
4 | <slot /> | 4 | <slot /> |
5 | </view> | 5 | </view> | ... | ... |
1 | @import '../common/index.wxss';.van-goods-action{position:fixed;right:0;bottom:0;left:0;display:-webkit-flex;display:flex;background-color:#fff}.van-goods-action--safe{padding-bottom:34px} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
src/ui/vant-weapp/grid-item/index.d.ts
0 → 100755
1 | export {}; |
src/ui/vant-weapp/grid-item/index.js
0 → 100755
1 | import { link } from '../mixins/link'; | ||
2 | import { VantComponent } from '../common/component'; | ||
3 | VantComponent({ | ||
4 | relation: { | ||
5 | name: 'grid', | ||
6 | type: 'ancestor', | ||
7 | linked(parent) { | ||
8 | this.parent = parent; | ||
9 | } | ||
10 | }, | ||
11 | mixins: [link], | ||
12 | props: { | ||
13 | icon: String, | ||
14 | dot: Boolean, | ||
15 | info: null, | ||
16 | text: String, | ||
17 | useSlot: Boolean | ||
18 | }, | ||
19 | mounted() { | ||
20 | this.updateStyle(); | ||
21 | }, | ||
22 | methods: { | ||
23 | updateStyle() { | ||
24 | if (!this.parent) { | ||
25 | return; | ||
26 | } | ||
27 | const { data, children } = this.parent; | ||
28 | const { columnNum, border, square, gutter, clickable, center } = data; | ||
29 | const width = `${100 / columnNum}%`; | ||
30 | const styleWrapper = []; | ||
31 | styleWrapper.push(`width: ${width}`); | ||
32 | if (square) { | ||
33 | styleWrapper.push(`padding-top: ${width}`); | ||
34 | } | ||
35 | if (gutter) { | ||
36 | styleWrapper.push(`padding-right: ${gutter}px`); | ||
37 | const index = children.indexOf(this); | ||
38 | if (index >= columnNum) { | ||
39 | styleWrapper.push(`margin-top: ${gutter}px`); | ||
40 | } | ||
41 | } | ||
42 | this.setData({ | ||
43 | style: styleWrapper.join('; '), | ||
44 | center, | ||
45 | border, | ||
46 | square, | ||
47 | gutter, | ||
48 | clickable | ||
49 | }); | ||
50 | }, | ||
51 | onClick() { | ||
52 | this.$emit('click'); | ||
53 | this.jumpLink(); | ||
54 | } | ||
55 | } | ||
56 | }); |
src/ui/vant-weapp/grid-item/index.json
0 → 100755
src/ui/vant-weapp/grid-item/index.wxml
0 → 100755
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | |||
3 | <view class="{{ utils.bem('grid-item', { square }) }}" style="{{ style }}" bindtap="onClick"> | ||
4 | <view class="{{ utils.bem('grid-item__content', { center, square, clickable, surround: border && gutter }) }} {{ border ? 'van-hairline--surround' : '' }}"> | ||
5 | <block wx:if="{{ useSlot }}"> | ||
6 | <slot /> | ||
7 | </block> | ||
8 | <block wx:else> | ||
9 | <view class="van-grid-item__icon"> | ||
10 | <van-icon wx:if="{{ icon }}" name="{{ icon }}" dot="{{ dot }}" info="{{ info }}" /> | ||
11 | <slot wx:else name="icon"></slot> | ||
12 | </view> | ||
13 | <view class="van-grid-item__text"> | ||
14 | <text wx:if="{{ text }}">{{ text }}</text> | ||
15 | <slot wx:else name="text"></slot> | ||
16 | </view> | ||
17 | </block> | ||
18 | </view> | ||
19 | </view> |
src/ui/vant-weapp/grid-item/index.wxss
0 → 100755
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:#7d7e80;color:var(--grid-item-text-color,#7d7e80);font-size:12px;font-size:var(--grid-item-text-font-size,12px)} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
src/ui/vant-weapp/grid/index.d.ts
0 → 100755
1 | export {}; |
src/ui/vant-weapp/grid/index.js
0 → 100755
1 | import { VantComponent } from '../common/component'; | ||
2 | VantComponent({ | ||
3 | relation: { | ||
4 | name: 'grid-item', | ||
5 | type: 'descendant', | ||
6 | linked(child) { | ||
7 | this.children.push(child); | ||
8 | }, | ||
9 | unlinked(child) { | ||
10 | this.children = this.children.filter((item) => item !== child); | ||
11 | } | ||
12 | }, | ||
13 | props: { | ||
14 | square: { | ||
15 | type: Boolean, | ||
16 | observer: 'updateChildren' | ||
17 | }, | ||
18 | gutter: { | ||
19 | type: [Number, String], | ||
20 | value: 0, | ||
21 | observer: 'updateChildren' | ||
22 | }, | ||
23 | clickable: { | ||
24 | type: Boolean, | ||
25 | observer: 'updateChildren' | ||
26 | }, | ||
27 | columnNum: { | ||
28 | type: Number, | ||
29 | value: 4, | ||
30 | observer: 'updateChildren' | ||
31 | }, | ||
32 | center: { | ||
33 | type: Boolean, | ||
34 | value: true, | ||
35 | observer: 'updateChildren' | ||
36 | }, | ||
37 | border: { | ||
38 | type: Boolean, | ||
39 | value: true, | ||
40 | observer: 'updateChildren' | ||
41 | } | ||
42 | }, | ||
43 | beforeCreate() { | ||
44 | this.children = []; | ||
45 | }, | ||
46 | created() { | ||
47 | const { gutter } = this.data; | ||
48 | if (gutter) { | ||
49 | this.setData({ | ||
50 | style: `padding-left: ${gutter}px` | ||
51 | }); | ||
52 | } | ||
53 | }, | ||
54 | methods: { | ||
55 | updateChildren() { | ||
56 | this.children.forEach((child) => { | ||
57 | child.updateStyle(); | ||
58 | }); | ||
59 | } | ||
60 | } | ||
61 | }); |
src/ui/vant-weapp/grid/index.json
0 → 100755
src/ui/vant-weapp/grid/index.wxml
0 → 100755
src/ui/vant-weapp/grid/index.wxss
0 → 100755
1 | @import '../common/index.wxss';.van-grid{position:relative;box-sizing:border-box;overflow:hidden} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { addUnit } from '../common/utils'; | ||
2 | VantComponent({ | 3 | VantComponent({ |
3 | props: { | 4 | props: { |
5 | dot: Boolean, | ||
4 | info: null, | 6 | info: null, |
5 | name: String, | 7 | size: { |
6 | size: String, | 8 | type: null, |
9 | observer: 'setSizeWithUnit' | ||
10 | }, | ||
7 | color: String, | 11 | color: String, |
8 | customStyle: String, | 12 | customStyle: String, |
9 | classPrefix: { | 13 | classPrefix: { |
10 | type: String, | 14 | type: String, |
11 | value: 'van-icon' | 15 | value: 'van-icon' |
16 | }, | ||
17 | name: { | ||
18 | type: String, | ||
19 | observer(val) { | ||
20 | this.setData({ | ||
21 | isImageName: val.indexOf('/') !== -1 | ||
22 | }); | ||
12 | } | 23 | } |
24 | } | ||
25 | }, | ||
26 | data: { | ||
27 | sizeWithUnit: null, | ||
13 | }, | 28 | }, |
14 | methods: { | 29 | methods: { |
15 | onClick() { | 30 | onClick() { |
16 | this.$emit('click'); | 31 | this.$emit('click'); |
32 | }, | ||
33 | setSizeWithUnit(size) { | ||
34 | this.setData({ | ||
35 | sizeWithUnit: addUnit(size) | ||
36 | }); | ||
17 | } | 37 | } |
18 | } | 38 | } |
19 | }); | 39 | }); | ... | ... |
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | |||
3 | <view | 1 | <view |
4 | class="custom-class {{ classPrefix }} {{ utils.isSrc(name) ? 'van-icon--image' : classPrefix + '-' + name }}" | 2 | class="custom-class {{ classPrefix }} {{ isImageName ? 'van-icon--image' : classPrefix + '-' + name }}" |
5 | style="{{ color ? 'color: ' + color + ';' : '' }}{{ size ? 'font-size: ' + size + ';' : '' }}{{ customStyle }}" | 3 | style="{{ color ? 'color: ' + color + ';' : '' }}{{ size ? 'font-size: ' + sizeWithUnit + ';' : '' }}{{ customStyle }}" |
6 | bind:tap="onClick" | 4 | bind:tap="onClick" |
7 | > | 5 | > |
8 | <van-info | 6 | <van-info |
9 | wx:if="{{ info !== null }}" | 7 | wx:if="{{ info !== null || dot }}" |
8 | dot="{{ dot }}" | ||
10 | info="{{ info }}" | 9 | info="{{ info }}" |
11 | custom-class="van-icon__info" | 10 | custom-class="van-icon__info" |
12 | /> | 11 | /> |
13 | <image | 12 | <image |
14 | wx:if="{{ utils.isSrc(name) }}" | 13 | wx:if="{{ isImageName }}" |
15 | src="{{ name }}" | 14 | src="{{ name }}" |
15 | mode="aspectFit" | ||
16 | class="van-icon__image" | 16 | class="van-icon__image" |
17 | /> | 17 | /> |
18 | </view> | 18 | </view> | ... | ... |
1 | @import '../common/index.wxss';@font-face{font-style:normal;font-weight:400;font-family:vant-icon;src:url(https://img.yzcdn.cn/vant/vant-icon-29f643.woff2) format("woff2"),url(https://img.yzcdn.cn/vant/vant-icon-29f643.woff) format("woff"),url(https://img.yzcdn.cn/vant/vant-icon-29f643.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-o:before{content:"\F03A"}.van-icon-comment:before{content:"\F03B"}.van-icon-completed:before{content:"\F03C"}.van-icon-contact:before{content:"\F03D"}.van-icon-coupon-o:before{content:"\F03E"}.van-icon-coupon:before{content:"\F03F"}.van-icon-credit-pay:before{content:"\F040"}.van-icon-cross:before{content:"\F041"}.van-icon-debit-pay:before{content:"\F042"}.van-icon-delete:before{content:"\F043"}.van-icon-descending:before{content:"\F044"}.van-icon-description:before{content:"\F045"}.van-icon-desktop-o:before{content:"\F046"}.van-icon-diamond-o:before{content:"\F047"}.van-icon-diamond:before{content:"\F048"}.van-icon-discount:before{content:"\F049"}.van-icon-ecard-pay:before{content:"\F04A"}.van-icon-edit:before{content:"\F04B"}.van-icon-ellipsis:before{content:"\F04C"}.van-icon-empty:before{content:"\F04D"}.van-icon-envelop-o:before{content:"\F04E"}.van-icon-exchange:before{content:"\F04F"}.van-icon-expand-o:before{content:"\F050"}.van-icon-expand:before{content:"\F051"}.van-icon-eye-o:before{content:"\F052"}.van-icon-eye:before{content:"\F053"}.van-icon-fail:before{content:"\F054"}.van-icon-failure:before{content:"\F055"}.van-icon-filter-o:before{content:"\F056"}.van-icon-fire-o:before{content:"\F057"}.van-icon-fire:before{content:"\F058"}.van-icon-flag-o:before{content:"\F059"}.van-icon-flower-o:before{content:"\F05A"}.van-icon-free-postage:before{content:"\F05B"}.van-icon-friends-o:before{content:"\F05C"}.van-icon-friends:before{content:"\F05D"}.van-icon-gem-o:before{content:"\F05E"}.van-icon-gem:before{content:"\F05F"}.van-icon-gift-card-o:before{content:"\F060"}.van-icon-gift-card:before{content:"\F061"}.van-icon-gift-o:before{content:"\F062"}.van-icon-gift:before{content:"\F063"}.van-icon-gold-coin-o:before{content:"\F064"}.van-icon-gold-coin:before{content:"\F065"}.van-icon-goods-collect-o:before{content:"\F066"}.van-icon-goods-collect:before{content:"\F067"}.van-icon-graphic:before{content:"\F068"}.van-icon-home-o:before{content:"\F069"}.van-icon-hot-o:before{content:"\F06A"}.van-icon-hot-sale-o:before{content:"\F06B"}.van-icon-hot-sale:before{content:"\F06C"}.van-icon-hot:before{content:"\F06D"}.van-icon-hotel-o:before{content:"\F06E"}.van-icon-idcard:before{content:"\F06F"}.van-icon-info-o:before{content:"\F070"}.van-icon-info:before{content:"\F071"}.van-icon-invition:before{content:"\F072"}.van-icon-label-o:before{content:"\F073"}.van-icon-label:before{content:"\F074"}.van-icon-like-o:before{content:"\F075"}.van-icon-like:before{content:"\F076"}.van-icon-live:before{content:"\F077"}.van-icon-location-o:before{content:"\F078"}.van-icon-location:before{content:"\F079"}.van-icon-lock:before{content:"\F07A"}.van-icon-logistics:before{content:"\F07B"}.van-icon-manager-o:before{content:"\F07C"}.van-icon-manager:before{content:"\F07D"}.van-icon-map-marked:before{content:"\F07E"}.van-icon-medel-o:before{content:"\F07F"}.van-icon-medel:before{content:"\F080"}.van-icon-more-o:before{content:"\F081"}.van-icon-more:before{content:"\F082"}.van-icon-music-o:before{content:"\F083"}.van-icon-new-arrival-o:before{content:"\F084"}.van-icon-new-arrival:before{content:"\F085"}.van-icon-new-o:before{content:"\F086"}.van-icon-new:before{content:"\F087"}.van-icon-newspaper-o:before{content:"\F088"}.van-icon-notes-o:before{content:"\F089"}.van-icon-orders-o:before{content:"\F08A"}.van-icon-other-pay:before{content:"\F08B"}.van-icon-paid:before{content:"\F08C"}.van-icon-passed:before{content:"\F08D"}.van-icon-pause-circle-o:before{content:"\F08E"}.van-icon-pause-circle:before{content:"\F08F"}.van-icon-pause:before{content:"\F090"}.van-icon-peer-pay:before{content:"\F091"}.van-icon-pending-payment:before{content:"\F092"}.van-icon-phone-circle-o:before{content:"\F093"}.van-icon-phone-o:before{content:"\F094"}.van-icon-phone:before{content:"\F095"}.van-icon-photo-o:before{content:"\F096"}.van-icon-photo:before{content:"\F097"}.van-icon-photograph:before{content:"\F098"}.van-icon-play-circle-o:before{content:"\F099"}.van-icon-play-circle:before{content:"\F09A"}.van-icon-play:before{content:"\F09B"}.van-icon-plus:before{content:"\F09C"}.van-icon-point-gift-o:before{content:"\F09D"}.van-icon-point-gift:before{content:"\F09E"}.van-icon-points:before{content:"\F09F"}.van-icon-printer:before{content:"\F0A0"}.van-icon-qr-invalid:before{content:"\F0A1"}.van-icon-qr:before{content:"\F0A2"}.van-icon-question-o:before{content:"\F0A3"}.van-icon-question:before{content:"\F0A4"}.van-icon-records:before{content:"\F0A5"}.van-icon-refund-o:before{content:"\F0A6"}.van-icon-replay:before{content:"\F0A7"}.van-icon-scan:before{content:"\F0A8"}.van-icon-search:before{content:"\F0A9"}.van-icon-send-gift-o:before{content:"\F0AA"}.van-icon-send-gift:before{content:"\F0AB"}.van-icon-service-o:before{content:"\F0AC"}.van-icon-service:before{content:"\F0AD"}.van-icon-setting-o:before{content:"\F0AE"}.van-icon-setting:before{content:"\F0AF"}.van-icon-share:before{content:"\F0B0"}.van-icon-shop-collect-o:before{content:"\F0B1"}.van-icon-shop-collect:before{content:"\F0B2"}.van-icon-shop-o:before{content:"\F0B3"}.van-icon-shop:before{content:"\F0B4"}.van-icon-shopping-cart-o:before{content:"\F0B5"}.van-icon-shopping-cart:before{content:"\F0B6"}.van-icon-shrink:before{content:"\F0B7"}.van-icon-sign:before{content:"\F0B8"}.van-icon-smile-comment-o:before{content:"\F0B9"}.van-icon-smile-comment:before{content:"\F0BA"}.van-icon-smile-o:before{content:"\F0BB"}.van-icon-star-o:before{content:"\F0BC"}.van-icon-star:before{content:"\F0BD"}.van-icon-stop-circle-o:before{content:"\F0BE"}.van-icon-stop-circle:before{content:"\F0BF"}.van-icon-stop:before{content:"\F0C0"}.van-icon-success:before{content:"\F0C1"}.van-icon-thumb-circle-o:before{content:"\F0C2"}.van-icon-todo-list-o:before{content:"\F0C3"}.van-icon-todo-list:before{content:"\F0C4"}.van-icon-tosend:before{content:"\F0C5"}.van-icon-tv-o:before{content:"\F0C6"}.van-icon-umbrella-circle:before{content:"\F0C7"}.van-icon-underway-o:before{content:"\F0C8"}.van-icon-underway:before{content:"\F0C9"}.van-icon-upgrade:before{content:"\F0CA"}.van-icon-user-circle-o:before{content:"\F0CB"}.van-icon-user-o:before{content:"\F0CC"}.van-icon-video-o:before{content:"\F0CD"}.van-icon-video:before{content:"\F0CE"}.van-icon-vip-card-o:before{content:"\F0CF"}.van-icon-vip-card:before{content:"\F0D0"}.van-icon-volume-o:before{content:"\F0D1"}.van-icon-volume:before{content:"\F0D2"}.van-icon-wap-home:before{content:"\F0D3"}.van-icon-wap-nav:before{content:"\F0D4"}.van-icon-warn-o:before{content:"\F0D5"}.van-icon-warning-o:before{content:"\F0D6"}.van-icon-weapp-nav:before{content:"\F0D7"}.van-icon-wechat:before{content:"\F0D8"}.van-icon-youzan-shield:before{content:"\F0D9"}.van-icon--image{width:1em;height:1em}.van-icon__image{position:absolute;top:0;right:0;bottom:0;left:0;max-width:100%;max-height:100%;margin:auto}.van-icon__info{z-index:1} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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-flex;display: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 | ... | \ No newline at end of file | ... | ... |
src/ui/vant-weapp/image/index.d.ts
0 → 100755
1 | export {}; |
src/ui/vant-weapp/image/index.js
0 → 100755
1 | import { addUnit, isDef } from '../common/utils'; | ||
2 | import { VantComponent } from '../common/component'; | ||
3 | import { button } from '../mixins/button'; | ||
4 | import { openType } from '../mixins/open-type'; | ||
5 | VantComponent({ | ||
6 | mixins: [button, openType], | ||
7 | classes: ['custom-class', 'loading-class', 'error-class', 'image-class'], | ||
8 | props: { | ||
9 | src: String, | ||
10 | width: String, | ||
11 | height: String, | ||
12 | fit: { | ||
13 | type: String, | ||
14 | value: 'fill' | ||
15 | }, | ||
16 | round: Boolean, | ||
17 | lazyLoad: Boolean, | ||
18 | showError: { | ||
19 | type: Boolean, | ||
20 | value: true | ||
21 | }, | ||
22 | showLoading: { | ||
23 | type: Boolean, | ||
24 | value: true | ||
25 | }, | ||
26 | showMenuByLongpress: Boolean, | ||
27 | // 受小程序slot限制所需要的属性 | ||
28 | useLoadingSlot: Boolean, | ||
29 | useErrorSlot: Boolean, | ||
30 | }, | ||
31 | data: { | ||
32 | fitWeapp: 'aspectFit', | ||
33 | FIT_MODE_MAP: { | ||
34 | contain: 'aspectFit', | ||
35 | cover: 'aspectFill', | ||
36 | fill: 'scaleToFill', | ||
37 | none: 'center', | ||
38 | // TODO: 这个没有原生的属性,需要后面实现,暂时先用contain; | ||
39 | 'scale-down': 'aspectFit' | ||
40 | }, | ||
41 | loading: true, | ||
42 | error: false | ||
43 | }, | ||
44 | watch: { | ||
45 | src() { | ||
46 | this.setData({ | ||
47 | loading: true, | ||
48 | error: false | ||
49 | }); | ||
50 | } | ||
51 | }, | ||
52 | mounted() { | ||
53 | this.init(); | ||
54 | }, | ||
55 | methods: { | ||
56 | init() { | ||
57 | const { FIT_MODE_MAP, fit } = this.data; | ||
58 | this.setData({ | ||
59 | mode: FIT_MODE_MAP[fit], | ||
60 | style: this.getStyle(), | ||
61 | }); | ||
62 | }, | ||
63 | getStyle() { | ||
64 | const { width, height } = this.data; | ||
65 | let style = ''; | ||
66 | if (isDef(width)) { | ||
67 | style += `width: ${addUnit(width)};`; | ||
68 | } | ||
69 | if (isDef(height)) { | ||
70 | style += `height: ${addUnit(height)};`; | ||
71 | } | ||
72 | return style; | ||
73 | }, | ||
74 | onLoad(event) { | ||
75 | this.setData({ | ||
76 | loading: false | ||
77 | }); | ||
78 | this.$emit('load', event.detail); | ||
79 | }, | ||
80 | onError(event) { | ||
81 | this.setData({ | ||
82 | loading: false, | ||
83 | error: true, | ||
84 | }); | ||
85 | this.$emit('error', event.detail); | ||
86 | }, | ||
87 | onClick(event) { | ||
88 | this.$emit('click', event.detail); | ||
89 | }, | ||
90 | } | ||
91 | }); |
src/ui/vant-weapp/image/index.json
0 → 100755
src/ui/vant-weapp/image/index.wxml
0 → 100755
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | |||
3 | <view | ||
4 | class="custom-class {{ utils.bem('image', { round })}}" | ||
5 | style="{{ style }}" | ||
6 | bind:tap="onClick" | ||
7 | > | ||
8 | <image | ||
9 | wx:if="{{ !error }}" | ||
10 | class="image-class van-image__img" | ||
11 | mode="{{ mode }}" | ||
12 | src="{{ src }}" | ||
13 | lazy-load="{{ lazyLoad }}" | ||
14 | show-menu-by-longpress="{{ showMenuByLongpress }}" | ||
15 | bind:load="onLoad" | ||
16 | bind:error="onError" | ||
17 | /> | ||
18 | |||
19 | <view | ||
20 | wx:if="{{ loading && showLoading }}" | ||
21 | class="loading-class van-image__loading" | ||
22 | > | ||
23 | <slot | ||
24 | wx:if="{{ useLoadingSlot }}" | ||
25 | name="loading" | ||
26 | /> | ||
27 | <van-icon | ||
28 | wx:else | ||
29 | name="photo-o" | ||
30 | size="22" | ||
31 | /> | ||
32 | </view> | ||
33 | <view | ||
34 | wx:if="{{ error && showError }}" | ||
35 | class="error-class van-image__error" | ||
36 | > | ||
37 | <slot | ||
38 | wx:if="{{ useErrorSlot }}" | ||
39 | name="error" | ||
40 | /> | ||
41 | <van-icon | ||
42 | wx:else | ||
43 | name="warning-o" | ||
44 | size="22" | ||
45 | /> | ||
46 | </view> | ||
47 | </view> |
src/ui/vant-weapp/image/index.wxss
0 → 100755
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:#f8f8f8;background-color:var(--image-placeholder-background-color,#f8f8f8)} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | |||
1 | <view | 3 | <view |
2 | wx:if="{{ info !== null }}" | 4 | wx:if="{{ info !== null && info !== '' || dot }}" |
3 | class="custom-class van-info" | 5 | class="custom-class van-info {{ utils.bem('info', { dot }) }}" |
4 | style="{{ customStyle }}" | 6 | style="{{ customStyle }}" |
5 | >{{ info }}</view> | 7 | >{{ dot ? '' : info }}</view> | ... | ... |
1 | @import '../common/index.wxss';.van-info{position:absolute;top:-8px;right:0;min-width:16px;padding:0 3px;font-family:PingFang SC,Helvetica Neue,Arial,sans-serif;font-size:12px;font-weight:500;line-height:14px;color:#fff;text-align:center;white-space:nowrap;background-color:#f44;border:1px solid #fff;border-radius:16px;-webkit-transform:translateX(50%);transform:translateX(50%);box-sizing:border-box;-webkit-transform-origin:100%;transform-origin:100%} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { addUnit } from '../common/utils'; | ||
2 | VantComponent({ | 3 | VantComponent({ |
3 | props: { | 4 | props: { |
4 | size: { | 5 | color: String, |
5 | type: String, | 6 | vertical: Boolean, |
6 | value: '30px' | ||
7 | }, | ||
8 | type: { | 7 | type: { |
9 | type: String, | 8 | type: String, |
10 | value: 'circular' | 9 | value: 'circular' |
11 | }, | 10 | }, |
12 | color: { | 11 | size: { |
13 | type: String, | 12 | type: String, |
14 | value: '#c9c9c9' | 13 | observer: 'setSizeWithUnit' |
14 | }, | ||
15 | textSize: { | ||
16 | type: String, | ||
17 | observer: 'setTextSizeWithUnit' | ||
18 | } | ||
19 | }, | ||
20 | methods: { | ||
21 | setSizeWithUnit(size) { | ||
22 | this.setData({ | ||
23 | sizeWithUnit: addUnit(size) | ||
24 | }); | ||
25 | }, | ||
26 | setTextSizeWithUnit(size) { | ||
27 | this.set({ | ||
28 | textSizeWithUnit: addUnit(size) | ||
29 | }); | ||
15 | } | 30 | } |
16 | } | 31 | } |
17 | }); | 32 | }); | ... | ... |
1 | <view | 1 | <view class="custom-class van-loading {{ vertical ? 'van-loading--vertical' : '' }}"> |
2 | class="van-loading custom-class" | ||
3 | style="width: {{ size }}; height: {{ size }}" | ||
4 | > | ||
5 | <view | 2 | <view |
6 | class="van-loading__spinner van-loading__spinner--{{ type }}" | 3 | class="van-loading__spinner van-loading__spinner--{{ type }}" |
7 | style="color: {{ color }};" | 4 | style="color: {{ color }}; width: {{ sizeWithUnit }}; height: {{ sizeWithUnit }}" |
8 | > | 5 | > |
9 | <view | 6 | <view |
10 | wx:if="{{ type === 'spinner' }}" | 7 | wx:if="{{ type === 'spinner' }}" |
... | @@ -13,4 +10,7 @@ | ... | @@ -13,4 +10,7 @@ |
13 | class="van-loading__dot" | 10 | class="van-loading__dot" |
14 | /> | 11 | /> |
15 | </view> | 12 | </view> |
13 | <view class="van-loading__text" style="font-size: {{ textSizeWithUnit }};"> | ||
14 | <slot /> | ||
15 | </view> | ||
16 | </view> | 16 | </view> | ... | ... |
1 | @import '../common/index.wxss';.van-loading{z-index:0;line-height:0;vertical-align:middle}.van-loading,.van-loading__spinner{position:relative;display:inline-block}.van-loading__spinner{z-index:-1;width:100%;height:100%;box-sizing:border-box;-webkit-animation:van-rotate .8s linear infinite;animation:van-rotate .8s linear infinite}.van-loading__spinner--spinner{-webkit-animation-timing-function:steps(12);animation-timing-function:steps(12)}.van-loading__spinner--circular{border-radius:100%;border:1px solid transparent;border-top-color:initial}.van-loading__dot{top:0;left:0;width:100%;height:100%;position:absolute}.van-loading__dot:before{width:2px;height:25%;content:" ";display:block;margin:0 auto;border-radius:40%;background-color:currentColor}.van-loading__dot:first-of-type{opacity:1;-webkit-transform:rotate(30deg);transform:rotate(30deg)}.van-loading__dot:nth-of-type(2){opacity:.9375;-webkit-transform:rotate(60deg);transform:rotate(60deg)}.van-loading__dot:nth-of-type(3){opacity:.875;-webkit-transform:rotate(90deg);transform:rotate(90deg)}.van-loading__dot:nth-of-type(4){opacity:.8125;-webkit-transform:rotate(120deg);transform:rotate(120deg)}.van-loading__dot:nth-of-type(5){opacity:.75;-webkit-transform:rotate(150deg);transform:rotate(150deg)}.van-loading__dot:nth-of-type(6){opacity:.6875;-webkit-transform:rotate(180deg);transform:rotate(180deg)}.van-loading__dot:nth-of-type(7){opacity:.625;-webkit-transform:rotate(210deg);transform:rotate(210deg)}.van-loading__dot:nth-of-type(8){opacity:.5625;-webkit-transform:rotate(240deg);transform:rotate(240deg)}.van-loading__dot:nth-of-type(9){opacity:.5;-webkit-transform:rotate(270deg);transform:rotate(270deg)}.van-loading__dot:nth-of-type(10){opacity:.4375;-webkit-transform:rotate(300deg);transform:rotate(300deg)}.van-loading__dot:nth-of-type(11){opacity:.375;-webkit-transform:rotate(330deg);transform:rotate(330deg)}.van-loading__dot:nth-of-type(12){opacity:.3125;-webkit-transform:rotate(1turn);transform:rotate(1turn)}@-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 | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
1 | export const basic = Behavior({ | 1 | export const basic = Behavior({ |
2 | methods: { | 2 | methods: { |
3 | $emit() { | 3 | $emit(...args) { |
4 | this.triggerEvent.apply(this, arguments); | 4 | this.triggerEvent(...args); |
5 | }, | 5 | }, |
6 | getRect(selector, all) { | 6 | getRect(selector, all) { |
7 | return new Promise(resolve => { | 7 | return new Promise(resolve => { | ... | ... |
1 | function setAsync(context, data) { | ||
2 | return new Promise(resolve => { | ||
3 | context.setData(data, resolve); | ||
4 | }); | ||
5 | } | ||
6 | ; | ||
7 | export const behavior = Behavior({ | 1 | export const behavior = Behavior({ |
8 | created() { | ||
9 | if (!this.$options) { | ||
10 | return; | ||
11 | } | ||
12 | const cache = {}; | ||
13 | const { computed } = this.$options(); | ||
14 | const keys = Object.keys(computed); | ||
15 | this.calcComputed = () => { | ||
16 | const needUpdate = {}; | ||
17 | keys.forEach(key => { | ||
18 | const value = computed[key].call(this); | ||
19 | if (cache[key] !== value) { | ||
20 | cache[key] = needUpdate[key] = value; | ||
21 | } | ||
22 | }); | ||
23 | return needUpdate; | ||
24 | }; | ||
25 | }, | ||
26 | attached() { | ||
27 | this.set(); | ||
28 | }, | ||
29 | methods: { | 2 | methods: { |
30 | // set data and set computed data | ||
31 | set(data, callback) { | 3 | set(data, callback) { |
32 | const stack = []; | 4 | return new Promise(resolve => { |
33 | if (data) { | 5 | this.setData(data, () => { |
34 | stack.push(setAsync(this, data)); | ||
35 | } | ||
36 | if (this.calcComputed) { | ||
37 | stack.push(setAsync(this, this.calcComputed())); | ||
38 | } | ||
39 | return Promise.all(stack).then(res => { | ||
40 | if (callback && typeof callback === 'function') { | 6 | if (callback && typeof callback === 'function') { |
41 | callback.call(this); | 7 | callback.call(this); |
42 | } | 8 | } |
43 | return res; | 9 | resolve(); |
10 | }); | ||
44 | }); | 11 | }); |
45 | } | 12 | } |
46 | } | 13 | } | ... | ... |
1 | import { behavior } from './behavior'; | 1 | import { behavior } from './behavior'; |
2 | import { observeProps } from './props'; | ||
3 | export function observe(vantOptions, options) { | 2 | export function observe(vantOptions, options) { |
4 | const { watch, computed } = vantOptions; | 3 | const { watch } = vantOptions; |
5 | options.behaviors.push(behavior); | 4 | options.behaviors.push(behavior); |
6 | if (watch) { | 5 | if (watch) { |
7 | const props = options.properties || {}; | 6 | const props = options.properties || {}; |
... | @@ -17,11 +16,4 @@ export function observe(vantOptions, options) { | ... | @@ -17,11 +16,4 @@ export function observe(vantOptions, options) { |
17 | }); | 16 | }); |
18 | options.properties = props; | 17 | options.properties = props; |
19 | } | 18 | } |
20 | if (computed) { | ||
21 | options.methods = options.methods || {}; | ||
22 | options.methods.$options = () => vantOptions; | ||
23 | if (options.properties) { | ||
24 | observeProps(options.properties); | ||
25 | } | ||
26 | } | ||
27 | } | 19 | } | ... | ... |
1 | export declare function observeProps(props: any): void; |
1 | export function observeProps(props) { | ||
2 | if (!props) { | ||
3 | return; | ||
4 | } | ||
5 | Object.keys(props).forEach(key => { | ||
6 | let prop = props[key]; | ||
7 | if (prop === null || !('type' in prop)) { | ||
8 | prop = { type: prop }; | ||
9 | } | ||
10 | let { observer } = prop; | ||
11 | prop.observer = function () { | ||
12 | if (observer) { | ||
13 | if (typeof observer === 'string') { | ||
14 | observer = this[observer]; | ||
15 | } | ||
16 | observer.apply(this, arguments); | ||
17 | } | ||
18 | this.set(); | ||
19 | }; | ||
20 | props[key] = prop; | ||
21 | }); | ||
22 | } |
1 | let cache = null; | ||
2 | function getSafeArea() { | ||
3 | return new Promise((resolve, reject) => { | ||
4 | if (cache != null) { | ||
5 | resolve(cache); | ||
6 | } | ||
7 | else { | ||
8 | wx.getSystemInfo({ | ||
9 | success: ({ model, screenHeight, statusBarHeight }) => { | ||
10 | const iphoneX = /iphone x/i.test(model); | ||
11 | const iphoneNew = /iPhone11/i.test(model) && screenHeight === 812; | ||
12 | cache = { | ||
13 | isIPhoneX: iphoneX || iphoneNew, | ||
14 | statusBarHeight | ||
15 | }; | ||
16 | resolve(cache); | ||
17 | }, | ||
18 | fail: reject | ||
19 | }); | ||
20 | } | ||
21 | }); | ||
22 | } | ||
23 | export const safeArea = ({ safeAreaInsetBottom = true, safeAreaInsetTop = false } = {}) => Behavior({ | ||
24 | properties: { | ||
25 | safeAreaInsetTop: { | ||
26 | type: Boolean, | ||
27 | value: safeAreaInsetTop | ||
28 | }, | ||
29 | safeAreaInsetBottom: { | ||
30 | type: Boolean, | ||
31 | value: safeAreaInsetBottom | ||
32 | } | ||
33 | }, | ||
34 | created() { | ||
35 | getSafeArea().then(({ isIPhoneX, statusBarHeight }) => { | ||
36 | this.set({ isIPhoneX, statusBarHeight }); | ||
37 | }); | ||
38 | } | ||
39 | }); |
... | @@ -10,85 +10,109 @@ export const transition = function (showDefaultValue) { | ... | @@ -10,85 +10,109 @@ export const transition = function (showDefaultValue) { |
10 | return Behavior({ | 10 | return Behavior({ |
11 | properties: { | 11 | properties: { |
12 | customStyle: String, | 12 | customStyle: String, |
13 | // @ts-ignore | ||
13 | show: { | 14 | show: { |
14 | type: Boolean, | 15 | type: Boolean, |
15 | value: showDefaultValue, | 16 | value: showDefaultValue, |
16 | observer: 'observeShow' | 17 | observer: 'observeShow' |
17 | }, | 18 | }, |
19 | // @ts-ignore | ||
18 | duration: { | 20 | duration: { |
19 | type: [Number, Object], | 21 | type: null, |
20 | value: 300, | 22 | value: 300, |
21 | observer: 'observeDuration' | 23 | observer: 'observeDuration' |
22 | }, | 24 | }, |
23 | name: { | 25 | name: { |
24 | type: String, | 26 | type: String, |
25 | value: 'fade', | 27 | value: 'fade' |
26 | observer: 'updateClasses' | ||
27 | } | 28 | } |
28 | }, | 29 | }, |
29 | data: { | 30 | data: { |
30 | type: '', | 31 | type: '', |
31 | inited: false, | 32 | inited: false, |
32 | display: false, | 33 | display: false |
33 | classNames: getClassNames('fade') | ||
34 | }, | 34 | }, |
35 | attached() { | 35 | attached() { |
36 | if (this.data.show) { | 36 | if (this.data.show) { |
37 | this.show(); | 37 | this.enter(); |
38 | } | 38 | } |
39 | }, | 39 | }, |
40 | methods: { | 40 | methods: { |
41 | observeShow(value) { | 41 | observeShow(value) { |
42 | if (value) { | 42 | value ? this.enter() : this.leave(); |
43 | this.show(); | ||
44 | } | ||
45 | else { | ||
46 | this.leave(); | ||
47 | } | ||
48 | }, | ||
49 | updateClasses(name) { | ||
50 | this.set({ | ||
51 | classNames: getClassNames(name) | ||
52 | }); | ||
53 | }, | 43 | }, |
54 | show() { | 44 | enter() { |
55 | const { classNames, duration } = this.data; | 45 | const { duration, name } = this.data; |
56 | const currentDuration = isObj(duration) ? duration.leave : duration; | 46 | const classNames = getClassNames(name); |
47 | const currentDuration = isObj(duration) ? duration.enter : duration; | ||
48 | this.status = 'enter'; | ||
49 | this.$emit('before-enter'); | ||
57 | Promise.resolve() | 50 | Promise.resolve() |
58 | .then(nextTick) | 51 | .then(nextTick) |
59 | .then(() => this.set({ | 52 | .then(() => { |
53 | this.checkStatus('enter'); | ||
54 | this.$emit('enter'); | ||
55 | this.setData({ | ||
60 | inited: true, | 56 | inited: true, |
61 | display: true, | 57 | display: true, |
62 | classes: classNames.enter, | 58 | classes: classNames.enter, |
63 | currentDuration | 59 | currentDuration |
64 | })) | 60 | }); |
61 | }) | ||
65 | .then(nextTick) | 62 | .then(nextTick) |
66 | .then(() => this.set({ | 63 | .then(() => { |
64 | this.checkStatus('enter'); | ||
65 | this.transitionEnded = false; | ||
66 | this.setData({ | ||
67 | classes: classNames['enter-to'] | 67 | classes: classNames['enter-to'] |
68 | })); | 68 | }); |
69 | }) | ||
70 | .catch(() => { }); | ||
69 | }, | 71 | }, |
70 | leave() { | 72 | leave() { |
71 | const { classNames, duration } = this.data; | 73 | if (!this.data.display) { |
72 | const currentDuration = isObj(duration) ? duration.leave : duration; | ||
73 | if (+currentDuration === 0) { | ||
74 | this.onTransitionEnd(); | ||
75 | return; | 74 | return; |
76 | } | 75 | } |
76 | const { duration, name } = this.data; | ||
77 | const classNames = getClassNames(name); | ||
78 | const currentDuration = isObj(duration) ? duration.leave : duration; | ||
79 | this.status = 'leave'; | ||
80 | this.$emit('before-leave'); | ||
77 | Promise.resolve() | 81 | Promise.resolve() |
78 | .then(nextTick) | 82 | .then(nextTick) |
79 | .then(() => this.set({ | 83 | .then(() => { |
84 | this.checkStatus('leave'); | ||
85 | this.$emit('leave'); | ||
86 | this.setData({ | ||
80 | classes: classNames.leave, | 87 | classes: classNames.leave, |
81 | currentDuration | 88 | currentDuration |
82 | })) | 89 | }); |
90 | }) | ||
83 | .then(nextTick) | 91 | .then(nextTick) |
84 | .then(() => this.set({ | 92 | .then(() => { |
93 | this.checkStatus('leave'); | ||
94 | this.transitionEnded = false; | ||
95 | setTimeout(() => this.onTransitionEnd(), currentDuration); | ||
96 | this.setData({ | ||
85 | classes: classNames['leave-to'] | 97 | classes: classNames['leave-to'] |
86 | })); | 98 | }); |
99 | }) | ||
100 | .catch(() => { }); | ||
101 | }, | ||
102 | checkStatus(status) { | ||
103 | if (status !== this.status) { | ||
104 | throw new Error(`incongruent status: ${status}`); | ||
105 | } | ||
87 | }, | 106 | }, |
88 | onTransitionEnd() { | 107 | onTransitionEnd() { |
89 | if (!this.data.show) { | 108 | if (this.transitionEnded) { |
90 | this.set({ display: false }); | 109 | return; |
91 | this.$emit('transitionEnd'); | 110 | } |
111 | this.transitionEnded = true; | ||
112 | this.$emit(`after-${this.status}`); | ||
113 | const { show, display } = this.data; | ||
114 | if (!show && display) { | ||
115 | this.setData({ display: false }); | ||
92 | } | 116 | } |
93 | } | 117 | } |
94 | } | 118 | } | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { safeArea } from '../mixins/safe-area'; | ||
3 | VantComponent({ | 2 | VantComponent({ |
4 | mixins: [safeArea({ safeAreaInsetTop: true })], | ||
5 | classes: ['title-class'], | 3 | classes: ['title-class'], |
6 | props: { | 4 | props: { |
7 | title: String, | 5 | title: String, |
... | @@ -15,8 +13,19 @@ VantComponent({ | ... | @@ -15,8 +13,19 @@ VantComponent({ |
15 | }, | 13 | }, |
16 | zIndex: { | 14 | zIndex: { |
17 | type: Number, | 15 | type: Number, |
18 | value: 120 | 16 | value: 1 |
19 | } | 17 | }, |
18 | safeAreaInsetTop: { | ||
19 | type: Boolean, | ||
20 | value: true | ||
21 | }, | ||
22 | }, | ||
23 | data: { | ||
24 | statusBarHeight: 0 | ||
25 | }, | ||
26 | created() { | ||
27 | const { statusBarHeight } = wx.getSystemInfoSync(); | ||
28 | this.setData({ statusBarHeight }); | ||
20 | }, | 29 | }, |
21 | methods: { | 30 | methods: { |
22 | onClickLeft() { | 31 | onClickLeft() { | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | 2 | ||
3 | <view | 3 | <view |
4 | class="{{ utils.bem('nav-bar', { fixed }) }} custom-class {{ border ? 'van-hairline--bottom' : '' }}" | 4 | class="{{ utils.bem('nav-bar', { fixed }) }} custom-class {{ border ? 'van-hairline--bottom' : '' }}" |
5 | style="z-index: {{ zIndex }}; {{ safeAreaInsetTop ? 'padding-top: ' + statusBarHeight + 'px;' : '' }}" | 5 | style="z-index: {{ zIndex }}; padding-top: {{ safeAreaInsetTop ? statusBarHeight : 0 }}px;" |
6 | > | 6 | > |
7 | <view class="van-nav-bar__left" bind:tap="onClickLeft"> | 7 | <view class="van-nav-bar__left" bind:tap="onClickLeft"> |
8 | <block wx:if="{{ leftArrow || leftText }}"> | 8 | <block wx:if="{{ leftArrow || leftText }}"> | ... | ... |
1 | @import '../common/index.wxss';.van-nav-bar{position:relative;height:44px;line-height:44px;text-align:center;background-color:#fff;-webkit-user-select:none;user-select:none}.van-nav-bar__text{display:inline-block;padding:0 15px;margin:0 -15px;color:#1989fa;vertical-align:middle}.van-nav-bar__text--hover{background-color:#f2f3f5}.van-nav-bar__arrow{color:#1989fa;vertical-align:middle}.van-nav-bar__arrow+.van-nav-bar__text{padding-left:25px;margin-left:-20px}.van-nav-bar--fixed{position:fixed;top:0;left:0;width:100%}.van-nav-bar__title{max-width:60%;margin:0 auto;font-size:16px;font-weight:500}.van-nav-bar__left,.van-nav-bar__right{position:absolute;bottom:0;font-size:14px}.van-nav-bar__left{left:15px}.van-nav-bar__right{right:15px} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
... | @@ -21,7 +21,7 @@ VantComponent({ | ... | @@ -21,7 +21,7 @@ VantComponent({ |
21 | }, | 21 | }, |
22 | delay: { | 22 | delay: { |
23 | type: Number, | 23 | type: Number, |
24 | value: 0 | 24 | value: 1 |
25 | }, | 25 | }, |
26 | speed: { | 26 | speed: { |
27 | type: Number, | 27 | type: Number, |
... | @@ -42,23 +42,18 @@ VantComponent({ | ... | @@ -42,23 +42,18 @@ VantComponent({ |
42 | backgroundColor: { | 42 | backgroundColor: { |
43 | type: String, | 43 | type: String, |
44 | value: BG_COLOR | 44 | value: BG_COLOR |
45 | } | 45 | }, |
46 | wrapable: Boolean | ||
46 | }, | 47 | }, |
47 | data: { | 48 | data: { |
48 | show: true, | 49 | show: true |
49 | hasRightIcon: false | ||
50 | }, | 50 | }, |
51 | watch: { | 51 | watch: { |
52 | text() { | 52 | text() { |
53 | this.set({}, this.init); | 53 | this.setData({}, this.init); |
54 | } | 54 | } |
55 | }, | 55 | }, |
56 | created() { | 56 | created() { |
57 | if (this.data.mode) { | ||
58 | this.set({ | ||
59 | hasRightIcon: true | ||
60 | }); | ||
61 | } | ||
62 | this.resetAnimation = wx.createAnimation({ | 57 | this.resetAnimation = wx.createAnimation({ |
63 | duration: 0, | 58 | duration: 0, |
64 | timingFunction: 'linear' | 59 | timingFunction: 'linear' |
... | @@ -71,7 +66,7 @@ VantComponent({ | ... | @@ -71,7 +66,7 @@ VantComponent({ |
71 | init() { | 66 | init() { |
72 | Promise.all([ | 67 | Promise.all([ |
73 | this.getRect('.van-notice-bar__content'), | 68 | this.getRect('.van-notice-bar__content'), |
74 | this.getRect('.van-notice-bar__content-wrap') | 69 | this.getRect('.van-notice-bar__wrap') |
75 | ]).then((rects) => { | 70 | ]).then((rects) => { |
76 | const [contentRect, wrapRect] = rects; | 71 | const [contentRect, wrapRect] = rects; |
77 | if (contentRect == null || | 72 | if (contentRect == null || |
... | @@ -98,14 +93,14 @@ VantComponent({ | ... | @@ -98,14 +93,14 @@ VantComponent({ |
98 | scroll() { | 93 | scroll() { |
99 | this.timer && clearTimeout(this.timer); | 94 | this.timer && clearTimeout(this.timer); |
100 | this.timer = null; | 95 | this.timer = null; |
101 | this.set({ | 96 | this.setData({ |
102 | animationData: this.resetAnimation | 97 | animationData: this.resetAnimation |
103 | .translateX(this.wrapWidth) | 98 | .translateX(this.wrapWidth) |
104 | .step() | 99 | .step() |
105 | .export() | 100 | .export() |
106 | }); | 101 | }); |
107 | setTimeout(() => { | 102 | setTimeout(() => { |
108 | this.set({ | 103 | this.setData({ |
109 | animationData: this.animation | 104 | animationData: this.animation |
110 | .translateX(-this.contentWidth) | 105 | .translateX(-this.contentWidth) |
111 | .step() | 106 | .step() |
... | @@ -119,7 +114,7 @@ VantComponent({ | ... | @@ -119,7 +114,7 @@ VantComponent({ |
119 | onClickIcon() { | 114 | onClickIcon() { |
120 | this.timer && clearTimeout(this.timer); | 115 | this.timer && clearTimeout(this.timer); |
121 | this.timer = null; | 116 | this.timer = null; |
122 | this.set({ show: false }); | 117 | this.setData({ show: false }); |
123 | }, | 118 | }, |
124 | onClick(event) { | 119 | onClick(event) { |
125 | this.$emit('click', event); | 120 | this.$emit('click', event); | ... | ... |
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | |||
1 | <view | 3 | <view |
2 | wx:if="{{ show }}" | 4 | wx:if="{{ show }}" |
3 | class="custom-class van-notice-bar {{ hasRightIcon ? 'van-notice-bar--within-icon' : '' }}" | 5 | class="custom-class {{ utils.bem('notice-bar', { withicon: mode, wrapable }) }}" |
4 | style="color: {{ color }}; background-color: {{ backgroundColor }};" | 6 | style="color: {{ color }}; background-color: {{ backgroundColor }};" |
5 | bind:tap="onClick" | 7 | bind:tap="onClick" |
6 | > | 8 | > |
7 | <view wx:if="{{ leftIcon }}" class="van-notice-bar__left-icon"> | 9 | <van-icon |
8 | <image src="{{ leftIcon }}" /> | 10 | wx:if="{{ leftIcon }}" |
9 | </view> | 11 | size="16px" |
10 | <view class="van-notice-bar__content-wrap"> | 12 | name="{{ leftIcon }}" |
11 | <view class="van-notice-bar__content {{ scrollable ? '' : 'van-ellipsis' }}" animation="{{ animationData }}"> | 13 | class="van-notice-bar__left-icon" |
14 | /> | ||
15 | <slot wx:else name="left-icon" /> | ||
16 | |||
17 | <view class="van-notice-bar__wrap"> | ||
18 | <view class="van-notice-bar__content {{ !scrollable && !wrapable ? 'van-ellipsis' : '' }}" animation="{{ animationData }}"> | ||
12 | {{ text }} | 19 | {{ text }} |
13 | </view> | 20 | </view> |
14 | </view> | 21 | </view> |
... | @@ -17,13 +24,14 @@ | ... | @@ -17,13 +24,14 @@ |
17 | wx:if="{{ mode === 'closeable' }}" | 24 | wx:if="{{ mode === 'closeable' }}" |
18 | class="van-notice-bar__right-icon" | 25 | class="van-notice-bar__right-icon" |
19 | name="cross" | 26 | name="cross" |
20 | bind:tap="onClickIcon" | 27 | catch:tap="onClickIcon" |
21 | /> | 28 | /> |
22 | <navigator | 29 | <navigator |
23 | wx:if="{{ mode === 'link' }}" | 30 | wx:elif="{{ mode === 'link' }}" |
24 | url="{{ url }}" | 31 | url="{{ url }}" |
25 | open-type="{{ openType }}" | 32 | open-type="{{ openType }}" |
26 | > | 33 | > |
27 | <van-icon class="van-notice-bar__right-icon" name="arrow" /> | 34 | <van-icon class="van-notice-bar__right-icon" name="arrow" /> |
28 | </navigator> | 35 | </navigator> |
36 | <slot wx:else name="right-icon" /> | ||
29 | </view> | 37 | </view> | ... | ... |
1 | @import '../common/index.wxss';.van-notice-bar{display:-webkit-flex;display:flex;height:40px;padding:0 15px;font-size:14px;line-height:24px;-webkit-align-items:center;align-items:center}.van-notice-bar--within-icon{position:relative;padding-right:40px}.van-notice-bar__left-icon{height:18px;min-width:20px;box-sizing:border-box}.van-notice-bar__left-icon>image{width:16px;height:16px}.van-notice-bar__right-icon{position:absolute;top:10px;right:15px;font-size:16px}.van-notice-bar__content-wrap{position:relative;height:24px;overflow:hidden;-webkit-flex:1;flex:1}.van-notice-bar__content{position:absolute;white-space:nowrap}.van-notice-bar__content.van-ellipsis{max-width:100%} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { RED } from '../common/color'; | 2 | import { WHITE } from '../common/color'; |
3 | import { safeArea } from '../mixins/safe-area'; | ||
4 | VantComponent({ | 3 | VantComponent({ |
5 | mixins: [safeArea()], | ||
6 | props: { | 4 | props: { |
7 | text: String, | 5 | message: String, |
8 | color: { | 6 | background: String, |
7 | type: { | ||
9 | type: String, | 8 | type: String, |
10 | value: '#fff' | 9 | value: 'danger' |
11 | }, | 10 | }, |
12 | backgroundColor: { | 11 | color: { |
13 | type: String, | 12 | type: String, |
14 | value: RED | 13 | value: WHITE |
15 | }, | 14 | }, |
16 | duration: { | 15 | duration: { |
17 | type: Number, | 16 | type: Number, |
18 | value: 3000 | 17 | value: 3000 |
18 | }, | ||
19 | zIndex: { | ||
20 | type: Number, | ||
21 | value: 110 | ||
22 | }, | ||
23 | safeAreaInsetTop: { | ||
24 | type: Boolean, | ||
25 | value: false | ||
19 | } | 26 | } |
20 | }, | 27 | }, |
21 | methods: { | 28 | methods: { |
22 | show() { | 29 | show() { |
23 | const { duration } = this.data; | 30 | const { duration, onOpened } = this.data; |
24 | clearTimeout(this.timer); | 31 | clearTimeout(this.timer); |
25 | this.set({ | 32 | this.setData({ |
26 | show: true | 33 | show: true |
27 | }); | 34 | }, onOpened); |
28 | if (duration > 0 && duration !== Infinity) { | 35 | if (duration > 0 && duration !== Infinity) { |
29 | this.timer = setTimeout(() => { | 36 | this.timer = setTimeout(() => { |
30 | this.hide(); | 37 | this.hide(); |
... | @@ -32,10 +39,17 @@ VantComponent({ | ... | @@ -32,10 +39,17 @@ VantComponent({ |
32 | } | 39 | } |
33 | }, | 40 | }, |
34 | hide() { | 41 | hide() { |
42 | const { onClose } = this.data; | ||
35 | clearTimeout(this.timer); | 43 | clearTimeout(this.timer); |
36 | this.set({ | 44 | this.setData({ |
37 | show: false | 45 | show: false |
38 | }); | 46 | }, onClose); |
47 | }, | ||
48 | onTap(event) { | ||
49 | const { onClick } = this.data; | ||
50 | if (onClick) { | ||
51 | onClick(event.detail); | ||
52 | } | ||
39 | } | 53 | } |
40 | } | 54 | } |
41 | }); | 55 | }); | ... | ... |
1 | <van-transition | 1 | <van-transition |
2 | name="slide-down" | 2 | name="slide-down" |
3 | show="{{ show }}" | 3 | show="{{ show }}" |
4 | custom-class="van-notify" | 4 | custom-class="van-notify__container" |
5 | custom-style="background-color:{{ backgroundColor }}; color: {{ color }};" | 5 | custom-style="z-index: {{ zIndex }};" |
6 | bind:tap="onTap" | ||
6 | > | 7 | > |
7 | <view wx:if="{{ safeAreaInsetTop }}" class="van-notify__safe-top" style="padding-top: {{ statusBarHeight }}px"></view> | 8 | <view |
8 | {{ text }} | 9 | class="van-notify van-notify--{{ type }}" |
10 | style="background:{{ background }};color:{{ color }};" | ||
11 | > | ||
12 | <view wx:if="{{ safeAreaInsetTop }}" class="van-notify__safe-area"></view> | ||
13 | <text>{{ message }}</text> | ||
14 | </view> | ||
9 | </van-transition> | 15 | </van-transition> | ... | ... |
1 | @import '../common/index.wxss';.van-notify{position:fixed;top:0;z-index:110;width:100%;padding:6px 15px;font-size:14px;line-height:20px;text-align:center;word-break:break-all;box-sizing:border-box}.van-notify__safe-top{height:44px} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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__safe-area{height:constant(safe-area-inset-top);height:env(safe-area-inset-top)}.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 | ... | \ No newline at end of file | ... | ... |
1 | declare type NotifyOptions = { | 1 | interface NotifyOptions { |
2 | text: string; | 2 | type?: 'primary' | 'success' | 'danger' | 'warning'; |
3 | color?: string; | 3 | color?: string; |
4 | backgroundColor?: string; | 4 | zIndex?: number; |
5 | message: string; | ||
6 | context?: any; | ||
5 | duration?: number; | 7 | duration?: number; |
6 | selector?: string; | 8 | selector?: string; |
7 | context?: any; | 9 | background?: string; |
8 | safeAreaInsetTop?: boolean; | 10 | safeAreaInsetTop?: boolean; |
9 | }; | 11 | onClick?: () => void; |
12 | onOpened?: () => void; | ||
13 | onClose?: () => void; | ||
14 | } | ||
10 | export default function Notify(options: NotifyOptions | string): void; | 15 | export default function Notify(options: NotifyOptions | string): void; |
11 | export {}; | 16 | export {}; | ... | ... |
1 | import { isObj } from '../common/utils'; | 1 | import { WHITE } from '../common/color'; |
2 | const defaultOptions = { | 2 | const defaultOptions = { |
3 | selector: '#van-notify', | 3 | selector: '#van-notify', |
4 | duration: 3000 | 4 | type: 'danger', |
5 | message: '', | ||
6 | background: '', | ||
7 | duration: 3000, | ||
8 | zIndex: 110, | ||
9 | color: WHITE, | ||
10 | safeAreaInsetTop: false, | ||
11 | onClick: () => { }, | ||
12 | onOpened: () => { }, | ||
13 | onClose: () => { } | ||
5 | }; | 14 | }; |
6 | function parseOptions(text) { | 15 | function parseOptions(message) { |
7 | return isObj(text) ? text : { text }; | 16 | return typeof message === 'string' ? { message } : message; |
8 | } | 17 | } |
9 | function getContext() { | 18 | function getContext() { |
10 | const pages = getCurrentPages(); | 19 | const pages = getCurrentPages(); |
... | @@ -14,6 +23,7 @@ export default function Notify(options) { | ... | @@ -14,6 +23,7 @@ export default function Notify(options) { |
14 | options = Object.assign({}, defaultOptions, parseOptions(options)); | 23 | options = Object.assign({}, defaultOptions, parseOptions(options)); |
15 | const context = options.context || getContext(); | 24 | const context = options.context || getContext(); |
16 | const notify = context.selectComponent(options.selector); | 25 | const notify = context.selectComponent(options.selector); |
26 | delete options.context; | ||
17 | delete options.selector; | 27 | delete options.selector; |
18 | if (notify) { | 28 | if (notify) { |
19 | notify.set(options); | 29 | notify.set(options); | ... | ... |
... | @@ -2,10 +2,9 @@ import { VantComponent } from '../common/component'; | ... | @@ -2,10 +2,9 @@ import { VantComponent } from '../common/component'; |
2 | VantComponent({ | 2 | VantComponent({ |
3 | props: { | 3 | props: { |
4 | show: Boolean, | 4 | show: Boolean, |
5 | mask: Boolean, | ||
6 | customStyle: String, | 5 | customStyle: String, |
7 | duration: { | 6 | duration: { |
8 | type: [Number, Object], | 7 | type: null, |
9 | value: 300 | 8 | value: 300 |
10 | }, | 9 | }, |
11 | zIndex: { | 10 | zIndex: { | ... | ... |
1 | <van-transition | 1 | <van-transition |
2 | show="{{ show }}" | 2 | show="{{ show }}" |
3 | custom-class="van-overlay" | 3 | custom-class="van-overlay" |
4 | custom-style="z-index: {{ zIndex }}; {{ mask ? 'background-color: rgba(0, 0, 0, .7);' : '' }}; {{ customStyle }}" | 4 | custom-style="z-index: {{ zIndex }}; {{ customStyle }}" |
5 | duration="{{ duration }}" | 5 | duration="{{ duration }}" |
6 | bind:tap="onClick" | 6 | bind:tap="onClick" |
7 | catch:touchmove="noop" | 7 | catch:touchmove="noop" | ... | ... |
1 | @import '../common/index.wxss';.van-overlay{position:fixed;top:0;right:0;bottom:0;left:0} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
1 | @import '../common/index.wxss';.van-panel{background:#fff}.van-panel__header-value{color:#f44}.van-panel__footer{padding:10px 15px} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
... | @@ -34,31 +34,17 @@ VantComponent({ | ... | @@ -34,31 +34,17 @@ VantComponent({ |
34 | this.setIndex(defaultIndex); | 34 | this.setIndex(defaultIndex); |
35 | }); | 35 | }); |
36 | }, | 36 | }, |
37 | computed: { | ||
38 | count() { | ||
39 | return this.data.options.length; | ||
40 | }, | ||
41 | baseOffset() { | ||
42 | const { data } = this; | ||
43 | return (data.itemHeight * (data.visibleItemCount - 1)) / 2; | ||
44 | }, | ||
45 | wrapperStyle() { | ||
46 | const { data } = this; | ||
47 | return [ | ||
48 | `transition: ${data.duration}ms`, | ||
49 | `transform: translate3d(0, ${data.offset + data.baseOffset}px, 0)`, | ||
50 | `line-height: ${data.itemHeight}px` | ||
51 | ].join('; '); | ||
52 | } | ||
53 | }, | ||
54 | watch: { | 37 | watch: { |
55 | defaultIndex(value) { | 38 | defaultIndex(value) { |
56 | this.setIndex(value); | 39 | this.setIndex(value); |
57 | } | 40 | } |
58 | }, | 41 | }, |
59 | methods: { | 42 | methods: { |
43 | getCount() { | ||
44 | return this.data.options.length; | ||
45 | }, | ||
60 | onTouchStart(event) { | 46 | onTouchStart(event) { |
61 | this.set({ | 47 | this.setData({ |
62 | startY: event.touches[0].clientY, | 48 | startY: event.touches[0].clientY, |
63 | startOffset: this.data.offset, | 49 | startOffset: this.data.offset, |
64 | duration: 0 | 50 | duration: 0 |
... | @@ -67,17 +53,15 @@ VantComponent({ | ... | @@ -67,17 +53,15 @@ VantComponent({ |
67 | onTouchMove(event) { | 53 | onTouchMove(event) { |
68 | const { data } = this; | 54 | const { data } = this; |
69 | const deltaY = event.touches[0].clientY - data.startY; | 55 | const deltaY = event.touches[0].clientY - data.startY; |
70 | this.set({ | 56 | this.setData({ |
71 | offset: range(data.startOffset + deltaY, -(data.count * data.itemHeight), data.itemHeight) | 57 | offset: range(data.startOffset + deltaY, -(this.getCount() * data.itemHeight), data.itemHeight) |
72 | }); | 58 | }); |
73 | }, | 59 | }, |
74 | onTouchEnd() { | 60 | onTouchEnd() { |
75 | const { data } = this; | 61 | const { data } = this; |
76 | if (data.offset !== data.startOffset) { | 62 | if (data.offset !== data.startOffset) { |
77 | this.set({ | 63 | this.setData({ duration: DEFAULT_DURATION }); |
78 | duration: DEFAULT_DURATION | 64 | const index = range(Math.round(-data.offset / data.itemHeight), 0, this.getCount() - 1); |
79 | }); | ||
80 | const index = range(Math.round(-data.offset / data.itemHeight), 0, data.count - 1); | ||
81 | this.setIndex(index, true); | 65 | this.setIndex(index, true); |
82 | } | 66 | } |
83 | }, | 67 | }, |
... | @@ -87,8 +71,9 @@ VantComponent({ | ... | @@ -87,8 +71,9 @@ VantComponent({ |
87 | }, | 71 | }, |
88 | adjustIndex(index) { | 72 | adjustIndex(index) { |
89 | const { data } = this; | 73 | const { data } = this; |
90 | index = range(index, 0, data.count); | 74 | const count = this.getCount(); |
91 | for (let i = index; i < data.count; i++) { | 75 | index = range(index, 0, count); |
76 | for (let i = index; i < count; i++) { | ||
92 | if (!this.isDisabled(data.options[i])) | 77 | if (!this.isDisabled(data.options[i])) |
93 | return i; | 78 | return i; |
94 | } | 79 | } |
... | @@ -115,9 +100,7 @@ VantComponent({ | ... | @@ -115,9 +100,7 @@ VantComponent({ |
115 | userAction && this.$emit('change', index); | 100 | userAction && this.$emit('change', index); |
116 | }); | 101 | }); |
117 | } | 102 | } |
118 | else { | ||
119 | return this.set({ offset }); | 103 | return this.set({ offset }); |
120 | } | ||
121 | }, | 104 | }, |
122 | setValue(value) { | 105 | setValue(value) { |
123 | const { options } = this.data; | 106 | const { options } = this.data; | ... | ... |
1 | <wxs src="./index.wxs" module="getOptionText" /> | ||
2 | |||
1 | <view | 3 | <view |
2 | class="van-picker-column custom-class" | 4 | class="van-picker-column custom-class" |
3 | style="height: {{ itemHeight * visibleItemCount }}px" | 5 | style="height: {{ itemHeight * visibleItemCount }}px" |
... | @@ -6,7 +8,7 @@ | ... | @@ -6,7 +8,7 @@ |
6 | bind:touchend="onTouchEnd" | 8 | bind:touchend="onTouchEnd" |
7 | bind:touchcancel="onTouchEnd" | 9 | bind:touchcancel="onTouchEnd" |
8 | > | 10 | > |
9 | <view style="{{ wrapperStyle }}"> | 11 | <view style="transition: transform {{ duration }}ms; line-height: {{ itemHeight }}px; transform: translate3d(0, {{ offset + (itemHeight * (visibleItemCount - 1)) / 2 }}px, 0)"> |
10 | <view | 12 | <view |
11 | wx:for="{{ options }}" | 13 | wx:for="{{ options }}" |
12 | wx:for-item="option" | 14 | wx:for-item="option" |
... | @@ -18,14 +20,3 @@ | ... | @@ -18,14 +20,3 @@ |
18 | >{{ getOptionText(option, valueKey) }}</view> | 20 | >{{ getOptionText(option, valueKey) }}</view> |
19 | </view> | 21 | </view> |
20 | </view> | 22 | </view> |
21 | |||
22 | <wxs module="getOptionText"> | ||
23 | function isObj(x) { | ||
24 | var type = typeof x; | ||
25 | return x !== null && (type === 'object' || type === 'function'); | ||
26 | } | ||
27 | |||
28 | module.exports = function (option, valueKey) { | ||
29 | return isObj(option) && option[valueKey] ? option[valueKey] : option; | ||
30 | } | ||
31 | </wxs> | ... | ... |
src/ui/vant-weapp/picker-column/index.wxs
0 → 100755
1 | @import '../common/index.wxss';.van-picker-column{overflow:hidden;font-size:16px;text-align:center}.van-picker-column__item{padding:0 5px;color:#999}.van-picker-column__item--selected{font-weight:500;color:#333}.van-picker-column__item--disabled{opacity:.3} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | function isSimple(columns) { | 2 | import { pickerProps } from './shared'; |
3 | return columns.length && !columns[0].values; | ||
4 | } | ||
5 | VantComponent({ | 3 | VantComponent({ |
6 | classes: ['active-class', 'toolbar-class', 'column-class'], | 4 | classes: ['active-class', 'toolbar-class', 'column-class'], |
7 | props: { | 5 | props: Object.assign(Object.assign({}, pickerProps), { valueKey: { |
8 | title: String, | ||
9 | loading: Boolean, | ||
10 | showToolbar: Boolean, | ||
11 | confirmButtonText: String, | ||
12 | cancelButtonText: String, | ||
13 | visibleItemCount: { | ||
14 | type: Number, | ||
15 | value: 5 | ||
16 | }, | ||
17 | valueKey: { | ||
18 | type: String, | 6 | type: String, |
19 | value: 'text' | 7 | value: 'text' |
20 | }, | 8 | }, toolbarPosition: { |
21 | itemHeight: { | 9 | type: String, |
10 | value: 'top' | ||
11 | }, defaultIndex: { | ||
22 | type: Number, | 12 | type: Number, |
23 | value: 44 | 13 | value: 0 |
24 | }, | 14 | }, columns: { |
25 | columns: { | ||
26 | type: Array, | 15 | type: Array, |
27 | value: [], | 16 | value: [], |
28 | observer(columns = []) { | 17 | observer(columns = []) { |
29 | this.simple = isSimple(columns); | 18 | this.simple = columns.length && !columns[0].values; |
30 | this.children = this.selectAllComponents('.van-picker__column'); | 19 | this.children = this.selectAllComponents('.van-picker__column'); |
31 | if (Array.isArray(this.children) && this.children.length) { | 20 | if (Array.isArray(this.children) && this.children.length) { |
32 | this.setColumns().catch(() => { }); | 21 | this.setColumns().catch(() => { }); |
33 | } | 22 | } |
34 | } | 23 | } |
35 | } | 24 | } }), |
36 | }, | ||
37 | beforeCreate() { | 25 | beforeCreate() { |
38 | this.children = []; | 26 | this.children = []; |
39 | }, | 27 | }, |
... | @@ -89,7 +77,7 @@ VantComponent({ | ... | @@ -89,7 +77,7 @@ VantComponent({ |
89 | setColumnValue(index, value) { | 77 | setColumnValue(index, value) { |
90 | const column = this.getColumn(index); | 78 | const column = this.getColumn(index); |
91 | if (column == null) { | 79 | if (column == null) { |
92 | return Promise.reject('setColumnValue: 对应列不存在'); | 80 | return Promise.reject(new Error('setColumnValue: 对应列不存在')); |
93 | } | 81 | } |
94 | return column.setValue(value); | 82 | return column.setValue(value); |
95 | }, | 83 | }, |
... | @@ -101,7 +89,7 @@ VantComponent({ | ... | @@ -101,7 +89,7 @@ VantComponent({ |
101 | setColumnIndex(columnIndex, optionIndex) { | 89 | setColumnIndex(columnIndex, optionIndex) { |
102 | const column = this.getColumn(columnIndex); | 90 | const column = this.getColumn(columnIndex); |
103 | if (column == null) { | 91 | if (column == null) { |
104 | return Promise.reject('setColumnIndex: 对应列不存在'); | 92 | return Promise.reject(new Error('setColumnIndex: 对应列不存在')); |
105 | } | 93 | } |
106 | return column.setIndex(optionIndex); | 94 | return column.setIndex(optionIndex); |
107 | }, | 95 | }, |
... | @@ -113,7 +101,7 @@ VantComponent({ | ... | @@ -113,7 +101,7 @@ VantComponent({ |
113 | setColumnValues(index, options, needReset = true) { | 101 | setColumnValues(index, options, needReset = true) { |
114 | const column = this.children[index]; | 102 | const column = this.children[index]; |
115 | if (column == null) { | 103 | if (column == null) { |
116 | return Promise.reject('setColumnValues: 对应列不存在'); | 104 | return Promise.reject(new Error('setColumnValues: 对应列不存在')); |
117 | } | 105 | } |
118 | const isSame = JSON.stringify(column.data.options) === JSON.stringify(options); | 106 | const isSame = JSON.stringify(column.data.options) === JSON.stringify(options); |
119 | if (isSame) { | 107 | if (isSame) { | ... | ... |
1 | <view class="van-picker custom-class"> | 1 | <template name="toolbar"> |
2 | <view | 2 | <view |
3 | wx:if="{{ showToolbar }}" | 3 | wx:if="{{ showToolbar }}" |
4 | class="van-picker__toolbar van-hairline--top-bottom toolbar-class" | 4 | class="van-picker__toolbar van-hairline--top-bottom toolbar-class" |
... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
10 | data-type="cancel" | 10 | data-type="cancel" |
11 | bindtap="emit" | 11 | bindtap="emit" |
12 | > | 12 | > |
13 | {{ cancelButtonText || '取消' }} | 13 | {{ cancelButtonText }} |
14 | </view> | 14 | </view> |
15 | <view wx:if="{{ title }}" class="van-picker__title van-ellipsis">{{ title }}</view> | 15 | <view wx:if="{{ title }}" class="van-picker__title van-ellipsis">{{ title }}</view> |
16 | <view | 16 | <view |
... | @@ -20,9 +20,13 @@ | ... | @@ -20,9 +20,13 @@ |
20 | data-type="confirm" | 20 | data-type="confirm" |
21 | bindtap="emit" | 21 | bindtap="emit" |
22 | > | 22 | > |
23 | {{ confirmButtonText || '确认' }} | 23 | {{ confirmButtonText }} |
24 | </view> | 24 | </view> |
25 | </view> | 25 | </view> |
26 | </template> | ||
27 | |||
28 | <view class="van-picker custom-class"> | ||
29 | <template is="toolbar" wx:if="{{ toolbarPosition === 'top' }}" data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template> | ||
26 | <view wx:if="{{ loading }}" class="van-picker__loading"> | 30 | <view wx:if="{{ loading }}" class="van-picker__loading"> |
27 | <loading color="#1989fa"/> | 31 | <loading color="#1989fa"/> |
28 | </view> | 32 | </view> |
... | @@ -39,7 +43,7 @@ | ... | @@ -39,7 +43,7 @@ |
39 | custom-class="column-class" | 43 | custom-class="column-class" |
40 | value-key="{{ valueKey }}" | 44 | value-key="{{ valueKey }}" |
41 | initial-options="{{ isSimple(columns) ? item : item.values }}" | 45 | initial-options="{{ isSimple(columns) ? item : item.values }}" |
42 | default-index="{{ item.defaultIndex }}" | 46 | default-index="{{ item.defaultIndex || defaultIndex }}" |
43 | item-height="{{ itemHeight }}" | 47 | item-height="{{ itemHeight }}" |
44 | visible-item-count="{{ visibleItemCount }}" | 48 | visible-item-count="{{ visibleItemCount }}" |
45 | active-class="active-class" | 49 | active-class="active-class" |
... | @@ -50,6 +54,7 @@ | ... | @@ -50,6 +54,7 @@ |
50 | style="height: {{ itemHeight }}px" | 54 | style="height: {{ itemHeight }}px" |
51 | /> | 55 | /> |
52 | </view> | 56 | </view> |
57 | <template is="toolbar" wx:if="{{ toolbarPosition === 'bottom' }}" data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template> | ||
53 | </view> | 58 | </view> |
54 | 59 | ||
55 | <wxs module="isSimple"> | 60 | <wxs module="isSimple"> | ... | ... |
1 | @import '../common/index.wxss';.van-picker{position:relative;overflow:hidden;-webkit-text-size-adjust:100%;background-color:#fff;-webkit-user-select:none;user-select:none}.van-picker__toolbar{display:-webkit-flex;display:flex;height:44px;line-height:44px;-webkit-justify-content:space-between;justify-content:space-between}.van-picker__cancel,.van-picker__confirm{padding:0 15px;font-size:14px;color:#1989fa}.van-picker__cancel--hover,.van-picker__confirm--hover{background-color:#f2f3f5}.van-picker__title{max-width:50%;font-size:16px;font-weight:500;text-align:center}.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;background-color:hsla(0,0%,100%,.9);-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-picker__frame,.van-picker__loading .van-loading{position:absolute;top:50%;left:0;z-index:1;width:100%;pointer-events:none;-webkit-transform:translateY(-50%);transform:translateY(-50%)} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
src/ui/vant-weapp/picker/shared.d.ts
0 → 100755
1 | export declare const pickerProps: { | ||
2 | title: StringConstructor; | ||
3 | loading: BooleanConstructor; | ||
4 | showToolbar: BooleanConstructor; | ||
5 | cancelButtonText: { | ||
6 | type: StringConstructor; | ||
7 | value: string; | ||
8 | }; | ||
9 | confirmButtonText: { | ||
10 | type: StringConstructor; | ||
11 | value: string; | ||
12 | }; | ||
13 | visibleItemCount: { | ||
14 | type: NumberConstructor; | ||
15 | value: number; | ||
16 | }; | ||
17 | itemHeight: { | ||
18 | type: NumberConstructor; | ||
19 | value: number; | ||
20 | }; | ||
21 | }; |
src/ui/vant-weapp/picker/shared.js
0 → 100755
1 | export const pickerProps = { | ||
2 | title: String, | ||
3 | loading: Boolean, | ||
4 | showToolbar: Boolean, | ||
5 | cancelButtonText: { | ||
6 | type: String, | ||
7 | value: '取消' | ||
8 | }, | ||
9 | confirmButtonText: { | ||
10 | type: String, | ||
11 | value: '确认' | ||
12 | }, | ||
13 | visibleItemCount: { | ||
14 | type: Number, | ||
15 | value: 5 | ||
16 | }, | ||
17 | itemHeight: { | ||
18 | type: Number, | ||
19 | value: 44 | ||
20 | } | ||
21 | }; |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { transition } from '../mixins/transition'; | 2 | import { transition } from '../mixins/transition'; |
3 | import { safeArea } from '../mixins/safe-area'; | ||
4 | VantComponent({ | 3 | VantComponent({ |
5 | classes: [ | 4 | classes: [ |
6 | 'enter-class', | 5 | 'enter-class', |
... | @@ -10,14 +9,16 @@ VantComponent({ | ... | @@ -10,14 +9,16 @@ VantComponent({ |
10 | 'leave-active-class', | 9 | 'leave-active-class', |
11 | 'leave-to-class' | 10 | 'leave-to-class' |
12 | ], | 11 | ], |
13 | mixins: [transition(false), safeArea()], | 12 | mixins: [transition(false)], |
14 | props: { | 13 | props: { |
14 | round: Boolean, | ||
15 | closeable: Boolean, | ||
16 | customStyle: String, | ||
17 | overlayStyle: String, | ||
15 | transition: { | 18 | transition: { |
16 | type: String, | 19 | type: String, |
17 | observer: 'observeClass' | 20 | observer: 'observeClass' |
18 | }, | 21 | }, |
19 | customStyle: String, | ||
20 | overlayStyle: String, | ||
21 | zIndex: { | 22 | zIndex: { |
22 | type: Number, | 23 | type: Number, |
23 | value: 100 | 24 | value: 100 |
... | @@ -26,6 +27,14 @@ VantComponent({ | ... | @@ -26,6 +27,14 @@ VantComponent({ |
26 | type: Boolean, | 27 | type: Boolean, |
27 | value: true | 28 | value: true |
28 | }, | 29 | }, |
30 | closeIcon: { | ||
31 | type: String, | ||
32 | value: 'cross' | ||
33 | }, | ||
34 | closeIconPosition: { | ||
35 | type: String, | ||
36 | value: 'top-right' | ||
37 | }, | ||
29 | closeOnClickOverlay: { | 38 | closeOnClickOverlay: { |
30 | type: Boolean, | 39 | type: Boolean, |
31 | value: true | 40 | value: true |
... | @@ -34,12 +43,23 @@ VantComponent({ | ... | @@ -34,12 +43,23 @@ VantComponent({ |
34 | type: String, | 43 | type: String, |
35 | value: 'center', | 44 | value: 'center', |
36 | observer: 'observeClass' | 45 | observer: 'observeClass' |
46 | }, | ||
47 | safeAreaInsetBottom: { | ||
48 | type: Boolean, | ||
49 | value: true | ||
50 | }, | ||
51 | safeAreaInsetTop: { | ||
52 | type: Boolean, | ||
53 | value: false | ||
37 | } | 54 | } |
38 | }, | 55 | }, |
39 | created() { | 56 | created() { |
40 | this.observeClass(); | 57 | this.observeClass(); |
41 | }, | 58 | }, |
42 | methods: { | 59 | methods: { |
60 | onClickCloseIcon() { | ||
61 | this.$emit('close'); | ||
62 | }, | ||
43 | onClickOverlay() { | 63 | onClickOverlay() { |
44 | this.$emit('click-overlay'); | 64 | this.$emit('click-overlay'); |
45 | if (this.data.closeOnClickOverlay) { | 65 | if (this.data.closeOnClickOverlay) { |
... | @@ -48,10 +68,13 @@ VantComponent({ | ... | @@ -48,10 +68,13 @@ VantComponent({ |
48 | }, | 68 | }, |
49 | observeClass() { | 69 | observeClass() { |
50 | const { transition, position } = this.data; | 70 | const { transition, position } = this.data; |
51 | this.updateClasses(transition || position); | 71 | const updateData = { |
72 | name: transition || position | ||
73 | }; | ||
52 | if (transition === 'none') { | 74 | if (transition === 'none') { |
53 | this.set({ duration: 0 }); | 75 | updateData.duration = 0; |
54 | } | 76 | } |
77 | this.setData(updateData); | ||
55 | } | 78 | } |
56 | } | 79 | } |
57 | }); | 80 | }); | ... | ... |
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | 1 | <wxs src="../wxs/utils.wxs" module="utils" /> |
2 | 2 | ||
3 | <van-overlay | 3 | <van-overlay |
4 | wx:if="{{ inited && overlay }}" | 4 | wx:if="{{ overlay }}" |
5 | mask | ||
6 | show="{{ show }}" | 5 | show="{{ show }}" |
7 | z-index="{{ zIndex }}" | 6 | z-index="{{ zIndex }}" |
8 | custom-style="{{ overlayStyle }}" | 7 | custom-style="{{ overlayStyle }}" |
... | @@ -11,10 +10,15 @@ | ... | @@ -11,10 +10,15 @@ |
11 | /> | 10 | /> |
12 | <view | 11 | <view |
13 | wx:if="{{ inited }}" | 12 | wx:if="{{ inited }}" |
14 | class="custom-class {{ classes }} {{ utils.bem('popup', [position, { safe: isIPhoneX && safeAreaInsetBottom }]) }}" | 13 | class="custom-class {{ classes }} {{ utils.bem('popup', [position, { round, safe: safeAreaInsetBottom, safeTop: safeAreaInsetTop }]) }}" |
15 | style="z-index: {{ zIndex }}; -webkit-transition-duration:{{ currentDuration }}ms; transition-duration:{{ currentDuration }}ms; {{ display ? '' : 'display: none;' }} {{ customStyle }}" | 14 | style="z-index: {{ zIndex }}; -webkit-transition-duration:{{ currentDuration }}ms; transition-duration:{{ currentDuration }}ms; {{ display ? '' : 'display: none;' }};{{ customStyle }}" |
16 | bind:transitionend="onTransitionEnd" | 15 | bind:transitionend="onTransitionEnd" |
17 | > | 16 | > |
18 | <view wx:if="{{ safeAreaInsetTop }}" class="van-popup__safe-top" style="padding-top: {{ statusBarHeight }}px;"></view> | ||
19 | <slot /> | 17 | <slot /> |
18 | <van-icon | ||
19 | wx:if="{{ closeable }}" | ||
20 | name="{{ closeIcon }}" | ||
21 | class="van-popup__close-icon van-popup__close-icon--{{ closeIconPosition }}" | ||
22 | bind:tap="onClickCloseIcon" | ||
23 | /> | ||
20 | </view> | 24 | </view> | ... | ... |
1 | @import '../common/index.wxss';.van-popup{position:fixed;top:50%;left:50%;max-height:100%;overflow-y:auto;background-color:#fff;box-sizing:border-box;-webkit-animation:ease both;animation:ease both;-webkit-overflow-scrolling:touch;transition-timing-function:ease}.van-popup--center{-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0)}.van-popup--top{top:0;right:auto;bottom:auto;left:50%;width:100%;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.van-popup--right{top:50%;right:0;bottom:auto;left:auto;-webkit-transform:translate3d(0,-50%,0);transform:translate3d(0,-50%,0)}.van-popup--bottom{top:auto;right:auto;bottom:0;left:50%;width:100%;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.van-popup--left{top:50%;right:auto;bottom:auto;left:0;-webkit-transform:translate3d(0,-50%,0);transform:translate3d(0,-50%,0)}.van-popup--bottom.van-popup--safe{padding-bottom:34px}.van-popup--left .van-popup__safe-top,.van-popup--right .van-popup__safe-top,.van-popup--top .van-popup__safe-top{height:44px}.van-popup--bottom .van-popup__safe-top,.van-popup--center .van-popup__safe-top{padding-top:0!important}.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{opacity:0;-webkit-transform:translate3d(-50%,-50%,0) scale(.7);transform:translate3d(-50%,-50%,0) scale(.7)}.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(-50%,100%,0);transform:translate3d(-50%,100%,0)}.van-top-enter,.van-top-leave-to{-webkit-transform:translate3d(-50%,-100%,0);transform:translate3d(-50%,-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 | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { BLUE } from '../common/color'; | 2 | import { BLUE } from '../common/color'; |
3 | import { addUnit } from '../common/utils'; | ||
3 | VantComponent({ | 4 | VantComponent({ |
4 | props: { | 5 | props: { |
5 | inactive: Boolean, | 6 | inactive: Boolean, |
6 | percentage: Number, | 7 | percentage: Number, |
7 | pivotText: String, | 8 | pivotText: String, |
8 | pivotColor: String, | 9 | pivotColor: String, |
10 | trackColor: String, | ||
9 | showPivot: { | 11 | showPivot: { |
10 | type: Boolean, | 12 | type: Boolean, |
11 | value: true | 13 | value: true |
... | @@ -17,48 +19,19 @@ VantComponent({ | ... | @@ -17,48 +19,19 @@ VantComponent({ |
17 | textColor: { | 19 | textColor: { |
18 | type: String, | 20 | type: String, |
19 | value: '#fff' | 21 | value: '#fff' |
20 | } | ||
21 | }, | ||
22 | data: { | ||
23 | pivotWidth: 0, | ||
24 | progressWidth: 0 | ||
25 | }, | ||
26 | watch: { | ||
27 | pivotText: 'getWidth', | ||
28 | showPivot: 'getWidth' | ||
29 | }, | ||
30 | computed: { | ||
31 | portionStyle() { | ||
32 | const width = (this.data.progressWidth - this.data.pivotWidth) * this.data.percentage / 100 + 'px'; | ||
33 | const background = this.getCurrentColor(); | ||
34 | return `width: ${width}; background: ${background}; `; | ||
35 | }, | ||
36 | pivotStyle() { | ||
37 | const color = this.data.textColor; | ||
38 | const background = this.data.pivotColor || this.getCurrentColor(); | ||
39 | return `color: ${color}; background: ${background}`; | ||
40 | }, | 22 | }, |
41 | text() { | 23 | strokeWidth: { |
42 | return this.data.pivotText || this.data.percentage + '%'; | 24 | type: null, |
25 | observer: 'setStrokeWidthUnit' | ||
43 | } | 26 | } |
44 | }, | 27 | }, |
45 | mounted() { | 28 | data: { |
46 | this.getWidth(); | 29 | strokeWidthUnit: '4px' |
47 | }, | 30 | }, |
48 | methods: { | 31 | methods: { |
49 | getCurrentColor() { | 32 | setStrokeWidthUnit(val) { |
50 | return this.data.inactive ? '#cacaca' : this.data.color; | 33 | this.setData({ |
51 | }, | 34 | strokeWidthUnit: addUnit(val) |
52 | getWidth() { | ||
53 | this.getRect('.van-progress').then(rect => { | ||
54 | this.set({ | ||
55 | progressWidth: rect.width | ||
56 | }); | ||
57 | }); | ||
58 | this.getRect('.van-progress__pivot').then(rect => { | ||
59 | this.set({ | ||
60 | pivotWidth: rect.width || 0 | ||
61 | }); | ||
62 | }); | 35 | }); |
63 | } | 36 | } |
64 | } | 37 | } | ... | ... |
1 | <view class="van-progress custom-class"> | 1 | <wxs src="./index.wxs" module="getters" /> |
2 | |||
3 | <view | ||
4 | class="van-progress custom-class" | ||
5 | style="height: {{ strokeWidthUnit }}; {{ trackColor ? 'background: ' + trackColor : '' }}" | ||
6 | > | ||
2 | <view | 7 | <view |
3 | class="van-progress__portion {{ showPivot && text ? 'van-progress__portion--with-pivot' : '' }}" | 8 | class="van-progress__portion" |
4 | style="{{ portionStyle }}" | 9 | style="width: {{ percentage }}%; background: {{ inactive ? '#cacaca' : color }}" |
5 | > | 10 | > |
6 | <view | 11 | <view |
7 | wx:if="{{ showPivot && text }}" | 12 | wx:if="{{ showPivot && getters.text(pivotText, percentage) }}" |
8 | style="{{ pivotStyle }}" | 13 | style="color: {{ textColor }}; background: {{ pivotColor ? pivotColor : inactive ? '#cacaca' : color }}" |
9 | class="van-progress__pivot" | 14 | class="van-progress__pivot" |
10 | > | 15 | > |
11 | {{ text }} | 16 | {{ getters.text(pivotText, percentage) }} |
12 | </view> | 17 | </view> |
13 | </view> | 18 | </view> |
14 | </view> | 19 | </view> | ... | ... |
src/ui/vant-weapp/progress/index.wxs
0 → 100755
1 | @import '../common/index.wxss';.van-progress{height:4px;position:relative;border-radius:4px;background:#e5e5e5}.van-progress__portion{left:0;height:100%;position:absolute;border-radius:inherit}.van-progress__portion--with-pivot{border-top-right-radius:0;border-bottom-right-radius:0}.van-progress__pivot{top:50%;right:0;min-width:2em;padding:0 5px;font-size:10px;position:absolute;line-height:1.6;text-align:center;border-radius:1em;word-break:keep-all;box-sizing:border-box;background-color:#e5e5e5;-webkit-transform:translate(100%,-50%);transform:translate(100%,-50%)} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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:#e5e5e5;background:var(--progress-background-color,#e5e5e5)}.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 | ... | \ No newline at end of file | ... | ... |
... | @@ -5,28 +5,33 @@ VantComponent({ | ... | @@ -5,28 +5,33 @@ VantComponent({ |
5 | name: 'radio', | 5 | name: 'radio', |
6 | type: 'descendant', | 6 | type: 'descendant', |
7 | linked(target) { | 7 | linked(target) { |
8 | const { value, disabled } = this.data; | 8 | this.children = this.children || []; |
9 | target.set({ | 9 | this.children.push(target); |
10 | value: value, | 10 | this.updateChild(target); |
11 | disabled: disabled || target.data.disabled | 11 | }, |
12 | }); | 12 | unlinked(target) { |
13 | this.children = this.children.filter((child) => child !== target); | ||
13 | } | 14 | } |
14 | }, | 15 | }, |
15 | props: { | 16 | props: { |
16 | value: null, | 17 | value: { |
17 | disabled: Boolean | 18 | type: null, |
19 | observer: 'updateChildren' | ||
18 | }, | 20 | }, |
19 | watch: { | 21 | disabled: { |
20 | value(value) { | 22 | type: Boolean, |
21 | const children = this.getRelationNodes('../radio/index'); | 23 | observer: 'updateChildren' |
22 | children.forEach(child => { | 24 | } |
23 | child.set({ value }); | 25 | }, |
24 | }); | 26 | methods: { |
27 | updateChildren() { | ||
28 | (this.children || []).forEach((child) => this.updateChild(child)); | ||
25 | }, | 29 | }, |
26 | disabled(disabled) { | 30 | updateChild(child) { |
27 | const children = this.getRelationNodes('../radio/index'); | 31 | const { value, disabled } = this.data; |
28 | children.forEach(child => { | 32 | child.setData({ |
29 | child.set({ disabled: disabled || child.data.disabled }); | 33 | value, |
34 | disabled: disabled || child.data.disabled | ||
30 | }); | 35 | }); |
31 | } | 36 | } |
32 | } | 37 | } | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { addUnit } from '../common/utils'; | ||
2 | VantComponent({ | 3 | VantComponent({ |
3 | field: true, | 4 | field: true, |
4 | relation: { | 5 | relation: { |
5 | name: 'radio-group', | 6 | name: 'radio-group', |
6 | type: 'ancestor' | 7 | type: 'ancestor', |
8 | linked(target) { | ||
9 | this.parent = target; | ||
10 | }, | ||
11 | unlinked() { | ||
12 | this.parent = null; | ||
13 | } | ||
7 | }, | 14 | }, |
8 | classes: ['icon-class', 'label-class'], | 15 | classes: ['icon-class', 'label-class'], |
9 | props: { | 16 | props: { |
10 | name: null, | ||
11 | value: null, | 17 | value: null, |
12 | disabled: Boolean, | 18 | disabled: Boolean, |
19 | useIconSlot: Boolean, | ||
20 | checkedColor: String, | ||
21 | labelPosition: { | ||
22 | type: String, | ||
23 | value: 'right' | ||
24 | }, | ||
13 | labelDisabled: Boolean, | 25 | labelDisabled: Boolean, |
14 | labelPosition: String, | 26 | shape: { |
15 | checkedColor: String | 27 | type: String, |
28 | value: 'round' | ||
29 | }, | ||
30 | iconSize: { | ||
31 | type: null, | ||
32 | observer: 'setIconSizeUnit' | ||
33 | } | ||
34 | }, | ||
35 | data: { | ||
36 | iconSizeWithUnit: '20px' | ||
16 | }, | 37 | }, |
17 | methods: { | 38 | methods: { |
39 | setIconSizeUnit(val) { | ||
40 | this.setData({ | ||
41 | iconSizeWithUnit: addUnit(val) | ||
42 | }); | ||
43 | }, | ||
18 | emitChange(value) { | 44 | emitChange(value) { |
19 | const instance = this.getRelationNodes('../radio-group/index')[0] || this; | 45 | const instance = this.parent || this; |
20 | instance.$emit('input', value); | 46 | instance.$emit('input', value); |
21 | instance.$emit('change', value); | 47 | instance.$emit('change', value); |
22 | }, | 48 | }, |
23 | onChange(event) { | 49 | onChange(event) { |
24 | this.emitChange(event.detail.value); | 50 | console.log(event); |
51 | this.emitChange(this.data.name); | ||
25 | }, | 52 | }, |
26 | onClickLabel() { | 53 | onClickLabel() { |
27 | if (!this.data.disabled && !this.data.labelDisabled) { | 54 | const { disabled, labelDisabled, name } = this.data; |
28 | this.emitChange(this.data.name); | 55 | if (!disabled && !labelDisabled) { |
56 | this.emitChange(name); | ||
29 | } | 57 | } |
30 | } | 58 | } |
31 | } | 59 | } | ... | ... |
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | 1 | <wxs src="../wxs/utils.wxs" module="utils" /> |
2 | 2 | ||
3 | <view class="van-radio custom-class"> | 3 | <view class="van-radio custom-class"> |
4 | <view class="van-radio__input"> | 4 | <view |
5 | <radio-group bindchange="onChange"> | 5 | wx:if="{{ labelPosition === 'left' }}" |
6 | <radio | 6 | class="label-class {{ utils.bem('radio__label', [labelPosition, { disabled }]) }}" |
7 | value="{{ name }}" | 7 | bindtap="onClickLabel" |
8 | checked="{{ value === name }}" | 8 | > |
9 | disabled="{{ disabled }}" | 9 | <slot /> |
10 | class="van-radio__control" | 10 | </view> |
11 | /> | 11 | <view class="van-radio__icon-wrap" style="font-size: {{ iconSizeWithUnit }};" bindtap="onChange"> |
12 | </radio-group> | 12 | <slot wx:if="{{ useIconSlot }}" name="icon" /> |
13 | <van-icon | 13 | <van-icon |
14 | class="{{ utils.bem('radio__icon', { disabled, checked: !disabled && name === value, check: !disabled && name !== value }) }}" | 14 | wx:else |
15 | name="success" | ||
16 | class="{{ utils.bem('radio__icon', [shape, { disabled, checked: value === name }]) }}" | ||
17 | style="{{ checkedColor && !disabled && value === name ? 'border-color:' + checkedColor + '; background-color:' + checkedColor + ';' : '' }}" | ||
15 | custom-class="icon-class" | 18 | custom-class="icon-class" |
16 | color="{{ value === name ? checkedColor : '' }}" | 19 | custom-style="line-height: {{ iconSizeWithUnit }};font-size: .8em;display: block;" |
17 | name="{{ value === name ? 'checked' : 'circle' }}" | ||
18 | /> | 20 | /> |
19 | </view> | 21 | </view> |
20 | <view class="van-radio__label van-radio__label--{{ labelPosition }} label-class" bindtap="onClickLabel"> | 22 | <view |
23 | wx:if="{{ labelPosition === 'right' }}" | ||
24 | class="label-class {{ utils.bem('radio__label', [labelPosition, { disabled }]) }}" | ||
25 | bindtap="onClickLabel" | ||
26 | > | ||
21 | <slot /> | 27 | <slot /> |
22 | </view> | 28 | </view> |
23 | </view> | 29 | </view> | ... | ... |
1 | @import '../common/index.wxss';.van-radio{overflow:hidden;line-height:1;-webkit-user-select:none;user-select:none}.van-radio__input,.van-radio__label{display:inline-block;vertical-align:middle}.van-radio__input{position:relative;font-size:20px}.van-radio__control{z-index:1;position:absolute;top:0;left:0;width:100%;height:100%;margin:0;opacity:0}.van-radio__label{margin-left:10px;color:#333;font-size:16px;line-height:20px}.van-radio__label--left{margin:0 10px 0 0;float:left}.van-radio__label:empty{margin:0}.van-radio__icon{pointer-events:none;display:block;line-height:0}.van-radio__icon--disabled{color:#e5e5e5}.van-radio__icon--checked{color:#1989fa}.van-radio__icon--check{color:#c9c9c9} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 #e5e5e5;border:1px solid var(--radio-border-color,#e5e5e5);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 | ... | \ No newline at end of file | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { addUnit } from '../common/utils'; | ||
2 | VantComponent({ | 3 | VantComponent({ |
3 | field: true, | 4 | field: true, |
4 | classes: ['icon-class'], | 5 | classes: ['icon-class'], |
5 | props: { | 6 | props: { |
7 | value: Number, | ||
6 | readonly: Boolean, | 8 | readonly: Boolean, |
7 | disabled: Boolean, | 9 | disabled: Boolean, |
10 | allowHalf: Boolean, | ||
8 | size: { | 11 | size: { |
9 | type: Number, | 12 | type: null, |
10 | value: 20 | 13 | observer: 'setSizeWithUnit' |
11 | }, | 14 | }, |
12 | icon: { | 15 | icon: { |
13 | type: String, | 16 | type: String, |
... | @@ -33,46 +36,58 @@ VantComponent({ | ... | @@ -33,46 +36,58 @@ VantComponent({ |
33 | type: Number, | 36 | type: Number, |
34 | value: 5 | 37 | value: 5 |
35 | }, | 38 | }, |
36 | value: { | 39 | gutter: { |
37 | type: Number, | 40 | type: null, |
38 | value: 0 | 41 | observer: 'setGutterWithUnit' |
42 | }, | ||
43 | touchable: { | ||
44 | type: Boolean, | ||
45 | value: true | ||
39 | } | 46 | } |
40 | }, | 47 | }, |
41 | data: { | 48 | data: { |
42 | innerValue: 0 | 49 | innerValue: 0, |
50 | gutterWithUnit: undefined, | ||
51 | sizeWithUnit: '20px' | ||
43 | }, | 52 | }, |
44 | watch: { | 53 | watch: { |
45 | value(value) { | 54 | value(value) { |
46 | if (value !== this.data.innerValue) { | 55 | if (value !== this.data.innerValue) { |
47 | this.set({ innerValue: value }); | 56 | this.setData({ innerValue: value }); |
48 | } | 57 | } |
49 | } | 58 | } |
50 | }, | 59 | }, |
51 | computed: { | ||
52 | list() { | ||
53 | const { count, innerValue } = this.data; | ||
54 | return Array.from({ length: count }, (_, index) => index < innerValue); | ||
55 | } | ||
56 | }, | ||
57 | methods: { | 60 | methods: { |
61 | setSizeWithUnit(val) { | ||
62 | this.setData({ | ||
63 | sizeWithUnit: addUnit(val) | ||
64 | }); | ||
65 | }, | ||
66 | setGutterWithUnit(val) { | ||
67 | this.setData({ | ||
68 | gutterWithUnit: addUnit(val) | ||
69 | }); | ||
70 | }, | ||
58 | onSelect(event) { | 71 | onSelect(event) { |
59 | const { data } = this; | 72 | const { data } = this; |
60 | const { index } = event.currentTarget.dataset; | 73 | const { score } = event.currentTarget.dataset; |
61 | if (!data.disabled && !data.readonly) { | 74 | if (!data.disabled && !data.readonly) { |
62 | this.set({ innerValue: index + 1 }); | 75 | this.setData({ innerValue: score + 1 }); |
63 | this.$emit('input', index + 1); | 76 | this.$emit('input', score + 1); |
64 | this.$emit('change', index + 1); | 77 | this.$emit('change', score + 1); |
65 | } | 78 | } |
66 | }, | 79 | }, |
67 | onTouchMove(event) { | 80 | onTouchMove(event) { |
68 | const { clientX, clientY } = event.touches[0]; | 81 | const { touchable } = this.data; |
69 | this.getRect('.van-rate__item', true).then(list => { | 82 | if (!touchable) |
70 | const target = list.find(item => clientX >= item.left && | 83 | return; |
71 | clientX <= item.right && | 84 | const { clientX } = event.touches[0]; |
72 | clientY >= item.top && | 85 | this.getRect('.van-rate__icon', true).then((list) => { |
73 | clientY <= item.bottom); | 86 | const target = list |
87 | .sort(item => item.right - item.left) | ||
88 | .find(item => clientX >= item.left && clientX <= item.right); | ||
74 | if (target != null) { | 89 | if (target != null) { |
75 | this.onSelect(Object.assign({}, event, { currentTarget: target })); | 90 | this.onSelect(Object.assign(Object.assign({}, event), { currentTarget: target })); |
76 | } | 91 | } |
77 | }); | 92 | }); |
78 | } | 93 | } | ... | ... |
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | |||
1 | <view | 3 | <view |
2 | class="van-rate custom-class" | 4 | class="van-rate custom-class" |
3 | bind:touchmove="onTouchMove" | 5 | bind:touchmove="onTouchMove" |
4 | > | 6 | > |
5 | <van-icon | 7 | <view |
6 | wx:for="{{ list }}" | ||
7 | wx:key="index" | ||
8 | class="van-rate__item" | 8 | class="van-rate__item" |
9 | wx:for="{{ count }}" | ||
10 | wx:key="index" | ||
11 | style="font-size: {{ sizeWithUnit }};padding-right: {{ index !== count - 1 ? gutterWithUnit : '' }}" | ||
12 | > | ||
13 | <van-icon | ||
14 | name="{{ index + 1 <= innerValue ? icon : voidIcon }}" | ||
15 | class="van-rate__icon" | ||
16 | custom-class="icon-class" | ||
17 | data-score="{{ index }}" | ||
18 | color="{{ disabled ? disabledColor : index + 1 <= innerValue ? color : voidColor }}" | ||
19 | bind:click="onSelect" | ||
20 | /> | ||
21 | |||
22 | <van-icon | ||
23 | wx:if="{{ allowHalf }}" | ||
24 | name="{{ index + 0.5 <= innerValue ? icon : voidIcon }}" | ||
25 | class="{{ utils.bem('rate__icon', ['half']) }}" | ||
9 | custom-class="icon-class" | 26 | custom-class="icon-class" |
10 | size="{{ size }}px" | 27 | data-score="{{ index - 0.5 }}" |
11 | data-index="{{ index }}" | 28 | color="{{ disabled ? disabledColor : index + 0.5 <= innerValue ? color : voidColor }}" |
12 | name="{{ item ? icon : voidIcon }}" | ||
13 | color="{{ disabled ? disabledColor : item ? color : voidColor }}" | ||
14 | bind:click="onSelect" | 29 | bind:click="onSelect" |
15 | /> | 30 | /> |
31 | </view> | ||
16 | </view> | 32 | </view> | ... | ... |
1 | @import '../common/index.wxss';.van-rate{-webkit-user-select:none;user-select:none}.van-rate__item{width:1em;padding:0 2px;box-sizing:initial} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
... | @@ -27,7 +27,7 @@ VantComponent({ | ... | @@ -27,7 +27,7 @@ VantComponent({ |
27 | const style = gutter | 27 | const style = gutter |
28 | ? `margin-right: ${margin}; margin-left: ${margin};` | 28 | ? `margin-right: ${margin}; margin-left: ${margin};` |
29 | : ''; | 29 | : ''; |
30 | this.set({ style }); | 30 | this.setData({ style }); |
31 | this.getRelationNodes('../col/index').forEach(col => { | 31 | this.getRelationNodes('../col/index').forEach(col => { |
32 | col.setGutter(this.data.gutter); | 32 | col.setGutter(this.data.gutter); |
33 | }); | 33 | }); | ... | ... |
1 | @import '../common/index.wxss';.van-row:after{content:"";display:table;clear:both} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | @import '../common/index.wxss';.van-row:after{display:table;clear:both;content:""} | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -3,6 +3,7 @@ VantComponent({ | ... | @@ -3,6 +3,7 @@ VantComponent({ |
3 | field: true, | 3 | field: true, |
4 | classes: ['field-class', 'input-class', 'cancel-class'], | 4 | classes: ['field-class', 'input-class', 'cancel-class'], |
5 | props: { | 5 | props: { |
6 | label: String, | ||
6 | focus: Boolean, | 7 | focus: Boolean, |
7 | error: Boolean, | 8 | error: Boolean, |
8 | disabled: Boolean, | 9 | disabled: Boolean, |
... | @@ -10,8 +11,19 @@ VantComponent({ | ... | @@ -10,8 +11,19 @@ VantComponent({ |
10 | inputAlign: String, | 11 | inputAlign: String, |
11 | showAction: Boolean, | 12 | showAction: Boolean, |
12 | useActionSlot: Boolean, | 13 | useActionSlot: Boolean, |
14 | useLeftIconSlot: Boolean, | ||
15 | useRightIconSlot: Boolean, | ||
16 | leftIcon: { | ||
17 | type: String, | ||
18 | value: 'search' | ||
19 | }, | ||
20 | rightIcon: String, | ||
13 | placeholder: String, | 21 | placeholder: String, |
14 | placeholderStyle: String, | 22 | placeholderStyle: String, |
23 | actionText: { | ||
24 | type: String, | ||
25 | value: '取消' | ||
26 | }, | ||
15 | background: { | 27 | background: { |
16 | type: String, | 28 | type: String, |
17 | value: '#ffffff' | 29 | value: '#ffffff' |
... | @@ -24,17 +36,26 @@ VantComponent({ | ... | @@ -24,17 +36,26 @@ VantComponent({ |
24 | type: String, | 36 | type: String, |
25 | value: 'square' | 37 | value: 'square' |
26 | }, | 38 | }, |
27 | label: String | 39 | clearable: { |
40 | type: Boolean, | ||
41 | value: true | ||
42 | } | ||
28 | }, | 43 | }, |
29 | methods: { | 44 | methods: { |
30 | onChange(event) { | 45 | onChange(event) { |
31 | this.set({ value: event.detail }); | 46 | this.setData({ value: event.detail }); |
32 | this.$emit('change', event.detail); | 47 | this.$emit('change', event.detail); |
33 | }, | 48 | }, |
34 | onCancel() { | 49 | onCancel() { |
35 | this.set({ value: '' }); | 50 | /** |
51 | * 修复修改输入框值时,输入框失焦和赋值同时触发,赋值失效 | ||
52 | * https://github.com/youzan/vant-weapp/issues/1768 | ||
53 | */ | ||
54 | setTimeout(() => { | ||
55 | this.setData({ value: '' }); | ||
36 | this.$emit('cancel'); | 56 | this.$emit('cancel'); |
37 | this.$emit('change', ''); | 57 | this.$emit('change', ''); |
58 | }, 200); | ||
38 | }, | 59 | }, |
39 | onSearch() { | 60 | onSearch() { |
40 | this.$emit('search', this.data.value); | 61 | this.$emit('search', this.data.value); | ... | ... |
... | @@ -9,9 +9,9 @@ | ... | @@ -9,9 +9,9 @@ |
9 | <slot wx:else name="label" /> | 9 | <slot wx:else name="label" /> |
10 | 10 | ||
11 | <van-field | 11 | <van-field |
12 | clearable | ||
13 | type="search" | 12 | type="search" |
14 | left-icon="search" | 13 | left-icon="{{ !useLeftIconSlot ? leftIcon : '' }}" |
14 | right-icon="{{ !useRightIconSlot ? rightIcon : '' }}" | ||
15 | focus="{{ focus }}" | 15 | focus="{{ focus }}" |
16 | error="{{ error }}" | 16 | error="{{ error }}" |
17 | border="{{ false }}" | 17 | border="{{ false }}" |
... | @@ -20,6 +20,7 @@ | ... | @@ -20,6 +20,7 @@ |
20 | value="{{ value }}" | 20 | value="{{ value }}" |
21 | disabled="{{ disabled }}" | 21 | disabled="{{ disabled }}" |
22 | readonly="{{ readonly }}" | 22 | readonly="{{ readonly }}" |
23 | clearable="{{ clearable }}" | ||
23 | maxlength="{{ maxlength }}" | 24 | maxlength="{{ maxlength }}" |
24 | input-align="{{ inputAlign }}" | 25 | input-align="{{ inputAlign }}" |
25 | input-class="input-class" | 26 | input-class="input-class" |
... | @@ -31,7 +32,10 @@ | ... | @@ -31,7 +32,10 @@ |
31 | bind:change="onChange" | 32 | bind:change="onChange" |
32 | bind:confirm="onSearch" | 33 | bind:confirm="onSearch" |
33 | bind:clear="onClear" | 34 | bind:clear="onClear" |
34 | /> | 35 | > |
36 | <slot wx:if="{{ useLeftIconSlot }}" name="left-icon" slot="left-icon" /> | ||
37 | <slot wx:if="{{ useRightIconSlot }}" name="right-icon" slot="right-icon" /> | ||
38 | </van-field> | ||
35 | </view> | 39 | </view> |
36 | 40 | ||
37 | <view | 41 | <view |
... | @@ -41,6 +45,6 @@ | ... | @@ -41,6 +45,6 @@ |
41 | hover-stay-time="70" | 45 | hover-stay-time="70" |
42 | > | 46 | > |
43 | <slot wx:if="{{ useActionSlot }}" name="action" /> | 47 | <slot wx:if="{{ useActionSlot }}" name="action" /> |
44 | <view wx:else bind:tap="onCancel" class="cancel-class">取消</view> | 48 | <view wx:else bind:tap="onCancel" class="cancel-class">{{ actionText }}</view> |
45 | </view> | 49 | </view> |
46 | </view> | 50 | </view> | ... | ... |
1 | @import '../common/index.wxss';.van-search{padding:10px 16px;-webkit-align-items:center;align-items:center;box-sizing:border-box}.van-search,.van-search__content{display:-webkit-flex;display:flex}.van-search__content{padding-left:10px;background-color:#f7f8fa;border-radius:2px;-webkit-flex:1;flex:1}.van-search__content--round{border-radius:17px}.van-search__label{padding:0 5px;font-size:14px;line-height:34px;color:#333}.van-search__field{-webkit-flex:1;flex:1}.van-search__field__left-icon{color:#999}.van-search--withaction{padding-right:0}.van-search input::-webkit-search-cancel-button,.van-search input::-webkit-search-decoration,.van-search input::-webkit-search-results-button,.van-search input::-webkit-search-results-decoration{display:none}.van-search__action{padding:0 10px;font-size:14px;line-height:34px;color:#333}.van-search__action--hover{background-color:#f2f3f5} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
src/ui/vant-weapp/sidebar-item/index.d.ts
0 → 100755
1 | export {}; |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | VantComponent({ | 2 | VantComponent({ |
3 | classes: [ | ||
4 | 'active-class', | ||
5 | 'disabled-class', | ||
6 | ], | ||
3 | relation: { | 7 | relation: { |
4 | type: 'ancestor', | 8 | type: 'ancestor', |
5 | name: 'badge-group' | 9 | name: 'sidebar', |
10 | linked(target) { | ||
11 | this.parent = target; | ||
12 | } | ||
6 | }, | 13 | }, |
7 | props: { | 14 | props: { |
15 | dot: Boolean, | ||
8 | info: null, | 16 | info: null, |
9 | title: String | 17 | title: String, |
18 | disabled: Boolean | ||
10 | }, | 19 | }, |
11 | methods: { | 20 | methods: { |
12 | onClick() { | 21 | onClick() { |
13 | const group = this.getRelationNodes('../badge-group/index')[0]; | 22 | const { parent } = this; |
14 | if (group) { | 23 | if (!parent || this.data.disabled) { |
15 | group.setActive(this); | 24 | return; |
16 | } | 25 | } |
26 | const index = parent.children.indexOf(this); | ||
27 | parent.setActive(index).then(() => { | ||
28 | this.$emit('click', index); | ||
29 | parent.$emit('change', index); | ||
30 | }); | ||
17 | }, | 31 | }, |
18 | setActive(active) { | 32 | setActive(selected) { |
19 | this.set({ active }); | 33 | return this.setData({ selected }); |
20 | } | 34 | } |
21 | } | 35 | } |
22 | }); | 36 | }); | ... | ... |
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | 1 | <wxs src="../wxs/utils.wxs" module="utils" /> |
2 | 2 | ||
3 | <view | 3 | <view |
4 | class="{{ utils.bem('badge', { active }) }} van-hairline custom-class" | 4 | class="{{ utils.bem('sidebar-item', { selected, disabled }) }} {{ selected ? 'active-class' : '' }} {{ disabled ? 'disabled-class' : '' }} custom-class" |
5 | hover-class="van-badge--hover" | 5 | hover-class="van-sidebar-item--hover" |
6 | hover-stay-time="70" | 6 | hover-stay-time="70" |
7 | bind:tap="onClick" | 7 | bind:tap="onClick" |
8 | > | 8 | > |
9 | <view class="van-badge__text"> | 9 | <view class="van-sidebar-item__text"> |
10 | <van-info | 10 | <van-info |
11 | wx:if="{{ info !== null }}" | 11 | wx:if="{{ info !== null || dot }}" |
12 | dot="{{ dot }}" | ||
12 | info="{{ info }}" | 13 | info="{{ info }}" |
13 | custom-style="right: 4px" | 14 | custom-style="right: 4px" |
14 | /> | 15 | /> | ... | ... |
src/ui/vant-weapp/sidebar-item/index.wxss
0 → 100755
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 | ... | \ No newline at end of file |
src/ui/vant-weapp/sidebar/index.d.ts
0 → 100755
1 | export {}; |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { isNumber } from '../common/utils'; | ||
3 | VantComponent({ | 2 | VantComponent({ |
4 | relation: { | 3 | relation: { |
5 | name: 'badge', | 4 | name: 'sidebar-item', |
6 | type: 'descendant', | 5 | type: 'descendant', |
7 | linked(target) { | 6 | linked(target) { |
8 | this.badges.push(target); | 7 | this.children.push(target); |
9 | this.setActive(); | 8 | this.setActive(this.data.activeKey); |
10 | }, | 9 | }, |
11 | unlinked(target) { | 10 | unlinked(target) { |
12 | this.badges = this.badges.filter(item => item !== target); | 11 | this.items = this.children.filter((item) => item !== target); |
13 | this.setActive(); | 12 | this.setActive(this.data.activeKey); |
14 | } | 13 | } |
15 | }, | 14 | }, |
16 | props: { | 15 | props: { |
17 | active: { | 16 | activeKey: { |
18 | type: Number, | 17 | type: Number, |
19 | value: 0 | 18 | value: 0, |
19 | observer: 'setActive' | ||
20 | } | 20 | } |
21 | }, | 21 | }, |
22 | watch: { | ||
23 | active: 'setActive' | ||
24 | }, | ||
25 | beforeCreate() { | 22 | beforeCreate() { |
26 | this.badges = []; | 23 | this.children = []; |
27 | this.currentActive = -1; | 24 | this.currentActive = -1; |
28 | }, | 25 | }, |
29 | methods: { | 26 | methods: { |
30 | setActive(badge) { | 27 | setActive(activeKey) { |
31 | let { active } = this.data; | 28 | const { children, currentActive } = this; |
32 | const { badges } = this; | 29 | if (!children.length) { |
33 | if (badge && !isNumber(badge)) { | 30 | return Promise.resolve(); |
34 | active = badges.indexOf(badge); | ||
35 | } | ||
36 | if (active === this.currentActive) { | ||
37 | return; | ||
38 | } | 31 | } |
39 | if (this.currentActive !== -1 && badges[this.currentActive]) { | 32 | this.currentActive = activeKey; |
40 | this.$emit('change', active); | 33 | const stack = []; |
41 | badges[this.currentActive].setActive(false); | 34 | if (currentActive !== activeKey && children[currentActive]) { |
35 | stack.push(children[currentActive].setActive(false)); | ||
42 | } | 36 | } |
43 | if (badges[active]) { | 37 | if (children[activeKey]) { |
44 | badges[active].setActive(true); | 38 | stack.push(children[activeKey].setActive(true)); |
45 | this.currentActive = active; | ||
46 | } | 39 | } |
40 | return Promise.all(stack); | ||
47 | } | 41 | } |
48 | } | 42 | } |
49 | }); | 43 | }); | ... | ... |
src/ui/vant-weapp/sidebar/index.json
0 → 100755
src/ui/vant-weapp/sidebar/index.wxss
0 → 100755
1 | @import '../common/index.wxss';.van-sidebar{width:85px;width:var(--sidebar-width,85px)} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
src/ui/vant-weapp/skeleton/index.d.ts
0 → 100755
1 | export {}; |
src/ui/vant-weapp/skeleton/index.js
0 → 100755
1 | import { VantComponent } from '../common/component'; | ||
2 | VantComponent({ | ||
3 | props: { | ||
4 | row: { | ||
5 | type: Number, | ||
6 | value: 0 | ||
7 | }, | ||
8 | title: Boolean, | ||
9 | avatar: Boolean, | ||
10 | loading: { | ||
11 | type: Boolean, | ||
12 | value: true | ||
13 | }, | ||
14 | animate: { | ||
15 | type: Boolean, | ||
16 | value: true | ||
17 | }, | ||
18 | avatarSize: { | ||
19 | type: String, | ||
20 | value: '32px' | ||
21 | }, | ||
22 | avatarShape: { | ||
23 | type: String, | ||
24 | value: 'round' | ||
25 | }, | ||
26 | titleWidth: { | ||
27 | type: String, | ||
28 | value: '40%' | ||
29 | }, | ||
30 | rowWidth: { | ||
31 | type: null, | ||
32 | value: '100%', | ||
33 | observer(val) { | ||
34 | this.setData({ isArray: val instanceof Array }); | ||
35 | } | ||
36 | } | ||
37 | }, | ||
38 | data: { | ||
39 | isArray: false | ||
40 | } | ||
41 | }); |
src/ui/vant-weapp/skeleton/index.json
0 → 100755
src/ui/vant-weapp/skeleton/index.wxml
0 → 100755
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | |||
3 | <view | ||
4 | wx:if="{{ loading }}" | ||
5 | class="custom-class {{ utils.bem('skeleton', [{animate}]) }}" | ||
6 | > | ||
7 | <view | ||
8 | wx:if="{{ avatar }}" | ||
9 | class="{{ utils.bem('skeleton__avatar', [avatarShape])}}" | ||
10 | style="{{ 'width:' + avatarSize + ';height:' + avatarSize }}" | ||
11 | /> | ||
12 | <view class="{{ utils.bem('skeleton__content')}}"> | ||
13 | <view | ||
14 | wx:if="{{ title }}" | ||
15 | class="{{ utils.bem('skeleton__title') }}" | ||
16 | style="{{ 'width:' + titleWidth }}" | ||
17 | /> | ||
18 | <view | ||
19 | wx:for="row" | ||
20 | wx:for-index="index" | ||
21 | class="{{ utils.bem('skeleton__row') }}" | ||
22 | style="{{ 'width:' + (isArray ? rowWidth[index] : rowWidth) }}" | ||
23 | /> | ||
24 | </view> | ||
25 | </view> | ||
26 | <view wx:else class="{{ utils.bem('skeleton__content')}}"> | ||
27 | <slot /> | ||
28 | </view> |
src/ui/vant-weapp/skeleton/index.wxss
0 → 100755
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 | ... | \ No newline at end of file |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { touch } from '../mixins/touch'; | 2 | import { touch } from '../mixins/touch'; |
3 | import { addUnit } from '../common/utils'; | ||
3 | VantComponent({ | 4 | VantComponent({ |
4 | mixins: [touch], | 5 | mixins: [touch], |
5 | props: { | 6 | props: { |
... | @@ -24,7 +25,7 @@ VantComponent({ | ... | @@ -24,7 +25,7 @@ VantComponent({ |
24 | value: 0 | 25 | value: 0 |
25 | }, | 26 | }, |
26 | barHeight: { | 27 | barHeight: { |
27 | type: String, | 28 | type: null, |
28 | value: '2px' | 29 | value: '2px' |
29 | } | 30 | } |
30 | }, | 31 | }, |
... | @@ -42,34 +43,50 @@ VantComponent({ | ... | @@ -42,34 +43,50 @@ VantComponent({ |
42 | return; | 43 | return; |
43 | this.touchStart(event); | 44 | this.touchStart(event); |
44 | this.startValue = this.format(this.data.value); | 45 | this.startValue = this.format(this.data.value); |
46 | this.dragStatus = 'start'; | ||
45 | }, | 47 | }, |
46 | onTouchMove(event) { | 48 | onTouchMove(event) { |
47 | if (this.data.disabled) | 49 | if (this.data.disabled) |
48 | return; | 50 | return; |
51 | if (this.dragStatus === 'start') { | ||
52 | this.$emit('drag-start'); | ||
53 | } | ||
49 | this.touchMove(event); | 54 | this.touchMove(event); |
55 | this.dragStatus = 'draging'; | ||
50 | this.getRect('.van-slider').then((rect) => { | 56 | this.getRect('.van-slider').then((rect) => { |
51 | const diff = this.deltaX / rect.width * 100; | 57 | const diff = this.deltaX / rect.width * 100; |
52 | this.updateValue(this.startValue + diff, false, true); | 58 | this.newValue = this.startValue + diff; |
59 | this.updateValue(this.newValue, false, true); | ||
53 | }); | 60 | }); |
54 | }, | 61 | }, |
55 | onTouchEnd() { | 62 | onTouchEnd() { |
56 | if (this.data.disabled) | 63 | if (this.data.disabled) |
57 | return; | 64 | return; |
58 | this.updateValue(this.data.value, true); | 65 | if (this.dragStatus === 'draging') { |
66 | this.updateValue(this.newValue, true); | ||
67 | this.$emit('drag-end'); | ||
68 | } | ||
59 | }, | 69 | }, |
60 | onClick(event) { | 70 | onClick(event) { |
61 | if (this.data.disabled) | 71 | if (this.data.disabled) |
62 | return; | 72 | return; |
73 | const { min } = this.data; | ||
63 | this.getRect('.van-slider').then((rect) => { | 74 | this.getRect('.van-slider').then((rect) => { |
64 | const value = (event.detail.x - rect.left) / rect.width * 100; | 75 | const value = (event.detail.x - rect.left) / rect.width * this.getRange() + min; |
65 | this.updateValue(value, true); | 76 | this.updateValue(value, true); |
66 | }); | 77 | }); |
67 | }, | 78 | }, |
68 | updateValue(value, end, drag) { | 79 | updateValue(value, end, drag) { |
69 | value = this.format(value); | 80 | value = this.format(value); |
70 | this.set({ | 81 | const { barHeight, min } = this.data; |
82 | const width = `${((value - min) * 100) / this.getRange()}%`; | ||
83 | this.setData({ | ||
71 | value, | 84 | value, |
72 | barStyle: `width: ${value}%; height: ${this.data.barHeight};` | 85 | barStyle: ` |
86 | width: ${width}; | ||
87 | height: ${addUnit(barHeight)}; | ||
88 | ${drag ? 'transition: none;' : ''} | ||
89 | `, | ||
73 | }); | 90 | }); |
74 | if (drag) { | 91 | if (drag) { |
75 | this.$emit('drag', { value }); | 92 | this.$emit('drag', { value }); |
... | @@ -78,6 +95,10 @@ VantComponent({ | ... | @@ -78,6 +95,10 @@ VantComponent({ |
78 | this.$emit('change', value); | 95 | this.$emit('change', value); |
79 | } | 96 | } |
80 | }, | 97 | }, |
98 | getRange() { | ||
99 | const { max, min } = this.data; | ||
100 | return max - min; | ||
101 | }, | ||
81 | format(value) { | 102 | format(value) { |
82 | const { max, min, step } = this.data; | 103 | const { max, min, step } = this.data; |
83 | return Math.round(Math.max(min, Math.min(value, max)) / step) * step; | 104 | return Math.round(Math.max(min, Math.min(value, max)) / step) * step; | ... | ... |
1 | @import '../common/index.wxss';.van-slider{position:relative;border-radius:999px;background-color:#e5e5e5}.van-slider__bar{position:relative;border-radius:inherit;background-color:#1989fa}.van-slider__button{width:20px;height:20px;border-radius:50%;background-color:#fff;box-shadow:0 1px 2px rgba(0,0,0,.5)}.van-slider__button-wrapper{position:absolute;top:50%;right:0;-webkit-transform:translate3d(50%,-50%,0);transform:translate3d(50%,-50%,0)}.van-slider__button-wrapper:after{content:"";position:absolute;width:200%;height:200%;top:-50%;left:-50%}.van-slider--disabled{opacity:.3} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | @import '../common/index.wxss';.van-slider{position:relative;border-radius:999px;border-radius:var(--border-radius-max,999px);background-color:#e5e5e5;background-color:var(--slider-inactive-background-color,#e5e5e5)}.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 | ... | \ No newline at end of file | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { addUnit, isDef } from '../common/utils'; | ||
3 | const LONG_PRESS_START_TIME = 600; | ||
4 | const LONG_PRESS_INTERVAL = 200; | ||
5 | // add num and avoid float number | ||
6 | function add(num1, num2) { | ||
7 | const cardinal = Math.pow(10, 10); | ||
8 | return Math.round((num1 + num2) * cardinal) / cardinal; | ||
9 | } | ||
2 | VantComponent({ | 10 | VantComponent({ |
3 | field: true, | 11 | field: true, |
4 | classes: [ | 12 | classes: ['input-class', 'plus-class', 'minus-class'], |
5 | 'input-class', | ||
6 | 'plus-class', | ||
7 | 'minus-class' | ||
8 | ], | ||
9 | props: { | 13 | props: { |
10 | value: null, | 14 | value: null, |
11 | integer: Boolean, | 15 | integer: Boolean, |
12 | disabled: Boolean, | 16 | disabled: Boolean, |
13 | inputWidth: String, | 17 | inputWidth: null, |
18 | buttonSize: null, | ||
14 | asyncChange: Boolean, | 19 | asyncChange: Boolean, |
15 | disableInput: Boolean, | 20 | disableInput: Boolean, |
21 | decimalLength: { | ||
22 | type: Number, | ||
23 | value: null | ||
24 | }, | ||
16 | min: { | 25 | min: { |
17 | type: null, | 26 | type: null, |
18 | value: 1 | 27 | value: 1 |
... | @@ -24,14 +33,14 @@ VantComponent({ | ... | @@ -24,14 +33,14 @@ VantComponent({ |
24 | step: { | 33 | step: { |
25 | type: null, | 34 | type: null, |
26 | value: 1 | 35 | value: 1 |
27 | } | ||
28 | }, | 36 | }, |
29 | computed: { | 37 | showPlus: { |
30 | minusDisabled() { | 38 | type: Boolean, |
31 | return this.data.disabled || this.data.value <= this.data.min; | 39 | value: true |
32 | }, | 40 | }, |
33 | plusDisabled() { | 41 | showMinus: { |
34 | return this.data.disabled || this.data.value >= this.data.max; | 42 | type: Boolean, |
43 | value: true | ||
35 | } | 44 | } |
36 | }, | 45 | }, |
37 | watch: { | 46 | watch: { |
... | @@ -40,20 +49,39 @@ VantComponent({ | ... | @@ -40,20 +49,39 @@ VantComponent({ |
40 | return; | 49 | return; |
41 | } | 50 | } |
42 | const newValue = this.range(value); | 51 | const newValue = this.range(value); |
43 | if (typeof newValue === 'number' && value !== newValue) { | 52 | if (typeof newValue === 'number' && +this.data.value !== newValue) { |
44 | this.set({ value: newValue }); | 53 | this.setData({ value: newValue }); |
45 | } | 54 | } |
55 | }, | ||
56 | inputWidth() { | ||
57 | this.set({ | ||
58 | inputStyle: this.computeInputStyle() | ||
59 | }); | ||
60 | }, | ||
61 | buttonSize() { | ||
62 | this.set({ | ||
63 | inputStyle: this.computeInputStyle(), | ||
64 | buttonStyle: this.computeButtonStyle() | ||
65 | }); | ||
46 | } | 66 | } |
47 | }, | 67 | }, |
48 | data: { | 68 | data: { |
49 | focus: false | 69 | focus: false, |
70 | inputStyle: '', | ||
71 | buttonStyle: '' | ||
50 | }, | 72 | }, |
51 | created() { | 73 | created() { |
52 | this.set({ | 74 | this.setData({ |
53 | value: this.range(this.data.value) | 75 | value: this.range(this.data.value) |
54 | }); | 76 | }); |
55 | }, | 77 | }, |
56 | methods: { | 78 | methods: { |
79 | isDisabled(type) { | ||
80 | if (type === 'plus') { | ||
81 | return this.data.disabled || this.data.value >= this.data.max; | ||
82 | } | ||
83 | return this.data.disabled || this.data.value <= this.data.min; | ||
84 | }, | ||
57 | onFocus(event) { | 85 | onFocus(event) { |
58 | this.$emit('focus', event.detail); | 86 | this.$emit('focus', event.detail); |
59 | }, | 87 | }, |
... | @@ -64,33 +92,79 @@ VantComponent({ | ... | @@ -64,33 +92,79 @@ VantComponent({ |
64 | }, | 92 | }, |
65 | // limit value range | 93 | // limit value range |
66 | range(value) { | 94 | range(value) { |
67 | return Math.max(Math.min(this.data.max, value), this.data.min); | 95 | value = String(value).replace(/[^0-9.-]/g, ''); |
96 | // format range | ||
97 | value = value === '' ? 0 : +value; | ||
98 | value = Math.max(Math.min(this.data.max, value), this.data.min); | ||
99 | // format decimal | ||
100 | if (isDef(this.data.decimalLength)) { | ||
101 | value = value.toFixed(this.data.decimalLength); | ||
102 | } | ||
103 | return value; | ||
68 | }, | 104 | }, |
69 | onInput(event) { | 105 | onInput(event) { |
70 | const { value = '' } = event.detail || {}; | 106 | const { value = '' } = event.detail || {}; |
71 | this.triggerInput(value); | 107 | this.triggerInput(value); |
72 | }, | 108 | }, |
73 | onChange(type) { | 109 | onChange() { |
74 | if (this.data[`${type}Disabled`]) { | 110 | const { type } = this; |
111 | if (this.isDisabled(type)) { | ||
75 | this.$emit('overlimit', type); | 112 | this.$emit('overlimit', type); |
76 | return; | 113 | return; |
77 | } | 114 | } |
78 | const diff = type === 'minus' ? -this.data.step : +this.data.step; | 115 | const diff = type === 'minus' ? -this.data.step : +this.data.step; |
79 | const value = Math.round((this.data.value + diff) * 100) / 100; | 116 | const value = add(+this.data.value, diff); |
80 | this.triggerInput(this.range(value)); | 117 | this.triggerInput(this.range(value)); |
81 | this.$emit(type); | 118 | this.$emit(type); |
82 | }, | 119 | }, |
83 | onMinus() { | 120 | longPressStep() { |
84 | this.onChange('minus'); | 121 | this.longPressTimer = setTimeout(() => { |
122 | this.onChange(); | ||
123 | this.longPressStep(); | ||
124 | }, LONG_PRESS_INTERVAL); | ||
125 | }, | ||
126 | onTap(event) { | ||
127 | const { type } = event.currentTarget.dataset; | ||
128 | this.type = type; | ||
129 | this.onChange(); | ||
130 | }, | ||
131 | onTouchStart(event) { | ||
132 | clearTimeout(this.longPressTimer); | ||
133 | const { type } = event.currentTarget.dataset; | ||
134 | this.type = type; | ||
135 | this.isLongPress = false; | ||
136 | this.longPressTimer = setTimeout(() => { | ||
137 | this.isLongPress = true; | ||
138 | this.onChange(); | ||
139 | this.longPressStep(); | ||
140 | }, LONG_PRESS_START_TIME); | ||
85 | }, | 141 | }, |
86 | onPlus() { | 142 | onTouchEnd() { |
87 | this.onChange('plus'); | 143 | clearTimeout(this.longPressTimer); |
88 | }, | 144 | }, |
89 | triggerInput(value) { | 145 | triggerInput(value) { |
90 | this.set({ | 146 | this.setData({ |
91 | value: this.data.asyncChange ? this.data.value : value | 147 | value: this.data.asyncChange ? this.data.value : value |
92 | }); | 148 | }); |
93 | this.$emit('change', value); | 149 | this.$emit('change', value); |
150 | }, | ||
151 | computeInputStyle() { | ||
152 | let style = ''; | ||
153 | if (this.data.inputWidth) { | ||
154 | style = `width: ${addUnit(this.data.inputWidth)};`; | ||
155 | } | ||
156 | if (this.data.buttonSize) { | ||
157 | style += `height: ${addUnit(this.data.buttonSize)};`; | ||
158 | } | ||
159 | return style; | ||
160 | }, | ||
161 | computeButtonStyle() { | ||
162 | let style = ''; | ||
163 | const size = addUnit(this.data.buttonSize); | ||
164 | if (this.data.buttonSize) { | ||
165 | style = `width: ${size};height: ${size};`; | ||
166 | } | ||
167 | return style; | ||
94 | } | 168 | } |
95 | } | 169 | } |
96 | }); | 170 | }); | ... | ... |
... | @@ -2,15 +2,20 @@ | ... | @@ -2,15 +2,20 @@ |
2 | 2 | ||
3 | <view class="van-stepper custom-class"> | 3 | <view class="van-stepper custom-class"> |
4 | <view | 4 | <view |
5 | class="minus-class {{ utils.bem('stepper__minus', { disabled: minusDisabled }) }}" | 5 | wx:if="{{ showMinus }}" |
6 | data-type="minus" | ||
7 | style="{{ buttonStyle }}" | ||
8 | class="minus-class {{ utils.bem('stepper__minus', { disabled: disabled || value <= min }) }}" | ||
6 | hover-class="van-stepper__minus--hover" | 9 | hover-class="van-stepper__minus--hover" |
7 | hover-stay-time="70" | 10 | hover-stay-time="70" |
8 | bind:tap="onMinus" | 11 | bind:tap="onTap" |
12 | bind:touchstart="onTouchStart" | ||
13 | bind:touchend="onTouchEnd" | ||
9 | /> | 14 | /> |
10 | <input | 15 | <input |
11 | type="{{ integer ? 'number' : 'digit' }}" | 16 | type="{{ integer ? 'number' : 'digit' }}" |
12 | class="input-class {{ utils.bem('stepper__input', { disabled: disabled || disableInput }) }}" | 17 | class="input-class {{ utils.bem('stepper__input', { disabled: disabled || disableInput }) }}" |
13 | style="{{ inputWidth ? 'width: ' + inputWidth : '' }}" | 18 | style="{{ inputStyle }}" |
14 | value="{{ value }}" | 19 | value="{{ value }}" |
15 | focus="{{ focus }}" | 20 | focus="{{ focus }}" |
16 | disabled="{{ disabled || disableInput }}" | 21 | disabled="{{ disabled || disableInput }}" |
... | @@ -19,9 +24,14 @@ | ... | @@ -19,9 +24,14 @@ |
19 | bind:blur="onBlur" | 24 | bind:blur="onBlur" |
20 | /> | 25 | /> |
21 | <view | 26 | <view |
22 | class="plus-class {{ utils.bem('stepper__plus', { disabled: plusDisabled }) }}" | 27 | wx:if="{{ showPlus }}" |
28 | data-type="plus" | ||
29 | style="{{ buttonStyle }}" | ||
30 | class="plus-class {{ utils.bem('stepper__plus', { disabled: disabled || value >= max }) }}" | ||
23 | hover-class="van-stepper__plus--hover" | 31 | hover-class="van-stepper__plus--hover" |
24 | hover-stay-time="70" | 32 | hover-stay-time="70" |
25 | bind:tap="onPlus" | 33 | bind:tap="onTap" |
34 | bind:touchstart="onTouchStart" | ||
35 | bind:touchend="onTouchEnd" | ||
26 | /> | 36 | /> |
27 | </view> | 37 | </view> | ... | ... |
1 | @import '../common/index.wxss';.van-stepper{font-size:0}.van-stepper__minus,.van-stepper__plus{position:relative;display:inline-block;width:28px;height:28px;padding:5px;margin:1px;vertical-align:middle;background-color:#f2f3f5;border:0;box-sizing:border-box}.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:#333;content:""}.van-stepper__minus--hover,.van-stepper__plus--hover{background-color:#e8e8e8}.van-stepper__minus--disabled,.van-stepper__plus--disabled{background-color:#f7f8fa}.van-stepper__minus--disabled:after,.van-stepper__minus--disabled:before,.van-stepper__plus--disabled:after,.van-stepper__plus--disabled:before{background-color:#c9c9c9}.van-stepper__minus--disabled.van-stepper__minus--hover,.van-stepper__minus--disabled.van-stepper__plus--hover,.van-stepper__plus--disabled.van-stepper__minus--hover,.van-stepper__plus--disabled.van-stepper__plus--hover{background-color:#f7f8fa}.van-stepper__minus{border-radius:4px 0 0 4px}.van-stepper__minus:after{display:none}.van-stepper__plus{border-radius:0 4px 4px 0}.van-stepper__input{display:inline-block;width:30px;height:26px;padding:1px;margin:1px;font-size:14px;color:#333;text-align:center;vertical-align:middle;background-color:#f2f3f5;border:0;border-width:1px 0;border-radius:0;box-sizing:initial;-webkit-appearance:none}.van-stepper__input--disabled{color:#c9c9c9;background-color:#f2f3f5} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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;content:"";background-color:#323233;background-color:var(--text-color,#323233)}.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__minus--disabled:after,.van-stepper__minus--disabled:before,.van-stepper__plus--disabled,.van-stepper__plus--disabled.van-stepper__minus--hover,.van-stepper__plus--disabled.van-stepper__plus--hover,.van-stepper__plus--disabled:after,.van-stepper__plus--disabled:before{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 | ... | \ No newline at end of file | ... | ... |
... | @@ -12,6 +12,11 @@ VantComponent({ | ... | @@ -12,6 +12,11 @@ VantComponent({ |
12 | activeColor: { | 12 | activeColor: { |
13 | type: String, | 13 | type: String, |
14 | value: GREEN | 14 | value: GREEN |
15 | } | 15 | }, |
16 | activeIcon: { | ||
17 | type: String, | ||
18 | value: 'checked' | ||
19 | }, | ||
20 | inactiveIcon: String | ||
16 | } | 21 | } |
17 | }); | 22 | }); | ... | ... |
... | @@ -12,10 +12,26 @@ | ... | @@ -12,10 +12,26 @@ |
12 | <view>{{ item.desc }}</view> | 12 | <view>{{ item.desc }}</view> |
13 | </view> | 13 | </view> |
14 | <view class="van-step__circle-container"> | 14 | <view class="van-step__circle-container"> |
15 | <view class="van-step__circle" wx:if="{{ index !== active }}" style="{{ index < active ? 'background-color: ' + activeColor : '' }}" /> | 15 | <block wx:if="{{ index !== active }}"> |
16 | <van-icon wx:else name="checked" color="{{ activeColor }}" custom-class="van-step__active" /> | 16 | <van-icon |
17 | wx:if="{{ inactiveIcon }}" | ||
18 | color="#969799" | ||
19 | name="{{ inactiveIcon }}" | ||
20 | custom-class="van-step__icon" | ||
21 | /> | ||
22 | <view | ||
23 | wx:else | ||
24 | class="van-step__circle" | ||
25 | style="{{ index < active ? 'background-color: ' + activeColor : '' }}" | ||
26 | /> | ||
27 | </block> | ||
28 | |||
29 | <van-icon wx:else name="{{ activeIcon }}" color="{{ activeColor }}" custom-class="van-step__icon" /> | ||
17 | </view> | 30 | </view> |
18 | <view wx:if="{{ index !== steps.length - 1 }}" class="van-step__line" style="{{ index < active ? 'background-color: ' + activeColor : '' }}" /> | 31 | <view |
32 | wx:if="{{ index !== steps.length - 1 }}" | ||
33 | class="van-step__line" style="{{ index < active ? 'background-color: ' + activeColor : '' }}" | ||
34 | /> | ||
19 | </view> | 35 | </view> |
20 | </view> | 36 | </view> |
21 | </view> | 37 | </view> | ... | ... |
1 | @import '../common/index.wxss';.van-steps{overflow:hidden;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;color:#999}.van-step--finish{color:#333}.van-step__circle{width:5px;height:5px;background-color:#999;border-radius:50%}.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;padding:0 8px;background-color:#fff;-webkit-transform:translate3d(-50%,50%,0);transform:translate3d(-50%,50%,0)}.van-step--horizontal .van-step__title{display:inline-block;font-size:12px;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.van-step--horizontal .van-step__line{position:absolute;right:0;bottom:6px;left:0;height:1px;background-color:#eee;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0)}.van-step--horizontal.van-step--process{color:#333}.van-step--horizontal.van-step--process .van-step__active{display:block;font-size:12px;line-height:1}.van-step--vertical{padding:10px 10px 10px 0;font-size:14px;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;background-color:#fff;content:""}.van-step--vertical .van-step__active,.van-step--vertical .van-step__circle,.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__active{font-size:12px;line-height:1}.van-step--vertical .van-step__line{z-index:1;width:1px;height:100%;background-color:#eee;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
src/ui/vant-weapp/sticky/index.d.ts
0 → 100755
1 | export {}; |
src/ui/vant-weapp/sticky/index.js
0 → 100755
1 | import { VantComponent } from '../common/component'; | ||
2 | VantComponent({ | ||
3 | props: { | ||
4 | zIndex: { | ||
5 | type: Number, | ||
6 | value: 99 | ||
7 | }, | ||
8 | offsetTop: { | ||
9 | type: Number, | ||
10 | value: 0 | ||
11 | }, | ||
12 | disabled: Boolean | ||
13 | }, | ||
14 | data: { | ||
15 | wrapStyle: '', | ||
16 | containerStyle: '' | ||
17 | }, | ||
18 | methods: { | ||
19 | setStyle() { | ||
20 | const { offsetTop, height, fixed, zIndex } = this.data; | ||
21 | if (fixed) { | ||
22 | this.setData({ | ||
23 | wrapStyle: `top: ${offsetTop}px;`, | ||
24 | containerStyle: `height: ${height}px; z-index: ${zIndex};` | ||
25 | }); | ||
26 | } | ||
27 | else { | ||
28 | this.setData({ | ||
29 | wrapStyle: '', | ||
30 | containerStyle: '' | ||
31 | }); | ||
32 | } | ||
33 | }, | ||
34 | observerContentScroll() { | ||
35 | const { offsetTop } = this.data; | ||
36 | const intersectionObserver = this.createIntersectionObserver({ | ||
37 | thresholds: [0, 1] | ||
38 | }); | ||
39 | this.intersectionObserver = intersectionObserver; | ||
40 | intersectionObserver.relativeToViewport({ top: -offsetTop }); | ||
41 | intersectionObserver.observe('.van-sticky', (res) => { | ||
42 | if (this.data.disabled) { | ||
43 | return; | ||
44 | } | ||
45 | // @ts-ignore | ||
46 | const { top, height } = res.boundingClientRect; | ||
47 | const fixed = top <= offsetTop; | ||
48 | this.$emit('scroll', { | ||
49 | scrollTop: top, | ||
50 | isFixed: fixed | ||
51 | }); | ||
52 | this.setData({ fixed, height }); | ||
53 | wx.nextTick(() => { | ||
54 | this.setStyle(); | ||
55 | }); | ||
56 | }); | ||
57 | } | ||
58 | }, | ||
59 | mounted() { | ||
60 | this.observerContentScroll(); | ||
61 | }, | ||
62 | destroyed() { | ||
63 | this.intersectionObserver.disconnect(); | ||
64 | } | ||
65 | }); |
src/ui/vant-weapp/sticky/index.json
0 → 100755
src/ui/vant-weapp/sticky/index.wxml
0 → 100755
src/ui/vant-weapp/sticky/index.wxss
0 → 100755
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 | ... | \ No newline at end of file |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { safeArea } from '../mixins/safe-area'; | ||
3 | VantComponent({ | 2 | VantComponent({ |
4 | mixins: [safeArea()], | ||
5 | classes: [ | 3 | classes: [ |
6 | 'bar-class', | 4 | 'bar-class', |
7 | 'price-class', | 5 | 'price-class', |
8 | 'button-class' | 6 | 'button-class' |
9 | ], | 7 | ], |
10 | props: { | 8 | props: { |
11 | tip: null, | 9 | tip: { |
10 | type: null, | ||
11 | observer: 'updateTip' | ||
12 | }, | ||
13 | tipIcon: String, | ||
12 | type: Number, | 14 | type: Number, |
13 | price: null, | 15 | price: { |
16 | type: null, | ||
17 | observer: 'updatePrice' | ||
18 | }, | ||
14 | label: String, | 19 | label: String, |
15 | loading: Boolean, | 20 | loading: Boolean, |
16 | disabled: Boolean, | 21 | disabled: Boolean, |
... | @@ -22,21 +27,29 @@ VantComponent({ | ... | @@ -22,21 +27,29 @@ VantComponent({ |
22 | buttonType: { | 27 | buttonType: { |
23 | type: String, | 28 | type: String, |
24 | value: 'danger' | 29 | value: 'danger' |
25 | } | ||
26 | }, | ||
27 | computed: { | ||
28 | hasPrice() { | ||
29 | return typeof this.data.price === 'number'; | ||
30 | }, | 30 | }, |
31 | priceStr() { | 31 | decimalLength: { |
32 | return (this.data.price / 100).toFixed(2); | 32 | type: Number, |
33 | value: 2, | ||
34 | observer: 'updatePrice' | ||
33 | }, | 35 | }, |
34 | tipStr() { | 36 | suffixLabel: String, |
35 | const { tip } = this.data; | 37 | safeAreaInsetBottom: { |
36 | return typeof tip === 'string' ? tip : ''; | 38 | type: Boolean, |
39 | value: true | ||
37 | } | 40 | } |
38 | }, | 41 | }, |
39 | methods: { | 42 | methods: { |
43 | updatePrice() { | ||
44 | const { price, decimalLength } = this.data; | ||
45 | this.setData({ | ||
46 | hasPrice: typeof price === 'number', | ||
47 | priceStr: (price / 100).toFixed(decimalLength) | ||
48 | }); | ||
49 | }, | ||
50 | updateTip() { | ||
51 | this.setData({ hasTip: typeof this.data.tip === 'string' }); | ||
52 | }, | ||
40 | onSubmit(event) { | 53 | onSubmit(event) { |
41 | this.$emit('submit', event.detail); | 54 | this.$emit('submit', event.detail); |
42 | } | 55 | } | ... | ... |
... | @@ -3,19 +3,28 @@ | ... | @@ -3,19 +3,28 @@ |
3 | <view class="van-submit-bar custom-class"> | 3 | <view class="van-submit-bar custom-class"> |
4 | <slot name="top" /> | 4 | <slot name="top" /> |
5 | 5 | ||
6 | <view wx:if="{{ tip }}" class="van-submit-bar__tip"> | 6 | <view class="van-submit-bar__tip"> |
7 | {{ tipStr }}<slot name="tip" /> | 7 | <van-icon |
8 | wx:if="{{ tipIcon }}" | ||
9 | size="12px" | ||
10 | name="{{ tipIcon }}" | ||
11 | custom-class="van-submit-bar__tip-icon" | ||
12 | /> | ||
13 | <view wx:if="{{ hasTip }}" class="van-submit-bar__tip-text"> | ||
14 | {{ tip }} | ||
15 | </view> | ||
16 | <slot name="tip" /> | ||
8 | </view> | 17 | </view> |
9 | 18 | ||
10 | <view class="bar-class {{ utils.bem('submit-bar__bar', { safe: safeAreaInsetBottom && isIPhoneX }) }}"> | 19 | <view class="bar-class {{ utils.bem('submit-bar__bar', { safe: safeAreaInsetBottom }) }}"> |
11 | <slot /> | 20 | <slot /> |
12 | <view class="van-submit-bar__text"> | 21 | <view wx:if="{{ hasPrice }}" class="van-submit-bar__text"> |
13 | <block wx:if="{{ hasPrice }}"> | ||
14 | <text>{{ label || '合计:' }}</text> | 22 | <text>{{ label || '合计:' }}</text> |
15 | <text class="van-submit-bar__price price-class"> | 23 | <text class="van-submit-bar__price price-class"> |
16 | <text class="van-submit-bar__currency">{{ currency }}</text> {{ priceStr }} | 24 | <text class="van-submit-bar__currency">{{ currency }} </text> |
25 | <text>{{ priceStr }}</text> | ||
17 | </text> | 26 | </text> |
18 | </block> | 27 | <text class="van-submit-bar__suffix-label">{{ suffixLabel }}</text> |
19 | </view> | 28 | </view> |
20 | <van-button | 29 | <van-button |
21 | square | 30 | square | ... | ... |
1 | @import '../common/index.wxss';.van-submit-bar{z-index:100;position:fixed;bottom:0;left:0;width:100%;-webkit-user-select:none;user-select:none}.van-submit-bar__tip{padding:10px;color:#f56723;font-size:12px;line-height:18px;background-color:#fff7cc}.van-submit-bar__bar{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;height:50px;background-color:#fff;font-size:14px}.van-submit-bar__bar--safe{padding-bottom:34px}.van-submit-bar__text{-webkit-flex:1;flex:1;color:#333;font-weight:500;text-align:right}.van-submit-bar__price{color:#f44;font-size:18px;padding-right:12px}.van-submit-bar__currency{font-size:14px}.van-submit-bar__button button{width:110px} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { touch } from '../mixins/touch'; | 2 | import { touch } from '../mixins/touch'; |
3 | const THRESHOLD = 0.3; | 3 | const THRESHOLD = 0.3; |
4 | let ARRAY = []; | ||
4 | VantComponent({ | 5 | VantComponent({ |
5 | props: { | 6 | props: { |
6 | disabled: Boolean, | 7 | disabled: Boolean, |
... | @@ -12,14 +13,22 @@ VantComponent({ | ... | @@ -12,14 +13,22 @@ VantComponent({ |
12 | type: Number, | 13 | type: Number, |
13 | value: 0 | 14 | value: 0 |
14 | }, | 15 | }, |
15 | asyncClose: Boolean | 16 | asyncClose: Boolean, |
17 | name: { | ||
18 | type: [Number, String], | ||
19 | value: '' | ||
20 | } | ||
16 | }, | 21 | }, |
17 | mixins: [touch], | 22 | mixins: [touch], |
18 | data: { | 23 | data: { |
19 | catchMove: true | 24 | catchMove: false |
20 | }, | 25 | }, |
21 | created() { | 26 | created() { |
22 | this.offset = 0; | 27 | this.offset = 0; |
28 | ARRAY.push(this); | ||
29 | }, | ||
30 | destroyed() { | ||
31 | ARRAY = ARRAY.filter(item => item !== this); | ||
23 | }, | 32 | }, |
24 | methods: { | 33 | methods: { |
25 | open(position) { | 34 | open(position) { |
... | @@ -35,8 +44,8 @@ VantComponent({ | ... | @@ -35,8 +44,8 @@ VantComponent({ |
35 | const transform = `translate3d(${offset}px, 0, 0)`; | 44 | const transform = `translate3d(${offset}px, 0, 0)`; |
36 | const transition = this.draging | 45 | const transition = this.draging |
37 | ? 'none' | 46 | ? 'none' |
38 | : '.6s cubic-bezier(0.18, 0.89, 0.32, 1)'; | 47 | : 'transform .6s cubic-bezier(0.18, 0.89, 0.32, 1)'; |
39 | this.set({ | 48 | this.setData({ |
40 | wrapperStyle: ` | 49 | wrapperStyle: ` |
41 | -webkit-transform: ${transform}; | 50 | -webkit-transform: ${transform}; |
42 | -webkit-transition: ${transition}; | 51 | -webkit-transition: ${transition}; |
... | @@ -57,11 +66,17 @@ VantComponent({ | ... | @@ -57,11 +66,17 @@ VantComponent({ |
57 | else { | 66 | else { |
58 | this.swipeMove(0); | 67 | this.swipeMove(0); |
59 | } | 68 | } |
69 | this.setData({ catchMove: false }); | ||
60 | }, | 70 | }, |
61 | startDrag(event) { | 71 | startDrag(event) { |
62 | if (this.data.disabled) { | 72 | if (this.data.disabled) { |
63 | return; | 73 | return; |
64 | } | 74 | } |
75 | ARRAY.forEach(item => { | ||
76 | if (item !== this) { | ||
77 | item.close(); | ||
78 | } | ||
79 | }); | ||
65 | this.draging = true; | 80 | this.draging = true; |
66 | this.startOffset = this.offset; | 81 | this.startOffset = this.offset; |
67 | this.firstDirection = ''; | 82 | this.firstDirection = ''; |
... | @@ -75,7 +90,7 @@ VantComponent({ | ... | @@ -75,7 +90,7 @@ VantComponent({ |
75 | this.touchMove(event); | 90 | this.touchMove(event); |
76 | if (!this.firstDirection) { | 91 | if (!this.firstDirection) { |
77 | this.firstDirection = this.direction; | 92 | this.firstDirection = this.direction; |
78 | this.set({ catchMove: this.firstDirection === 'horizontal' }); | 93 | this.setData({ catchMove: this.firstDirection === 'horizontal' }); |
79 | } | 94 | } |
80 | if (this.firstDirection === 'vertical') { | 95 | if (this.firstDirection === 'vertical') { |
81 | return; | 96 | return; |
... | @@ -102,7 +117,7 @@ VantComponent({ | ... | @@ -102,7 +117,7 @@ VantComponent({ |
102 | return; | 117 | return; |
103 | } | 118 | } |
104 | if (this.data.asyncClose) { | 119 | if (this.data.asyncClose) { |
105 | this.$emit('close', { position, instance: this }); | 120 | this.$emit('close', { position, instance: this, name: this.data.name }); |
106 | } | 121 | } |
107 | else { | 122 | else { |
108 | this.swipeMove(0); | 123 | this.swipeMove(0); | ... | ... |
1 | import { VantComponent } from '../common/component'; | ||
2 | VantComponent({ | ||
3 | field: true, | ||
4 | props: { | ||
5 | value: null, | ||
6 | title: String, | ||
7 | border: Boolean, | ||
8 | checked: Boolean, | ||
9 | loading: Boolean, | ||
10 | disabled: Boolean, | ||
11 | activeColor: String, | ||
12 | inactiveColor: String, | ||
13 | size: { | ||
14 | type: String, | ||
15 | value: '24px' | ||
16 | }, | ||
17 | activeValue: { | ||
18 | type: null, | ||
19 | value: true | ||
20 | }, | ||
21 | inactiveValue: { | ||
22 | type: null, | ||
23 | value: false | ||
24 | } | ||
25 | }, | ||
26 | watch: { | ||
27 | checked(value) { | ||
28 | this.set({ value }); | ||
29 | } | ||
30 | }, | ||
31 | created() { | ||
32 | this.set({ value: this.data.checked }); | ||
33 | }, | ||
34 | methods: { | ||
35 | onChange(event) { | ||
36 | this.$emit('change', event.detail); | ||
37 | } | ||
38 | } | ||
39 | }); |
1 | <van-cell | ||
2 | center | ||
3 | title="{{ title }}" | ||
4 | border="{{ border }}" | ||
5 | custom-class="van-switch-cell" | ||
6 | > | ||
7 | <van-switch | ||
8 | size="{{ size }}" | ||
9 | checked="{{ checked }}" | ||
10 | loading="{{ loading }}" | ||
11 | disabled="{{ disabled }}" | ||
12 | active-color="{{ activeColor }}" | ||
13 | inactive-color="{{ inactiveColor }}" | ||
14 | active-value="{{ activeValue }}" | ||
15 | inactive-value="{{ inactiveValue }}" | ||
16 | custom-class="van-switch-cell__switch" | ||
17 | bind:change="onChange" | ||
18 | /> | ||
19 | </van-cell> |
1 | @import '../common/index.wxss';.van-switch-cell{padding-top:9px;padding-bottom:9px}.van-switch-cell__switch{vertical-align:middle} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { BLUE, GRAY_DARK } from '../common/color'; | ||
2 | VantComponent({ | 3 | VantComponent({ |
3 | field: true, | 4 | field: true, |
4 | classes: ['node-class'], | 5 | classes: ['node-class'], |
... | @@ -23,13 +24,20 @@ VantComponent({ | ... | @@ -23,13 +24,20 @@ VantComponent({ |
23 | }, | 24 | }, |
24 | watch: { | 25 | watch: { |
25 | checked(value) { | 26 | checked(value) { |
26 | this.set({ value }); | 27 | const loadingColor = this.getLoadingColor(value); |
28 | this.setData({ value, loadingColor }); | ||
27 | } | 29 | } |
28 | }, | 30 | }, |
29 | created() { | 31 | created() { |
30 | this.set({ value: this.data.checked }); | 32 | const { checked: value } = this.data; |
33 | const loadingColor = this.getLoadingColor(value); | ||
34 | this.setData({ value, loadingColor }); | ||
31 | }, | 35 | }, |
32 | methods: { | 36 | methods: { |
37 | getLoadingColor(checked) { | ||
38 | const { activeColor, inactiveColor } = this.data; | ||
39 | return checked ? activeColor || BLUE : inactiveColor || GRAY_DARK; | ||
40 | }, | ||
33 | onClick() { | 41 | onClick() { |
34 | const { activeValue, inactiveValue } = this.data; | 42 | const { activeValue, inactiveValue } = this.data; |
35 | if (!this.data.disabled && !this.data.loading) { | 43 | if (!this.data.disabled && !this.data.loading) { | ... | ... |
... | @@ -6,6 +6,6 @@ | ... | @@ -6,6 +6,6 @@ |
6 | bind:tap="onClick" | 6 | bind:tap="onClick" |
7 | > | 7 | > |
8 | <view class="van-switch__node node-class"> | 8 | <view class="van-switch__node node-class"> |
9 | <van-loading wx:if="{{ loading }}" size="50%" custom-class="van-switch__loading" /> | 9 | <van-loading wx:if="{{ loading }}" color="{{ loadingColor }}" custom-class="van-switch__loading" /> |
10 | </view> | 10 | </view> |
11 | </view> | 11 | </view> | ... | ... |
1 | @import '../common/index.wxss';.van-switch{display:inline-block;position:relative;width:2em;border:1px solid rgba(0,0,0,.1);border-radius:1em;box-sizing:initial;transition:background-color .3s}.van-switch,.van-switch__node{height:1em;background-color:#fff}.van-switch__node{top:0;left:0;position:absolute;border-radius:100%;width:1em;z-index:1;transition:.3s;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)}.van-switch__loading{top:25%;left:25%;position:absolute!important}.van-switch--on{background-color:#1989fa}.van-switch--on .van-switch__node{-webkit-transform:translateX(1em);transform:translateX(1em)}.van-switch--disabled{opacity:.4} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
... | @@ -2,14 +2,24 @@ import { VantComponent } from '../common/component'; | ... | @@ -2,14 +2,24 @@ import { VantComponent } from '../common/component'; |
2 | VantComponent({ | 2 | VantComponent({ |
3 | relation: { | 3 | relation: { |
4 | name: 'tabs', | 4 | name: 'tabs', |
5 | type: 'ancestor' | 5 | type: 'ancestor', |
6 | linked(target) { | ||
7 | this.parent = target; | ||
8 | }, | ||
9 | unlinked() { | ||
10 | this.parent = null; | ||
11 | } | ||
6 | }, | 12 | }, |
7 | props: { | 13 | props: { |
8 | dot: Boolean, | 14 | dot: Boolean, |
9 | info: null, | 15 | info: null, |
10 | title: String, | 16 | title: String, |
11 | disabled: Boolean, | 17 | disabled: Boolean, |
12 | titleStyle: String | 18 | titleStyle: String, |
19 | name: { | ||
20 | type: [Number, String], | ||
21 | value: '', | ||
22 | } | ||
13 | }, | 23 | }, |
14 | data: { | 24 | data: { |
15 | width: null, | 25 | width: null, |
... | @@ -25,10 +35,18 @@ VantComponent({ | ... | @@ -25,10 +35,18 @@ VantComponent({ |
25 | titleStyle: 'update' | 35 | titleStyle: 'update' |
26 | }, | 36 | }, |
27 | methods: { | 37 | methods: { |
38 | setComputedName() { | ||
39 | this.computedName = this.data.name || this.index; | ||
40 | }, | ||
41 | getComputedName() { | ||
42 | if (this.data.name !== '') { | ||
43 | return this.data.name; | ||
44 | } | ||
45 | return this.index; | ||
46 | }, | ||
28 | update() { | 47 | update() { |
29 | const parent = this.getRelationNodes('../tabs/index')[0]; | 48 | if (this.parent) { |
30 | if (parent) { | 49 | this.parent.updateTabs(); |
31 | parent.updateTabs(); | ||
32 | } | 50 | } |
33 | } | 51 | } |
34 | } | 52 | } | ... | ... |
... | @@ -2,15 +2,13 @@ import { VantComponent } from '../common/component'; | ... | @@ -2,15 +2,13 @@ import { VantComponent } from '../common/component'; |
2 | VantComponent({ | 2 | VantComponent({ |
3 | props: { | 3 | props: { |
4 | info: null, | 4 | info: null, |
5 | name: null, | ||
5 | icon: String, | 6 | icon: String, |
6 | dot: Boolean | 7 | dot: Boolean |
7 | }, | 8 | }, |
8 | relation: { | 9 | relation: { |
9 | name: 'tabbar', | 10 | name: 'tabbar', |
10 | type: 'ancestor', | 11 | type: 'ancestor' |
11 | linked(target) { | ||
12 | this.parent = target; | ||
13 | } | ||
14 | }, | 12 | }, |
15 | data: { | 13 | data: { |
16 | active: false | 14 | active: false |
... | @@ -22,11 +20,28 @@ VantComponent({ | ... | @@ -22,11 +20,28 @@ VantComponent({ |
22 | } | 20 | } |
23 | this.$emit('click'); | 21 | this.$emit('click'); |
24 | }, | 22 | }, |
25 | setActive({ active, color }) { | 23 | updateFromParent() { |
26 | if (this.data.active !== active) { | 24 | const { parent } = this; |
27 | return this.set({ active, color }); | 25 | if (!parent) { |
26 | return; | ||
27 | } | ||
28 | const index = parent.children.indexOf(this); | ||
29 | const parentData = parent.data; | ||
30 | const { data } = this; | ||
31 | const active = (data.name || index) === parentData.active; | ||
32 | const patch = {}; | ||
33 | if (active !== data.active) { | ||
34 | patch.active = active; | ||
35 | } | ||
36 | if (parentData.activeColor !== data.activeColor) { | ||
37 | patch.activeColor = parentData.activeColor; | ||
38 | } | ||
39 | if (parentData.inactiveColor !== data.inactiveColor) { | ||
40 | patch.inactiveColor = parentData.inactiveColor; | ||
28 | } | 41 | } |
29 | return Promise.resolve(); | 42 | return Object.keys(patch).length > 0 |
43 | ? this.set(patch) | ||
44 | : Promise.resolve(); | ||
30 | } | 45 | } |
31 | } | 46 | } |
32 | }); | 47 | }); | ... | ... |
... | @@ -2,14 +2,14 @@ | ... | @@ -2,14 +2,14 @@ |
2 | 2 | ||
3 | <view | 3 | <view |
4 | class="{{ utils.bem('tabbar-item', { active }) }} custom-class" | 4 | class="{{ utils.bem('tabbar-item', { active }) }} custom-class" |
5 | style="{{ active && color ? 'color: ' + color : '' }}" | 5 | style="color: {{ active ? activeColor : inactiveColor }}" |
6 | bind:tap="onClick" | 6 | bind:tap="onClick" |
7 | > | 7 | > |
8 | <view class="{{ utils.bem('tabbar-item__icon', { dot }) }}"> | 8 | <view class="van-tabbar-item__icon"> |
9 | <van-icon | 9 | <van-icon |
10 | wx:if="{{ icon }}" | 10 | wx:if="{{ icon }}" |
11 | name="{{ icon }}" | 11 | name="{{ icon }}" |
12 | customStyle="display: block" | 12 | custom-class="van-tabbar-item__icon__inner" |
13 | /> | 13 | /> |
14 | <block wx:else> | 14 | <block wx:else> |
15 | <slot | 15 | <slot |
... | @@ -19,9 +19,9 @@ | ... | @@ -19,9 +19,9 @@ |
19 | <slot wx:else name="icon" /> | 19 | <slot wx:else name="icon" /> |
20 | </block> | 20 | </block> |
21 | <van-info | 21 | <van-info |
22 | wx:if="{{ info !== null }}" | 22 | dot="{{ dot }}" |
23 | info="{{ info }}" | 23 | info="{{ info }}" |
24 | custom-style="margin-top: 2px" | 24 | custom-class="van-tabbar-item__info" |
25 | /> | 25 | /> |
26 | </view> | 26 | </view> |
27 | <view class="van-tabbar-item__text"> | 27 | <view class="van-tabbar-item__text"> | ... | ... |
1 | @import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-tabbar-item{color:#7d7e80;height:100%;display:-webkit-flex;display:flex;line-height:1;font-size:12px;-webkit-align-items:center;align-items:center;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center;justify-content:center}.van-tabbar-item__icon{font-size:18px;margin-bottom:5px;position:relative}.van-tabbar-item__icon--dot:after{top:0;right:-8px;width:8px;height:8px;content:" ";position:absolute;border-radius:100%;background-color:#f44}.van-tabbar-item__icon image{width:30px;height:18px;display:block}.van-tabbar-item--active{color:#1989fa} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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:#7d7e80;color:var(--tabbar-item-text-color,#7d7e80);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 | ... | \ No newline at end of file | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { safeArea } from '../mixins/safe-area'; | ||
3 | VantComponent({ | 2 | VantComponent({ |
4 | mixins: [safeArea()], | ||
5 | relation: { | 3 | relation: { |
6 | name: 'tabbar-item', | 4 | name: 'tabbar-item', |
7 | type: 'descendant', | 5 | type: 'descendant', |
8 | linked(target) { | 6 | linked(target) { |
9 | this.children = this.children || []; | ||
10 | this.children.push(target); | 7 | this.children.push(target); |
11 | this.setActiveItem(); | 8 | target.parent = this; |
9 | target.updateFromParent(); | ||
12 | }, | 10 | }, |
13 | unlinked(target) { | 11 | unlinked(target) { |
14 | this.children = this.children || []; | 12 | this.children = this.children.filter((item) => item !== target); |
15 | this.children = this.children.filter(item => item !== target); | 13 | this.updateChildren(); |
16 | this.setActiveItem(); | ||
17 | } | 14 | } |
18 | }, | 15 | }, |
19 | props: { | 16 | props: { |
20 | active: Number, | 17 | active: { |
21 | activeColor: String, | 18 | type: null, |
19 | observer: 'updateChildren' | ||
20 | }, | ||
21 | activeColor: { | ||
22 | type: String, | ||
23 | observer: 'updateChildren' | ||
24 | }, | ||
25 | inactiveColor: { | ||
26 | type: String, | ||
27 | observer: 'updateChildren' | ||
28 | }, | ||
22 | fixed: { | 29 | fixed: { |
23 | type: Boolean, | 30 | type: Boolean, |
24 | value: true | 31 | value: true |
25 | }, | 32 | }, |
33 | border: { | ||
34 | type: Boolean, | ||
35 | value: true | ||
36 | }, | ||
26 | zIndex: { | 37 | zIndex: { |
27 | type: Number, | 38 | type: Number, |
28 | value: 1 | 39 | value: 1 |
29 | } | ||
30 | }, | 40 | }, |
31 | watch: { | 41 | safeAreaInsetBottom: { |
32 | active(active) { | 42 | type: Boolean, |
33 | this.currentActive = active; | 43 | value: true |
34 | this.setActiveItem(); | ||
35 | } | 44 | } |
36 | }, | 45 | }, |
37 | created() { | 46 | beforeCreate() { |
38 | this.currentActive = this.data.active; | 47 | this.children = []; |
39 | }, | 48 | }, |
40 | methods: { | 49 | methods: { |
41 | setActiveItem() { | 50 | updateChildren() { |
42 | if (!Array.isArray(this.children) || !this.children.length) { | 51 | const { children } = this; |
52 | if (!Array.isArray(children) || !children.length) { | ||
43 | return Promise.resolve(); | 53 | return Promise.resolve(); |
44 | } | 54 | } |
45 | return Promise.all(this.children.map((item, index) => item.setActive({ | 55 | return Promise.all(children.map((child) => child.updateFromParent())); |
46 | active: index === this.currentActive, | ||
47 | color: this.data.activeColor | ||
48 | }))); | ||
49 | }, | 56 | }, |
50 | onChange(child) { | 57 | onChange(child) { |
51 | const active = (this.children || []).indexOf(child); | 58 | const index = this.children.indexOf(child); |
52 | if (active !== this.currentActive && active !== -1) { | 59 | const active = child.data.name || index; |
53 | this.currentActive = active; | 60 | if (active !== this.data.active) { |
54 | this.setActiveItem().then(() => { | ||
55 | this.$emit('change', active); | 61 | this.$emit('change', active); |
56 | }); | ||
57 | } | 62 | } |
58 | } | 63 | } |
59 | } | 64 | } | ... | ... |
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | 1 | <wxs src="../wxs/utils.wxs" module="utils" /> |
2 | 2 | ||
3 | <view | 3 | <view |
4 | class="custom-class van-hairline--top-bottom {{ utils.bem('tabbar', { fixed, safe: isIPhoneX && safeAreaInsetBottom }) }}" | 4 | class="custom-class {{ border ? 'van-hairline--top-bottom' : '' }} {{ utils.bem('tabbar', { fixed, safe: safeAreaInsetBottom }) }}" |
5 | style="{{ zIndex ? 'z-index: ' + zIndex : '' }}" | 5 | style="{{ zIndex ? 'z-index: ' + zIndex : '' }}" |
6 | > | 6 | > |
7 | <slot /> | 7 | <slot /> | ... | ... |
1 | @import '../common/index.wxss';.van-tabbar{display:-webkit-flex;display:flex;width:100%;height:50px;background-color:#fff}.van-tabbar--fixed{position:fixed;bottom:0;left:0}.van-tabbar--safe{padding-bottom:34px} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { touch } from '../mixins/touch'; | 2 | import { touch } from '../mixins/touch'; |
3 | import { nextTick, isDef, addUnit } from '../common/utils'; | ||
3 | VantComponent({ | 4 | VantComponent({ |
4 | mixins: [touch], | 5 | mixins: [touch], |
5 | classes: ['nav-class', 'tab-class', 'tab-active-class', 'line-class'], | 6 | classes: ['nav-class', 'tab-class', 'tab-active-class', 'line-class'], |
... | @@ -7,33 +8,52 @@ VantComponent({ | ... | @@ -7,33 +8,52 @@ VantComponent({ |
7 | name: 'tab', | 8 | name: 'tab', |
8 | type: 'descendant', | 9 | type: 'descendant', |
9 | linked(child) { | 10 | linked(child) { |
10 | this.child.push(child); | 11 | child.index = this.children.length; |
12 | this.children.push(child); | ||
11 | this.updateTabs(this.data.tabs.concat(child.data)); | 13 | this.updateTabs(this.data.tabs.concat(child.data)); |
12 | }, | 14 | }, |
13 | unlinked(child) { | 15 | unlinked(child) { |
14 | const index = this.child.indexOf(child); | 16 | const index = this.children.indexOf(child); |
15 | const { tabs } = this.data; | 17 | const { tabs } = this.data; |
16 | tabs.splice(index, 1); | 18 | tabs.splice(index, 1); |
17 | this.child.splice(index, 1); | 19 | this.children.splice(index, 1); |
20 | let i = index; | ||
21 | while (i >= 0 && i < this.children.length) { | ||
22 | const currentChild = this.children[i]; | ||
23 | currentChild.index--; | ||
24 | i++; | ||
25 | } | ||
18 | this.updateTabs(tabs); | 26 | this.updateTabs(tabs); |
19 | } | 27 | } |
20 | }, | 28 | }, |
21 | props: { | 29 | props: { |
22 | color: String, | 30 | color: { |
31 | type: String, | ||
32 | observer: 'setLine' | ||
33 | }, | ||
23 | sticky: Boolean, | 34 | sticky: Boolean, |
24 | animated: Boolean, | 35 | animated: { |
36 | type: Boolean, | ||
37 | observer: 'setTrack' | ||
38 | }, | ||
25 | swipeable: Boolean, | 39 | swipeable: Boolean, |
26 | lineWidth: { | 40 | lineWidth: { |
27 | type: Number, | 41 | type: [String, Number], |
28 | value: -1 | 42 | value: -1, |
43 | observer: 'setLine' | ||
29 | }, | 44 | }, |
30 | lineHeight: { | 45 | lineHeight: { |
31 | type: Number, | 46 | type: [String, Number], |
32 | value: -1 | 47 | value: -1, |
48 | observer: 'setLine' | ||
33 | }, | 49 | }, |
34 | active: { | 50 | active: { |
35 | type: Number, | 51 | type: [String, Number], |
36 | value: 0 | 52 | value: 0, |
53 | observer(value) { | ||
54 | this.currentName = value; | ||
55 | this.setActiveTab(); | ||
56 | } | ||
37 | }, | 57 | }, |
38 | type: { | 58 | type: { |
39 | type: String, | 59 | type: String, |
... | @@ -53,7 +73,12 @@ VantComponent({ | ... | @@ -53,7 +73,12 @@ VantComponent({ |
53 | }, | 73 | }, |
54 | swipeThreshold: { | 74 | swipeThreshold: { |
55 | type: Number, | 75 | type: Number, |
56 | value: 4 | 76 | value: 4, |
77 | observer() { | ||
78 | this.setData({ | ||
79 | scrollable: this.children.length > this.data.swipeThreshold | ||
80 | }); | ||
81 | } | ||
57 | }, | 82 | }, |
58 | offsetTop: { | 83 | offsetTop: { |
59 | type: Number, | 84 | type: Number, |
... | @@ -67,65 +92,49 @@ VantComponent({ | ... | @@ -67,65 +92,49 @@ VantComponent({ |
67 | scrollable: false, | 92 | scrollable: false, |
68 | trackStyle: '', | 93 | trackStyle: '', |
69 | wrapStyle: '', | 94 | wrapStyle: '', |
70 | position: '' | 95 | position: '', |
71 | }, | 96 | currentIndex: 0 |
72 | watch: { | ||
73 | swipeThreshold() { | ||
74 | this.set({ | ||
75 | scrollable: this.child.length > this.data.swipeThreshold | ||
76 | }); | ||
77 | }, | ||
78 | color: 'setLine', | ||
79 | lineWidth: 'setLine', | ||
80 | lineHeight: 'setLine', | ||
81 | active: 'setActiveTab', | ||
82 | animated: 'setTrack', | ||
83 | offsetTop: 'setWrapStyle' | ||
84 | }, | 97 | }, |
85 | beforeCreate() { | 98 | beforeCreate() { |
86 | this.child = []; | 99 | this.children = []; |
87 | }, | 100 | }, |
88 | mounted() { | 101 | mounted() { |
89 | this.setLine(true); | 102 | this.setLine(true); |
90 | this.setTrack(); | 103 | this.setTrack(); |
91 | this.scrollIntoView(); | 104 | this.scrollIntoView(); |
92 | this.getRect('.van-tabs__wrap').then((rect) => { | ||
93 | this.navHeight = rect.height; | ||
94 | this.observerContentScroll(); | ||
95 | }); | ||
96 | }, | ||
97 | destroyed() { | ||
98 | this.createIntersectionObserver().disconnect(); | ||
99 | }, | 105 | }, |
100 | methods: { | 106 | methods: { |
101 | updateTabs(tabs) { | 107 | updateTabs(tabs) { |
102 | tabs = tabs || this.data.tabs; | 108 | tabs = tabs || this.data.tabs; |
103 | this.set({ | 109 | this.setData({ |
104 | tabs, | 110 | tabs, |
105 | scrollable: tabs.length > this.data.swipeThreshold | 111 | scrollable: tabs.length > this.data.swipeThreshold |
106 | }); | 112 | }); |
107 | this.setActiveTab(); | 113 | this.setActiveTab(); |
108 | }, | 114 | }, |
109 | trigger(eventName, index) { | 115 | trigger(eventName, name) { |
116 | const { tabs, currentIndex } = this.data; | ||
110 | this.$emit(eventName, { | 117 | this.$emit(eventName, { |
111 | index, | 118 | name, |
112 | title: this.data.tabs[index].title | 119 | title: tabs[currentIndex].title |
113 | }); | 120 | }); |
114 | }, | 121 | }, |
115 | onTap(event) { | 122 | onTap(event) { |
116 | const { index } = event.currentTarget.dataset; | 123 | const { index } = event.currentTarget.dataset; |
124 | const child = this.children[index]; | ||
125 | const computedName = child.getComputedName(); | ||
117 | if (this.data.tabs[index].disabled) { | 126 | if (this.data.tabs[index].disabled) { |
118 | this.trigger('disabled', index); | 127 | this.trigger('disabled', computedName); |
119 | } | 128 | } |
120 | else { | 129 | else { |
121 | this.trigger('click', index); | 130 | this.trigger('click', computedName); |
122 | this.setActive(index); | 131 | this.setActive(computedName); |
123 | } | 132 | } |
124 | }, | 133 | }, |
125 | setActive(active) { | 134 | setActive(name) { |
126 | if (active !== this.data.active) { | 135 | if (name !== this.currentName) { |
127 | this.trigger('change', active); | 136 | this.currentName = name; |
128 | this.set({ active }); | 137 | this.trigger('change', name); |
129 | this.setActiveTab(); | 138 | this.setActiveTab(); |
130 | } | 139 | } |
131 | }, | 140 | }, |
... | @@ -133,22 +142,24 @@ VantComponent({ | ... | @@ -133,22 +142,24 @@ VantComponent({ |
133 | if (this.data.type !== 'line') { | 142 | if (this.data.type !== 'line') { |
134 | return; | 143 | return; |
135 | } | 144 | } |
136 | const { color, active, duration, lineWidth, lineHeight } = this.data; | 145 | const { color, duration, currentIndex, lineWidth, lineHeight } = this.data; |
137 | this.getRect('.van-tab', true).then((rects) => { | 146 | this.getRect('.van-tab', true).then((rects) => { |
138 | const rect = rects[active]; | 147 | const rect = rects[currentIndex]; |
139 | const width = lineWidth !== -1 ? lineWidth : rect.width / 2; | 148 | const width = lineWidth !== -1 ? lineWidth : rect.width / 2; |
140 | const height = lineHeight !== -1 ? `height: ${lineHeight}px;` : ''; | 149 | const height = lineHeight !== -1 |
150 | ? `height: ${addUnit(lineHeight)}; border-radius: ${addUnit(lineHeight)};` | ||
151 | : ''; | ||
141 | let left = rects | 152 | let left = rects |
142 | .slice(0, active) | 153 | .slice(0, currentIndex) |
143 | .reduce((prev, curr) => prev + curr.width, 0); | 154 | .reduce((prev, curr) => prev + curr.width, 0); |
144 | left += (rect.width - width) / 2; | 155 | left += (rect.width - width) / 2; |
145 | const transition = skipTransition | 156 | const transition = skipTransition |
146 | ? '' | 157 | ? '' |
147 | : `transition-duration: ${duration}s; -webkit-transition-duration: ${duration}s;`; | 158 | : `transition-duration: ${duration}s; -webkit-transition-duration: ${duration}s;`; |
148 | this.set({ | 159 | this.setData({ |
149 | lineStyle: ` | 160 | lineStyle: ` |
150 | ${height} | 161 | ${height} |
151 | width: ${width}px; | 162 | width: ${addUnit(width)}; |
152 | background-color: ${color}; | 163 | background-color: ${color}; |
153 | -webkit-transform: translateX(${left}px); | 164 | -webkit-transform: translateX(${left}px); |
154 | transform: translateX(${left}px); | 165 | transform: translateX(${left}px); |
... | @@ -158,39 +169,48 @@ VantComponent({ | ... | @@ -158,39 +169,48 @@ VantComponent({ |
158 | }); | 169 | }); |
159 | }, | 170 | }, |
160 | setTrack() { | 171 | setTrack() { |
161 | const { animated, active, duration } = this.data; | 172 | const { animated, duration, currentIndex } = this.data; |
162 | if (!animated) | 173 | if (!animated) |
163 | return ''; | 174 | return ''; |
164 | this.getRect('.van-tabs__content').then((rect) => { | 175 | this.getRect('.van-tabs__content').then((rect) => { |
165 | const { width } = rect; | 176 | const { width } = rect; |
166 | this.set({ | 177 | this.setData({ |
167 | trackStyle: ` | 178 | trackStyle: ` |
168 | width: ${width * this.child.length}px; | 179 | width: ${width * this.children.length}px; |
169 | left: ${-1 * active * width}px; | 180 | left: ${-1 * currentIndex * width}px; |
170 | transition: left ${duration}s; | 181 | transition: left ${duration}s; |
171 | display: -webkit-box; | 182 | display: -webkit-box; |
172 | display: flex; | 183 | display: flex; |
173 | ` | 184 | ` |
174 | }); | 185 | }); |
175 | const props = { width, animated }; | 186 | const data = { width, animated }; |
176 | this.child.forEach((item) => { | 187 | this.children.forEach((item) => { |
177 | item.set(props); | 188 | item.setData(data); |
178 | }); | 189 | }); |
179 | }); | 190 | }); |
180 | }, | 191 | }, |
181 | setActiveTab() { | 192 | setActiveTab() { |
182 | this.child.forEach((item, index) => { | 193 | if (!isDef(this.currentName)) { |
194 | const { active } = this.data; | ||
195 | const { children = [] } = this; | ||
196 | this.currentName = | ||
197 | active === '' && children.length | ||
198 | ? children[0].getComputedName() | ||
199 | : active; | ||
200 | } | ||
201 | this.children.forEach((item, index) => { | ||
183 | const data = { | 202 | const data = { |
184 | active: index === this.data.active | 203 | active: item.getComputedName() === this.currentName |
185 | }; | 204 | }; |
186 | if (data.active) { | 205 | if (data.active) { |
206 | this.setData({ currentIndex: index }); | ||
187 | data.inited = true; | 207 | data.inited = true; |
188 | } | 208 | } |
189 | if (data.active !== item.data.active) { | 209 | if (data.active !== item.data.active) { |
190 | item.set(data); | 210 | item.setData(data); |
191 | } | 211 | } |
192 | }); | 212 | }); |
193 | this.set({}, () => { | 213 | nextTick(() => { |
194 | this.setLine(); | 214 | this.setLine(); |
195 | this.setTrack(); | 215 | this.setTrack(); |
196 | this.scrollIntoView(); | 216 | this.scrollIntoView(); |
... | @@ -198,7 +218,7 @@ VantComponent({ | ... | @@ -198,7 +218,7 @@ VantComponent({ |
198 | }, | 218 | }, |
199 | // scroll active tab into view | 219 | // scroll active tab into view |
200 | scrollIntoView() { | 220 | scrollIntoView() { |
201 | const { active, scrollable } = this.data; | 221 | const { currentIndex, scrollable } = this.data; |
202 | if (!scrollable) { | 222 | if (!scrollable) { |
203 | return; | 223 | return; |
204 | } | 224 | } |
... | @@ -206,11 +226,11 @@ VantComponent({ | ... | @@ -206,11 +226,11 @@ VantComponent({ |
206 | this.getRect('.van-tab', true), | 226 | this.getRect('.van-tab', true), |
207 | this.getRect('.van-tabs__nav') | 227 | this.getRect('.van-tabs__nav') |
208 | ]).then(([tabRects, navRect]) => { | 228 | ]).then(([tabRects, navRect]) => { |
209 | const tabRect = tabRects[active]; | 229 | const tabRect = tabRects[currentIndex]; |
210 | const offsetLeft = tabRects | 230 | const offsetLeft = tabRects |
211 | .slice(0, active) | 231 | .slice(0, currentIndex) |
212 | .reduce((prev, curr) => prev + curr.width, 0); | 232 | .reduce((prev, curr) => prev + curr.width, 0); |
213 | this.set({ | 233 | this.setData({ |
214 | scrollLeft: offsetLeft - (navRect.width - tabRect.width) / 2 | 234 | scrollLeft: offsetLeft - (navRect.width - tabRect.width) / 2 |
215 | }); | 235 | }); |
216 | }); | 236 | }); |
... | @@ -229,83 +249,18 @@ VantComponent({ | ... | @@ -229,83 +249,18 @@ VantComponent({ |
229 | onTouchEnd() { | 249 | onTouchEnd() { |
230 | if (!this.data.swipeable) | 250 | if (!this.data.swipeable) |
231 | return; | 251 | return; |
232 | const { active, tabs } = this.data; | 252 | const { tabs, currentIndex } = this.data; |
233 | const { direction, deltaX, offsetX } = this; | 253 | const { direction, deltaX, offsetX } = this; |
234 | const minSwipeDistance = 50; | 254 | const minSwipeDistance = 50; |
235 | if (direction === 'horizontal' && offsetX >= minSwipeDistance) { | 255 | if (direction === 'horizontal' && offsetX >= minSwipeDistance) { |
236 | if (deltaX > 0 && active !== 0) { | 256 | if (deltaX > 0 && currentIndex !== 0) { |
237 | this.setActive(active - 1); | 257 | const child = this.children[currentIndex - 1]; |
238 | } | 258 | this.setActive(child.getComputedName()); |
239 | else if (deltaX < 0 && active !== tabs.length - 1) { | ||
240 | this.setActive(active + 1); | ||
241 | } | ||
242 | } | ||
243 | }, | ||
244 | setWrapStyle() { | ||
245 | const { offsetTop, position } = this.data; | ||
246 | let wrapStyle; | ||
247 | switch (position) { | ||
248 | case 'top': | ||
249 | wrapStyle = ` | ||
250 | top: ${offsetTop}px; | ||
251 | position: fixed; | ||
252 | `; | ||
253 | break; | ||
254 | case 'bottom': | ||
255 | wrapStyle = ` | ||
256 | top: auto; | ||
257 | bottom: 0; | ||
258 | `; | ||
259 | break; | ||
260 | default: | ||
261 | wrapStyle = ''; | ||
262 | } | ||
263 | // cut down `set` | ||
264 | if (wrapStyle === this.data.wrapStyle) | ||
265 | return; | ||
266 | this.set({ wrapStyle }); | ||
267 | }, | ||
268 | observerContentScroll() { | ||
269 | if (!this.data.sticky) { | ||
270 | return; | ||
271 | } | 259 | } |
272 | const { offsetTop } = this.data; | 260 | else if (deltaX < 0 && currentIndex !== tabs.length - 1) { |
273 | const { windowHeight } = wx.getSystemInfoSync(); | 261 | const child = this.children[currentIndex - 1]; |
274 | this.createIntersectionObserver().disconnect(); | 262 | this.setActive(child.getComputedName()); |
275 | this.createIntersectionObserver() | ||
276 | .relativeToViewport({ top: -(this.navHeight + offsetTop) }) | ||
277 | .observe('.van-tabs', (res) => { | ||
278 | const { top } = res.boundingClientRect; | ||
279 | if (top > offsetTop) { | ||
280 | return; | ||
281 | } | ||
282 | const position = res.intersectionRatio > 0 ? 'top' : 'bottom'; | ||
283 | this.$emit('scroll', { | ||
284 | scrollTop: top + offsetTop, | ||
285 | isFixed: position === 'top' | ||
286 | }); | ||
287 | this.setPosition(position); | ||
288 | }); | ||
289 | this.createIntersectionObserver() | ||
290 | .relativeToViewport({ bottom: -(windowHeight - 1 - offsetTop) }) | ||
291 | .observe('.van-tabs', (res) => { | ||
292 | const { top, bottom } = res.boundingClientRect; | ||
293 | if (bottom < this.navHeight) { | ||
294 | return; | ||
295 | } | 263 | } |
296 | const position = res.intersectionRatio > 0 ? 'top' : ''; | ||
297 | this.$emit('scroll', { | ||
298 | scrollTop: top + offsetTop, | ||
299 | isFixed: position === 'top' | ||
300 | }); | ||
301 | this.setPosition(position); | ||
302 | }); | ||
303 | }, | ||
304 | setPosition(position) { | ||
305 | if (position !== this.data.position) { | ||
306 | this.set({ position }).then(() => { | ||
307 | this.setWrapStyle(); | ||
308 | }); | ||
309 | } | 264 | } |
310 | } | 265 | } |
311 | } | 266 | } | ... | ... |
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | 1 | <wxs src="../wxs/utils.wxs" module="utils" /> |
2 | 2 | ||
3 | <view class="custom-class {{ utils.bem('tabs', [type]) }}"> | 3 | <view class="custom-class {{ utils.bem('tabs', [type]) }}"> |
4 | <view style="z-index: {{ zIndex }}; {{ wrapStyle }}" class="{{ utils.bem('tabs__wrap', { scrollable }) }} {{ type === 'line' && border ? 'van-hairline--top-bottom' : '' }}"> | 4 | <van-sticky disabled="{{ !sticky }}" z-index="{{ zIndex }}" offset-top="{{ offsetTop }}"> |
5 | <view class="{{ utils.bem('tabs__wrap', { scrollable }) }} {{ type === 'line' && border ? 'van-hairline--top-bottom' : '' }}"> | ||
5 | <slot name="nav-left" /> | 6 | <slot name="nav-left" /> |
6 | 7 | ||
7 | <scroll-view | 8 | <scroll-view |
8 | scroll-x="{{ scrollable }}" | 9 | scroll-x="{{ scrollable }}" |
9 | scroll-with-animation | 10 | scroll-with-animation |
10 | scroll-left="{{ scrollLeft }}" | 11 | scroll-left="{{ scrollLeft }}" |
11 | class="van-tabs__scroll--{{ type }}" | 12 | class="{{ utils.bem('tabs__scroll', [type]) }}" |
12 | style="{{ color ? 'border-color: ' + color : '' }}" | 13 | style="{{ color ? 'border-color: ' + color : '' }}" |
13 | > | 14 | > |
14 | <view class="{{ utils.bem('tabs__nav', [type]) }} nav-class"> | 15 | <view class="{{ utils.bem('tabs__nav', [type]) }} nav-class"> |
... | @@ -17,15 +18,16 @@ | ... | @@ -17,15 +18,16 @@ |
17 | wx:for="{{ tabs }}" | 18 | wx:for="{{ tabs }}" |
18 | wx:key="index" | 19 | wx:key="index" |
19 | data-index="{{ index }}" | 20 | data-index="{{ index }}" |
20 | class="van-ellipsis tab-class {{ index === active ? 'tab-active-class' : '' }} {{ utils.bem('tab', { active: index === active, disabled: item.disabled }) }}" | 21 | class="van-ellipsis tab-class {{ index === currentIndex ? 'tab-active-class' : '' }} {{ utils.bem('tab', { active: index === currentIndex, disabled: item.disabled }) }}" |
21 | style="{{ color && index !== active && type === 'card' && !item.disabled ? 'color: ' + color : '' }} {{ color && index === active && type === 'card' ? ';background-color:' + color : '' }} {{ color ? ';border-color: ' + color : '' }} {{ scrollable ? ';flex-basis:' + (88 / swipeThreshold) + '%' : '' }}" | 22 | style="{{ color && index !== currentIndex && type === 'card' && !item.disabled ? 'color: ' + color : '' }} {{ color && index === currentIndex && type === 'card' ? ';background-color:' + color : '' }} {{ color ? ';border-color: ' + color : '' }} {{ scrollable ? ';flex-basis:' + (88 / swipeThreshold) + '%' : '' }}" |
22 | bind:tap="onTap" | 23 | bind:tap="onTap" |
23 | > | 24 | > |
24 | <view class="van-ellipsis {{ utils.bem('tab__title', { dot: item.dot }) }}" style="{{ item.titleStyle }}"> | 25 | <view class="van-ellipsis" style="{{ item.titleStyle }}"> |
25 | {{ item.title }} | 26 | {{ item.title }} |
26 | <van-info | 27 | <van-info |
27 | wx:if="{{ item.info !== null }}" | 28 | wx:if="{{ item.info !== null || item.dot }}" |
28 | info="{{ item.info }}" | 29 | info="{{ item.info }}" |
30 | dot="{{ item.dot }}" | ||
29 | custom-class="van-tab__title__info" | 31 | custom-class="van-tab__title__info" |
30 | /> | 32 | /> |
31 | </view> | 33 | </view> |
... | @@ -35,6 +37,8 @@ | ... | @@ -35,6 +37,8 @@ |
35 | 37 | ||
36 | <slot name="nav-right" /> | 38 | <slot name="nav-right" /> |
37 | </view> | 39 | </view> |
40 | </van-sticky> | ||
41 | |||
38 | <view | 42 | <view |
39 | class="van-tabs__content" | 43 | class="van-tabs__content" |
40 | bind:touchstart="onTouchStart" | 44 | bind:touchstart="onTouchStart" | ... | ... |
1 | @import '../common/index.wxss';.van-tabs{position:relative;-webkit-tap-highlight-color:transparent}.van-tabs__wrap{position:absolute;top:0;right:0;left:0;display:-webkit-flex;display:flex;background-color:#fff}.van-tabs__wrap--page-top{position:fixed}.van-tabs__wrap--content-bottom{top:auto;bottom:0}.van-tabs__wrap--scrollable .van-tab{-webkit-flex:0 0 22%;flex:0 0 22%}.van-tabs__scroll--card{border:1px solid #f44;border-radius:2px}.van-tabs__nav{position:relative;display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none}.van-tabs__nav--line{height:100%}.van-tabs__nav--card{height:30px}.van-tabs__nav--card .van-tab{line-height:30px;color:#f44;border-right:1px solid #f44}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{color:#fff;background-color:#f44}.van-tabs__line{position:absolute;bottom:0;left:0;z-index:1;height:3px;background-color:#f44;border-radius:3px}.van-tabs--line{padding-top:44px}.van-tabs--line .van-tabs__wrap{height:44px}.van-tabs--card{padding-top:30px;margin:0 15px}.van-tabs--card .van-tabs__wrap{height:30px}.van-tabs__content{overflow:hidden}.van-tab,.van-tabs__track{position:relative}.van-tab{min-width:0;padding:0 5px;font-size:14px;line-height:44px;color:#7d7e80;text-align:center;cursor:pointer;box-sizing:border-box;-webkit-flex:1;flex:1}.van-tab--active{font-weight:500;color:#333}.van-tab--disabled{color:#c9c9c9}.van-tab__title--dot:after{display:inline-block;width:8px;height:8px;vertical-align:middle;background-color:#f44;border-radius:100%;content:""}.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 | ... | \ No newline at end of file |
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}.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:#7d7e80;color:var(--tab-text-color,#7d7e80);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__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 | ... | \ No newline at end of file | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | import { RED, BLUE, GREEN } from '../common/color'; | ||
3 | const DEFAULT_COLOR = '#999'; | ||
4 | const COLOR_MAP = { | ||
5 | danger: RED, | ||
6 | primary: BLUE, | ||
7 | success: GREEN | ||
8 | }; | ||
9 | VantComponent({ | 2 | VantComponent({ |
10 | props: { | 3 | props: { |
11 | size: String, | 4 | size: String, |
12 | type: String, | ||
13 | mark: Boolean, | 5 | mark: Boolean, |
14 | color: String, | 6 | color: String, |
15 | plain: Boolean, | 7 | plain: Boolean, |
16 | round: Boolean, | 8 | round: Boolean, |
17 | textColor: String | 9 | textColor: String, |
10 | type: { | ||
11 | type: String, | ||
12 | value: 'default' | ||
18 | }, | 13 | }, |
19 | computed: { | 14 | closeable: Boolean |
20 | style() { | 15 | }, |
21 | const color = this.data.color || COLOR_MAP[this.data.type] || DEFAULT_COLOR; | 16 | methods: { |
22 | const key = this.data.plain ? 'color' : 'background-color'; | 17 | onClose() { |
23 | const style = { [key]: color }; | 18 | this.$emit('close'); |
24 | if (this.data.textColor) { | ||
25 | style.color = this.data.textColor; | ||
26 | } | ||
27 | return Object.keys(style).map(key => `${key}: ${style[key]}`).join(';'); | ||
28 | } | 19 | } |
29 | } | 20 | } |
30 | }); | 21 | }); | ... | ... |
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | 1 | <wxs src="../wxs/utils.wxs" module="utils" /> |
2 | 2 | ||
3 | <view | 3 | <view |
4 | class="custom-class {{ utils.bem('tag', [size, { mark, plain, round }]) }} {{ plain ? 'van-hairline--surround' : '' }}" | 4 | class="custom-class {{ utils.bem('tag', [type, size, { mark, plain, round }]) }} {{ plain ? 'van-hairline--surround' : '' }}" |
5 | style="{{ style }}" | 5 | style="{{ color && !plain ? 'background-color: ' + color + ';' : '' }}{{ textColor || (color && plain) ? 'color: ' + (textColor || color) : '' }}" |
6 | > | 6 | > |
7 | <slot /> | 7 | <slot /> |
8 | <van-icon | ||
9 | wx:if="{{ closeable }}" | ||
10 | name="cross" | ||
11 | custom-class="van-tag__close" | ||
12 | bind:click="onClose" | ||
13 | /> | ||
8 | </view> | 14 | </view> | ... | ... |
1 | @import '../common/index.wxss';.van-tag{color:#fff;font-size:10px;padding:.2em .5em;line-height:normal;border-radius:.2em;display:inline-block}.van-tag:after{border-color:currentColor;border-radius:.4em}.van-tag--mark{padding-right:.6em;border-radius:0 .8em .8em 0}.van-tag--mark:after{border-radius:0 1.6em 1.6em 0}.van-tag--round{border-radius:.8em}.van-tag--round:after{border-radius:1.6em}.van-tag--medium{font-size:12px}.van-tag--large{font-size:14px} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
1 | <van-overlay | 1 | <van-overlay |
2 | wx:if="{{ mask || forbidClick }}" | 2 | wx:if="{{ mask || forbidClick }}" |
3 | show="{{ show }}" | 3 | show="{{ show }}" |
4 | mask="{{ mask }}" | ||
5 | z-index="{{ zIndex }}" | 4 | z-index="{{ zIndex }}" |
5 | custom-style="{{ mask ? '' : 'background-color: transparent;' }}" | ||
6 | /> | 6 | /> |
7 | <van-transition | 7 | <van-transition |
8 | show="{{ show }}" | 8 | show="{{ show }}" |
... | @@ -27,5 +27,7 @@ | ... | @@ -27,5 +27,7 @@ |
27 | <van-icon wx:else class="van-toast__icon" name="{{ type }}" /> | 27 | <van-icon wx:else class="van-toast__icon" name="{{ type }}" /> |
28 | <text wx:if="{{ message }}" class="van-toast__text">{{ message }}</text> | 28 | <text wx:if="{{ message }}" class="van-toast__text">{{ message }}</text> |
29 | </block> | 29 | </block> |
30 | |||
31 | <slot /> | ||
30 | </view> | 32 | </view> |
31 | </van-transition> | 33 | </van-transition> | ... | ... |
1 | @import '../common/index.wxss';.van-toast{display:-webkit-flex;display:flex;color:#fff;font-size:14px;line-height:20px;border-radius:4px;word-break:break-all;-webkit-align-items:center;align-items:center;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center;justify-content:center;box-sizing:initial;background-color:rgba(51,51,51,.88);white-space:pre-wrap}.van-toast__container{position:fixed;top:50%;left:50%;max-width:70%;width:-webkit-fit-content;width:fit-content;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.van-toast--text{padding:8px 12px;min-width:96px}.van-toast--icon{width:90px;padding:15px;min-height:90px}.van-toast--icon .van-toast__icon{font-size:48px}.van-toast--icon .van-toast__text{padding-top:5px}.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 | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
1 | /// <reference types="miniprogram-api-typings" /> | ||
1 | declare type ToastMessage = string | number; | 2 | declare type ToastMessage = string | number; |
2 | export declare type ToastOptions = { | 3 | interface ToastOptions { |
3 | show?: boolean; | 4 | show?: boolean; |
4 | type?: string; | 5 | type?: string; |
5 | mask?: boolean; | 6 | mask?: boolean; |
6 | zIndex?: number; | 7 | zIndex?: number; |
7 | context?: any; | 8 | context?: WechatMiniprogram.Component.TrivialInstance | WechatMiniprogram.Page.TrivialInstance; |
8 | position?: string; | 9 | position?: string; |
9 | duration?: number; | 10 | duration?: number; |
10 | selector?: string; | 11 | selector?: string; |
11 | forbidClick?: boolean; | 12 | forbidClick?: boolean; |
12 | loadingType?: string; | 13 | loadingType?: string; |
13 | message?: ToastMessage; | 14 | message?: ToastMessage; |
14 | }; | 15 | onClose?: () => void; |
15 | export interface Toast { | 16 | } |
16 | (message: ToastOptions | ToastMessage, options?: ToastOptions): Weapp.Component; | 17 | declare function Toast(toastOptions: ToastOptions | ToastMessage): WechatMiniprogram.Component.TrivialInstance; |
17 | loading?(options?: ToastOptions | ToastMessage): Weapp.Component; | 18 | declare namespace Toast { |
18 | success?(options?: ToastOptions | ToastMessage): Weapp.Component; | 19 | var loading: (options: string | number | ToastOptions) => WechatMiniprogram.Component.Instance<Record<string, any>, Record<string, any>, Record<string, any>>; |
19 | fail?(options?: ToastOptions | ToastMessage): Weapp.Component; | 20 | var success: (options: string | number | ToastOptions) => WechatMiniprogram.Component.Instance<Record<string, any>, Record<string, any>, Record<string, any>>; |
20 | clear?(): void; | 21 | var fail: (options: string | number | ToastOptions) => WechatMiniprogram.Component.Instance<Record<string, any>, Record<string, any>, Record<string, any>>; |
21 | setDefaultOptions?(options: ToastOptions): void; | 22 | var clear: () => void; |
22 | resetDefaultOptions?(): void; | 23 | var setDefaultOptions: (options: ToastOptions) => void; |
24 | var resetDefaultOptions: () => void; | ||
23 | } | 25 | } |
24 | declare const Toast: Toast; | ||
25 | export default Toast; | 26 | export default Toast; | ... | ... |
... | @@ -5,7 +5,7 @@ const defaultOptions = { | ... | @@ -5,7 +5,7 @@ const defaultOptions = { |
5 | message: '', | 5 | message: '', |
6 | show: true, | 6 | show: true, |
7 | zIndex: 1000, | 7 | zIndex: 1000, |
8 | duration: 3000, | 8 | duration: 2000, |
9 | position: 'middle', | 9 | position: 'middle', |
10 | forbidClick: false, | 10 | forbidClick: false, |
11 | loadingType: 'circular', | 11 | loadingType: 'circular', |
... | @@ -20,8 +20,8 @@ function getContext() { | ... | @@ -20,8 +20,8 @@ function getContext() { |
20 | const pages = getCurrentPages(); | 20 | const pages = getCurrentPages(); |
21 | return pages[pages.length - 1]; | 21 | return pages[pages.length - 1]; |
22 | } | 22 | } |
23 | const Toast = (options = {}) => { | 23 | function Toast(toastOptions) { |
24 | options = Object.assign({}, currentOptions, parseOptions(options)); | 24 | const options = Object.assign(Object.assign({}, currentOptions), parseOptions(toastOptions)); |
25 | const context = options.context || getContext(); | 25 | const context = options.context || getContext(); |
26 | const toast = context.selectComponent(options.selector); | 26 | const toast = context.selectComponent(options.selector); |
27 | if (!toast) { | 27 | if (!toast) { |
... | @@ -30,8 +30,14 @@ const Toast = (options = {}) => { | ... | @@ -30,8 +30,14 @@ const Toast = (options = {}) => { |
30 | } | 30 | } |
31 | delete options.context; | 31 | delete options.context; |
32 | delete options.selector; | 32 | delete options.selector; |
33 | toast.clear = () => { | ||
34 | toast.setData({ show: false }); | ||
35 | if (options.onClose) { | ||
36 | options.onClose(); | ||
37 | } | ||
38 | }; | ||
33 | queue.push(toast); | 39 | queue.push(toast); |
34 | toast.set(options); | 40 | toast.setData(options); |
35 | clearTimeout(toast.timer); | 41 | clearTimeout(toast.timer); |
36 | if (options.duration > 0) { | 42 | if (options.duration > 0) { |
37 | toast.timer = setTimeout(() => { | 43 | toast.timer = setTimeout(() => { |
... | @@ -40,18 +46,18 @@ const Toast = (options = {}) => { | ... | @@ -40,18 +46,18 @@ const Toast = (options = {}) => { |
40 | }, options.duration); | 46 | }, options.duration); |
41 | } | 47 | } |
42 | return toast; | 48 | return toast; |
43 | }; | 49 | } |
44 | const createMethod = type => options => Toast(Object.assign({ type }, parseOptions(options))); | 50 | const createMethod = (type) => (options) => Toast(Object.assign({ type }, parseOptions(options))); |
45 | ['loading', 'success', 'fail'].forEach(method => { | 51 | Toast.loading = createMethod('loading'); |
46 | Toast[method] = createMethod(method); | 52 | Toast.success = createMethod('success'); |
47 | }); | 53 | Toast.fail = createMethod('fail'); |
48 | Toast.clear = () => { | 54 | Toast.clear = () => { |
49 | queue.forEach(toast => { | 55 | queue.forEach(toast => { |
50 | toast.clear(); | 56 | toast.clear(); |
51 | }); | 57 | }); |
52 | queue = []; | 58 | queue = []; |
53 | }; | 59 | }; |
54 | Toast.setDefaultOptions = options => { | 60 | Toast.setDefaultOptions = (options) => { |
55 | Object.assign(currentOptions, options); | 61 | Object.assign(currentOptions, options); |
56 | }; | 62 | }; |
57 | Toast.resetDefaultOptions = () => { | 63 | Toast.resetDefaultOptions = () => { | ... | ... |
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{opacity:0;-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0)}.van-fade-down-enter,.van-fade-down-leave-to{opacity:0;-webkit-transform:translate3d(0,-100%,0);transform:translate3d(0,-100%,0)}.van-fade-left-enter,.van-fade-left-leave-to{opacity:0;-webkit-transform:translate3d(-100%,0,0);transform:translate3d(-100%,0,0)}.van-fade-right-enter,.van-fade-right-leave-to{opacity:0;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,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 | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
1 | import { VantComponent } from '../common/component'; | 1 | import { VantComponent } from '../common/component'; |
2 | const ITEM_HEIGHT = 44; | 2 | import { addUnit } from '../common/utils'; |
3 | VantComponent({ | 3 | VantComponent({ |
4 | classes: [ | 4 | classes: [ |
5 | 'main-item-class', | 5 | 'main-item-class', |
... | @@ -10,47 +10,50 @@ VantComponent({ | ... | @@ -10,47 +10,50 @@ VantComponent({ |
10 | 'content-disabled-class' | 10 | 'content-disabled-class' |
11 | ], | 11 | ], |
12 | props: { | 12 | props: { |
13 | items: Array, | 13 | items: { |
14 | type: Array, | ||
15 | observer: 'updateSubItems' | ||
16 | }, | ||
17 | activeId: null, | ||
14 | mainActiveIndex: { | 18 | mainActiveIndex: { |
15 | type: Number, | 19 | type: Number, |
16 | value: 0 | 20 | value: 0, |
21 | observer: 'updateSubItems' | ||
17 | }, | 22 | }, |
18 | activeId: { | 23 | height: { |
19 | type: [Number, String] | 24 | type: [Number, String], |
25 | value: 300, | ||
26 | observer: 'updateHeight' | ||
20 | }, | 27 | }, |
21 | maxHeight: { | 28 | max: { |
22 | type: Number, | 29 | type: Number, |
23 | value: 300 | 30 | value: Infinity |
24 | } | 31 | } |
25 | }, | 32 | }, |
26 | data: { | 33 | data: { |
27 | subItems: [], | 34 | subItems: [] |
28 | mainHeight: 0, | ||
29 | itemHeight: 0 | ||
30 | }, | ||
31 | watch: { | ||
32 | items() { | ||
33 | this.updateSubItems().then(() => { | ||
34 | this.updateMainHeight(); | ||
35 | }); | ||
36 | }, | ||
37 | maxHeight() { | ||
38 | this.updateItemHeight(this.data.subItems); | ||
39 | this.updateMainHeight(); | ||
40 | }, | 35 | }, |
41 | mainActiveIndex: 'updateSubItems' | 36 | created() { |
37 | this.updateHeight(); | ||
42 | }, | 38 | }, |
43 | methods: { | 39 | methods: { |
44 | // 当一个子项被选择时 | 40 | // 当一个子项被选择时 |
45 | onSelectItem(event) { | 41 | onSelectItem(event) { |
46 | const { item } = event.currentTarget.dataset; | 42 | const { item } = event.currentTarget.dataset; |
47 | if (!item.disabled) { | 43 | const isArray = Array.isArray(this.data.activeId); |
44 | // 判断有没有超出右侧选择的最大数 | ||
45 | const isOverMax = isArray && this.data.activeId.length >= this.data.max; | ||
46 | // 判断该项有没有被选中, 如果有被选中,则忽视是否超出的条件 | ||
47 | const isSelected = isArray | ||
48 | ? this.data.activeId.indexOf(item.id) > -1 | ||
49 | : this.data.activeId === item.id; | ||
50 | if (!item.disabled && (!isOverMax || isSelected)) { | ||
48 | this.$emit('click-item', item); | 51 | this.$emit('click-item', item); |
49 | } | 52 | } |
50 | }, | 53 | }, |
51 | // 当一个导航被点击时 | 54 | // 当一个导航被点击时 |
52 | onClickNav(event) { | 55 | onClickNav(event) { |
53 | const { index } = event.currentTarget.dataset; | 56 | const index = event.detail; |
54 | const item = this.data.items[index]; | 57 | const item = this.data.items[index]; |
55 | if (!item.disabled) { | 58 | if (!item.disabled) { |
56 | this.$emit('click-nav', { index }); | 59 | this.$emit('click-nav', { index }); |
... | @@ -60,19 +63,12 @@ VantComponent({ | ... | @@ -60,19 +63,12 @@ VantComponent({ |
60 | updateSubItems() { | 63 | updateSubItems() { |
61 | const { items, mainActiveIndex } = this.data; | 64 | const { items, mainActiveIndex } = this.data; |
62 | const { children = [] } = items[mainActiveIndex] || {}; | 65 | const { children = [] } = items[mainActiveIndex] || {}; |
63 | this.updateItemHeight(children); | ||
64 | return this.set({ subItems: children }); | 66 | return this.set({ subItems: children }); |
65 | }, | 67 | }, |
66 | // 更新组件整体高度,根据最大高度和当前组件需要展示的高度来决定 | 68 | updateHeight() { |
67 | updateMainHeight() { | 69 | this.setData({ |
68 | const { items = [], subItems = [] } = this.data; | 70 | innerHeight: addUnit(this.data.height) |
69 | const maxHeight = Math.max(items.length * ITEM_HEIGHT, subItems.length * ITEM_HEIGHT); | 71 | }); |
70 | this.set({ mainHeight: Math.min(maxHeight, this.data.maxHeight) }); | ||
71 | }, | ||
72 | // 更新子项列表高度,根据可展示的最大高度和当前子项列表的高度决定 | ||
73 | updateItemHeight(subItems) { | ||
74 | const itemHeight = Math.min(subItems.length * ITEM_HEIGHT, this.data.maxHeight); | ||
75 | return this.set({ itemHeight }); | ||
76 | } | 72 | } |
77 | } | 73 | } |
78 | }); | 74 | }); | ... | ... |
... | @@ -2,6 +2,7 @@ | ... | @@ -2,6 +2,7 @@ |
2 | "component": true, | 2 | "component": true, |
3 | "usingComponents": { | 3 | "usingComponents": { |
4 | "van-icon": "../icon/index", | 4 | "van-icon": "../icon/index", |
5 | "van-cell": "../cell/index" | 5 | "van-sidebar": "../sidebar/index", |
6 | "van-sidebar-item": "../sidebar-item/index" | ||
6 | } | 7 | } |
7 | } | 8 | } | ... | ... |
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | 1 | <wxs src="../wxs/utils.wxs" module="utils" /> |
2 | <wxs src="./index.wxs" module="wxs" /> | ||
2 | 3 | ||
3 | <view | 4 | <view |
4 | class="van-tree-select" | 5 | class="van-tree-select" |
5 | style="height: {{ mainHeight }}px" | 6 | style="height: {{ innerHeight }}" |
6 | > | 7 | > |
7 | <scroll-view scroll-y class="van-tree-select__nav"> | 8 | <scroll-view scroll-y class="van-tree-select__nav"> |
8 | <view | 9 | <van-sidebar bind:change="onClickNav" custom-class="van-tree-select__nav__inner"> |
10 | <van-sidebar-item | ||
9 | wx:for="{{ items }}" | 11 | wx:for="{{ items }}" |
10 | wx:key="index" | 12 | wx:key="index" |
11 | class="van-ellipsis main-item-class {{ utils.bem('tree-select__nitem', { active: mainActiveIndex === index, disabled: item.disabled }) }} {{ mainActiveIndex === index ? 'main-active-class' : '' }} {{ item.disabled ? 'main-disabled-class' : '' }}" | 13 | custom-class="main-item-class" |
12 | data-index="{{ index }}" | 14 | active-class="main-active-class" |
13 | bind:tap="onClickNav" | 15 | disabled-class="main-disabled-class" |
14 | > | 16 | title="{{ item.text }}" |
15 | {{ item.text }} | 17 | disabled="{{ item.disabled }}" |
16 | </view> | 18 | /> |
19 | </van-sidebar> | ||
17 | </scroll-view> | 20 | </scroll-view> |
18 | <scroll-view | 21 | <scroll-view scroll-y class="van-tree-select__content"> |
19 | scroll-y | 22 | <slot name="content" /> |
20 | class="van-tree-select__content" | ||
21 | style="height: {{ itemHeight }}px" | ||
22 | > | ||
23 | <view | 23 | <view |
24 | wx:for="{{ subItems }}" | 24 | wx:for="{{ subItems }}" |
25 | wx:key="id" | 25 | wx:key="id" |
26 | class="van-ellipsis van-hairline--bottom content-item-class {{ utils.bem('tree-select__item', { active: activeId === item.id, disabled: item.disabled }) }} {{ activeId === item.id ? 'content-active-class' : '' }} {{ item.disabled ? 'content-disabled-class' : '' }}" | 26 | class="van-ellipsis content-item-class {{ utils.bem('tree-select__item', { active: wxs.isActive(activeId, item.id), disabled: item.disabled }) }} {{ wxs.isActive(activeId, item.id) ? 'content-active-class' : '' }} {{ item.disabled ? 'content-disabled-class' : '' }}" |
27 | data-item="{{ item }}" | 27 | data-item="{{ item }}" |
28 | bind:tap="onSelectItem" | 28 | bind:tap="onSelectItem" |
29 | > | 29 | > |
30 | {{ item.text }} | 30 | {{ item.text }} |
31 | <van-icon | 31 | <van-icon |
32 | wx:if="{{ activeId === item.id }}" | 32 | wx:if="{{ wxs.isActive(activeId, item.id) }}" |
33 | name="checked" | 33 | name="checked" |
34 | size="16px" | 34 | size="16px" |
35 | class="van-tree-select__selected" | 35 | class="van-tree-select__selected" | ... | ... |
src/ui/vant-weapp/tree-select/index.wxs
0 → 100755
1 | @import '../common/index.wxss';.van-tree-select{position:relative;font-size:14px;-webkit-user-select:none;user-select:none}.van-tree-select__nav{position:absolute;top:0;bottom:0;left:0;width:35%;min-width:120px;background-color:#fafafa}.van-tree-select__nitem{position:relative;padding:0 9px 0 15px;line-height:44px}.van-tree-select__nitem--active:after{position:absolute;top:0;bottom:0;left:0;width:3.6px;background-color:#f44;content:""}.van-tree-select__nitem--active{font-weight:700;background-color:#fff}.van-tree-select__nitem--disabled{color:#999}.van-tree-select__content{width:65%;padding-left:15px;margin-left:35%;background-color:#fff;box-sizing:border-box}.van-tree-select__item{position:relative;font-weight:700;line-height:44px}.van-tree-select__item--active{color:#f44}.van-tree-select__item--disabled{color:#999}.van-tree-select__selected{position:absolute;top:0;right:15px;bottom:0;height:24px;margin:auto 0;line-height:24px} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | ... | \ No newline at end of file | ... | ... |
src/ui/vant-weapp/uploader/index.d.ts
0 → 100755
1 | export {}; |
src/ui/vant-weapp/uploader/index.js
0 → 100755
1 | import { VantComponent } from '../common/component'; | ||
2 | import { isImageFile } from './utils'; | ||
3 | import { addUnit } from '../common/utils'; | ||
4 | VantComponent({ | ||
5 | props: { | ||
6 | disabled: Boolean, | ||
7 | uploadText: String, | ||
8 | previewSize: { | ||
9 | type: null, | ||
10 | value: 90, | ||
11 | observer: 'setComputedPreviewSize' | ||
12 | }, | ||
13 | name: { | ||
14 | type: [Number, String], | ||
15 | value: '' | ||
16 | }, | ||
17 | accept: { | ||
18 | type: String, | ||
19 | value: 'image' | ||
20 | }, | ||
21 | fileList: { | ||
22 | type: Array, | ||
23 | value: [], | ||
24 | observer: 'formatFileList' | ||
25 | }, | ||
26 | maxSize: { | ||
27 | type: Number, | ||
28 | value: Number.MAX_VALUE | ||
29 | }, | ||
30 | maxCount: { | ||
31 | type: Number, | ||
32 | value: 100 | ||
33 | }, | ||
34 | previewImage: { | ||
35 | type: Boolean, | ||
36 | value: true | ||
37 | }, | ||
38 | previewFullImage: { | ||
39 | type: Boolean, | ||
40 | value: true | ||
41 | }, | ||
42 | imageFit: { | ||
43 | type: String, | ||
44 | value: 'scaleToFill' | ||
45 | }, | ||
46 | useSlot: Boolean, | ||
47 | useBeforeRead: Boolean | ||
48 | }, | ||
49 | data: { | ||
50 | lists: [], | ||
51 | computedPreviewSize: '', | ||
52 | isInCount: true | ||
53 | }, | ||
54 | methods: { | ||
55 | formatFileList() { | ||
56 | const { fileList = [], maxCount } = this.data; | ||
57 | const lists = fileList.map(item => (Object.assign(Object.assign({}, item), { isImage: typeof item.isImage === 'undefined' | ||
58 | ? isImageFile(item) | ||
59 | : item.isImage }))); | ||
60 | this.setData({ lists, isInCount: lists.length < maxCount }); | ||
61 | }, | ||
62 | setComputedPreviewSize(val) { | ||
63 | this.setData({ | ||
64 | computedPreviewSize: addUnit(val) | ||
65 | }); | ||
66 | }, | ||
67 | startUpload() { | ||
68 | if (this.data.disabled) | ||
69 | return; | ||
70 | const { name = '', capture = ['album', 'camera'], maxCount = 100, multiple = false, maxSize, accept, lists, useBeforeRead = false // 是否定义了 beforeRead | ||
71 | } = this.data; | ||
72 | let chooseFile = null; | ||
73 | const newMaxCount = maxCount - lists.length; | ||
74 | // 设置为只选择图片的时候使用 chooseImage 来实现 | ||
75 | if (accept === 'image') { | ||
76 | chooseFile = new Promise((resolve, reject) => { | ||
77 | wx.chooseImage({ | ||
78 | count: multiple ? (newMaxCount > 9 ? 9 : newMaxCount) : 1, | ||
79 | sourceType: capture, | ||
80 | success: res => { | ||
81 | resolve(res); | ||
82 | }, | ||
83 | fail: err => { | ||
84 | reject(err); | ||
85 | } | ||
86 | }); | ||
87 | }); | ||
88 | } | ||
89 | else { | ||
90 | chooseFile = new Promise((resolve, reject) => { | ||
91 | wx.chooseMessageFile({ | ||
92 | count: multiple ? newMaxCount : 1, | ||
93 | type: 'file', | ||
94 | success(res) { | ||
95 | resolve(res); | ||
96 | }, | ||
97 | fail: err => { | ||
98 | reject(err); | ||
99 | } | ||
100 | }); | ||
101 | }); | ||
102 | } | ||
103 | chooseFile.then(res => { | ||
104 | const file = multiple ? res.tempFiles : res.tempFiles[0]; | ||
105 | // 检查文件大小 | ||
106 | if (file instanceof Array) { | ||
107 | const sizeEnable = file.every(item => item.size <= maxSize); | ||
108 | if (!sizeEnable) { | ||
109 | this.$emit('oversize', { name }); | ||
110 | return; | ||
111 | } | ||
112 | } | ||
113 | else if (file.size > maxSize) { | ||
114 | this.$emit('oversize', { name }); | ||
115 | return; | ||
116 | } | ||
117 | // 触发上传之前的钩子函数 | ||
118 | if (useBeforeRead) { | ||
119 | this.$emit('before-read', { | ||
120 | file, | ||
121 | name, | ||
122 | callback: result => { | ||
123 | if (result) { | ||
124 | // 开始上传 | ||
125 | this.$emit('after-read', { file, name }); | ||
126 | } | ||
127 | } | ||
128 | }); | ||
129 | } | ||
130 | else { | ||
131 | this.$emit('after-read', { file, name }); | ||
132 | } | ||
133 | }); | ||
134 | }, | ||
135 | deleteItem(event) { | ||
136 | const { index } = event.currentTarget.dataset; | ||
137 | this.$emit('delete', { index, name: this.data.name }); | ||
138 | }, | ||
139 | doPreviewImage(event) { | ||
140 | if (!this.data.previewFullImage) | ||
141 | return; | ||
142 | const curUrl = event.currentTarget.dataset.url; | ||
143 | const images = this.data.lists | ||
144 | .filter(item => item.isImage) | ||
145 | .map(item => item.url || item.path); | ||
146 | this.$emit('click-preview', { url: curUrl, name: this.data.name }); | ||
147 | wx.previewImage({ | ||
148 | urls: images, | ||
149 | current: curUrl, | ||
150 | fail() { | ||
151 | wx.showToast({ title: '预览图片失败', icon: 'none' }); | ||
152 | } | ||
153 | }); | ||
154 | } | ||
155 | } | ||
156 | }); |
src/ui/vant-weapp/uploader/index.json
0 → 100755
src/ui/vant-weapp/uploader/index.wxml
0 → 100755
1 | <wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | |||
3 | <view | ||
4 | class="van-uploader" | ||
5 | > | ||
6 | <view class="van-uploader__wrapper"> | ||
7 | <!-- 预览样式 --> | ||
8 | <block wx:if="{{ previewImage }}"> | ||
9 | <view | ||
10 | wx:for="{{ lists }}" | ||
11 | wx:key="{{ index }}" | ||
12 | class="van-uploader__preview" | ||
13 | > | ||
14 | <image | ||
15 | wx:if="{{ item.isImage }}" | ||
16 | mode="{{ imageFit }}" | ||
17 | src="{{ item.url || item.path }}" | ||
18 | alt="{{ item.name || ('图片' + index) }}" | ||
19 | class="van-uploader__preview-image" | ||
20 | style="width: {{ computedPreviewSize }}px; height: {{ computedPreviewSize }}px;" | ||
21 | data-url="{{ item.url || item.path }}" | ||
22 | bind:tap="doPreviewImage" | ||
23 | /> | ||
24 | <view | ||
25 | wx:else | ||
26 | class="van-uploader__file" | ||
27 | style="width: {{ computedPreviewSize }}px; height: {{ computedPreviewSize }}px;" | ||
28 | > | ||
29 | <van-icon name="description" class="van-uploader__file-icon" /> | ||
30 | <view class="van-uploader__file-name van-ellipsis">{{ item.name || item.url || item.path }}</view> | ||
31 | </view> | ||
32 | <van-icon | ||
33 | name="delete" | ||
34 | class="van-uploader__preview-delete" | ||
35 | bind:tap="deleteItem" | ||
36 | data-index="{{ index }}" | ||
37 | /> | ||
38 | </view> | ||
39 | </block> | ||
40 | <!-- 上传样式 --> | ||
41 | <block wx:if="{{ isInCount }}"> | ||
42 | <block wx:if="{{ useSlot }}"> | ||
43 | <view class="van-uploader__slot" bind:tap="startUpload"> | ||
44 | <slot /> | ||
45 | </view> | ||
46 | </block> | ||
47 | <block wx:else> | ||
48 | <!-- 默认上传样式 --> | ||
49 | <view | ||
50 | class="van-uploader__upload" | ||
51 | style="width: {{ computedPreviewSize }}px; height: {{ computedPreviewSize }}px;" | ||
52 | bind:tap="startUpload" | ||
53 | > | ||
54 | <van-icon name="plus" class="van-uploader__upload-icon" /> | ||
55 | <text wx:if="{{ uploadText }}" class="van-uploader__upload-text">{{ uploadText }}</text> | ||
56 | </view> | ||
57 | </block> | ||
58 | </block> | ||
59 | </view> | ||
60 | </view> |
src/ui/vant-weapp/uploader/index.wxss
0 → 100755
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 #e5e5e5}.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}.van-uploader__preview-delete{position:absolute;right:0;bottom:0;display:inline-block;width:18px;height:18px;padding:1px;color:#fff;text-align:center;background-color:rgba(0,0,0,.45)}.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:#f8f8f8}.van-uploader__file-icon{display:inline-block;width:20px;height:20px;color:#7d7e80;font-size:20px}.van-uploader__file-name{box-sizing:border-box;width:100%;margin-top:8px;padding:0 5px;color:#7d7e80;font-size:12px;text-align:center} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
src/ui/vant-weapp/uploader/utils.d.ts
0 → 100755
src/ui/vant-weapp/uploader/utils.js
0 → 100755
1 | const IMAGE_EXT = ['jpeg', 'jpg', 'gif', 'png', 'svg']; | ||
2 | export function isImageUrl(url) { | ||
3 | return IMAGE_EXT.some(ext => url.indexOf(`.${ext}`) !== -1); | ||
4 | } | ||
5 | export function isImageFile(item) { | ||
6 | if (item.type) { | ||
7 | return item.type.indexOf('image') === 0; | ||
8 | } | ||
9 | if (item.path) { | ||
10 | return isImageUrl(item.path); | ||
11 | } | ||
12 | if (item.url) { | ||
13 | return isImageUrl(item.url); | ||
14 | } | ||
15 | return false; | ||
16 | } |
1 | var bem = require('./bem.wxs').bem; | 1 | var bem = require('./bem.wxs').bem; |
2 | var memoize = require('./memoize.wxs').memoize; | 2 | var memoize = require('./memoize.wxs').memoize; |
3 | 3 | ||
4 | function isSrc(url) { | ||
5 | return url.indexOf('http') === 0 || url.indexOf('data:image') === 0 || url.indexOf('//') === 0; | ||
6 | } | ||
7 | |||
8 | module.exports = { | 4 | module.exports = { |
9 | bem: memoize(bem), | 5 | bem: memoize(bem), |
10 | isSrc: isSrc, | ||
11 | memoize: memoize | 6 | memoize: memoize |
12 | }; | 7 | }; | ... | ... |
-
Please register or sign in to post a comment