tested linkage add step
This commit is contained in:
parent
636cd67923
commit
b4efa1204f
2 changed files with 100 additions and 13 deletions
|
|
@ -23,14 +23,21 @@ async function fetchDeviceLists() {
|
|||
async function readDevice() {
|
||||
showLoader();
|
||||
await store.readDevice($q);
|
||||
await store.getInfo($q); // ดึงข้อมูล CID
|
||||
await store.postReadIdCard($q); // ดึงข้อมูล id card จากเครื่องอ่านบัตร
|
||||
await store.amiEnvironment($q);
|
||||
await store.amiConnect($q);
|
||||
// await store.getInfo($q); // ดึงข้อมูล CID
|
||||
// await store.postReadIdCard($q); // ดึงข้อมูล id card จากเครื่องอ่านบัตร
|
||||
// await store.amiEnvironment($q);
|
||||
// await store.amiConnect($q);
|
||||
hideLoader();
|
||||
}
|
||||
|
||||
// 3. ขอข้อมูล x-Key (9080)
|
||||
async function amiRequest() {
|
||||
showLoader();
|
||||
await store.amiRequest($q, 9080);
|
||||
hideLoader();
|
||||
}
|
||||
|
||||
// 4. เชื่อมต่อและใส่ PIN
|
||||
async function verifyPin() {
|
||||
showLoader();
|
||||
await store.authentication($q);
|
||||
|
|
@ -157,9 +164,9 @@ function onClose() {
|
|||
</div>
|
||||
</q-timeline-entry>
|
||||
|
||||
<!-- เชื่อมต่อและใส่ PIN -->
|
||||
<!-- ขอข้อมูล 9080 -->
|
||||
<q-timeline-entry
|
||||
title="เชื่อมต่อและใส่ PIN"
|
||||
title="ตรวจสอบข้อมูล"
|
||||
:icon="
|
||||
store.step === 3
|
||||
? 'mdi-pencil'
|
||||
|
|
@ -170,6 +177,29 @@ function onClose() {
|
|||
:color="store.step < 3 ? 'grey-4' : ''"
|
||||
>
|
||||
<div class="row" v-if="store.step === 3">
|
||||
<div class="q-col-gutter-sm">
|
||||
<q-btn
|
||||
color="primary"
|
||||
label="ดำเนินการต่อ"
|
||||
@click="amiRequest"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</q-timeline-entry>
|
||||
|
||||
<!-- เชื่อมต่อและใส่ PIN -->
|
||||
<q-timeline-entry
|
||||
title="เชื่อมต่อและใส่ PIN"
|
||||
:icon="
|
||||
store.step === 4
|
||||
? 'mdi-pencil'
|
||||
: store.step > 4
|
||||
? 'done'
|
||||
: 'mdi-numeric-4'
|
||||
"
|
||||
:color="store.step < 4 ? 'grey-4' : ''"
|
||||
>
|
||||
<div class="row" v-if="store.step === 4">
|
||||
<q-btn
|
||||
color="primary"
|
||||
label="ดำเนินการต่อ"
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ export const useLinkageStore = defineStore("linkageData", () => {
|
|||
* @param {any} q ค่า this ของ quasar
|
||||
*/
|
||||
async function fetchDeviceLists(q: any) {
|
||||
console.log("[0] START fetchDeviceLists");
|
||||
|
||||
await fetch(`${apiURL.value}/smart-card/device`, {
|
||||
method: "GET",
|
||||
})
|
||||
|
|
@ -29,6 +31,8 @@ export const useLinkageStore = defineStore("linkageData", () => {
|
|||
throw new Error("Something went wrong");
|
||||
})
|
||||
.then(async (data) => {
|
||||
console.log("fetchDeviceLists===>", data);
|
||||
|
||||
devicesOp.value = await data.devices;
|
||||
devicesData.value = await data.devices;
|
||||
step.value = 2;
|
||||
|
|
@ -42,6 +46,8 @@ export const useLinkageStore = defineStore("linkageData", () => {
|
|||
* @param {any} q ค่า this ของ quasar
|
||||
*/
|
||||
async function readDevice(q: any) {
|
||||
console.log("[1] อ่านบัตร");
|
||||
|
||||
await fetch(
|
||||
`${apiURL.value}/smart-card/connect/?deviceName=${devices.value}`,
|
||||
{
|
||||
|
|
@ -54,8 +60,9 @@ export const useLinkageStore = defineStore("linkageData", () => {
|
|||
}
|
||||
throw new Error("Something went wrong");
|
||||
})
|
||||
.then(async (data) => {
|
||||
return;
|
||||
.then((data) => {
|
||||
console.log("readDevice===>", data);
|
||||
getInfo(q);
|
||||
})
|
||||
.catch((error) => {
|
||||
messageError(q, error);
|
||||
|
|
@ -66,6 +73,8 @@ export const useLinkageStore = defineStore("linkageData", () => {
|
|||
* @param {any} q ค่า this ของ quasar
|
||||
*/
|
||||
async function getInfo(q: any) {
|
||||
console.log("START getInfo");
|
||||
|
||||
await fetch(`${apiURL.value}/smart-card/info`, {
|
||||
method: "GET",
|
||||
})
|
||||
|
|
@ -76,8 +85,12 @@ export const useLinkageStore = defineStore("linkageData", () => {
|
|||
throw new Error("Something went wrong");
|
||||
})
|
||||
.then(async (data) => {
|
||||
console.log("getInfo===>", data);
|
||||
CID.value = await data.cid;
|
||||
return;
|
||||
|
||||
console.log("cid===>", CID.value);
|
||||
|
||||
postReadIdCard(q);
|
||||
})
|
||||
.catch((error) => {
|
||||
messageError(q, error);
|
||||
|
|
@ -89,6 +102,8 @@ export const useLinkageStore = defineStore("linkageData", () => {
|
|||
* @param {any} q ค่า this ของ quasar
|
||||
*/
|
||||
async function postReadIdCard(q: any) {
|
||||
console.log("START postReadIdCard");
|
||||
|
||||
await fetch(`${apiURL.value}/smart-card/read/`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
|
|
@ -105,8 +120,11 @@ export const useLinkageStore = defineStore("linkageData", () => {
|
|||
throw new Error("Something went wrong");
|
||||
})
|
||||
.then(async (data) => {
|
||||
console.log("postReadIdCard===>", data);
|
||||
PID.value = await data.personalID;
|
||||
return;
|
||||
console.log("personalID===>", PID.value);
|
||||
await amiEnvironment(q);
|
||||
await amiConnect(q);
|
||||
})
|
||||
.catch((error) => {
|
||||
messageError(q, error);
|
||||
|
|
@ -170,6 +188,7 @@ export const useLinkageStore = defineStore("linkageData", () => {
|
|||
* @param q ค่า this ของ quasar
|
||||
*/
|
||||
async function authentication(q: any) {
|
||||
console.log("[4] START authentication");
|
||||
await fetch(`${apiURL.value}/smart-card/authentication`, {
|
||||
method: "GET",
|
||||
})
|
||||
|
|
@ -193,6 +212,8 @@ export const useLinkageStore = defineStore("linkageData", () => {
|
|||
* @param q ค่า this ของ quasar
|
||||
*/
|
||||
async function verifyPin(q: any) {
|
||||
console.log("START verifyPin");
|
||||
|
||||
const requestOptions = {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
|
|
@ -213,7 +234,12 @@ export const useLinkageStore = defineStore("linkageData", () => {
|
|||
throw new Error("Something went wrong");
|
||||
})
|
||||
.then(async (data) => {
|
||||
console.log("verifyPin===>", data);
|
||||
|
||||
envelopGMXs.value = await data.crossAuthen.envelope;
|
||||
|
||||
console.log("envelopGMXs===>", envelopGMXs.value);
|
||||
|
||||
await amiRequest(q, 9081);
|
||||
})
|
||||
.catch((error) => {
|
||||
|
|
@ -239,16 +265,41 @@ export const useLinkageStore = defineStore("linkageData", () => {
|
|||
serviceCode?: string
|
||||
) {
|
||||
let message = "";
|
||||
console.log("code===>", code);
|
||||
|
||||
if (code === 9080) {
|
||||
console.log("[3] START amiRequest");
|
||||
|
||||
console.log("PID===>", PID.value);
|
||||
console.log("CID===>", CID.value);
|
||||
console.log("officeid===>", officeid.value);
|
||||
|
||||
message = `${code}${PID.value}${CID.value}${officeid.value}`;
|
||||
|
||||
console.log("message===>", message);
|
||||
} else if (code === 9081) {
|
||||
const x = xKey.value;
|
||||
const y = envelopGMXs.value;
|
||||
const x = await xKey.value;
|
||||
const y = await envelopGMXs.value;
|
||||
console.log("PID===>", PID.value);
|
||||
console.log("CID===>", CID.value);
|
||||
console.log("x===>", x);
|
||||
console.log("y===>", y);
|
||||
|
||||
message = `${code}${PID.value}${CID.value}${x}${y}`;
|
||||
|
||||
console.log("message===>", message);
|
||||
} else if (code === 5000) {
|
||||
const T = tKey.value;
|
||||
const T = await tKey.value;
|
||||
|
||||
console.log("T===>", T);
|
||||
console.log("officeCode===>", officeCode.value);
|
||||
console.log("versionCode===>", versionCode.value);
|
||||
console.log("serviceCode===>", serviceCode);
|
||||
console.log("idcard===>", idcard);
|
||||
|
||||
message = `${code}${T}${officeCode.value}${versionCode.value}${serviceCode}${idcard}`;
|
||||
|
||||
console.log("message===>", message);
|
||||
}
|
||||
|
||||
await fetch(`${apiURL.value}/ami/request`, {
|
||||
|
|
@ -270,9 +321,15 @@ export const useLinkageStore = defineStore("linkageData", () => {
|
|||
|
||||
if (code === 9080) {
|
||||
xKey.value = await removeText;
|
||||
|
||||
console.log("xKey===>", xKey.value);
|
||||
|
||||
step.value = 3;
|
||||
} else if (code === 9081) {
|
||||
tKey.value = removeText;
|
||||
|
||||
console.log("tKey===>", tKey.value);
|
||||
|
||||
step.value = 4;
|
||||
} else if (code === 5000) {
|
||||
return removeText;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue