|
@@ -86,30 +86,29 @@ function calMoreImageInfo(e, idx, that, bindName) {
|
|
|
|
|
|
// 计算视觉优先的图片宽高
|
|
|
function wxAutoImageCal(originalWidth, originalHeight,that,bindName) {
|
|
|
- //获取图片的原始长宽s
|
|
|
-
|
|
|
- const windowInfo = wx.getWindowInfoSync();
|
|
|
+ // 使用同步接口获取窗口信息
|
|
|
+ const windowInfo = wx.getWindowInfo();
|
|
|
|
|
|
- // 安全获取边距配置(防止undefined错误)
|
|
|
- const padding = that.data?.[bindName]?.view?.imagePadding || 0;
|
|
|
-
|
|
|
- // 计算可用显示宽度(窗口宽度 - 左右边距)
|
|
|
- const maxWidth = windowInfo.windowWidth - 2 * padding;
|
|
|
+ // 安全获取边距配置(防止undefined错误)
|
|
|
+ const padding = that.data?.[bindName]?.view?.imagePadding || 0;
|
|
|
|
|
|
- let targetWidth = originalWidth;
|
|
|
- let targetHeight = originalHeight;
|
|
|
-
|
|
|
- // 按宽度比例缩放
|
|
|
- if (targetWidth > maxWidth) {
|
|
|
- targetWidth = maxWidth;
|
|
|
- targetHeight = (targetWidth * originalHeight) / originalWidth;
|
|
|
- }
|
|
|
-
|
|
|
- // 返回标准化命名的结果(驼峰命名)
|
|
|
- return {
|
|
|
- imageWidth: targetWidth,
|
|
|
- imageHeight: targetHeight // 修正原代码拼写错误 (imageheight → imageHeight)
|
|
|
- };
|
|
|
+ // 计算可用显示宽度(窗口宽度 - 左右边距)
|
|
|
+ const maxWidth = windowInfo.windowWidth - 2 * padding;
|
|
|
+
|
|
|
+ let targetWidth = originalWidth;
|
|
|
+ let targetHeight = originalHeight;
|
|
|
+
|
|
|
+ // 按宽度比例缩放
|
|
|
+ if (targetWidth > maxWidth) {
|
|
|
+ targetWidth = maxWidth;
|
|
|
+ targetHeight = (targetWidth * originalHeight) / originalWidth;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 返回标准化命名的结果(驼峰命名)
|
|
|
+ return {
|
|
|
+ imageWidth: targetWidth,
|
|
|
+ imageHeight: targetHeight // 修正原代码拼写错误 (imageheight → imageHeight)
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
function wxParseTemArray(temArrayName,bindNameReg,total,that){
|