From 7203d3c46e2d1c58ced6c5528243ce74a20146da Mon Sep 17 00:00:00 2001 From: Wayne Date: Thu, 6 Jul 2023 09:43:53 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A0=90=E8=A3=BD=E5=8D=A1=E7=B3=BB=E7=B5=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.h888 | 6 + .env.slash | 2 +- package.json | 3 +- src/main.js | 3 +- src/pages/user/Precard.vue | 116 ++++++++----- src/pages/user/components/AddPreForm.vue | 210 ++++++++++++----------- src/services/card.js | 2 - yarn.lock | 23 ++- 8 files changed, 205 insertions(+), 160 deletions(-) create mode 100644 .env.h888 diff --git a/.env.h888 b/.env.h888 new file mode 100644 index 0000000..fe5cf29 --- /dev/null +++ b/.env.h888 @@ -0,0 +1,6 @@ +VUE_ENV = development + +VUE_APP_PUBLIC_PATH = '/admin' + +VUE_APP_API_URL=https://card.h888.fun/adminapi/v1 + diff --git a/.env.slash b/.env.slash index 21fb201..34bfb95 100644 --- a/.env.slash +++ b/.env.slash @@ -2,5 +2,5 @@ VUE_ENV = production VUE_APP_PUBLIC_PATH = '/admin' -VUE_APP_API_URL=https://card.h888.fun/adminapi/v1 +VUE_APP_API_URL=https://card.slash1000.com/adminapi/v1 diff --git a/package.json b/package.json index 990836f..a23f14f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", - "build:dev": "vue-cli-service build --mode development", + "build:h888": "vue-cli-service build --mode development", "build:sta": "vue-cli-service build --mode stage", "build:slash": "vue-cli-service build --mode slash", "lint": "vue-cli-service lint", @@ -18,6 +18,7 @@ }, "dependencies": { "@antv/data-set": "^0.11.4", + "@vue/composition-api": "^1.7.1", "animate.css": "^4.1.0", "ant-design-vue": "1.7.2", "axios": "^0.19.2", diff --git a/src/main.js b/src/main.js index c372da6..b68df53 100644 --- a/src/main.js +++ b/src/main.js @@ -1,4 +1,5 @@ import Vue from 'vue' +import VueCompositionAPI from '@vue/composition-api' import App from './App.vue' import {initRouter} from './router' import './theme/index.less' @@ -26,7 +27,7 @@ Vue.use(Viser) Vue.use(Plugins) Vue.use(CKEditor) Vue.use(VueClipboard) - +Vue.use(VueCompositionAPI) bootstrap({router, store, i18n, message: Vue.prototype.$message}) new Vue({ diff --git a/src/pages/user/Precard.vue b/src/pages/user/Precard.vue index ce18c2a..6abc091 100644 --- a/src/pages/user/Precard.vue +++ b/src/pages/user/Precard.vue @@ -21,8 +21,8 @@ 新增 + @change="onChange" @selectedRowChange="onSelectChange" @showSizeChange="onShowSizeChange" :scroll="{ x: 1100 }" + rowKey="id">
{{ level[row.text] }}
@@ -37,16 +37,13 @@
- + 複製URL - + 下載QR - + 列印 @@ -64,15 +61,13 @@
-
- - +
@@ -103,9 +98,9 @@ const columns = [ }, { - title: '代理', - dataIndex: 'agent_name', - key: 'agent_name', + title: '名稱', + dataIndex: 'name', + key: 'name', width: 120 }, // { @@ -116,7 +111,7 @@ const columns = [ // }, { title: '卡號', - dataIndex: 'verify_code', + dataIndex: 'serial_no', width: 100 }, { @@ -255,16 +250,10 @@ export default { }, async onSwitchChange(checked, rec) { - this.showCodeScan = true - this.vcode.id = rec.id - this.$nextTick(function () { - this.vcodeMsg = '請將卡片靠近讀卡機' - this.vcodeStatus = true - this.$refs.vcode.select() - }) - + if (checked === true) { + this.getVCode(rec.id) + } return - }, onShowSizeChange(current, size) { this.pagination.current = current @@ -340,6 +329,7 @@ export default { console.log(this.vcode) }, + // 可能沒用 handleFocus() { this.vcodeMsg = '請將卡片靠近讀卡機' this.vcodeStatus = true @@ -349,42 +339,84 @@ export default { this.vcodeMsg = '點擊此處開始偵測感應' this.vcodeStatus = false }, - async getVCode() { - if (this.vcode.code.trim().length != 8 && this.vcode.code.trim().length != 14) { - this.vcode.code = '' - this.vcodeMsg = '掃碼失敗' + async getVCode(id) { + let nfcReaderUrl = 'http://localhost:8088' + + this.showCodeScan = true + this.vcode.id = id + + this.vcodeStatus = true + this.vcodeMsg = '請將卡片靠近讀卡機' + + let res1 = await fetch(nfcReaderUrl + '/getnfcid', { + method: 'GET', + }) + + res1 = await res1.json() + + if (res1.code !== 200) { + this.vcodeMsg = res1.error this.vcodeStatus = false setTimeout(() => { - this.vcodeMsg = '請將卡片靠近讀卡機' - this.vcodeStatus = true + this.showCodeScan = false + return this.$message.success('操作失敗') }, 2000) return } - this.vcode.code = this.vcode.code.toUpperCase() + this.vcodeMsg = '讀取卡號' + res1.sid + this.vcode.code = res1.sid - const res = await updateVerifyCode( + let res2 = await updateVerifyCode( this.vcode ) - this.vcode.code = '' - - if (res.code !== 200) { - // return this.$message.error(res.data); - this.vcodeMsg = res.data + if (res2.code !== 200) { + this.vcodeMsg = res2.data this.vcodeStatus = false setTimeout(() => { - this.vcodeStatus = true - this.vcodeMsg = '請將卡片靠近讀卡機' + this.showCodeScan = false + return this.$message.success('操作失敗') }, 2000) return } - this.showCodeScan = false + + this.vcodeMsg = '開始寫入卡片...' + + const data = new URLSearchParams(); + data.append('data', res2.data); + + let res3 = await fetch(nfcReaderUrl + '/writenfc', { + method: 'POST', + body: data, + }) + + res3 = await res3.json() + + if (res3.code !== 200) { + this.vcodeMsg = res3.error + this.vcodeStatus = false + setTimeout(() => { + this.showCodeScan = false + return this.$message.success('操作失敗') + }, 2000) + return + } + + this.vcodeMsg = '寫入成功' + this.vcodeStatus = true + this.vcode.code = '' + this.vcode.id = null + this.genTable() - return this.$message.success('操作成功') + + setTimeout(() => { + this.showCodeScan = false + return this.$message.success('操作成功') + }, 2000) }, closeModal() { this.vcode = { id: null, code: '' } diff --git a/src/pages/user/components/AddPreForm.vue b/src/pages/user/components/AddPreForm.vue index 9973e14..fb0d675 100644 --- a/src/pages/user/components/AddPreForm.vue +++ b/src/pages/user/components/AddPreForm.vue @@ -1,56 +1,56 @@