增加other分包页面
我的页面里增加跳转other分包跳转(仅在ios不是浏览器审核时展示)
This commit is contained in:
47
tuniao-ui/libs/mixin/components_color.js
Normal file
47
tuniao-ui/libs/mixin/components_color.js
Normal file
@@ -0,0 +1,47 @@
|
||||
module.exports = {
|
||||
data() {
|
||||
|
||||
},
|
||||
props: {
|
||||
// 背景颜色
|
||||
backgroundColor: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
// 字体颜色
|
||||
fontColor: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
// 字体大小
|
||||
fontSize: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
// 字体大小单位
|
||||
fontUnit: {
|
||||
type: String,
|
||||
default: 'rpx'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
backgroundColorStyle() {
|
||||
return this.$t.color.getBackgroundColorStyle(this.backgroundColor)
|
||||
},
|
||||
backgroundColorClass() {
|
||||
return this.$t.color.getBackgroundColorInternalClass(this.backgroundColor)
|
||||
},
|
||||
fontColorStyle() {
|
||||
return this.$t.color.getFontColorStyle(this.fontColor)
|
||||
},
|
||||
fontColorClass() {
|
||||
return this.$t.color.getFontColorInternalClass(this.fontColor)
|
||||
},
|
||||
fontSizeStyle() {
|
||||
return this.$t.string.getLengthUnitValue(this.fontSize, this.fontUnit)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
}
|
||||
}
|
||||
68
tuniao-ui/libs/mixin/mixin.js
Normal file
68
tuniao-ui/libs/mixin/mixin.js
Normal file
@@ -0,0 +1,68 @@
|
||||
module.exports = {
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
onLoad() {
|
||||
// getRect挂载再$t上,用为这个方法需要使用in(this),所以无法把它独立层一个单独的文件导出
|
||||
this.$t.getRect = this._tGetRect
|
||||
},
|
||||
beforeDestory() {
|
||||
// 判断当前页面是否存在parent和children
|
||||
// 组件销毁时,移除子组件在父组件children数组中的实例,释放资源,避免数据混乱
|
||||
if (this.parent && uni.$t.test.array(this.parent.children)) {
|
||||
// 组件销毁时,移除子组件在父组件children数组中的实例
|
||||
const childrenList = this.parent.children
|
||||
childrenList.map((child, index) => {
|
||||
// 如果相对,则移除
|
||||
if (child === this) {
|
||||
childrenList.splice(index, 1)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 查询节点信息
|
||||
* 当前方法在支付宝小程序中无法获取组件跟接点的尺寸
|
||||
* 解决办法:为组件根部再套一个没有任何作用的view元素
|
||||
*/
|
||||
_tGetRect(selector, all) {
|
||||
return new Promise((resolve) => {
|
||||
uni.createSelectorQuery()
|
||||
.in(this)[all ? 'selectAll' : 'select'](selector)
|
||||
.boundingClientRect(rect => {
|
||||
if (all && Array.isArray(rect) && rect.length) {
|
||||
resolve(rect)
|
||||
}
|
||||
if (!all && rect) {
|
||||
resolve(rect)
|
||||
}
|
||||
})
|
||||
.exec()
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 获取父组件的数据
|
||||
*/
|
||||
getParentData(parentName = '') {
|
||||
// 避免再created中定义parent变量
|
||||
if (!this.parent) this.parent = false
|
||||
// 通过获取父组件实例
|
||||
// 将父组件this中对应的参数,赋值给本组件的parentData对象中对应的属性
|
||||
// 头条小程序不支持通过this.parent.xxx去监听父组件参数的变化,所以需要本方法进行实现
|
||||
this.parent = this.$t.$parent.call(this, parentName)
|
||||
if (this.parent) {
|
||||
// 遍历parentData中的属性,将parent中同名的属性赋值给parentData
|
||||
Object.keys(this.parentData).map(key => {
|
||||
this.parentData[key] = this.parent[key]
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 阻止事件冒泡
|
||||
*/
|
||||
preventEvent(e) {
|
||||
e && e.stopPropagation && e.stopPropagation()
|
||||
}
|
||||
}
|
||||
}
|
||||
30
tuniao-ui/libs/mixin/mpShare.js
Normal file
30
tuniao-ui/libs/mixin/mpShare.js
Normal file
@@ -0,0 +1,30 @@
|
||||
module.exports = {
|
||||
onLoad() {
|
||||
// 设置默认的转发参数
|
||||
this.$t.mpShare = {
|
||||
// 分享的标题,默认为小程序名称
|
||||
title: '',
|
||||
// 分享的路径,默认为当前页面
|
||||
path: '',
|
||||
// 分享时显示的图片,默认为当前页面截图
|
||||
imageUrl: '',
|
||||
// 当前页面是否可以分享
|
||||
share: true
|
||||
}
|
||||
if (!this.$t.mpShare.share) {
|
||||
uni.hideShareMenu()
|
||||
}
|
||||
},
|
||||
onShareAppMessage() {
|
||||
return this.$t.mpShare
|
||||
},
|
||||
// #ifdef MP-WEIXIN
|
||||
onShareTimeline() {
|
||||
return {
|
||||
title: this.$t.mpShare.title,
|
||||
query: this.$t.mpShare.path.substring(this.$t.mpShare.path.indexOf('?') + 1, this.$t.mpShare.path.length),
|
||||
imageUrl: this.$t.mpShare.imageUrl
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
61
tuniao-ui/libs/mixin/touch.js
Normal file
61
tuniao-ui/libs/mixin/touch.js
Normal file
@@ -0,0 +1,61 @@
|
||||
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 default {
|
||||
methods: {
|
||||
touchStart(e) {
|
||||
this.resetTouchStatus()
|
||||
const touch = this.getTouchPoint(e)
|
||||
this.startX = touch.x
|
||||
this.startY = touch.y
|
||||
},
|
||||
touchMove(e) {
|
||||
const touch = this.getTouchPoint(e)
|
||||
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)
|
||||
},
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user