读取卡片与安卓对接

This commit is contained in:
李彪 2025-04-25 14:55:58 +08:00
parent 3f9d75d597
commit 56db79cc23
4 changed files with 194 additions and 102 deletions

View File

@ -7,6 +7,10 @@ export const GetHomeDataApi = (data) =>
export const GetRegionDataListApi = (data) =>
request.get("/api/AdminApp/GetRegionDataList", data);
// 子区域列表
export const GetAreaListApi = (data) =>
request.get("/api/AdminApp/GetAreaList", data);
// 用户数据
export const GetUserDataApi = (data) =>
request.get("/api/AdminApp/GetUserData", data);

View File

@ -8,7 +8,7 @@
<view class="dialog-content">
<!-- 头部标题和标签 -->
<view class="dialog-header">
<text class="title">A31栋宿舍楼道口</text>
<text class="title">{{currentRow.name}}</text>
<u-tag class="tag" text="室内" mode="light" />
<!-- <u-tag
class="tag"
@ -27,20 +27,28 @@
<!-- 副标题 - 负责人 -->
<view class="dialog-subtitle"> 区域主负责人{{ "张三" }} </view>
<!-- 中间图片 -->
<view class="dialog-image-container">
<!-- 已存在卡片时显示图片 -->
<view class="dialog-image-container" v-if="isChange === true">
<!-- 替换为实际的图片路径 -->
<image
src="/static/adminImg/nfc-result.png"
mode="widthFix"
class="dialog-image"
></image>
<image src="/static/adminImg/nfc-result.png" mode="widthFix" class="dialog-image"></image>
</view>
<!-- 未存在nfc时显示图片 -->
<view class="dialog-image-container" v-if="isChange === false">
<!-- 替换为实际的图片路径 -->
<image src="/static/adminImg/step.png" mode="widthFix" style="width: 500rpx;"></image>
</view>
<!-- 更换绑定链接 -->
<view class="change-binding" @click="handleChangeBinding">
<view v-if="isChange === true" class="change-binding" @click="nfcChange">
更换绑定
</view>
<!-- -->
<view v-if="step === 1">1.请将标签卡贴靠设备NFC识别处</view>
<view v-if="step === 2">2.如果确定将该卡片写入该区域,请将标签卡贴靠设备xNFC识别处否则请退出</view>
<view v-if="step === 3">3.请再次将标签卡贴靠设备NFC识别处</view>
<view v-if="step === 4">{{lookData}}</view>
</view>
<!-- 底部按钮 -->
@ -52,48 +60,84 @@
</template>
<script>
import { loginApi } from "@/api/apiList";
import { loginApi } from '@/api/apiList'
export default {
props: {
// /
visible: {
type: Boolean,
default: false,
default: false
},
// props
// title: String,
// responsiblePerson: String,
currentRow: {
type: Object,
default: () => ({})
}
},
data() {
return {};
return {
isChange: false,
step: 0,
lookData: {}
}
},
mounted() {
window.nfcInitFn = this.nfcInitFn
},
mounted() {},
onLoad() {},
methods: {
nfcInitFn(data) {
if (!data) {
return uni.showToast({ title: '未传入参数 initFn', icon: 'none' })
}
if (data.step === 1) {
this.step = 1
}
if (data.step === 2) {
this.step = 2
}
if (data.step === 3) {
this.step = 3
}
if (data.step === 4) {
this.lookData = data
this.step = 4
// uni.showModal({
// title: '',
// content: JSON.stringify(data) || ' initFn',
// showCancel: true,
// success: function (res) {}
// })
}
},
//
closeDialog() {
//
this.$emit("close");
this.$emit('close')
},
//
handleChangeBinding() {
this.$emit("changeBinding");
nfcChange() {
this.isChange = false
this.step = 1
// this.$emit('changeBinding')
// this.closeDialogInternal(); //
},
//
handleConfirm() {
this.$emit("confirm");
this.closeDialogInternal();
this.$emit('confirm')
this.closeDialogInternal()
},
// emit
closeDialogInternal() {
if (this.visible) {
this.$emit("update:visible", false); // 使 v-model
this.$emit("close"); // 使 :visible @close
this.$emit('update:visible', false) // 使 v-model
this.$emit('close') // 使 :visible @close
}
},
},
};
}
}
}
</script>
<style lang="scss" scoped>
@ -164,14 +208,14 @@ export default {
}
.dialog-image-container {
width: 200rpx; /* 根据图片调整 */
// border: 1px solid red;
height: auto;
margin-bottom: 30rpx;
}
.dialog-image {
width: 100%;
height: auto; /* 让图片自适应高度 */
.dialog-image {
width: 100%;
width: 200rpx; /* 根据图片调整 */
height: auto; /* 让图片自适应高度 */
}
}
.change-binding {

View File

@ -11,9 +11,12 @@
<view class="card-totel">{{ form.noBindnfc }}</view>
</view>
</view>
<!-- tabs -->
<u-tabs class="tabs-box" bg-color="#F6F8FC" :list="tabsList" :is-scroll="true" :current="tabCurrent" @change="tabChangeFn"></u-tabs>
<!-- 搜索 -->
<view class="search-box">
<u-input class="search-input" v-model="keyword" border placeholder="搜索名称"></u-input>
<u-input class="search-input" v-model="keyword" :clearable="false" border placeholder="搜索名称" @keyup.enter="searchFn"></u-input>
<u-icon name="search" class="search-icon" size="40" @click="searchFn"></u-icon>
<view class="select-box" @click="selectFn">
<view>
{{ selectVal }}
@ -21,129 +24,163 @@
<image src="/static/svg/down.svg" style="width: 30rpx; height: 30rpx; margin-left: 10rpx"></image>
</view>
</view>
<!-- tabs -->
<u-tabs class="tabs-box" bg-color="#F6F8FC" :list="tabsList" :is-scroll="true" :current="tabCurrent"
@change="tabChangeFn"></u-tabs>
<!-- tip -->
<view class="tip-box">共10个子区域其中5个未绑定</view>
<view v-if="sonList.length" class="tip-box">{{sonForm.countData}}个子区域其中{{sonForm.countData - sonForm.bindData}}个未绑定</view>
<!-- 列表 -->
<view class="list-box">
<scroll-view :scroll-y="true" class="scroll-Y">
<view v-for="i in 80" class="item-box">
<view class="item-title">子区域{{ i }}</view>
<view v-if="i % 2 === 0" class="btn-have btn">已绑定</view>
<view v-if="i % 2 !== 0" class="btn-none btn" @click="showDialog = true">去绑定</view>
<view v-for="item in sonList" class="item-box">
<view class="item-title">{{ item.name }}</view>
<view v-if="item.state === true" class="btn-have btn" @click="dialogShowFn(item)">已绑定</view>
<view v-if="item.state === false" class="btn-none btn" @click="dialogShowFn(item)">去绑定</view>
</view>
<view v-if="!sonList.length" style="height:100rpx;"></view>
<u-empty v-if="!sonList.length" text="数据为空" mode="list"></u-empty>
</scroll-view>
</view>
<!-- 筛选的下拉 -->
<u-action-sheet :list="options" title="请选择" @click="changeFn" v-model:value="selectShow"></u-action-sheet>
<bind-dialog :visible="showDialog" @close="showDialog = false" @changeBinding="onChangeBinding"
@confirm="onConfirm"></bind-dialog>
<!-- 弹窗 -->
<bind-dialog ref="dialogRef" :visible="showDialog" @close="showDialog = false" :currentRow="currentRow" @changeBinding="onChangeBinding" @confirm="onConfirm"></bind-dialog>
<u-tabbar :list="vuex_tabbar"></u-tabbar>
</view>
</template>
<script>
import { GetRegionDataListApi, GetHomeDataApi } from "@/api/apiAdmin.js";
import BindDialog from "@/pages/adminNfc/components/bindDialog.vue"; //
import { GetRegionDataListApi, GetHomeDataApi, GetAreaListApi } from '@/api/apiAdmin.js'
import BindDialog from '@/pages/adminNfc/components/bindDialog.vue' //
export default {
components: {
BindDialog,
BindDialog
},
data() {
return {
form: {
"regionCount": 0,
"areaCount": 0,
"bindnfc": 0,
"noBindnfc": 0
regionCount: 0,
areaCount: 0,
bindnfc: 0,
noBindnfc: 0
},
keyword: "",
keyword: '',
selectShow: false,
showDialog: false,
selectVal: "全部",
selectVal: '筛选',
options: [
{
text: "全部",
text: '全部',
value: 0
},
{
text: "已绑定",
text: '已绑定',
value: 1
},
{
text: "未绑定",
},
text: '未绑定',
value: 2
}
],
tabCurrent: 0,
tabCurrentId: '',
tabsList: [
{
name: "区域1",
},
{
name: "区域2",
},
{
name: "区域3",
},
{
name: "区域4",
},
{
name: "区域5",
},
{
name: "区域6",
},
{
name: "区域7",
},
{
name: "区域8",
},
// {
// name: '1'
// },
// {
// name: '2'
// },
],
};
//
sonList: [],
sonForm: {
bindData: 0,
countData: 0
},
currentRow: {}
}
},
mounted() {
uni.hideLoading(); // Loading
uni.hideLoading() // Loading
},
onLoad() {
this.getAreaFn();
this.getAreaFn()
},
onShow() {
this.getDataFn();
this.getDataFn()
},
methods: {
async getDataFn() {
const res = await GetHomeDataApi();
console.log(res, "首页数据");
Object.assign(this.form, res.data);
dialogShowFn(row) {
console.log(JSON.parse(JSON.stringify(row)), 'row--')
this.currentRow = row
this.$refs.dialogRef.isChange = row.state //
this.$refs.dialogRef.step = 0 //
this.showDialog = true
},
async getDataFn() {
const res = await GetHomeDataApi()
console.log(res, '首页数据')
Object.assign(this.form, res.data)
},
//
async getAreaFn() {
const res = await GetRegionDataListApi()
console.log(res, "区域数据");
this.tabsList = res.data.areaList
console.log(res, '区域数据')
this.tabsList = res.data
if (this.tabsList.length > 0) {
this.tabCurrentId = this.tabsList[0].id
this.getSonAreaFn()
}
},
//
async getSonAreaFn() {
const req = {
regionId: this.tabCurrentId
}
if (this.keyword) {
req.keyword = this.keyword
}
const findRow = this.options.find(x => x.text === this.selectVal)
if (findRow) {
req.type = findRow.value
}
const res = await GetAreaListApi(req)
console.log(res, '子区域数据')
this.sonList = res.data.data
this.sonForm.bindData = res.data.bindData
this.sonForm.countData = res.data.countData
},
async searchFn() {
this.getSonAreaFn()
},
selectFn() {
this.selectShow = true;
this.selectShow = true
},
changeFn(val) {
console.log(val, "val--");
this.selectVal = this.options[val].text;
console.log(val, 'val--')
this.selectVal = this.options[val].text
this.getSonAreaFn()
},
//
tabChangeFn(val) {
console.log(val, "val--");
this.tabCurrent = val;
//
this.keyword = ''
this.selectVal = '筛选'
console.log(val, 'val--')
console.log(this.tabsList[val], 'tabsList--current')
this.tabCurrent = val
this.tabCurrentId = this.tabsList[val].id
this.getSonAreaFn()
},
onChangeBinding() {
console.log("点击了更换绑定");
console.log('点击了更换绑定')
//
},
onConfirm() {
console.log("点击了知道了");
console.log('点击了知道了')
//
},
},
};
}
}
}
</script>
<style lang="scss" scoped>
.content {
@ -178,24 +215,30 @@ export default {
}
.card-left {
background: url("/static/adminImg/icon-bg1.png") no-repeat right 32rpx bottom 20rpx / 60rpx 60rpx;
background: url('/static/adminImg/icon-bg1.png') no-repeat right 32rpx bottom 20rpx / 60rpx 60rpx;
background-color: #4974f3;
}
.card-right {
margin-left: 20rpx;
background: url("/static/adminImg/icon-bg2.png") no-repeat right 32rpx bottom 20rpx / 60rpx 60rpx;
background: url('/static/adminImg/icon-bg2.png') no-repeat right 32rpx bottom 20rpx / 60rpx 60rpx;
background-color: #53d5a9;
}
}
.search-box {
position: relative;
display: flex;
align-items: center;
// border: 1px solid red;
margin-top: 20rpx;
// margin-top: 20rpx;
padding: 20rpx;
.search-icon {
position: absolute;
right: 210rpx;
top: 50%;
transform: translateY(-50%);
}
.search-input {
background-color: white;
border-radius: 50rpx;
@ -213,6 +256,7 @@ export default {
text-align: center;
padding-top: 10rpx;
padding-bottom: 10rpx;
// color: #4974f3;
}
}

BIN
static/adminImg/step.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB