<template>
|
<view class="activation-container">
|
<!-- 设备信息卡片 -->
|
<view class="info-card">
|
<view class="card-title">
|
设备信息
|
<text class="debug-badge" v-if="isDebugVersion">试用版本</text>
|
</view>
|
<view class="info-item">
|
<text class="label">设备名称:</text>
|
<text class="value">{{ deviceInfo.name }}</text>
|
</view>
|
<view class="info-item">
|
<text class="label">操作系统:</text>
|
<text class="value">{{ deviceInfo.os }}</text>
|
</view>
|
<view class="info-item">
|
<text class="label">CPU型号:</text>
|
<text class="value">{{ deviceInfo.cpu }}</text>
|
</view>
|
<view class="info-item">
|
<text class="label">设备ID:</text>
|
<text class="value">{{ deviceInfo.deviceId }}</text>
|
</view>
|
</view>
|
|
<!-- 运行码部分 -->
|
<view class="code-card" v-if="!isDebugVersion">
|
<view class="card-title">
|
设备运行码
|
<text class="debug-badge" v-if="isDebugVersion">试用版本</text>
|
</view>
|
<view class="code-display">
|
<text class="code-text">{{ runningCode || '点击生成运行码' }}</text>
|
</view>
|
<view class="code-actions">
|
<button class="action-btn generate" @click="generateRunningCode"
|
:disabled="runningCode.length !== 0">生成运行码</button>
|
<button class="action-btn copy" @click="copyRunningCode"
|
:disabled="runningCode.length === 0">复制运行码</button>
|
</view>
|
<view class="code-tip" v-if="isDebugVersion">试用版本无需提交运行码获取激活码,系统已自动激活</view>
|
<view class="code-tip" v-else>请将运行码提交给系统管理员,获取激活码</view>
|
</view>
|
|
<!-- 激活码输入部分 -->
|
<view class="activation-form">
|
<!-- 试用版本信息 -->
|
<template v-if="isDebugVersion">
|
<view class="card-title">试用版本信息</view>
|
<view class="debug-info">
|
<text :class="debugTextClass">当前为试用版本,{{expStatus ? "已过期":"已自动激活"}}
|
</text>
|
<text></text>
|
<!-- <text :class="debugTextClass">有效期至:{{ ActivationConfig.debugExpiryDate }}</text> -->
|
</view>
|
</template>
|
|
<!-- 正式版本激活码输入 -->
|
<template v-else>
|
<view class="card-title">激活系统</view>
|
<view class="input-group">
|
<input class="activation-input" v-model="activationCode" placeholder="请输入激活码"
|
:disabled="isActivated" />
|
<button class="action-btn activate" @click="activateSystem"
|
:disabled="!activationCode || isActivated">{{ isActivated ? '已激活' : '激活' }}</button>
|
</view>
|
</template>
|
</view>
|
|
<!-- 激活状态 -->
|
<view class="status-card" v-if="isActivated && !isDebugVersion">
|
<view class="card-title">
|
激活状态
|
<text class="debug-badge" v-if="isDebugVersion">试用版本</text>
|
</view>
|
<view class="status-info">
|
<view class="status-item">
|
<text class="label">状态:</text>
|
<text class="value success">{{ isDebugVersion ? '已激活(试用版本)' : '已激活' }}</text>
|
</view>
|
<!-- <view class="status-item">
|
<text class="label">激活时间:</text>
|
<text class="value">{{ activationInfo.activatedDate }}</text>
|
</view>
|
<view class="status-item">
|
<text class="label">有效期至:</text>
|
<text class="value">
|
{{ activationInfo.expiryDate }}
|
<span v-if="isDebugVersion">(固定)</span>
|
</text>
|
</view>
|
<view class="status-item">
|
<text class="label">剩余天数:</text>
|
<text class="value" :class="{'debug-days': isDebugVersion}">{{ activationInfo.daysLeft }}天</text>
|
</view> -->
|
</view>
|
</view>
|
|
<!-- 底部说明 -->
|
<view class="footer-note">
|
<text>如需帮助,请联系系统管理员</text>
|
<text class="contact">联系电话:17377884651</text>
|
<view class="wechat-link" @click="showWechatQRCode">
|
<text>查看微信二维码</text>
|
</view>
|
|
<!-- <view class="wechat-link" @click="gotoIndex" v-if="!expStatus">
|
<text>返回首页</text>
|
</view> -->
|
</view>
|
|
<!-- 微信二维码弹窗 -->
|
<BaseModal v-model="qrCodeVisible" title="微信二维码" :showFooter="false" animationType="scale">
|
<view class="qrcode-container">
|
<image class="qrcode-image" src="/static/wechat-qrcode.jpg" @click="previewImage" mode="aspectFit">
|
</image>
|
<text class="qrcode-tip">扫描上方二维码添加客服微信</text>
|
</view>
|
</BaseModal>
|
</view>
|
</template>
|
|
<script>
|
import activationService from "@/services/activationService";
|
import {
|
ActivationConfig
|
} from "@/config/activation";
|
import BaseModal from "@/components/BaseModal.vue";
|
|
export default {
|
components: {
|
BaseModal
|
},
|
data() {
|
return {
|
// 添加ActivationConfig到data中
|
ActivationConfig,
|
// 设备信息
|
deviceInfo: {
|
name: "",
|
os: "",
|
cpu: "",
|
deviceId: ""
|
},
|
// 运行码
|
runningCode: "",
|
// 激活码
|
activationCode: "",
|
// 激活信息从全局获取
|
activationInfo: getApp().globalData.activationStatus || {
|
activatedDate: "",
|
expiryDate: "",
|
daysLeft: 0,
|
isDebug: false,
|
isTrial: false
|
},
|
// 试用版本标志
|
isDebugVersion: ActivationConfig.isDebugVersion,
|
debugTextClass: "debug-text",
|
daysLeft: 0,
|
// 微信二维码弹窗控制
|
qrCodeVisible: false,
|
expStatus: false
|
};
|
},
|
|
computed: {
|
// 是否已激活
|
isActivated() {
|
return this.activationInfo && this.activationInfo.isValid;
|
}
|
},
|
|
created() {
|
// 获取设备信息
|
this.getDeviceInfo();
|
|
// 检查激活状态
|
// this.checkActivationStatus();
|
|
// 检查本地存储中是否有运行码
|
const savedCode = uni.getStorageSync(
|
ActivationConfig.storageKeys.runningCode
|
);
|
if (savedCode) {
|
this.runningCode = savedCode;
|
} else if (ActivationConfig.isDebugVersion) {
|
// 试用版本:如果没有运行码,自动生成一个
|
this.generateRunningCode();
|
}
|
// const activationStatus = activationService.checkActivationStatus()
|
// this.daysLeft = activationStatus.daysLeft;
|
// if (activationStatus.daysLeft <= 0) {
|
// this.debugTextClass = 'debug-exp-text';
|
// // uni.showModal({
|
// // title: '提示',
|
// // content: '试用时间已到,请联系管理员',
|
// // showCancel: false
|
// // })
|
// }else{
|
// this.debugTextClass = 'debug-text';
|
// }
|
activationService.checkDataCount().then(result => {
|
this.expStatus = result.expStatus;
|
if (this.expStatus) {
|
this.debugTextClass = 'debug-exp-text';
|
}
|
})
|
},
|
|
methods: {
|
// 获取设备信息
|
async getDeviceInfo() {
|
try {
|
const systemInfo = uni.getSystemInfoSync();
|
const platform = systemInfo.platform;
|
const deviceBrand = systemInfo.brand;
|
const deviceModel = systemInfo.model;
|
|
// 初始化设备信息
|
this.deviceInfo = {
|
name: `${deviceBrand} ${deviceModel}`,
|
os: systemInfo.system,
|
cpu: platform === "android" ?
|
"ARM处理器" : platform === "ios" ?
|
"Apple处理器" : "Intel处理器",
|
deviceId: "获取中..." // 初始值
|
};
|
|
// 获取设备唯一标识
|
let deviceId = "";
|
|
try {
|
// 尝试获取设备唯一标识
|
if (platform === "android") {
|
// Android可以使用deviceId
|
deviceId = systemInfo.deviceId || systemInfo.uuid;
|
} else if (platform === "ios") {
|
// iOS可以使用uuid
|
deviceId = systemInfo.uuid;
|
}
|
|
// 如果没有获取到,生成一个唯一标识
|
if (!deviceId) {
|
deviceId = this.generateDeviceUniqueId();
|
}
|
|
// 使用设备唯一标识作为deviceId地址的替代
|
this.deviceInfo.deviceId = deviceId;
|
} catch (e) {
|
console.error("获取设备标识失败:", e);
|
this.deviceInfo.deviceId = this.generateDeviceUniqueId();
|
}
|
} catch (error) {
|
console.error("获取设备信息失败:", error);
|
// 使用模拟数据作为后备
|
this.deviceInfo = {
|
name: "未知设备",
|
os: "未知系统",
|
cpu: "未知处理器",
|
deviceId: this.generateDeviceUniqueId()
|
};
|
}
|
},
|
|
gotoIndex() {
|
uni.redirectTo({
|
url: '/pages/index/index'
|
})
|
},
|
|
previewImage() {
|
uni.previewImage({
|
urls: ['/static/wechat-qrcode.jpg'], // 需传入数组,即使只有一张图
|
current: 0 // 当前显示图片的索引
|
});
|
},
|
|
// 生成设备唯一标识符
|
generateDeviceUniqueId() {
|
// 使用设备信息和时间戳生成一个唯一标识符
|
const timestamp = Date.now().toString(36);
|
const randomStr = Math.random()
|
.toString(36)
|
.substr(2, 8);
|
return `DEV-${timestamp}-${randomStr}`.toUpperCase();
|
},
|
|
// 检查激活状态
|
checkActivationStatus() {
|
// 使用activationService检查激活状态
|
const status = activationService.checkActivationStatus();
|
this.activationInfo = status;
|
|
// 更新全局状态
|
getApp().globalData.activationStatus = status;
|
|
return status;
|
},
|
|
// 生成设备运行码
|
generateRunningCode() {
|
try {
|
// 显示加载状态
|
uni.showLoading({
|
title: "正在生成运行码..."
|
});
|
|
// 使用activationService生成运行码
|
this.runningCode = activationService.generateRunningCode(
|
this.deviceInfo.deviceId
|
);
|
|
// 保存运行码到本地存储
|
uni.setStorageSync(
|
ActivationConfig.storageKeys.runningCode,
|
this.runningCode
|
);
|
|
uni.hideLoading();
|
} catch (error) {
|
uni.hideLoading();
|
uni.showToast({
|
title: "生成运行码失败",
|
icon: "none"
|
});
|
console.error("生成运行码失败:", error);
|
}
|
},
|
|
// 复制运行码到剪贴板
|
copyRunningCode() {
|
if (!this.runningCode) {
|
uni.showToast({
|
title: "请先生成运行码",
|
icon: "none"
|
});
|
return;
|
}
|
|
uni.setClipboardData({
|
data: this.runningCode,
|
success: () => {
|
uni.showToast({
|
title: "运行码已复制",
|
icon: "success"
|
});
|
}
|
});
|
},
|
|
// 激活系统
|
activateSystem() {
|
if (!this.activationCode) {
|
uni.showToast({
|
title: "请输入激活码",
|
icon: "none"
|
});
|
return;
|
}
|
|
// 显示加载状态
|
uni.showLoading({
|
title: "正在激活..."
|
});
|
|
try {
|
// 调用激活服务
|
const result = activationService.activateWithCode(this.activationCode);
|
|
uni.hideLoading();
|
|
if (result.success) {
|
// 激活成功
|
this.activationInfo = result.activationInfo;
|
|
// 更新全局状态
|
getApp().globalData.activationStatus = result.activationInfo;
|
|
uni.showToast({
|
title: "激活成功",
|
icon: "success"
|
});
|
} else {
|
// 激活失败
|
uni.showToast({
|
title: result.message || "激活失败",
|
icon: "none"
|
});
|
}
|
} catch (error) {
|
uni.hideLoading();
|
uni.showToast({
|
title: "激活过程出错",
|
icon: "none"
|
});
|
console.error("激活系统失败:", error);
|
}
|
},
|
|
// 显示微信二维码弹窗
|
showWechatQRCode() {
|
this.qrCodeVisible = true;
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.activation-container {
|
padding: 30rpx;
|
min-height: 100vh;
|
display: flex;
|
flex-direction: column;
|
background-color: var(--bg-color);
|
background-image: linear-gradient(135deg,
|
rgba(0, 0, 0, 0.02) 25%,
|
transparent 25%,
|
transparent 50%,
|
rgba(0, 0, 0, 0.02) 50%,
|
rgba(0, 0, 0, 0.02) 75%,
|
transparent 75%,
|
transparent);
|
background-size: 40rpx 40rpx;
|
overflow-y: auto;
|
|
// 试用版本信息样式
|
.debug-info {
|
background-color: rgba(41, 121, 255, 0.1);
|
border-radius: 10rpx;
|
padding: 20rpx;
|
margin-bottom: 15rpx;
|
border-left: 4rpx solid #2979ff;
|
display: flex;
|
flex-direction: column;
|
|
.debug-text {
|
font-size: 28rpx;
|
color: #2979ff;
|
margin-bottom: 10rpx;
|
font-weight: 500;
|
|
&:last-child {
|
margin-bottom: 0;
|
}
|
}
|
|
.debug-exp-text {
|
font-size: 28rpx;
|
color: red;
|
margin-bottom: 10rpx;
|
font-weight: 500;
|
|
&:last-child {
|
margin-bottom: 0;
|
}
|
}
|
}
|
|
// 试用版本标记
|
.debug-badge {
|
display: inline-block;
|
background-color: #2979ff;
|
color: white;
|
font-size: 20rpx;
|
padding: 4rpx 10rpx;
|
border-radius: 20rpx;
|
margin-left: 10rpx;
|
vertical-align: middle;
|
font-weight: normal;
|
}
|
|
// 试用版本剩余天数样式
|
.debug-days {
|
color: #2979ff !important;
|
font-weight: bold;
|
}
|
|
.info-card,
|
.code-card,
|
.activation-form,
|
.status-card {
|
background-color: var(--card-bg);
|
border-radius: 16rpx;
|
padding: 25rpx;
|
margin-bottom: 25rpx;
|
box-shadow: 0 8rpx 20rpx var(--shadow-color);
|
position: relative;
|
overflow: hidden;
|
|
&::before {
|
content: "";
|
position: absolute;
|
top: 0;
|
left: 0;
|
width: 100%;
|
height: 4rpx;
|
background: linear-gradient(90deg, #2979ff, #5e35b1);
|
}
|
}
|
|
.card-title {
|
font-size: 30rpx;
|
font-weight: bold;
|
color: var(--text-color);
|
margin-bottom: 20rpx;
|
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
padding-bottom: 15rpx;
|
position: relative;
|
|
&::after {
|
content: "";
|
position: absolute;
|
bottom: -1px;
|
left: 0;
|
width: 50rpx;
|
height: 3rpx;
|
background: linear-gradient(90deg, #2979ff, #5e35b1);
|
}
|
}
|
|
.info-item {
|
display: flex;
|
margin-bottom: 15rpx;
|
align-items: center;
|
|
.label {
|
width: 140rpx;
|
color: var(--text-color);
|
opacity: 0.7;
|
font-size: 26rpx;
|
}
|
|
.value {
|
flex: 1;
|
color: var(--text-color);
|
font-size: 26rpx;
|
font-weight: 500;
|
background-color: rgba(0, 0, 0, 0.03);
|
padding: 8rpx 15rpx;
|
border-radius: 6rpx;
|
border-left: 3rpx solid #2979ff;
|
}
|
}
|
|
.code-display {
|
background: linear-gradient(145deg,
|
rgba(0, 0, 0, 0.03),
|
rgba(0, 0, 0, 0.06));
|
padding: 20rpx;
|
border-radius: 10rpx;
|
margin-bottom: 20rpx;
|
min-height: 70rpx;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
position: relative;
|
overflow: hidden;
|
|
.code-text {
|
font-family: "Courier New", monospace;
|
font-size: 26rpx;
|
color: var(--text-color);
|
word-break: break-all;
|
text-align: center;
|
}
|
}
|
|
.code-actions {
|
display: flex;
|
justify-content: space-between;
|
margin-bottom: 15rpx;
|
|
.action-btn {
|
flex: 1;
|
margin: 0 8rpx;
|
font-size: 26rpx;
|
height: 80rpx;
|
line-height: 80rpx;
|
border-radius: 40rpx;
|
transition: all 0.3s ease;
|
border: none;
|
|
&.generate {
|
background: linear-gradient(135deg, #2979ff, #5e35b1);
|
color: #fff;
|
box-shadow: 0 4rpx 10rpx rgba(41, 121, 255, 0.3);
|
|
&:active {
|
transform: translateY(2rpx);
|
box-shadow: 0 2rpx 5rpx rgba(41, 121, 255, 0.3);
|
}
|
}
|
|
&.copy {
|
background: linear-gradient(135deg, #67c23a, #009688);
|
color: #fff;
|
box-shadow: 0 4rpx 10rpx rgba(103, 194, 58, 0.3);
|
|
&:active {
|
transform: translateY(2rpx);
|
box-shadow: 0 2rpx 5rpx rgba(103, 194, 58, 0.3);
|
}
|
}
|
|
&:first-child {
|
margin-left: 0;
|
}
|
|
&:last-child {
|
margin-right: 0;
|
}
|
|
&[disabled] {
|
background: linear-gradient(135deg, #c0c4cc, #909399);
|
color: #fff;
|
box-shadow: none;
|
}
|
}
|
}
|
|
.code-tip {
|
font-size: 22rpx;
|
color: var(--text-color);
|
opacity: 0.6;
|
text-align: center;
|
margin-top: 12rpx;
|
font-style: italic;
|
}
|
|
.activation-form {
|
.input-group {
|
display: flex;
|
align-items: center;
|
|
.activation-input {
|
flex: 1;
|
height: 80rpx;
|
border: 1px solid rgba(0, 0, 0, 0.1);
|
border-radius: 40rpx;
|
padding: 0 20rpx;
|
margin-right: 15rpx;
|
font-size: 26rpx;
|
background-color: rgba(0, 0, 0, 0.02);
|
color: var(--text-color);
|
transition: all 0.3s ease;
|
|
&:focus {
|
border-color: #2979ff;
|
box-shadow: 0 0 0 2rpx rgba(41, 121, 255, 0.1);
|
}
|
}
|
|
.action-btn {
|
width: 150rpx;
|
height: 80rpx;
|
line-height: 80rpx;
|
background: linear-gradient(135deg, #2979ff, #5e35b1);
|
color: #fff;
|
font-size: 26rpx;
|
border-radius: 40rpx;
|
box-shadow: 0 4rpx 10rpx rgba(41, 121, 255, 0.3);
|
transition: all 0.3s ease;
|
border: none;
|
|
&:active {
|
transform: translateY(2rpx);
|
box-shadow: 0 2rpx 5rpx rgba(41, 121, 255, 0.3);
|
}
|
|
&[disabled] {
|
background: linear-gradient(135deg, #c0c4cc, #909399);
|
box-shadow: none;
|
}
|
}
|
}
|
}
|
|
.status-card {
|
.status-info {
|
.status-item {
|
display: flex;
|
margin-bottom: 15rpx;
|
align-items: center;
|
|
.label {
|
width: 160rpx;
|
color: var(--text-color);
|
opacity: 0.7;
|
font-size: 26rpx;
|
}
|
|
.value {
|
flex: 1;
|
color: var(--text-color);
|
font-size: 26rpx;
|
font-weight: 500;
|
background-color: rgba(0, 0, 0, 0.03);
|
padding: 8rpx 15rpx;
|
border-radius: 6rpx;
|
|
&.success {
|
color: #67c23a;
|
border-left: 3rpx solid #67c23a;
|
}
|
|
&.warning {
|
color: #e6a23c;
|
border-left: 3rpx solid #e6a23c;
|
}
|
}
|
}
|
}
|
}
|
|
.footer-note {
|
text-align: center;
|
font-size: 22rpx;
|
color: var(--text-color);
|
opacity: 0.6;
|
margin-top: 30rpx;
|
margin-bottom: 20rpx;
|
|
.contact {
|
display: inline-block;
|
margin-left: 10rpx;
|
color: #2979ff;
|
font-weight: 500;
|
text-decoration: underline;
|
}
|
|
.wechat-link {
|
margin-top: 15rpx;
|
color: #2979ff;
|
font-size: 24rpx;
|
font-weight: 500;
|
text-decoration: underline;
|
cursor: pointer;
|
|
&:active {
|
opacity: 0.8;
|
}
|
}
|
}
|
|
// 二维码弹窗样式
|
.qrcode-container {
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
padding: 20rpx;
|
|
.qrcode-image {
|
width: 400rpx;
|
height: 400rpx;
|
margin-bottom: 20rpx;
|
border-radius: 10rpx;
|
box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.1);
|
}
|
|
.qrcode-tip {
|
font-size: 26rpx;
|
color: var(--text-color);
|
opacity: 0.8;
|
text-align: center;
|
}
|
}
|
}
|
</style>
|