不甘寂寞 před 2 roky
rodič
revize
a3853e64b2

+ 10
- 12
after-sale/card-Renewal/renewal-confirm.vue Zobrazit soubor

@@ -83,7 +83,7 @@
</view>
</template>

<script lang="ts" setup>
<script setup>
import {
reactive
} from "vue";
@@ -162,7 +162,7 @@
uni.$off('bluetoothLink')
})
//获取订单详情
const queryOrderDetail = (id: string) => {
const queryOrderDetail = (id) => {
const options = {
type: 2,
data: {
@@ -208,12 +208,11 @@
console.log(result.cosRecordId);
if (cmdArray.length > 0) {
tools.showLoadingAlert("正在执行指令");
bluetoothUtil.transCmd(cmdArray, "10", function(res: any) {
bluetoothUtil.transCmd(cmdArray, "10", function(res) {
tools.hideLoadingAlert();
let status = res[cmdArray.length - 1].substring(res[cmdArray.length - 1].length -
4, res[cmdArray.length - 1].length);
if (status == "9000") {
bluetoothUtil.disconnectDevice(); //断开蓝牙
if (status == "9000") {
getCommandBack(result.command, result.cosRecordId, res.toString());
}
})
@@ -224,7 +223,7 @@
/**
* 写卡指令返回 请求
*/
const getCommandBack = (command: any, cosRecordId: string, response: string) => {
const getCommandBack = (command, cosRecordId, response) => {
console.log('======循环写卡指令中======')
tools.showLoadingAlert("加载中");
let options = {
@@ -235,18 +234,17 @@
command: command,
response: response,
cosRecordId: cosRecordId,
cosType: "2"
cosType: 2
}, //请求参数
method: "POST", //提交方式(默认POST)
showLoading: true, //是否显示加载中(默认显示)
};
//调用方式
request(writeCardBack, options)
.then((res) => {
tools.hideLoadingAlert();
let result = JSON.parse(res.bizContent);
console.log("*********************",result);
if (result.orderStatus == 1 || result.orderStatus == "1") {
tools.showLoadingAlert("执行指令中");
bluetoothUtil.transCmd(result.command.split(","), "10", function(res) {
@@ -255,13 +253,13 @@
getCommandBack(result.command, cosRecordId, response);
});
} else {
getCardModifyConfirm(result.cosRecordId); //卡信息变更确认
getCardModifyConfirm(cosRecordId);
}
})
};

//卡信息变更确认
const getCardModifyConfirm = (cosRecordId: string) => {
const getCardModifyConfirm = (cosRecordId) => {
const options = {
type: 2,
data: {
@@ -272,7 +270,7 @@
method: "POST",
showLoading: true,
};
request(cardModifyConfirm, options).then((res: any) => {
request(cardModifyConfirm, options).then((res) => {
console.log(res);
state.showPopup = true;
})

+ 48
- 12
after-sale/equipment-upgrade/upgrade-confirm.vue Zobrazit soubor

@@ -77,7 +77,7 @@
</view>
</template>

<script lang="ts" setup>
<script setup>
import {
reactive
} from "vue";
@@ -156,7 +156,7 @@
uni.$off('bluetoothLink')
})
//获取订单详情
const queryOrderDetail = (id: string) => {
const queryOrderDetail = (id) => {
const options = {
type: 2,
data: {
@@ -205,25 +205,61 @@

let cmdArray = result.command.split(",");
console.log(cmdArray);
console.log(cmdArray.length - 1);
console.log(result.cosRecordId);
if (cmdArray.length > 0) {
tools.showLoadingAlert("正在执行指令");
bluetoothUtil.transCmd(cmdArray, "10", function(res: any) {
bluetoothUtil.transCmd(cmdArray, "10", function(res) {
tools.hideLoadingAlert();
let status = res[cmdArray.length - 1].substring(res[cmdArray.length - 1].length -
4, res[cmdArray.length - 1].length);
if (status == "9000") {
//断开蓝牙
bluetoothUtil.disconnectDevice();
getCardModifyConfirm(result.cosRecordId)
if (status == "9000") {
getCommandBack(result.command, result.cosRecordId, res.toString());
}
})
}
})
}
};
/**
* 写卡指令返回 请求
*/
const getCommandBack = (command, cosRecordId, response) => {
console.log('======循环写卡指令中======')
tools.showLoadingAlert("加载中");
let options = {
type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
data: {
cardId: orderInfos.cardId,
orderId: orderInfos.orderId,
command: command,
response: response,
cosRecordId: cosRecordId,
cosType: 2
}, //请求参数
method: "POST", //提交方式(默认POST)
showLoading: true, //是否显示加载中(默认显示)
};
//调用方式
request(writeCardBack, options)
.then((res) => {
tools.hideLoadingAlert();
let result = JSON.parse(res.bizContent);
if (result.orderStatus == 1 || result.orderStatus == "1") {
tools.showLoadingAlert("执行指令中");
bluetoothUtil.transCmd(result.command.split(","), "10", function(res) {
tools.hideLoadingAlert();
let response = res.toString();
getCommandBack(result.command, cosRecordId, response);
});
} else {
getCardModifyConfirm(cosRecordId);
}
})
};
//卡信息变更确认
const getCardModifyConfirm = (cosRecordId:string) => {
const getCardModifyConfirm = (cosRecordId) => {
const options = {
type: 2,
data: {
@@ -234,11 +270,11 @@
method: "POST",
showLoading: true,
};
request(cardModifyConfirm, options).then((res: any) => {
request(cardModifyConfirm, options).then((res) => {
console.log(res);
state.showPopup = true;
})
}
};

//去连接蓝牙
const toPage = () => {

+ 1
- 1
manifest.json Zobrazit soubor

@@ -52,7 +52,7 @@
"quickapp" : {},
/* 小程序特有相关 */
"mp-weixin" : {
"appid" : "wx214b4f8de36a0181",
"appid" : "wx008c60533388527a",
"setting" : {
"urlCheck" : false,
"checkSiteMap" : false,

+ 125
- 106
utils/network/encryption.js Zobrazit soubor

@@ -1,148 +1,167 @@
import {
ksort
} from '../util/ksort.js'
import {
md5
} from '../util/md5.js'
import {
sha1
} from '../util/sha1.js'
import { ksort } from "../util/ksort.js";
import { md5 } from "../util/md5.js";
import { sha1 } from "../util/sha1.js";


const _signCode = 'etc123456'; //签名码
const _signCode = "etc123456"; //签名码

function pad2(n) {
return n < 10 ? '0' + n : n
return n < 10 ? "0" + n : n;
}

//获取时间ymdHis
function getDate() {
var date = new Date();
return date.getFullYear().toString() + pad2(date.getMonth() + 1) +
pad2(date.getDate()) + pad2(date.getHours()) +
pad2(date.getMinutes()) + pad2(date.getSeconds());
var date = new Date();
return (
date.getFullYear().toString() +
pad2(date.getMonth() + 1) +
pad2(date.getDate()) +
pad2(date.getHours()) +
pad2(date.getMinutes()) +
pad2(date.getSeconds())
);
}

/**
* 获取随机数
*/
function generateMixed(n) {
var chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
var res = "";
for (var i = 0; i < n; i++) {
var id = Math.ceil(Math.random() * 8);
res += chars[id];
}
return res;
var chars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
var res = "";
for (var i = 0; i < n; i++) {
var id = Math.ceil(Math.random() * 8);
res += chars[id];
}
return res;
}

//签名
function sign(data, signCode) {
data = ksort(data);
var signStr = '';
var requestId = false;
for (let k in data) {
if (k != 'sign') {
if (k == 'requestId') {
requestId = data[k];
}
signStr += k + '=' + data[k] + '&';
}
}
signStr += 'signCode=' + signCode;
// console.log("signStr*************"+signStr);
if (!requestId) {
return false;
}
signStr = md5(signStr);
signStr = signStr.toUpperCase();
// console.log('MD5**************' + signStr);
signStr += requestId;
// console.log('requestId**************' + signStr);
signStr = sha1(signStr);
signStr = signStr.toUpperCase();
// console.log('SHA1**************' + signStr);
return signStr;
data = ksort(data);
var signStr = "";
var requestId = false;
for (let k in data) {
if (k != "sign") {
if (k == "requestId") {
requestId = data[k];
}
signStr += k + "=" + data[k] + "&";
}
}
signStr += "signCode=" + signCode;
// console.log("signStr*************"+signStr);
if (!requestId) {
return false;
}
signStr = md5(signStr);
signStr = signStr.toUpperCase();
// console.log('MD5**************' + signStr);
signStr += requestId;
// console.log('requestId**************' + signStr);
signStr = sha1(signStr);
signStr = signStr.toUpperCase();
// console.log('SHA1**************' + signStr);
return signStr;
}

//arrayToJsonString array 转json字符串
export function arrayToJsonString(array) {
var json = {};
for (var i in array) {
if (array[i] instanceof Array) {
json[i] = {};
for (var o in array[i]) {
if (array[i][o] instanceof Array) {
json[i][o] = {};
for (var q in array[i][o]) {
if (array[i][o][q] instanceof Array) {
json[i][o][q] = {};
for (var w in array[i][o][q]) {
json[i][o][q][w] = array[i][o][q][w];
}
} else {
json[i][o][q] = array[i][o][q];
}
}
} else {
json[i][o] = array[i][o];
}
}
} else {
json[i] = array[i];
}
}
return JSON.stringify(json);
var json = {};
for (var i in array) {
if (array[i] instanceof Array) {
json[i] = {};
for (var o in array[i]) {
if (array[i][o] instanceof Array) {
json[i][o] = {};
for (var q in array[i][o]) {
if (array[i][o][q] instanceof Array) {
json[i][o][q] = {};
for (var w in array[i][o][q]) {
json[i][o][q][w] = array[i][o][q][w];
}
} else {
json[i][o][q] = array[i][o][q];
}
}
} else {
json[i][o] = array[i][o];
}
}
} else {
json[i] = array[i];
}
}
return JSON.stringify(json);
}

/**
*json字符串转换成json对象
*/
export function stringToJson(data) {
return JSON.parse(data);
return JSON.parse(data);
}

//array转json对象
export function arrayToJson(array) {
return stringToJson(arrayToJsonString(array));
return stringToJson(arrayToJsonString(array));
}

//时间格式化
export function formatTime (date) {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
export function formatTime(date) {
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
const hour = date.getHours();
const minute = date.getMinutes();
const second = date.getSeconds();

return `${[year, month, day].map(formatNumber).join('-')}T${[hour, minute, second].map(formatNumber).join(':')}`
return `${[year, month, day].map(formatNumber).join("-")}T${[
hour,
minute,
second,
]
.map(formatNumber)
.join(":")}`;
}

function formatNumber (n) {
n = n.toString()
return n[1] ? n : `0${n}`
function formatNumber(n) {
n = n.toString();
return n[1] ? n : `0${n}`;
}

//调用中台参数
export function encryption(urlcode, subdata, type) {
// console.log('输出内容',stringToJson(JSON.stringify(subdata)))
var requestData = new Array();
requestData['IFCODE'] = urlcode;
requestData['AppId'] = 'admin001';
requestData['encryptType'] = 'NONE';
requestData['signType'] = 'MD5';
requestData['ReqId'] = requestData['AppId']+'_'+getDate()+'_' + generateMixed(5);
requestData['timestamp'] = formatTime(new Date());
//更据type判断是否转字符串
if (type === 2) {
requestData['bizContent'] = JSON.stringify(subdata);
} else {
requestData['bizContent'] = subdata;
}
console.log('bizContent='+requestData['bizContent']+'&signType=MD5&encryptType=NONE&timestamp='+requestData['timestamp']+'&IFCODE='+urlcode);
requestData['sign'] = md5('bizContent='+requestData['bizContent']+'&signType=MD5&encryptType=NONE&timestamp='+requestData['timestamp']+'&IFCODE='+urlcode);
let endData = arrayToJson(requestData);
console.log('输出内容', endData)
return endData;
// console.log('输出内容',stringToJson(JSON.stringify(subdata)))
var requestData = new Array();
requestData["IFCODE"] = urlcode;
requestData["AppId"] = "admin001";
requestData["encryptType"] = "NONE";
requestData["signType"] = "MD5";
requestData["ReqId"] =
requestData["AppId"] + "_" + getDate() + "_" + generateMixed(5);
requestData["timestamp"] = formatTime(new Date());
//更据type判断是否转字符串
if (type === 2) {
requestData["bizContent"] = JSON.stringify(subdata);
} else {
requestData["bizContent"] = subdata;
}
console.log(
"bizContent=" +
requestData["bizContent"] +
"&signType=MD5&encryptType=NONE&timestamp=" +
requestData["timestamp"] +
"&IFCODE=" +
urlcode
);
requestData["sign"] = md5(
"bizContent=" +
requestData["bizContent"] +
"&signType=MD5&encryptType=NONE&timestamp=" +
requestData["timestamp"] +
"&IFCODE=" +
urlcode
);
let endData = arrayToJson(requestData);
console.log("输出内容", endData);
return endData;
}

+ 4
- 4
utils/util/fileData.js Zobrazit soubor

@@ -1,7 +1,7 @@
// import {
// TextEncoder,
// TextDecoder
// } from "text-decoding";
import {
TextEncoder,
TextDecoder
} from "text-decoding";


export function IntegerToHexString(num, nLen) {

Načítá se…
Zrušit
Uložit