市北人才赋能平台 --小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

82 lines
2.2 KiB

// pages/topics/common/interactive/common/imageCell/index.js
import { store } from '../../../../utils/store.js'
Component({
/**
* 组件的属性列表
*/
properties: {
activityId: String,
title: String,
activityImg:String,
time: String,
commentNum: Number,
dataIndex:Number,
},
/**
* 组件的初始数据
*/
data: {
startX: 0, //开始坐标
startY: 0
},
/**
* 组件的方法列表
*/
methods: {
onTap() {
this.triggerEvent('clickListItem', { activityId: this.properties.activityId })
},
touchstart: function (e) {
let {nickName} = store.readUserInfo()
if (e.currentTarget.dataset.name === nickName) {
//开始触摸时 重置所有删除
if (this.properties.isTouchMove) {
this.setData({
isTouchMove: false
})
}
this.setData({
startX: e.changedTouches[0].clientX,
startY: e.changedTouches[0].clientY,
})
}
},
touchmove: function (e) {
let { nickName } = store.readUserInfo()
if (e.currentTarget.dataset.name === nickName) {
var that = this
// index = e.currentTarget.dataset.index,//当前索引
const startX = that.data.startX//开始X坐标
const startY = that.data.startY//开始Y坐标
const touchMoveX = e.changedTouches[0].clientX//滑动变化坐标
const touchMoveY = e.changedTouches[0].clientY//滑动变化坐标
//获取滑动角度
const angle = that.angle({ X: startX, Y: startY }, { X: touchMoveX, Y: touchMoveY })
if (Math.abs(angle) > 30) return;
if (touchMoveX > startX) //右滑
that.setData({
isTouchMove: false
})
else //左滑
that.setData({
isTouchMove: true
})
}
// console.log(e)
},
angle: function (start, end) {
var _X = end.X - start.X,
_Y = end.Y - start.Y
//返回角度 /Math.atan()返回数字的反正切值
return 360 * Math.atan(_Y / _X) / (2 * Math.PI);
},
del: function (e) {
this.triggerEvent('deleteTopic', { id: e.currentTarget.dataset.id })
}
}
})