完成了登录模块
This commit is contained in:
@ -1,72 +1,141 @@
|
||||
Page({
|
||||
const { baseUrl } = require('../../../request');
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
Page({
|
||||
data: {
|
||||
items: [null, null, null],
|
||||
items_1: [null, null, null],
|
||||
items_2: [null, null, null],
|
||||
activeTab: 0
|
||||
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 });
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
// “开码记录”跳tab
|
||||
goToPromoTab() {
|
||||
this.setData({ activeTab: 1 });
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
// “新增推广码”跳转
|
||||
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`
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
// “结算明细”跳转
|
||||
goToSettlementDetail() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/settlementDetail/settlementDetail' // 替换为你的页面路径
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
// 推广码-查看资料
|
||||
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)}`
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
// 弹出作业码弹窗
|
||||
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'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
goToNotificationDetail(e) {
|
||||
const id = e.currentTarget.dataset.id;
|
||||
wx.navigateTo({
|
||||
url: `/pages/projectModule/projectNotice/projectNotice?id=${id}` // 路径请根据你的项目实际调整
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user