2026-05-28 09:48:42 +08:00

2 lines
4.0 KiB
JavaScript

"use strict";const e=require("../../common/vendor.js"),l=require("../../common/libraries/apiLoading.js"),o=require("../../common/libraries/naviHelper.js"),a=require("../../gen/Apis.js"),i=require("./model.js"),t=()=>{console.log("进来:");const l=e.index.createCanvasContext("poster_firstCanvas");e.index.canvasToTempFilePath({canvasId:"alipay_qrcode",x:0,y:0,width:170,height:170,destWidth:170,destHeight:170,success:o=>{l.clearRect(0,0,345,504),e.index.downloadFile({url:"https://pay-prod-1369486729.cos.ap-guangzhou.myqcloud.com/uploads/cs-test/01KP2XJ54TN4DVMCCJJ0AVNJK8.png",success(e){var a,t,n,d,s;l.drawImage(e.tempFilePath,0,0,345,504),l.font="bold 18px Arial",l.setTextAlign("center"),l.fillText((null==(a=i.useModel.orderInfo.value)?void 0:a.name)||"-",172.5,45),l.font="bold 16px Arial",l.fillStyle="#DF3600",l.fillText(`缴费金额:¥${null==(t=i.useModel.orderInfo.value)?void 0:t.amount}`,172.5,78),l.font="14px Arial",l.fillStyle="#333",l.fillText("请使用支付宝扫码支付",172.5,450),l.font="12px Arial",l.fillStyle="#666",l.fillText(`生成时间:${null==(s=null==(d=null==(n=i.useModel)?void 0:n.alipayQrCode)?void 0:d.value)?void 0:s.time} 有效时间30分钟`,172.5,475),l.drawImage(o.tempFilePath,72.5,150,200,200),l.restore(),l.draw()}}),console.log(o,"支付宝二维码路径")},fail:e=>{console.log(e,"支付宝二维码路径失败")}})},n=()=>{var l,o,a;const n=new e.UQRCode;n.data=null==(a=null==(o=null==(l=i.useModel)?void 0:l.alipayQrCode)?void 0:o.value)?void 0:a.payinfo,n.size=170,n.make();const d=e.index.createCanvasContext("alipay_qrcode");n.canvasContext=d,n.drawCanvas(),setTimeout(()=>{t()},300)},d=()=>{const l=e.index.createCanvasContext("poster_firstCanvas");e.index.downloadFile({url:"https://pay-prod-1369486729.cos.ap-guangzhou.myqcloud.com/uploads/cs-test/01KP2XJ54TN4DVMCCJJ0AVNJK8.png",success(e){var o,a,t,n;l.clearRect(0,0,345,504),l.drawImage(e.tempFilePath,0,0,345,504),l.font="bold 18px Arial",l.setTextAlign("center"),l.fillText((null==(o=i.useModel.custQrcodeInfo.value)?void 0:o.name)||"-",172.5,45),l.font="bold 16px Arial",l.fillStyle="#DF3600",l.fillText(`缴费金额:¥${null==(a=i.useModel.custQrcodeInfo.value)?void 0:a.amount}`,172.5,78),l.font="14px Arial",l.fillStyle="#333",l.fillText("请使用微信扫码支付",172.5,450),l.font="12px Arial",l.fillStyle="#666",l.fillText(`生成时间:${null==(t=i.useModel.custQrcodeInfo.value)?void 0:t.time}`,172.5,475),l.drawImage(null==(n=i.useModel.custQrcodeInfo.value)?void 0:n.url,72.5,150,200,200),l.restore(),l.draw()}})},s={getHouseDetail(e){},setCanvas(o){((o,i)=>{l.getApiLoading(a.Apis.HouseOrder.HouseOrders.GetPayQrCode,{id:null==o?void 0:o.order_id}).then(l=>{var o;const a=e.index.getFileSystemManager();let t=(new Date).getTime(),n=e.wx$1.env.USER_DATA_PATH+"/"+t+".png";a.writeFile({filePath:n,data:null==(o=null==l?void 0:l.data)?void 0:o.qr_code.slice(22),encoding:"base64",success:()=>null==i?void 0:i(n)})})})(o,e=>{i.useModel.custQrcodeInfo.value={...o,url:e},d(),console.log(e,"二维码路径")})},onDownloadPosters(){e.index.showLoading({title:"正在保存中..."}),e.index.canvasToTempFilePath({x:0,y:0,width:345,height:504,destWidth:1380,destHeight:2016,canvasId:"poster_firstCanvas",success:function(l){e.index.hideLoading(),e.index.saveImageToPhotosAlbum({filePath:l.tempFilePath,success:function(){console.log("save success"),o.showToast("保存成功!")},fail(){e.index.hideLoading()}}),console.log(l.tempFilePath)},fail(){e.index.hideLoading()}})},initActualImages:async e=>{},choiceImgPopControl(){var e;this.initActualImages(null==(e=i.useModel.houseDetail.value)?void 0:e.id)},copyLink(){},changeTab(o){var s,r,u,c;i.useModel.tabCurrent.value=o,o?(null==(u=null==(r=null==(s=i.useModel)?void 0:s.alipayQrCode)?void 0:r.value)?void 0:u.payinfo)?t():l.getApiLoading(a.Apis.HouseOrder.HouseOrders.AlipayQrCode,{id:null==(c=i.useModel.orderInfo.value)?void 0:c.order_id,pay_type:"Alipay"}).then(l=>{i.useModel.alipayQrCode.value={...null==l?void 0:l.data,time:e.dayjs().format("YYYY-MM-DD HH:mm")},n()}):d()}};exports.method=s;