const util = require("../../utils/util.js"); Component({ properties: { aid: { type: String, observer: function (aid) { this.setData({ aid }); } }, source:{ type:Number, observer: function (source){ this.setData({ source}); } }, isPrizetable:{ type:Boolean, observer: function (newVal){ console.log(newVal) this.setData({ isPrizetable:newVal}); } }, isShareGroup:{ type:Boolean, observer: function (newVal){ console.log(newVal) this.setData({ isShareGroup:newVal}); } }, listData:{ type:Object, observer: function (newVal){ this.setData({ listData:newVal}); } }, }, data: { cardOverUsers:[], source: 0, downTimer:null, inTimer:null, index: 0, show:false, isShow:false, isPrizetable:false, //是否在大转盘页面 isShareGroup:false, //是否为分享家或者机构轮播 listData:{} }, pageLifetimes:{ show(){ this.getSold(); }, hide() { clearTimeout(this.data.downTimer); clearTimeout(this.data.inTimer); } }, methods: { downTime() { let that = this; that.data.downTimer = setTimeout(() => { if (that.data.index < ((that.data.cardOverUsers.length && (!that.data.isPrizetable || !that.data.isShareGroup)) || that.data.listData.length) - 1) { that.data.index++; } else { that.data.index = 0; } that.setData({ show: true, index: that.data.index }); that.data.inTimer = setTimeout(() => { that.setData({ show: false }); that.downTime(); }, 3000); }, 2000); }, img(e){ let index = e.currentTarget.dataset.index; this.data.cardOverUsers[index].avatar = '/images/default_logo.jpg'; this.setData({ cardOverUsers: this.data.cardOverUsers}); }, goActivity(e){ if (this.data.source == 1) return false; wx.navigateTo({ url: '/pages/product/activity/index?aid=' + e.currentTarget.dataset.aid, }); }, getSold(){ let that = this; if (that.data.isPrizetable || this.data.isShareGroup) { that.setData({ show: false, isShow: false, index: 0, downTimer: null, inTimer: null}); that.downTime(); setTimeout(function(){ that.setData({ isShow: true}); }, 3000); } else { util.ajax({ func:"order/soldRecord", data: { "source": that.data.source, "aid": that.data.aid}, load:false },function(res){ if(res.code == 0){ that.setData({ show: false, isShow: false, index: 0, downTimer: null, inTimer: null, cardOverUsers: res.data }); that.downTime(); setTimeout(function(){ that.setData({ isShow: true}); }, 3000); } }) } } } })