123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- const app = getApp()
- import {
- getActivities,
- getRank
- } from '~/api/global'
- import {
- storeBindingsBehavior
- } from 'mobx-miniprogram-bindings'
- import {
- store
- } from '~/store/index'
- Component({
- behaviors: [storeBindingsBehavior],
- storeBindings: {
- store,
- fields: {
- userInfo: 'userInfo'
- },
- },
- properties: {
-
- classify: {
- type: Number,
- value: 1
- },
- dataList: {
- type: Array,
- value: [],
- observer(value) {
- this.setData({
- activityList: value
- })
- }
- }
- },
-
- data: {
-
- type: '',
- activityList: [],
- isIos: app.globalData.isIOS,
- dsqList: []
- },
- lifetimes: {
- attached() {
- this.getActivities()
- },
- detached() {
- this.data.dsqList.forEach(item => {
- clearInterval(item)
- })
- }
- },
-
- methods: {
- async getActivities() {
- this.data.dsqList.forEach(item => {
- clearInterval(item)
- })
- let activityList = []
- if (this.properties.classify == '3') {
- return
- } else if (this.properties.classify == '4') {
- activityList = await getActivities({
- classify: 3,
- grade: this.data.userInfo.grade
- })
- } else if (this.properties.classify == '2') {
- activityList = await getRank({
- classify: 2,
- grade: this.data.userInfo.grade
- })
- } else {
- activityList = await getActivities({
- classify: this.properties.classify,
- grade: this.data.userInfo.grade
- })
- }
- this.setData({
- activityList,
- })
- activityList.forEach((item, index) => {
- if (item.bannerType == 4 && item.voucherType) {
- this.activityTimeOut(item.endTime, index)
- }
- })
- },
- jumpUserInfo({
- currentTarget
- }) {
- if (!currentTarget.dataset.uid) {
- return
- }
- wx.navigateTo({
- url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
- })
- },
- 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',
- [`activityList[${index}].finish`]: true,
- })
- return clearInterval(dsq)
- }
-
- var h = parseInt(times / 60 / 60);
-
- 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,
- [`activityList[${index}].finish`]: false,
- })
- times = --times;
- }, 1000);
- this.setData({
- dsqList: [...this.data.dsqList, dsq]
- })
- },
- activityEvent({
- currentTarget
- }) {
-
- let {
- type,
- id,
- title,
- explain
- } = currentTarget.dataset.info
- if (type == 1) {
- wx.navigateTo({
- url: `/pages/rankIntro/index?title=${title}&img=${explain}`,
- })
- }
- if (type == 5) {
- wx.navigateTo({
- url: `/pages/match/index?activityId=${id}`,
- })
- }
- if ([2, 3, 4].includes(type)) {
- wx.navigateTo({
- url: `/pages/ranking/index?id=${id}&type=${type}`,
- })
- }
- if (type == 9) {
- wx.navigateTo({
- url: "/pages/invite/index",
- })
- }
- if (type == 10) {
- this.selectComponent('#buyVip').open()
- }
- if (type == 11) {
- let url = ''
- if (!this.data.userInfo.saleUserId) {
- url = '/salesperson/pages/sale/index'
- } else {
- url = '/salesperson/pages/saleOffice/index'
- }
- wx.navigateTo({
- url
- })
- }
- },
- drawVoucher({
- currentTarget
- }) {
- let info = currentTarget.dataset.info
- if (info.finish) {
- return
- }
- this.selectComponent('#voucher').open({
- type: info.type,
- id: info.id,
- voucherType: info.voucherType,
- preferential: info.price
- })
- }
- }
- })
|