weapp版本升级到1.11.7

"version": "1.11.7"
This commit is contained in:
Abin committed 2026-01-07 13:54:40 +08:00
1 parent a3c886146a
commit 66ba21dd7b
67 files changed
+566 -365

No files matched your search

+5
View File
@@ -36,6 +36,10 @@ VantComponent({
type: Boolean,
value: true,
},
ellipsis: {
type: Boolean,
value: true,
},
showHeader: {
type: Boolean,
value: true,
@@ -148,6 +152,7 @@ VantComponent({
selected: null,
},
],
activeTab: 0,
});
},
onClose() {
+1
View File
@@ -19,6 +19,7 @@
color="{{ activeColor }}"
border="{{ false }}"
swipeable="{{ swipeable }}"
ellipsis="{{ ellipsis }}"
bind:click="onClickTab"
>
<van-tab
+3 -2
View File
@@ -24,6 +24,7 @@ VantComponent({
},
data: {
expanded: false,
parentBorder: true,
},
mounted() {
this.updateExpanded();
@@ -34,7 +35,7 @@ VantComponent({
if (!this.parent) {
return;
}
const { value, accordion } = this.parent.data;
const { value, accordion, border } = this.parent.data;
const { children = [] } = this.parent;
const { name } = this.data;
const index = children.indexOf(this);
@@ -45,7 +46,7 @@ VantComponent({
if (expanded !== this.data.expanded) {
setContentAnimate(this, expanded, this.mounted);
}
this.setData({ index, expanded });
this.setData({ index, expanded, parentBorder: border });
},
onClick() {
if (this.data.disabled) {
+1 -1
View File
@@ -1,6 +1,6 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<view class="van-collapse-item custom-class {{ index !== 0 ? 'van-hairline--top' : '' }}">
<view class="van-collapse-item custom-class {{ index !== 0 && parentBorder ? 'van-hairline--top' : '' }}">
<van-cell
size="{{ size }}"
title="{{ title }}"
+1
View File
@@ -4,6 +4,7 @@ interface VantComponentInstance {
children: WechatMiniprogram.Component.TrivialInstance[];
index: number;
$emit: (name: string, detail?: unknown, options?: WechatMiniprogram.Component.TriggerEventOption) => void;
setView: (value: Record<string, any>, callback?: () => void) => void;
}
export type VantComponentOptions<Data extends WechatMiniprogram.Component.DataOption, Props extends WechatMiniprogram.Component.PropertyOption, Methods extends WechatMiniprogram.Component.MethodOption> = {
data?: Data;
+9 -7
View File
@@ -89,13 +89,15 @@ VantComponent({
},
close(action) {
this.setData({ show: false });
wx.nextTick(() => {
this.$emit('close', action);
const { callback } = this.data;
if (callback) {
callback(action, this);
}
});
this.closeAction = action;
},
onAfterLeave() {
const { closeAction: action } = this;
this.$emit('close', action);
const { callback } = this.data;
if (callback) {
callback(action, this);
}
},
stopLoading() {
this.setData({
+1
View File
@@ -11,6 +11,7 @@
close-on-click-overlay="{{ closeOnClickOverlay }}"
root-portal="{{ rootPortal }}"
bind:close="onClickOverlay"
bind:after-leave="onAfterLeave"
>
<view
wx:if="{{ title || useTitleSlot }}"
+16 -1
View File
@@ -31,6 +31,18 @@ VantComponent({
innerValue: '',
showClear: false,
},
watch: {
value(value) {
if (value !== this.value) {
this.setData({ innerValue: value });
this.value = value;
this.setShowClear();
}
},
clearTrigger() {
this.setShowClear();
},
},
created() {
this.value = this.data.value;
this.setData({ innerValue: this.value });
@@ -95,6 +107,9 @@ VantComponent({
onKeyboardHeightChange(event) {
this.$emit('keyboardheightchange', event.detail);
},
onBindNicknameReview(event) {
this.$emit('nicknamereview', event.detail);
},
emitChange(detail) {
const { extraEventParams } = this.data;
this.setData({ value: detail.value });
@@ -116,7 +131,7 @@ VantComponent({
const trigger = clearTrigger === 'always' || (clearTrigger === 'focus' && focused);
showClear = hasValue && trigger;
}
this.setData({ showClear });
this.setView({ showClear });
},
noop() { },
},
+1
View File
@@ -27,4 +27,5 @@
bindfocus="onFocus"
bindconfirm="onConfirm"
bindkeyboardheightchange="onKeyboardHeightChange"
bindnicknamereview="onBindNicknameReview"
/>
+1 -9
View File
@@ -1,13 +1,5 @@
export const commonProps = {
value: {
type: String,
observer(value) {
if (value !== this.value) {
this.setData({ innerValue: value });
this.value = value;
}
},
},
value: String,
placeholder: String,
placeholderStyle: String,
placeholderClass: String,
+1 -1
View File
@@ -1 +1 @@
@import '../common/index.wxss';.van-image{display:inline-block;position:relative}.van-image--round{border-radius:50%;overflow:hidden}.van-image--round .van-image__img{border-radius:inherit}.van-image__error,.van-image__img,.van-image__loading{display:block;height:100%;width:100%}.van-image__error,.van-image__loading{align-items:center;background-color:var(--image-placeholder-background-color,#f7f8fa);color:var(--image-placeholder-text-color,#969799);display:flex;flex-direction:column;font-size:var(--image-placeholder-font-size,14px);justify-content:center;left:0;position:absolute;top:0}.van-image__loading-icon{color:var(--image-loading-icon-color,#dcdee0);font-size:var(--image-loading-icon-size,32px)!important}.van-image__error-icon{color:var(--image-error-icon-color,#dcdee0);font-size:var(--image-error-icon-size,32px)!important}
@import '../common/index.wxss';.van-image{display:inline-block;position:relative;vertical-align:top}.van-image--round{border-radius:50%;overflow:hidden}.van-image--round .van-image__img{border-radius:inherit}.van-image__error,.van-image__img,.van-image__loading{display:block;height:100%;width:100%}.van-image__error,.van-image__loading{align-items:center;background-color:var(--image-placeholder-background-color,#f7f8fa);color:var(--image-placeholder-text-color,#969799);display:flex;flex-direction:column;font-size:var(--image-placeholder-font-size,14px);justify-content:center;left:0;position:absolute;top:0}.van-image__loading-icon{color:var(--image-loading-icon-color,#dcdee0);font-size:var(--image-loading-icon-size,32px)!important}.van-image__error-icon{color:var(--image-error-icon-color,#dcdee0);font-size:var(--image-error-icon-size,32px)!important}
+15
View File
@@ -7,5 +7,20 @@ export const basic = Behavior({
this.setData(data);
return new Promise((resolve) => wx.nextTick(resolve));
},
// high performance setData
setView(data, callback) {
const target = {};
let hasChange = false;
Object.keys(data).forEach((key) => {
if (data[key] !== this.data[key]) {
target[key] = data[key];
hasChange = true;
}
});
if (hasChange) {
return this.setData(target, callback);
}
return callback && callback();
},
},
});
+57 -51
View File
@@ -21,7 +21,6 @@ export function transition(showDefaultValue) {
duration: {
type: null,
value: 300,
observer: 'observeDuration',
},
name: {
type: String,
@@ -43,74 +42,81 @@ export function transition(showDefaultValue) {
if (value === old) {
return;
}
value ? this.enter() : this.leave();
value ? this.enureEnter() : this.enureLeave();
},
enter() {
if (this.enterFinishedPromise)
enureEnter() {
if (this.enterPromise)
return;
this.enterFinishedPromise = new Promise((resolve) => {
const { duration, name } = this.data;
const classNames = getClassNames(name);
const currentDuration = isObj(duration) ? duration.enter : duration;
if (this.status === 'enter') {
this.enterPromise = new Promise((resolve) => this.enter(resolve));
},
enureLeave() {
const { enterPromise } = this;
if (!enterPromise)
return;
enterPromise
.then(() => new Promise((resolve) => this.leave(resolve)))
.then(() => {
this.enterPromise = null;
});
},
enter(resolve) {
const { duration, name } = this.data;
const classNames = getClassNames(name);
const currentDuration = isObj(duration) ? duration.enter : duration;
if (this.status === 'enter') {
return;
}
this.status = 'enter';
this.$emit('before-enter');
requestAnimationFrame(() => {
if (this.status !== 'enter') {
return;
}
this.status = 'enter';
this.$emit('before-enter');
this.$emit('enter');
this.setData({
inited: true,
display: true,
classes: classNames.enter,
currentDuration,
});
requestAnimationFrame(() => {
if (this.status !== 'enter') {
return;
}
this.$emit('enter');
this.setData({
inited: true,
display: true,
classes: classNames.enter,
currentDuration,
});
requestAnimationFrame(() => {
if (this.status !== 'enter') {
return;
}
this.transitionEnded = false;
this.setData({ classes: classNames['enter-to'] });
resolve();
});
this.transitionEnded = false;
this.setData({ classes: classNames['enter-to'] });
resolve();
});
});
},
leave() {
if (!this.enterFinishedPromise)
leave(resolve) {
if (!this.data.display) {
return;
this.enterFinishedPromise.then(() => {
if (!this.data.display) {
}
const { duration, name } = this.data;
const classNames = getClassNames(name);
const currentDuration = isObj(duration) ? duration.leave : duration;
this.status = 'leave';
this.$emit('before-leave');
requestAnimationFrame(() => {
if (this.status !== 'leave') {
return;
}
const { duration, name } = this.data;
const classNames = getClassNames(name);
const currentDuration = isObj(duration) ? duration.leave : duration;
this.status = 'leave';
this.$emit('before-leave');
this.$emit('leave');
this.setData({
classes: classNames.leave,
currentDuration,
});
requestAnimationFrame(() => {
if (this.status !== 'leave') {
return;
}
this.$emit('leave');
this.setData({
classes: classNames.leave,
currentDuration,
});
requestAnimationFrame(() => {
if (this.status !== 'leave') {
return;
}
this.transitionEnded = false;
setTimeout(() => {
this.onTransitionEnd();
this.enterFinishedPromise = null;
}, currentDuration);
this.setData({ classes: classNames['leave-to'] });
});
this.transitionEnded = false;
setTimeout(() => {
this.onTransitionEnd();
resolve();
}, currentDuration);
this.setData({ classes: classNames['leave-to'] });
});
});
},
+19 -12
View File
@@ -61,7 +61,7 @@ VantComponent({
getRect(this, '.van-notice-bar__wrap'),
]).then((rects) => {
const [contentRect, wrapRect] = rects;
const { speed, scrollable, delay } = this.data;
const { scrollable } = this.data;
if (contentRect == null ||
wrapRect == null ||
!contentRect.width ||
@@ -70,20 +70,26 @@ VantComponent({
return;
}
if (scrollable || wrapRect.width < contentRect.width) {
const duration = ((wrapRect.width + contentRect.width) / speed) * 1000;
this.wrapWidth = wrapRect.width;
this.contentWidth = contentRect.width;
this.duration = duration;
this.animation = wx.createAnimation({
duration,
timingFunction: 'linear',
delay,
});
this.initAnimation(wrapRect.width, contentRect.width);
this.scroll(true);
}
});
});
},
initAnimation(warpWidth, contentWidth) {
const { speed, delay } = this.data;
this.wrapWidth = warpWidth;
this.contentWidth = contentWidth;
// begin 0
this.contentDuration = (contentWidth / speed) * 1000;
// begin -wrapWidth
this.duration = ((warpWidth + contentWidth) / speed) * 1000;
this.animation = wx.createAnimation({
duration: this.contentDuration,
timingFunction: 'linear',
delay,
});
},
scroll(isInit = false) {
this.timer && clearTimeout(this.timer);
this.timer = null;
@@ -93,17 +99,18 @@ VantComponent({
.step()
.export(),
});
const duration = isInit ? this.contentDuration : this.duration;
requestAnimationFrame(() => {
this.setData({
animationData: this.animation
.translateX(-this.contentWidth)
.step()
.step({ duration })
.export(),
});
});
this.timer = setTimeout(() => {
this.scroll();
}, this.duration + this.data.delay);
}, duration + this.data.delay);
},
onClickIcon(event) {
if (this.data.mode === 'closeable') {
+23 -27
View File
@@ -72,18 +72,18 @@ VantComponent({
},
created() {
this.setData({
currentValue: this.format(this.data.value),
currentValue: this.format(this.data.value).newValue,
});
},
methods: {
observeValue() {
const { value } = this.data;
this.setData({ currentValue: this.format(value) });
this.setData({ currentValue: this.format(value).newValue });
},
check() {
const val = this.format(this.data.currentValue);
if (!equal(val, this.data.currentValue)) {
this.setData({ currentValue: val });
const { newValue } = this.format(this.data.currentValue);
if (!equal(newValue, this.data.currentValue)) {
this.setData({ currentValue: newValue });
}
},
isDisabled(type) {
@@ -97,10 +97,10 @@ VantComponent({
this.$emit('focus', event.detail);
},
onBlur(event) {
const value = this.format(event.detail.value);
this.setData({ currentValue: value });
this.emitChange(value);
this.$emit('blur', Object.assign(Object.assign({}, event.detail), { value }));
const data = this.format(event.detail.value);
this.setData({ currentValue: data.newValue });
this.emitChange(data);
this.$emit('blur', Object.assign(Object.assign({}, event.detail), { value: +data.newValue }));
},
// filter illegal characters
filter(value) {
@@ -110,17 +110,16 @@ VantComponent({
}
return value;
},
// limit value range
format(value) {
value = this.filter(value);
// filter illegal characters and format integer
const safeValue = this.filter(value);
// format range
value = value === '' ? 0 : +value;
value = Math.max(Math.min(this.data.max, value), this.data.min);
const rangeValue = Math.max(Math.min(this.data.max, +safeValue), this.data.min);
// format decimal
if (isDef(this.data.decimalLength)) {
value = value.toFixed(this.data.decimalLength);
}
return value;
const newValue = isDef(this.data.decimalLength)
? rangeValue.toFixed(this.data.decimalLength)
: String(rangeValue);
return { value, newValue };
},
onInput(event) {
const { value = '' } = event.detail || {};
@@ -128,19 +127,16 @@ VantComponent({
if (value === '') {
return;
}
let formatted = this.filter(value);
// limit max decimal length
if (isDef(this.data.decimalLength) && formatted.indexOf('.') !== -1) {
const pair = formatted.split('.');
formatted = `${pair[0]}.${pair[1].slice(0, this.data.decimalLength)}`;
}
const formatted = this.format(value);
this.emitChange(formatted);
},
emitChange(value) {
emitChange(data) {
const { value, newValue } = data;
if (!this.data.asyncChange) {
this.setData({ currentValue: value });
// fix when input 11. parsed to 11, unable to enter decimal
this.setData({ currentValue: +value === +newValue ? value : newValue });
}
this.$emit('change', value);
this.$emit('change', +newValue);
},
onChange() {
const { type } = this;
@@ -149,7 +145,7 @@ VantComponent({
return;
}
const diff = type === 'minus' ? -this.data.step : +this.data.step;
const value = this.format(add(+this.data.currentValue, diff));
const value = this.format(String(add(+this.data.currentValue, diff)));
this.emitChange(value);
this.$emit(type);
},
+1 -1
View File
@@ -1 +1 @@
@import '../common/index.wxss';.van-steps{background-color:var(--steps-background-color,#fff);overflow:hidden}.van-steps--horizontal{padding:10px}.van-steps--horizontal .van-step__wrapper{display:flex;overflow:hidden;position:relative}.van-steps--vertical{padding-left:10px}.van-steps--vertical .van-step__wrapper{padding:0 0 0 20px}.van-step{color:var(--step-text-color,#969799);flex:1;font-size:var(--step-font-size,14px);position:relative}.van-step--finish{color:var(--step-finish-text-color,#323233)}.van-step__circle{background-color:var(--step-circle-color,#969799);border-radius:50%;height:var(--step-circle-size,5px);width:var(--step-circle-size,5px)}.van-step--horizontal{padding-bottom:14px}.van-step--horizontal:first-child .van-step__title{transform:none}.van-step--horizontal:first-child .van-step__circle-container{padding:0 8px 0 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;transform:none}.van-step--horizontal:last-child .van-step__circle-container{padding:0 0 0 8px;right:0;transform:translate3d(0,50%,0)}.van-step--horizontal .van-step__circle-container{background-color:#fff;bottom:6px;padding:0 var(--padding-xs,8px);position:absolute;transform:translate3d(-50%,50%,0);z-index:1}.van-step--horizontal .van-step__title{display:inline-block;font-size:var(--step-horizontal-title-font-size,12px);transform:translate3d(-50%,0,0)}.van-step--horizontal .van-step__line{background-color:var(--step-line-color,#ebedf0);bottom:6px;height:1px;left:0;position:absolute;right:0;transform:translate3d(0,50%,0)}.van-step--horizontal.van-step--process{color:var(--step-process-text-color,#323233)}.van-step--horizontal.van-step--process .van-step__icon{display:block;font-size:var(--step-icon-size,12px);line-height:1}.van-step--vertical{line-height:18px;padding:10px 10px 10px 0}.van-step--vertical:after{border-bottom-width:1px}.van-step--vertical:last-child:after{border-bottom-width:none}.van-step--vertical:first-child:before{background-color:#fff;content:"";height:20px;left:-15px;position:absolute;top:0;width:1px;z-index:1}.van-step--vertical .van-step__circle,.van-step--vertical .van-step__icon,.van-step--vertical .van-step__line{left:-14px;position:absolute;top:19px;transform:translate3d(-50%,-50%,0);z-index:2}.van-step--vertical .van-step__icon{background-color:var(--steps-background-color,#fff);font-size:var(--step-icon-size,12px);line-height:1}.van-step--vertical .van-step__line{background-color:var(--step-line-color,#ebedf0);height:100%;transform:translate3d(-50%,0,0);width:1px;z-index:1}
@import '../common/index.wxss';.van-steps{background-color:var(--steps-background-color,#fff);overflow:hidden}.van-steps--horizontal{padding:10px}.van-steps--horizontal .van-step__wrapper{display:flex;overflow:hidden;position:relative}.van-steps--vertical{padding-left:10px}.van-steps--vertical .van-step__wrapper{padding:0 0 0 20px}.van-step{color:var(--step-text-color,#969799);flex:1;font-size:var(--step-font-size,14px);position:relative}.van-step--finish{color:var(--step-finish-text-color,#323233)}.van-step__circle{background-color:var(--step-circle-color,#969799);border-radius:50%;height:var(--step-circle-size,5px);width:var(--step-circle-size,5px)}.van-step--horizontal{padding-bottom:14px}.van-step--horizontal:first-child .van-step__title{transform:none}.van-step--horizontal:first-child .van-step__circle-container{padding:0 8px 0 0;transform:translate3d(0,50%,0)}.van-step--horizontal:last-child{bottom:0;position:absolute;right:0;top:0;width:auto}.van-step--horizontal:last-child .van-step__title{text-align:right;transform:none}.van-step--horizontal:last-child .van-step__circle-container{padding:0 0 0 8px;right:0;transform:translate3d(0,50%,0)}.van-step--horizontal .van-step__circle-container{background-color:#fff;bottom:6px;padding:0 var(--padding-xs,8px);position:absolute;transform:translate3d(-50%,50%,0);z-index:1}.van-step--horizontal .van-step__title{display:inline-block;font-size:var(--step-horizontal-title-font-size,12px);transform:translate3d(-50%,0,0)}.van-step--horizontal .van-step__line{background-color:var(--step-line-color,#ebedf0);bottom:6px;height:1px;left:0;position:absolute;right:0;transform:translate3d(0,50%,0)}.van-step--horizontal.van-step--process{color:var(--step-process-text-color,#323233)}.van-step--horizontal.van-step--process .van-step__icon{display:block;font-size:var(--step-icon-size,12px);line-height:1}.van-step--vertical{line-height:18px;padding:10px 10px 10px 0}.van-step--vertical:after{border-bottom-width:1px}.van-step--vertical:last-child:after{border-bottom-width:none}.van-step--vertical:first-child:before{background-color:#fff;content:"";height:20px;left:-15px;position:absolute;top:0;width:1px;z-index:1}.van-step--vertical .van-step__circle,.van-step--vertical .van-step__icon,.van-step--vertical .van-step__line{left:-14px;position:absolute;top:19px;transform:translate3d(-50%,-50%,0);z-index:2}.van-step--vertical .van-step__icon{background-color:var(--steps-background-color,#fff);font-size:var(--step-icon-size,12px);line-height:1}.van-step--vertical .van-step__line{background-color:var(--step-line-color,#ebedf0);height:100%;transform:translate3d(-50%,0,0);width:1px;z-index:1}
+4 -2
View File
@@ -1,7 +1,7 @@
import { VantComponent } from '../common/component';
import { isImageFile, chooseFile, isVideoFile } from './utils';
import { imageProps, videoProps, mediaProps, messageFileProps } from './shared';
import { isBoolean, isPromise } from '../common/validator';
import { imageProps, mediaProps, messageFileProps, videoProps } from './shared';
import { chooseFile, isImageFile, isVideoFile } from './utils';
VantComponent({
props: Object.assign(Object.assign(Object.assign(Object.assign({ disabled: Boolean, multiple: Boolean, uploadText: String, useBeforeRead: Boolean, afterRead: null, beforeRead: null, previewSize: {
type: null,
@@ -153,6 +153,8 @@ VantComponent({
});
},
onPreviewFile(event) {
if (!this.data.previewFile)
return;
const { index } = event.currentTarget.dataset;
wx.openDocument({
filePath: this.data.lists[index].url,
+1
View File
@@ -29,6 +29,7 @@
poster="{{ item.thumb }}"
autoplay="{{ item.autoplay }}"
object-fit="{{videoFit}}"
referrer-policy="{{ referrerPolicy }}"
class="van-uploader__preview-image"
style="{{ computed.sizeStyle({ previewSize }) }}"
data-index="{{ index }}"
+8
View File
@@ -29,6 +29,10 @@ export declare const videoProps: {
type: StringConstructor;
value: string;
};
referrerPolicy: {
type: StringConstructor;
value: string;
};
};
export declare const mediaProps: {
capture: {
@@ -50,4 +54,8 @@ export declare const mediaProps: {
};
export declare const messageFileProps: {
extension: null;
previewFile: {
type: BooleanConstructor;
value: boolean;
};
};
+8
View File
@@ -31,6 +31,10 @@ export const videoProps = {
type: String,
value: 'back',
},
referrerPolicy: {
type: String,
value: 'no-referrer',
},
};
// props for media
export const mediaProps = {
@@ -54,4 +58,8 @@ export const mediaProps = {
// props for file
export const messageFileProps = {
extension: null,
previewFile: {
type: Boolean,
value: true,
},
};