qingcheng-xiaochengxu/pages/projectModule/projectDetail/projectDetail.js

142 lines
3.5 KiB
JavaScript
Raw Normal View History

2025-05-19 01:08:33 +00:00
const { baseUrl } = require('../../../request');
2025-05-17 15:17:14 +00:00
2025-05-19 01:08:33 +00:00
Page({
2025-05-17 15:17:14 +00:00
data: {
2025-05-19 01:08:33 +00:00
projectDetail: {},
notificationList: [],
settlementDetailList: [],
promoCodeList: [],
activeTab: 0,
id: null,
showPromoPop: false,
currentQrcode: '',
currentPromoLink: ''
2025-05-17 15:17:14 +00:00
},
onLoad(options) {
2025-05-19 01:08:33 +00:00
const id = options.id;
this.setData({ id });
2025-05-17 15:17:14 +00:00
},
2025-05-19 01:08:33 +00:00
// 每次页面展示都刷新含navigateBack返回时
onShow() {
// 防止id为null
if (this.data.id) {
this.fetchProjectDetail(this.data.id);
}
2025-05-17 15:17:14 +00:00
},
2025-05-19 01:08:33 +00:00
fetchProjectDetail(id) {
const token = wx.getStorageSync('token');
wx.request({
url: baseUrl + '/project/query/id', // 替换为你的接口地址
method: 'POST',
header: {
Authorization: token
},
data: {
id
},
success: (res) => {
if (res.data.code === 1) {
const detail = res.data.data || {};
this.setData({
projectDetail: detail,
notificationList: detail.projectNotificationVOList || [],
settlementDetailList: detail.projectAllDetailVOList || [],
promoCodeList: detail.promoCodeApplyVOList || []
});
} else {
wx.showToast({
title: res.data.message || '数据获取失败',
icon: 'none'
});
}
},
fail: () => {
wx.showToast({
title: '网络错误',
icon: 'none'
});
}
});
2025-05-17 15:17:14 +00:00
},
2025-05-19 01:08:33 +00:00
switchTab(e) {
const idx = +e.currentTarget.dataset.index;
this.setData({ activeTab: idx });
2025-05-17 15:17:14 +00:00
},
2025-05-19 01:08:33 +00:00
// “开码记录”跳tab
goToPromoTab() {
this.setData({ activeTab: 1 });
2025-05-17 15:17:14 +00:00
},
2025-05-19 01:08:33 +00:00
// “新增推广码”跳转
addPromoCode() {
const id = this.data.id;
const promoCodeDesc = this.data.projectDetail.applyPromoCodeDesc || '';
// encodeURIComponent 防止有特殊字符
wx.navigateTo({
url: `/pages/projectModule/applyCode/applyCode?id=${id}&desc=${encodeURIComponent(promoCodeDesc)}&mode=add`
});
2025-05-17 15:17:14 +00:00
},
2025-05-19 01:08:33 +00:00
// “结算明细”跳转
goToSettlementDetail() {
wx.navigateTo({
2025-05-28 16:47:08 +00:00
url: '/pages/projectModule/subSettlement/subSettlement' // 替换为你的页面路径
2025-05-19 01:08:33 +00:00
});
},
2025-05-17 15:17:14 +00:00
2025-05-19 01:08:33 +00:00
// 推广码-查看资料
goToPromoMaterial(e) {
const id = e.currentTarget.dataset.id; // 项目id
const name = e.currentTarget.dataset.name; // 业务员姓名
const phone = e.currentTarget.dataset.phone; // 业务员手机号
const promoCodeDesc = this.data.projectDetail.applyPromoCodeDesc || '';
wx.navigateTo({
url: `/pages/projectModule/applyCode/applyCode?id=${id}&desc=${encodeURIComponent(promoCodeDesc)}&mode=view&name=${encodeURIComponent(name)}&phone=${encodeURIComponent(phone)}`
});
2025-05-17 15:17:14 +00:00
},
2025-05-19 01:08:33 +00:00
// 弹出作业码弹窗
onShowPromoPop(e) {
const qrcode = e.currentTarget.dataset.qrcode;
const link = e.currentTarget.dataset.link;
this.setData({
showPromoPop: true,
currentQrcode: qrcode,
currentPromoLink: link
});
},
// 关闭弹窗
onClosePromoPop() {
this.setData({ showPromoPop: false });
},
// 复制推广码
copyPromoCode(e) {
const code = e.currentTarget.dataset.code;
wx.setClipboardData({
data: code,
success: function () {
wx.showToast({
title: '复制成功',
icon: 'success'
});
}
});
},
2025-05-17 15:17:14 +00:00
2025-05-19 01:08:33 +00:00
goToNotificationDetail(e) {
const id = e.currentTarget.dataset.id;
wx.navigateTo({
url: `/pages/projectModule/projectNotice/projectNotice?id=${id}` // 路径请根据你的项目实际调整
});
2025-05-17 15:17:14 +00:00
}
2025-05-19 01:08:33 +00:00
});