1
This commit is contained in:
18
uview-plus/libs/mixin/button.js
Normal file
18
uview-plus/libs/mixin/button.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { defineMixin } from '../vue'
|
||||
|
||||
export const buttonMixin = defineMixin({
|
||||
props: {
|
||||
lang: String,
|
||||
sessionFrom: String,
|
||||
sendMessageTitle: String,
|
||||
sendMessagePath: String,
|
||||
sendMessageImg: String,
|
||||
showMessageCard: Boolean,
|
||||
appParameter: String,
|
||||
formType: String,
|
||||
openType: String
|
||||
}
|
||||
})
|
||||
|
||||
export default buttonMixin
|
||||
|
||||
201
uview-plus/libs/mixin/mixin.js
Normal file
201
uview-plus/libs/mixin/mixin.js
Normal file
File diff suppressed because it is too large
Load Diff
13
uview-plus/libs/mixin/mpMixin.js
Normal file
13
uview-plus/libs/mixin/mpMixin.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { defineMixin } from '../vue'
|
||||
|
||||
export const mpMixin = defineMixin({
|
||||
// #ifdef MP-WEIXIN
|
||||
// 将自定义节点设置成虚拟的,更加接近Vue组件的表现,能更好的使用flex属性
|
||||
options: {
|
||||
virtualHost: true
|
||||
}
|
||||
// #endif
|
||||
})
|
||||
|
||||
export default mpMixin
|
||||
|
||||
26
uview-plus/libs/mixin/mpShare.js
Normal file
26
uview-plus/libs/mixin/mpShare.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { defineMixin } from '../vue'
|
||||
import { queryParams } from '../function/index'
|
||||
export const mpShare = defineMixin({
|
||||
data() {
|
||||
return {
|
||||
mpShare: {
|
||||
title: '', // 默认为小程序名称
|
||||
path: '', // 默认为当前页面路径
|
||||
imageUrl: '' // 默认为当前页面的截图
|
||||
}
|
||||
}
|
||||
},
|
||||
async onLoad(options) {
|
||||
var pages = getCurrentPages();
|
||||
var page = pages[pages.length - 1];
|
||||
this.mpShare.path = page.route + queryParams(options);
|
||||
},
|
||||
onShareAppMessage(res) {
|
||||
if (res.from === 'button') {// 来自页面内分享按钮
|
||||
console.log(res.target)
|
||||
}
|
||||
return this.mpShare;
|
||||
}
|
||||
})
|
||||
|
||||
export default mpShare
|
||||
27
uview-plus/libs/mixin/openType.js
Normal file
27
uview-plus/libs/mixin/openType.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { defineMixin } from '../vue'
|
||||
|
||||
export const openType = defineMixin({
|
||||
props: {
|
||||
openType: String
|
||||
},
|
||||
methods: {
|
||||
onGetUserInfo(event) {
|
||||
this.$emit('getuserinfo', event.detail)
|
||||
},
|
||||
onContact(event) {
|
||||
this.$emit('contact', event.detail)
|
||||
},
|
||||
onGetPhoneNumber(event) {
|
||||
this.$emit('getphonenumber', event.detail)
|
||||
},
|
||||
onError(event) {
|
||||
this.$emit('error', event.detail)
|
||||
},
|
||||
onLaunchApp(event) {
|
||||
this.$emit('launchapp', event.detail)
|
||||
},
|
||||
onOpenSetting(event) {
|
||||
this.$emit('opensetting', event.detail)
|
||||
}
|
||||
}
|
||||
})
|
||||
249
uview-plus/libs/mixin/style.js
Normal file
249
uview-plus/libs/mixin/style.js
Normal file
File diff suppressed because it is too large
Load Diff
61
uview-plus/libs/mixin/touch.js
Normal file
61
uview-plus/libs/mixin/touch.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import { defineMixin } from '../vue'
|
||||
|
||||
const MIN_DISTANCE = 10
|
||||
|
||||
function getDirection(x, y) {
|
||||
if (x > y && x > MIN_DISTANCE) {
|
||||
return 'horizontal'
|
||||
}
|
||||
if (y > x && y > MIN_DISTANCE) {
|
||||
return 'vertical'
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export const touchMixin = defineMixin({
|
||||
methods: {
|
||||
getTouchPoint(e) {
|
||||
if (!e) {
|
||||
return {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
} if (e.touches && e.touches[0]) {
|
||||
return {
|
||||
x: e.touches[0].pageX,
|
||||
y: e.touches[0].pageY
|
||||
}
|
||||
} if (e.changedTouches && e.changedTouches[0]) {
|
||||
return {
|
||||
x: e.changedTouches[0].pageX,
|
||||
y: e.changedTouches[0].pageY
|
||||
}
|
||||
}
|
||||
return {
|
||||
x: e.clientX || 0,
|
||||
y: e.clientY || 0
|
||||
}
|
||||
},
|
||||
resetTouchStatus() {
|
||||
this.direction = ''
|
||||
this.deltaX = 0
|
||||
this.deltaY = 0
|
||||
this.offsetX = 0
|
||||
this.offsetY = 0
|
||||
},
|
||||
touchStart(event) {
|
||||
this.resetTouchStatus()
|
||||
const touch = this.getTouchPoint(event)
|
||||
this.startX = touch.x
|
||||
this.startY = touch.y
|
||||
},
|
||||
touchMove(event) {
|
||||
const touch = this.getTouchPoint(event)
|
||||
this.deltaX = touch.x - this.startX
|
||||
this.deltaY = touch.y - this.startY
|
||||
this.offsetX = Math.abs(this.deltaX)
|
||||
this.offsetY = Math.abs(this.deltaY)
|
||||
this.direction = this.direction || getDirection(this.offsetX, this.offsetY)
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user