diff --git a/app.json b/app.json index 6726f42..527ee14 100644 --- a/app.json +++ b/app.json @@ -24,8 +24,7 @@ "pages/circularize/circularize", "pages/askHousing/askHousing", "pages/transfer/transfer", - "pages/video_show/video_show", - "pages/dome/dome" + "pages/video_show/video_show" ], "subpackages": [{ diff --git a/pages/brandApartmentDetail/brandApartmentDetail.js b/pages/brandApartmentDetail/brandApartmentDetail.js index 932ad8a..3b0fe64 100644 --- a/pages/brandApartmentDetail/brandApartmentDetail.js +++ b/pages/brandApartmentDetail/brandApartmentDetail.js @@ -328,7 +328,7 @@ Page({ const roomList = this.data.roomList || [] let title = `${ roomList.length > 1 ? '多房型' : '' }` - const price = Math.min(...roomList.map(item => item.price)); + const price = data.rentprice title += ` HK$${ price }起` const bj = data.image diff --git a/pages/dome/dome.js b/pages/dome/dome.js deleted file mode 100644 index 58a334e..0000000 --- a/pages/dome/dome.js +++ /dev/null @@ -1,287 +0,0 @@ -// pages/dome/dome.js -Page({ - /** - * 页面的初始数据 - */ - data: {}, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - this.drawPoster(); - }, - - async drawPoster() { - - return - // 修改画布创建方式 - const canvas = wx.createOffscreenCanvas({ - type: "2d", - width: 280 * 2, // 增加分辨率 - height: 224 * 2, // 增加分辨率 - }); - const ctx = canvas.getContext("2d"); - ctx.scale(2, 2); // 缩放绘图上下文 - - // 绘制背景 - let bgImg = canvas.createImage(); - await new Promise((resolve) => { - bgImg.onload = resolve; - bgImg.src = "https://oss.x-php.com/Zvt57TuJSUvkyhw-xG7Y2l-T9pwkfHvqqsgFptxhXa6QWi2uePJ5Bg8cFLPIqoYV7MsLCmeW5lr_-kU8uRQ0NDI5"; - }); - // 计算aspectFill模式参数 - const containerRatio = 280 / 219; // 容器宽高比 (280x219) - const imageRatio = bgImg.width / bgImg.height; - let drawWidth, - drawHeight, - offsetX = 0, - offsetY = 0; - - if (imageRatio > containerRatio) { - // 图片更宽,按高度缩放 - drawHeight = 219; - drawWidth = drawHeight * imageRatio; - offsetX = (280 - drawWidth) / 2; - } else { - // 图片更高,按宽度缩放 - drawWidth = 280; - drawHeight = drawWidth / imageRatio; - offsetY = (219 - drawHeight) / 2; - } - - // 绘制圆角背景(修改drawImage参数) - ctx.save(); - ctx.beginPath(); - ctx.moveTo(15, 4); - ctx.arcTo(280, 4, 280, 224, 15); - ctx.arcTo(280, 224, 0, 224, 15); - ctx.arcTo(0, 224, 0, 4, 15); - ctx.arcTo(0, 4, 280, 4, 15); - ctx.closePath(); - ctx.clip(); - // 计算源图片裁剪区域 - let srcX = 0, - srcY = 0, - srcWidth = bgImg.width, - srcHeight = bgImg.height; - - // 修正缩放逻辑 - if (imageRatio > containerRatio) { - // 图片更宽时,按容器高度缩放 - drawHeight = 219; - drawWidth = drawHeight * imageRatio; - offsetX = (280 - drawWidth) / 2; - - // 源图片裁剪:取中间宽度区域 - srcWidth = bgImg.height * containerRatio; - srcX = (bgImg.width - srcWidth) / 2; - } else { - // 图片更高时,按容器宽度缩放 - drawWidth = 280; - drawHeight = drawWidth / imageRatio; - offsetY = (219 - drawHeight) / 2; - - // 源图片裁剪:取中间高度区域 - srcHeight = bgImg.width / containerRatio; - srcY = (bgImg.height - srcHeight) / 2; - } - - // 修改后的drawImage调用 - ctx.drawImage( - bgImg, - srcX, - srcY, - srcWidth, // 改为计算后的裁剪宽度 - srcHeight, // 改为计算后的裁剪高度 - offsetX, - 4, - drawWidth, - drawHeight - ); - ctx.restore(); - - // 绘制右上角标签 - let tagImg = canvas.createImage(); - await new Promise((resolve) => { - tagImg.onload = resolve; - tagImg.src = "https://app.gter.net/image/miniApp/HKRenting/high-quality-tag.png"; - }); - ctx.drawImage(tagImg, 215, 0, 65, 54); - - let username = "asdfghjjkl,jhasdfghjjkl,jhasdfghjjkl,jhasdfghjjkl,jh"; - - // 绘制用户信息区域 - // 绘制用户信息区域 - // 先测量文本长度 - ctx.font = "14px PingFang SC"; - ctx.fillStyle = "#000"; - - let displayText = username + " 为你推荐14"; - let textMetrics = ctx.measureText(displayText); - let textWidth = textMetrics.width; - - // 添加文本截断逻辑 - const MAX_TEXT_WIDTH = 165; // 最大允许文本宽度 - if (textWidth > MAX_TEXT_WIDTH) { - let limit = username.length; - // 逐步减少字符直到宽度合适 - while (textWidth > MAX_TEXT_WIDTH && limit > 0) { - limit--; - displayText = username.substring(0, limit) + "... 为你推荐"; - textMetrics = ctx.measureText(displayText); - textWidth = textMetrics.width; - } - } - - // 动态计算区域宽度(头像24 + 边距4 + 文本宽度 + 右边距10) - const infoWidth = 24 + 4 + textWidth + 10; - const startX = 0; - const startY = 24; - const radius = 16; - - ctx.fillStyle = "#f2f2f2"; - ctx.beginPath(); - ctx.moveTo(startX, startY); - ctx.lineTo(infoWidth - radius, startY); - ctx.arcTo(infoWidth, startY, infoWidth, startY + 28, radius); - ctx.lineTo(infoWidth, startY + 28 - radius); - ctx.arcTo(infoWidth, startY + 28, startX, startY + 28, radius); - ctx.lineTo(startX, startY + 28); - ctx.closePath(); - ctx.fill(); - - // 绘制头像 - let avatarImg = canvas.createImage(); - await new Promise((resolve) => { - avatarImg.onload = resolve; - avatarImg.src = "https://oss.x-php.com/avatar/97K4EWIMLrsbGTWXslC0UlxSH_WP0kIg22nLYMG8a1OEctxifNbDW9U7oWFhY2E~/middle"; - }); - ctx.save(); - ctx.beginPath(); - ctx.arc(14, 38, 12, 0, Math.PI * 2); - ctx.clip(); - ctx.drawImage(avatarImg, 2, 26, 24, 24); - ctx.restore(); - - // 绘制用户名 - ctx.fillStyle = "#000"; - ctx.font = "14px PingFang SC"; - // 修改最终文本绘制调用 - console.log("displayText", displayText); - ctx.fillText(displayText, 30, 43); // 使用处理后的文本 - - // 绘制底部信息栏 - const gradient = ctx.createLinearGradient(0, 190, 0, 224); - gradient.addColorStop(0, "rgba(51, 51, 51, 0.2)"); - gradient.addColorStop(1, "rgba(51, 51, 51, 0.9)"); - ctx.fillStyle = gradient; - - ctx.beginPath(); - ctx.moveTo(0, 190); - ctx.arcTo(280, 190, 280, 224, 0); - ctx.arcTo(280, 224, 0, 224, 15); - ctx.arcTo(0, 224, 0, 190, 15); - ctx.closePath(); - ctx.fill(); - - // 绘制位置图标 - let positionIcon = canvas.createImage(); - await new Promise((resolve) => { - positionIcon.onload = resolve; - positionIcon.src = "https://app.gter.net/image/miniApp/HKRenting/position-icon.svg"; - }); - ctx.drawImage(positionIcon, 9, 200, 10, 14); - - // 绘制位置文本 - ctx.fillStyle = "#fff"; - ctx.font = "15px microsoft yahei"; - ctx.fillText("香港 | 多房型 HK$5600起", 25, 212); - - // 绘制箭头图标 - let arrowIcon = canvas.createImage(); - await new Promise((resolve) => { - arrowIcon.onload = resolve; - arrowIcon.src = "https://app.gter.net/image/miniApp/HKRenting/arrow-round-yellow.svg"; - }); - ctx.drawImage(arrowIcon, 255, 200, 16, 16); - - // 修改最后保存图片的尺寸 - const imgData = canvas.toDataURL({ - width: 280, - height: 224, - destWidth: 280 * 2, // 输出双倍分辨率 - destHeight: 224 * 2, - }); - const time = new Date().getTime(); - const filePath = wx.env.USER_DATA_PATH + "/poster" + time + "share" + ".png"; - - const fs = wx.getFileSystemManager(); - // console.log("imgData", imgData); - this.setData({ - src: imgData, - }); - - fs.writeFile({ - filePath, - data: imgData.replace(/^data:image\/\w+;base64,/, ""), - encoding: "base64", - success: (res) => { - wx.getImageInfo({ - src: filePath, - success: (res) => { - console.log("res", res); - }, - }); - this.setData({ - filePath, - }); - }, - fail: (err) => { - // 此处可能存在内存满了的情况 - // 需要根据具体需求处理 - console.log(err); - }, - }); - fs.close(); - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() {}, - - /** - * 生命周期函数--监听页面显示 - */ - onShow() {}, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() {}, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() {}, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() {}, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() {}, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - return { - imageUrl: this.data.filePath, - }; - }, -}); \ No newline at end of file diff --git a/pages/dome/dome.json b/pages/dome/dome.json deleted file mode 100644 index cdf14a7..0000000 --- a/pages/dome/dome.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "usingComponents": { - } -} \ No newline at end of file diff --git a/pages/dome/dome.less b/pages/dome/dome.less deleted file mode 100644 index 47b005c..0000000 --- a/pages/dome/dome.less +++ /dev/null @@ -1,154 +0,0 @@ -/* pages/dome/dome.wxss */ - -.image { - width: 280px; - height: 168px; - // background-color: royalblue; -} - -.container { - padding-top: 180rpx; -} - -.placard { - width: 280px; - height: 224px; - position: relative; - padding-top: 4px; - - .placard-bj { - width: 280px; - height: 219px; - border-radius: 15px; - } - - .placard-tag { - position: absolute; - top: 0; - right: 0; - width: 65px; - height: 54px; - } - - .placard-info { - position: absolute; - top: 24px; - left: 0; - background-color: rgba(242, 242, 242, 1); - display: flex; - align-items: center; - padding-right: 10px; - height: 28px; - background-color: rgba(242, 242, 242, 1); - border-radius: 0 16px 16px 0; - font-size: 14px; - font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; - - .avatar { - width: 24px; - height: 24px; - border-radius: 50%; - margin-left: 2px; - margin-right: 4px; - } - } - - .position { - position: absolute; - bottom: 0; - left: 0; - width: 280px; - height: 34px; - background-color: rgba(0, 0, 0, 0.5); - display: flex; - align-items: center; - padding: 0 9px; - border-radius: 0 0 15px 15px; - - .position-icon { - width: 10px; - height: 14px; - margin-right: 3px; - } - - .position-text { - flex: 1; - font-family: 'microsoft yahei'; - font-size: 15px; - color: #FFFFFF; - } - - .position-arrow { - width: 16px; - height: 16px; - } - } -} - -.placard-no-pic { - width: 280px; - height: 224px; - position: relative; - - .info { - display: flex; - align-items: center; - color: #555555; - font-size: 14px; - margin-bottom: 13px; - - .avatar { - width: 24px; - height: 24px; - border-radius: 50%; - margin-right: 5px; - } - } - - .box { - position: relative; - - .bj { - width: 280px; - height: 188px; - border-radius: 10px; - } - - .text { - font-size: 16px; - color: #000000; - font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; - line-height: 50px; - } - - .position { - position: absolute; - top: 0; - left: 44px; - } - - - .type { - position: absolute; - top: 50px; - left: 44px; - } - - .price { - position: absolute; - top: 100px; - left: 44px; - display: flex; - align-items: center; - - .sum { - font-family: 'PingFangSC-Semibold', 'PingFang SC Semibold', 'PingFang SC', sans-serif; - font-weight: 650; - font-size: 20px; - color: #FA6B11; - margin-right: 4px; - } - } - - } -} \ No newline at end of file diff --git a/pages/dome/dome.wxml b/pages/dome/dome.wxml deleted file mode 100644 index 7357156..0000000 --- a/pages/dome/dome.wxml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - 肖荣豪 为你推荐 - - - - - 香港 > 新界 > 大围/沙田 - 合租 · 房间 - 5300 HK$/月 - - - - - 23 - - - - - - 肖荣豪 为你推荐 - - - - - - 香港 | 多房型 HK$5600起 - - - - - - \ No newline at end of file diff --git a/pages/dome/dome.wxss b/pages/dome/dome.wxss deleted file mode 100644 index 0a9cf10..0000000 --- a/pages/dome/dome.wxss +++ /dev/null @@ -1,129 +0,0 @@ -/* pages/dome/dome.wxss */ -.image { - width: 280px; - height: 168px; -} -.container { - padding-top: 180rpx; -} -.placard { - width: 280px; - height: 224px; - position: relative; - padding-top: 4px; -} -.placard .placard-bj { - width: 280px; - height: 219px; - border-radius: 15px; -} -.placard .placard-tag { - position: absolute; - top: 0; - right: 0; - width: 65px; - height: 54px; -} -.placard .placard-info { - position: absolute; - top: 24px; - left: 0; - display: flex; - align-items: center; - padding-right: 10px; - height: 28px; - background-color: #f2f2f2; - border-radius: 0 16px 16px 0; - font-size: 14px; - font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; -} -.placard .placard-info .avatar { - width: 24px; - height: 24px; - border-radius: 50%; - margin-left: 2px; - margin-right: 4px; -} -.placard .position { - position: absolute; - bottom: 0; - left: 0; - width: 280px; - height: 34px; - background-color: rgba(0, 0, 0, 0.5); - display: flex; - align-items: center; - padding: 0 9px; - border-radius: 0 0 15px 15px; -} -.placard .position .position-icon { - width: 10px; - height: 14px; - margin-right: 3px; -} -.placard .position .position-text { - flex: 1; - font-family: 'microsoft yahei'; - font-size: 15px; - color: #FFFFFF; -} -.placard .position .position-arrow { - width: 16px; - height: 16px; -} -.placard-no-pic { - width: 280px; - height: 224px; - position: relative; -} -.placard-no-pic .info { - display: flex; - align-items: center; - color: #555555; - font-size: 14px; - margin-bottom: 13px; -} -.placard-no-pic .info .avatar { - width: 24px; - height: 24px; - border-radius: 50%; - margin-right: 5px; -} -.placard-no-pic .box { - position: relative; -} -.placard-no-pic .box .bj { - width: 280px; - height: 188px; - border-radius: 10px; -} -.placard-no-pic .box .text { - font-size: 16px; - color: #000000; - font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; - line-height: 50px; -} -.placard-no-pic .box .position { - position: absolute; - top: 0; - left: 44px; -} -.placard-no-pic .box .type { - position: absolute; - top: 50px; - left: 44px; -} -.placard-no-pic .box .price { - position: absolute; - top: 100px; - left: 44px; - display: flex; - align-items: center; -} -.placard-no-pic .box .price .sum { - font-family: 'PingFangSC-Semibold', 'PingFang SC Semibold', 'PingFang SC', sans-serif; - font-weight: 650; - font-size: 20px; - color: #FA6B11; - margin-right: 4px; -} diff --git a/pages/index/index.js b/pages/index/index.js index 813fa17..749d379 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -131,11 +131,13 @@ Page({ if (el['select']) listType = el['type'] }) data.apartment = data.apartment.slice(0, 5) + this.setData({ ...data, listType, loding: false }) + this.getNoticeNumber() this.getListData() }) diff --git a/pages/index/index.wxml b/pages/index/index.wxml index c5d393e..6242e44 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -1,4 +1,5 @@ + @@ -11,7 +12,6 @@ - @@ -25,9 +25,11 @@ - - - + + + + + @@ -88,27 +90,42 @@ + + + + + + {{ item.title }} + {{ item.propaganda }} + + + + + + + + - - - - - 更多 - - - - {{ item.title }} - {{ item.propaganda }} - - - - - + + + + + 更多 + + {{ item.title }} + {{ item.propaganda }} + + + + + + + diff --git a/pages/index/indexcss.less b/pages/index/indexcss.less index f6d535e..2b2a9ce 100644 --- a/pages/index/indexcss.less +++ b/pages/index/indexcss.less @@ -227,6 +227,96 @@ right: -15rpx; transform: rotate(90deg); + } + } +} + +.xin-head-swiper { + margin-bottom: 30rpx; + display: block; +} + +.apartment-block-new { + margin-top: 37.5rpx; + + .list { + width: 100vw; + box-sizing: border-box; + white-space: nowrap; + + .item { + position: relative; + width: 322.5rpx; + height: 390rpx; + border-radius: 24rpx; + display: inline-flex; + + &:first-of-type { + margin-left: 30rpx; + } + + &:not(:last-of-type) { + margin-right: 18rpx; + } + + &:last-of-type { + margin-right: 30rpx; + } + + .bj { + width: 322.5rpx; + height: 390rpx; + border-radius: 24rpx; + } + + .title { + font-family: 'PingFangSC-Semibold', 'PingFang SC Semibold', 'PingFang SC', sans-serif; + font-weight: 650; + font-style: normal; + font-size: 30rpx; + position: absolute; + top: 18rpx; + left: 22.5rpx; + width: 294rpx; + } + + .describe { + font-family: 'PingFangSC-Regular', + 'PingFang SC', + sans-serif; + font-weight: 400; + font-style: normal; + color: #555555; + font-size: 21rpx; + position: absolute; + top: 103.5rpx; + left: 66rpx; + width: 211.5rpx; + } + + .cover { + position: absolute; + top: 184.5rpx; + left: 27rpx; + width: 270rpx; + height: 177rpx; + + .cover-img { + width: 270rpx; + height: 177rpx; + border-radius: 10rpx; + } + + .play { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 84rpx; + height: 84rpx; + } + } + } } } \ No newline at end of file diff --git a/pages/index/indexcss.wxss b/pages/index/indexcss.wxss index ed1cd90..cc8d146 100644 --- a/pages/index/indexcss.wxss +++ b/pages/index/indexcss.wxss @@ -190,3 +190,77 @@ right: -15rpx; transform: rotate(90deg); } +.xin-head-swiper { + margin-bottom: 30rpx; + display: block; +} +.apartment-block-new { + margin-top: 37.5rpx; +} +.apartment-block-new .list { + width: 100vw; + box-sizing: border-box; + white-space: nowrap; +} +.apartment-block-new .list .item { + position: relative; + width: 322.5rpx; + height: 390rpx; + border-radius: 24rpx; + display: inline-flex; +} +.apartment-block-new .list .item:first-of-type { + margin-left: 30rpx; +} +.apartment-block-new .list .item:not(:last-of-type) { + margin-right: 18rpx; +} +.apartment-block-new .list .item:last-of-type { + margin-right: 30rpx; +} +.apartment-block-new .list .item .bj { + width: 322.5rpx; + height: 390rpx; + border-radius: 24rpx; +} +.apartment-block-new .list .item .title { + font-family: 'PingFangSC-Semibold', 'PingFang SC Semibold', 'PingFang SC', sans-serif; + font-weight: 650; + font-style: normal; + font-size: 30rpx; + position: absolute; + top: 18rpx; + left: 22.5rpx; + width: 294rpx; +} +.apartment-block-new .list .item .describe { + font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; + font-weight: 400; + font-style: normal; + color: #555555; + font-size: 21rpx; + position: absolute; + top: 103.5rpx; + left: 66rpx; + width: 211.5rpx; +} +.apartment-block-new .list .item .cover { + position: absolute; + top: 184.5rpx; + left: 27rpx; + width: 270rpx; + height: 177rpx; +} +.apartment-block-new .list .item .cover .cover-img { + width: 270rpx; + height: 177rpx; + border-radius: 10rpx; +} +.apartment-block-new .list .item .cover .play { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 84rpx; + height: 84rpx; +} diff --git a/template/xinHeadSwiper/xinHeadSwiper.js b/template/xinHeadSwiper/xinHeadSwiper.js index 1eec91e..af16ec4 100644 --- a/template/xinHeadSwiper/xinHeadSwiper.js +++ b/template/xinHeadSwiper/xinHeadSwiper.js @@ -8,6 +8,7 @@ Component({ */ properties: { data: Array, + page: String, }, /** @@ -16,6 +17,7 @@ Component({ data: { swiperCurrent: 0, HeadSwiperHeight: 100, + swiperHeightObj: {}, loadIndex: 0, // 加载图片的数量 }, @@ -26,17 +28,25 @@ Component({ methods: { // 轮播图的加载事件 loadHeadSwiper(e) { + const index = e.target.dataset.index || 0 let ratio = app.globalData.screen_data['windowWidth'] / 750 let originalWidth = e.detail.width; let originalHeight = e.detail.height; let height = originalHeight / originalWidth * 690 * ratio this.data.loadIndex++ - if (height > this.data.HeadSwiperHeight) { - this.setData({ - HeadSwiperHeight: height - }) - } + let swiperHeightObj = this.data.swiperHeightObj || {} + swiperHeightObj[index] = height + this.setData({ + swiperHeightObj, + }) + + // if (height > this.data.HeadSwiperHeight) { + // this.setData({ + // HeadSwiperHeight: height + // }) + // } + if (this.data.loadIndex != this.data.data.length) return this.triggerEvent("recordSwiperHeight") }, diff --git a/template/xinHeadSwiper/xinHeadSwiper.wxml b/template/xinHeadSwiper/xinHeadSwiper.wxml index 32d2376..5c94854 100644 --- a/template/xinHeadSwiper/xinHeadSwiper.wxml +++ b/template/xinHeadSwiper/xinHeadSwiper.wxml @@ -1,18 +1,18 @@ - - - -
- - -
-
-
+ + + +
+ + +
+
- - - - + + + + + \ No newline at end of file diff --git a/template/xinHeadSwiper/xinHeadSwiper.wxss b/template/xinHeadSwiper/xinHeadSwiper.wxss index c7fa98f..a65069d 100644 --- a/template/xinHeadSwiper/xinHeadSwiper.wxss +++ b/template/xinHeadSwiper/xinHeadSwiper.wxss @@ -4,6 +4,7 @@ .headSwiper-swiper { position: relative; + transition: all .2s; } .headSwiper { @@ -68,4 +69,26 @@ background: transparent; border: none; outline: none; +} + +.red-point { + display: flex; + justify-content: center; + align-items: center; + margin-top: 15rpx; +} + +.red-point .item { + width: 7.5rpx; + height: 7.5rpx; + background-color: rgba(170, 170, 170, 1); + border-radius: 30rpx; +} + +.red-point .item.pitch { + background-color: rgba(249, 93, 93, 1); +} + +.red-point .item:not(:last-of-type) { + margin-right: 7.5rpx; } \ No newline at end of file diff --git a/utils/miucms.js b/utils/miucms.js index 7e8c04c..b21dd01 100644 --- a/utils/miucms.js +++ b/utils/miucms.js @@ -2,19 +2,19 @@ var initial_url = "https://app.gter.net/tenement"; var app = null; function initial(self) { - const fs = wx.getFileSystemManager(); - console.log("getCurrentDate", getCurrentDate()); - fs.mkdir({ - dirPath: `${wx.env.USER_DATA_PATH}/${getCurrentDate()}`, - // dirPath: `${wx.env.USER_DATA_PATH}/2025-04-13`, - success(res) { - console.log("res", res); - }, - fail(err) { - console.log("err", err); - }, - }); - fs.close(); + // const fs = wx.getFileSystemManager(); + // console.log("getCurrentDate", getCurrentDate()); + // fs.mkdir({ + // dirPath: `${wx.env.USER_DATA_PATH}/${getCurrentDate()}`, + // // dirPath: `${wx.env.USER_DATA_PATH}/2025-04-13`, + // success(res) { + // console.log("res", res); + // }, + // fail(err) { + // console.log("err", err); + // }, + // }); + // fs.close(); app = self; getUserInfo(function (code) { @@ -962,7 +962,21 @@ function generatePoster(target) { arrowIcon.src = `https://app.gter.net/image/miniApp/HKRenting/arrow-round-yellow.png?${Date.now()}`; }); ctx.drawImage(arrowIcon, 255, 200, 16, 16); - console.log("绘制箭头图标完成"); + console.log("绘制箭头图标完成-开始保存"); + + wx.canvasToTempFilePath({ + quality: 1, + canvas, + success: (res) => { + console.log("生成路径", res.tempFilePath) + resolve(res.tempFilePath); + }, + fail: err => { + console.log("生成失败", err); + } + }) + + return // 修改最后保存图片的尺寸 const imgData = canvas.toDataURL({ @@ -974,6 +988,8 @@ function generatePoster(target) { const filePath = `${wx.env.USER_DATA_PATH}/${getCurrentDate()}/poster_share_${Date.now()}.png`; const fs = wx.getFileSystemManager(); + + console.log("开始保存"); let writeFileSum = 0; // 写入次数 const writeFile = () => { @@ -1124,12 +1140,15 @@ function generatePosterNoImage(target) { // 绘制文字信息 ctx.font = "16px PingFang SC"; ctx.fillStyle = "#000000"; + console.log("渲染文字信息完成"); // 位置信息 ctx.fillText(target.position, 44, 71); + console.log("渲染位置信息完成"); // 类型信息 ctx.fillText(target.typeText, 44, 121); + console.log("渲染类型完成"); // 价格信息 ctx.font = "20px PingFang SC"; @@ -1138,7 +1157,21 @@ function generatePosterNoImage(target) { ctx.font = "16px PingFang SC"; ctx.fillStyle = "#000000"; ctx.fillText("HK$/月", 44 + ctx.measureText(target.price).width + 12, 171); + console.log("渲染价格完成"); + wx.canvasToTempFilePath({ + quality: 1, + canvas, + success: (res) => { + console.log("生成路径", res.tempFilePath) + resolve(res.tempFilePath); + }, + fail: err => { + console.log("生成失败", err); + } + }) + + return // 导出图片 const imgData = canvas.toDataURL({ destWidth: 280 * 2,