123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- const app = getApp();
- Page({
- data: {
- StatusBar: app.globalData.StatusBar,
- CustomBar: app.globalData.CustomBar,
- cardCur: 0,
- tower: [{
- id: 0,
- url: 'https://image.weilanwl.com/img/4x3-1.jpg'
- }, {
- id: 1,
- url: 'https://image.weilanwl.com/img/4x3-2.jpg'
- }, {
- id: 2,
- url: 'https://image.weilanwl.com/img/4x3-3.jpg'
- }, {
- id: 3,
- url: 'https://image.weilanwl.com/img/4x3-4.jpg'
- }, {
- id: 4,
- url: 'https://image.weilanwl.com/img/4x3-2.jpg'
- }, {
- id: 5,
- url: 'https://image.weilanwl.com/img/4x3-4.jpg'
- }, {
- id: 6,
- url: 'https://image.weilanwl.com/img/4x3-2.jpg'
- }]
- },
- onLoad() {
- this.towerSwiper('tower');
-
- },
- DotStyle(e) {
- this.setData({
- DotStyle: e.detail.value
- })
- },
-
- cardSwiper(e) {
- this.setData({
- cardCur: e.detail.current
- })
- },
-
-
- towerSwiper(name) {
- let list = this.data[name];
- for (let i = 0; i < list.length; i++) {
- list[i].zIndex = parseInt(list.length / 2) + 1 - Math.abs(i - parseInt(list.length / 2))
- list[i].mLeft = i - parseInt(list.length / 2)
- }
- this.setData({
- towerList: list
- })
- },
-
- towerStart(e) {
- this.setData({
- towerStart: e.touches[0].pageX
- })
- },
-
- towerMove(e) {
- this.setData({
- direction: e.touches[0].pageX - this.data.towerStart > 0 ? 'right' : 'left'
- })
- },
-
- towerEnd(e) {
- let direction = this.data.direction;
- let list = this.data.towerList;
- if (direction == 'right') {
- let mLeft = list[0].mLeft;
- let zIndex = list[0].zIndex;
- for (let i = 1; i < list.length; i++) {
- list[i - 1].mLeft = list[i].mLeft
- list[i - 1].zIndex = list[i].zIndex
- }
- list[list.length - 1].mLeft = mLeft;
- list[list.length - 1].zIndex = zIndex;
- this.setData({
- towerList: list
- })
- } else {
- let mLeft = list[list.length - 1].mLeft;
- let zIndex = list[list.length - 1].zIndex;
- for (let i = list.length - 1; i > 0; i--) {
- list[i].mLeft = list[i - 1].mLeft
- list[i].zIndex = list[i - 1].zIndex
- }
- list[0].mLeft = mLeft;
- list[0].zIndex = zIndex;
- this.setData({
- towerList: list
- })
- }
- },
- });
|