提交初始版本,使用vant ui库
This commit is contained in:
1
miniprogram_npm/@vant/weapp/mixins/basic.d.ts
vendored
Normal file
1
miniprogram_npm/@vant/weapp/mixins/basic.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const basic: string;
|
14
miniprogram_npm/@vant/weapp/mixins/basic.js
Normal file
14
miniprogram_npm/@vant/weapp/mixins/basic.js
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.basic = void 0;
|
||||
exports.basic = Behavior({
|
||||
methods: {
|
||||
$emit: function (name, detail, options) {
|
||||
this.triggerEvent(name, detail, options);
|
||||
},
|
||||
set: function (data) {
|
||||
this.setData(data);
|
||||
return new Promise(function (resolve) { return wx.nextTick(resolve); });
|
||||
},
|
||||
},
|
||||
});
|
1
miniprogram_npm/@vant/weapp/mixins/button.d.ts
vendored
Normal file
1
miniprogram_npm/@vant/weapp/mixins/button.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const button: string;
|
54
miniprogram_npm/@vant/weapp/mixins/button.js
Normal file
54
miniprogram_npm/@vant/weapp/mixins/button.js
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.button = void 0;
|
||||
var version_1 = require("../common/version");
|
||||
exports.button = Behavior({
|
||||
externalClasses: ['hover-class'],
|
||||
properties: {
|
||||
id: String,
|
||||
buttonId: String,
|
||||
lang: String,
|
||||
businessId: Number,
|
||||
sessionFrom: String,
|
||||
sendMessageTitle: String,
|
||||
sendMessagePath: String,
|
||||
sendMessageImg: String,
|
||||
showMessageCard: Boolean,
|
||||
appParameter: String,
|
||||
ariaLabel: String,
|
||||
openType: String,
|
||||
getUserProfileDesc: String,
|
||||
},
|
||||
data: {
|
||||
canIUseGetUserProfile: (0, version_1.canIUseGetUserProfile)(),
|
||||
},
|
||||
methods: {
|
||||
onGetUserInfo: function (event) {
|
||||
this.triggerEvent('getuserinfo', event.detail);
|
||||
},
|
||||
onContact: function (event) {
|
||||
this.triggerEvent('contact', event.detail);
|
||||
},
|
||||
onGetPhoneNumber: function (event) {
|
||||
this.triggerEvent('getphonenumber', event.detail);
|
||||
},
|
||||
onGetRealTimePhoneNumber: function (event) {
|
||||
this.triggerEvent('getrealtimephonenumber', event.detail);
|
||||
},
|
||||
onError: function (event) {
|
||||
this.triggerEvent('error', event.detail);
|
||||
},
|
||||
onLaunchApp: function (event) {
|
||||
this.triggerEvent('launchapp', event.detail);
|
||||
},
|
||||
onOpenSetting: function (event) {
|
||||
this.triggerEvent('opensetting', event.detail);
|
||||
},
|
||||
onAgreePrivacyAuthorization: function (event) {
|
||||
this.triggerEvent('agreeprivacyauthorization', event.detail);
|
||||
},
|
||||
onChooseAvatar: function (event) {
|
||||
this.triggerEvent('chooseavatar', event.detail);
|
||||
},
|
||||
},
|
||||
});
|
1
miniprogram_npm/@vant/weapp/mixins/link.d.ts
vendored
Normal file
1
miniprogram_npm/@vant/weapp/mixins/link.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const link: string;
|
27
miniprogram_npm/@vant/weapp/mixins/link.js
Normal file
27
miniprogram_npm/@vant/weapp/mixins/link.js
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.link = void 0;
|
||||
exports.link = Behavior({
|
||||
properties: {
|
||||
url: String,
|
||||
linkType: {
|
||||
type: String,
|
||||
value: 'navigateTo',
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
jumpLink: function (urlKey) {
|
||||
if (urlKey === void 0) { urlKey = 'url'; }
|
||||
var url = this.data[urlKey];
|
||||
if (url) {
|
||||
if (this.data.linkType === 'navigateTo' &&
|
||||
getCurrentPages().length > 9) {
|
||||
wx.redirectTo({ url: url });
|
||||
}
|
||||
else {
|
||||
wx[this.data.linkType]({ url: url });
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
6
miniprogram_npm/@vant/weapp/mixins/page-scroll.d.ts
vendored
Normal file
6
miniprogram_npm/@vant/weapp/mixins/page-scroll.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
type IPageScrollOption = WechatMiniprogram.Page.IPageScrollOption;
|
||||
type Scroller = (this: WechatMiniprogram.Component.TrivialInstance, event?: IPageScrollOption) => void;
|
||||
export declare function pageScrollMixin(scroller: Scroller): string;
|
||||
export {};
|
47
miniprogram_npm/@vant/weapp/mixins/page-scroll.js
Normal file
47
miniprogram_npm/@vant/weapp/mixins/page-scroll.js
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.pageScrollMixin = void 0;
|
||||
var validator_1 = require("../common/validator");
|
||||
var utils_1 = require("../common/utils");
|
||||
function onPageScroll(event) {
|
||||
var _a = (0, utils_1.getCurrentPage)().vanPageScroller, vanPageScroller = _a === void 0 ? [] : _a;
|
||||
vanPageScroller.forEach(function (scroller) {
|
||||
if (typeof scroller === 'function') {
|
||||
// @ts-ignore
|
||||
scroller(event);
|
||||
}
|
||||
});
|
||||
}
|
||||
function pageScrollMixin(scroller) {
|
||||
return Behavior({
|
||||
attached: function () {
|
||||
var page = (0, utils_1.getCurrentPage)();
|
||||
if (!(0, utils_1.isDef)(page)) {
|
||||
return;
|
||||
}
|
||||
var _scroller = scroller.bind(this);
|
||||
var _a = page.vanPageScroller, vanPageScroller = _a === void 0 ? [] : _a;
|
||||
if ((0, validator_1.isFunction)(page.onPageScroll) && page.onPageScroll !== onPageScroll) {
|
||||
vanPageScroller.push(page.onPageScroll.bind(page));
|
||||
}
|
||||
vanPageScroller.push(_scroller);
|
||||
page.vanPageScroller = vanPageScroller;
|
||||
page.onPageScroll = onPageScroll;
|
||||
this._scroller = _scroller;
|
||||
},
|
||||
detached: function () {
|
||||
var _this = this;
|
||||
var page = (0, utils_1.getCurrentPage)();
|
||||
if (!(0, utils_1.isDef)(page) || !(0, utils_1.isDef)(page.vanPageScroller)) {
|
||||
return;
|
||||
}
|
||||
var vanPageScroller = page.vanPageScroller;
|
||||
var index = vanPageScroller.findIndex(function (v) { return v === _this._scroller; });
|
||||
if (index > -1) {
|
||||
page.vanPageScroller.splice(index, 1);
|
||||
}
|
||||
this._scroller = undefined;
|
||||
},
|
||||
});
|
||||
}
|
||||
exports.pageScrollMixin = pageScrollMixin;
|
1
miniprogram_npm/@vant/weapp/mixins/touch.d.ts
vendored
Normal file
1
miniprogram_npm/@vant/weapp/mixins/touch.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const touch: string;
|
40
miniprogram_npm/@vant/weapp/mixins/touch.js
Normal file
40
miniprogram_npm/@vant/weapp/mixins/touch.js
Normal file
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.touch = void 0;
|
||||
// @ts-nocheck
|
||||
var MIN_DISTANCE = 10;
|
||||
function getDirection(x, y) {
|
||||
if (x > y && x > MIN_DISTANCE) {
|
||||
return 'horizontal';
|
||||
}
|
||||
if (y > x && y > MIN_DISTANCE) {
|
||||
return 'vertical';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
exports.touch = Behavior({
|
||||
methods: {
|
||||
resetTouchStatus: function () {
|
||||
this.direction = '';
|
||||
this.deltaX = 0;
|
||||
this.deltaY = 0;
|
||||
this.offsetX = 0;
|
||||
this.offsetY = 0;
|
||||
},
|
||||
touchStart: function (event) {
|
||||
this.resetTouchStatus();
|
||||
var touch = event.touches[0];
|
||||
this.startX = touch.clientX;
|
||||
this.startY = touch.clientY;
|
||||
},
|
||||
touchMove: function (event) {
|
||||
var touch = event.touches[0];
|
||||
this.deltaX = touch.clientX - this.startX;
|
||||
this.deltaY = touch.clientY - this.startY;
|
||||
this.offsetX = Math.abs(this.deltaX);
|
||||
this.offsetY = Math.abs(this.deltaY);
|
||||
this.direction =
|
||||
this.direction || getDirection(this.offsetX, this.offsetY);
|
||||
},
|
||||
},
|
||||
});
|
1
miniprogram_npm/@vant/weapp/mixins/transition.d.ts
vendored
Normal file
1
miniprogram_npm/@vant/weapp/mixins/transition.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function transition(showDefaultValue: boolean): string;
|
136
miniprogram_npm/@vant/weapp/mixins/transition.js
Normal file
136
miniprogram_npm/@vant/weapp/mixins/transition.js
Normal file
@@ -0,0 +1,136 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.transition = void 0;
|
||||
// @ts-nocheck
|
||||
var utils_1 = require("../common/utils");
|
||||
var validator_1 = require("../common/validator");
|
||||
var getClassNames = function (name) { return ({
|
||||
enter: "van-".concat(name, "-enter van-").concat(name, "-enter-active enter-class enter-active-class"),
|
||||
'enter-to': "van-".concat(name, "-enter-to van-").concat(name, "-enter-active enter-to-class enter-active-class"),
|
||||
leave: "van-".concat(name, "-leave van-").concat(name, "-leave-active leave-class leave-active-class"),
|
||||
'leave-to': "van-".concat(name, "-leave-to van-").concat(name, "-leave-active leave-to-class leave-active-class"),
|
||||
}); };
|
||||
function transition(showDefaultValue) {
|
||||
return Behavior({
|
||||
properties: {
|
||||
customStyle: String,
|
||||
// @ts-ignore
|
||||
show: {
|
||||
type: Boolean,
|
||||
value: showDefaultValue,
|
||||
observer: 'observeShow',
|
||||
},
|
||||
// @ts-ignore
|
||||
duration: {
|
||||
type: null,
|
||||
value: 300,
|
||||
observer: 'observeDuration',
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
value: 'fade',
|
||||
},
|
||||
},
|
||||
data: {
|
||||
type: '',
|
||||
inited: false,
|
||||
display: false,
|
||||
},
|
||||
ready: function () {
|
||||
if (this.data.show === true) {
|
||||
this.observeShow(true, false);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
observeShow: function (value, old) {
|
||||
if (value === old) {
|
||||
return;
|
||||
}
|
||||
value ? this.enter() : this.leave();
|
||||
},
|
||||
enter: function () {
|
||||
var _this = this;
|
||||
if (this.enterFinishedPromise)
|
||||
return;
|
||||
this.enterFinishedPromise = new Promise(function (resolve) {
|
||||
var _a = _this.data, duration = _a.duration, name = _a.name;
|
||||
var classNames = getClassNames(name);
|
||||
var currentDuration = (0, validator_1.isObj)(duration) ? duration.enter : duration;
|
||||
if (_this.status === 'enter') {
|
||||
return;
|
||||
}
|
||||
_this.status = 'enter';
|
||||
_this.$emit('before-enter');
|
||||
(0, utils_1.requestAnimationFrame)(function () {
|
||||
if (_this.status !== 'enter') {
|
||||
return;
|
||||
}
|
||||
_this.$emit('enter');
|
||||
_this.setData({
|
||||
inited: true,
|
||||
display: true,
|
||||
classes: classNames.enter,
|
||||
currentDuration: currentDuration,
|
||||
});
|
||||
(0, utils_1.requestAnimationFrame)(function () {
|
||||
if (_this.status !== 'enter') {
|
||||
return;
|
||||
}
|
||||
_this.transitionEnded = false;
|
||||
_this.setData({ classes: classNames['enter-to'] });
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
leave: function () {
|
||||
var _this = this;
|
||||
if (!this.enterFinishedPromise)
|
||||
return;
|
||||
this.enterFinishedPromise.then(function () {
|
||||
if (!_this.data.display) {
|
||||
return;
|
||||
}
|
||||
var _a = _this.data, duration = _a.duration, name = _a.name;
|
||||
var classNames = getClassNames(name);
|
||||
var currentDuration = (0, validator_1.isObj)(duration) ? duration.leave : duration;
|
||||
_this.status = 'leave';
|
||||
_this.$emit('before-leave');
|
||||
(0, utils_1.requestAnimationFrame)(function () {
|
||||
if (_this.status !== 'leave') {
|
||||
return;
|
||||
}
|
||||
_this.$emit('leave');
|
||||
_this.setData({
|
||||
classes: classNames.leave,
|
||||
currentDuration: currentDuration,
|
||||
});
|
||||
(0, utils_1.requestAnimationFrame)(function () {
|
||||
if (_this.status !== 'leave') {
|
||||
return;
|
||||
}
|
||||
_this.transitionEnded = false;
|
||||
setTimeout(function () {
|
||||
_this.onTransitionEnd();
|
||||
_this.enterFinishedPromise = null;
|
||||
}, currentDuration);
|
||||
_this.setData({ classes: classNames['leave-to'] });
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
onTransitionEnd: function () {
|
||||
if (this.transitionEnded) {
|
||||
return;
|
||||
}
|
||||
this.transitionEnded = true;
|
||||
this.$emit("after-".concat(this.status));
|
||||
var _a = this.data, show = _a.show, display = _a.display;
|
||||
if (!show && display) {
|
||||
this.setData({ display: false });
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
exports.transition = transition;
|
Reference in New Issue
Block a user