detection-business/pages/staff/staff-my.vue
2025-06-16 17:17:24 +08:00

756 lines
17 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- 我的 -->
<template>
<view class="content">
<view style="width: 100%; height: 44px;"></view>
<view class="top-ail">
<view class="dix">
<view style="display: flex">
<view class="touxiang">
<image :src="baseUrl +user.avatar" mode="" v-if="user.avatar"></image>
<image src="/static/imgs/yh.png" mode="" v-else></image>
</view>
<view class="">
<view class="t-title">{{ user.nickname }}</view>
<view class="t-tel">{{ user.mobile }}</view>
</view>
</view>
<!-- 添加编辑按钮 -->
<view class="edit-button">
<view style="margin-bottom: 10px" @click="modifyPassword">修改密码</view>
<view style="margin-top: 10px" @click="editUserInfo">编辑信息</view>
</view>
</view>
<!-- 三项 -->
<!-- 店铺商铺 -->
<!-- -->
<view class="ian-box" v-if="showCheckout">
<!-- <view class="on-input" @click="golieb()">
<view class="dix">
<view class="d-icon">
<image src="../../static/detection/zhaq.png" mode=""></image>
</view>
<view class="aa">上门取车列表</view>
</view>
<view class="">
<uni-icons type="right" color="#999999" size="16"></uni-icons>
</view>
</view> -->
<view class="on-input" @click="goRoyalty()">
<view class="dix">
<view class="d-icon">
<image src="../../static/detection/zhaq.png" mode=""></image>
</view>
<view class="aa">提成记录</view>
</view>
<view class="">
<uni-icons type="right" color="#999999" size="16"></uni-icons>
</view>
</view>
<view class="on-input" @click="goWorkReport()">
<view class="dix">
<view class="d-icon">
<image src="../../static/detection/zhaq.png" mode=""></image>
</view>
<view class="aa">工作汇报</view>
</view>
<view class="">
<uni-icons type="right" color="#999999" size="16"></uni-icons>
</view>
</view>
<view class="on-input" @click="goFile()">
<view class="dix">
<view class="d-icon">
<image src="../../static/detection/zhaq.png" mode=""></image>
</view>
<view class="aa">文档管理</view>
</view>
<view class="">
<uni-icons type="right" color="#999999" size="16"></uni-icons>
</view>
</view>
<view class="on-input" @click="goAppointment()" v-if="lookAppointment">
<view class="dix">
<view class="d-icon">
<image src="../../static/detection/zhaq.png" mode=""></image>
</view>
<view class="aa">预约信息</view>
</view>
<view class="">
<uni-icons type="right" color="#999999" size="16"></uni-icons>
</view>
</view>
</view>
<!-- <view class="ian-box">-->
<!-- <view class="on-input" @click="goWord()">-->
<!-- <view class="dix">-->
<!-- <view class="d-icon">-->
<!-- <image src="../../static/detection/zhaq.png" mode=""></image>-->
<!-- </view>-->
<!-- <view class="aa">word</view>-->
<!-- </view>-->
<!-- <view class="">-->
<!-- <uni-icons type="right" color="#999999" size="16"></uni-icons>-->
<!-- </view>-->
<!-- </view>-->
<!-- </view>-->
<view class="ian-box">
<!-- <view class="on-input">
<view class="dix">
<view class="d-icon">
<image src="../../static/detection/zhaq.png" mode=""></image>
</view>
<view class="aa">账户与安全</view>
</view>
<view class="">
<uni-icons type="right" color="#999999" size="16"></uni-icons>
</view>
</view>
<view class="on-input">
<view class="dix">
<view class="d-icon">
<image src="../../static/detection/yhk.png" mode=""></image>
</view>
<view class="aa">银行卡管理</view>
</view>
<view class="">
<uni-icons type="right" color="#999999" size="16"></uni-icons>
</view>
</view> -->
<view class="on-input" @click="dialogToggle()">
<view class="dix">
<view class="d-icon">
<image src="../../static/detection/tc.png" mode=""></image>
</view>
<view class="aa">退出登录</view>
</view>
<view class="">
<uni-icons type="right" color="#999999" size="16"></uni-icons>
</view>
</view>
<view class="on-input" @click="checkoutRole()" v-if="showCheckout">
<view class="dix">
<view class="d-icon">
<image src="../../static/detection/tc.png" mode=""></image>
</view>
<view class="aa">{{chooseIdx == 3 ? '切换员工端' : '切换业务经理端'}}</view>
</view>
<view class="">
<uni-icons type="right" color="#999999" size="16"></uni-icons>
</view>
</view>
</view>
<view class="ian-box">
<view class="formItem">
<image class="formIcon" mode="aspectFit" src="../../static/icons/userInfo_3.png"></image>
<text class="formLabel">我的邀请码</text>
<text class="formValue"></text>
</view>
<view style="padding-bottom: 60rpx;" class="formItem">
<canvas id="qrcode" canvas-id="qrcode" style="width: 200px;height: 200px;margin: auto"
@longpress="saveQRCode"></canvas>
</view>
<text
style="display: block; font-weight: bold; text-align: center; color: #000000; font-size: 30rpx; border-bottom: 1px solid #ddd;">
长按邀请码可保存到相册
</text>
<canvas canvas-id="saveCanvas"
style="position: fixed; left: -9999px; width: 240px; height: 240px;"></canvas>
</view>
</view>
<uni-popup ref="alertDialog" type="dialog">
<uni-popup-dialog cancelText="关闭" confirmText="同意" title="通知" content="您确认要退出吗!" @confirm="dialogConfirm"
@close="dialogClose"></uni-popup-dialog>
</uni-popup>
<!-- 底部 -->
<view style="width: 100%; height: 50px;"></view>
<tabBar :msg="msg"></tabBar>
</view>
</template>
<script>
import config from '@/config'
import request from '../../utils/request';
const UQRCode = require('uqrcodejs');
import tabBar from '../../components/staffTabBer/tabBar.vue'
export default {
data() {
return {
msg: '3',
user: {},
baseUrl: '',
chooseIdx: undefined,
partnerId: '',
myindex: {},
lookAppointment: false,
shareUrl: config.shareUrl,
showCheckout: false
}
},
onLoad() {
this.baseUrl = this.$baseImageUrl + '/',
this.chooseIdx = uni.getStorageSync("chooseIdx")
},
onShow() {
this.user = uni.getStorageSync('staffinfo')
console.log(this.user);
this.partnerId = uni.getStorageSync('partnerId')
this.getindexmy()
this.ifAppointment()
},
components: {
tabBar,
},
methods: {
dialogToggle() {
this.$refs.alertDialog.open()
uni.removeStorageSync('userInfo')
uni.removeStorageSync('staffinfo')
},
modifyPassword() {
// 跳转到修改密码页面
uni.navigateTo({
url: '/pages/modifyPassword/modifyPassword' // 修改密码页面路径
});
},
generateUniCode(code) {
this.$nextTick(() => {
// 获取uQRCode实例
const qr = new UQRCode();
// 设置二维码内容
qr.data = this.shareUrl + code;
// 设置二维码大小必须与canvas设置的宽高一致
qr.size = 200;
// 调用制作二维码方法
qr.make();
// 获取canvas上下文
const canvasContext = uni.createCanvasContext('qrcode', this); // 如果是组件this必须传入
// 设置uQRCode实例的canvas上下文
qr.canvasContext = canvasContext;
// 调用绘制方法将二维码图案绘制到canvas上
qr.drawCanvas();
})
},
dialogConfirm() {
this.tui()
this.$refs.alertDialog.close()
},
ifAppointment() {
request({
url: '/partnerOwn/partner/ifHasRole',
method: 'get',
params: {
dictType: 'ins_appointment_role'
}
}).then((res) => {
this.lookAppointment = res.data
})
},
// 点击编辑信息按钮时调用此方法
editUserInfo() {
// 这里可以跳转到编辑页面并传递参数
uni.navigateTo({
url: `/pages/editUserInfo/editUserInfo`
});
},
checkoutRole() {
uni.showLoading({
title: '加载中'
});
if (this.chooseIdx == 3) {
uni.setStorageSync("chooseIdx", 2)
} else {
uni.setStorageSync("chooseIdx", 3)
}
setTimeout(function() {
uni.hideLoading();
}, 500);
this.chooseIdx = uni.getStorageSync("chooseIdx")
},
dialogClose() {
this.$refs.alertDialog.close()
console.log('点击关闭')
},
async getindexmy() {
console.log('调用')
// let res = await request({
// url:'/partnerOwn/partner/accountInfo?partnerId='+this.partnerId,
// method: 'get',
// })
// this.myindex = res.data
let ress = await request({
url: '/inspectionStaff/get',
method: 'get',
params: {
id: uni.getStorageSync('userId')
}
})
console.log('个人信息', ress.data)
this.user = ress.data
this.generateUniCode(ress.data.uniqueCode)
// 判断角色是否只有一个业务经理
const hasJcywjl = ress.data.userRoles
?.flatMap(r => r.roleCode) // 把所有 roleCode 数组合并成一个大数组
.includes('jcywjl'); // 判断是否包含目标代码
if (hasJcywjl) {
this.showCheckout = false
} else {
this.showCheckout = true
}
},
tui() {
uni.clearStorageSync();
uni.reLaunch({
url: '/pages/Login/login'
})
},
golieb() {
uni.navigateTo({
url: "/pages/staff/golist"
})
},
goRoyalty() {
uni.navigateTo({
url: "/pages/staff/goRoyalty"
})
},
goWorkReport() {
uni.navigateTo({
url: "/pages/manage/workReport/reportList"
})
},
goFile() {
uni.navigateTo({
url: "/pages/manage/deviceManage"
})
},
goAppointment() {
uni.navigateTo({
url: "/pages/order/reservationlist"
})
},
goWord() {
request({
url: '/system/info/exportWord',
method: 'get',
params: {
id: 4400
}
})
},
getdianpu() {
uni.navigateTo({
url: "/pages/my/shoporder"
})
},
// 弹窗提示
saveQRCode() {
uni.showModal({
title: '提示',
content: '确定要保存邀请码到相册吗?',
success: (res) => {
if (res.confirm) {
this.doSaveQRCode();
}
}
});
},
// 保存邀请码
async doSaveQRCode() {
uni.showLoading({
title: '保存中...',
mask: true
});
try {
// 获取原始二维码图片路径
const tempPath = await this.getCanvasTempPath('qrcode');
// 创建一个带留白的新canvas
const paddedPath = await this.createPaddedImage(tempPath);
// 保存带留白的图片
await this.saveToAlbum(paddedPath);
uni.showToast({
title: '保存成功',
icon: 'success'
});
} catch (err) {
console.error('保存失败:', err);
uni.showToast({
title: '保存失败: ' + (err.errMsg || '未知错误'),
icon: 'none',
duration: 3000
});
} finally {
uni.hideLoading();
}
},
getCanvasTempPath(canvasId) {
return new Promise((resolve, reject) => {
uni.canvasToTempFilePath({
canvasId: canvasId,
success: resolve,
fail: reject
}, this);
});
},
createPaddedImage(tempPath) {
return new Promise((resolve, reject) => {
const padding = 20; // 留白大小单位px
const qrSize = 200; // 二维码原始大小
const canvasSize = qrSize + padding * 2; // 带留白的总大小
const nameHeight = 30; // 姓名区域高度
const totalHeight = canvasSize + nameHeight; // 总高度(二维码 + 姓名)
const ctx = uni.createCanvasContext('saveCanvas', this);
// 1. 绘制白色背景(扩展到包含姓名区域)
ctx.setFillStyle('#ffffff');
ctx.fillRect(0, 0, canvasSize, totalHeight);
// 2. 绘制姓名(居中显示)
ctx.setFontSize(16); // 字体大小
ctx.setFillStyle('#000000'); // 字体颜色
ctx.setTextAlign('center'); // 水平居中
ctx.fillText(this.user.nickname || '未设置姓名', canvasSize / 2, nameHeight - 5);
// 3. 绘制二维码(在姓名下方)
ctx.drawImage(tempPath.tempFilePath, padding, nameHeight, qrSize, qrSize);
ctx.draw(false, () => {
setTimeout(() => {
this.getCanvasTempPath('saveCanvas')
.then(resolve)
.catch(reject);
}, 300);
});
});
},
saveToAlbum(filePath) {
return new Promise((resolve, reject) => {
uni.saveImageToPhotosAlbum({
filePath: filePath.tempFilePath,
success: resolve,
fail: (err) => {
// 处理权限问题
if (err.errMsg.includes('auth')) {
uni.showModal({
title: '提示',
content: '需要相册权限才能保存图片',
success: (res) => {
if (res.confirm) {
uni.openSetting();
}
}
});
}
reject(err);
}
});
});
},
}
}
</script>
<style scoped lang="scss">
.content {
box-sizing: border-box;
width: 100%;
height: calc(100vh);
background: linear-gradient(225deg, #EFF5FF 0%, rgba(255, 255, 255, 0) 100%);
}
.c-top {
width: 100%;
// height: 283px;
// background-color: cornflowerblue;
// background: url("http://www.nuoyunr.com/lananRsc/shopBg.png") center no-repeat;
// background-size:100% 100%;
}
.top-ail {
width: 100%;
box-sizing: border-box;
padding: 20px;
}
.dix {
display: flex;
align-items: center;
justify-content: space-between;
/* 保持头像和信息左对齐,按钮右对齐 */
}
.touxiang {
width: 50px;
height: 50px;
border-radius: 50%;
overflow: hidden;
background-color: whitesmoke;
margin-left: 10px;
image {
width: 100%;
height: 100%;
}
}
.t-title {
font-size: 18px;
font-weight: bold;
color: #333333;
margin-left: 15px;
}
.t-tel {
font-size: 14px;
font-weight: 400;
color: #999999;
margin-left: 15px;
}
.sanxiang {
width: 100%;
box-sizing: border-box;
padding: 20px;
background-color: white;
border-radius: 8px;
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 30px;
}
.lan-box {
width: 100%;
box-sizing: border-box;
padding: 15px;
background: linear-gradient(90deg, #EDF4FD 0%, #E1EFFF 100%);
border-radius: 8px;
margin: 10px auto;
}
.s-box {
width: 33%;
border-right: 1px solid #EEEEEE;
text-align: center;
}
.simg {
width: 26px;
height: 26px;
margin: 0 auto;
image {
width: 100%;
height: 100%;
}
}
.zc-text {
font-size: 13px;
font-weight: 400;
color: #333333;
margin: 5px auto;
}
.lan-num {
font-size: 26px;
font-weight: 600;
color: #0D2E8D;
}
.hei-title {
font-size: 16px;
font-weight: 600;
color: #333333;
}
.cont-box {
margin-top: 10px;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
.c-left {
width: 50%;
box-sizing: border-box;
}
.l-left {
width: 50%;
box-sizing: border-box;
border-right: 1px solid #EEEEEE;
padding-right: 5px;
}
.c-bt {
font-size: 14px;
font-weight: 400;
color: #666666;
margin-bottom: 2px;
}
.c-lan {
font-size: 25px;
font-weight: 600;
color: #0D2E8D;
}
.c-right {
width: 122px;
height: 35px;
background: #FFFFFF;
border-radius: 50px;
display: flex;
justify-content: center;
align-items: center;
color: #0D2E8D;
}
.l-icon {
width: 15px;
height: 15px;
image {
width: 100%;
height: 100%;
}
}
.lan-text {
font-size: 14px;
font-weight: 400;
color: #0D2E8D;
margin: 0px 2px;
}
.c-hei {
font-size: 20px;
font-weight: 600;
color: #333333;
}
.dian-box {
background-color: white;
border-radius: 8px;
box-sizing: border-box;
width: 100%;
padding: 15px;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
}
.ian-box {
background-color: white;
border-radius: 8px;
box-sizing: border-box;
width: 100%;
padding: 15px;
padding-bottom: 0px;
// margin-bottom: 10px;
margin-top: 10px;
}
.dian-top {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 5px;
}
.d-icon {
width: 16px;
height: 16px;
image {
width: 100%;
height: 100%;
}
}
.aa {
font-size: 16px;
font-weight: 400;
color: #333333;
margin-left: 5px;
}
.on-input {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
// border-bottom: 1px solid #EEEEEE;
padding-bottom: 10px;
margin-bottom: 10px;
}
.edit-button {
font-size: 14px;
color: #007aff;
margin-top: 10px;
cursor: pointer;
align-self: flex-end;
/* 使按钮右对齐 */
view:hover {
text-decoration: underline;
}
}
.formItem {
box-sizing: border-box;
padding: 40rpx 0;
display: flex;
align-items: center;
justify-content: space-between;
column-gap: 20rpx;
}
.formIcon {
width: 44rpx;
height: 44rpx;
}
.formLabel {
font-size: 32rpx;
color: #333333;
}
.formValue {
flex: 1;
width: 0;
text-align: right;
font-size: 32rpx;
color: #999999;
}
.formBtn {
width: 24rpx;
height: 24rpx;
}
//.edit-button:hover {
// text-decoration: underline;
//}
</style>