Files
qingcheng-xiaochengxu/pages/personCenter/mine/mine.js

319 lines
7.2 KiB
JavaScript
Raw Normal View History

2025-05-21 18:40:41 +08:00
// pages/personCenter/mine/mine.js
2025-05-29 09:02:02 +08:00
const { baseUrl } = require("../../../request");
const { globalImgUrl } = require("../../../request")
2025-05-29 09:02:02 +08:00
2025-05-21 18:40:41 +08:00
Page({
/**
* 页面的初始数据
*/
data: {
2025-07-20 18:22:59 +08:00
items: [null,null,null],
2025-05-29 09:02:02 +08:00
nickName: "",
userAvatar: "",
phoneNumber: "",
2025-06-03 10:38:24 +08:00
userAccount: "",
invitationCode: "",
showPopup: false, // 控制弹窗显示与否
2025-08-07 11:45:28 +08:00
isShowOrder: true,
qrcode: "", // 设置二维码图片的路径
2025-07-20 18:22:59 +08:00
userRole: "",
2025-08-07 19:56:53 +08:00
title: '查看绩效',
2025-08-06 13:16:08 +08:00
id: 0,
2025-08-08 13:48:37 +08:00
globalImgUrl
},
2025-06-25 15:44:12 +08:00
// 跳转课程订单页面
courseOrder() {
wx.navigateTo({
url: '/pages/course/courseOrderList/courseOrderList',
})
},
2025-08-08 13:48:37 +08:00
updateAvatar(e) {
const { avatarUrl } = e.detail
this.uploadAvatar(avatarUrl)
},
uploadAvatar(filePath) {
wx.showLoading({ title: '上传中...' });
wx.uploadFile({
url: baseUrl + '/file/upload',
filePath,
name: 'file',
formData: {
biz: 'default'
},
success: res => {
wx.hideLoading();
let result = JSON.parse(res.data);
console.log(result)
if (result.code === 1) {
this.setData({userAvatar: result.data})
this.updateUserInfo(result.data)
} else {
wx.showToast({
title: result.message || '上传失败',
icon: 'none'
});
}
},
fail: err => {
wx.hideLoading();
console.error('uploadFile fail', err);
wx.showToast({ title: '网络错误,上传失败', icon: 'none' });
}
});
},
updateUserInfo(view) {
const token = wx.getStorageSync('token')
wx.request({
url: baseUrl + '/userInfo/modify/avatar',
method: 'POST',
header: {
Authorization: token
},
data: {
templateString: view
},
success: res => {
console.log(res.data)
},
fail: err => {
wx.showToast({ title: '用户头像更新失败', icon: 'none' });
}
})
},
2025-06-25 15:44:12 +08:00
// 跳转结算记录页面
gotoSettlementRecord() {
wx.navigateTo({
url: '/pages/course/courseSettlementRecord/courseSettlementRecord',
})
},
// 点击二维码时,显示弹窗
showPromoPopup() {
this.setData({
showPopup: true
});
},
2025-06-03 10:40:11 +08:00
testOrigin() {
console.log("testOrigin");
},
// 关闭弹窗
closePopup() {
this.setData({
showPopup: false
});
2025-05-21 18:40:41 +08:00
},
2025-05-21 20:24:34 +08:00
myteam(){
wx.navigateTo({
url: '/pages/personCenter/teamManage/teamManage',
})
},
zhijin(){
wx.navigateTo({
url: '/pages/personCenter/billingDetails/billingDetails',
})
},
mingxi(){
wx.navigateTo({
url: '/pages/personCenter/fundingDetails/fundingDetails',
})
},
xiangmu(){
wx.navigateTo({
url: '/pages/projectModule/userProject/userProject',
})
},
2025-05-26 09:46:08 +08:00
lxsj(){
wx.navigateTo({
url: '/pages/personCenter/contactSuper/contactSuper',
})
},
zhshezhi(){
wx.navigateTo({
url: '/pages/personCenter/accountSetting/accountSetting',
})
},
tixianzhanghu() {
wx.navigateTo({
url: '/pages/personCenter/withdrawalAccount/withdrawalAccount',
})
},
lijitixian() {
wx.navigateTo({
url: '/pages/personCenter/withdrawal/withdrawal',
})
},
2025-05-28 18:53:41 +08:00
szcy() {
wx.navigateTo({
url: '/pages/personCenter/commissionSetting/commissionSetting',
})
},
2025-05-21 18:40:41 +08:00
/**
* 生命周期函数--监听页面加载
*/
2025-06-11 11:32:02 +08:00
getUserMainInfo() {
const token = wx.getStorageSync('token');
// 获取用户主要信息
wx.request({
url: baseUrl + '/userInfo/get/main/jwt',
method: 'GET',
header: {
Authorization: token
},
success: res => {
if (res.data.code === 1) {
let result = res.data.data
2025-08-07 11:45:28 +08:00
console.log('====fdfs>', res)
2025-06-11 11:32:02 +08:00
this.setData({
2025-08-07 11:45:28 +08:00
qrcode: globalImgUrl + result.inviteQrCode
2025-06-11 11:32:02 +08:00
})
} else {
wx.showToast({
title: '获取个人信息失败',
icon: 'none'
})
2025-05-29 09:02:02 +08:00
}
2025-06-11 11:32:02 +08:00
},
fail: () => {
wx.showToast({ title: '网络错误,请重试', icon: 'none' });
}
})
// 获取用户信息
wx.request({
url: baseUrl + '/userInfo/get/jwt',
method: 'GET',
header: {
Authorization: token
},
success: res => {
2025-07-20 18:22:59 +08:00
console.log('用户信息---->',res.data);
2025-06-11 11:32:02 +08:00
if (res.data.code === 1) {
2025-08-07 11:45:28 +08:00
let result = res.data.data
2025-06-11 11:32:02 +08:00
this.setData({
2025-08-07 11:45:28 +08:00
nickName: result.nickName,
userAvatar: result.userAvatar,
phoneNumber: result.phoneNumber,
userAccount: result.userAccount,
invitationCode: result.invitationCode,
userRole: result.userRole,
id: result.id,
2025-06-11 11:32:02 +08:00
})
2025-08-07 19:56:53 +08:00
console.log(result.userRole)
if (result.userRole !== 'user') this.setData({ isShowOrder: false});
if (result.userRole === 'staff') this.setData({title: '客户订单'});
2025-05-29 09:02:02 +08:00
}
2025-06-11 11:32:02 +08:00
}
})
},
2025-08-07 11:45:28 +08:00
onLoad() {
2025-06-11 11:32:02 +08:00
this.getUserMainInfo()
2025-05-21 18:40:41 +08:00
},
2025-06-04 00:18:25 +08:00
// 复制邀请码到剪贴板
copyInvitationCode() {
wx.setClipboardData({
data: this.data.invitationCode,
success() {
wx.showToast({
title: '复制成功',
icon: 'success',
duration: 1500
});
},
fail() {
wx.showToast({
title: '复制失败',
icon: 'error',
duration: 1500
});
}
});
},
2025-08-04 16:27:52 +08:00
// 跳转仪表盘
gotoDashboard() {
const { userRole } = this.data
wx.navigateTo({
url: `/pages/dashboardModule/overviewPerformance/overviewPerformance?role=${userRole}`,
})
},
// 跳转查看绩效
checkPerformance() {
2025-08-06 13:16:08 +08:00
const { userRole } = this.data;
const { id } = this.data;
2025-08-04 16:27:52 +08:00
2025-08-06 13:16:08 +08:00
if (userRole === 'manager') {
2025-08-04 16:27:52 +08:00
wx.navigateTo({
2025-08-06 13:16:08 +08:00
url: `/pages/dashboardModule/supervisorPerformance/supervisorPerformance?role=${userRole}&id=${id}`,
2025-08-04 16:27:52 +08:00
})
2025-08-07 19:56:53 +08:00
} else if (userRole === 'staff') {
wx.navigateTo({
url: `/pages/dashboardModule/userOrderPerformance/userOrderPerformance?userId=${id}`,
})
2025-08-04 16:27:52 +08:00
} else {
wx.navigateTo({
2025-08-07 19:56:53 +08:00
url: `/pages/dashboardModule/staffPerformance/staffPerformance?role=${userRole}&supId=${id}`,
2025-08-04 16:27:52 +08:00
})
}
},
2025-08-07 19:56:53 +08:00
// 跳转主管排名
gotoSupervisorRank(e) {
2025-08-08 13:48:37 +08:00
console.log(e)
2025-08-07 19:56:53 +08:00
const {userRole} = this.data
2025-08-08 13:48:37 +08:00
console.log('===========>', userRole)
if (userRole === 'staff') {
2025-08-07 19:56:53 +08:00
wx.showToast({
title: '无权限',
icon: 'error'
})
return ;
}
2025-08-04 16:27:52 +08:00
wx.navigateTo({
2025-08-08 13:48:37 +08:00
url: `/pages/dashboardModule/performanceRanking/performanceRanking?role=manager`,
2025-08-04 16:27:52 +08:00
})
},
2025-06-04 00:18:25 +08:00
2025-08-07 19:56:53 +08:00
// 跳转员工排名
gotoStaffRank(e) {
console.log(e);
const {userRole} = this.data
console.log('===========>', userRole)
if (userRole === 'user') {
wx.showToast({
title: '无权限',
icon: 'error'
})
return ;
}
wx.navigateTo({
2025-08-08 13:48:37 +08:00
url: `/pages/dashboardModule/performanceRanking/performanceRanking?role=staff`,
2025-08-07 19:56:53 +08:00
})
},
2025-05-21 18:40:41 +08:00
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
2025-06-11 11:32:02 +08:00
this.getUserMainInfo()
2025-05-21 18:40:41 +08:00
},
gotoCall() {
wx.makePhoneCall({
phoneNumber: this.data.phoneNumber
})
},
2025-08-04 16:27:52 +08:00
2025-05-21 18:40:41 +08:00
})