Commit 34f40616 by liimin

fix(mp/points): 替换废弃 getSystemInfo 为 getDeviceInfo/getWindowInfo/getAppBaseInfo

基础库 2.20.1 起 getSystemInfoSync/getSystemInfo 已废弃(3.7.0 起鸿蒙需改用新接口)。
本次消除 points 小程序启动与控制台里的弃用告警:

- api/env/index.js: 环境判定改用 getDeviceInfo().platform,旧基础库回退保留
- components/NavigationBar: 拆 statusBarHeight/screenWidth→getWindowInfo、fontSizeSetting→getAppBaseInfo,去 .then
- storageApi.setSystem_info: 合并 device/window/appBase 信息后存储,保 Track.js 字段
- packageEquity freecard/allEquity: windowHeight 改 getWindowInfo()
- utils_wx.getSystemInfo: 合并五个新接口返回,兼容原有回调契约
- utils/sentry: 清理注释块内两处陈旧引用
1 parent 917b43e7
......@@ -11,7 +11,10 @@ let index = 2
4预发布
*/
const accountInfo = wx.getAccountInfoSync()
const systemInfo = wx.getSystemInfoSync()
// 基础库 2.20.1+ 起 getSystemInfoSync 已废弃,环境判定只用到 platform,
// 改用 getDeviceInfo;旧基础库(无该接口)回退到旧接口,避免无谓报错。
const systemInfo =
typeof wx.getDeviceInfo === 'function' ? wx.getDeviceInfo() : wx.getSystemInfoSync()
// console.log(systemInfo);
// console.log(accountInfo.miniProgram.envVersion)
//手动控制体验版环境的请求 true就依据下面index false就默认为2
......
......@@ -34,39 +34,45 @@ Component({
},
init() {
/**
* 获取自定义导航栏信息
* 获取自定义导航栏信息。
* 基础库 2.20.1+ 起 getSystemInfo 已废弃,按字段拆分到新接口:
* statusBarHeight / screenWidth → wx.getWindowInfo()
* fontSizeSetting → wx.getAppBaseInfo()
* 新接口均为同步返回,去掉原来的 .then 异步时序。
*/
wx.getSystemInfo().then(res => {
let {
fontSizeSetting,
statusBarHeight,
screenWidth
} = res
const {
height,
right,
width,
top
} = wx.getMenuButtonBoundingClientRect(),
currentPages = getCurrentPages(), {
showBack
} = this.data
if (showBack && currentPages.length > 1) this.setData({
SHOWBACK: true
})
let navigationBarHeight = height + ((top - statusBarHeight) * 2)
let navigationBarPadding = screenWidth - right
let navigationBarWidth = screenWidth - (navigationBarPadding * 2 + width * 2)
this.setData({
statusBarHeight,
navigationBarHeight,
navigationBarStyle: `font-size:${fontSizeSetting}px;`,
navigationBarTextWidth: `width:${navigationBarWidth}px;padding:0 ${navigationBarPadding}px;`
})
this.emit({
navigationBarHeight,
statusBarHeight
})
const windowInfo = wx.getWindowInfo() || {}
const appBaseInfo = wx.getAppBaseInfo() || {}
let {
fontSizeSetting,
statusBarHeight,
screenWidth,
} = {
...windowInfo,
fontSizeSetting: appBaseInfo.fontSizeSetting,
}
const {
height,
right,
width,
top,
} = wx.getMenuButtonBoundingClientRect()
const currentPages = getCurrentPages()
const { showBack } = this.data
if (showBack && currentPages.length > 1) this.setData({
SHOWBACK: true
})
let navigationBarHeight = height + ((top - statusBarHeight) * 2)
let navigationBarPadding = screenWidth - right
let navigationBarWidth = screenWidth - (navigationBarPadding * 2 + width * 2)
this.setData({
statusBarHeight,
navigationBarHeight,
navigationBarStyle: `font-size:${fontSizeSetting}px;`,
navigationBarTextWidth: `width:${navigationBarWidth}px;padding:0 ${navigationBarPadding}px;`
})
this.emit({
navigationBarHeight,
statusBarHeight
})
},
emit({
......
......@@ -15,7 +15,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let system = wx.getSystemInfoSync()
let system = wx.getWindowInfo()
this.getAllMerchantList()
this.setData({
cHeight: system.windowHeight
......
......@@ -61,7 +61,7 @@ Page({
},
onLoad(options) {
let system = wx.getSystemInfoSync()
let system = wx.getWindowInfo()
const { merchantId } = wx.p.storage.get('merchant_info')
this.toGetFreeCardDay(merchantId)
this.setData({
......
......@@ -47,13 +47,14 @@ export function getNavigationBarTitleText() {
/** 存储设备信息 */
export function setSystem_info(that) {
let info = storage.get('system_info')
!info &&
wx.getSystemInfo({
success(res) {
// console.log(res)
storage.set('system_info', res)
}
})
if (!info) {
// 基础库 2.20.1+ 起 getSystemInfo 已废弃,按字段拆到新接口后合并存储,
// 保证 utils/track/Track.js 读取的 brand/model/system/SDKVersion/version 等字段仍可用。
const windowInfo = wx.getWindowInfo() || {}
const appBaseInfo = wx.getAppBaseInfo() || {}
const deviceInfo = wx.getDeviceInfo() || {}
storage.set('system_info', { ...deviceInfo, ...appBaseInfo, ...windowInfo })
}
}
export default{
......
......@@ -200,7 +200,7 @@ reportParamError('霈W”撘虜嚗erchantId, channelSource, phone 餈
productId: 'prod_456',
quantity: 2,
operation: 'add_to_cart',
userAgent: wx.getSystemInfoSync(),
userAgent: wx.getDeviceInfo(),
timestamp: Date.now()
};
......@@ -212,7 +212,7 @@ reportSentryError('韐剔頧行仃韐', cartParams, {
user_type: 'premium'
},
contexts: {
device_info: wx.getSystemInfoSync(),
device_info: { ...wx.getDeviceInfo(), ...wx.getWindowInfo(), ...wx.getAppBaseInfo() },
app_version: '1.2.3'
}
});*/
......@@ -58,14 +58,18 @@ const showToast = val => {
/**获取设备信息 */
const getSystemInfo = callBack => {
wx.getSystemInfo({
success(res) {
callBack(res)
},
fail(err) {
callBack(err)
}
})
try {
// 基础库 2.20.1+ 起 getSystemInfo 已废弃,按字段拆到新接口后合并返回,
// 保持与原 getSystemInfo 一致的字段集合,避免调用方逐个改造。
const windowInfo = wx.getWindowInfo() || {}
const appBaseInfo = wx.getAppBaseInfo() || {}
const deviceInfo = wx.getDeviceInfo() || {}
const systemSetting = wx.getSystemSetting() || {}
const appAuthorizeSetting = wx.getAppAuthorizeSetting() || {}
callBack({ ...deviceInfo, ...appBaseInfo, ...windowInfo, ...systemSetting, ...appAuthorizeSetting })
} catch (err) {
callBack(err)
}
}
/**拨打电话 */
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!