This commit is contained in:
ylj20011123 2025-05-27 18:14:40 +08:00
parent 073d6b1ce7
commit 2ba9968029
65 changed files with 336 additions and 157 deletions

View File

@ -89,7 +89,7 @@
<view class="detailBottomItem">
<!-- serviceDetail.sumDetail.haveREFUELINGGUN -->
<image class="detailIcon" :src="true
<image class="detailIcon" :src="serviceDetail.haveREFUELINGGUN
? '/static/images/home/serviceGasoline.svg'
: '/static/images/home/noServiceGasoline.svg'
" />
@ -106,7 +106,7 @@
</view>
<view class="detailBottomItem">
<!-- serviceDetail.sumDetail.havePARKING -->
<image class="detailIcon" :src="true
<image class="detailIcon" :src="serviceDetail.havePARKING
? '/static/images/home/carStop.svg'
: '/static/images/home/noCarStop.svg'
" />
@ -115,7 +115,7 @@
</view>
<view class="detailBottomItem">
<!-- serviceDetail.sumDetail.haveWC -->
<image class="detailIcon" :src="true
<image class="detailIcon" :src="serviceDetail.haveWC
? '/static/images/home/toilet.svg'
: '/static/images/home/noToilet.svg'
" />
@ -124,7 +124,7 @@
</view>
<view class="detailBottomItem">
<!-- serviceDetail.HASMOTHER -->
<image class="detailIcon" :src="true
<image class="detailIcon" :src="serviceDetail.HASMOTHER
? ' /static/images/home/badyHome.svg'
: '/static/images/home/noBadyHome.svg'
" />
@ -495,7 +495,7 @@ export default {
console.log("stronge", stronge);
// 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");
let _this = this
setTimeout(() => {
@ -553,7 +553,7 @@ export default {
//
this.handleGetShoppingMall();
this.handleAes()
// this.handleAes()
this.$utils.addUserBehaviorNew();
},
async onShow() {
@ -635,23 +635,20 @@ export default {
//
async handleAes() {
const req = {
ProvinceCode: '340000',
ServerpartId: "416",
DataType: 1,
StartMonth: "202401",
EndMonth: "202412",
waybillNo: "434491081179331",
mobile: "15558136957",
type: 'encryption'
}
let str = JSON.stringify(req)
console.log('strstrstrstrstr', str)
let jiami = encryptAES(str)
console.log('jiamijiamijiamijiami', jiami)
// let jiami = encryptAES(str)
// console.log('jiamijiamijiamijiami', jiami)
let jiemi = decryptAES(jiami)
console.log('jiemijiemijiemijiemijiemi', jiemi)
// let jiemi = decryptAES(jiami)
// console.log('jiemijiemijiemijiemijiemi', jiemi)
const data = await this.$api.$zzyLocalPost(
"/CommercialApi/Analysis/GetBusinessRevenueList",
"/WeChat/ExpressQuery",
req
);
@ -662,7 +659,7 @@ export default {
console.log('1231');
return new Promise((resolve, reject) => {
uni.getFuzzyLocation({
uni.getLocation({
type: "gcj02",
altitude: true,
success: async (res) => {
@ -691,8 +688,12 @@ export default {
console.log('handleReloadFunIndex');
this.triggered = true
let _this = this
// const seatInfo = await this.handleGetNewPosition()
// handleGetNearService(this, seatInfo.longitude, seatInfo.latitude)
const seatInfo = await this.handleGetNewPosition()
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) => {
@ -2236,7 +2237,7 @@ export default {
background: #fff;
border-radius: 32rpx;
// 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-size: 100% 100%;
box-sizing: border-box;

View File

@ -19,11 +19,50 @@
<view class="contentItem">
<view class="itemLeft">昵称</view>
<view class="itemRight">
<view class="phoneBox">
<!-- <view class="phoneBox">
{{ userInfo.MEMBERSHIP_NAME }}
</view> -->
<input class="phoneBox" v-model="editableNickname" placeholder="请输入昵称" />
</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 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="itemLeft">手机号码</view>
@ -79,7 +118,7 @@
</view>
<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>
</view>
@ -91,6 +130,16 @@ export default {
data() {
return {
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: {
@ -110,8 +159,117 @@ export default {
onLoad() {
//
this.handleGetUserDetail();
//
this.handleGetUserNewInfo();
},
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; // 01
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() {
uni.navigateTo({
@ -193,7 +351,6 @@ export default {
this.$forceUpdate();
console.log("this.userInfo", this.userInfo);
},
//
async onChooseAvatar(e) {
let _this = this;
@ -231,7 +388,7 @@ export default {
<style lang="less" scoped>
.main {
width: 100vw;
height: 100vh;
min-height: 100vh;
box-sizing: border-box;
background-color: #F5F5F5;
display: flex;
@ -315,6 +472,7 @@ export default {
width: 100%;
box-sizing: border-box;
padding: 0 32rpx;
margin-top: 32rpx;
.saveBtn {
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

View File

@ -12873,7 +12873,7 @@ var staticImagePath = 'https://eshangtech.com/ShopICO';
// let nodeUrl = 'https://es.robot-z.cn'
var nodeUrl = 'https://es.eshangtech.com';
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`
var type = uni.getSystemInfoSync();
@ -12902,19 +12902,14 @@ var api = {
data.ownerUnitId = '911';
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 || '';
if (data.type === 'encryption') {}
var requstOptions = {
url: isWebApi ? _this.url + control : _this.url,
data: data.type === 'encryption' ? {
postData: {
name: "",
value: (0, _handleAes.encryptAES)(JSON.stringify(data))
}
postData: (0, _handleAes.encryptAES)(JSON.stringify(data))
} : data,
method: method
};
if (data.type === 'encryption') {
console.log('requstOptionsrequstOptionsrequstOptionsrequstOptions', requstOptions);
}
if (method === 'POST') {
if (data.requestType === 'application/x-www-form-urlencoded') {
requstOptions.header = {
@ -12931,6 +12926,7 @@ var api = {
requstOptions.success = function (res) {
// success
if (res.statusCode !== 200 && res.statusCode !== 201) {
uni.hideLoading();
uni.showToast({
title: '网络出错,稍后再试',
icon: 'none'
@ -12952,7 +12948,7 @@ var api = {
}
}
}
console.log('res.datares.datares.datares.data', res.data);
uni.hideLoading();
resolve(res.data);
};
requstOptions.fail = function (error) {
@ -13127,9 +13123,9 @@ function bytesToBase64(bytes) {
var str = '',
i = 0;
while (i < bytes.length) {
var c1 = bytes[i++] || 0,
c2 = bytes[i++] || 0,
c3 = bytes[i++] || 0;
var c1 = bytes[i++],
c2 = bytes[i++],
c3 = bytes[i++];
var e1 = c1 >> 2,
e2 = (c1 & 3) << 4 | c2 >> 4,
e3 = (c2 & 15) << 2 | c3 >> 6,
@ -13158,14 +13154,22 @@ function base64ToBytes(str) {
return output;
}
function pkcs7Pad(data) {
var blockSize = 16;
var blockSize = 16; // AES块大小为16字节
var pad = blockSize - data.length % blockSize;
return data.concat(Array(pad).fill(pad));
}
function pkcs7Unpad(data) {
var blockSize = 16; // 确保这里也定义blockSize
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;
}
function xorBlock(a, b) {
var out = [];
for (var i = 0; i < a.length; i++) {
@ -13182,18 +13186,19 @@ function aesBlockDecrypt(block, key) {
return xorBlock(block, key);
}
function aesCbcEncrypt(plainBytes, keyBytes, ivBytes) {
var padded = pkcs7Pad(plainBytes); // 应用PKCS#7填充
var blocks = [],
prev = ivBytes;
for (var i = 0; i < plainBytes.length; i += 16) {
var block = plainBytes.slice(i, i + 16);
if (block.length < 16) block = block.concat(Array(16 - block.length).fill(0));
for (var i = 0; i < padded.length; i += 16) {
var block = padded.slice(i, i + 16);
var xored = xorBlock(block, prev);
var encrypted = aesBlockEncrypt(xored, keyBytes);
blocks = blocks.concat(encrypted);
prev = encrypted;
}
return blocks;
return blocks; // 返回完整的加密块
}
function aesCbcDecrypt(cipherBytes, keyBytes, ivBytes) {
var blocks = [],
prev = ivBytes;
@ -13204,8 +13209,9 @@ function aesCbcDecrypt(cipherBytes, keyBytes, ivBytes) {
blocks = blocks.concat(xored);
prev = block;
}
return blocks;
return pkcs7Unpad(blocks); // 移除PKCS#7填充
}
var CryptoJS = {};
CryptoJS.enc = {
Utf8: {
@ -13231,26 +13237,26 @@ CryptoJS.AES = {
var bytes = typeof data === 'string' ? toBytes(data) : data;
var k = typeof key === 'string' ? toBytes(key) : Array.from(key);
var iv = typeof options.iv === 'string' ? toBytes(options.iv) : Array.from(options.iv);
var padded = pkcs7Pad(bytes);
var encrypted = aesCbcEncrypt(padded, k, iv);
var encryptedBlocks = aesCbcEncrypt(bytes, k, iv);
return {
toString: function toString() {
return bytesToBase64(encrypted);
return CryptoJS.enc.Base64.stringify(encryptedBlocks); // 使用标准方法转换为Base64
}
};
},
decrypt: function decrypt(ciphertext, key, options) {
var cipherBytes = typeof ciphertext === 'string' ? base64ToBytes(ciphertext) : ciphertext;
var k = typeof key === 'string' ? toBytes(key) : Array.from(key);
var iv = typeof options.iv === 'string' ? toBytes(options.iv) : Array.from(options.iv);
var decrypted = aesCbcDecrypt(cipherBytes, k, iv);
var unpadded = pkcs7Unpad(decrypted);
return {
toString: function toString(enc) {
if (enc && enc === CryptoJS.enc.Utf8) {
return fromBytes(unpadded);
return CryptoJS.enc.Utf8.stringify(decrypted); // 转换回原始字符串
}
return unpadded;
return decrypted;
}
};
}

View File

@ -367,7 +367,7 @@ var _default = {
console.log("stronge", stronge);
// 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");
_this = _this2;
setTimeout(function () {
@ -421,9 +421,10 @@ var _default = {
_this2.handleGetProductsList();
// 商城的内容
_this2.handleGetShoppingMall();
_this2.handleAes();
// this.handleAes()
_this2.$utils.addUserBehaviorNew();
case 20:
case 19:
case "end":
return _context.stop();
}
@ -543,31 +544,29 @@ var _default = {
handleAes: function handleAes() {
var _this5 = this;
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) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
req = {
ProvinceCode: '340000',
ServerpartId: "416",
DataType: 1,
StartMonth: "202401",
EndMonth: "202412",
waybillNo: "434491081179331",
mobile: "15558136957",
type: 'encryption'
};
str = JSON.stringify(req);
console.log('strstrstrstrstr', str);
jiami = (0, _handleAes.encryptAES)(str);
console.log('jiamijiamijiamijiami', jiami);
jiemi = (0, _handleAes.decryptAES)(jiami);
console.log('jiemijiemijiemijiemijiemi', jiemi);
_context4.next = 9;
return _this5.$api.$zzyLocalPost("/CommercialApi/Analysis/GetBusinessRevenueList", req);
case 9:
// let jiami = encryptAES(str)
// console.log('jiamijiamijiamijiami', jiami)
// let jiemi = decryptAES(jiami)
// console.log('jiemijiemijiemijiemijiemi', jiemi)
_context4.next = 5;
return _this5.$api.$zzyLocalPost("/WeChat/ExpressQuery", req);
case 5:
data = _context4.sent;
console.log('dhsiadhashda', data);
case 11:
case 7:
case "end":
return _context4.stop();
}
@ -579,7 +578,7 @@ var _default = {
handleGetNewPosition: function handleGetNewPosition() {
console.log('1231');
return new Promise(function (resolve, reject) {
uni.getFuzzyLocation({
uni.getLocation({
type: "gcj02",
altitude: true,
success: function () {
@ -618,15 +617,24 @@ var _default = {
handleReloadFunIndex: function handleReloadFunIndex() {
var _this6 = this;
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
var _this;
var _this, seatInfo;
return _regenerator.default.wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
console.log('handleReloadFunIndex');
_this6.triggered = true;
_this = _this6; // const seatInfo = await this.handleGetNewPosition()
// handleGetNearService(this, seatInfo.longitude, seatInfo.latitude)
_this = _this6;
_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) {
setTimeout(function () {
_this.funList = [{
@ -731,7 +739,7 @@ var _default = {
resolve(true);
}, 300);
}));
case 4:
case 12:
case "end":
return _context6.stop();
}

File diff suppressed because one or more lines are too long

View File

@ -618,7 +618,7 @@
height: calc(2688 * 70vw / 1242);
background: #fff;
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-size: 100% 100%;
box-sizing: border-box;

View File

@ -16,7 +16,7 @@ let nodeUrl = 'https://es.eshangtech.com'
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 type = uni.getSystemInfoSync();
@ -47,19 +47,18 @@ const api = {
data.ownerUnitId = '911'
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 || ''
if (data.type === 'encryption') {
}
let requstOptions = {
url: isWebApi ? this.url + control : this.url,
data: data.type === 'encryption' ? {
postData: {
name: "",
value: encryptAES(JSON.stringify(data))
}
postData: encryptAES(JSON.stringify(data))
} : data,
method: method
}
if (data.type === 'encryption') {
console.log('requstOptionsrequstOptionsrequstOptionsrequstOptions', requstOptions);
}
if (method === 'POST') {
@ -77,6 +76,7 @@ const api = {
requstOptions.success = function (res) {
// success
if (res.statusCode !== 200 && res.statusCode !== 201) {
uni.hideLoading()
uni.showToast({
title: '网络出错,稍后再试',
icon: 'none'
@ -99,10 +99,7 @@ const api = {
}
}
console.log('res.datares.datares.datares.data', res.data);
uni.hideLoading()
resolve(res.data)
}
requstOptions.fail = function (error) {

View File

@ -34,7 +34,7 @@ const b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
function bytesToBase64(bytes) {
let str = '', i = 0;
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;
if (isNaN(c2)) e3 = e4 = 64;
else if (isNaN(c3)) e4 = 64;
@ -42,6 +42,7 @@ function bytesToBase64(bytes) {
}
return str;
}
function base64ToBytes(str) {
let output = [], i = 0;
str = str.replace(/[^A-Za-z0-9\+\/\=]/g, '');
@ -55,14 +56,22 @@ function base64ToBytes(str) {
return output;
}
function pkcs7Pad(data) {
const blockSize = 16;
const blockSize = 16; // AES块大小为16字节
const pad = blockSize - (data.length % blockSize);
return data.concat(Array(pad).fill(pad));
}
function pkcs7Unpad(data) {
const blockSize = 16; // 确保这里也定义blockSize
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;
}
function xorBlock(a, b) {
const out = [];
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);
}
function aesCbcEncrypt(plainBytes, keyBytes, ivBytes) {
let padded = pkcs7Pad(plainBytes); // 应用PKCS#7填充
let blocks = [], prev = ivBytes;
for (let i = 0; i < plainBytes.length; i += 16) {
let block = plainBytes.slice(i, i + 16);
if (block.length < 16) block = block.concat(Array(16 - block.length).fill(0));
for (let i = 0; i < padded.length; i += 16) {
let block = padded.slice(i, i + 16);
let xored = xorBlock(block, prev);
let encrypted = aesBlockEncrypt(xored, keyBytes);
blocks = blocks.concat(encrypted);
prev = encrypted;
}
return blocks;
return blocks; // 返回完整的加密块
}
function aesCbcDecrypt(cipherBytes, keyBytes, ivBytes) {
let blocks = [], prev = ivBytes;
for (let i = 0; i < cipherBytes.length; i += 16) {
@ -97,7 +107,7 @@ function aesCbcDecrypt(cipherBytes, keyBytes, ivBytes) {
blocks = blocks.concat(xored);
prev = block;
}
return blocks;
return pkcs7Unpad(blocks); // 移除PKCS#7填充
}
const CryptoJS = {};
CryptoJS.enc = {
@ -122,11 +132,10 @@ CryptoJS.AES = {
let bytes = typeof data === 'string' ? toBytes(data) : data;
let k = typeof key === 'string' ? toBytes(key) : Array.from(key);
let iv = typeof options.iv === 'string' ? toBytes(options.iv) : Array.from(options.iv);
let padded = pkcs7Pad(bytes);
let encrypted = aesCbcEncrypt(padded, k, iv);
let encryptedBlocks = aesCbcEncrypt(bytes, k, iv);
return {
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 iv = typeof options.iv === 'string' ? toBytes(options.iv) : Array.from(options.iv);
let decrypted = aesCbcDecrypt(cipherBytes, k, iv);
let unpadded = pkcs7Unpad(decrypted);
return {
toString: function (enc) {
if (enc && enc === CryptoJS.enc.Utf8) {
return fromBytes(unpadded);
return CryptoJS.enc.Utf8.stringify(decrypted); // 转换回原始字符串
}
return unpadded;
return decrypted;
}
};
}
};
export default CryptoJS;