Files
shanxia2.0/miniprogram/utils/portalEnvelope.js
T
wuzilongandCursor af79aa50a2 fix(pl): 司机回执缺品牌数量时仍保存单据,并按业务结果提示成败。
未填写品牌数量不再拦截照片和备注;已填写的品牌数量仍校验。小程序在 HTTP 200 的业务失败下不再弹出保存成功。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-06 23:57:34 +08:00

16 lines
700 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 门户信封 { code, message, data } 的业务失败文案。
* HTTP 200 仍可能携带 code=400;code 缺失或非数字时视为裸 JSON。
* @param {unknown} data
* @returns {string | null}
*/
export function portalBusinessErrorMessage(data) {
if (!data || typeof data !== 'object' || Array.isArray(data)) return null
if (!Object.prototype.hasOwnProperty.call(data, 'code')) return null
const code = Number(data.code)
if (!Number.isFinite(code) || code === 200 || code === 0) return null
const message = typeof data.message === 'string' ? data.message.trim() : ''
const msg = typeof data.msg === 'string' ? data.msg.trim() : ''
return message || msg || '请求失败'
}