acdr-ui/dist/dev/mp-weixin/utils/commUtils.js.map

1 line
3.9 KiB
Plaintext

{"version":3,"file":"commUtils.js","sources":["../../../../src/utils/commUtils.js"],"sourcesContent":["import sheep from '@/sheep'\nimport PLATFORM from './platform'\n\n// 获取服务baseUrl\nexport const baseUrl = import.meta.env.VITE_SERVER_BASEURL\nexport const uploadUrl = import.meta.env.VITE_SERVER_BASEURL\nexport const ossUrl = import.meta.env.VITE_OSS_BASEURL\n\nexport const toast = (message) => {\n uni.showToast({ title: message, icon: 'none' })\n}\n\n// 解析图片\nexport const imgUrl = (img, isOss) => {\n const placeholder = 'https://via.placeholder.com/150' // 占位符图片的URL\n const isLocation = img.startsWith('@/')\n if (isLocation) return img.replace('@', ossUrl)\n if (isOss || isLocation) ossUrl + img || placeholder\n\n if (!img) return placeholder\n\n // 检查图片是否为网络图片(判断是否以 http:// 或 https:// 开头)\n const isNetworkImage = img.startsWith('http://') || img.startsWith('https://')\n\n return isNetworkImage ? img : `${uploadUrl + img}`\n}\n\n// 使用异步的询问对话框\nexport const showModalAsync = (options) => {\n return new Promise((resolve, reject) => {\n uni.showModal({\n ...options,\n success: (res) => {\n if (res.confirm) {\n resolve(res)\n } else if (res.cancel) {\n resolve(res)\n }\n },\n fail: (err) => {\n reject(err)\n },\n })\n })\n}\n\n// 扫码逻辑\nexport const scanCodeAsync = () => {\n return new Promise((resolve, reject) => {\n uni.scanCode({\n onlyFromCamera: true, // 是否只能从相机扫码\n success: (res) => {\n resolve(res) // 成功时返回扫码结果\n },\n fail: (err) => {\n reject(err) // 失败时返回错误信息\n },\n })\n })\n}\n\n// 路径导航\nexport const toPath = (path) => {\n if (path === '/') {\n uni.switchTab({ url: '/pages/index/index' })\n return\n }\n\n // 如果没有指定路由默认跳转到首页去\n if (!path) {\n uni.switchTab({ url: '/pages/index/index' })\n return\n }\n\n // 判断是不是属于网络路由\n const isWebUrl = path.startsWith('http://') || path.startsWith('https://')\n if (isWebUrl) {\n PLATFORM.isH5 && window.open(path)\n PLATFORM.isApp && uni.navigateTo({ url: '/pages/webview/webview?url=' + path })\n return\n }\n\n // 判断是不是属于商城的路由界面\n const isMallPath = path.includes('/pages/mall') !== -1\n if (isMallPath) {\n sheep.$router.go(path)\n return\n }\n\n // 其他情况使用 uni.navigateTo\n uni.navigateTo({ url: path })\n}\n"],"names":["uni","sheep"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIO,MAAM,UAAU;AAChB,MAAM,YAAY;AAClB,MAAM,SAAS;AAET,MAAA,QAAQ,CAAC,YAAY;AAChCA,gBAAA,MAAI,UAAU,EAAE,OAAO,SAAS,MAAM,QAAQ;AAChD;AAGa,MAAA,SAAS,CAAC,KAAK,UAAU;AACpC,QAAM,cAAc;AACd,QAAA,aAAa,IAAI,WAAW,IAAI;AAClC,MAAA;AAAmB,WAAA,IAAI,QAAQ,KAAK,MAAM;AAG9C,MAAI,CAAC;AAAY,WAAA;AAGjB,QAAM,iBAAiB,IAAI,WAAW,SAAS,KAAK,IAAI,WAAW,UAAU;AAE7E,SAAO,iBAAiB,MAAM,GAAG,YAAY,GAAG;AAClD;AAGa,MAAA,iBAAiB,CAAC,YAAY;AACzC,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtCA,kBAAAA,MAAI,UAAU,iCACT,UADS;AAAA,MAEZ,SAAS,CAAC,QAAQ;AAChB,YAAI,IAAI,SAAS;AACf,kBAAQ,GAAG;AAAA,QAAA,WACF,IAAI,QAAQ;AACrB,kBAAQ,GAAG;AAAA,QACb;AAAA,MACF;AAAA,MACA,MAAM,CAAC,QAAQ;AACb,eAAO,GAAG;AAAA,MACZ;AAAA,IAAA,EACD;AAAA,EAAA,CACF;AACH;AAGO,MAAM,gBAAgB,MAAM;AACjC,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtCA,kBAAAA,MAAI,SAAS;AAAA,MACX,gBAAgB;AAAA;AAAA,MAChB,SAAS,CAAC,QAAQ;AAChB,gBAAQ,GAAG;AAAA,MACb;AAAA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