feat: 半屏连续扫与修改密码报错并升至1.1.25

This commit is contained in:
2026-11-10 08:27:17 +08:00
parent 706fcda5b9
commit c0067e3b89
12 changed files with 439 additions and 74 deletions
+1 -1
View File
@@ -114,7 +114,7 @@ const install = (Vue, vm) => {
// 个人信息修改
user: {
saveUserInfo: (params = {}) => vm.$u.post(config.productionApiUrl+'/mobile/user/saveUserInfo', params),
infoSavePwd: (params = {}) => vm.$u.put(config.productionApiUrl+'/system/user/profile/updatePwd', params),
infoSavePwd: (params = {}) => vm.$u.put('/system/user/profile/updatePwd', params),
infoSavePqa: (params = {}) => vm.$u.post(config.productionApiUrl+'/sys/user/infoSavePqa', params),
},
+22 -7
View File
@@ -73,18 +73,33 @@ const install = (Vue, vm) => {
return false;
}
console.log('res',res)
if (!(res.data)){
const rejectWithMessage = (message) => {
const text = String(message || '请求失败').trim() || '请求失败';
vm.$u.toast(text);
return Promise.reject(new Error(text));
};
// HTTP 非 200(如 404)时直接报错,避免把字符串/HTML 当业务 data 解析
if (res.statusCode && res.statusCode !== 200) {
let message = `请求失败(${res.statusCode})`;
if (typeof res.data === 'string' && res.data.trim()) {
message = res.data.trim().slice(0, 120);
} else if (res.data && typeof res.data === 'object') {
message = res.data.msg || res.data.message || message;
}
return rejectWithMessage(message);
}
if (res.data === undefined || res.data === null || res.data === '') {
const errMsg = String((res && res.errMsg) || '');
const isNetworkError = res.statusCode === -1
|| /Unable to resolve host|Failed to connect|request:fail|timeout|网络/i.test(errMsg);
const message = isNetworkError ? '当前没有网络,请检查网络后重试' : '未连接到服务器';
vm.$u.toast(message)
return Promise.reject(new Error(message));
return rejectWithMessage(message);
}
if(res.data.code !== 0) {
vm.$u.toast(res.data.msg)
return Promise.reject(new Error(res.data.msg))
if (typeof res.data !== 'object') {
return rejectWithMessage(String(res.data).slice(0, 120));
}
if (res.data.code !== 0) {
return rejectWithMessage(res.data.msg || res.data.message || '请求失败');
}
let data = res.data.data;
console.log('data',data)
+259
View File
@@ -0,0 +1,259 @@
<template>
<view v-show="visible" class="plus-barcode-panel">
<view class="plus-barcode-panel__toolbar">
<text class="plus-barcode-panel__tip">{{ tipText }}</text>
<text class="plus-barcode-panel__close" @click.stop="close">收起</text>
</view>
<!-- #ifdef APP-PLUS -->
<view :id="holderId" class="plus-barcode-panel__holder" />
<!-- #endif -->
<!-- #ifndef APP-PLUS -->
<view class="plus-barcode-panel__fallback">
<text>当前环境不支持半屏扫码,请使用输入框或系统扫码</text>
</view>
<!-- #endif -->
</view>
</template>
<script>
const DEFAULT_FILTERS = [0, 1, 2, 8, 10]; // QR EAN13 EAN8 CODE39 CODE128
let barcodeSeq = 0;
export default {
name: 'PlusBarcodePanel',
props: {
visible: { type: Boolean, default: false },
hintText: { type: String, default: '将条码放入框内,可连续扫' },
scanTimeSpace: { type: Number, default: 1200 },
filters: { type: Array, default: () => DEFAULT_FILTERS.slice() },
},
data() {
barcodeSeq += 1;
return {
holderId: `plusBarcodeHolder_${barcodeSeq}`,
barcodeViewId: `plusBarcodeView_${barcodeSeq}`,
_barcode: null,
_restartTimer: null,
_active: false,
_creating: false,
};
},
computed: {
tipText() {
return this.hintText || '将条码放入框内,可连续扫';
},
},
watch: {
visible(val) {
if (val) {
this.$nextTick(() => {
this.openNative();
});
} else {
this.destroyNative();
}
},
},
beforeDestroy() {
this.destroyNative();
},
methods: {
open() {
if (this.visible) {
this.$nextTick(() => this.openNative());
return;
}
this.$emit('update:visible', true);
},
close() {
this.destroyNative();
if (this.visible) {
this.$emit('update:visible', false);
}
this.$emit('close');
},
getCurrentWebview() {
// #ifdef APP-PLUS
try {
const pages = getCurrentPages();
const page = pages[pages.length - 1];
if (page && typeof page.$getAppWebview === 'function') {
return page.$getAppWebview();
}
} catch (e) {
console.warn('PlusBarcodePanel getCurrentWebview failed', e);
}
// #endif
return null;
},
openNative() {
// #ifdef APP-PLUS
if (!this.visible || this._creating) return;
if (this._barcode) {
this.resumeScan();
return;
}
this._creating = true;
this._active = true;
// 等占位区域完成布局后再量位置,避免 Android 上 rect 为 0
setTimeout(() => {
if (!this.visible || !this._active) {
this._creating = false;
return;
}
uni.createSelectorQuery()
.in(this)
.select('.plus-barcode-panel__holder')
.boundingClientRect((rect) => {
this._creating = false;
if (!this.visible || !this._active) return;
if (!rect || !rect.width || !rect.height) {
uni.showToast({ title: '扫码区域未就绪', icon: 'none' });
return;
}
this.createBarcode(rect);
})
.exec();
}, 80);
// #endif
},
createBarcode(rect) {
// #ifdef APP-PLUS
const webview = this.getCurrentWebview();
if (!webview || typeof plus === 'undefined' || !plus.barcode) {
uni.showToast({ title: '当前环境不支持扫码', icon: 'none' });
return;
}
this.destroyNative(false);
try {
const barcode = plus.barcode.create(
this.barcodeViewId,
this.filters && this.filters.length ? this.filters : DEFAULT_FILTERS,
{
top: `${Math.round(rect.top)}px`,
left: `${Math.round(rect.left)}px`,
width: `${Math.round(rect.width)}px`,
height: `${Math.round(rect.height)}px`,
position: 'absolute',
background: '#000000',
frameColor: '#2979ff',
scanbarColor: '#2979ff',
},
);
barcode.onmarked = (type, code) => {
this.onMarked(type, code);
};
barcode.onerror = (err) => {
console.error('PlusBarcodePanel onerror', err);
};
webview.append(barcode);
this._barcode = barcode;
this._active = true;
barcode.start({
vibrate: true,
sound: 'default',
});
} catch (e) {
console.error('PlusBarcodePanel create failed', e);
uni.showToast({ title: '打开扫码失败', icon: 'none' });
this._barcode = null;
}
// #endif
},
onMarked(type, code) {
const result = String(code || '').trim();
if (!result || !this._active) return;
try {
if (this._barcode) this._barcode.cancel();
} catch (e) {
// ignore
}
this.$emit('success', result, type);
clearTimeout(this._restartTimer);
const gap = Number(this.scanTimeSpace) > 0 ? Number(this.scanTimeSpace) : 1200;
this._restartTimer = setTimeout(() => {
this.resumeScan();
}, gap);
},
resumeScan() {
// #ifdef APP-PLUS
if (!this.visible || !this._active || !this._barcode) return;
try {
this._barcode.start({
vibrate: true,
sound: 'default',
});
} catch (e) {
console.warn('PlusBarcodePanel resume failed', e);
}
// #endif
},
destroyNative(clearActive = true) {
clearTimeout(this._restartTimer);
this._restartTimer = null;
if (clearActive) this._active = false;
// #ifdef APP-PLUS
const barcode = this._barcode;
this._barcode = null;
if (!barcode) return;
try {
barcode.cancel();
} catch (e) {
// ignore
}
try {
barcode.close();
} catch (e) {
// ignore
}
// #endif
},
},
};
</script>
<style scoped lang="scss">
@import '@/common/pda-typography.scss';
.plus-barcode-panel {
background: #000;
margin-top: 16rpx;
}
.plus-barcode-panel__toolbar {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 72rpx;
padding: 12rpx 26rpx;
background: #1f1f1f;
box-sizing: border-box;
}
.plus-barcode-panel__tip {
flex: 1;
color: #ffffff;
font-size: $pda-font-action;
padding-right: 16rpx;
}
.plus-barcode-panel__close {
color: #2979ff;
font-size: $pda-font-action;
flex-shrink: 0;
}
.plus-barcode-panel__holder {
width: 100%;
height: 420rpx;
background: #000;
}
.plus-barcode-panel__fallback {
display: flex;
align-items: center;
justify-content: center;
height: 420rpx;
padding: 24rpx;
box-sizing: border-box;
background: #333;
color: #fff;
font-size: $pda-font-body;
text-align: center;
}
</style>
@@ -11,6 +11,14 @@
@confirm="$emit('scan')"
/>
<view
v-if="scanning"
class="fabric-out-scanClose"
@click.stop="$emit('phone-scan')"
>
关闭扫码
</view>
<view
v-else
class="fabric-out-toolbarIcon"
@click.stop="$emit('phone-scan')"
>
@@ -35,12 +43,14 @@ export default {
deleteMode: { type: Boolean, default: false },
message: { type: String, default: '' },
disabledTip: { type: String, default: '当前状态不可扫码' },
scanning: { type: Boolean, default: false },
},
};
</script>
<style scoped lang="scss">
@import '@/pages/storefabric/storeFabricBusinessOutPage.scss';
@import '@/common/pda-typography.scss';
.fabric-out-toolbarIcon {
display: flex;
@@ -54,4 +64,19 @@ export default {
background: #f7f7f7;
flex-shrink: 0;
}
.fabric-out-scanClose {
display: flex;
align-items: center;
justify-content: center;
margin-left: 8rpx;
padding: 0 16rpx;
height: 72rpx;
border-radius: 8rpx;
border: 1rpx solid #2979ff;
background: #eaf2ff;
color: #2979ff;
font-size: $pda-font-action;
flex-shrink: 0;
white-space: nowrap;
}
</style>
+2 -2
View File
@@ -2,8 +2,8 @@
"name" : "浩拓织厂",
"appid" : "__UNI__F79F300",
"description" : "周尚-浩拓织厂",
"versionName" : "1.1.24",
"versionCode" : 124,
"versionName" : "1.1.25",
"versionCode" : 125,
"transformPx" : false,
"app-plus" : {
"optimization" : {
@@ -42,12 +42,20 @@
</view>
<view v-if="showScanSection">
<PlusBarcodePanel
ref="plusBarcodePanel"
:visible.sync="phoneScanPanelOpen"
hint-text="连续扫码出仓,扫完可继续下一条"
:scan-time-space="1200"
@success="onPlusBarcodeSuccess"
/>
<FabricOutScanBar
:can-scan="canScan"
:value="QRBarCode"
:delete-mode="BarCodeDelStatus"
:message="BillDataMessage"
disabled-tip="请先提交保存后再扫码"
:scanning="phoneScanPanelOpen"
@input="QRBarCode = $event"
@scan="handleScan"
@phone-scan="handlePhoneScan"
@@ -98,6 +106,7 @@ import FabricOutScanDetail from '@/components/storefabric/FabricOutScanDetail.vu
import FabricOutSummaryTable from '@/components/storefabric/FabricOutSummaryTable.vue';
import FabricOutFooter from '@/components/storefabric/FabricOutFooter.vue';
import SearchSelectPopup from '@/components/storefabric/SearchSelectPopup.vue';
import PlusBarcodePanel from '@/components/common/PlusBarcodePanel.vue';
export default {
components: {
@@ -109,6 +118,7 @@ export default {
FabricOutSummaryTable,
FabricOutFooter,
SearchSelectPopup,
PlusBarcodePanel,
},
mixins: [formMixin],
onLoad() {
@@ -36,11 +36,19 @@
</view>
<view v-if="showScanSection">
<PlusBarcodePanel
ref="plusBarcodePanel"
:visible.sync="phoneScanPanelOpen"
hint-text="连续扫码出仓,扫完可继续下一条"
:scan-time-space="1200"
@success="onPlusBarcodeSuccess"
/>
<FabricOutScanBar
:can-scan="canScan"
:value="QRBarCode"
:delete-mode="BarCodeDelStatus"
:message="BillDataMessage"
:scanning="phoneScanPanelOpen"
@input="QRBarCode = $event"
@scan="handleScan"
@phone-scan="handlePhoneScan"
@@ -81,6 +89,7 @@ import FabricOutScanDetail from '@/components/storefabric/FabricOutScanDetail.vu
import FabricOutSummaryTable from '@/components/storefabric/FabricOutSummaryTable.vue';
import FabricOutFooter from '@/components/storefabric/FabricOutFooter.vue';
import SearchSelectPopup from '@/components/storefabric/SearchSelectPopup.vue';
import PlusBarcodePanel from '@/components/common/PlusBarcodePanel.vue';
export default {
components: {
@@ -92,6 +101,7 @@ export default {
FabricOutSummaryTable,
FabricOutFooter,
SearchSelectPopup,
PlusBarcodePanel,
},
mixins: [formMixin],
data() {
@@ -64,6 +64,7 @@ export default {
auditStatus: 0,
businessUnitOptions: [],
dropdownLoading: false,
phoneScanPanelOpen: false,
};
},
computed: {
@@ -112,25 +113,29 @@ export default {
},
onHide() {
this.isPageActive = false;
this.closePhoneScanPanel();
this.unregisterScanBroadcast();
},
onUnload() {
this.isPageActive = false;
this.closePhoneScanPanel();
this.unregisterScanBroadcast();
},
methods: {
handlePhoneScan() {
// 手机连续扫:优先 Ba-Scanner;无插件时扫完自动再开相机
this.openPhoneScan({
continuous: true,
hintText: '连续扫码出仓,扫完可继续下一条',
scanTimeSpace: 1200,
callback: (scanResult) => {
if (!this.canScan) {
this.showError('请先提交保存后再扫码');
return;
}
this.phoneScanPanelOpen = !this.phoneScanPanelOpen;
},
closePhoneScanPanel() {
this.phoneScanPanelOpen = false;
},
onPlusBarcodeSuccess(scanResult) {
this.QRBarCode = String(scanResult || '').trim().replace(/[\r\n]/g, '');
return this.handleScan();
},
});
},
registerOrderScanBroadcast() {
this.registerScanBroadcast((scanResult) => {
this.QRBarCode = scanResult.trim().replace(/[\r\n]/g, '');
@@ -141,6 +146,7 @@ export default {
const nextCanScan = this.isEditable && canScanAtStatus(status);
if (this.canScan && !nextCanScan) {
this.unregisterScanBroadcast();
this.closePhoneScanPanel();
}
this.canScan = nextCanScan;
},
+48 -6
View File
@@ -57,6 +57,14 @@
</view>
</view>
<PlusBarcodePanel
ref="plusBarcodePanel"
:visible.sync="phoneScanPanelOpen"
hint-text="连续扫码进仓,扫完可继续下一条"
:scan-time-space="1200"
@success="onPlusBarcodeSuccess"
/>
<view class="manual-in__scan">
<input
class="manual-in__scan-input"
@@ -77,6 +85,14 @@
<u-icon name="close-circle-fill" size="44" color="#bfbfbf" />
</view>
<view
v-if="phoneScanPanelOpen"
class="manual-in__scan-close"
@click.stop="handlePhoneScan"
>
关闭扫码
</view>
<view
v-else
class="manual-in__scan-icon"
@click.stop="handlePhoneScan"
>
@@ -133,6 +149,7 @@
<script>
import CommonNavbar from '@/components/common-navbar/index';
import SearchSelectPopup from '@/components/storefabric/SearchSelectPopup.vue';
import PlusBarcodePanel from '@/components/common/PlusBarcodePanel.vue';
import scanMixin from '@/common/scanMixin.js';
import util from '@/common/util.js';
import { formatWeightKg } from '@/common/storeFabricBusinessOut.js';
@@ -186,7 +203,7 @@ function normalizeLevelIds(value) {
}
export default {
components: { CommonNavbar, SearchSelectPopup },
components: { CommonNavbar, SearchSelectPopup, PlusBarcodePanel },
mixins: [scanMixin],
data() {
return {
@@ -204,6 +221,7 @@ export default {
inspectorPickerShow: false,
inspectorOptions: [],
inspectorOptionsLoaded: false,
phoneScanPanelOpen: false,
};
},
computed: {
@@ -224,9 +242,16 @@ export default {
this.loadInspectorOptions();
},
onShow() {
this.isPageActive = true;
this.refocusScanInput(50);
},
onHide() {
this.isPageActive = false;
this.closePhoneScanPanel();
},
onUnload() {
this.isPageActive = false;
this.closePhoneScanPanel();
clearTimeout(this._scanFocusTimer);
},
methods: {
@@ -237,6 +262,12 @@ export default {
this.scanFocus = true;
}, delay);
},
closePhoneScanPanel() {
this.phoneScanPanelOpen = false;
},
onPlusBarcodeSuccess(scanResult) {
return this.handleScanCode(scanResult);
},
navToSetting() {
uni.navigateTo({ url: '/pages/sys/user/scan-settings' });
},
@@ -354,11 +385,7 @@ export default {
this.$u.toast(err);
return;
}
this.openPhoneScan({
callback: (scanResult) => {
this.handleScanCode(scanResult);
},
});
this.phoneScanPanelOpen = !this.phoneScanPanelOpen;
},
onScanConfirm() {
const code = String(this.scanCode || '').trim();
@@ -554,6 +581,21 @@ export default {
background: #f7f7f7;
}
.manual-in__scan-close {
display: flex;
align-items: center;
justify-content: center;
height: 72rpx;
padding: 0 16rpx;
flex-shrink: 0;
border-radius: 8rpx;
border: 1rpx solid #2979ff;
background: #eaf2ff;
color: #2979ff;
font-size: $pda-font-action;
white-space: nowrap;
}
.manual-in__placeholder {
color: #b0b4bb;
font-size: $pda-font-placeholder;
+1 -1
View File
@@ -41,7 +41,7 @@
<u-gap height="20" bg-color="#f5f5f5"></u-gap>
<u-cell-item icon="question-circle" :iconStyle="{ color: '#ff8d06' }" title="常见问题" @click="navTo('problem')"></u-cell-item>
<u-cell-item icon="kefu-ermai" :iconStyle="{ color: '#5f8dff' }" title="意见反馈" @click="navTo('comment')"></u-cell-item>
<u-cell-item icon="map" :iconStyle="{ color: '#316ede' }" title="账号安全" @click="navTo('pwd')"></u-cell-item>
<u-cell-item icon="map" :iconStyle="{ color: '#316ede' }" title="修改密码" @click="navTo('pwd')"></u-cell-item>
<u-cell-item icon="scan" :iconStyle="{ color: '#36cfc9' }" title="扫描设置" @click="navTo('scan-settings')"></u-cell-item>
<u-cell-item icon="order" :iconStyle="{ color: '#59bdf9' }" title="清除缓存" @click="navTo('clear-cache')"></u-cell-item>
<!--<u-cell-item icon="account" :iconStyle="{ color: '#27c0dc' }" title="关于我们" @click="navTo('about')"></u-cell-item>
+10 -11
View File
@@ -68,31 +68,30 @@ export default {
methods: {
submit() {
this.$refs.uForm.validate(valid => {
if (valid) {
if (!valid) {
this.$u.toast('您填写的信息有误,请根据提示修正。');
return;
}
this.$u.api.user.infoSavePwd({
oldPassword: this.model.oldPassword,
newPassword: this.model.newPassword
}).then(res => {
if(res.code == '200'){
}).then(() => {
uni.showModal({
title: '提示',
content: res.msg,
content: '密码修改成功',
showCancel: false,
success: function () {
success: () => {
uni.navigateBack();
}
});
}else{
}).catch((err) => {
const message = (err && (err.message || err.msg)) || '修改密码失败';
uni.showModal({
title: '提示',
content: res.msg,
content: message,
showCancel: false
});
}
});
} else {
this.$u.toast('您填写的信息有误,请根据提示修正。');
}
});
},
cancel() {
+11 -12
View File
@@ -33,7 +33,7 @@ export default {
model: {
oldPassword: '',
newPassword: '',
confirmNewPassword: ''
confirmPassword: ''
},
rules: {
oldPassword: [
@@ -78,31 +78,30 @@ export default {
methods: {
submit() {
this.$refs.uForm.validate(valid => {
if (valid) {
if (!valid) {
this.$u.toast('您填写的信息有误,请根据提示修正。');
return;
}
this.$u.api.user.infoSavePwd({
oldPassword: this.model.oldPassword,
newPassword: this.model.newPassword
}).then(res => {
if(res.code == '200'){
}).then(() => {
uni.showModal({
title: '提示',
content: res.msg,
content: '密码修改成功',
showCancel: false,
success: function () {
success: () => {
uni.navigateBack();
}
});
}else{
}).catch((err) => {
const message = (err && (err.message || err.msg)) || '修改密码失败';
uni.showModal({
title: '提示',
content: res.msg,
content: message,
showCancel: false
});
}
});
} else {
this.$u.toast('您填写的信息有误,请根据提示修正。');
}
});
},
cancel() {