刷卡功能对接中

This commit is contained in:
李彪 2025-04-28 15:31:01 +08:00
parent 98d1fdc287
commit ad2d48c4ca
5 changed files with 94 additions and 15 deletions

View File

@ -13,4 +13,8 @@ export const GetAreaListApi = (data) =>
// 用户数据 // 用户数据
export const GetUserDataApi = (data) => export const GetUserDataApi = (data) =>
request.get("/api/AdminApp/GetUserData", data); request.get("/api/AdminApp/GetUserData", data);
// Nfc重置
export const ResetNFCApi = (data) =>
request.post("/api/Region/ResetNFC", data);

View File

@ -29,7 +29,7 @@
<image class="card-img" style="width: 130rpx; height: 130rpx" src="/static/adminImg/card4.png"></image> <image class="card-img" style="width: 130rpx; height: 130rpx" src="/static/adminImg/card4.png"></image>
</view> </view>
</view> </view>
<view v-if="true" style="display: flex"> <view v-if="false" style="display: flex">
<u-button type="error" @click="testFn">调试录入卡片</u-button> <u-button type="error" @click="testFn">调试录入卡片</u-button>
</view> </view>
</view> </view>

View File

@ -9,7 +9,7 @@
<!-- 头部标题和标签 --> <!-- 头部标题和标签 -->
<view class="dialog-header"> <view class="dialog-header">
<text class="title">{{ currentRow.name }}</text> <text class="title">{{ currentRow.name }}</text>
<u-tag class="tag" text="室内" mode="light" /> <!-- <u-tag class="tag" text="室内" mode="light" /> -->
<!-- <u-tag <!-- <u-tag
class="tag" class="tag"
:text="areaType" :text="areaType"
@ -25,8 +25,9 @@
</view> </view>
<!-- 副标题 - 负责人 --> <!-- 副标题 - 负责人 -->
<view class="dialog-subtitle"> 区域主负责人{{ "张三" }} </view> <!-- <view class="dialog-subtitle"> 区域主负责人张三 </view> -->
<view>传入参数{{ showMsg }}</view>
<view>接口返回结果{{ resData }}</view>
<!-- 已存在卡片时显示图片 --> <!-- 已存在卡片时显示图片 -->
<view class="dialog-image-container" v-if="isChange === true"> <view class="dialog-image-container" v-if="isChange === true">
<!-- 替换为实际的图片路径 --> <!-- 替换为实际的图片路径 -->
@ -48,7 +49,8 @@
<view v-if="step === 1">1.请将标签卡贴靠设备NFC识别处</view> <view v-if="step === 1">1.请将标签卡贴靠设备NFC识别处</view>
<view v-if="step === 2">2.如果确定将该卡片写入该区域,请将标签卡贴靠设备xNFC识别处否则请退出</view> <view v-if="step === 2">2.如果确定将该卡片写入该区域,请将标签卡贴靠设备xNFC识别处否则请退出</view>
<view v-if="step === 3">3.请再次将标签卡贴靠设备NFC识别处</view> <view v-if="step === 3">3.请再次将标签卡贴靠设备NFC识别处</view>
<view v-if="step === 4">{{ lookData }}</view> <!-- <view v-if="step === 3">{{ lookData }}</view> -->
<!-- <view v-if="step === 4">{{ lookData }}</view> -->
</view> </view>
<!-- 底部按钮 --> <!-- 底部按钮 -->
@ -60,7 +62,7 @@
</template> </template>
<script> <script>
import { loginApi } from '@/api/apiList' import { ResetNFCApi } from '@/api/apiAdmin'
export default { export default {
props: { props: {
// / // /
@ -80,20 +82,35 @@ export default {
return { return {
isChange: false, isChange: false,
step: 0, step: 0,
lookData: {} lookData: {},
resData: {},
showMsg: ''
} }
}, },
mounted() { mounted() {
window.nfcInitFn = this.nfcInitFn // window.nfcInitFn = this.nfcInitFn
}, },
onLoad() { }, onLoad() { },
methods: { methods: {
nfcInitFn(data) { async nfcInitFn(data) {
if (!data) { if (!data) {
return uni.showToast({ title: '未传入参数 initFn', icon: 'none' }) uni.showToast({ title: '未传入参数nfcInitFn', icon: 'none' })
return
}
this.showMsg = data
// uni.showModal({
// title: "",
// content: JSON.stringify(data) || '',
// success: function (res) {
// },
// });
if (data.step === 8) {
uni.showToast({ title: '刷卡失败', icon: 'none' })
return
} }
if (this.isChange === true) { if (this.isChange === true) {
return uni.showToast({ title: '请点击更换绑定后刷卡', icon: 'none' }) uni.showToast({ title: '请点击更换绑定后刷卡', icon: 'none' })
return
} }
if (data.step === 1) { if (data.step === 1) {
this.step = 1 this.step = 1
@ -103,6 +120,53 @@ export default {
} }
if (data.step === 3) { if (data.step === 3) {
this.step = 3 this.step = 3
this.lookData = data
const req = {
"AreaId": data.areaId,
"pwd": data.pwd,
"isAdd": !this.currentRow.state,
// "isAdd": true,
}
console.log(req, '重置nfc--req')
console.log(666);
// uni.showLoading({ title: '...' })
const res = await ResetNFCApi(req).catch(e => e)
if (!res.succeed) {
uni.showToast({ title: res.error || '绑定失败', icon: 'none' })
}
this.resData = res;
try {
if (isAndroid && AndroidJs) {
console.log("%c%s", "color:red", "安卓--调用方法");
const reqRow = {
name: "resetNFCRes",
data: res,
};
console.log(reqRow, 'reqRow--')
AndroidJs.func(JSON.stringify(reqRow)); //
} else {
console.log("%c%s", "color:red", "苹果--调用方法");
const reqRow = {
name: "back-iphone",
data: "",
};
window.webkit.messageHandlers.func.postMessage(JSON.stringify(reqRow)); // ios
}
} catch (e) {
console.log(e, "e-----判断安卓苹果类型出错");
}
return
// uni.hideLoading()
console.log(res, '重置nfc')
this.resData = res;
if (res.succeed) {
uni.showToast({ title: '绑定成功', icon: 'none' })
} else {
uni.showToast({ title: res.error || '绑定失败', icon: 'none' })
}
return
} }
if (data.step === 4) { if (data.step === 4) {
this.lookData = data this.lookData = data
@ -124,17 +188,21 @@ export default {
nfcChange() { nfcChange() {
this.isChange = false this.isChange = false
this.step = 1 this.step = 1
console.log(this.currentRow, 'this.currentRow--')
//
let u = navigator.userAgent;
let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android
try { try {
if (isAndroid && AndroidJs) { if (isAndroid && AndroidJs) {
console.log("%c%s", "color:red", "安卓--调用方法"); console.log("%c%s", "color:red", "安卓--调用方法");
const reqRow = { const reqRow = {
name: "area", name: "area",
data: { data: {
state: this.currentRow.state, // state: this.currentRow.state,
state: true,
areaId: this.currentRow.id, areaId: this.currentRow.id,
}, },
}; };
console.log(reqRow, 'reqRow--')
AndroidJs.func(JSON.stringify(reqRow)); // AndroidJs.func(JSON.stringify(reqRow)); //
} else { } else {
console.log("%c%s", "color:red", "苹果--调用方法"); console.log("%c%s", "color:red", "苹果--调用方法");

View File

@ -117,6 +117,7 @@ export default {
// //
let u = navigator.userAgent; let u = navigator.userAgent;
let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android
console.log(row.state, 'row.state--')
// //
if (row.state === false) { if (row.state === false) {
try { try {
@ -125,7 +126,8 @@ export default {
const reqRow = { const reqRow = {
name: "area", name: "area",
data: { data: {
state: row.state, // state: row.state,
state: true,
areaId: row.id, areaId: row.id,
}, },
}; };
@ -147,6 +149,8 @@ export default {
console.log(JSON.parse(JSON.stringify(row)), 'row--') console.log(JSON.parse(JSON.stringify(row)), 'row--')
this.currentRow = row this.currentRow = row
this.$refs.dialogRef.isChange = row.state // this.$refs.dialogRef.isChange = row.state //
this.$refs.dialogRef.resData = ''
this.$refs.dialogRef.showMsg = ''
this.$refs.dialogRef.step = 0 // this.$refs.dialogRef.step = 0 //
if (row.state === false) { if (row.state === false) {
this.$refs.dialogRef.step = 1 // this.$refs.dialogRef.step = 1 //

View File

@ -18,6 +18,7 @@
</template> </template>
<script> <script>
import bcrypt from "bcryptjs"; import bcrypt from "bcryptjs";
import { jwtDecode } from "jwt-decode";
import { loginApi } from "@/api/apiList"; import { loginApi } from "@/api/apiList";
export default { export default {
data() { data() {
@ -74,6 +75,8 @@ export default {
} }
let token = res.data; let token = res.data;
uni.setStorageSync("token", "Bearer " + token); uni.setStorageSync("token", "Bearer " + token);
console.log(jwtDecode(token), "解析的token信息");
// return
console.log(type, "type--"); console.log(type, "type--");
if (type === "user") { if (type === "user") {
const normalTabBar = [ const normalTabBar = [