From 8cfe3b775e16a3e7e04544451c513d65280b34c0 Mon Sep 17 00:00:00 2001 From: whycq <whycq> Date: 星期六, 09 四月 2022 16:47:28 +0800 Subject: [PATCH] # --- pages/basics/pakin.vue | 81 +++++++++++++++++++++++++++++++++++++--- 1 files changed, 74 insertions(+), 7 deletions(-) diff --git a/pages/basics/pakin.vue b/pages/basics/pakin.vue index 3d547c3..9a1e612 100644 --- a/pages/basics/pakin.vue +++ b/pages/basics/pakin.vue @@ -9,9 +9,10 @@ <view class="box-buttom"> <input v-model="barcode" type="text" placeholder="鎵爜 / 杈撳叆"> <view class="search-icon"> - <uni-icons type="closeempty" size="25" color="#a5a5a5" @click="removeBarcode()"></uni-icons> + <uni-icons type="closeempty" size="20" color="#a5a5a5" @click="removeBarcode()"></uni-icons> </view> </view> + <button class="cu-btn bg-blue" @click="scan">鎵爜</button> </view> <view class="pak-seach-box"> <view class="box-top"> @@ -21,7 +22,7 @@ <view class="box-buttom"> <input v-model="matnr" type="text" placeholder="鎵爜 / 杈撳叆" @input="findMat()"> <view class="search-icon"> - <uni-icons type="closeempty" size="25" color="#a5a5a5" @click="removeMatnr()"></uni-icons> + <uni-icons type="closeempty" size="20" color="#a5a5a5" @click="removeMatnr()"></uni-icons> </view> </view> <button class="cu-btn bg-blue" @click="selectMat()">+鎻愬彇</button> @@ -61,6 +62,7 @@ </template> <script> + import permision from "@/common/permission.js" export default { data() { return { @@ -70,6 +72,8 @@ pick:'hide', matnr:'', matList:[], + man:'', + result: '' } }, mounted(){ @@ -79,21 +83,66 @@ this.basePORT = UPORT }, methods: { + async scan() { + // #ifdef APP-PLUS + let status = await this.checkPermission(); + if (status !== 1) { + return; + } + // #endif + uni.scanCode({ + success: (res) => { + this.matnr = res.result + this.findMat(this.matnr) + }, + fail: (err) => { + // 闇�瑕佹敞鎰忕殑鏄皬绋嬪簭鎵爜涓嶉渶瑕佺敵璇风浉鏈烘潈闄� + } + }); + } + // #ifdef APP-PLUS + , + async checkPermission(code) { + let status = permision.isIOS ? await permision.requestIOS('camera') : + await permision.requestAndroid('android.permission.CAMERA'); + + if (status === null || status === 1) { + status = 1; + } else { + uni.showModal({ + content: "闇�瑕佺浉鏈烘潈闄�", + confirmText: "璁剧疆", + success: function(res) { + if (res.confirm) { + permision.gotoAppSetting(); + } + } + }) + } + return status; + } + // #endif + , resst() { this.matList = [] this.barcode = '' this.matnr = '' + uni.vibrateShort(); }, removeBarcode() { this.barcode = '' + uni.vibrateShort(); }, removeMatnr() { this.matnr = '' + uni.vibrateShort(); }, remove(item,index) { this.matList.splice(index,1) + uni.vibrateShort(); }, comb() { + uni.vibrateShort(); let that = this; if (that.barcode === '') { uni.showToast({title: '璇锋壂鎻忔墭鐩樻潯鐮�', icon: "none", position: 'top'}); @@ -115,7 +164,7 @@ 'token':uni.getStorageSync('token') }, success(result) { - uni.hideLoading(); + uni.showLoading(); var res = result.data if (res.code === 200) { uni.showToast({ @@ -129,7 +178,7 @@ uni.reLaunch({ url: '../login/login' }); - }, 500); + }, 1000); } else { uni.showToast({title: res.msg, icon: "none",position: 'top'}) } @@ -137,7 +186,23 @@ }); }, selectMat() { - + let that = this + uni.vibrateShort(); + uni.navigateTo({ + url: "matSelect", + events: { + // 涓烘寚瀹氫簨浠舵坊鍔犱竴涓洃鍚櫒锛岃幏鍙栬鎵撳紑椤甸潰浼犻�佸埌褰撳墠椤甸潰鐨勬暟鎹� + acceptDataFromOpenedPage: function(data) { + that.matnr = data.data + that.findMat(that.matnr) + }, + }, + success: function(res) { + // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹� + res.eventChannel.emit('acceptDataFromOpenerPage', {baseIP:that.baseIP, basePORT:that.basePORT }) + } + }); + that.matnr = '' }, findMat() { let that = this @@ -150,6 +215,7 @@ 'token':uni.getStorageSync('token') }, success(result) { + uni.vibrateShort(); let res = result.data if (res.code === 200 && res.data) { that.matData = res.data @@ -157,13 +223,13 @@ url: "matQuery", events: { // 涓烘寚瀹氫簨浠舵坊鍔犱竴涓洃鍚櫒锛岃幏鍙栬鎵撳紑椤甸潰浼犻�佸埌褰撳墠椤甸潰鐨勬暟鎹� - acceptDataFromOpenedPage: function(data) { + matList: function(data) { that.matList.push(data.data) }, }, success: function(res) { // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹� - res.eventChannel.emit('acceptDataFromOpenerPage', { data: that.matData }) + res.eventChannel.emit('matData', { data: that.matData }) } }); } @@ -249,6 +315,7 @@ margin: 15rpx 15rpx 0rpx 15rpx; } .box-buttom input { + width: 75%; float: left; margin: 8rpx 10rpx 0rpx 25rpx; } -- Gitblit v1.9.1