import { fetchHome, fetchConfig } from '../../services/home/home'; import { fetchPerson } from '../../services/usercenter/fetchPerson'; Page({ data: { imgSrcs: [], tabList: [], demandList: [], demandListLoadStatus: 0, pageLoading: false, current: 1, role: '', image: '', imageSrc: '', autoplay: true, duration: '500', interval: 5000, navigation: { type: 'dots' }, swiperImageProps: { mode: 'scaleToFill' }, img1: '', img2: '', img3: '', tabList: [], }, demandListPagination: { index: 0, num: 20, }, privateData: { tabIndex: 0, }, onShow() { this.getTabBar().init(); setTimeout(() => { fetchPerson().then((res) => { if (res.code === 1) { let { role } = res.data; this.setData({ role, }); } }); }, 3000); }, onLoad() { this.init(); let role = wx.getStorageSync('userInfo')?.role; if (role == 'dev') { this.toDemandHall(); } }, onReachBottom() { if (this.data.demandListLoadStatus === 0) { } }, onPullDownRefresh() { this.init(); }, init() { this.loadHomePage(); }, loadHomePage() { wx.stopPullDownRefresh(); this.setData({ pageLoading: true }); fetchConfig().then( (res) => { console.log(res); if (res.code == 1) { let resData = res.data; this.setData({ pageLoading: false, tabList: resData.developTypes }); } } ); }, toSubscribe() { let tmpIds = []; wx.requestSubscribeMessage({ tmplIds: tmpIds, success(re) { console.log(re); }, fail(res) { console.log(res.errMsg, res.errCode); } }); }, publish(e) { wx.navigateTo({ url: `/pages/demand/publish/index` }); }, joinUs(e) { wx.navigateTo({ url: `/pages/developer/join/index` }); }, onReTry() { }, toDemandHall() { wx.navigateTo({ url: `/pages/demand/list/index?opType=all`, }); }, navToActivityDetail({ detail }) { const { index: promotionID = 0 } = detail || {}; wx.navigateTo({ url: `/pages/promotion-detail/index?promotion_id=${promotionID}`, }); }, });