fix:系统版本读取manifest.json;孔夫子登录失败显示errInfo

This commit is contained in:
97694732@qq.com 2026-06-15 13:34:30 +08:00
parent 2d16446dd7
commit 34220db758
2 changed files with 121 additions and 106 deletions

View File

@ -53,7 +53,7 @@
</view>
<view class="user-info">
<text class="user-name">用户名</text>
<text class="version-text">系统版本v1.0.0</text>
<text class="version-text">系统版本v{{ appVersion }}</text>
</view>
</view>
@ -130,116 +130,131 @@
</template>
<script>
export default {
data() {
return {
currentTab: 'home'
}
},
// manifest.json uni-app
var manifestData = {}
try {
manifestData = require('../../manifest.json')
} catch (e) {
manifestData = { versionName: '1.0.0' }
}
onLoad() {
uni.setNavigationBarTitle({
title: '入库助手'
})
},
export default {
data() {
return {
currentTab: 'home',
appVersion: manifestData.versionName || '1.0.0'
}
},
methods: {
// Tab
switchTab(tab) {
this.currentTab = tab
onLoad() {
uni.setNavigationBarTitle({
title: tab === 'home' ? '入库助手' : '我的'
title: '入库助手'
})
},
// ISBN
handleISBNUpload() {
const data = uni.getStorageSync('selectedWarehouseData')
let params = 'tab=isbn'
if (data && data.warehouseName && data.locationCode) {
const encode = encodeURIComponent
params += `&whName=${encode(data.warehouseName)}&whCode=${encode(data.warehouseCode)}&whId=${encode(data.warehouseId)}`
params += `&locCode=${encode(data.locationCode)}&locName=${encode(data.locationName)}&locId=${encode(data.locationId)}`
}
uni.navigateTo({ url: `/pages/upload/upload?${params}` })
},
// ISBN
handleNoISBNUpload() {
const data = uni.getStorageSync('selectedWarehouseData')
let params = 'tab=no-isbn'
if (data && data.warehouseName && data.locationCode) {
const encode = encodeURIComponent
params += `&whName=${encode(data.warehouseName)}&whCode=${encode(data.warehouseCode)}&whId=${encode(data.warehouseId)}`
params += `&locCode=${encode(data.locationCode)}&locName=${encode(data.locationName)}&locId=${encode(data.locationId)}`
}
uni.navigateTo({ url: `/pages/upload/upload?${params}` })
},
//
handleMenu(type) {
const menuNames = {
vip: '开通会员',
offline: '线下订单管理',
shelf: '货架管理',
refresh: '孔网商品翻新',
record: '上书记录',
order: '仓库订单查询'
}
// VIP
if (type === 'vip') {
uni.navigateTo({
url: '/pages/vip/vip'
})
return
}
//
if (type === 'record') {
uni.navigateTo({
url: '/pages/record/record'
})
return
}
//
if (type === 'order') {
uni.navigateTo({
url: '/pages/order/order'
})
return
}
uni.showToast({
title: menuNames[type],
icon: 'none'
})
// TODO:
},
// 退
handleLogout() {
uni.showModal({
title: '提示',
content: '确定要退出登录吗?',
success: (res) => {
if (res.confirm) {
uni.removeStorageSync('token')
uni.redirectTo({
url: '/pages/login/login'
})
}
// App 使 plus.runtime.version
try {
if (typeof plus !== 'undefined' && plus.runtime && plus.runtime.version) {
this.appVersion = plus.runtime.version
}
})
} catch (e) {}
},
//
goBackToEntry() {
uni.redirectTo({ url: '/pages/entry/entry' })
methods: {
// Tab
switchTab(tab) {
this.currentTab = tab
uni.setNavigationBarTitle({
title: tab === 'home' ? '入库助手' : '我的'
})
},
// ISBN
handleISBNUpload() {
const data = uni.getStorageSync('selectedWarehouseData')
let params = 'tab=isbn'
if (data && data.warehouseName && data.locationCode) {
const encode = encodeURIComponent
params += `&whName=${encode(data.warehouseName)}&whCode=${encode(data.warehouseCode)}&whId=${encode(data.warehouseId)}`
params += `&locCode=${encode(data.locationCode)}&locName=${encode(data.locationName)}&locId=${encode(data.locationId)}`
}
uni.navigateTo({ url: `/pages/upload/upload?${params}` })
},
// ISBN
handleNoISBNUpload() {
const data = uni.getStorageSync('selectedWarehouseData')
let params = 'tab=no-isbn'
if (data && data.warehouseName && data.locationCode) {
const encode = encodeURIComponent
params += `&whName=${encode(data.warehouseName)}&whCode=${encode(data.warehouseCode)}&whId=${encode(data.warehouseId)}`
params += `&locCode=${encode(data.locationCode)}&locName=${encode(data.locationName)}&locId=${encode(data.locationId)}`
}
uni.navigateTo({ url: `/pages/upload/upload?${params}` })
},
//
handleMenu(type) {
const menuNames = {
vip: '开通会员',
offline: '线下订单管理',
shelf: '货架管理',
refresh: '孔网商品翻新',
record: '上书记录',
order: '仓库订单查询'
}
// VIP
if (type === 'vip') {
uni.navigateTo({
url: '/pages/vip/vip'
})
return
}
//
if (type === 'record') {
uni.navigateTo({
url: '/pages/record/record'
})
return
}
//
if (type === 'order') {
uni.navigateTo({
url: '/pages/order/order'
})
return
}
uni.showToast({
title: menuNames[type],
icon: 'none'
})
// TODO:
},
// 退
handleLogout() {
uni.showModal({
title: '提示',
content: '确定要退出登录吗?',
success: (res) => {
if (res.confirm) {
uni.removeStorageSync('token')
uni.redirectTo({
url: '/pages/login/login'
})
}
}
})
},
//
goBackToEntry() {
uni.redirectTo({ url: '/pages/entry/entry' })
}
}
}
}
</script>
<style>

View File

@ -54,13 +54,13 @@ export function login(username, password) {
try {
const json = typeof res.data === 'string' ? JSON.parse(res.data) : res.data
if (json.errCode === 1001) {
resolve({ success: false, token: '', message: '账号或密码错误' })
resolve({ success: false, token: '', message: json.errInfo || '账号或密码错误' })
} else if (json.errCode === 1005) {
resolve({ success: false, token: '', message: '密码错误' })
resolve({ success: false, token: '', message: json.errInfo || '密码错误' })
} else if (json.errCode === 1009) {
resolve({ success: false, token: '', message: '调用次数已达上限,请稍后再试' })
resolve({ success: false, token: '', message: json.errInfo || '调用次数已达上限,请稍后再试' })
} else {
resolve({ success: false, token: '', message: json.msg || '登录失败' })
resolve({ success: false, token: '', message: json.errInfo || '登录失败' })
}
} catch (e) {
resolve({ success: false, token: '', message: '登录失败,请检查账号密码' })