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 ...@@ -11,7 +11,10 @@ let index = 2
4预发布 4预发布
*/ */
const accountInfo = wx.getAccountInfoSync() 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(systemInfo);
// console.log(accountInfo.miniProgram.envVersion) // console.log(accountInfo.miniProgram.envVersion)
//手动控制体验版环境的请求 true就依据下面index false就默认为2 //手动控制体验版环境的请求 true就依据下面index false就默认为2
......
...@@ -34,39 +34,45 @@ Component({ ...@@ -34,39 +34,45 @@ Component({
}, },
init() { init() {
/** /**
* 获取自定义导航栏信息 * 获取自定义导航栏信息。
* 基础库 2.20.1+ 起 getSystemInfo 已废弃,按字段拆分到新接口:
* statusBarHeight / screenWidth → wx.getWindowInfo()
* fontSizeSetting → wx.getAppBaseInfo()
* 新接口均为同步返回,去掉原来的 .then 异步时序。
*/ */
wx.getSystemInfo().then(res => { const windowInfo = wx.getWindowInfo() || {}
let { const appBaseInfo = wx.getAppBaseInfo() || {}
fontSizeSetting, let {
statusBarHeight, fontSizeSetting,
screenWidth statusBarHeight,
} = res screenWidth,
const { } = {
height, ...windowInfo,
right, fontSizeSetting: appBaseInfo.fontSizeSetting,
width, }
top const {
} = wx.getMenuButtonBoundingClientRect(), height,
currentPages = getCurrentPages(), { right,
showBack width,
} = this.data top,
if (showBack && currentPages.length > 1) this.setData({ } = wx.getMenuButtonBoundingClientRect()
SHOWBACK: true const currentPages = getCurrentPages()
}) const { showBack } = this.data
let navigationBarHeight = height + ((top - statusBarHeight) * 2) if (showBack && currentPages.length > 1) this.setData({
let navigationBarPadding = screenWidth - right SHOWBACK: true
let navigationBarWidth = screenWidth - (navigationBarPadding * 2 + width * 2) })
this.setData({ let navigationBarHeight = height + ((top - statusBarHeight) * 2)
statusBarHeight, let navigationBarPadding = screenWidth - right
navigationBarHeight, let navigationBarWidth = screenWidth - (navigationBarPadding * 2 + width * 2)
navigationBarStyle: `font-size:${fontSizeSetting}px;`, this.setData({
navigationBarTextWidth: `width:${navigationBarWidth}px;padding:0 ${navigationBarPadding}px;` statusBarHeight,
}) navigationBarHeight,
this.emit({ navigationBarStyle: `font-size:${fontSizeSetting}px;`,
navigationBarHeight, navigationBarTextWidth: `width:${navigationBarWidth}px;padding:0 ${navigationBarPadding}px;`
statusBarHeight })
}) this.emit({
navigationBarHeight,
statusBarHeight
}) })
}, },
emit({ emit({
......
...@@ -15,7 +15,7 @@ Page({ ...@@ -15,7 +15,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
let system = wx.getSystemInfoSync() let system = wx.getWindowInfo()
this.getAllMerchantList() this.getAllMerchantList()
this.setData({ this.setData({
cHeight: system.windowHeight cHeight: system.windowHeight
......
...@@ -61,7 +61,7 @@ Page({ ...@@ -61,7 +61,7 @@ Page({
}, },
onLoad(options) { onLoad(options) {
let system = wx.getSystemInfoSync() let system = wx.getWindowInfo()
const { merchantId } = wx.p.storage.get('merchant_info') const { merchantId } = wx.p.storage.get('merchant_info')
this.toGetFreeCardDay(merchantId) this.toGetFreeCardDay(merchantId)
this.setData({ this.setData({
......
...@@ -47,13 +47,14 @@ export function getNavigationBarTitleText() { ...@@ -47,13 +47,14 @@ export function getNavigationBarTitleText() {
/** 存储设备信息 */ /** 存储设备信息 */
export function setSystem_info(that) { export function setSystem_info(that) {
let info = storage.get('system_info') let info = storage.get('system_info')
!info && if (!info) {
wx.getSystemInfo({ // 基础库 2.20.1+ 起 getSystemInfo 已废弃,按字段拆到新接口后合并存储,
success(res) { // 保证 utils/track/Track.js 读取的 brand/model/system/SDKVersion/version 等字段仍可用。
// console.log(res) const windowInfo = wx.getWindowInfo() || {}
storage.set('system_info', res) const appBaseInfo = wx.getAppBaseInfo() || {}
} const deviceInfo = wx.getDeviceInfo() || {}
}) storage.set('system_info', { ...deviceInfo, ...appBaseInfo, ...windowInfo })
}
} }
export default{ export default{
......
...@@ -200,7 +200,7 @@ reportParamError('霈W”撘虜嚗erchantId, channelSource, phone 餈 ...@@ -200,7 +200,7 @@ reportParamError('霈W”撘虜嚗erchantId, channelSource, phone 餈
productId: 'prod_456', productId: 'prod_456',
quantity: 2, quantity: 2,
operation: 'add_to_cart', operation: 'add_to_cart',
userAgent: wx.getSystemInfoSync(), userAgent: wx.getDeviceInfo(),
timestamp: Date.now() timestamp: Date.now()
}; };
...@@ -212,7 +212,7 @@ reportSentryError('韐剔頧行仃韐', cartParams, { ...@@ -212,7 +212,7 @@ reportSentryError('韐剔頧行仃韐', cartParams, {
user_type: 'premium' user_type: 'premium'
}, },
contexts: { contexts: {
device_info: wx.getSystemInfoSync(), device_info: { ...wx.getDeviceInfo(), ...wx.getWindowInfo(), ...wx.getAppBaseInfo() },
app_version: '1.2.3' app_version: '1.2.3'
} }
});*/ });*/
...@@ -58,14 +58,18 @@ const showToast = val => { ...@@ -58,14 +58,18 @@ const showToast = val => {
/**获取设备信息 */ /**获取设备信息 */
const getSystemInfo = callBack => { const getSystemInfo = callBack => {
wx.getSystemInfo({ try {
success(res) { // 基础库 2.20.1+ 起 getSystemInfo 已废弃,按字段拆到新接口后合并返回,
callBack(res) // 保持与原 getSystemInfo 一致的字段集合,避免调用方逐个改造。
}, const windowInfo = wx.getWindowInfo() || {}
fail(err) { const appBaseInfo = wx.getAppBaseInfo() || {}
callBack(err) 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!