diff --git a/packageA/pages/liveStream/liveStream.js b/packageA/pages/liveStream/liveStream.js index 990d007..1e16b24 100644 --- a/packageA/pages/liveStream/liveStream.js +++ b/packageA/pages/liveStream/liveStream.js @@ -10,7 +10,6 @@ var t = require("../../../utils/util"), o = s.globalData.setting, os = o; var regeneratorRuntime = require('../../../utils/runtime.js'); - const app = getApp(); let self = null; @@ -21,14 +20,34 @@ Page({ */ data: { curPage: 1, + ad_data: null, + sharimg: "", living: {}, livetoBegin: {}, liveOver: {}, - list: null, - isLoading: false, // 检测是否已经发送请求,防止重复发送请求 - noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 - pageNum: 1, // 当前页数 - + list: null, + isLoading: false, // 检测是否已经发送请求,防止重复发送请求 + noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 + pageNum: 1, // 当前页数 + details: {}, + status: '', + btnText: '', + showActionSheet: true, + showPlaybill: true, + windowWidth: 0, + windowHeight: 0, + dpr: 0, + canvasScale: 1.0, + nickName: '', + avatarUrl: '', + coverImg: '', + canvasToImgPath: '', + screenWidth: 0, + canvasHidden: 1, + gid: '', + shareImgPath: '', + shartitle: "", + anchorname:"" }, // list: [], // live: { @@ -41,8 +60,18 @@ Page({ clickItem: function (e) { // id:列表项id // live:直播类别 即将开始/直播中/精彩回放 + + if (e.currentTarget.dataset.live == 101) { + var live_status = 'ing' + } + if (e.currentTarget.dataset.live == 102) { + var live_status = 'toBegin' + } + if (e.currentTarget.dataset.live == 103) { + var live_status = 'over' + } wx.navigateTo({ - url: '/packageA/pages/liveStreamDetails/liveStreamDetails?id=' + e.currentTarget.dataset.id + '&live=' + e.currentTarget.dataset.live + url: '/packageA/pages/liveStreamDetails/liveStreamDetails?id=' + e.currentTarget.dataset.id + '&live=' + live_status }) // console.log('options-->'); }, @@ -69,9 +98,9 @@ Page({ }, success: function (res) { // console.log('我发起了PUT请求,请求结果:', res.data); - if(res.data.code == 0) { - resolve(); - }; + if (res.data.code == 0) { + resolve(); + }; } }); }); @@ -208,88 +237,90 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - self=this; - getApp().is_Single_page(this,function(){ - app.isLogin().then(function(data) {//进入页面前已经授权登录成功 - self.setData({ + self = this; + getApp().is_Single_page(this, function () { + app.isLogin().then(function (data) {//进入页面前已经授权登录成功 + self.setData({ userInfo: data, }); }); }) - + + + getApp().request.promiseGet("/api/weshop/ad/page?pid=1207&store_id=" + os.stoid, { + data: { + enabled: 1 + } + }).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { + var a = res.data.data.pageData; + var narr = []; + for (var i in a) { + var tt = { + 'ad_code': os.imghost + a[i].ad_code, + 'media_link': '', + 'ad_weapplink': a[i].ad_weapplink + }; + narr.push(tt); + } + self.setData({ + ad_data: narr + }); + } + }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, + /** * 生命周期函数--监听页面显示 */ onShow: function () { - getApp().check_can_share(); - if(app.globalData.userInfo) { - if(!this.data.isLogin) { - this.setData({ - userInfo: app.globalData.userInfo, - imghost: app.globalData.setting.imghost, - isLogin: true, - }); - - this.updateLiveList().then(() => { - - self.getData(true, '/api/weshop/wx/livelist/page', { //请求直播中列表 - storedId: o.stoid, - live_status: 101, - pageSize: 100, - }).then((res) => { - self.setData({ - living: self.data.list, - }); - - - console.log(self.data.living); - - //直播中列表请求完后,请求即将开始列表 - self.getData(true, '/api/weshop/wx/livelist/page', { - storedId: o.stoid, - live_status: 102, - pageSize: 100, - }).then((res) => { - self.setData({ - livetoBegin: self.data.list, - }); - - //即将开始列表请求完后,请求结束列表 - self.getData(true, '/api/weshop/wx/livelist/page', { - storedId: o.stoid, - live_status: 103, - }).then((res) => { - self.setData({ - liveOver: self.data.list, - }); - }); - - - }); - - - }); - - - - - - }); - - - - }; - }; + getApp().check_can_share(); + if (app.globalData.userInfo) { + if (!this.data.isLogin) { + this.setData({ + userInfo: app.globalData.userInfo, + imghost: app.globalData.setting.imghost, + isLogin: true, + }); + + this.updateLiveList().then(() => { + + self.getData(true, '/api/weshop/wx/livelist/page', { //请求直播中列表 + storedId: o.stoid, + pageSize: 100, + ordertype: 1, + liveshow: 1 + }).then((res) => { + var list = self.data.list + for (var i in list.pageData) { + var share_img = list.pageData[i].share_img + list.pageData[i].share_img = share_img.replace("http://", 'https://') + } + self.setData({ + living: list, + }); + + }); + + + + + + }); + + + + }; + }; }, /** @@ -306,6 +337,340 @@ Page({ }, + + + // 分享操作表 + clickShare: function (e) { + var sharimg = e.currentTarget.dataset.sharimg + var shartitle = e.currentTarget.dataset.shartitle + var anchorname= e.currentTarget.dataset.anchorname + if (!getApp().globalData.user_id) { + getApp().goto("/packageE/pages/togoin/togoin"); + return false; + } + this.setData({ + showActionSheet: !this.data.showActionSheet, + sharimg: sharimg, + shartitle: shartitle, + anchorname:anchorname + }) + }, + + // actionSheet - 取消按钮 + hiddenActionSheet: function () { + this.setData({ + showActionSheet: 'false' + }) + if (!this.data.showPlaybill) { + this.setData({ + showPlaybill: 'true' + }); + } + }, + + // 获取图片信息 + getImageInfo(src) { + return new Promise((resolve, reject) => { + wx.getImageInfo({ + src: src, + success: (res) => { + resolve(res); + } + }) + }); + }, + + closeWin: function () { + this.setData({ + showPlaybill: 'true' + }); + }, + + //生成海报 + createPlaybill: function () { + // 1.提示 “正在生成海报...” + wx.showLoading({ + title: '正在生成海报...' + }); + + // 3.展示生成的海报 + this.setData({ + showActionSheet: 'false', + // showPlaybill: !this.data.showPlaybill + }); + + // 2.生成海报,如果生成完毕,关闭提示 + this.drawPlaybill(); + + }, + + + // 生成海报 + drawPlaybill: async function () { + + var that = this; + // wx.showLoading({ + // title: '正在生成海报...' + // }); + + + + + // 请求主图 + await that.getImageInfo(that.data.sharimg).then(res => { + that.setData({ + coverImg: res.path, + coverImgWidth: res.width, + coverImgHeight: res.height, + coverImgSize: that.imageResize(res.width, res.height), + // coverImgHeight: res.height, + }); + // console.log('主图加载成功~', that.data.coverImgSize); + }); + + + + + + var path2 = getApp().globalData.userInfo.head_pic; + if (path2 == "") { + path2 = "../../../images/share/hui_hear_pic.png"; + } else { + getApp().request.promiseGet("/api/weshop/marketing/help/help/imgbase64/get", { + data: { + imgurl: path2 + } + }).then(res => { + if (res.data.code == 0) { + console.log(9999) + + var imgSrc = res.data.data;//base64编码 + var save = wx.getFileSystemManager(); + var number = Math.random(); + save.writeFile({ + filePath: wx.env.USER_DATA_PATH + '/pic' + number + '.png', + data: imgSrc, + encoding: 'base64', + success: res => { + that.setData({ + avatarUrl: wx.env.USER_DATA_PATH + '/pic' + number + '.png' + }); + console.log(wx.env.USER_DATA_PATH + '/pic' + number + '.png') + }, fail: err => { + console.log(err) + } + }) + } + }) + } + + + // 请求二维码 + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + + os.stoid + "?sceneValue=1012" + "&pageValue=pages/goods/goodsInfo/goodsInfo"; + + if (!this.data.ewm) { + + await that.getImageInfo(path3).then(res => { + that.setData({ + ewm: res.path + }); + console.log('二维码加载成功~') + }); + } + + + + // 数据准备 + const title = this.data.shartitle; + // const headImg = app.globalData.userInfo['head_pic']; + + // console.log('----------------v', headImg); + + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + + os.stoid + "?sceneValue=1012" + "&pageValue=packageA/pages/liveStreamDetails/liveStreamDetails"; + + // 以iPhone6为例,375/750 = 0.5 + // let scale = this.data.windowWidth / 375; + let scale = this.data.screenWidth / 750 * 1.35 + + + // 适配屏get幕 + // let scale = this.data.windowWidth / 375.0; + // this.setData({totalHeight: 667 * scale}); + + // 获取Canvas + let ctx = wx.createCanvasContext('myCanvas'); + + // 放大 因为不放大的话,生成的分享图会模糊。暂时先注释 + // ctx.scale(this.data.canvasScale, this.data.canvasScale) + + + + // var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + + // os.stoid + "?sceneValue=1012" + "&pageValue=pages/goods/goodsInfo/goodsInfo"; + // + "?sceneValue=1012" + "&pageValue=packageA/pages/liveStreamDetails/liveStreamDetails" + // console.log('path3---->', path3); + + + // 绘制主背景白色 + ctx.setFillStyle('#ffffff'); + ctx.fillRect(0, 0, 480, 738); + + // 绘制头像 + ctx.save(); + ctx.beginPath(); + ctx.arc(58, 52, 28, 0, 2 * Math.PI); + ctx.clip(); + // console.log('1__________________>',app.globalData.userInfo['head_pic']); + ctx.drawImage(this.data.avatarUrl, 30, 24, 56, 56); + ctx.restore(); + + // 绘制昵称 + ctx.setFontSize(22); + ctx.setFillStyle('#ADADAD'); + ctx.fillText(app.globalData.userInfo.nickname, 106, 60); + + // 绘制主图 + ctx.setFillStyle('#f8f8f8'); + ctx.fillRect(0, 104, 480, 380); + + // var w = this.data.coverImgWidth; + // var h = this.data.coverImgHeight; + var w = this.data.coverImgSize.imageWidth; + var h = this.data.coverImgSize.imageHeight; + // var dw = 480/w //canvas与图片的宽高比 + // var dh = 380/h + // var ratio + // // 裁剪图片中间部分 + // if(w > 480 && h > 380 || w < 480 && h < 380){ + // if (dw > dh) { + // ctx.drawImage(this.data.coverImg, 0, (h - 380/dw)/2, w, 380/dw, 0, 104, 480, 380); + // } else { + // ctx.drawImage(this.data.coverImg, (w - 480/dh)/2, 0, 480/dh, h, 0, 104, 480, 380); + // }; + // } + // // 拉伸图片 + // else{ + // if(w < 300){ + // ctx.drawImage(this.data.coverImg, 0, (h - 380/dw)/2, w, 380/dw, 0, 104, 480, 380); + // }else { + // ctx.drawImage(this.data.coverImg, (w - 480/dh)/2, 0, 480/dh, h, 0, 104, 480, 380); + // } + // }; + ctx.drawImage(this.data.coverImg, (480 - w) / 2, (380 - h) / 2 + 104, w, h); + + + // 绘制文字 + ctx.setFontSize(24); + ctx.setFillStyle('#1E1E1E'); + this.drawText(ctx, title, 30, 600, 200, 460, 2); + + // 绘制小程序码 + ctx.drawImage(this.data.ewm, 310, 540, 132, 132); + + + //绘制文字:长按识别 + ctx.setFontSize(20); + ctx.setFillStyle('#1E1E1E'); + ctx.fillText('长按识别小程序', 309, 710); + + ctx.draw(true, function () { + setTimeout(function () { + // console.log("我进来了~~~~~"); + wx.canvasToTempFilePath({ + x: 0, + y: 0, + width: 750, + height: 1217, + destWidth: 750, + destHeight: 1217, + canvasId: 'myCanvas', + fileType: 'jpg', + success: function (res) { + wx.hideLoading(); + that.setData({ + canvasToImgPath: res.tempFilePath, + showPlaybill: !that.data.showPlaybill + }); + // console.log('生成海报陈宫啦', that.data.canvasToImgPath); + // that.saveImageToPhotosAlbum(res.tempFilePath); + // console.log('截图陈宫:', that.data.canvasToImgPath); + // wx.previewImage({ + // //将图片预览出来 + // urls: [that.data.canvasToImgPath] + // }); + } + }) + }, 1000) + }); + + + + }, + + + + imageResize(imgWidth, imgHeight) { + var imageSize = {}; + var originalWidth = imgWidth;//图片原始宽 + var originalHeight = imgHeight;//图片原始高 + var originalScale = originalHeight / originalWidth;//图片高宽比 + // console.log('originalWidth: ' + originalWidth) + // console.log('originalHeight: ' + originalHeight) + + //获取屏幕宽高 + var winWidth = 480; + var winHeight = 380; + var winScale = winHeight / winWidth;//屏幕高宽比 + // console.log('windowWidth: ' + winWidth) + // console.log('windowHeight: ' + winHeight) + if (originalScale < winScale) {//图片高宽比小于屏幕高宽比 + //图片缩放后的宽为屏幕宽 + imageSize.imageWidth = winWidth; + imageSize.imageHeight = (winWidth * originalHeight) / originalWidth; + } else {//图片高宽比大于屏幕高宽比 + //图片缩放后的高为屏幕高 + imageSize.imageHeight = winHeight; + imageSize.imageWidth = (winHeight * originalWidth) / originalHeight; + } + console.log('缩放后的宽: ' + imageSize.imageWidth) + console.log('缩放后的高: ' + imageSize.imageHeight) + return imageSize; + }, + + + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 + drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) { + var lineWidth = 0; + var lastSubStrIndex = 0; //每次开始截取的字符串的索引 + var han = 0; + for (let i = 0; i < str.length; i++) { + if (han == 2) return; + //lineWidth += ctx.measureText(str[i]).width; + lineWidth += ut.measureText(str[i], 21.3 * unit); + if (lineWidth > canvasWidth) { + han++; + + if (han == 2) { + ctx.textAlign = 'justify'; + ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 + } else { + ctx.textAlign = 'justify'; + ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); + } + initHeight += 35; //22为字体的高度 + lineWidth = 0; + lastSubStrIndex = i; + titleHeight += 20; + } + if (i == str.length - 1) { //绘制剩余部分 + ctx.textAlign = 'justify'; + ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); + } + } + }, + /** * 页面相关事件处理函数--监听用户下拉动作 */ @@ -343,108 +708,256 @@ Page({ // duration: 1000 // }) // } - - // console.log('触底啦'); - this.scrollToLower('/api/weshop/wx/livelist/page', { - storedId: o.stoid, - live_status: 103 - }); + + // console.log('触底啦'); + this.scrollToLower('/api/weshop/wx/livelist/page', { + storedId: o.stoid, + live_status: 103 + }); }, /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { getApp().globalData.no_clear=1; + * 用户点击右上角分享 + */ + onShareAppMessage: function (res) { + getApp().globalData.clear = 1; + this.setData({ + showActionSheet: 'false' + }) + var self = this; if (res.from === 'button') { // 来自页面内转发按钮 - // console.log(res.target) + console.log(res.target) } return { - title: '直播列表' - // path: '/page/user?id=123' + title: this.data.details.name, + success: function (res) { + console.log('res---->', res); + }, + complete: function (res) { + console.log('comple', res) + } } }, - onShareTimeline: function (res) { - getApp().globalData.no_clear=1; - var user_id=getApp().globalData.user_id; - if(!user_id) user_id=0; + onShareTimeline: function (res) { + getApp().globalData.no_clear = 1; + var user_id = getApp().globalData.user_id; + if (!user_id) user_id = 0; + + return { + title: '直播列表', + query: 'first_leader=' + user_id + } + }, + + + /** + * 请求数据 + */ + getData: function (isInit, url, data) { + let p = app.request.promiseGet(url, { + data: data, + isShowLoading: true, + }) + .then(function (res) { + if (res.data.code == 0) { + + self.setData({ + isLoading: false + }); + + if (isInit) {// 第一次加载 + self.setData({ + list: res.data.data + }); + } else { + self.setData({ + 'list.pageData': self.data.list.pageData.concat(res.data.data.pageData) + }); + }; + + if ((res.data.data.pageData.length == 0) || (res.data.data.pageSize * res.data.data.page >= res.data.data.total)) { + self.setData({ + noMore: true + }); + }; + + } else { + self.setData({ + 'list.pageData': [] + }); + }; + + }); + + return p; + }, + - return { - title: '直播列表', - query: 'first_leader='+user_id + // 保存图片到手机 + onSaveToPhone() { + var self = this; + // 获取用户的当前设置,返回值中有小程序已经向用户请求过的权限 + this.getSetting().then((res) => { + // 判断用户是否授权了保存到相册的权限,如果没有发起授权 + if (!res.authSetting['scope.writePhotosAlbum']) { + this.authorize().then(() => { + // 同意授权后保存下载文件 + this.saveImageToPhotosAlbum(self.data.canvasToImgPath) + }) + } else { + // 如果已经授权,保存下载文件 + this.saveImageToPhotosAlbum(self.data.canvasToImgPath) + } + }) + }, + + //打开设置,引导用户授权 + onOpenSetting() { + wx.openSetting({ + success: (res) => { + // console.log(res.authSetting) + } + }) + }, + + // 获取用户已经授予了哪些权限 + getSetting() { + return new Promise((resolve, reject) => { + wx.getSetting({ + success: res => { + resolve(res) + } + }) + }) + }, + + // 发起首次授权请求 + authorize() { + // isFirst 用来记录是否为首次发起授权, + // 如果首次授权拒绝后,isFirst赋值为1 + let isFirst = wx.getStorageSync('isFirst') || 0; + return new Promise((resolve, reject) => { + wx.authorize({ + scope: 'scope.writePhotosAlbum', + // 同意授权 + success: () => { + resolve(); + }, + // 拒绝授权,这里是用户拒绝授权后的回调 + fail: res => { + if (isFirst === 0) { + wx.setStorageSync('isFirst', 1); + wx.showToast({ + title: '保存失败', + icon: 'none', + duration: 1000 + }) + } else { + this.showModal(); + } + console.log('拒绝授权'); + reject(); + } + }) + }) + }, + + //保存下载文件 + savedownloadFile(img) { + this.downLoadFile(img).then((res) => { + return this.saveImageToPhotosAlbum(res.tempFilePath) + }).then(() => { + // resolve() + }) + }, + + //单文件下载(下载文件资源到本地),客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径。 + downLoadFile(img) { + var self = this; + return new Promise((resolve, reject) => { + wx.showLoading({ + title: '保存中...', + mask: true, + }); + wx.downloadFile({ + url: img, + success: (res) => { + resolve(res); + } + }) + }) + }, + + // 保存图片到系统相册 + saveImageToPhotosAlbum(saveUrl) { + var self = this; + return new Promise((resolve, reject) => { + wx.saveImageToPhotosAlbum({ + filePath: saveUrl, + success: (res) => { + wx.showToast({ + title: '保存成功', + duration: 1000, + }); + self.setData({ + showPlaybill: 'true' + }); + resolve(); + }, + fail: () => { + wx.showToast({ + title: '保存失败', + duration: 1000, + }); } - }, - - - /** - * 请求数据 - */ - getData: function(isInit, url, data) { - let p = app.request.promiseGet(url, { - data: data, - isShowLoading: true, - }) - .then(function(res) { - if(res.data.code == 0) { - - self.setData({ - isLoading: false - }); - - if(isInit) {// 第一次加载 - self.setData({ - list: res.data.data - }); - } else { - self.setData({ - 'list.pageData': self.data.list.pageData.concat(res.data.data.pageData) - }); - }; - - if((res.data.data.pageData.length == 0) || (res.data.data.pageSize * res.data.data.page >= res.data.data.total)) { - self.setData({ - noMore: true - }); - }; - - } else { - self.setData({ - 'list.pageData': [] - }); - }; - - }); - - return p; - }, - - - /** - * 上拉加载 - */ - scrollToLower(url, requestData) { - // 数据总量 - let total = this.data.list.total; - // 单页最大数据量 - let pageSize = this.data.list.pageSize; - // 如果数据总量不为0且小于或等于单页最大数据量,说明数据已全部加载,显示‘没有更多了’ - if((total != 0)&&(total <= pageSize)) { - this.setData({ - noMore: true - }); - }; - - if(!this.data.isLoading && !this.data.noMore) { - this.setData({ - isLoading: true, - pageNum: this.data.pageNum + 1 - }); - requestData.page = this.data.pageNum; - this.getData(false, url, requestData); - }; - }, - - + }) + }) + }, + + + // 弹出模态框提示用户是否要去设置页授权 + showModal() { + wx.showModal({ + title: '检测到您没有打开保存到相册的权限,是否前往设置打开?', + success: (res) => { + if (res.confirm) { + console.log('用户点击确定') + this.onOpenSetting() // 打开设置页面 + } else if (res.cancel) { + console.log('用户点击取消') + } + } + }) + }, + + + /** + * 上拉加载 + */ + scrollToLower(url, requestData) { + // 数据总量 + let total = this.data.list.total; + // 单页最大数据量 + let pageSize = this.data.list.pageSize; + // 如果数据总量不为0且小于或等于单页最大数据量,说明数据已全部加载,显示‘没有更多了’ + if ((total != 0) && (total <= pageSize)) { + this.setData({ + noMore: true + }); + }; + + if (!this.data.isLoading && !this.data.noMore) { + this.setData({ + isLoading: true, + pageNum: this.data.pageNum + 1 + }); + requestData.page = this.data.pageNum; + this.getData(false, url, requestData); + }; + }, + + }) \ No newline at end of file diff --git a/packageA/pages/liveStream/liveStream.wxml b/packageA/pages/liveStream/liveStream.wxml index e762f12..ed5c088 100644 --- a/packageA/pages/liveStream/liveStream.wxml +++ b/packageA/pages/liveStream/liveStream.wxml @@ -1,8 +1,8 @@ - - + + - - - 直播中 - - - - - - - - - {{item.name}} - {{filter.format_time(item.start_time, 2)}} 开始 - 主播:{{item['anchor_name']}} - - 观看直播 - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 正在直播 + 即将开播 + 回放 + 已失效 + + + + 小程序直播 + + + + + + + {{item.name}} + + + + {{item['anchor_name']}} + + + + + 分享 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packageA/pages/liveStream/liveStream.wxss b/packageA/pages/liveStream/liveStream.wxss index 5e8c15f..0da53f1 100644 --- a/packageA/pages/liveStream/liveStream.wxss +++ b/packageA/pages/liveStream/liveStream.wxss @@ -1,18 +1,41 @@ /* pages/liveStream/liveStream.wxss */ +page{ + background-color: #eee; +} .title { font-size: 30rpx; padding: 50rpx 32rpx; } .list-item { - padding: 0 32rpx 30rpx; display: flex; } .list-item-left { position: relative; - width: 340rpx; - height: 220rpx; flex-shrink: 0; } + +.xcx-image { + width: 20rpx; + height: 20rpx; + margin-left: 18rpx; + margin-top: 8rpx; + background-size:contain; + background-repeat: no-repeat; + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkAgMAAAANjH3HAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAlQTFRFPcRKAAAA////QjSLrQAAAAN0Uk5T/wD/aewfvgAAATZJREFUeJzt1MFxBSEIANDfRErTAyXQj+nAg1T58wVUEDObnfxLJl52xrcKKvr4SIf2OMG/vF0yUY2FvlqJBF9CgeQOPJ8VYGm7kLTiJatUL3AUVCEvdEGKlTylXhXgPlmrl8ZDAymciBOUbcZImo69Knoy+YakSMr3Es52W8L1lLniSPYdFQlOQQTsmdYp9rSRhoCpHeh/cQ8aoUVMJUo2XbIR9NJU5LcusN6FvEkRgU2SCNISRwqVRWt8ZKB3e+Sp6+lDhrQ096CqjGz4k+e7M2KOqlqlhoLLKe+STtJuSP1V+XEGIJLD3TlLSXqhVnn1fKZll4xIwQcij5cTfurGmXshLSAjeJTxtK/LcZKcjNe4eUlRmHmzfBgWCMLMG+zDiOA+mci2NVPQR5nvjkt5kb39NXkCPTYQh7BBvFgAAAAASUVORK5CYII= + + ) ; +} + +.share-image { + width: 30rpx; + height: 30rpx; + margin-left: 18rpx; + margin-top: 8rpx; + background-size:contain; + background-repeat: no-repeat; + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkBAMAAACCzIhnAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAACFQTFRFAAAA/04w/04w/04w/04w/04w/0ww/0Aw/0AA/00w/04wncLKIgAAAAt0Uk5TAP8/LxsOQBAE4ZBG21G1AAABIUlEQVR4nO3W2w3CMAwF0AYEEnzRDRiBEViFERiBzUEg+vK913ZFEUjxRyWanDqP4rRpatT4YpR2EIdlyAg8YhEyFQEyFT4xSfzp55M0qh++X4QoeJRqLKRJTZg8Tk14LrGtclkpYVN5bzK4jQndW7pg/A1iRLxChJQ0ka92hIBGQ/S/ARGyH4rgKShSZA5BeAWwrZ5gRFWZjxBP2A5uEkKUwESXWEPccZke/rj+gRw74pxJPTl1RIsBOXe/TacyStyTTZ6sn9cLIJPB9mT1vF4JOSDyilue7PJknydbsJMOQV8HHgFRSSW/TwKlzvSZR+LlMUpMZZ9J/OM0R+yp7n2yoHaHtGAYbSRQ5owIpcETzIhAGroqGeEYvfwJUGOZuAN2OElDEXSpWQAAAABJRU5ErkJggg== + ) ; +} .list-item-right { display: flex; flex-direction: column; @@ -21,11 +44,54 @@ /* position: relative; padding-bottom: 70rpx; */ } + +.share-actionSheet { + background-color: white; + padding-top: 45rpx; + position: fixed; + width: 100%; + bottom: 0; + z-index: 2; +} +.share-actionSheet-title { + font-size: 38rpx; + +} +.share-actionSheet-list { + display: flex; + justify-content: space-around; + padding-bottom: 30rpx; +} +.share-actionSheet-item { + text-align: center; + padding: 20rpx; +} +.share-actionSheet-pic { + display: block; + width: 118rpx; + height: 118rpx; + border-radius: 50%; + margin: 0 auto; +} +.share-actionSheet-desc { + font-size: 28rpx; +} + +.share-actionSheet-title, +.share-actionSheet-cancle { + text-align: center; +} + +.share-actionSheet-cancle { + padding: 30rpx 0; + border-top: 2rpx solid #CBCBCB; +} .item-pic { /* width: 400rpx; */ width: 100%; height: 100%; background-color: #eee; + border-radius: 15rpx; } .item-desc { position: absolute; @@ -55,7 +121,7 @@ display: -webkit-box; -webkit-box-orient: vertical; - -webkit-line-clamp: 2; + -webkit-line-clamp: 1; overflow: hidden; } .item-time { @@ -66,6 +132,12 @@ .item-anchor { color: #999; font-size: 24rpx; + text-align: justify; + + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 1; + overflow: hidden; } .item-btn { @@ -76,7 +148,81 @@ color: #fff; font-size: 24rpx; text-align: center; + position: absolute;top: 15rpx;left: 7px; + border-radius: 15rpx; +} +.item-btnhf { + width: 172rpx; + height: 56rpx; + line-height: 56rpx; + background-color: #acacac; + color: #fff; + font-size: 24rpx; + text-align: center; + position: absolute;top: 15rpx;left: 7px; + border-radius: 15rpx; } +.item-btnjjkb { + width: 172rpx; + height: 56rpx; + line-height: 56rpx; + background-color: rgb(250, 182, 36); + color: #fff; + font-size: 24rpx; + text-align: center; + position: absolute;top: 15rpx;left: 7px; + border-radius: 15rpx; +} + + +.item-btnld { + width: 202rpx; + height: 56rpx; + line-height: 56rpx; + background-color: #c9c9c9; + font-size: 24rpx; + text-align: center; + position: absolute; + bottom: 12rpx; + border-top-right-radius: 15rpx; + overflow: hidden; + opacity: 0.3; +} +.item-btnldt { + width: 202rpx; + height: 56rpx; + line-height: 56rpx; + color: white; + font-size: 24rpx; + text-align: center; + position: absolute; + bottom: 12rpx; + overflow: hidden; + margin-left: 20rpx; +} + +.item-btnxcx { + width: 32rpx; + height: 32rpx; + line-height: 56rpx; + color: rgb(233, 233, 233); + font-size: 24rpx; + left: 0; + bottom: 22rpx; + position: absolute; + overflow: hidden; + +} + +.content { + background-color: white; + padding-bottom: 168rpx; + position: relative; +} +button::after { + border: none; +} + subscribe { position: relative; } @@ -108,4 +254,53 @@ subscribe { line-height: 3; color: #909090; text-align: center; -} \ No newline at end of file +} + +.share-actionSheet.active ~ .mask, + +.mask { + display: none; + background-color: rgba(0,0,0,.7); + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; +} +.playbill { + position: fixed; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + z-index: 9999; + background: none; +} +.share-actionSheet.active ~ .mask, +.playbill.active ~ .mask { + display: block; +} +.playbill-pic { + display: block; + width: 560rpx; + height: auto; + margin: 0 auto 26rpx; + border-radius: 10rpx; + overflow: hidden; +} + +.playbill-save { + width: 560rpx; + height: 100rpx; + line-height: 100rpx; + background-color: #f23030; + color: #fff; + font-size: 36rpx; + text-align: center; + margin: 0 auto; +} +.playbill-save image { + width: 44rpx; + height: 36rpx; + margin-right: 23rpx; +} + diff --git a/packageA/pages/liveStreamDetails/liveStreamDetails.js b/packageA/pages/liveStreamDetails/liveStreamDetails.js index 8ac2e74..c5bcc82 100644 --- a/packageA/pages/liveStreamDetails/liveStreamDetails.js +++ b/packageA/pages/liveStreamDetails/liveStreamDetails.js @@ -157,7 +157,7 @@ drawText: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, un // }); - if(!this.data.coverImg) { + // 请求主图 await that.getImageInfo(that.data.details['share_img']).then(res => { @@ -170,18 +170,49 @@ drawText: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, un }); // console.log('主图加载成功~', that.data.coverImgSize); }); + + + var path2 = getApp().globalData.userInfo.head_pic; + if (path2 == "") { + path2 = "../../../images/share/hui_hear_pic.png"; + } else { + getApp().request.promiseGet("/api/weshop/marketing/help/help/imgbase64/get", { + data: { + imgurl: path2 + } + }).then(res => { + if (res.data.code == 0) { + console.log(9999) + + var imgSrc = res.data.data;//base64编码 + var save = wx.getFileSystemManager(); + var number = Math.random(); + save.writeFile({ + filePath: wx.env.USER_DATA_PATH + '/pic' + number + '.png', + data: imgSrc, + encoding: 'base64', + success: res => { + that.setData({ + avatarUrl: wx.env.USER_DATA_PATH + '/pic' + number + '.png' + }); + console.log(wx.env.USER_DATA_PATH + '/pic' + number + '.png') + }, fail: err => { + console.log(err) + } + }) + } + }) } - - if(!this.data.avatarUrl) { + // if(!this.data.avatarUrl) { // 请求头像 - await that.getImageInfo(app.globalData.userInfo['head_pic']).then(res => { - that.setData({ - avatarUrl: res.path - }); - console.log('头像加载成功~') - }); - } + // await that.getImageInfo(app.globalData.userInfo['head_pic']).then(res => { + // that.setData({ + // avatarUrl: res.path + // }); + // console.log('头像加载成功~') + // }); + // } // 请求二维码 var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + @@ -530,7 +561,7 @@ drawText: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, un switch(options.live) { case 'toBegin': { this.setData({ - btnText: '订阅' + btnText: '即将开播' }) break; } diff --git a/packageC/pages/group_list/group_list.js b/packageC/pages/group_list/group_list.js index 2a4cffc..43c6bbf 100644 --- a/packageC/pages/group_list/group_list.js +++ b/packageC/pages/group_list/group_list.js @@ -14,10 +14,12 @@ Page({ // goodlist: null, isLogin: false, - list: null, + list: [], isLoading: false, // 检测是否已经发送请求,防止重复发送请求 noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 pageNum: 1, // 当前页数 + + time_arr:[] }, /** @@ -63,7 +65,7 @@ Page({ }; this.setData({ - list: null, + list: [], pageNum: 1, noMore: false, }); @@ -110,7 +112,7 @@ Page({ this.setData({ - list: null, + list: [], type: typeValue, }); @@ -141,6 +143,9 @@ Page({ * 页面上拉触底事件的处理函数 */ onReachBottom: function () { + + if(this.data.isLoading) return false; + let data = this.data.currentData; this.scrollToLower('/api/weshop/goods/groupBuy/page', data); }, @@ -148,47 +153,48 @@ Page({ /** * 用户点击右上角分享 */ - onShareAppMessage: function () { getApp().globalData.no_clear=1 - - }, + onShareAppMessage: function () { getApp().globalData.no_clear=1; }, /** * 请求数据 */ getData: function(isInit, url, data) { + + wx.showLoading(); + let p = app.request.promiseGet(url, { data: data, - isShowLoading: true, + isShowLoading: false, }) .then(function(res) { - if(res.data.code == 0) { - + + + + if(ut.ajax_ok(res)) { + self.setData({ - isLoading: false - }); + ['list['+(self.data.pageNum-1)+']']:res.data.data.pageData + }) - if(isInit) {// 第一次加载 - self.setData({ - list: res.data.data - }); - } else { - self.setData({ - 'list.pageData': self.data.list.pageData.concat(res.data.data.pageData) - }); - }; - - if((res.data.data.pageData.length == 0) || (res.data.data.pageSize * res.data.data.page >= res.data.data.total)) { + if(res.data.data.pageSize * res.data.data.page >= res.data.data.total){ self.setData({ noMore: true }); }; + + } else { - self.setData({ - 'list.pageData': [] - }); + self.setData({ noMore: true }); }; + + self.setData({ + isLoading: false, + is_get:1 + }); + + wx.hideLoading(); }); @@ -218,6 +224,7 @@ Page({ }); requestData.page = this.data.pageNum; this.getData(false, url, requestData); + }; }, @@ -229,38 +236,64 @@ Page({ //----倒计时函数----- - countDown() { - if(!this.data.is_timer) return false; - var th=this; - // 获取当前时间,同时得到活动结束时间数组 - let newTime = ut.gettimestamp(); - var endTimeList = this.data.list.pageData; - if(endTimeList == null) return null; - // 对结束时间进行处理渲染到页面 - for(var i = 0; i < endTimeList.length; i++) { - var o = endTimeList[i]; - var endTime = this.data.type == 1?o.end_time:o.start_time; - // if(th.data.type==0) endTime = o.start_time; - let obj = null; - // 如果活动未结束,对时间进行处理 - if (endTime - newTime > 0) { - let time = (endTime - newTime); - // 获取天、时、分、秒 - let day = parseInt(time / (60 * 60 * 24)); - let hou = parseInt(time % (60 * 60 * 24) / 3600); - let min = parseInt(time % (60 * 60 * 24) % 3600 / 60); - let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); - obj = { - day: this.timeFormat(day), hou: this.timeFormat(hou), min: this.timeFormat(min), sec: this.timeFormat(sec), hide: 1 - } - } else { - //活动已结束,全部设置为'00' - obj = { day: '00', hou: '00', min: '00', sec: '00' } - } - var txt ="goodlist["+i+"].djs"; - th.setData({ [txt]: obj}); - } - }, + countDown() { + + if (!this.data.is_timer) return false; + var th = this; + // 获取当前时间,同时得到活动结束时间数组 + let newTime = ut.gettimestamp(); + + + var time_arr=[]; + + for (let j = 0; j < this.data.list.length; j++) { + var endTimeList = this.data.list[j]; + if (endTimeList == null) return null; + + var arr_new=[]; + + // 对结束时间进行处理渲染到页面 + for (var i = 0; i < endTimeList.length; i++) { + + var o = endTimeList[i]; + var endTime = this.data.type == 1 ? o.end_time : o.start_time; + // if(th.data.type==0) endTime = o.start_time; + let obj = null; + // 如果活动未结束,对时间进行处理 + if (endTime - newTime > 0) { + let time = (endTime - newTime); + // 获取天、时、分、秒 + let day = parseInt(time / (60 * 60 * 24)); + let hou = parseInt(time % (60 * 60 * 24) / 3600); + let min = parseInt(time % (60 * 60 * 24) % 3600 / 60); + let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); + obj = { + day: this.timeFormat(day), + hou: this.timeFormat(hou), + min: this.timeFormat(min), + sec: this.timeFormat(sec), + hide: 1 + } + } else { + //活动已结束,全部设置为'00' + obj = {day: '00', hou: '00', min: '00', sec: '00'} + } + //var txt = "goodlist[" + i + "].djs"; + //th.setData({[txt]: obj}); + + var e={djs:obj}; + arr_new.push(e); + + } + + time_arr.push(arr_new); + + + } + + this.setData({time_arr:time_arr}); + + }, diff --git a/packageC/pages/group_list/group_list.wxml b/packageC/pages/group_list/group_list.wxml index 92526d1..daa82b6 100644 --- a/packageC/pages/group_list/group_list.wxml +++ b/packageC/pages/group_list/group_list.wxml @@ -1,9 +1,13 @@ - - + + + + + + + data-errorimg="list[{{p_idx}}][{{index}}].original_img" binderror="bind_bnerr2" lazy-load="true"> @@ -24,7 +28,9 @@ 已售{{item.buy_num+item.virtual_num}}0 - {{goodlist[index].djs.day}}天{{goodlist[index].djs.hou}}时{{goodlist[index].djs.min}}分{{goodlist[index].djs.sec}}秒 + + {{time_arr[p_idx][index].djs.day}}天{{time_arr[p_idx][index].djs.hou}}时{{time_arr[p_idx][index].djs.min}}分{{time_arr[p_idx][index].djs.sec}}秒 + @@ -35,24 +41,11 @@ - + - - + + - - \ No newline at end of file diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral.wxml b/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral.wxml deleted file mode 100644 index 383f797..0000000 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral.wxml +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - {{data.goods_name}} - - - {{prom_integral}}积分 - + - {{prom_price}}元 - 0积分 - - - - - - 已售:{{prom_act.buy_num}} - 可售:{{prom_act.limitqty-prom_act.buy_num}} - - - - - - - - - {{def_pick_store.pickup_name}} - - 距离:{{def_pick_store.distance>1000?filters.toFix(def_pick_store.distance/1000,2)+"km":filters.toFix(def_pick_store.distance,0)+"m"}} - - - - - - - - 选择门店 - - - - - (库存不足) - - (库存不足) - - (配送不匹配) - (库存不足) - - - - 地址:{{def_pick_store.fulladdress}} - - - - - - - - - - 购买数量 - - - - - + - - - - - - - - - 配送不匹配 - - - - - - - 库存不足 - - - - - - 库存不足 - - - - 库存不足 - - - - 请先选择门店 - - - - 库存不足 - - - 立即兑换 - - - - - - - - - - - - - \ No newline at end of file diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral_normal.wxml b/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral_normal.wxml deleted file mode 100644 index 24db585..0000000 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral_normal.wxml +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - {{sele_g.goods_name}} - - - - {{sele_g[card_field]}} - {{sele_g.shop_price}} - - - - 已售:{{sele_g.sales_sum}} - - 可售:{{def_pick_store.CanOutQty}} - 可售:0 - - 可售:{{sele_g.store_count}} - - - - - - - - - - {{def_pick_store.pickup_name}} - - 距离:{{def_pick_store.distance>1000?filters.toFix(def_pick_store.distance/1000,2)+"km":filters.toFix(def_pick_store.distance,0)+"m"}} - - - - - - - - 选择门店 - - - - - (库存不足) - - (库存不足) - - (配送不匹配) - (库存不足) - - - 地址:{{def_pick_store.fulladdress}} - - - - - - - - - - 购买数量 - - - - - + - - - - - - - - 再买{{hui_condition.need}} - ,免{{hui_condition.money}}元 - ,打{{hui_condition.sale}}折 - ,包邮 - ,送{{hui_condition.intValue}}积分 - ,送优惠券 - ,送赠品 - ,送礼包 - ,送专享礼包 - - - - - - - - - - 配送不匹配 - - - - - 库存不足 - - - - - - 库存不足 - - - - 库存不足 - - - - 请先选择门店 - - - - 库存不足 - - - - 加入购物车 - 立即购买 - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js index 53d4f8f..33be4f1 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js @@ -4066,8 +4066,6 @@ Page({ // ind == 1 为普通购买 openSpecModel_pt: function (e) { - - this.setData({ open_ind_store: 9, goodsInputNum: 1 }); // 判断是否有待支付订单 var aid = this.data.group_id; @@ -4190,7 +4188,9 @@ Page({ // } // }); + th.data.prom_type=9; + th.get_sto(); th.setData({ is_normal: 0, @@ -4809,12 +4809,16 @@ Page({ context.setTextAlign('left'); context.fillText('强烈推荐', 64 * unit, 672 * unit); // 7.商品价格 - let price = '¥' + this.data.data.shop_price; - // if (th.data.prom_act) - // pri0 = th.data.prom_act.price; + let price = '¥' + parseFloat( this.data.luckGoInfo.group_price/100).toFixed(2); context.setFontSize(32 * unit); context.setFillStyle('#DE1117'); context.fillText(price, 54 * unit, 730 * unit); + + //-- 零售价的优化 -- + var wp= 60 * unit+ut.measureText( price, 32 * unit); + var hp=730 * unit + this.draw_pos_price(context,wp,hp,this.data.data.market_price,unit); + // 8.商品标题 context.setFontSize(20 * unit); context.setFillStyle('#898989'); @@ -4835,6 +4839,29 @@ Page({ + //---市场价划掉--- + draw_pos_price(context,w,h,market_price,unit){ + + if(!this.data.sys_switch) return false; + if(!this.data.sys_switch.is_retail_price) return false; + + + context.setFillStyle("gray") + context.setFontSize(22 * unit) + var pri0 = "¥" + market_price; + context.fillText(pri0, w, h); + + var c_h=h-6; + context.setStrokeStyle('gray'); + context.setLineWidth(1 * unit); + context.moveTo(w - 5, c_h); + context.lineTo(w + ut.measureText(pri0, 22 * unit) + 5, c_h); + context.stroke(); + + }, + + + //--定义的保存图片方法,分享团--- saveImageToPhotosAlbum: function () { //--先判断会员状态-- @@ -4851,8 +4878,8 @@ Page({ //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 9幸运购 var type = 9; - console.log('type', type); - if (type == 6) type = 2; + var th=this; + if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; wx.showLoading({ title: '生成中...', }) @@ -4882,8 +4909,6 @@ Page({ ///二微码 var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + os.stoid + "?sceneValue=" + scene + "&pageValue=packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo"; - // var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + - // os.stoid + "?sceneValue=" + scene + "&pageValue=packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo"; console.log('path3......', path3); @@ -4899,14 +4924,6 @@ Page({ // 先画背景 var pg_path = "../../../../images/share/share_bg.png"; - // context.fillStyle="#FFFFFF"; - // context.fillRect(0,0,554 * unit, 899 * unit); - - // if(type == 0) { - // this.drawPoster(context); - // return false; - // }; - //-- 如果有自定义海报的时候,判断背景的图片 -- if (th.data.share_b_img) { @@ -4915,17 +4932,17 @@ Page({ // context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); - if (!th.data.share_b_img && (type == 9)) { // 如果是普通商品,绘制新海报 + if (!th.data.share_b_img) { // 如果是普通商品,绘制新海报 th.drawPoster(context, unit, th.data.share_goods_img, vpath); } else { context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); }; - // th.drawPoster(context, unit, th.data.share_goods_img, vpath); + //-- 是自定义海报的情况下 -- - if (th.data.share_b_img || type != 0) { + if (th.data.share_b_img ) { @@ -4973,28 +4990,22 @@ Page({ // context.setFillStyle("#7f7f7f") // context.setFontSize(21.3 * unit) // context.fillText("向您发出幸运购邀请", 152 * unit, 90 * unit); - } - - }; + } var share_title = th.data.data.goods_name; - if (th.data.prom_type == 1 || th.data.prom_type == 6 || th.data.prom_type == 4) { - share_title = th.data.prom_act.share_title; - if (!share_title) share_title = th.data.prom_act.title; - if (th.data.prom_type == 4) share_title = th.data.prom_act.name; - } - //---产品名称--- //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - if (th.data.share_b_img || (type != 4 && type != 9)) { + if (th.data.share_b_img ) { context.setFillStyle("black"); context.setFontSize(21.3 * unit) - th.draw_Text(context, share_title, + getApp().draw_Text(context, share_title, 38 * unit, 180 * unit, 220 * unit, 220 * unit, unit); + + //------产品的价格------- context.setFontSize(23 * unit) context.setFillStyle("red") @@ -5018,276 +5029,49 @@ Page({ context.fillText('参团价', 330 * unit, 179 * unit); //---市场价划掉--- - context.setFillStyle("gray") - context.setFontSize(22 * unit) - pri0 = "零售价:¥" + th.data.data.market_price.toFixed(2); - var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; - context.fillText(pri0, wd2, 213 * unit); - - context.setStrokeStyle('gray'); - context.setLineWidth(1 * unit); - context.moveTo(wd2 - 5, 206 * unit); - context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); - context.stroke(); - - } else if (type == 4 && type != 0) { - context.setFillStyle("black"); - context.setFontSize(21.3 * unit) - th.draw_Text(context, share_title, - 38 * unit, 170 * unit, 20 * unit, 300 * unit, unit); - //------ 产品的价格 ----- - var pri0 = th.data.prom_act.addmoney; - var integral = th.data.prom_act.integral; - var text = ""; - if (integral) { text = integral + "积分"; } - if (pri0 && integral) { text += "+"; } - if (pri0) { text += "¥" + pri0; } - - if (!pri0 && !integral) { text = "0积分"; } - context.setFillStyle("red"); - context.fillText(text, 38 * unit, 235 * unit); + // context.setFillStyle("gray") + // context.setFontSize(22 * unit) + pri0 = "零售价:¥" + th.data.data.market_price.toFixed(2); + var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; + + // context.fillText(pri0, wd2, 213 * unit); + // context.setStrokeStyle('gray'); + // context.setLineWidth(1 * unit); + // context.moveTo(wd2 - 5, 206 * unit); + // context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); + // context.stroke(); + + th.draw_pos_price(context,wd2, 213 * unit,pri0,unit); } //---中间大图--- - if ( th.data.share_b_img || type != 9) { - context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); + if ( th.data.share_b_img ) { + context.drawImage(th.data.share_goods_img, 70 * unit, 245 * unit, 408 * unit, 408 * unit); }; //---自定义海报 产品质量保证 if(th.data.share_b_img && th.data.poster.show_quality==1 ){ var g_path = "../../../../images/share/s_gou.png"; - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); + context.drawImage(g_path, 56 * unit, 650 * unit, 22 * unit, 22 * unit); context.setFillStyle("red") context.setFontSize(18 * unit) - context.fillText("正品保证", 84 * unit, 690 * unit); + context.fillText("正品保证", 84 * unit, 670 * unit); - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); + context.drawImage(g_path, 218 * unit, 650 * unit, 22 * unit, 22 * unit); context.setFillStyle("red") context.setFontSize(18 * unit) - context.fillText("纯实体店", 246 * unit, 690 * unit); + context.fillText("纯实体店", 246 * unit, 670 * unit); - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); + context.drawImage(g_path, 388 * unit, 650 * unit, 22 * unit, 22 * unit); context.setFillStyle("red") context.setFontSize(18 * unit) - context.fillText("官方验证", 420 * unit, 690 * unit); + context.fillText("官方验证", 420 * unit, 670 * unit); } //-------大图后面就不一样了----------- switch (type) { - case 0: break;//普通商品的展示 - case 4: - //中间的几个字 - if (th.data.poster && parseInt(th.data.poster.style) == 2) { - if (parseInt(th.data.poster.show_quality)) { - var g_path = "../../../../images/share/s_gou.png"; - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("正品保证", 84 * unit, 690 * unit); - - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("纯实体店", 246 * unit, 690 * unit); - - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("官方验证", 420 * unit, 690 * unit); - } - - } else { - var g_path = "../../../../images/share/s_gou.png"; - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("正品保证", 84 * unit, 690 * unit); - - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("纯实体店", 246 * unit, 690 * unit); - - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("官方验证", 420 * unit, 690 * unit); - } - - - //---画线--- - context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 710 * unit) - context.lineTo(520 * unit, 710 * unit) - context.stroke(); - - //---文字--- - context.setFillStyle("black") - context.setFontSize(22 * unit) - - if (type == 0) { - // 原来start ---> - context.setFontSize(24 * unit) - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); - - context.setFontSize(22 * unit) - context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 806 * unit); - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit); - - } else { - context.setFontSize(24 * unit) - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); - context.setFontSize(22 * unit) - context.fillText("长按识别二维码", 40 * unit, 806 * unit); - context.fillText("立即开始兑换", 40 * unit, 846 * unit); - - } - - //---二维吗图--- - //-- 自定义海报 -- - if (th.data.poster) { - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); - } else { - //---二维吗图--- - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); - }; - - break; - case 1: //秒杀商品的展示 - //---画线--- - context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 670 * unit) - context.lineTo(520 * unit, 670 * unit) - context.stroke(); - - //画秒杀的图片 - var miaos_path = '../../../../images/share/miao_share.png'; - context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit); - - context.setFillStyle("black") - context.setFontSize(24 * unit) - context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit); - //---文字--- - context.setFontSize(22 * unit) - context.setFillStyle("black") - context.fillText("特惠好物,限时秒杀", 40 * unit, 826 * unit); - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit); - - - //---二维吗图--- - //-- 自定义海报 -- - if (th.data.poster) { - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; - context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit); - } else { - //---二维吗图--- - context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit); - } - break; - - case 2: //会员团和商家团的展示 - //---画线--- - context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 670 * unit) - context.lineTo(520 * unit, 670 * unit) - context.stroke(); - //---文字--- - context.setFillStyle("black") - context.setFontSize(24 * unit) - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); - - //绘制成团图片 - var ct_img = "../../../../images/share/ct_num.png"; - context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); - var ct_num = th.data.prom_act.ct_num; - context.setFontSize(14 * unit) - context.font = 'normal'; - context.setFillStyle("red") - if (ct_num < 10) { - context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit); - } else { - context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit); - } - context.setFontSize(22 * unit) - context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit); - - context.setFillStyle("gray") - context.fillText("快来和我一起拼团吧!", 40 * unit, 806 * unit); - context.setFillStyle("black") - context.font = 'normal bold 18px sans-serif'; - context.setFontSize(21.3 * unit) - context.fillText("长按识别二维码,立即参团", 40 * unit, 836 * unit); - - - //---二维吗图--- - //-- 自定义海报 -- - if (th.data.poster) { - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); - } else { - //---二维吗图--- - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); - } - break - case 3: //阶梯团的展示 - //---画线--- - context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 670 * unit) - context.lineTo(520 * unit, 670 * unit) - context.stroke(); - //---文字--- - context.setFillStyle("black") - context.setFontSize(24 * unit) - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); - - //---绘制中间阶梯的价格--- - var list = th.data.prom_act.ct_rylist; - for (var i = 0; i < list.length; i++) { - var item = list[i]; - var wi = i * 90 * unit; - context.font = 'normal'; - context.setFontSize(16 * unit) - context.setFillStyle("red") - context.fillText("¥", 40 * unit + wi, 756 * unit); - context.setFontSize(22 * unit) - var pri = parseFloat(item.price).toFixed(2); - context.fillText(pri, 56 * unit + wi, 756 * unit); - context.setFillStyle("gray") - context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit); - } - //----------------下面部分---------------- - // context.setFillStyle("gray") - // context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit); - // context.setFillStyle("black") - // context.font = 'normal bold 18px sans-serif'; - // context.setFontSize(22 * unit) - // context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit); - //context.setFillStyle("gray") - context.setFillStyle("black") - context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit); - //context.font = 'normal bold 18px sans-serif'; - context.setFontSize(21 * unit) - context.fillText("长按识别二维码,立即参团", 40 * unit, 850 * unit); - - - //-- 自定义海报 -- - if (th.data.poster) { - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); - } else { - //---二维吗图--- - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); - } - break; - - case 9: if(th.data.share_b_img){ @@ -5363,12 +5147,11 @@ Page({ break; - } //--- 如果是自定义海报的时候 --- - if ( th.data.share_b_img || type != 9) { + if ( th.data.share_b_img ) { if (th.data.poster && parseInt(th.data.poster.style) == 2) { @@ -5413,6 +5196,14 @@ Page({ }; + if(th.data.poster.show_time==1){ + var act_time = ''; + act_time="截止时间:"+ ut.formatTime(th.data.luckGoInfo.end_time); + context.setFillStyle("red") + getApp().draw_Text(context, act_time, 38 * unit, 880 * unit, 200 * unit, 340 * unit, unit); + } + + //把画板内容绘制成图片,并回调 画板图片路径 context.draw(false, function () { @@ -5464,35 +5255,6 @@ Page({ }); }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - var han = 0; - for (let i = 0; i < str.length; i++) { - if (han == 2) return; - //lineWidth += ctx.measureText(str[i]).width; - lineWidth += ut.measureText(str[i], 21.3 * unit); - if (lineWidth > canvasWidth) { - han++; - - if (han == 2) - ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 - else - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); - - initHeight += 22; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - titleHeight += 20; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - }, - // ----视频图片---- // 图片计数器 swiperChange: function (e) { diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml index 007e47b..5dbbfe7 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml @@ -113,12 +113,22 @@ {{filters.toFix(luckGoInfo.group_price/100,2)}} - - - - {{sele_g[card_field]}} - {{sele_g.shop_price}} + + 零售价:{{data.market_price}} + + + + + + {{sele_g[card_field]}} + {{data.shop_price}} + + + + + + @@ -1049,8 +1059,6 @@ - - - - 关闭 - - - --> + diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxss b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxss index 76eb995..7d49f88 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxss +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxss @@ -2319,7 +2319,7 @@ left:25rpx; color: #fff; } .xc-qt-price .xc-qtunit-price{ - margin-left:-96rpx; + margin-left:-70rpx; } .xc-nanber{ top:-25rpx; diff --git a/packageC/pages/presell/goodsInfo/goodsInfo.js b/packageC/pages/presell/goodsInfo/goodsInfo.js index e95fa43..4076ef1 100644 --- a/packageC/pages/presell/goodsInfo/goodsInfo.js +++ b/packageC/pages/presell/goodsInfo/goodsInfo.js @@ -2775,6 +2775,8 @@ Page({ } }, + + //--定义的保存图片方法,分享团--- saveImageToPhotosAlbum: function () { //--先判断会员状态-- @@ -2823,7 +2825,7 @@ Page({ ///二微码 var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + os.stoid + "?sceneValue=" + scene + "&pageValue=packageC/pages/presell/goodsInfo/goodsInfo"; - + console.log(path3); @@ -2838,9 +2840,6 @@ Page({ //先画背景 var pg_path = "../../../../images/share/share_bg.png"; - // context.fillStyle="#FFFFFF"; - // context.fillRect(0,0,554 * unit, 899 * unit); - //-- 如果有自定义海报的时候,判断背景的图片 -- if (th.data.share_b_img) { pg_path = th.data.share_b_img; @@ -2893,11 +2892,11 @@ Page({ //---产品名称--- //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - if (type != 4) { + context.setFillStyle("black"); context.setFontSize(21.3 * unit) th.draw_Text(context, share_title, - 80 * unit, 200 * unit, 200 * unit, 279 * unit, unit); + 80 * unit, 160 * unit, 200 * unit, 279 * unit, unit); //------产品的价格------- context.setFontSize(22 * unit) @@ -2909,15 +2908,16 @@ Page({ // pri0 = th.data.prom_act.price; pri0 = parseFloat(pri0).toFixed(2); var wd1 = th.data.screenWidth - ut.measureText(pri0, 31 * unit) - 25; - context.fillText("¥", wd1 - 15, 185 * unit); + context.fillText("¥", wd1 - 15, 160 * unit); context.setFontSize(22 * unit) - context.fillText(pri0, wd1, 185 * unit); + context.fillText(pri0, wd1, 165 * unit); //---市场价划掉--- - context.setFillStyle("red") - context.setFontSize(22 * unit) - pri0 = "¥" + th.data.data.market_price.toFixed(2); - var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; + // context.setFillStyle("red") + // context.setFontSize(22 * unit) + // pri0 = "¥" + th.data.data.market_price.toFixed(2); + // var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; + if(th.data.presellForm.presell_type==1){ // context.setStrokeStyle('gray'); @@ -2926,75 +2926,62 @@ Page({ // context.moveTo(wd2 - 5, 206 * unit); // context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); // context.stroke(); - }else{ - context.fillText('定金', wd2, 213 * unit); + + //-- 零售价的优化 -- + var wp= th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 50; + var hp= 180 * unit + th.draw_pos_price(context,wp,hp,th.data.data.market_price,unit); + + }else{ + var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 50; + context.fillText('定金', wd2, 190 * unit); } - - - } else { - context.setFillStyle("black"); - context.setFontSize(21.3 * unit) - th.draw_Text(context, share_title, - 38 * unit, 170 * unit, 20 * unit, 300 * unit, unit); - //------ 产品的价格 ----- - var pri0 = th.data.prom_act.addmoney; - var integral = th.data.prom_act.integral; - var text = ""; - if (integral) { text = integral + "积分"; } - if (pri0 && integral) { text += "+"; } - if (pri0) { text += "¥" + pri0; } - - if (!pri0 && !integral) { text = "0积分"; } - context.setFillStyle("red"); - context.fillText(text, 38 * unit, 235 * unit); - } - //console.log(th.data.share_goods_img); //let share_goods_img=th.data.presellForm.share_img; //share_goods_img?share_goods_img:th.data.data.share_goods_img; //---中间大图--- - context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); + context.drawImage(th.data.share_goods_img, 70 * unit, 210 * unit, 408 * unit, 408 * unit); //---自定义海报 产品质量保证 if(th.data.poster.show_quality==1 ){ var g_path = "/images/share/s_gou.png"; - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); + context.drawImage(g_path, 56 * unit, 630 * unit, 22 * unit, 22 * unit); context.setFillStyle("red") context.setFontSize(18 * unit) - context.fillText("正品保证", 84 * unit, 690 * unit); + context.fillText("正品保证", 84 * unit, 650 * unit); - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); + context.drawImage(g_path, 218 * unit, 630 * unit, 22 * unit, 22 * unit); context.setFillStyle("red") context.setFontSize(18 * unit) - context.fillText("纯实体店", 246 * unit, 690 * unit); + context.fillText("纯实体店", 246 * unit, 650 * unit); - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); + context.drawImage(g_path, 388 * unit, 630 * unit, 22 * unit, 22 * unit); context.setFillStyle("red") context.setFontSize(18 * unit) - context.fillText("官方验证", 420 * unit, 690 * unit); + context.fillText("官方验证", 420 * unit, 650 * unit); } //---画线--- context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 665 * unit) - context.lineTo(520 * unit, 665 * unit) + context.moveTo(32 * unit, 662 * unit) + context.lineTo(520 * unit, 662 * unit) context.stroke(); //---文字--- context.setFillStyle("black") // context.setFontSize(22 * unit) context.setFontSize(24 * unit) - context.fillText(th.data.sto_sele_name_1, 40 * unit, 730 * unit); + context.fillText(th.data.sto_sele_name_1, 40 * unit, 700 * unit); context.setFillStyle("red") context.setFontSize(20 * unit) var presell_price = `预售价:${th.data.presellList.presell_price}` - context.fillText(presell_price, 40 * unit, 780 * unit); + context.fillText(presell_price, 40 * unit, 750 * unit); context.setFillStyle("black") context.setFontSize(22 * unit) - context.fillText("特惠好物,限时预售", 40 * unit, 826 * unit); - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit); + context.fillText("特惠好物,限时预售", 40 * unit, 800 * unit); + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 840 * unit); //---二维吗图--- //-- 自定义海报 -- @@ -3007,8 +2994,6 @@ Page({ context.drawImage(vpath, 390 * unit, 746 * unit, 130 * unit, 116 * unit); } - - //--- 如果是自定义海报的时候 --- if (th.data.poster && parseInt(th.data.poster.style) == 2) { @@ -3051,6 +3036,13 @@ Page({ } + if(th.data.poster.show_time==1){ + var act_time=''; + act_time="截止时间:"+ ut.formatTime(th.data.presellForm.end_time); + context.setFillStyle("red") + getApp().draw_Text(context, act_time,38 * unit, 880 * unit, 200 * unit, 340 * unit, unit); + } + //把画板内容绘制成图片,并回调 画板图片路径 context.draw(false, function () { setTimeout(function () { @@ -3170,490 +3162,7 @@ Page({ // 先画背景 var pg_path = "../../../../images/share/share_bg.png"; - - //-- 如果有自定义海报的时候,判断背景的图片 -- - if (th.data.share_b_img) { - pg_path = th.data.share_b_img; - } - // context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); - console.log('海报类型-----') - console.log(type); - - if ( !th.data.share_b_img && (type == 0 || type == 1 || type == 2 || type == 3 )){ // 如果是普通商品,绘制新海报 - th.drawPoster(context, unit, th.data.share_goods_img, vpath, type); - } else { - context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); - // var erm_x = parseFloat(th.data.poster.ewm_x) * 2; - // var erm_y = parseFloat(th.data.poster.ewm_y) * 2; - // context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); - // th.drawPoster(context, unit, th.data.share_goods_img, vpath); - }; - - // th.drawPoster(context, unit, th.data.share_goods_img, vpath); - - - //-- 是自定义海报的情况下 -- - if (th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) { - - if (th.data.poster && parseInt(th.data.poster.style) == 2) { - //在线上分享人的情况下 - if (parseInt(th.data.poster.show_headpic)) { - //获取坐标 - var x = parseFloat(th.data.poster.head_x) * 2; - var y = parseFloat(th.data.poster.head_y) * 2; - var x1 = (x + 90) * unit; - var y1 = (y + 50) * unit; - //--昵称--- - context.setFontSize(24 * unit) - context.setFillStyle("black") - context.fillText(app.globalData.userInfo.nickname, x1, y1); - var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit; - //强烈推荐 改许程 - var tj_path = "../../../../images/share/q_tj.png"; - context.drawImage(tj_path, x1 + width, y1 - 22 * unit, 85 * unit, 30 * unit); - context.setFontSize(16 * unit); - context.setLineJoin('round'); //交点设置成圆角 - context.setFillStyle("white"); - context.fillText('强烈推荐', x1 + width + 8 * unit, y1 - 1 * unit); - - //context.setFillStyle("black") - //context.setFontSize(24 * unit) - //context.fillText(getApp().globalData.config.store_name, 40 * unit, 130 * unit); - } - } else { - //--昵称--- - context.setFontSize(24 * unit); - context.setFillStyle("black"); - context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); - var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; - //强烈推荐 改许程 - var tj_path = "../../../../images/share/q_tj.png"; - context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit); - context.setFontSize(16 * unit); - context.setLineJoin('round'); //交点设置成圆角 - context.setFillStyle("white"); - context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit); - } - - }; - - - var share_title = th.data.data.goods_name; - if (th.data.prom_type == 1 || th.data.prom_type == 2 || th.data.prom_type == 6 || th.data.prom_type == 4) { - share_title = th.data.prom_act.share_title; - if (!share_title) share_title = th.data.prom_act.title; - if (th.data.prom_type == 4) share_title = th.data.prom_act.name; - } - - //---产品名称--- - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - if (th.data.share_b_img || (type != 4 && type != 0 && type != 1 && type != 2 && type != 3)) { - context.setFillStyle("black"); - context.setFontSize(21.3 * unit) - getApp().draw_Text(context, share_title, - 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); - - //------产品的价格------- - context.setFontSize(23 * unit) - context.setFillStyle("red") - - var pri0 = th.data.data.shop_price; - if (th.data.card_field && th.data.data[th.data.card_field]) { - pri0 = th.data.data[th.data.card_field]; - } - - if (th.data.prom_act) - pri0 = th.data.prom_price; - pri0 = parseFloat(pri0).toFixed(2); - var wd1 = th.data.screenWidth - ut.measureText(pri0, 31 * unit) - 25; - context.fillText("¥", wd1 - 15, 185 * unit); - context.setFontSize(31 * unit) - context.fillText(pri0, wd1, 185 * unit); - - //---市场价划掉--- - /*-- - context.setFillStyle("gray") - context.setFontSize(22 * unit) - pri0 = "¥" + th.data.data.market_price.toFixed(2); - var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; - context.fillText(pri0, wd2, 213 * unit); - - context.setStrokeStyle('gray'); - context.setLineWidth(1 * unit); - context.moveTo(wd2 - 5, 206 * unit); - context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); - context.stroke();--*/ - - } else if ( ( type == 4 && type != 0 && type != 1 && type != 2 && type != 3)) { - context.setFillStyle("black"); - context.setFontSize(21.3 * unit) - getApp().draw_Text(context, share_title, - 38 * unit, 170 * unit, 20 * unit, 300 * unit, unit); - //------ 产品的价格 ----- - var pri0 = th.data.prom_act.addmoney; - var integral = th.data.prom_act.integral; - var text = ""; - if (integral) { - text = integral + "积分"; - } - if (pri0 && integral) { - text += "+"; - } - if (pri0) { - text += "¥" + pri0; - } - - if (!pri0 && !integral) { - text = "0积分"; - } - context.setFillStyle("red"); - context.fillText(text, 38 * unit, 235 * unit); - - } - - //---中间大图--- - if ( th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) { - context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); - } - ; - - //---自定义海报 产品质量保证 - if(th.data.share_b_img && th.data.poster.show_quality==1 ){ - var g_path = "../../../../images/share/s_gou.png"; - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("正品保证", 84 * unit, 690 * unit); - - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("纯实体店", 246 * unit, 690 * unit); - - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("官方验证", 420 * unit, 690 * unit); - - } - //-------大图后面就不一样了----------- - switch (type) { - case 0: - if(!th.data.share_b_img){ - break - } - //---画线--- - context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 710 * unit) - context.lineTo(520 * unit, 710 * unit) - context.stroke(); - //---文字--- - context.setFillStyle("black") - context.setFontSize(22 * unit) - // 原来start ---> - context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 776 * unit); - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 826 * unit); - // <--- 原来end - // context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 816 * unit); - // context.setFontSize(18 * unit) - // context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 850 * unit); - //---二维吗图--- - context.drawImage(vpath, 380 * unit, 736 * unit, 120 * unit, 120 * unit); - break;//普通商品的展示 - case 4: - // 中间的几个字 - if (th.data.poster && parseInt(th.data.poster.style) == 2) { - if (parseInt(th.data.poster.show_quality)) { - var g_path = "../../../../images/share/s_gou.png"; - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("正品保证", 84 * unit, 690 * unit); - - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("纯实体店", 246 * unit, 690 * unit); - - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("官方验证", 420 * unit, 690 * unit); - } - - } else { - var g_path = "../../../../images/share/s_gou.png"; - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("正品保证", 84 * unit, 690 * unit); - - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("纯实体店", 246 * unit, 690 * unit); - - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); - context.setFillStyle("red") - context.setFontSize(18 * unit) - context.fillText("官方验证", 420 * unit, 690 * unit); - } - - - //---画线--- - context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 710 * unit) - context.lineTo(520 * unit, 710 * unit) - context.stroke(); - - //---文字--- - context.setFillStyle("black") - context.setFontSize(22 * unit) - - if (type == 0 || type == -1) { - // 原来start ---> - context.setFontSize(24 * unit) - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); - - context.setFontSize(22 * unit) - context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 806 * unit); - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit); - - } else { - context.setFontSize(24 * unit) - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); - context.setFontSize(22 * unit) - context.fillText("长按识别二维码", 40 * unit, 806 * unit); - context.fillText("立即开始兑换", 40 * unit, 846 * unit); - - } - - //---二维吗图--- - //-- 自定义海报 -- - if (th.data.share_b_img || th.data.poster) { - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); - } else { - //---二维吗图--- - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); - } - ; - - break; - case 1: //秒杀商品的展示 - if(!th.data.share_b_img){ - break - } - //---画线--- - context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 670 * unit) - context.lineTo(520 * unit, 670 * unit) - context.stroke(); - - //画秒杀的图片 - var miaos_path = '../../../../images/share/miao_share.png'; - context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit); - - context.setFillStyle("black") - context.setFontSize(24 * unit) - context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit); - //---文字--- - context.setFontSize(22 * unit) - context.setFillStyle("black") - context.fillText("特惠好物,限时秒杀", 40 * unit, 826 * unit); - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit); - - - //---二维吗图--- - //-- 自定义海报 -- - if (th.data.share_b_img || th.data.poster) { - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; - context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit); - } else { - //---二维吗图--- - context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit); - } - break; - - case 2: //会员团和商家团的展示 - if(!th.data.share_b_img){ - break - } - //---画线--- - context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 670 * unit) - context.lineTo(520 * unit, 670 * unit) - context.stroke(); - //---文字--- - context.setFillStyle("black") - context.setFontSize(24 * unit) - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); - - //绘制成团图片 - var ct_img = "../../../../images/share/ct_num.png"; - context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); - var ct_num = th.data.prom_act.ct_num; - context.setFontSize(14 * unit) - context.font = 'normal'; - context.setFillStyle("red") - if (ct_num < 10) { - context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit); - } else { - context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit); - } - context.setFontSize(22 * unit) - context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit); - - context.setFillStyle("gray") - context.fillText("快来和我一起拼团吧!", 40 * unit, 806 * unit); - context.setFillStyle("black") - context.font = 'normal bold 18px sans-serif'; - context.setFontSize(21.3 * unit) - context.fillText("长按识别二维码,立即参团", 40 * unit, 836 * unit); - - - //---二维吗图--- - //-- 自定义海报 -- - if (th.data.share_b_img || th.data.poster) { - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); - } else { - //---二维吗图--- - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); - } - break - case 3: //阶梯团的展示 - if(!th.data.share_b_img){ - break - } - //---画线--- - context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 670 * unit) - context.lineTo(520 * unit, 670 * unit) - context.stroke(); - //---文字--- - context.setFillStyle("black") - context.setFontSize(24 * unit) - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); - - //---绘制中间阶梯的价格--- - var list = th.data.prom_act.ct_rylist; - for (var i = 0; i < list.length; i++) { - var item = list[i]; - var wi = i * 90 * unit; - context.font = 'normal'; - context.setFontSize(16 * unit) - context.setFillStyle("red") - context.fillText("¥", 40 * unit + wi, 756 * unit); - context.setFontSize(22 * unit) - var pri = parseFloat(item.price).toFixed(2); - context.fillText(pri, 56 * unit + wi, 756 * unit); - context.setFillStyle("gray") - context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit); - } - //----------------下面部分---------------- - - context.setFillStyle("black") - context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit); - //context.font = 'normal bold 18px sans-serif'; - context.setFontSize(21 * unit) - context.fillText("长按识别二维码,立即参团", 40 * unit, 850 * unit); - - - //-- 自定义海报 -- - if (th.data.share_b_img || th.data.poster) { - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); - } else { - //---二维吗图--- - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); - } - break - - - case -1: //秒杀商品的展示 - //---画线--- - context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 670 * unit) - context.lineTo(520 * unit, 670 * unit) - context.stroke(); - - - context.setFillStyle("black") - context.setFontSize(24 * unit) - context.fillText(th.data.sto_sele_name_1, 40 * unit, 744 * unit); - //---文字--- - context.setFontSize(22 * unit) - context.setFillStyle("black") - context.fillText("长按识别二维码", 40 * unit, 800 * unit); - context.fillText("立即开始抢购", 40 * unit, 846 * unit); - - - //---二维吗图--- - //-- 自定义海报 -- - if (th.data.share_b_img || th.data.poster) { - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; - context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit); - } else { - //---二维吗图--- - context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit); - } - break; - - - } - - - //--- 如果是自定义海报的时候 --- - if ( th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) { - - if (th.data.poster && parseInt(th.data.poster.style) == 2) { - - //如果显示会员信息的话 - if (parseInt(th.data.poster.show_headpic)) { - //获取坐标 - var x = parseFloat(th.data.poster.head_x) * 2; - var y = parseFloat(th.data.poster.head_y) * 2; - //---绘制圆形要放在最后---- - context.save(); - context.beginPath(); - var h_x = x * unit; - var h_y = y * unit; - var h_r = 40 * unit; - var cx = h_x + h_r; - var cy = h_y + h_r; - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); - context.closePath(); - context.fill(); - context.clip(); - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); - context.restore(); - } - - } else { - //---绘制圆形要放在最后---- - context.save(); - context.beginPath(); - var h_x = 60 * unit; - var h_y = 24 * unit; - var h_r = 40 * unit; - var cx = h_x + h_r; - var cy = h_y + h_r; - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); - context.closePath(); - context.fill(); - context.clip(); - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); - context.restore(); - } - - } - ; + th.drawPoster(context, unit, th.data.share_goods_img, vpath, type); //把画板内容绘制成图片,并回调 画板图片路径 @@ -3729,144 +3238,126 @@ Page({ } } }, + drawPoster(context, unit, img, vpath, type) { - // 1.灰色背景 - context.setFillStyle('#f2f1f6'); - context.rect(0, 0, 554 * unit, 899 * unit); - context.fill(); - - // 2.商城名称 - let shopName = this.data.sto_sele_name_1; - context.setTextAlign('center'); - context.setFontSize(26 * unit); - context.setFillStyle('black'); - context.fillText(shopName, 277 * unit, 60 * unit); - - // 3.推荐来源 - let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; - context.setTextAlign('center'); - context.setFontSize(22 * unit); - context.setFillStyle('#96959a'); - context.fillText(fromText, 277 * unit, 105 * unit); - - // 4.海报背景 - context.setFillStyle('white'); - context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); - - // 5.商品图片 - // 图片的x坐标 - let bg_x = 37 * unit - // 图片的y坐标 - let bg_y = 157 * unit - // 图片宽度 - let bg_w = 480 * unit - // 图片高度 - let bg_h = 474 * unit - // 图片圆角 - let bg_r = 4 - // 绘制海报背景图片圆角 - context.save() - context.beginPath() - context.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5) - context.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2) - context.arc(bg_x + bg_w, bg_y + bg_h, bg_r, 0, Math.PI * 0.5) - context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) - context.clip() - context.drawImage(img, bg_x, bg_y, bg_w, bg_h); - context.restore(); - - // 6.强烈推荐 - let src = ''; - context.beginPath(); - if(type == 0) { // 普通 - src = '../../../../images/share/q_tj.png'; - context.drawImage(src, 54 * unit, 648 * unit, 85 * unit, 30 * unit); - context.setFontSize(16 * unit) - context.setFillStyle("white") - context.setTextAlign('left'); - context.fillText('强烈推荐', 64 * unit, 668 * unit); - }; - if(type == 1) { // 秒杀 - src = '../../../images/share/miao_share.png'; - context.drawImage(src, 54 * unit, 648 * unit, 200 * unit, 36 * unit); - context.setTextAlign('left'); - }; - if(type == 2) { // 商家和会员团 - src = '../../../images/share/ct_num.png'; - context.drawImage(src, 54 * unit, 648 * unit, 120 * unit, 30 * unit); - context.setTextAlign('left'); - - let ct_num = self.data.prom_act.ct_num; - context.setFontSize(16 * unit) - context.font = 'normal'; - context.setFillStyle("red") - if (ct_num < 10) { - context.fillText(ct_num + "人拼团", 100 * unit, 670 * unit); - } else { - context.fillText(ct_num + "人拼团", 96 * unit, 670 * unit); - } - context.setFontSize(22 * unit) - context.fillText("已拼" + self.data.prom_act.buy_num + "份", 186 * unit, 672 * unit); - }; - if(type == 3) { // 阶梯团 - let list = self.data.prom_act.ct_rylist; - for (let i = 0; i < list.length; i++) { - let item = list[i]; - let wi = i * 90 * unit; - context.font = 'normal'; - context.setTextAlign('left'); - context.setFontSize(16 * unit) - context.setFillStyle("red") - context.fillText("¥", 50 * unit + wi, 680 * unit); - context.setFontSize(22 * unit) - let pri = parseFloat(item.price).toFixed(2); - context.fillText(pri, 66 * unit + wi, 680 * unit); - context.setFillStyle("gray") - context.fillText("满" + item.rynum + "人", 50 * unit + wi, 716 * unit); - } - }; - - // 7.商品价格 - if(type != 3) { - let price = this.data.data.shop_price; - if (this.data.card_field && this.data.data[this.data.card_field]) { - price = this.data.data[this.data.card_field]; - } - if (this.data.prom_act) price = this.data.prom_price; - price = parseFloat(price).toFixed(2); - context.setFontSize(32 * unit); - context.setFillStyle('#DE1117'); - if (this.data.prom_type == 4 && this.data.prom_integral){ - context.fillText(this.data.prom_integral+'积分+¥' + price, 54 * unit, 735 * unit); - }else{ - if(this.data.prom_type ==8){ - price = this.data.presellList.presell_price - context.fillText('¥' + price, 54 * unit, 735 * unit); - }else{ - context.fillText('¥' + price, 54 * unit, 735 * unit); - } - } - + // 1.灰色背景 + context.setFillStyle('#f2f1f6'); + context.rect(0, 0, 554 * unit, 899 * unit); + context.fill(); + + // 2.商城名称 + let shopName = this.data.sto_sele_name_1; + context.setTextAlign('center'); + context.setFontSize(26 * unit); + context.setFillStyle('black'); + context.fillText(shopName, 277 * unit, 60 * unit); + + // 3.推荐来源 + let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; + context.setTextAlign('center'); + context.setFontSize(22 * unit); + context.setFillStyle('#96959a'); + context.fillText(fromText, 277 * unit, 105 * unit); + + // 4.海报背景 + context.setFillStyle('white'); + context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); + + // 5.商品图片 + // 图片的x坐标 + let bg_x = 37 * unit + // 图片的y坐标 + let bg_y = 157 * unit + // 图片宽度 + let bg_w = 480 * unit + // 图片高度 + let bg_h = 474 * unit + // 图片圆角 + let bg_r = 4 + // 绘制海报背景图片圆角 + context.save() + context.beginPath() + context.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5) + context.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2) + context.arc(bg_x + bg_w, bg_y + bg_h, bg_r, 0, Math.PI * 0.5) + context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) + context.clip() + context.drawImage(img, bg_x, bg_y, bg_w, bg_h); + context.restore(); + + // 6.强烈推荐 + let src = ''; + context.beginPath(); + if (type == 0) { // 普通 + src = '../../../../images/share/q_tj.png'; + context.drawImage(src, 54 * unit, 648 * unit, 85 * unit, 30 * unit); + context.setFontSize(16 * unit) + context.setFillStyle("white") + context.setTextAlign('left'); + context.fillText('强烈推荐', 64 * unit, 668 * unit); + } + + + // 7.商品价格 + let price = this.data.data.shop_price; + if (this.data.card_field && this.data.data[this.data.card_field]) { + price = this.data.data[this.data.card_field]; + } + if (this.data.prom_act) price = this.data.prom_price; + price = parseFloat(price).toFixed(2); + context.setFontSize(32 * unit); + context.setFillStyle('#DE1117'); + + price = this.data.presellList.presell_price + context.fillText('¥' + price, 54 * unit, 735 * unit); + + + //-- 零售价的优化 -- + var wp= 62 * unit+ut.measureText('¥' + price, 32 * unit); + var hp=735 * unit + this.draw_pos_price(context,wp,hp,this.data.data.market_price,unit); + + + // 8.商品标题 + context.setFontSize(20 * unit); + context.setFillStyle('#898989'); + getApp().draw_Text(context, this.data.data.goods_name, 54 * unit, 800 * unit, 240 * unit, 280 * unit, unit, 1); + + // 9.小程序码 + context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); + context.setFontSize(16 * unit); + context.setFillStyle('#777'); + context.fillText('长按识别二维码', 378 * unit, 810 * unit); + + // 10.竖线 + context.beginPath(); + context.setFillStyle('#eee'); + context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit); + context.fill(); + }, + + + //---市场价划掉--- + draw_pos_price(context,w,h,market_price,unit){ + + if(!this.data.sys_switch) return false; + if(!this.data.sys_switch.is_retail_price) return false; + + context.setFillStyle("gray") + context.setFontSize(22 * unit) + var pri0 = "¥" + market_price.toFixed(2); + context.fillText(pri0, w, h); + + var c_h=h-6; + context.setStrokeStyle('gray'); + context.setLineWidth(1 * unit); + context.moveTo(w - 5, c_h); + context.lineTo(w + ut.measureText(pri0, 22 * unit) + 5, c_h); + context.stroke(); - }; - - // 8.商品标题 - context.setFontSize(20 * unit); - context.setFillStyle('#898989'); - getApp().draw_Text(context, this.data.data.goods_name, 54 * unit, 800 * unit, 240 * unit, 280 * unit, unit, 1); - - // 9.小程序码 - context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); - context.setFontSize(16 * unit); - context.setFillStyle('#777'); - context.fillText('长按识别二维码', 378 * unit, 810 * unit); - - // 10.竖线 - context.beginPath(); - context.setFillStyle('#eee'); - context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit); - context.fill(); }, + + // ----视频图片---- // 图片计数器 swiperChange: function (e) { diff --git a/pages/giftpack/giftpacklist/giftpacklist.js b/pages/giftpack/giftpacklist/giftpacklist.js index f83e6cd..53ac4f3 100644 --- a/pages/giftpack/giftpacklist/giftpacklist.js +++ b/pages/giftpack/giftpacklist/giftpacklist.js @@ -1104,6 +1104,10 @@ Page({ context.fillText(price_txt, 54 * unit, 735 * unit); + var wp= 62 * unit; + var hp=765 * unit + this.draw_pos_price(context,wp,hp,this.giftPosPrice,unit); + // 8.商品标题 context.setFontSize(20 * unit); context.setFillStyle('#898989'); @@ -1122,6 +1126,26 @@ Page({ context.fill(); }, + + //---市场价划掉--- + draw_pos_price(context,w,h,market_price,unit){ + + if(!this.is_retail_price) return false; + + context.setFillStyle("gray") + context.setFontSize(22 * unit) + var pri0 = "¥" + market_price.toFixed(2); + context.fillText(pri0, w, h); + + var c_h=h-6; + context.setStrokeStyle('gray'); + context.setLineWidth(1 * unit); + context.moveTo(w - 5, c_h); + context.lineTo(w + ut.measureText(pri0, 22 * unit) + 5, c_h); + context.stroke(); + + }, + //--获取商品图片的本地缓存,回调写法-- get_goods_temp: function (tt) { var ee = this; diff --git a/pages/goods/categoryList/categoryList.wxml b/pages/goods/categoryList/categoryList.wxml index 79d6e7f..988baee 100644 --- a/pages/goods/categoryList/categoryList.wxml +++ b/pages/goods/categoryList/categoryList.wxml @@ -292,7 +292,8 @@ - + + @@ -303,7 +304,7 @@ - + - + + - {{goods.items.name}} + {{goods.items.name}} 更多 @@ -335,7 +337,7 @@ - + {{item.name}} diff --git a/pages/goods/categoryList/categoryList.wxss b/pages/goods/categoryList/categoryList.wxss index 5115230..b18a19c 100644 --- a/pages/goods/categoryList/categoryList.wxss +++ b/pages/goods/categoryList/categoryList.wxss @@ -400,7 +400,7 @@ line-height: 65rpx; } .type_img_frame { box-sizing: border-box; - width: calc(100% / 3); + width: calc(90% / 3); height: 140rpx; margin-top: 20rpx; margin-bottom: 20rpx; diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index e5e8b1d..8f47225 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -5371,13 +5371,15 @@ Page({ let pri = parseFloat(item.price).toFixed(2); context.fillText(pri, 66 * unit + wi, 680 * unit); - var wp = 62 * unit + wi + ut.measureText('¥' + pri, 32 * unit); - var hp = 735 * unit - self.draw_pos_price(context, wp, hp, self.data.data.market_price, unit); context.setFillStyle("gray") context.fillText("满" + item.rynum + "人", 50 * unit + wi, 716 * unit); } + + + var wp= 52 * unit; + var hp=755 * unit + self.draw_pos_price(context,wp,hp,self.data.data.market_price,unit); } @@ -5394,16 +5396,16 @@ Page({ if (this.data.prom_type == 4 && this.data.prom_integral) { context.fillText(this.data.prom_integral + '积分+¥' + price, 54 * unit, 735 * unit); - var wp = 62 * unit + ut.measureText(this.data.prom_integral + '积分+¥' + price, 32 * unit); - var hp = 735 * unit - this.draw_pos_price(context, wp, hp, this.data.data.market_price, unit); + var wp= 62 * unit+ut.measureText(this.data.prom_integral + '积分+¥' + price, 32 * unit); + var hp=735 * unit + this.draw_pos_price(context,wp,hp,this.data.data.market_price,unit); } else { context.fillText('¥' + price, 54 * unit, 735 * unit); - var wp = 62 * unit + ut.measureText('¥' + price, 32 * unit); - var hp = 735 * unit - this.draw_pos_price(context, wp, hp, this.data.data.market_price, unit); + var wp= 62 * unit+ut.measureText('¥' + price, 32 * unit); + var hp=735 * unit + this.draw_pos_price(context,wp,hp,this.data.data.market_price,unit); } @@ -5429,17 +5431,17 @@ Page({ }, //---市场价划掉--- - draw_pos_price(context, w, h, market_price, unit) { + draw_pos_price(context,w,h,market_price,unit){ - if (!this.data.sys_switch) return false; - if (!this.data.sys_switch.is_retail_price) return false; + if(!this.data.sys_switch) return false; + if(!this.data.sys_switch.is_retail_price) return false; context.setFillStyle("gray") context.setFontSize(22 * unit) var pri0 = "¥" + market_price.toFixed(2); context.fillText(pri0, w, h); - var c_h = h - 6; + var c_h=h-6; context.setStrokeStyle('gray'); context.setLineWidth(1 * unit); context.moveTo(w - 5, c_h); @@ -5456,16 +5458,12 @@ Page({ var user_info = getApp().globalData.userInfo; if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { //getApp().my_warnning("请先登录",0,this); - wx.navigateTo({ - url: '/packageE/pages/togoin/togoin', - }) + wx.navigateTo({url: '/packageE/pages/togoin/togoin',}) return false; } if (this.data.share_hidden) { - this.setData({ - share_hidden: false, - }); + this.setData({share_hidden: false,}); }; //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 @@ -5482,18 +5480,15 @@ Page({ if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; console.log('商品类型。。。。。'); console.log(type); - wx.showLoading({ - title: '生成中...', - }) - var that = this, - th = that; + wx.showLoading({title: '生成中...',}) + var that = this, th = that; //设置画板显示,才能开始绘图 that.setData({ canvasHidden: false }) var app = getApp(); - var unit = that.data.screenWidth / 750 * 1.35; //基础单位, + var unit = that.data.screenWidth / 750 * 1.35; //基础单位, var path2 = that.data.data.original_img; var scene = th.data.gid + ""; scene += "." + th.data.sele_g.prom_type + "." + th.data.sele_g.prom_id; @@ -5510,7 +5505,7 @@ Page({ } ///二微码 var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + - os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo"; + os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo"; console.log(path3); @@ -5535,7 +5530,7 @@ Page({ console.log('海报类型-----') console.log(type); - if (!th.data.share_b_img && (type == 0 || type == 1 || type == 2 || type == 3)) { // 如果是普通商品,绘制新海报 + if ( !th.data.share_b_img && (type == 0 || type == 1 || type == 2 || type == 3 )){ // 如果是普通商品,绘制新海报 th.drawPoster(context, unit, th.data.share_goods_img, vpath, type); } else { context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); @@ -5546,10 +5541,10 @@ Page({ }; - + var act_time=''; //-- 是自定义海报的情况下 -- - if (th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) { + if (th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) { if (th.data.poster && parseInt(th.data.poster.style) == 2) { //在线上分享人的情况下 @@ -5595,19 +5590,27 @@ Page({ var share_title = th.data.data.goods_name; + + if (th.data.prom_type == 1 || th.data.prom_type == 2 || th.data.prom_type == 6 || th.data.prom_type == 4) { share_title = th.data.prom_act.share_title; if (!share_title) share_title = th.data.prom_act.title; if (th.data.prom_type == 4) share_title = th.data.prom_act.name; + + //-- 显示活动时间 -- + if(th.data.share_b_img) { + act_time="截止时间:"+ ut.formatTime(th.data.prom_act.end_time); + } } //---产品名称--- //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - if (th.data.share_b_img || (type != 4 && type != 0 && type != 1 && type != 2 && type != 3)) { + if (th.data.share_b_img || (type != 4 && type != 0 && type != 1 && type != 2 && type != 3)) { context.setFillStyle("black"); context.setFontSize(21.3 * unit) getApp().draw_Text(context, share_title, - 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); + 38 * unit, 170 * unit, 200 * unit, 279 * unit, unit); + //------产品的价格------- context.setFontSize(23 * unit) @@ -5621,17 +5624,18 @@ Page({ if (th.data.prom_act) pri0 = th.data.prom_price; pri0 = parseFloat(pri0).toFixed(2); + var wd1 = th.data.screenWidth - ut.measureText(pri0, 31 * unit) - 25; - if (th.data.prom_type != 4) - context.fillText("¥", wd1 - 15, 185 * unit); + if(th.data.prom_type!=4) + context.fillText("¥", wd1 - 15, 175 * unit); context.setFontSize(31 * unit) - var pri_str = pri0; - if (th.data.prom_type == 4) { - pri_str = ''; + var pri_str=pri0; + if(th.data.prom_type==4){ + pri_str=''; - if (th.data.prom_integral) pri_str = th.data.prom_integral + '积分'; + if(th.data.prom_integral) pri_str=th.data.prom_integral+'积分'; if (pri0 && th.data.prom_integral) { pri_str += "+"; } @@ -5640,8 +5644,9 @@ Page({ } wd1 = th.data.screenWidth - ut.measureText(pri_str, 31 * unit) - 20; + } - context.fillText(pri_str, wd1, 185 * unit); + context.fillText(pri_str, wd1, 175 * unit); //---市场价划掉--- // context.setFillStyle("gray") // context.setFontSize(22 * unit) @@ -5655,15 +5660,18 @@ Page({ // context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); // context.stroke(); - var wp = 62 * unit + wi + ut.measureText(pri_str, 32 * unit); - var hp = 735 * unit - th.draw_pos_price(context, wp, hp, self.data.data.market_price, unit); + var wp= wd1; + var hp=203 * unit; + if(th.data.prom_type!=4) wp-=12; + th.draw_pos_price(context,wp,hp,self.data.data.market_price,unit); - } else if (type == 4) { + } else if (type == 4 ) { context.setFillStyle("black"); context.setFontSize(21.3 * unit) getApp().draw_Text(context, share_title, - 38 * unit, 170 * unit, 20 * unit, 300 * unit, unit); + 38 * unit, 160 * unit, 20 * unit, 300 * unit, unit); + + //------ 产品的价格 ----- var pri0 = th.data.prom_act.addmoney; var integral = th.data.prom_act.integral; @@ -5682,7 +5690,7 @@ Page({ text = "0积分"; } context.setFillStyle("red"); - context.fillText(text, 38 * unit, 235 * unit); + context.fillText(text, 38 * unit, 175 * unit); //---市场价划掉--- // context.setFillStyle("gray") @@ -5697,44 +5705,42 @@ Page({ // context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); // context.stroke(); - - - var wp = 62 * unit + wi + ut.measureText(text, 32 * unit); - var hp = 735 * unit - th.draw_pos_price(context, wp, hp, self.data.data.market_price, unit); + var wp= wd1-12; + var hp=203 * unit + th.draw_pos_price(context,wp,hp,self.data.data.market_price,unit); } //---中间大图--- - if (th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) { - context.drawImage(th.data.share_goods_img, 70 * unit, 240 * unit, 408 * unit, 408 * unit); + if ( th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) { + context.drawImage(th.data.share_goods_img, 70 * unit, 220 * unit, 408 * unit, 408 * unit); } //---自定义海报 产品质量保证 - if (th.data.share_b_img && th.data.poster.show_quality == 1 && type != 4) { + if(th.data.share_b_img && th.data.poster.show_quality==1 && type!=4){ var g_path = "../../../images/share/s_gou.png"; - context.drawImage(g_path, 56 * unit, 650 * unit, 22 * unit, 22 * unit); + context.drawImage(g_path, 56 * unit, 640 * unit, 22 * unit, 22 * unit); context.setFillStyle("red") context.setFontSize(18 * unit) - context.fillText("正品保证", 84 * unit, 670 * unit); + context.fillText("正品保证", 84 * unit, 660 * unit); - context.drawImage(g_path, 218 * unit, 650 * unit, 22 * unit, 22 * unit); + context.drawImage(g_path, 218 * unit, 640 * unit, 22 * unit, 22 * unit); context.setFillStyle("red") context.setFontSize(18 * unit) - context.fillText("纯实体店", 246 * unit, 670 * unit); + context.fillText("纯实体店", 246 * unit, 660 * unit); - context.drawImage(g_path, 388 * unit, 650 * unit, 22 * unit, 22 * unit); + context.drawImage(g_path, 388 * unit, 640 * unit, 22 * unit, 22 * unit); context.setFillStyle("red") context.setFontSize(18 * unit) - context.fillText("官方验证", 420 * unit, 670 * unit); + context.fillText("官方验证", 420 * unit, 660 * unit); } - //-------大图后面就不一样了----------- + //-------大图后面就不一样了----------- switch (type) { case 0: - if (!th.data.share_b_img) { + if(!th.data.share_b_img){ break } //---画线--- @@ -5754,10 +5760,10 @@ Page({ // context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 850 * unit); //---二维吗图--- context.drawImage(vpath, 380 * unit, 736 * unit, 120 * unit, 120 * unit); - break; //普通商品的展示 + break;//普通商品的展示 case 4: - if (th.data.share_b_img && th.data.poster.show_quality == 1 && type != 4) { + if(th.data.share_b_img && th.data.poster.show_quality==1 && type!=4){ var g_path = "../../../images/share/s_gou.png"; context.drawImage(g_path, 56 * unit, 660 * unit, 22 * unit, 22 * unit); context.setFillStyle("red") @@ -5845,7 +5851,7 @@ Page({ //---二维吗图--- //-- 自定义海报 -- - if (th.data.share_b_img || th.data.poster) { + if (th.data.share_b_img || th.data.poster) { var erm_x = parseFloat(th.data.poster.ewm_x) * 2; var erm_y = parseFloat(th.data.poster.ewm_y) * 2; context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); @@ -5857,32 +5863,32 @@ Page({ break; case 1: //秒杀商品的展示 - if (!th.data.share_b_img) { + if(!th.data.share_b_img){ break } //---画线--- context.setLineWidth(1 * unit) - context.moveTo(32 * unit, 690 * unit) - context.lineTo(520 * unit, 690 * unit) + context.moveTo(32 * unit, 670 * unit) + context.lineTo(520 * unit, 670 * unit) context.stroke(); //画秒杀的图片 var miaos_path = '../../../images/share/miao_share.png'; - context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit); + context.drawImage(miaos_path, 43 * unit, 690 * unit, 222 * unit, 40 * unit); context.setFillStyle("black") context.setFontSize(24 * unit) - context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit); + context.fillText(th.data.sto_sele_name_1, 40 * unit, 770 * unit); //---文字--- context.setFontSize(22 * unit) context.setFillStyle("black") - context.fillText("特惠好物,限时秒杀", 40 * unit, 826 * unit); - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit); + context.fillText("特惠好物,限时秒杀", 40 * unit, 807 * unit); + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 844 * unit); //---二维吗图--- //-- 自定义海报 -- - if (th.data.share_b_img || th.data.poster) { + if (th.data.share_b_img || th.data.poster) { var erm_x = parseFloat(th.data.poster.ewm_x) * 2; var erm_y = parseFloat(th.data.poster.ewm_y) * 2; context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit); @@ -5893,7 +5899,7 @@ Page({ break; case 2: //会员团和商家团的展示 - if (!th.data.share_b_img) { + if(!th.data.share_b_img){ break } //---画线--- @@ -5931,7 +5937,7 @@ Page({ //---二维吗图--- //-- 自定义海报 -- - if (th.data.share_b_img || th.data.poster) { + if (th.data.share_b_img || th.data.poster) { var erm_x = parseFloat(th.data.poster.ewm_x) * 2; var erm_y = parseFloat(th.data.poster.ewm_y) * 2; context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); @@ -5941,7 +5947,7 @@ Page({ } break case 3: //阶梯团的展示 - if (!th.data.share_b_img) { + if(!th.data.share_b_img){ break } //---画线--- @@ -5979,7 +5985,7 @@ Page({ //-- 自定义海报 -- - if (th.data.share_b_img || th.data.poster) { + if (th.data.share_b_img || th.data.poster) { var erm_x = parseFloat(th.data.poster.ewm_x) * 2; var erm_y = parseFloat(th.data.poster.ewm_y) * 2; context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); @@ -6010,7 +6016,7 @@ Page({ //---二维吗图--- //-- 自定义海报 -- - if (th.data.share_b_img || th.data.poster) { + if (th.data.share_b_img || th.data.poster) { var erm_x = parseFloat(th.data.poster.ewm_x) * 2; var erm_y = parseFloat(th.data.poster.ewm_y) * 2; context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit); @@ -6025,7 +6031,7 @@ Page({ //--- 如果是自定义海报的时候 --- - if (th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) { + if ( th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) { if (th.data.poster && parseInt(th.data.poster.style) == 2) { @@ -6070,6 +6076,15 @@ Page({ } + + //-- 自定义的时候 -- + if(th.data.share_b_img && act_time && th.data.poster.show_time){ + context.setFillStyle("red") + getApp().draw_Text(context, act_time,38 * unit, 880 * unit, 200 * unit, 340 * unit, unit); + } + + + //把画板内容绘制成图片,并回调 画板图片路径 context.draw(false, function () { setTimeout(function () { diff --git a/pages/user/order_list/order_list.js b/pages/user/order_list/order_list.js index ce01aad..03ccf24 100644 --- a/pages/user/order_list/order_list.js +++ b/pages/user/order_list/order_list.js @@ -2051,7 +2051,6 @@ Page({ let list= []; if(currentIndex == 1) { - list = th.data.list2; list = list.concat(data); th.setData({list2:list}); }; @@ -2228,7 +2227,8 @@ Page({ this.setData({ currentPage2: 1, list2: [], - is_no_data2: 0, + is_no_data2: 0, + is_no_more2:0 });