update
This commit is contained in:
parent
073d6b1ce7
commit
2ba9968029
@ -89,7 +89,7 @@
|
|||||||
<view class="detailBottomItem">
|
<view class="detailBottomItem">
|
||||||
<!-- serviceDetail.sumDetail.haveREFUELINGGUN -->
|
<!-- serviceDetail.sumDetail.haveREFUELINGGUN -->
|
||||||
|
|
||||||
<image class="detailIcon" :src="true
|
<image class="detailIcon" :src="serviceDetail.haveREFUELINGGUN
|
||||||
? '/static/images/home/serviceGasoline.svg'
|
? '/static/images/home/serviceGasoline.svg'
|
||||||
: '/static/images/home/noServiceGasoline.svg'
|
: '/static/images/home/noServiceGasoline.svg'
|
||||||
" />
|
" />
|
||||||
@ -106,7 +106,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="detailBottomItem">
|
<view class="detailBottomItem">
|
||||||
<!-- serviceDetail.sumDetail.havePARKING -->
|
<!-- serviceDetail.sumDetail.havePARKING -->
|
||||||
<image class="detailIcon" :src="true
|
<image class="detailIcon" :src="serviceDetail.havePARKING
|
||||||
? '/static/images/home/carStop.svg'
|
? '/static/images/home/carStop.svg'
|
||||||
: '/static/images/home/noCarStop.svg'
|
: '/static/images/home/noCarStop.svg'
|
||||||
" />
|
" />
|
||||||
@ -115,7 +115,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="detailBottomItem">
|
<view class="detailBottomItem">
|
||||||
<!-- serviceDetail.sumDetail.haveWC -->
|
<!-- serviceDetail.sumDetail.haveWC -->
|
||||||
<image class="detailIcon" :src="true
|
<image class="detailIcon" :src="serviceDetail.haveWC
|
||||||
? '/static/images/home/toilet.svg'
|
? '/static/images/home/toilet.svg'
|
||||||
: '/static/images/home/noToilet.svg'
|
: '/static/images/home/noToilet.svg'
|
||||||
" />
|
" />
|
||||||
@ -124,7 +124,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="detailBottomItem">
|
<view class="detailBottomItem">
|
||||||
<!-- serviceDetail.HASMOTHER -->
|
<!-- serviceDetail.HASMOTHER -->
|
||||||
<image class="detailIcon" :src="true
|
<image class="detailIcon" :src="serviceDetail.HASMOTHER
|
||||||
? ' /static/images/home/badyHome.svg'
|
? ' /static/images/home/badyHome.svg'
|
||||||
: '/static/images/home/noBadyHome.svg'
|
: '/static/images/home/noBadyHome.svg'
|
||||||
" />
|
" />
|
||||||
@ -495,7 +495,7 @@ export default {
|
|||||||
console.log("stronge", stronge);
|
console.log("stronge", stronge);
|
||||||
|
|
||||||
// this.$refs.noticeRef.open("center");
|
// this.$refs.noticeRef.open("center");
|
||||||
if (new Date("2025-05-07 00:00:00").getTime() < new Date().getTime() && new Date("2025-05-15 23:59:59").getTime() > new Date().getTime()) {
|
if (new Date("2025-05-22 00:00:00").getTime() < new Date().getTime() && new Date("2025-05-29 23:59:59").getTime() > new Date().getTime()) {
|
||||||
this.$refs.noticeRef.open("center");
|
this.$refs.noticeRef.open("center");
|
||||||
let _this = this
|
let _this = this
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -553,7 +553,7 @@ export default {
|
|||||||
// 商城的内容
|
// 商城的内容
|
||||||
this.handleGetShoppingMall();
|
this.handleGetShoppingMall();
|
||||||
|
|
||||||
this.handleAes()
|
// this.handleAes()
|
||||||
this.$utils.addUserBehaviorNew();
|
this.$utils.addUserBehaviorNew();
|
||||||
},
|
},
|
||||||
async onShow() {
|
async onShow() {
|
||||||
@ -635,23 +635,20 @@ export default {
|
|||||||
// 测试加密的方法
|
// 测试加密的方法
|
||||||
async handleAes() {
|
async handleAes() {
|
||||||
const req = {
|
const req = {
|
||||||
ProvinceCode: '340000',
|
waybillNo: "434491081179331",
|
||||||
ServerpartId: "416",
|
mobile: "15558136957",
|
||||||
DataType: 1,
|
|
||||||
StartMonth: "202401",
|
|
||||||
EndMonth: "202412",
|
|
||||||
type: 'encryption'
|
type: 'encryption'
|
||||||
}
|
}
|
||||||
let str = JSON.stringify(req)
|
let str = JSON.stringify(req)
|
||||||
console.log('strstrstrstrstr', str)
|
console.log('strstrstrstrstr', str)
|
||||||
let jiami = encryptAES(str)
|
// let jiami = encryptAES(str)
|
||||||
console.log('jiamijiamijiamijiami', jiami)
|
// console.log('jiamijiamijiamijiami', jiami)
|
||||||
|
|
||||||
let jiemi = decryptAES(jiami)
|
// let jiemi = decryptAES(jiami)
|
||||||
console.log('jiemijiemijiemijiemijiemi', jiemi)
|
// console.log('jiemijiemijiemijiemijiemi', jiemi)
|
||||||
|
|
||||||
const data = await this.$api.$zzyLocalPost(
|
const data = await this.$api.$zzyLocalPost(
|
||||||
"/CommercialApi/Analysis/GetBusinessRevenueList",
|
"/WeChat/ExpressQuery",
|
||||||
req
|
req
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -662,7 +659,7 @@ export default {
|
|||||||
console.log('1231');
|
console.log('1231');
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.getFuzzyLocation({
|
uni.getLocation({
|
||||||
type: "gcj02",
|
type: "gcj02",
|
||||||
altitude: true,
|
altitude: true,
|
||||||
success: async (res) => {
|
success: async (res) => {
|
||||||
@ -691,8 +688,12 @@ export default {
|
|||||||
console.log('handleReloadFunIndex');
|
console.log('handleReloadFunIndex');
|
||||||
this.triggered = true
|
this.triggered = true
|
||||||
let _this = this
|
let _this = this
|
||||||
// const seatInfo = await this.handleGetNewPosition()
|
const seatInfo = await this.handleGetNewPosition()
|
||||||
// handleGetNearService(this, seatInfo.longitude, seatInfo.latitude)
|
console.log('seatInfo', seatInfo);
|
||||||
|
uni.setStorageSync("seatInfo", JSON.stringify(seatInfo));
|
||||||
|
uni.setStorageSync("actualLocation", JSON.stringify(seatInfo));
|
||||||
|
|
||||||
|
await _this.handleGetNearService(seatInfo.longitude, seatInfo.latitude)
|
||||||
|
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
@ -2236,7 +2237,7 @@ export default {
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 32rpx;
|
border-radius: 32rpx;
|
||||||
// background-image: url(https://eshangtech.com/minTestImg/caiyunyiguanggao.jpg);
|
// background-image: url(https://eshangtech.com/minTestImg/caiyunyiguanggao.jpg);
|
||||||
background-image: url(https://ahyd.eshangtech.com/UploadImageDir/minprogram/caiyunyiguanggao.jpg);
|
background-image: url(https://ahyd.eshangtech.com/UploadImageDir/minprogram/caiyunyiguanggao_0522_0529.jpg);
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-size: 100% 100%;
|
background-size: 100% 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|||||||
@ -19,11 +19,50 @@
|
|||||||
<view class="contentItem">
|
<view class="contentItem">
|
||||||
<view class="itemLeft">昵称</view>
|
<view class="itemLeft">昵称</view>
|
||||||
<view class="itemRight">
|
<view class="itemRight">
|
||||||
<view class="phoneBox">
|
<!-- <view class="phoneBox">
|
||||||
{{ userInfo.MEMBERSHIP_NAME }}
|
{{ userInfo.MEMBERSHIP_NAME }}
|
||||||
|
</view> -->
|
||||||
|
<input class="phoneBox" v-model="editableNickname" placeholder="请输入昵称" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 添加性别选择 -->
|
||||||
|
<view class="contentItem">
|
||||||
|
<view class="itemLeft">性别</view>
|
||||||
|
<view class="itemRight">
|
||||||
|
<picker @change="bindGenderChange" :value="genderIndex" :range="genderArray">
|
||||||
|
<view class="phoneBox">{{ genderArray[genderIndex] }}</view>
|
||||||
|
</picker>
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 添加生日选择 -->
|
||||||
|
<view class="contentItem">
|
||||||
|
<view class="itemLeft">生日</view>
|
||||||
|
<view class="itemRight">
|
||||||
|
<picker mode="multiSelector" @change="bindMultiPickerChange"
|
||||||
|
@columnchange="bindMultiPickerColumnChange" :value="multiIndex" :range="multiArray">
|
||||||
|
<view class="phoneBox">{{ birthday || '请选择生日' }}</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 添加证件号码输入 -->
|
||||||
|
<view class="contentItem">
|
||||||
|
<view class="itemLeft">证件号码</view>
|
||||||
|
<view class="itemRight">
|
||||||
|
<input class="phoneBox" v-model="idNumber" placeholder="请输入证件号码" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 添加邮箱地址输入 -->
|
||||||
|
<view class="contentItem">
|
||||||
|
<view class="itemLeft">邮箱地址</view>
|
||||||
|
<view class="itemRight">
|
||||||
|
<input class="phoneBox" v-model="email" placeholder="请输入邮箱地址" type="text" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
<view class="contentItem">
|
<view class="contentItem">
|
||||||
<view class="itemLeft">手机号码</view>
|
<view class="itemLeft">手机号码</view>
|
||||||
@ -79,7 +118,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="btnBox">
|
<view class="btnBox">
|
||||||
<!-- <view class="saveBtn" style="margin-bottom: 24rpx;">保存修改</view> -->
|
<view class="saveBtn" style="margin-bottom: 24rpx;" @click="handleSaveChange">保存修改</view>
|
||||||
<view class="loginOut" @click="handleGoLoginOut">退出登录</view>
|
<view class="loginOut" @click="handleGoLoginOut">退出登录</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -91,6 +130,16 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
userInfo: {},// 用户信息
|
userInfo: {},// 用户信息
|
||||||
|
editableNickname: '', // 可编辑的昵称
|
||||||
|
genderArray: ['男', '女'], // 性别选项
|
||||||
|
genderIndex: 0, // 选中的性别索引
|
||||||
|
multiArray: [['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'], Array.from({ length: 31 }, (_, i) => `${i + 1}日`)], // 多列选择器的数据
|
||||||
|
multiIndex: [0, 0], // 多列选择器的选中索引
|
||||||
|
birthday: '',
|
||||||
|
idNumber: '', // 证件号码
|
||||||
|
email: '', // 邮箱地址
|
||||||
|
WXProfile: '', // 微信头像
|
||||||
|
newUserInfo: {}, // 新的用户信息
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -110,8 +159,117 @@ export default {
|
|||||||
onLoad() {
|
onLoad() {
|
||||||
// 拿用户信息
|
// 拿用户信息
|
||||||
this.handleGetUserDetail();
|
this.handleGetUserDetail();
|
||||||
|
// 拿到用户新的信息
|
||||||
|
this.handleGetUserNewInfo();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 保存修改
|
||||||
|
async handleSaveChange() {
|
||||||
|
console.log('昵称', this.editableNickname);
|
||||||
|
console.log('性别', this.genderArray[this.genderIndex]);
|
||||||
|
console.log('生日', this.birthday);
|
||||||
|
console.log('证件号码', this.idNumber);
|
||||||
|
console.log('邮箱地址', this.email);
|
||||||
|
|
||||||
|
const req = {
|
||||||
|
Membership_NickName: this.editableNickname,
|
||||||
|
Membership_Sex: this.genderArray[this.genderIndex] === '男' ? 1 : 2,
|
||||||
|
Membership_Birthday: this.birthday,
|
||||||
|
Certificate_Number: this.idNumber,
|
||||||
|
Membership_Email: this.email,
|
||||||
|
type: 'encryption'
|
||||||
|
}
|
||||||
|
const userInfoData = await this.$api.$post(
|
||||||
|
"/WeChat/ModifyMemberInfo",
|
||||||
|
req
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('userInfoData', userInfoData);
|
||||||
|
if (userInfoData.Result_Code === 100) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '修改成功',
|
||||||
|
icon: 'success',
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
// 更新用户信息
|
||||||
|
this.handleGetUserNewInfo();
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '修改失败,请稍后再试',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 拿到新的用户信息
|
||||||
|
async handleGetUserNewInfo() {
|
||||||
|
const userInfoData = await this.$api.$post(
|
||||||
|
"/WeChat/GetMembershipInfoById",
|
||||||
|
{
|
||||||
|
type: 'encryption'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
console.log('userInfoData', userInfoData);
|
||||||
|
if (userInfoData.Result_Code === 100) {
|
||||||
|
this.newUserInfo = userInfoData.Result_Data;
|
||||||
|
console.log('this.newUserInfo', this.newUserInfo);
|
||||||
|
this.editableNickname = this.newUserInfo.Membership_NickName || '';
|
||||||
|
this.genderIndex = this.newUserInfo.Membership_Sex === 1 ? 0 : 1; // 男性为0,女性为1
|
||||||
|
this.multiIndex = [
|
||||||
|
new Date(this.newUserInfo.Membership_Birthday).getMonth(),
|
||||||
|
new Date(this.newUserInfo.Membership_Birthday).getDate() - 1
|
||||||
|
]; // 月份和日期索引
|
||||||
|
console.log('this.multiIndex', this.multiIndex);
|
||||||
|
const date = new Date(this.newUserInfo.Membership_Birthday);
|
||||||
|
this.birthday = `${date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1}-${date.getDate() < 10 ? '0' + date.getDate() : date.getDate()}`; // 格式化为 MM-DD
|
||||||
|
|
||||||
|
this.idNumber = this.newUserInfo.Certificate_Number
|
||||||
|
this.email = this.newUserInfo.Membership_Email
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 性别选择改变
|
||||||
|
bindGenderChange(e) {
|
||||||
|
this.genderIndex = e.detail.value
|
||||||
|
},
|
||||||
|
// 生日多列选择器列改变
|
||||||
|
bindMultiPickerColumnChange(e) {
|
||||||
|
const data = [...this.multiArray]; // 复制 multiArray
|
||||||
|
const multiIndex = [...this.multiIndex]; // 复制 multiIndex
|
||||||
|
multiIndex[e.detail.column] = e.detail.value;
|
||||||
|
|
||||||
|
if (e.detail.column === 0) { // 月份列改变
|
||||||
|
const month = e.detail.value + 1; // 月份是 1-based
|
||||||
|
let daysInMonth = 31;
|
||||||
|
if (month === 4 || month === 6 || month === 9 || month === 11) {
|
||||||
|
daysInMonth = 30;
|
||||||
|
} else if (month === 2) {
|
||||||
|
// 简化处理,不考虑闰年,二月按 28 天计算
|
||||||
|
daysInMonth = 28;
|
||||||
|
}
|
||||||
|
// 生成新的天数数组
|
||||||
|
const daysArray = Array.from({ length: daysInMonth }, (_, i) => `${i + 1}日`);
|
||||||
|
data[1] = daysArray; // 更新天数数组
|
||||||
|
|
||||||
|
// 如果之前选择的天数索引超出新月份的天数范围,则重置天数索引
|
||||||
|
if (multiIndex[1] >= daysInMonth) {
|
||||||
|
multiIndex[1] = daysInMonth - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新数据和索引
|
||||||
|
this.multiArray = data;
|
||||||
|
this.multiIndex = multiIndex;
|
||||||
|
},
|
||||||
|
// 生日多列选择器值改变
|
||||||
|
bindMultiPickerChange(e) {
|
||||||
|
this.multiIndex = e.detail.value;
|
||||||
|
const month = this.multiIndex[0] + 1;
|
||||||
|
const day = this.multiIndex[1] + 1;
|
||||||
|
// 格式化为 MM-DD 字符串,不足两位前补零
|
||||||
|
const formattedMonth = month < 10 ? '0' + month : month;
|
||||||
|
const formattedDay = day < 10 ? '0' + day : day;
|
||||||
|
this.birthday = `${formattedMonth}-${formattedDay}`;
|
||||||
|
},
|
||||||
// 收藏的商品
|
// 收藏的商品
|
||||||
handleGoFavoriteStore() {
|
handleGoFavoriteStore() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
@ -193,7 +351,6 @@ export default {
|
|||||||
this.$forceUpdate();
|
this.$forceUpdate();
|
||||||
console.log("this.userInfo", this.userInfo);
|
console.log("this.userInfo", this.userInfo);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 用户上传头像
|
// 用户上传头像
|
||||||
async onChooseAvatar(e) {
|
async onChooseAvatar(e) {
|
||||||
let _this = this;
|
let _this = this;
|
||||||
@ -231,7 +388,7 @@ export default {
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.main {
|
.main {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
min-height: 100vh;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background-color: #F5F5F5;
|
background-color: #F5F5F5;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -315,6 +472,7 @@ export default {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 0 32rpx;
|
padding: 0 32rpx;
|
||||||
|
margin-top: 32rpx;
|
||||||
|
|
||||||
.saveBtn {
|
.saveBtn {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
54
unpackage/dist/dev/mp-weixin/common/vendor.js
vendored
54
unpackage/dist/dev/mp-weixin/common/vendor.js
vendored
@ -12873,7 +12873,7 @@ var staticImagePath = 'https://eshangtech.com/ShopICO';
|
|||||||
// let nodeUrl = 'https://es.robot-z.cn'
|
// let nodeUrl = 'https://es.robot-z.cn'
|
||||||
var nodeUrl = 'https://es.eshangtech.com';
|
var nodeUrl = 'https://es.eshangtech.com';
|
||||||
var javaUrl = "https://admin.es.eshangtech.com/platform";
|
var javaUrl = "https://admin.es.eshangtech.com/platform";
|
||||||
var zzyLocal = "http://10.104.1.25:8900";
|
var zzyLocal = "http://10.104.1.35:8901";
|
||||||
// let javaUrl = `http://10.104.1.175:8070/platform`
|
// let javaUrl = `http://10.104.1.175:8070/platform`
|
||||||
|
|
||||||
var type = uni.getSystemInfoSync();
|
var type = uni.getSystemInfoSync();
|
||||||
@ -12902,19 +12902,14 @@ var api = {
|
|||||||
data.ownerUnitId = '911';
|
data.ownerUnitId = '911';
|
||||||
data.Membership_Id = _index.default.getters.user.MEMBERSHIP_ID || _index.default.getters.user.MemberShipID || data.MEMBERSHIP_ID || '';
|
data.Membership_Id = _index.default.getters.user.MEMBERSHIP_ID || _index.default.getters.user.MemberShipID || data.MEMBERSHIP_ID || '';
|
||||||
data.MembershipId = _index.default.getters.user.MEMBERSHIP_ID || _index.default.getters.user.MemberShipID || data.MEMBERSHIP_ID || '';
|
data.MembershipId = _index.default.getters.user.MEMBERSHIP_ID || _index.default.getters.user.MemberShipID || data.MEMBERSHIP_ID || '';
|
||||||
|
if (data.type === 'encryption') {}
|
||||||
var requstOptions = {
|
var requstOptions = {
|
||||||
url: isWebApi ? _this.url + control : _this.url,
|
url: isWebApi ? _this.url + control : _this.url,
|
||||||
data: data.type === 'encryption' ? {
|
data: data.type === 'encryption' ? {
|
||||||
postData: {
|
postData: (0, _handleAes.encryptAES)(JSON.stringify(data))
|
||||||
name: "",
|
|
||||||
value: (0, _handleAes.encryptAES)(JSON.stringify(data))
|
|
||||||
}
|
|
||||||
} : data,
|
} : data,
|
||||||
method: method
|
method: method
|
||||||
};
|
};
|
||||||
if (data.type === 'encryption') {
|
|
||||||
console.log('requstOptionsrequstOptionsrequstOptionsrequstOptions', requstOptions);
|
|
||||||
}
|
|
||||||
if (method === 'POST') {
|
if (method === 'POST') {
|
||||||
if (data.requestType === 'application/x-www-form-urlencoded') {
|
if (data.requestType === 'application/x-www-form-urlencoded') {
|
||||||
requstOptions.header = {
|
requstOptions.header = {
|
||||||
@ -12931,6 +12926,7 @@ var api = {
|
|||||||
requstOptions.success = function (res) {
|
requstOptions.success = function (res) {
|
||||||
// success
|
// success
|
||||||
if (res.statusCode !== 200 && res.statusCode !== 201) {
|
if (res.statusCode !== 200 && res.statusCode !== 201) {
|
||||||
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '网络出错,稍后再试',
|
title: '网络出错,稍后再试',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
@ -12952,7 +12948,7 @@ var api = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('res.datares.datares.datares.data', res.data);
|
uni.hideLoading();
|
||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
};
|
};
|
||||||
requstOptions.fail = function (error) {
|
requstOptions.fail = function (error) {
|
||||||
@ -13127,9 +13123,9 @@ function bytesToBase64(bytes) {
|
|||||||
var str = '',
|
var str = '',
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < bytes.length) {
|
while (i < bytes.length) {
|
||||||
var c1 = bytes[i++] || 0,
|
var c1 = bytes[i++],
|
||||||
c2 = bytes[i++] || 0,
|
c2 = bytes[i++],
|
||||||
c3 = bytes[i++] || 0;
|
c3 = bytes[i++];
|
||||||
var e1 = c1 >> 2,
|
var e1 = c1 >> 2,
|
||||||
e2 = (c1 & 3) << 4 | c2 >> 4,
|
e2 = (c1 & 3) << 4 | c2 >> 4,
|
||||||
e3 = (c2 & 15) << 2 | c3 >> 6,
|
e3 = (c2 & 15) << 2 | c3 >> 6,
|
||||||
@ -13158,14 +13154,22 @@ function base64ToBytes(str) {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
function pkcs7Pad(data) {
|
function pkcs7Pad(data) {
|
||||||
var blockSize = 16;
|
var blockSize = 16; // AES块大小为16字节
|
||||||
var pad = blockSize - data.length % blockSize;
|
var pad = blockSize - data.length % blockSize;
|
||||||
return data.concat(Array(pad).fill(pad));
|
return data.concat(Array(pad).fill(pad));
|
||||||
}
|
}
|
||||||
function pkcs7Unpad(data) {
|
function pkcs7Unpad(data) {
|
||||||
|
var blockSize = 16; // 确保这里也定义blockSize
|
||||||
var pad = data[data.length - 1];
|
var pad = data[data.length - 1];
|
||||||
|
if (pad > 0 && pad <= blockSize) {
|
||||||
|
for (var i = data.length - pad; i < data.length; i++) {
|
||||||
|
if (data[i] !== pad) return data; // 如果填充无效,则返回原始数据
|
||||||
|
}
|
||||||
|
|
||||||
return data.slice(0, data.length - pad);
|
return data.slice(0, data.length - pad);
|
||||||
}
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
function xorBlock(a, b) {
|
function xorBlock(a, b) {
|
||||||
var out = [];
|
var out = [];
|
||||||
for (var i = 0; i < a.length; i++) {
|
for (var i = 0; i < a.length; i++) {
|
||||||
@ -13182,18 +13186,19 @@ function aesBlockDecrypt(block, key) {
|
|||||||
return xorBlock(block, key);
|
return xorBlock(block, key);
|
||||||
}
|
}
|
||||||
function aesCbcEncrypt(plainBytes, keyBytes, ivBytes) {
|
function aesCbcEncrypt(plainBytes, keyBytes, ivBytes) {
|
||||||
|
var padded = pkcs7Pad(plainBytes); // 应用PKCS#7填充
|
||||||
var blocks = [],
|
var blocks = [],
|
||||||
prev = ivBytes;
|
prev = ivBytes;
|
||||||
for (var i = 0; i < plainBytes.length; i += 16) {
|
for (var i = 0; i < padded.length; i += 16) {
|
||||||
var block = plainBytes.slice(i, i + 16);
|
var block = padded.slice(i, i + 16);
|
||||||
if (block.length < 16) block = block.concat(Array(16 - block.length).fill(0));
|
|
||||||
var xored = xorBlock(block, prev);
|
var xored = xorBlock(block, prev);
|
||||||
var encrypted = aesBlockEncrypt(xored, keyBytes);
|
var encrypted = aesBlockEncrypt(xored, keyBytes);
|
||||||
blocks = blocks.concat(encrypted);
|
blocks = blocks.concat(encrypted);
|
||||||
prev = encrypted;
|
prev = encrypted;
|
||||||
}
|
}
|
||||||
return blocks;
|
return blocks; // 返回完整的加密块
|
||||||
}
|
}
|
||||||
|
|
||||||
function aesCbcDecrypt(cipherBytes, keyBytes, ivBytes) {
|
function aesCbcDecrypt(cipherBytes, keyBytes, ivBytes) {
|
||||||
var blocks = [],
|
var blocks = [],
|
||||||
prev = ivBytes;
|
prev = ivBytes;
|
||||||
@ -13204,8 +13209,9 @@ function aesCbcDecrypt(cipherBytes, keyBytes, ivBytes) {
|
|||||||
blocks = blocks.concat(xored);
|
blocks = blocks.concat(xored);
|
||||||
prev = block;
|
prev = block;
|
||||||
}
|
}
|
||||||
return blocks;
|
return pkcs7Unpad(blocks); // 移除PKCS#7填充
|
||||||
}
|
}
|
||||||
|
|
||||||
var CryptoJS = {};
|
var CryptoJS = {};
|
||||||
CryptoJS.enc = {
|
CryptoJS.enc = {
|
||||||
Utf8: {
|
Utf8: {
|
||||||
@ -13231,26 +13237,26 @@ CryptoJS.AES = {
|
|||||||
var bytes = typeof data === 'string' ? toBytes(data) : data;
|
var bytes = typeof data === 'string' ? toBytes(data) : data;
|
||||||
var k = typeof key === 'string' ? toBytes(key) : Array.from(key);
|
var k = typeof key === 'string' ? toBytes(key) : Array.from(key);
|
||||||
var iv = typeof options.iv === 'string' ? toBytes(options.iv) : Array.from(options.iv);
|
var iv = typeof options.iv === 'string' ? toBytes(options.iv) : Array.from(options.iv);
|
||||||
var padded = pkcs7Pad(bytes);
|
var encryptedBlocks = aesCbcEncrypt(bytes, k, iv);
|
||||||
var encrypted = aesCbcEncrypt(padded, k, iv);
|
|
||||||
return {
|
return {
|
||||||
toString: function toString() {
|
toString: function toString() {
|
||||||
return bytesToBase64(encrypted);
|
return CryptoJS.enc.Base64.stringify(encryptedBlocks); // 使用标准方法转换为Base64
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
decrypt: function decrypt(ciphertext, key, options) {
|
decrypt: function decrypt(ciphertext, key, options) {
|
||||||
var cipherBytes = typeof ciphertext === 'string' ? base64ToBytes(ciphertext) : ciphertext;
|
var cipherBytes = typeof ciphertext === 'string' ? base64ToBytes(ciphertext) : ciphertext;
|
||||||
var k = typeof key === 'string' ? toBytes(key) : Array.from(key);
|
var k = typeof key === 'string' ? toBytes(key) : Array.from(key);
|
||||||
var iv = typeof options.iv === 'string' ? toBytes(options.iv) : Array.from(options.iv);
|
var iv = typeof options.iv === 'string' ? toBytes(options.iv) : Array.from(options.iv);
|
||||||
var decrypted = aesCbcDecrypt(cipherBytes, k, iv);
|
var decrypted = aesCbcDecrypt(cipherBytes, k, iv);
|
||||||
var unpadded = pkcs7Unpad(decrypted);
|
|
||||||
return {
|
return {
|
||||||
toString: function toString(enc) {
|
toString: function toString(enc) {
|
||||||
if (enc && enc === CryptoJS.enc.Utf8) {
|
if (enc && enc === CryptoJS.enc.Utf8) {
|
||||||
return fromBytes(unpadded);
|
return CryptoJS.enc.Utf8.stringify(decrypted); // 转换回原始字符串
|
||||||
}
|
}
|
||||||
return unpadded;
|
|
||||||
|
return decrypted;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -367,7 +367,7 @@ var _default = {
|
|||||||
console.log("stronge", stronge);
|
console.log("stronge", stronge);
|
||||||
|
|
||||||
// this.$refs.noticeRef.open("center");
|
// this.$refs.noticeRef.open("center");
|
||||||
if (new Date("2025-05-07 00:00:00").getTime() < new Date().getTime() && new Date("2025-05-15 23:59:59").getTime() > new Date().getTime()) {
|
if (new Date("2025-05-22 00:00:00").getTime() < new Date().getTime() && new Date("2025-05-29 23:59:59").getTime() > new Date().getTime()) {
|
||||||
_this2.$refs.noticeRef.open("center");
|
_this2.$refs.noticeRef.open("center");
|
||||||
_this = _this2;
|
_this = _this2;
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@ -421,9 +421,10 @@ var _default = {
|
|||||||
_this2.handleGetProductsList();
|
_this2.handleGetProductsList();
|
||||||
// 商城的内容
|
// 商城的内容
|
||||||
_this2.handleGetShoppingMall();
|
_this2.handleGetShoppingMall();
|
||||||
_this2.handleAes();
|
|
||||||
|
// this.handleAes()
|
||||||
_this2.$utils.addUserBehaviorNew();
|
_this2.$utils.addUserBehaviorNew();
|
||||||
case 20:
|
case 19:
|
||||||
case "end":
|
case "end":
|
||||||
return _context.stop();
|
return _context.stop();
|
||||||
}
|
}
|
||||||
@ -543,31 +544,29 @@ var _default = {
|
|||||||
handleAes: function handleAes() {
|
handleAes: function handleAes() {
|
||||||
var _this5 = this;
|
var _this5 = this;
|
||||||
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
||||||
var req, str, jiami, jiemi, data;
|
var req, str, data;
|
||||||
return _regenerator.default.wrap(function _callee4$(_context4) {
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
||||||
while (1) {
|
while (1) {
|
||||||
switch (_context4.prev = _context4.next) {
|
switch (_context4.prev = _context4.next) {
|
||||||
case 0:
|
case 0:
|
||||||
req = {
|
req = {
|
||||||
ProvinceCode: '340000',
|
waybillNo: "434491081179331",
|
||||||
ServerpartId: "416",
|
mobile: "15558136957",
|
||||||
DataType: 1,
|
|
||||||
StartMonth: "202401",
|
|
||||||
EndMonth: "202412",
|
|
||||||
type: 'encryption'
|
type: 'encryption'
|
||||||
};
|
};
|
||||||
str = JSON.stringify(req);
|
str = JSON.stringify(req);
|
||||||
console.log('strstrstrstrstr', str);
|
console.log('strstrstrstrstr', str);
|
||||||
jiami = (0, _handleAes.encryptAES)(str);
|
// let jiami = encryptAES(str)
|
||||||
console.log('jiamijiamijiamijiami', jiami);
|
// console.log('jiamijiamijiamijiami', jiami)
|
||||||
jiemi = (0, _handleAes.decryptAES)(jiami);
|
|
||||||
console.log('jiemijiemijiemijiemijiemi', jiemi);
|
// let jiemi = decryptAES(jiami)
|
||||||
_context4.next = 9;
|
// console.log('jiemijiemijiemijiemijiemi', jiemi)
|
||||||
return _this5.$api.$zzyLocalPost("/CommercialApi/Analysis/GetBusinessRevenueList", req);
|
_context4.next = 5;
|
||||||
case 9:
|
return _this5.$api.$zzyLocalPost("/WeChat/ExpressQuery", req);
|
||||||
|
case 5:
|
||||||
data = _context4.sent;
|
data = _context4.sent;
|
||||||
console.log('dhsiadhashda', data);
|
console.log('dhsiadhashda', data);
|
||||||
case 11:
|
case 7:
|
||||||
case "end":
|
case "end":
|
||||||
return _context4.stop();
|
return _context4.stop();
|
||||||
}
|
}
|
||||||
@ -579,7 +578,7 @@ var _default = {
|
|||||||
handleGetNewPosition: function handleGetNewPosition() {
|
handleGetNewPosition: function handleGetNewPosition() {
|
||||||
console.log('1231');
|
console.log('1231');
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
uni.getFuzzyLocation({
|
uni.getLocation({
|
||||||
type: "gcj02",
|
type: "gcj02",
|
||||||
altitude: true,
|
altitude: true,
|
||||||
success: function () {
|
success: function () {
|
||||||
@ -618,15 +617,24 @@ var _default = {
|
|||||||
handleReloadFunIndex: function handleReloadFunIndex() {
|
handleReloadFunIndex: function handleReloadFunIndex() {
|
||||||
var _this6 = this;
|
var _this6 = this;
|
||||||
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
||||||
var _this;
|
var _this, seatInfo;
|
||||||
return _regenerator.default.wrap(function _callee6$(_context6) {
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
||||||
while (1) {
|
while (1) {
|
||||||
switch (_context6.prev = _context6.next) {
|
switch (_context6.prev = _context6.next) {
|
||||||
case 0:
|
case 0:
|
||||||
console.log('handleReloadFunIndex');
|
console.log('handleReloadFunIndex');
|
||||||
_this6.triggered = true;
|
_this6.triggered = true;
|
||||||
_this = _this6; // const seatInfo = await this.handleGetNewPosition()
|
_this = _this6;
|
||||||
// handleGetNearService(this, seatInfo.longitude, seatInfo.latitude)
|
_context6.next = 5;
|
||||||
|
return _this6.handleGetNewPosition();
|
||||||
|
case 5:
|
||||||
|
seatInfo = _context6.sent;
|
||||||
|
console.log('seatInfo', seatInfo);
|
||||||
|
uni.setStorageSync("seatInfo", JSON.stringify(seatInfo));
|
||||||
|
uni.setStorageSync("actualLocation", JSON.stringify(seatInfo));
|
||||||
|
_context6.next = 11;
|
||||||
|
return _this.handleGetNearService(seatInfo.longitude, seatInfo.latitude);
|
||||||
|
case 11:
|
||||||
return _context6.abrupt("return", new Promise(function (resolve) {
|
return _context6.abrupt("return", new Promise(function (resolve) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
_this.funList = [{
|
_this.funList = [{
|
||||||
@ -731,7 +739,7 @@ var _default = {
|
|||||||
resolve(true);
|
resolve(true);
|
||||||
}, 300);
|
}, 300);
|
||||||
}));
|
}));
|
||||||
case 4:
|
case 12:
|
||||||
case "end":
|
case "end":
|
||||||
return _context6.stop();
|
return _context6.stop();
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -618,7 +618,7 @@
|
|||||||
height: calc(2688 * 70vw / 1242);
|
height: calc(2688 * 70vw / 1242);
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 32rpx;
|
border-radius: 32rpx;
|
||||||
background-image: url(https://ahyd.eshangtech.com/UploadImageDir/minprogram/caiyunyiguanggao.jpg);
|
background-image: url(https://ahyd.eshangtech.com/UploadImageDir/minprogram/caiyunyiguanggao_0522_0529.jpg);
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-size: 100% 100%;
|
background-size: 100% 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|||||||
21
utils/api.js
21
utils/api.js
@ -16,7 +16,7 @@ let nodeUrl = 'https://es.eshangtech.com'
|
|||||||
|
|
||||||
let javaUrl = `https://admin.es.eshangtech.com/platform`
|
let javaUrl = `https://admin.es.eshangtech.com/platform`
|
||||||
|
|
||||||
let zzyLocal = `http://10.104.1.25:8900`
|
let zzyLocal = `http://10.104.1.35:8901`
|
||||||
// let javaUrl = `http://10.104.1.175:8070/platform`
|
// let javaUrl = `http://10.104.1.175:8070/platform`
|
||||||
|
|
||||||
let type = uni.getSystemInfoSync();
|
let type = uni.getSystemInfoSync();
|
||||||
@ -47,19 +47,18 @@ const api = {
|
|||||||
data.ownerUnitId = '911'
|
data.ownerUnitId = '911'
|
||||||
data.Membership_Id = Store.getters.user.MEMBERSHIP_ID || Store.getters.user.MemberShipID || data.MEMBERSHIP_ID || ''
|
data.Membership_Id = Store.getters.user.MEMBERSHIP_ID || Store.getters.user.MemberShipID || data.MEMBERSHIP_ID || ''
|
||||||
data.MembershipId = Store.getters.user.MEMBERSHIP_ID || Store.getters.user.MemberShipID || data.MEMBERSHIP_ID || ''
|
data.MembershipId = Store.getters.user.MEMBERSHIP_ID || Store.getters.user.MemberShipID || data.MEMBERSHIP_ID || ''
|
||||||
|
if (data.type === 'encryption') {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
let requstOptions = {
|
let requstOptions = {
|
||||||
url: isWebApi ? this.url + control : this.url,
|
url: isWebApi ? this.url + control : this.url,
|
||||||
data: data.type === 'encryption' ? {
|
data: data.type === 'encryption' ? {
|
||||||
postData: {
|
postData: encryptAES(JSON.stringify(data))
|
||||||
name: "",
|
|
||||||
value: encryptAES(JSON.stringify(data))
|
|
||||||
}
|
|
||||||
} : data,
|
} : data,
|
||||||
method: method
|
method: method
|
||||||
}
|
}
|
||||||
if (data.type === 'encryption') {
|
|
||||||
console.log('requstOptionsrequstOptionsrequstOptionsrequstOptions', requstOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (method === 'POST') {
|
if (method === 'POST') {
|
||||||
@ -77,6 +76,7 @@ const api = {
|
|||||||
requstOptions.success = function (res) {
|
requstOptions.success = function (res) {
|
||||||
// success
|
// success
|
||||||
if (res.statusCode !== 200 && res.statusCode !== 201) {
|
if (res.statusCode !== 200 && res.statusCode !== 201) {
|
||||||
|
uni.hideLoading()
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '网络出错,稍后再试',
|
title: '网络出错,稍后再试',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
@ -99,10 +99,7 @@ const api = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('res.datares.datares.datares.data', res.data);
|
uni.hideLoading()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resolve(res.data)
|
resolve(res.data)
|
||||||
}
|
}
|
||||||
requstOptions.fail = function (error) {
|
requstOptions.fail = function (error) {
|
||||||
|
|||||||
@ -34,7 +34,7 @@ const b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
|
|||||||
function bytesToBase64(bytes) {
|
function bytesToBase64(bytes) {
|
||||||
let str = '', i = 0;
|
let str = '', i = 0;
|
||||||
while (i < bytes.length) {
|
while (i < bytes.length) {
|
||||||
let c1 = bytes[i++] || 0, c2 = bytes[i++] || 0, c3 = bytes[i++] || 0;
|
let c1 = bytes[i++], c2 = bytes[i++], c3 = bytes[i++];
|
||||||
let e1 = c1 >> 2, e2 = ((c1 & 3) << 4) | (c2 >> 4), e3 = ((c2 & 15) << 2) | (c3 >> 6), e4 = c3 & 63;
|
let e1 = c1 >> 2, e2 = ((c1 & 3) << 4) | (c2 >> 4), e3 = ((c2 & 15) << 2) | (c3 >> 6), e4 = c3 & 63;
|
||||||
if (isNaN(c2)) e3 = e4 = 64;
|
if (isNaN(c2)) e3 = e4 = 64;
|
||||||
else if (isNaN(c3)) e4 = 64;
|
else if (isNaN(c3)) e4 = 64;
|
||||||
@ -42,6 +42,7 @@ function bytesToBase64(bytes) {
|
|||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function base64ToBytes(str) {
|
function base64ToBytes(str) {
|
||||||
let output = [], i = 0;
|
let output = [], i = 0;
|
||||||
str = str.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
str = str.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
||||||
@ -55,14 +56,22 @@ function base64ToBytes(str) {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
function pkcs7Pad(data) {
|
function pkcs7Pad(data) {
|
||||||
const blockSize = 16;
|
const blockSize = 16; // AES块大小为16字节
|
||||||
const pad = blockSize - (data.length % blockSize);
|
const pad = blockSize - (data.length % blockSize);
|
||||||
return data.concat(Array(pad).fill(pad));
|
return data.concat(Array(pad).fill(pad));
|
||||||
}
|
}
|
||||||
|
|
||||||
function pkcs7Unpad(data) {
|
function pkcs7Unpad(data) {
|
||||||
|
const blockSize = 16; // 确保这里也定义blockSize
|
||||||
const pad = data[data.length - 1];
|
const pad = data[data.length - 1];
|
||||||
|
if (pad > 0 && pad <= blockSize) {
|
||||||
|
for (let i = data.length - pad; i < data.length; i++) {
|
||||||
|
if (data[i] !== pad) return data; // 如果填充无效,则返回原始数据
|
||||||
|
}
|
||||||
return data.slice(0, data.length - pad);
|
return data.slice(0, data.length - pad);
|
||||||
}
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
function xorBlock(a, b) {
|
function xorBlock(a, b) {
|
||||||
const out = [];
|
const out = [];
|
||||||
for (let i = 0; i < a.length; i++) out[i] = a[i] ^ b[i];
|
for (let i = 0; i < a.length; i++) out[i] = a[i] ^ b[i];
|
||||||
@ -77,17 +86,18 @@ function aesBlockDecrypt(block, key) {
|
|||||||
return xorBlock(block, key);
|
return xorBlock(block, key);
|
||||||
}
|
}
|
||||||
function aesCbcEncrypt(plainBytes, keyBytes, ivBytes) {
|
function aesCbcEncrypt(plainBytes, keyBytes, ivBytes) {
|
||||||
|
let padded = pkcs7Pad(plainBytes); // 应用PKCS#7填充
|
||||||
let blocks = [], prev = ivBytes;
|
let blocks = [], prev = ivBytes;
|
||||||
for (let i = 0; i < plainBytes.length; i += 16) {
|
for (let i = 0; i < padded.length; i += 16) {
|
||||||
let block = plainBytes.slice(i, i + 16);
|
let block = padded.slice(i, i + 16);
|
||||||
if (block.length < 16) block = block.concat(Array(16 - block.length).fill(0));
|
|
||||||
let xored = xorBlock(block, prev);
|
let xored = xorBlock(block, prev);
|
||||||
let encrypted = aesBlockEncrypt(xored, keyBytes);
|
let encrypted = aesBlockEncrypt(xored, keyBytes);
|
||||||
blocks = blocks.concat(encrypted);
|
blocks = blocks.concat(encrypted);
|
||||||
prev = encrypted;
|
prev = encrypted;
|
||||||
}
|
}
|
||||||
return blocks;
|
return blocks; // 返回完整的加密块
|
||||||
}
|
}
|
||||||
|
|
||||||
function aesCbcDecrypt(cipherBytes, keyBytes, ivBytes) {
|
function aesCbcDecrypt(cipherBytes, keyBytes, ivBytes) {
|
||||||
let blocks = [], prev = ivBytes;
|
let blocks = [], prev = ivBytes;
|
||||||
for (let i = 0; i < cipherBytes.length; i += 16) {
|
for (let i = 0; i < cipherBytes.length; i += 16) {
|
||||||
@ -97,7 +107,7 @@ function aesCbcDecrypt(cipherBytes, keyBytes, ivBytes) {
|
|||||||
blocks = blocks.concat(xored);
|
blocks = blocks.concat(xored);
|
||||||
prev = block;
|
prev = block;
|
||||||
}
|
}
|
||||||
return blocks;
|
return pkcs7Unpad(blocks); // 移除PKCS#7填充
|
||||||
}
|
}
|
||||||
const CryptoJS = {};
|
const CryptoJS = {};
|
||||||
CryptoJS.enc = {
|
CryptoJS.enc = {
|
||||||
@ -122,11 +132,10 @@ CryptoJS.AES = {
|
|||||||
let bytes = typeof data === 'string' ? toBytes(data) : data;
|
let bytes = typeof data === 'string' ? toBytes(data) : data;
|
||||||
let k = typeof key === 'string' ? toBytes(key) : Array.from(key);
|
let k = typeof key === 'string' ? toBytes(key) : Array.from(key);
|
||||||
let iv = typeof options.iv === 'string' ? toBytes(options.iv) : Array.from(options.iv);
|
let iv = typeof options.iv === 'string' ? toBytes(options.iv) : Array.from(options.iv);
|
||||||
let padded = pkcs7Pad(bytes);
|
let encryptedBlocks = aesCbcEncrypt(bytes, k, iv);
|
||||||
let encrypted = aesCbcEncrypt(padded, k, iv);
|
|
||||||
return {
|
return {
|
||||||
toString: function () {
|
toString: function () {
|
||||||
return bytesToBase64(encrypted);
|
return CryptoJS.enc.Base64.stringify(encryptedBlocks); // 使用标准方法转换为Base64
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -135,15 +144,15 @@ CryptoJS.AES = {
|
|||||||
let k = typeof key === 'string' ? toBytes(key) : Array.from(key);
|
let k = typeof key === 'string' ? toBytes(key) : Array.from(key);
|
||||||
let iv = typeof options.iv === 'string' ? toBytes(options.iv) : Array.from(options.iv);
|
let iv = typeof options.iv === 'string' ? toBytes(options.iv) : Array.from(options.iv);
|
||||||
let decrypted = aesCbcDecrypt(cipherBytes, k, iv);
|
let decrypted = aesCbcDecrypt(cipherBytes, k, iv);
|
||||||
let unpadded = pkcs7Unpad(decrypted);
|
|
||||||
return {
|
return {
|
||||||
toString: function (enc) {
|
toString: function (enc) {
|
||||||
if (enc && enc === CryptoJS.enc.Utf8) {
|
if (enc && enc === CryptoJS.enc.Utf8) {
|
||||||
return fromBytes(unpadded);
|
return CryptoJS.enc.Utf8.stringify(decrypted); // 转换回原始字符串
|
||||||
}
|
}
|
||||||
return unpadded;
|
return decrypted;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CryptoJS;
|
export default CryptoJS;
|
||||||
Loading…
x
Reference in New Issue
Block a user