From 12f9bcbd74359c0fc58eea98e4f1685477b7e63f Mon Sep 17 00:00:00 2001 From: whycq <whycq> Date: 星期二, 12 四月 2022 16:29:40 +0800 Subject: [PATCH] # --- pages/basics/pakin.vue | 89 ++++++++++++++++++++++++++++++++++++++------ 1 files changed, 77 insertions(+), 12 deletions(-) diff --git a/pages/basics/pakin.vue b/pages/basics/pakin.vue index 08239b7..0a4e19a 100644 --- a/pages/basics/pakin.vue +++ b/pages/basics/pakin.vue @@ -9,7 +9,7 @@ <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> </view> @@ -21,7 +21,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> @@ -51,16 +51,17 @@ </scroll-view> <view class="footer flex justify-around"> <view> - <button class="cu-btn" @click="resst()">閲嶇疆</button> + <button class="cu-btn lg" @click="resst()">閲嶇疆</button> </view> <view> - <button class="cu-btn pakin-btn bg-blue" @click="comb()">缁勬墭</button> + <button class="cu-btn lg pakin-btn bg-blue" @click="comb()">缁勬墭</button> </view> </view> </view> </template> <script> + import permision from "@/common/permission.js" export default { data() { return { @@ -70,6 +71,7 @@ pick:'hide', matnr:'', matList:[], + result: '' } }, mounted(){ @@ -79,21 +81,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() { + 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 +162,7 @@ 'token':uni.getStorageSync('token') }, success(result) { - uni.hideLoading(); + uni.showLoading(); var res = result.data if (res.code === 200) { uni.showToast({ @@ -129,7 +176,7 @@ uni.reLaunch({ url: '../login/login' }); - }, 500); + }, 1000); } else { uni.showToast({title: res.msg, icon: "none",position: 'top'}) } @@ -137,7 +184,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 +213,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 +221,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 }) } }); } @@ -243,12 +307,13 @@ .box-buttom { display: inline-block; background-color: #ededed; - width: 70%; + width: 65%; height: 60rpx; border-radius: 20rpx; margin: 15rpx 15rpx 0rpx 15rpx; } .box-buttom input { + width: 75%; float: left; margin: 8rpx 10rpx 0rpx 25rpx; } @@ -276,7 +341,7 @@ color: #ffffff; display: inline-block; float: right; - width: 150rpx; + width: 180rpx; height: 60rpx; margin: 15rpx 15rpx 0rpx 15rpx; line-height: 60rpx; -- Gitblit v1.9.1