2026-09-17 16:25:31 +08:00
|
|
|
import { fetchHome, fetchConfig } from '../../services/home/home';
|
|
|
|
|
import { fetchPerson } from '../../services/usercenter/fetchPerson';
|
2026-10-14 14:44:01 +08:00
|
|
|
import { withPromoter, promoterQuery } from '../../utils/promoter';
|
2026-09-17 16:25:31 +08:00
|
|
|
|
|
|
|
|
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();
|
2026-09-29 16:24:19 +08:00
|
|
|
this.refreshRole();
|
2026-09-17 16:25:31 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onLoad() {
|
2026-09-29 16:24:19 +08:00
|
|
|
// 先用本地缓存渲染入口按钮,避免接口返回前闪烁;随后由 onShow 用接口数据校正
|
|
|
|
|
const role = (wx.getStorageSync('userInfo') || {}).role || '';
|
|
|
|
|
this.setData({ role });
|
2026-09-17 16:25:31 +08:00
|
|
|
this.init();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onReachBottom() {
|
|
|
|
|
if (this.data.demandListLoadStatus === 0) {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
this.init();
|
2026-09-29 16:24:19 +08:00
|
|
|
this.refreshRole();
|
2026-09-17 16:25:31 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
init() {
|
|
|
|
|
this.loadHomePage();
|
|
|
|
|
},
|
|
|
|
|
|
2026-09-29 16:24:19 +08:00
|
|
|
/**
|
|
|
|
|
* 拉取最新角色并写回本地缓存
|
|
|
|
|
* 入驻审核通过后,用户回到小程序触发 onShow 即可看到「进入接单大厅」入口
|
|
|
|
|
*/
|
|
|
|
|
refreshRole() {
|
|
|
|
|
return fetchPerson().then((res) => {
|
|
|
|
|
if (res.code === 1 && res.data) {
|
|
|
|
|
const role = res.data.role || '';
|
|
|
|
|
this.setData({ role });
|
|
|
|
|
const userInfo = wx.getStorageSync('userInfo');
|
|
|
|
|
if (userInfo && userInfo.role !== role) {
|
|
|
|
|
userInfo.role = role;
|
|
|
|
|
wx.setStorageSync('userInfo', userInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2026-09-17 16:25:31 +08:00
|
|
|
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}`,
|
|
|
|
|
});
|
|
|
|
|
},
|
2026-10-14 14:44:01 +08:00
|
|
|
|
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
return {
|
2026-10-14 18:00:26 +08:00
|
|
|
title: '代码邦 - 软件商城与定制开发平台',
|
2026-10-14 14:44:01 +08:00
|
|
|
path: withPromoter('/pages/home/home'),
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onShareTimeline() {
|
|
|
|
|
return {
|
2026-10-14 18:00:26 +08:00
|
|
|
title: '代码邦 - 软件商城与定制开发平台',
|
2026-10-14 14:44:01 +08:00
|
|
|
query: promoterQuery(),
|
|
|
|
|
};
|
|
|
|
|
},
|
2026-09-17 16:25:31 +08:00
|
|
|
});
|