z8018
8 天以前 d5317aef1dbb595923af02ede8bfa33ba37d6eb6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
<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>