142 lines
3.5 KiB
JavaScript
142 lines
3.5 KiB
JavaScript
const { baseUrl } = require('../../../request');
|
||
|
||
Page({
|
||
data: {
|
||
projectDetail: {},
|
||
notificationList: [],
|
||
settlementDetailList: [],
|
||
promoCodeList: [],
|
||
activeTab: 0,
|
||
id: null,
|
||
showPromoPop: false,
|
||
currentQrcode: '',
|
||
currentPromoLink: ''
|
||
},
|
||
|
||
onLoad(options) {
|
||
const id = options.id;
|
||
this.setData({ id });
|
||
},
|
||
|
||
// 每次页面展示都刷新(含navigateBack返回时)
|
||
onShow() {
|
||
// 防止id为null
|
||
if (this.data.id) {
|
||
this.fetchProjectDetail(this.data.id);
|
||
}
|
||
},
|
||
|
||
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'
|
||
});
|
||
}
|
||
});
|
||
},
|
||
|
||
switchTab(e) {
|
||
const idx = +e.currentTarget.dataset.index;
|
||
this.setData({ activeTab: idx });
|
||
},
|
||
|
||
// “开码记录”跳tab
|
||
goToPromoTab() {
|
||
this.setData({ activeTab: 1 });
|
||
},
|
||
|
||
// “新增推广码”跳转
|
||
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`
|
||
});
|
||
},
|
||
|
||
// “结算明细”跳转
|
||
goToSettlementDetail() {
|
||
wx.navigateTo({
|
||
url: '/pages/projectModule/subSettlement/subSettlement' // 替换为你的页面路径
|
||
});
|
||
},
|
||
|
||
// 推广码-查看资料
|
||
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)}`
|
||
});
|
||
},
|
||
|
||
// 弹出作业码弹窗
|
||
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'
|
||
});
|
||
}
|
||
});
|
||
},
|
||
|
||
goToNotificationDetail(e) {
|
||
const id = e.currentTarget.dataset.id;
|
||
wx.navigateTo({
|
||
url: `/pages/projectModule/projectNotice/projectNotice?id=${id}` // 路径请根据你的项目实际调整
|
||
});
|
||
}
|
||
|
||
});
|