| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- Component({
- options: {
- multipleSlots: true,
- addGlobalClass: true
- },
- properties: {
- list: {
- type: Array
- },
- active: {
- type: Number,
- value: 0
- },
- onChenge: {
- type: Function
- },
- mode: {
- type: String,
- value: "default" //buts
- },
- safety: {
- type: Function,
- value: true
- }
- },
- lifetimes: {
- attached() {
- getApp().globalData.Language.getLanguagePackage(this)
- }
- },
- data: {
- startPoint: 0, //记录滑动的初始位置
- slipFlag: false, //定义 滑动事件 节流阀, 防止一次滑动触发多次滑动事件
- },
- methods: {
- tabsChenge(e) {
- const {
- index
- } = e.currentTarget.dataset;
- if (this.data.active == index) return;
- this.setData({
- active: index
- });
- this.setActive();
- },
- setActive() {
- this.triggerEvent("onChenge", this.data.active);
- },
- myTouchStart(e) {
- return;
- this.setData({
- slipFlag: true,
- startPoint: e.touches[0]
- })
- },
- myTouchMove(e) {
- return;
- let active = this.data.active;
- if (((this.data.startPoint.clientX - e.touches[e.touches.length - 1].clientX) > 80) && this.data.slipFlag) {
- if (active != this.data.list.length - 1) active++;
- this.setData({
- slipFlag: false,
- active
- })
- } else if (((this.data.startPoint.clientX - e.touches[e.touches.length - 1].clientX) < -80) && this.data.slipFlag) {
- if (active != 0) active--;
- this.setData({
- slipFlag: false,
- active
- })
- }
- this.setActive();
- },
- }
- })
|