12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import {
- getActivities
- } from '~/api/global'
- Component({
- properties: {},
-
- data: {
-
- type: '4',
- activityList: [],
- dsqList: []
- },
- lifetimes: {
- attached() {
- this.getActivities()
- },
- detached() {
- this.data.dsqList.forEach(item => {
- clearInterval(item)
- })
- }
- },
-
- methods: {
- async getActivities() {
- let activityList = await getActivities()
- this.setData({
- activityList
- })
-
-
- },
- activityTimeOut(oTime, index) {
- let inputTime = new Date(oTime)
- let dsq = setInterval(() => {
- var nowTime = new Date();
-
- var times = (inputTime - nowTime) / 1000;
- if (times <= 0) {
- this.setData({
- [`activityList[${index}].hour`]: '00',
- [`activityList[${index}].minute`]: '00',
- [`activityList[${index}].second`]: '00',
- })
- return clearInterval(dsq)
- }
-
- var h = parseInt(times / 60 / 60 % 24);
-
- let hour = h < 10 ? "0" + h : h;
-
- var m = parseInt(times / 60 % 60);
-
- let minute = m < 10 ? "0" + m : m;
-
- var s = parseInt(times % 60);
-
- let second = s < 10 ? "0" + s : s;
- this.setData({
- [`activityList[${index}].hour`]: hour,
- [`activityList[${index}].minute`]: minute,
- [`activityList[${index}].second`]: second,
- })
- times = --times;
- }, 1000);
- this.setData({
- dsqList: [...this.data.dsqList, dsq]
- })
- },
- activityEvent({
- currentTarget
- }) {
-
- let {
- type,
- id
- } = currentTarget.dataset
- if ([2, 3, 4].includes(type)) {
- wx.navigateTo({
- url: `/pages/ranking/index?id=${id}&type=${type}`,
- })
- }
- },
- }
- })
|