mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-05-24 15:39:15 +08:00
build: compile 1.5.2
This commit is contained in:
parent
11445bed02
commit
e8b3c3fc8d
2
dist/cell/index.wxss
vendored
2
dist/cell/index.wxss
vendored
@ -1 +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;content:" ";pointer-events:none;right:16px;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__value{font-size:16px;font-size:var(--cell-large-value-font-size,16px)}.van-cell--large .van-cell__label{font-size:14px;font-size:var(--cell-large-label-font-size,14px)}
|
||||
@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;right:16px;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__value{font-size:16px;font-size:var(--cell-large-value-font-size,16px)}.van-cell--large .van-cell__label{font-size:14px;font-size:var(--cell-large-label-font-size,14px)}
|
2
dist/common/index.wxss
vendored
2
dist/common/index.wxss
vendored
@ -1 +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;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #ebedf0;-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}
|
||||
.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 #ebedf0;-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}
|
2
dist/common/style/hairline.wxss
vendored
2
dist/common/style/hairline.wxss
vendored
@ -1 +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;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #ebedf0;-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}
|
||||
.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 #ebedf0;-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}
|
2
dist/common/utils.d.ts
vendored
2
dist/common/utils.d.ts
vendored
@ -1,7 +1,6 @@
|
||||
/// <reference types="wechat-miniprogram" />
|
||||
export declare function isDef(value: any): boolean;
|
||||
export declare function isObj(x: any): boolean;
|
||||
export declare function isNumber(value: any): boolean;
|
||||
export declare function range(num: number, min: number, max: number): number;
|
||||
export declare function nextTick(fn: Function): void;
|
||||
export declare function getSystemInfoSync(): WechatMiniprogram.GetSystemInfoSyncResult;
|
||||
@ -9,6 +8,7 @@ export declare function addUnit(value?: string | number): string | undefined;
|
||||
export declare function requestAnimationFrame(
|
||||
cb: Function
|
||||
): void | WechatMiniprogram.NodesRef;
|
||||
export declare function pickExclude(obj: unknown, keys: string[]): {};
|
||||
export declare function getRect(
|
||||
this: WechatMiniprogram.Component.TrivialInstance,
|
||||
selector: string
|
||||
|
15
dist/common/utils.js
vendored
15
dist/common/utils.js
vendored
@ -1,3 +1,4 @@
|
||||
import { isNumber, isPlainObject } from './validator';
|
||||
export function isDef(value) {
|
||||
return value !== undefined && value !== null;
|
||||
}
|
||||
@ -5,9 +6,6 @@ export function isObj(x) {
|
||||
const type = typeof x;
|
||||
return x !== null && (type === 'object' || type === 'function');
|
||||
}
|
||||
export function isNumber(value) {
|
||||
return /^\d+(\.\d+)?$/.test(value);
|
||||
}
|
||||
export function range(num, min, max) {
|
||||
return Math.min(Math.max(num, min), max);
|
||||
}
|
||||
@ -43,6 +41,17 @@ export function requestAnimationFrame(cb) {
|
||||
cb();
|
||||
});
|
||||
}
|
||||
export function pickExclude(obj, keys) {
|
||||
if (!isPlainObject(obj)) {
|
||||
return {};
|
||||
}
|
||||
return Object.keys(obj).reduce((prev, key) => {
|
||||
if (!keys.includes(key)) {
|
||||
prev[key] = obj[key];
|
||||
}
|
||||
return prev;
|
||||
}, {});
|
||||
}
|
||||
export function getRect(selector) {
|
||||
return new Promise((resolve) => {
|
||||
wx.createSelectorQuery()
|
||||
|
11
dist/common/validator.d.ts
vendored
Normal file
11
dist/common/validator.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
export declare function isFunction(val: unknown): val is Function;
|
||||
export declare function isPlainObject(
|
||||
val: unknown
|
||||
): val is Record<string, unknown>;
|
||||
export declare function isPromise<T = unknown>(val: unknown): val is Promise<T>;
|
||||
export declare function isDef(value: any): boolean;
|
||||
export declare function isObj(x: unknown): x is Record<string, unknown>;
|
||||
export declare function isNumber(value: string): boolean;
|
||||
export declare function isBoolean(value: unknown): value is boolean;
|
||||
export declare function isImageUrl(url: string): boolean;
|
||||
export declare function isVideoUrl(url: string): boolean;
|
30
dist/common/validator.js
vendored
Normal file
30
dist/common/validator.js
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
export function isFunction(val) {
|
||||
return typeof val === 'function';
|
||||
}
|
||||
export function isPlainObject(val) {
|
||||
return val !== null && typeof val === 'object' && !Array.isArray(val);
|
||||
}
|
||||
export function isPromise(val) {
|
||||
return isPlainObject(val) && isFunction(val.then) && isFunction(val.catch);
|
||||
}
|
||||
export function isDef(value) {
|
||||
return value !== undefined && value !== null;
|
||||
}
|
||||
export function isObj(x) {
|
||||
const type = typeof x;
|
||||
return x !== null && (type === 'object' || type === 'function');
|
||||
}
|
||||
export function isNumber(value) {
|
||||
return /^\d+(\.\d+)?$/.test(value);
|
||||
}
|
||||
export function isBoolean(value) {
|
||||
return typeof value === 'boolean';
|
||||
}
|
||||
const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
|
||||
const VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv)/i;
|
||||
export function isImageUrl(url) {
|
||||
return IMAGE_REGEXP.test(url);
|
||||
}
|
||||
export function isVideoUrl(url) {
|
||||
return VIDEO_REGEXP.test(url);
|
||||
}
|
1
dist/definitions/index.js
vendored
1
dist/definitions/index.js
vendored
@ -0,0 +1 @@
|
||||
export {};
|
1
dist/definitions/weapp.js
vendored
1
dist/definitions/weapp.js
vendored
@ -0,0 +1 @@
|
||||
export {};
|
23
dist/goods-action-icon/index.wxml
vendored
23
dist/goods-action-icon/index.wxml
vendored
@ -22,17 +22,14 @@
|
||||
bindgetphonenumber="bindGetPhoneNumber"
|
||||
bindlaunchapp="bindLaunchApp"
|
||||
>
|
||||
<view class="van-goods-action-icon__content">
|
||||
<van-icon
|
||||
wx:if="{{ icon }}"
|
||||
size="20px"
|
||||
name="{{ icon }}"
|
||||
dot="{{ dot }}"
|
||||
info="{{ info }}"
|
||||
class="van-goods-action-icon__icon"
|
||||
custom-class="icon-class"
|
||||
/>
|
||||
<slot name="icon" />
|
||||
<text class="text-class">{{ text }}</text>
|
||||
</view>
|
||||
<van-icon
|
||||
wx:if="{{ icon }}"
|
||||
name="{{ icon }}"
|
||||
dot="{{ dot }}"
|
||||
info="{{ info }}"
|
||||
class="van-goods-action-icon__icon"
|
||||
custom-class="icon-class"
|
||||
/>
|
||||
<slot wx:else name="icon" />
|
||||
<text class="text-class">{{ text }}</text>
|
||||
</van-button>
|
||||
|
2
dist/goods-action-icon/index.wxss
vendored
2
dist/goods-action-icon/index.wxss
vendored
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-goods-action-icon{border:none!important;width:50px!important;width:var(--goods-action-icon-height,50px)!important}.van-goods-action-icon__content{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center;justify-content:center;height:100%;line-height:1;font-size:10px;font-size:var(--goods-action-icon-font-size,10px);color:#646566;color:var(--goods-action-icon-text-color,#646566)}.van-goods-action-icon__icon{margin-bottom:4px}
|
||||
@import '../common/index.wxss';.van-goods-action-icon{display:-webkit-flex!important;display:flex!important;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center!important;justify-content:center!important;line-height:1!important;border:none!important;font-size:10px!important;font-size:var(--goods-action-icon-font-size,10px)!important;color:#646566!important;color:var(--goods-action-icon-text-color,#646566)!important;min-width:48px;min-width:var(--goods-action-icon-width,48px);height:50px!important;height:var(--goods-action-icon-height,50px)!important}.van-goods-action-icon__icon{display:-webkit-flex;display:flex;margin:0 auto 5px;color:#323233;color:var(--goods-action-icon-color,#323233);font-size:18px;font-size:var(--goods-action-icon-size,18px)}
|
2
dist/goods-action/index.wxss
vendored
2
dist/goods-action/index.wxss
vendored
@ -1 +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)}
|
||||
@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;height:50px;height:var(--goods-action-height,50px);background-color:#fff;background-color:var(--goods-action-background-color,#fff)}.van-goods-action--safe{padding-bottom:env(safe-area-inset-bottom)}
|
2
dist/icon/index.wxss
vendored
2
dist/icon/index.wxss
vendored
File diff suppressed because one or more lines are too long
2
dist/share-sheet/options.wxss
vendored
2
dist/share-sheet/options.wxss
vendored
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-share-sheet__options{position:relative;display:-webkit-flex;display:flex;padding:16px 0 16px 8px;overflow-x:auto;overflow-y:visible;-webkit-overflow-scrolling:touch}.van-share-sheet__options--border:before{position:absolute;box-sizing:border-box;content:" ";pointer-events:none;top:0;right:0;left:16px;border-top:1px solid #ebedf0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-share-sheet__options::-webkit-scrollbar{height:0}.van-share-sheet__option{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-user-select:none;user-select:none}.van-share-sheet__option:active{opacity:.7}.van-share-sheet__button{height:auto;padding:0;line-height:inherit;background-color:initial;border:0}.van-share-sheet__button:after{border:0}.van-share-sheet__icon{width:48px;height:48px;margin:0 16px}.van-share-sheet__name{margin-top:8px;padding:0 4px;color:#646566;font-size:12px}.van-share-sheet__option-description{padding:0 4px;color:#c8c9cc;font-size:12px}
|
||||
@import '../common/index.wxss';.van-share-sheet__options{position:relative;display:-webkit-flex;display:flex;padding:16px 0 16px 8px;overflow-x:auto;overflow-y:visible;-webkit-overflow-scrolling:touch}.van-share-sheet__options--border:before{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:0;right:0;left:16px;border-top:1px solid #ebedf0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-share-sheet__options::-webkit-scrollbar{height:0}.van-share-sheet__option{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-user-select:none;user-select:none}.van-share-sheet__option:active{opacity:.7}.van-share-sheet__button{height:auto;padding:0;line-height:inherit;background-color:initial;border:0}.van-share-sheet__button:after{border:0}.van-share-sheet__icon{width:48px;height:48px;margin:0 16px}.van-share-sheet__name{margin-top:8px;padding:0 4px;color:#646566;font-size:12px}.van-share-sheet__option-description{padding:0 4px;color:#c8c9cc;font-size:12px}
|
12
dist/tabs/index.wxs
vendored
12
dist/tabs/index.wxs
vendored
@ -68,10 +68,14 @@ function trackStyle(data) {
|
||||
}
|
||||
|
||||
return [
|
||||
'transform: translate3d(' + -100 * data.currentIndex + '%, 0, 0)',
|
||||
'-webkit-transition-duration: ' + data.duration + 's',
|
||||
'transition-duration: ' + data.duration + 's',
|
||||
].join(';');
|
||||
['left', -100 * data.currentIndex + '%'],
|
||||
['-webkit-transition-duration', data.duration + 's'],
|
||||
['transition-duration: ', data.duration + 's'],
|
||||
]
|
||||
.map(function (item) {
|
||||
return item.join(':');
|
||||
})
|
||||
.join(';');
|
||||
}
|
||||
|
||||
function lineStyle(data) {
|
||||
|
2
dist/tabs/index.wxss
vendored
2
dist/tabs/index.wxss
vendored
@ -1 +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__wrap--scrollable .van-tab--complete{-webkit-flex:1 0 auto!important;flex:1 0 auto!important;padding:0 12px}.van-tabs__wrap--scrollable .van-tabs__nav--complete{padding-right:8px;padding-left:8px}.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__scroll::-webkit-scrollbar{display:none}.van-tabs__nav{position:relative;display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none}.van-tabs__nav--card{box-sizing:border-box;height:30px;height:var(--tabs-card-height,30px);border:1px solid #ee0a24;border:var(--border-width-base,1px) solid var(--tabs-default-color,#ee0a24);border-radius:2px;border-radius:var(--border-radius-sm,2px)}.van-tabs__nav--card .van-tab{color:#ee0a24;color:var(--tabs-default-color,#ee0a24);line-height:28px;line-height:calc(var(--tabs-card-height, 30px) - 2*var(--border-width-base, 1px));border-right:1px solid #ee0a24;border-right:var(--border-width-base,1px) solid var(--tabs-default-color,#ee0a24)}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{color:#fff;color:var(--white,#fff);background-color:#ee0a24;background-color:var(--tabs-default-color,#ee0a24)}.van-tabs__nav--card .van-tab--disabled{color:#c8c9cc;color:var(--tab-disabled-text-color,#c8c9cc)}.van-tabs__line{position:absolute;bottom:0;left:0;z-index:1;height:3px;height:var(--tabs-bottom-bar-height,3px);border-radius:3px;border-radius:var(--tabs-bottom-bar-height,3px);background-color:#ee0a24;background-color:var(--tabs-bottom-bar-color,#ee0a24)}.van-tabs__track{position:relative;width:100%;height:100%}.van-tabs__track--animated{display:-webkit-flex;display:flex;transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform}.van-tabs__content{overflow:hidden}.van-tabs--line .van-tabs__wrap{height:44px;height:var(--tabs-line-height,44px)}.van-tabs--card .van-tabs__wrap{height:30px;height:var(--tabs-card-height,30px)}.van-tab{position:relative;-webkit-flex:1;flex:1;box-sizing:border-box;min-width:0;padding:0 5px;text-align:center;cursor:pointer;color:#646566;color:var(--tab-text-color,#646566);font-size:14px;font-size:var(--tab-font-size,14px);line-height:44px;line-height:var(--tabs-line-height,44px)}.van-tab--active{font-weight:500;font-weight:var(--font-weight-bold,500);color:#323233;color:var(--tab-active-text-color,#323233)}.van-tab--disabled{color:#c8c9cc;color:var(--tab-disabled-text-color,#c8c9cc)}.van-tab__title__info{position:relative!important;top:-1px!important;display:inline-block;-webkit-transform:translateX(0)!important;transform:translateX(0)!important}
|
||||
@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__wrap--scrollable .van-tab--complete{-webkit-flex:1 0 auto!important;flex:1 0 auto!important;padding:0 12px}.van-tabs__wrap--scrollable .van-tabs__nav--complete{padding-right:8px;padding-left:8px}.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__scroll::-webkit-scrollbar{display:none}.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) - var(--border-width-base, 1px)*2);border-right:1px solid #ee0a24;border-right:var(--border-width-base,1px) solid var(--tabs-default-color,#ee0a24)}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{color:#fff;color:var(--white,#fff);background-color:#ee0a24;background-color:var(--tabs-default-color,#ee0a24)}.van-tabs__nav--card .van-tab--disabled{color:#c8c9cc;color:var(--tab-disabled-text-color,#c8c9cc)}.van-tabs__line{position:absolute;bottom:0;left:0;z-index:1;height:3px;height:var(--tabs-bottom-bar-height,3px);border-radius:3px;border-radius:var(--tabs-bottom-bar-height,3px);background-color:#ee0a24;background-color:var(--tabs-bottom-bar-color,#ee0a24)}.van-tabs__track{position:relative;width:100%;height:100%}.van-tabs__track--animated{display:-webkit-flex;display:flex;transition-property:left}.van-tabs__content{overflow:hidden}.van-tabs--line .van-tabs__wrap{height:44px;height:var(--tabs-line-height,44px)}.van-tabs--card .van-tabs__wrap{height:30px;height:var(--tabs-card-height,30px)}.van-tab{position:relative;-webkit-flex:1;flex:1;box-sizing:border-box;min-width:0;padding:0 5px;text-align:center;cursor:pointer;color:#646566;color:var(--tab-text-color,#646566);font-size:14px;font-size:var(--tab-font-size,14px);line-height:44px;line-height:var(--tabs-line-height,44px)}.van-tab--active{font-weight:500;font-weight:var(--font-weight-bold,500);color:#323233;color:var(--tab-active-text-color,#323233)}.van-tab--disabled{color:#c8c9cc;color:var(--tab-disabled-text-color,#c8c9cc)}.van-tab__title__info{position:relative!important;top:-1px!important;display:inline-block;-webkit-transform:translateX(0)!important;transform:translateX(0)!important}
|
55
dist/uploader/index.js
vendored
55
dist/uploader/index.js
vendored
@ -1,6 +1,7 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { isImageFile, isVideo, chooseFile, isPromise } from './utils';
|
||||
import { isImageFile, chooseFile, isVideoFile } from './utils';
|
||||
import { chooseImageProps, chooseVideoProps } from './shared';
|
||||
import { isBoolean, isPromise } from '../common/validator';
|
||||
VantComponent({
|
||||
props: Object.assign(
|
||||
Object.assign(
|
||||
@ -74,14 +75,12 @@ VantComponent({
|
||||
const { fileList = [], maxCount } = this.data;
|
||||
const lists = fileList.map((item) =>
|
||||
Object.assign(Object.assign({}, item), {
|
||||
isImage:
|
||||
typeof item.isImage === 'undefined'
|
||||
? isImageFile(item)
|
||||
: item.isImage,
|
||||
deletable:
|
||||
typeof item.deletable === 'undefined' ? true : item.deletable,
|
||||
isImage: isImageFile(item),
|
||||
isVideo: isVideoFile(item),
|
||||
deletable: isBoolean(item.deletable) ? item.deletable : true,
|
||||
})
|
||||
);
|
||||
console.log(lists);
|
||||
this.setData({ lists, isInCount: lists.length < maxCount });
|
||||
},
|
||||
getDetail(index) {
|
||||
@ -99,13 +98,8 @@ VantComponent({
|
||||
})
|
||||
)
|
||||
.then((res) => {
|
||||
let file = null;
|
||||
if (isVideo(res, accept)) {
|
||||
file = Object.assign({ path: res.tempFilePath }, res);
|
||||
} else {
|
||||
file = multiple ? res.tempFiles : res.tempFiles[0];
|
||||
}
|
||||
this.onBeforeRead(file);
|
||||
console.log(res);
|
||||
this.onBeforeRead(multiple ? res : res[0]);
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$emit('error', error);
|
||||
@ -139,7 +133,7 @@ VantComponent({
|
||||
}
|
||||
},
|
||||
onAfterRead(file) {
|
||||
const { maxSize } = this.data;
|
||||
const { maxSize, afterRead } = this.data;
|
||||
const oversize = Array.isArray(file)
|
||||
? file.some((item) => item.size > maxSize)
|
||||
: file.size > maxSize;
|
||||
@ -147,8 +141,8 @@ VantComponent({
|
||||
this.$emit('oversize', Object.assign({ file }, this.getDetail()));
|
||||
return;
|
||||
}
|
||||
if (typeof this.data.afterRead === 'function') {
|
||||
this.data.afterRead(file, this.getDetail());
|
||||
if (typeof afterRead === 'function') {
|
||||
afterRead(file, this.getDetail());
|
||||
}
|
||||
this.$emit('after-read', Object.assign({ file }, this.getDetail()));
|
||||
},
|
||||
@ -167,32 +161,25 @@ VantComponent({
|
||||
const { lists } = this.data;
|
||||
const item = lists[index];
|
||||
wx.previewImage({
|
||||
urls: lists
|
||||
.filter((item) => item.isImage)
|
||||
.map((item) => item.url || item.path),
|
||||
current: item.url || item.path,
|
||||
urls: lists.filter((item) => isImageFile(item)).map((item) => item.url),
|
||||
current: item.url,
|
||||
fail() {
|
||||
wx.showToast({ title: '预览图片失败', icon: 'none' });
|
||||
},
|
||||
});
|
||||
},
|
||||
// fix: accept 为 video 时不能展示视频
|
||||
onPreviewVideo: function (event) {
|
||||
onPreviewVideo(event) {
|
||||
if (!this.data.previewFullImage) return;
|
||||
var index = event.currentTarget.dataset.index;
|
||||
var lists = this.data.lists;
|
||||
const { index } = event.currentTarget.dataset;
|
||||
const { lists } = this.data;
|
||||
wx.previewMedia({
|
||||
sources: lists
|
||||
.filter(function (item) {
|
||||
return item.isVideo;
|
||||
})
|
||||
.map(function (item) {
|
||||
item.type = 'video';
|
||||
item.url = item.url || item.path;
|
||||
return item;
|
||||
}),
|
||||
.filter((item) => isVideoFile(item))
|
||||
.map((item) =>
|
||||
Object.assign(Object.assign({}, item), { type: 'video' })
|
||||
),
|
||||
current: index,
|
||||
fail: function () {
|
||||
fail() {
|
||||
wx.showToast({ title: '预览视频失败', icon: 'none' });
|
||||
},
|
||||
});
|
||||
|
14
dist/uploader/index.wxml
vendored
14
dist/uploader/index.wxml
vendored
@ -14,7 +14,7 @@
|
||||
<image
|
||||
wx:if="{{ item.isImage }}"
|
||||
mode="{{ imageFit }}"
|
||||
src="{{ item.url || item.path }}"
|
||||
src="{{ item.thumb || item.url }}"
|
||||
alt="{{ item.name || ('图片' + index) }}"
|
||||
class="van-uploader__preview-image"
|
||||
style="width: {{ utils.addUnit(previewSize) }}; height: {{ utils.addUnit(previewSize) }};"
|
||||
@ -23,21 +23,23 @@
|
||||
/>
|
||||
<video
|
||||
wx:elif="{{ item.isVideo }}"
|
||||
src="{{item.url || item.path}}"
|
||||
autoplay="{{item.autoplay}}"
|
||||
src="{{ item.url }}"
|
||||
title="{{ item.name || ('视频' + index) }}"
|
||||
poster="{{ item.thumb }}"
|
||||
autoplay="{{ item.autoplay }}"
|
||||
class="van-uploader__preview-image"
|
||||
style="width: {{ utils.addUnit(previewSize) }}; height: {{ utils.addUnit(previewSize) }};"
|
||||
data-index="{{ index }}"
|
||||
bind:tap="onPreviewVideo"
|
||||
>
|
||||
</video>
|
||||
</video>
|
||||
<view
|
||||
wx:else
|
||||
class="van-uploader__file"
|
||||
style="width: {{ utils.addUnit(previewSize) }}; height: {{ utils.addUnit(previewSize) }};"
|
||||
>
|
||||
<van-icon name="description" class="van-uploader__file-icon" />
|
||||
<view class="van-uploader__file-name van-ellipsis">{{ item.name || item.url || item.path }}</view>
|
||||
<view class="van-uploader__file-name van-ellipsis">{{ item.name || item.url }}</view>
|
||||
</view>
|
||||
<view
|
||||
wx:if="{{ item.status === 'uploading' || item.status === 'failed' }}"
|
||||
@ -59,7 +61,7 @@
|
||||
|
||||
<!-- 上传样式 -->
|
||||
<block wx:if="{{ isInCount }}">
|
||||
<view class="van-uploader__slot" bind:tap="startUpload">
|
||||
<view class="van-uploader__slot" bindtap="startUpload">
|
||||
<slot />
|
||||
</view>
|
||||
|
||||
|
27
dist/uploader/utils.d.ts
vendored
27
dist/uploader/utils.d.ts
vendored
@ -1,18 +1,15 @@
|
||||
/// <reference types="wechat-miniprogram" />
|
||||
interface File {
|
||||
path: string;
|
||||
url: string;
|
||||
size: number;
|
||||
name: string;
|
||||
size?: number;
|
||||
name?: string;
|
||||
type: string;
|
||||
time: number;
|
||||
image: boolean;
|
||||
duration?: number;
|
||||
time?: number;
|
||||
isImage?: boolean;
|
||||
isVideo?: boolean;
|
||||
}
|
||||
export declare function isImageFile(item: File): boolean;
|
||||
export declare function isVideo(
|
||||
res: any,
|
||||
accept: string
|
||||
): res is WechatMiniprogram.ChooseVideoSuccessCallbackResult;
|
||||
export declare function isVideoFile(item: File): boolean;
|
||||
export declare function chooseFile({
|
||||
accept,
|
||||
multiple,
|
||||
@ -31,13 +28,5 @@ export declare function chooseFile({
|
||||
sizeType: any;
|
||||
camera: any;
|
||||
maxCount: any;
|
||||
}): Promise<
|
||||
| WechatMiniprogram.ChooseImageSuccessCallbackResult
|
||||
| WechatMiniprogram.ChooseMediaSuccessCallbackResult
|
||||
| WechatMiniprogram.ChooseVideoSuccessCallbackResult
|
||||
| WechatMiniprogram.ChooseMessageFileSuccessCallbackResult
|
||||
>;
|
||||
export declare function isFunction(val: unknown): val is Function;
|
||||
export declare function isObject(val: any): val is Record<any, any>;
|
||||
export declare function isPromise<T = any>(val: unknown): val is Promise<T>;
|
||||
}): Promise<unknown>;
|
||||
export {};
|
||||
|
115
dist/uploader/utils.js
vendored
115
dist/uploader/utils.js
vendored
@ -1,21 +1,71 @@
|
||||
const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
|
||||
function isImageUrl(url) {
|
||||
return IMAGE_REGEXP.test(url);
|
||||
}
|
||||
import { pickExclude } from '../common/utils';
|
||||
import { isImageUrl, isVideoUrl } from '../common/validator';
|
||||
export function isImageFile(item) {
|
||||
if (item.type) {
|
||||
return item.type.indexOf('image') === 0;
|
||||
if (item.isImage != null) {
|
||||
return item.isImage;
|
||||
}
|
||||
if (item.path) {
|
||||
return isImageUrl(item.path);
|
||||
if (item.type) {
|
||||
return item.type === 'image';
|
||||
}
|
||||
if (item.url) {
|
||||
return isImageUrl(item.url);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export function isVideo(res, accept) {
|
||||
return accept === 'video';
|
||||
export function isVideoFile(item) {
|
||||
if (item.isVideo != null) {
|
||||
return item.isVideo;
|
||||
}
|
||||
if (item.type) {
|
||||
return item.type === 'video';
|
||||
}
|
||||
if (item.url) {
|
||||
return isVideoUrl(item.url);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function formatImage(res) {
|
||||
return res.tempFiles.map((item) =>
|
||||
Object.assign(Object.assign({}, pickExclude(item, ['path'])), {
|
||||
type: 'image',
|
||||
url: item.path,
|
||||
thumb: item.path,
|
||||
})
|
||||
);
|
||||
}
|
||||
function formatVideo(res) {
|
||||
return [
|
||||
Object.assign(
|
||||
Object.assign(
|
||||
{},
|
||||
pickExclude(res, ['tempFilePath', 'thumbTempFilePath', 'errMsg'])
|
||||
),
|
||||
{ type: 'video', url: res.tempFilePath, thumb: res.thumbTempFilePath }
|
||||
),
|
||||
];
|
||||
}
|
||||
function formatMedia(res) {
|
||||
return res.tempFiles.map((item) =>
|
||||
Object.assign(
|
||||
Object.assign(
|
||||
{},
|
||||
pickExclude(item, ['fileType', 'thumbTempFilePath', 'tempFilePath'])
|
||||
),
|
||||
{
|
||||
type: res.type,
|
||||
url: item.tempFilePath,
|
||||
thumb:
|
||||
res.type === 'video' ? item.thumbTempFilePath : item.tempFilePath,
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
function formatFile(res) {
|
||||
return res.tempFiles.map((item) =>
|
||||
Object.assign(Object.assign({}, pickExclude(item, ['path'])), {
|
||||
url: item.path,
|
||||
})
|
||||
);
|
||||
}
|
||||
export function chooseFile({
|
||||
accept,
|
||||
@ -27,57 +77,46 @@ export function chooseFile({
|
||||
camera,
|
||||
maxCount,
|
||||
}) {
|
||||
switch (accept) {
|
||||
case 'image':
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
switch (accept) {
|
||||
case 'image':
|
||||
wx.chooseImage({
|
||||
count: multiple ? Math.min(maxCount, 9) : 1,
|
||||
sourceType: capture,
|
||||
sizeType,
|
||||
success: resolve,
|
||||
success: (res) => resolve(formatImage(res)),
|
||||
fail: reject,
|
||||
});
|
||||
});
|
||||
case 'media':
|
||||
return new Promise((resolve, reject) => {
|
||||
break;
|
||||
case 'media':
|
||||
wx.chooseMedia({
|
||||
count: multiple ? Math.min(maxCount, 9) : 1,
|
||||
sourceType: capture,
|
||||
maxDuration,
|
||||
sizeType,
|
||||
camera,
|
||||
success: resolve,
|
||||
success: (res) => resolve(formatMedia(res)),
|
||||
fail: reject,
|
||||
});
|
||||
});
|
||||
case 'video':
|
||||
return new Promise((resolve, reject) => {
|
||||
break;
|
||||
case 'video':
|
||||
wx.chooseVideo({
|
||||
sourceType: capture,
|
||||
compressed,
|
||||
maxDuration,
|
||||
camera,
|
||||
success: resolve,
|
||||
success: (res) => resolve(formatVideo(res)),
|
||||
fail: reject,
|
||||
});
|
||||
});
|
||||
default:
|
||||
return new Promise((resolve, reject) => {
|
||||
break;
|
||||
default:
|
||||
wx.chooseMessageFile({
|
||||
count: multiple ? maxCount : 1,
|
||||
type: 'file',
|
||||
success: resolve,
|
||||
type: accept,
|
||||
success: (res) => resolve(formatFile(res)),
|
||||
fail: reject,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
export function isFunction(val) {
|
||||
return typeof val === 'function';
|
||||
}
|
||||
export function isObject(val) {
|
||||
return val !== null && typeof val === 'object';
|
||||
}
|
||||
export function isPromise(val) {
|
||||
return isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1 +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;content:" ";pointer-events:none;right:16px;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__value{font-size:16px;font-size:var(--cell-large-value-font-size,16px)}.van-cell--large .van-cell__label{font-size:14px;font-size:var(--cell-large-label-font-size,14px)}
|
||||
@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;right:16px;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__value{font-size:16px;font-size:var(--cell-large-value-font-size,16px)}.van-cell--large .van-cell__label{font-size:14px;font-size:var(--cell-large-label-font-size,14px)}
|
@ -1 +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;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #ebedf0;-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}
|
||||
.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 #ebedf0;-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}
|
@ -1 +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;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #ebedf0;-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}
|
||||
.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 #ebedf0;-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}
|
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
exports.getAllRect = exports.getRect = exports.requestAnimationFrame = exports.addUnit = exports.getSystemInfoSync = exports.nextTick = exports.range = exports.isNumber = exports.isObj = exports.isDef = void 0;
|
||||
exports.getAllRect = exports.getRect = exports.pickExclude = exports.requestAnimationFrame = exports.addUnit = exports.getSystemInfoSync = exports.nextTick = exports.range = exports.isObj = exports.isDef = void 0;
|
||||
var validator_1 = require('./validator');
|
||||
function isDef(value) {
|
||||
return value !== undefined && value !== null;
|
||||
}
|
||||
@ -10,10 +11,6 @@ function isObj(x) {
|
||||
return x !== null && (type === 'object' || type === 'function');
|
||||
}
|
||||
exports.isObj = isObj;
|
||||
function isNumber(value) {
|
||||
return /^\d+(\.\d+)?$/.test(value);
|
||||
}
|
||||
exports.isNumber = isNumber;
|
||||
function range(num, min, max) {
|
||||
return Math.min(Math.max(num, min), max);
|
||||
}
|
||||
@ -37,7 +34,7 @@ function addUnit(value) {
|
||||
return undefined;
|
||||
}
|
||||
value = String(value);
|
||||
return isNumber(value) ? value + 'px' : value;
|
||||
return validator_1.isNumber(value) ? value + 'px' : value;
|
||||
}
|
||||
exports.addUnit = addUnit;
|
||||
function requestAnimationFrame(cb) {
|
||||
@ -54,6 +51,18 @@ function requestAnimationFrame(cb) {
|
||||
});
|
||||
}
|
||||
exports.requestAnimationFrame = requestAnimationFrame;
|
||||
function pickExclude(obj, keys) {
|
||||
if (!validator_1.isPlainObject(obj)) {
|
||||
return {};
|
||||
}
|
||||
return Object.keys(obj).reduce(function (prev, key) {
|
||||
if (!keys.includes(key)) {
|
||||
prev[key] = obj[key];
|
||||
}
|
||||
return prev;
|
||||
}, {});
|
||||
}
|
||||
exports.pickExclude = pickExclude;
|
||||
function getRect(selector) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve) {
|
||||
|
42
lib/common/validator.js
Normal file
42
lib/common/validator.js
Normal file
@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
exports.isVideoUrl = exports.isImageUrl = exports.isBoolean = exports.isNumber = exports.isObj = exports.isDef = exports.isPromise = exports.isPlainObject = exports.isFunction = void 0;
|
||||
function isFunction(val) {
|
||||
return typeof val === 'function';
|
||||
}
|
||||
exports.isFunction = isFunction;
|
||||
function isPlainObject(val) {
|
||||
return val !== null && typeof val === 'object' && !Array.isArray(val);
|
||||
}
|
||||
exports.isPlainObject = isPlainObject;
|
||||
function isPromise(val) {
|
||||
return isPlainObject(val) && isFunction(val.then) && isFunction(val.catch);
|
||||
}
|
||||
exports.isPromise = isPromise;
|
||||
function isDef(value) {
|
||||
return value !== undefined && value !== null;
|
||||
}
|
||||
exports.isDef = isDef;
|
||||
function isObj(x) {
|
||||
var type = typeof x;
|
||||
return x !== null && (type === 'object' || type === 'function');
|
||||
}
|
||||
exports.isObj = isObj;
|
||||
function isNumber(value) {
|
||||
return /^\d+(\.\d+)?$/.test(value);
|
||||
}
|
||||
exports.isNumber = isNumber;
|
||||
function isBoolean(value) {
|
||||
return typeof value === 'boolean';
|
||||
}
|
||||
exports.isBoolean = isBoolean;
|
||||
var IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
|
||||
var VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv)/i;
|
||||
function isImageUrl(url) {
|
||||
return IMAGE_REGEXP.test(url);
|
||||
}
|
||||
exports.isImageUrl = isImageUrl;
|
||||
function isVideoUrl(url) {
|
||||
return VIDEO_REGEXP.test(url);
|
||||
}
|
||||
exports.isVideoUrl = isVideoUrl;
|
@ -22,17 +22,14 @@
|
||||
bindgetphonenumber="bindGetPhoneNumber"
|
||||
bindlaunchapp="bindLaunchApp"
|
||||
>
|
||||
<view class="van-goods-action-icon__content">
|
||||
<van-icon
|
||||
wx:if="{{ icon }}"
|
||||
size="20px"
|
||||
name="{{ icon }}"
|
||||
dot="{{ dot }}"
|
||||
info="{{ info }}"
|
||||
class="van-goods-action-icon__icon"
|
||||
custom-class="icon-class"
|
||||
/>
|
||||
<slot name="icon" />
|
||||
<text class="text-class">{{ text }}</text>
|
||||
</view>
|
||||
<van-icon
|
||||
wx:if="{{ icon }}"
|
||||
name="{{ icon }}"
|
||||
dot="{{ dot }}"
|
||||
info="{{ info }}"
|
||||
class="van-goods-action-icon__icon"
|
||||
custom-class="icon-class"
|
||||
/>
|
||||
<slot wx:else name="icon" />
|
||||
<text class="text-class">{{ text }}</text>
|
||||
</van-button>
|
||||
|
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-goods-action-icon{border:none!important;width:50px!important;width:var(--goods-action-icon-height,50px)!important}.van-goods-action-icon__content{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center;justify-content:center;height:100%;line-height:1;font-size:10px;font-size:var(--goods-action-icon-font-size,10px);color:#646566;color:var(--goods-action-icon-text-color,#646566)}.van-goods-action-icon__icon{margin-bottom:4px}
|
||||
@import '../common/index.wxss';.van-goods-action-icon{display:-webkit-flex!important;display:flex!important;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center!important;justify-content:center!important;line-height:1!important;border:none!important;font-size:10px!important;font-size:var(--goods-action-icon-font-size,10px)!important;color:#646566!important;color:var(--goods-action-icon-text-color,#646566)!important;min-width:48px;min-width:var(--goods-action-icon-width,48px);height:50px!important;height:var(--goods-action-icon-height,50px)!important}.van-goods-action-icon__icon{display:-webkit-flex;display:flex;margin:0 auto 5px;color:#323233;color:var(--goods-action-icon-color,#323233);font-size:18px;font-size:var(--goods-action-icon-size,18px)}
|
@ -1 +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)}
|
||||
@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;height:50px;height:var(--goods-action-height,50px);background-color:#fff;background-color:var(--goods-action-background-color,#fff)}.van-goods-action--safe{padding-bottom:env(safe-area-inset-bottom)}
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-share-sheet__options{position:relative;display:-webkit-flex;display:flex;padding:16px 0 16px 8px;overflow-x:auto;overflow-y:visible;-webkit-overflow-scrolling:touch}.van-share-sheet__options--border:before{position:absolute;box-sizing:border-box;content:" ";pointer-events:none;top:0;right:0;left:16px;border-top:1px solid #ebedf0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-share-sheet__options::-webkit-scrollbar{height:0}.van-share-sheet__option{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-user-select:none;user-select:none}.van-share-sheet__option:active{opacity:.7}.van-share-sheet__button{height:auto;padding:0;line-height:inherit;background-color:initial;border:0}.van-share-sheet__button:after{border:0}.van-share-sheet__icon{width:48px;height:48px;margin:0 16px}.van-share-sheet__name{margin-top:8px;padding:0 4px;color:#646566;font-size:12px}.van-share-sheet__option-description{padding:0 4px;color:#c8c9cc;font-size:12px}
|
||||
@import '../common/index.wxss';.van-share-sheet__options{position:relative;display:-webkit-flex;display:flex;padding:16px 0 16px 8px;overflow-x:auto;overflow-y:visible;-webkit-overflow-scrolling:touch}.van-share-sheet__options--border:before{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:0;right:0;left:16px;border-top:1px solid #ebedf0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-share-sheet__options::-webkit-scrollbar{height:0}.van-share-sheet__option{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-user-select:none;user-select:none}.van-share-sheet__option:active{opacity:.7}.van-share-sheet__button{height:auto;padding:0;line-height:inherit;background-color:initial;border:0}.van-share-sheet__button:after{border:0}.van-share-sheet__icon{width:48px;height:48px;margin:0 16px}.van-share-sheet__name{margin-top:8px;padding:0 4px;color:#646566;font-size:12px}.van-share-sheet__option-description{padding:0 4px;color:#c8c9cc;font-size:12px}
|
@ -68,10 +68,14 @@ function trackStyle(data) {
|
||||
}
|
||||
|
||||
return [
|
||||
'transform: translate3d(' + -100 * data.currentIndex + '%, 0, 0)',
|
||||
'-webkit-transition-duration: ' + data.duration + 's',
|
||||
'transition-duration: ' + data.duration + 's',
|
||||
].join(';');
|
||||
['left', -100 * data.currentIndex + '%'],
|
||||
['-webkit-transition-duration', data.duration + 's'],
|
||||
['transition-duration: ', data.duration + 's'],
|
||||
]
|
||||
.map(function (item) {
|
||||
return item.join(':');
|
||||
})
|
||||
.join(';');
|
||||
}
|
||||
|
||||
function lineStyle(data) {
|
||||
|
@ -1 +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__wrap--scrollable .van-tab--complete{-webkit-flex:1 0 auto!important;flex:1 0 auto!important;padding:0 12px}.van-tabs__wrap--scrollable .van-tabs__nav--complete{padding-right:8px;padding-left:8px}.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__scroll::-webkit-scrollbar{display:none}.van-tabs__nav{position:relative;display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none}.van-tabs__nav--card{box-sizing:border-box;height:30px;height:var(--tabs-card-height,30px);border:1px solid #ee0a24;border:var(--border-width-base,1px) solid var(--tabs-default-color,#ee0a24);border-radius:2px;border-radius:var(--border-radius-sm,2px)}.van-tabs__nav--card .van-tab{color:#ee0a24;color:var(--tabs-default-color,#ee0a24);line-height:28px;line-height:calc(var(--tabs-card-height, 30px) - 2*var(--border-width-base, 1px));border-right:1px solid #ee0a24;border-right:var(--border-width-base,1px) solid var(--tabs-default-color,#ee0a24)}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{color:#fff;color:var(--white,#fff);background-color:#ee0a24;background-color:var(--tabs-default-color,#ee0a24)}.van-tabs__nav--card .van-tab--disabled{color:#c8c9cc;color:var(--tab-disabled-text-color,#c8c9cc)}.van-tabs__line{position:absolute;bottom:0;left:0;z-index:1;height:3px;height:var(--tabs-bottom-bar-height,3px);border-radius:3px;border-radius:var(--tabs-bottom-bar-height,3px);background-color:#ee0a24;background-color:var(--tabs-bottom-bar-color,#ee0a24)}.van-tabs__track{position:relative;width:100%;height:100%}.van-tabs__track--animated{display:-webkit-flex;display:flex;transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform}.van-tabs__content{overflow:hidden}.van-tabs--line .van-tabs__wrap{height:44px;height:var(--tabs-line-height,44px)}.van-tabs--card .van-tabs__wrap{height:30px;height:var(--tabs-card-height,30px)}.van-tab{position:relative;-webkit-flex:1;flex:1;box-sizing:border-box;min-width:0;padding:0 5px;text-align:center;cursor:pointer;color:#646566;color:var(--tab-text-color,#646566);font-size:14px;font-size:var(--tab-font-size,14px);line-height:44px;line-height:var(--tabs-line-height,44px)}.van-tab--active{font-weight:500;font-weight:var(--font-weight-bold,500);color:#323233;color:var(--tab-active-text-color,#323233)}.van-tab--disabled{color:#c8c9cc;color:var(--tab-disabled-text-color,#c8c9cc)}.van-tab__title__info{position:relative!important;top:-1px!important;display:inline-block;-webkit-transform:translateX(0)!important;transform:translateX(0)!important}
|
||||
@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__wrap--scrollable .van-tab--complete{-webkit-flex:1 0 auto!important;flex:1 0 auto!important;padding:0 12px}.van-tabs__wrap--scrollable .van-tabs__nav--complete{padding-right:8px;padding-left:8px}.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__scroll::-webkit-scrollbar{display:none}.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) - var(--border-width-base, 1px)*2);border-right:1px solid #ee0a24;border-right:var(--border-width-base,1px) solid var(--tabs-default-color,#ee0a24)}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{color:#fff;color:var(--white,#fff);background-color:#ee0a24;background-color:var(--tabs-default-color,#ee0a24)}.van-tabs__nav--card .van-tab--disabled{color:#c8c9cc;color:var(--tab-disabled-text-color,#c8c9cc)}.van-tabs__line{position:absolute;bottom:0;left:0;z-index:1;height:3px;height:var(--tabs-bottom-bar-height,3px);border-radius:3px;border-radius:var(--tabs-bottom-bar-height,3px);background-color:#ee0a24;background-color:var(--tabs-bottom-bar-color,#ee0a24)}.van-tabs__track{position:relative;width:100%;height:100%}.van-tabs__track--animated{display:-webkit-flex;display:flex;transition-property:left}.van-tabs__content{overflow:hidden}.van-tabs--line .van-tabs__wrap{height:44px;height:var(--tabs-line-height,44px)}.van-tabs--card .van-tabs__wrap{height:30px;height:var(--tabs-card-height,30px)}.van-tab{position:relative;-webkit-flex:1;flex:1;box-sizing:border-box;min-width:0;padding:0 5px;text-align:center;cursor:pointer;color:#646566;color:var(--tab-text-color,#646566);font-size:14px;font-size:var(--tab-font-size,14px);line-height:44px;line-height:var(--tabs-line-height,44px)}.van-tab--active{font-weight:500;font-weight:var(--font-weight-bold,500);color:#323233;color:var(--tab-active-text-color,#323233)}.van-tab--disabled{color:#c8c9cc;color:var(--tab-disabled-text-color,#c8c9cc)}.van-tab__title__info{position:relative!important;top:-1px!important;display:inline-block;-webkit-transform:translateX(0)!important;transform:translateX(0)!important}
|
@ -18,6 +18,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
var component_1 = require('../common/component');
|
||||
var utils_1 = require('./utils');
|
||||
var shared_1 = require('./shared');
|
||||
var validator_1 = require('../common/validator');
|
||||
component_1.VantComponent({
|
||||
props: __assign(
|
||||
__assign(
|
||||
@ -94,14 +95,14 @@ component_1.VantComponent({
|
||||
maxCount = _a.maxCount;
|
||||
var lists = fileList.map(function (item) {
|
||||
return __assign(__assign({}, item), {
|
||||
isImage:
|
||||
typeof item.isImage === 'undefined'
|
||||
? utils_1.isImageFile(item)
|
||||
: item.isImage,
|
||||
deletable:
|
||||
typeof item.deletable === 'undefined' ? true : item.deletable,
|
||||
isImage: utils_1.isImageFile(item),
|
||||
isVideo: utils_1.isVideoFile(item),
|
||||
deletable: validator_1.isBoolean(item.deletable)
|
||||
? item.deletable
|
||||
: true,
|
||||
});
|
||||
});
|
||||
console.log(lists);
|
||||
this.setData({ lists: lists, isInCount: lists.length < maxCount });
|
||||
},
|
||||
getDetail: function (index) {
|
||||
@ -126,13 +127,8 @@ component_1.VantComponent({
|
||||
})
|
||||
)
|
||||
.then(function (res) {
|
||||
var file = null;
|
||||
if (utils_1.isVideo(res, accept)) {
|
||||
file = __assign({ path: res.tempFilePath }, res);
|
||||
} else {
|
||||
file = multiple ? res.tempFiles : res.tempFiles[0];
|
||||
}
|
||||
_this.onBeforeRead(file);
|
||||
console.log(res);
|
||||
_this.onBeforeRead(multiple ? res : res[0]);
|
||||
})
|
||||
.catch(function (error) {
|
||||
_this.$emit('error', error);
|
||||
@ -162,7 +158,7 @@ component_1.VantComponent({
|
||||
if (!res) {
|
||||
return;
|
||||
}
|
||||
if (utils_1.isPromise(res)) {
|
||||
if (validator_1.isPromise(res)) {
|
||||
res.then(function (data) {
|
||||
return _this.onAfterRead(data || file);
|
||||
});
|
||||
@ -171,7 +167,9 @@ component_1.VantComponent({
|
||||
}
|
||||
},
|
||||
onAfterRead: function (file) {
|
||||
var maxSize = this.data.maxSize;
|
||||
var _a = this.data,
|
||||
maxSize = _a.maxSize,
|
||||
afterRead = _a.afterRead;
|
||||
var oversize = Array.isArray(file)
|
||||
? file.some(function (item) {
|
||||
return item.size > maxSize;
|
||||
@ -181,8 +179,8 @@ component_1.VantComponent({
|
||||
this.$emit('oversize', __assign({ file: file }, this.getDetail()));
|
||||
return;
|
||||
}
|
||||
if (typeof this.data.afterRead === 'function') {
|
||||
this.data.afterRead(file, this.getDetail());
|
||||
if (typeof afterRead === 'function') {
|
||||
afterRead(file, this.getDetail());
|
||||
}
|
||||
this.$emit('after-read', __assign({ file: file }, this.getDetail()));
|
||||
},
|
||||
@ -203,18 +201,17 @@ component_1.VantComponent({
|
||||
wx.previewImage({
|
||||
urls: lists
|
||||
.filter(function (item) {
|
||||
return item.isImage;
|
||||
return utils_1.isImageFile(item);
|
||||
})
|
||||
.map(function (item) {
|
||||
return item.url || item.path;
|
||||
return item.url;
|
||||
}),
|
||||
current: item.url || item.path,
|
||||
current: item.url,
|
||||
fail: function () {
|
||||
wx.showToast({ title: '预览图片失败', icon: 'none' });
|
||||
},
|
||||
});
|
||||
},
|
||||
// fix: accept 为 video 时不能展示视频
|
||||
onPreviewVideo: function (event) {
|
||||
if (!this.data.previewFullImage) return;
|
||||
var index = event.currentTarget.dataset.index;
|
||||
@ -222,12 +219,10 @@ component_1.VantComponent({
|
||||
wx.previewMedia({
|
||||
sources: lists
|
||||
.filter(function (item) {
|
||||
return item.isVideo;
|
||||
return utils_1.isVideoFile(item);
|
||||
})
|
||||
.map(function (item) {
|
||||
item.type = 'video';
|
||||
item.url = item.url || item.path;
|
||||
return item;
|
||||
return __assign(__assign({}, item), { type: 'video' });
|
||||
}),
|
||||
current: index,
|
||||
fail: function () {
|
||||
|
@ -14,7 +14,7 @@
|
||||
<image
|
||||
wx:if="{{ item.isImage }}"
|
||||
mode="{{ imageFit }}"
|
||||
src="{{ item.url || item.path }}"
|
||||
src="{{ item.thumb || item.url }}"
|
||||
alt="{{ item.name || ('图片' + index) }}"
|
||||
class="van-uploader__preview-image"
|
||||
style="width: {{ utils.addUnit(previewSize) }}; height: {{ utils.addUnit(previewSize) }};"
|
||||
@ -23,21 +23,23 @@
|
||||
/>
|
||||
<video
|
||||
wx:elif="{{ item.isVideo }}"
|
||||
src="{{item.url || item.path}}"
|
||||
autoplay="{{item.autoplay}}"
|
||||
src="{{ item.url }}"
|
||||
title="{{ item.name || ('视频' + index) }}"
|
||||
poster="{{ item.thumb }}"
|
||||
autoplay="{{ item.autoplay }}"
|
||||
class="van-uploader__preview-image"
|
||||
style="width: {{ utils.addUnit(previewSize) }}; height: {{ utils.addUnit(previewSize) }};"
|
||||
data-index="{{ index }}"
|
||||
bind:tap="onPreviewVideo"
|
||||
>
|
||||
</video>
|
||||
</video>
|
||||
<view
|
||||
wx:else
|
||||
class="van-uploader__file"
|
||||
style="width: {{ utils.addUnit(previewSize) }}; height: {{ utils.addUnit(previewSize) }};"
|
||||
>
|
||||
<van-icon name="description" class="van-uploader__file-icon" />
|
||||
<view class="van-uploader__file-name van-ellipsis">{{ item.name || item.url || item.path }}</view>
|
||||
<view class="van-uploader__file-name van-ellipsis">{{ item.name || item.url }}</view>
|
||||
</view>
|
||||
<view
|
||||
wx:if="{{ item.status === 'uploading' || item.status === 'failed' }}"
|
||||
@ -59,7 +61,7 @@
|
||||
|
||||
<!-- 上传样式 -->
|
||||
<block wx:if="{{ isInCount }}">
|
||||
<view class="van-uploader__slot" bind:tap="startUpload">
|
||||
<view class="van-uploader__slot" bindtap="startUpload">
|
||||
<slot />
|
||||
</view>
|
||||
|
||||
|
@ -1,27 +1,100 @@
|
||||
'use strict';
|
||||
var __assign =
|
||||
(this && this.__assign) ||
|
||||
function () {
|
||||
__assign =
|
||||
Object.assign ||
|
||||
function (t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s)
|
||||
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
exports.isPromise = exports.isObject = exports.isFunction = exports.chooseFile = exports.isVideo = exports.isImageFile = void 0;
|
||||
var IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
|
||||
function isImageUrl(url) {
|
||||
return IMAGE_REGEXP.test(url);
|
||||
}
|
||||
exports.chooseFile = exports.isVideoFile = exports.isImageFile = void 0;
|
||||
var utils_1 = require('../common/utils');
|
||||
var validator_1 = require('../common/validator');
|
||||
function isImageFile(item) {
|
||||
if (item.type) {
|
||||
return item.type.indexOf('image') === 0;
|
||||
if (item.isImage != null) {
|
||||
return item.isImage;
|
||||
}
|
||||
if (item.path) {
|
||||
return isImageUrl(item.path);
|
||||
if (item.type) {
|
||||
return item.type === 'image';
|
||||
}
|
||||
if (item.url) {
|
||||
return isImageUrl(item.url);
|
||||
return validator_1.isImageUrl(item.url);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.isImageFile = isImageFile;
|
||||
function isVideo(res, accept) {
|
||||
return accept === 'video';
|
||||
function isVideoFile(item) {
|
||||
if (item.isVideo != null) {
|
||||
return item.isVideo;
|
||||
}
|
||||
if (item.type) {
|
||||
return item.type === 'video';
|
||||
}
|
||||
if (item.url) {
|
||||
return validator_1.isVideoUrl(item.url);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.isVideoFile = isVideoFile;
|
||||
function formatImage(res) {
|
||||
return res.tempFiles.map(function (item) {
|
||||
return __assign(__assign({}, utils_1.pickExclude(item, ['path'])), {
|
||||
type: 'image',
|
||||
url: item.path,
|
||||
thumb: item.path,
|
||||
});
|
||||
});
|
||||
}
|
||||
function formatVideo(res) {
|
||||
return [
|
||||
__assign(
|
||||
__assign(
|
||||
{},
|
||||
utils_1.pickExclude(res, [
|
||||
'tempFilePath',
|
||||
'thumbTempFilePath',
|
||||
'errMsg',
|
||||
])
|
||||
),
|
||||
{ type: 'video', url: res.tempFilePath, thumb: res.thumbTempFilePath }
|
||||
),
|
||||
];
|
||||
}
|
||||
function formatMedia(res) {
|
||||
return res.tempFiles.map(function (item) {
|
||||
return __assign(
|
||||
__assign(
|
||||
{},
|
||||
utils_1.pickExclude(item, [
|
||||
'fileType',
|
||||
'thumbTempFilePath',
|
||||
'tempFilePath',
|
||||
])
|
||||
),
|
||||
{
|
||||
type: res.type,
|
||||
url: item.tempFilePath,
|
||||
thumb:
|
||||
res.type === 'video' ? item.thumbTempFilePath : item.tempFilePath,
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
function formatFile(res) {
|
||||
return res.tempFiles.map(function (item) {
|
||||
return __assign(__assign({}, utils_1.pickExclude(item, ['path'])), {
|
||||
url: item.path,
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.isVideo = isVideo;
|
||||
function chooseFile(_a) {
|
||||
var accept = _a.accept,
|
||||
multiple = _a.multiple,
|
||||
@ -31,61 +104,55 @@ function chooseFile(_a) {
|
||||
sizeType = _a.sizeType,
|
||||
camera = _a.camera,
|
||||
maxCount = _a.maxCount;
|
||||
switch (accept) {
|
||||
case 'image':
|
||||
return new Promise(function (resolve, reject) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
switch (accept) {
|
||||
case 'image':
|
||||
wx.chooseImage({
|
||||
count: multiple ? Math.min(maxCount, 9) : 1,
|
||||
sourceType: capture,
|
||||
sizeType: sizeType,
|
||||
success: resolve,
|
||||
success: function (res) {
|
||||
return resolve(formatImage(res));
|
||||
},
|
||||
fail: reject,
|
||||
});
|
||||
});
|
||||
case 'media':
|
||||
return new Promise(function (resolve, reject) {
|
||||
break;
|
||||
case 'media':
|
||||
wx.chooseMedia({
|
||||
count: multiple ? Math.min(maxCount, 9) : 1,
|
||||
sourceType: capture,
|
||||
maxDuration: maxDuration,
|
||||
sizeType: sizeType,
|
||||
camera: camera,
|
||||
success: resolve,
|
||||
success: function (res) {
|
||||
return resolve(formatMedia(res));
|
||||
},
|
||||
fail: reject,
|
||||
});
|
||||
});
|
||||
case 'video':
|
||||
return new Promise(function (resolve, reject) {
|
||||
break;
|
||||
case 'video':
|
||||
wx.chooseVideo({
|
||||
sourceType: capture,
|
||||
compressed: compressed,
|
||||
maxDuration: maxDuration,
|
||||
camera: camera,
|
||||
success: resolve,
|
||||
success: function (res) {
|
||||
return resolve(formatVideo(res));
|
||||
},
|
||||
fail: reject,
|
||||
});
|
||||
});
|
||||
default:
|
||||
return new Promise(function (resolve, reject) {
|
||||
break;
|
||||
default:
|
||||
wx.chooseMessageFile({
|
||||
count: multiple ? maxCount : 1,
|
||||
type: 'file',
|
||||
success: resolve,
|
||||
type: accept,
|
||||
success: function (res) {
|
||||
return resolve(formatFile(res));
|
||||
},
|
||||
fail: reject,
|
||||
});
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.chooseFile = chooseFile;
|
||||
function isFunction(val) {
|
||||
return typeof val === 'function';
|
||||
}
|
||||
exports.isFunction = isFunction;
|
||||
function isObject(val) {
|
||||
return val !== null && typeof val === 'object';
|
||||
}
|
||||
exports.isObject = isObject;
|
||||
function isPromise(val) {
|
||||
return isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
||||
}
|
||||
exports.isPromise = isPromise;
|
||||
|
Loading…
x
Reference in New Issue
Block a user