From a7d57d269e928fafa367ed16e9c664a284aa1fba Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Thu, 14 Sep 2023 17:22:12 +0800 Subject: [PATCH] up --- .../pages/shopDetail/shopDetail.vue | 19 +- .../packageOrder/pages/myOrder/myOrder.vue | 15 +- .../orderPackageDetail/orderPackageDetail.vue | 6 +- pages/active/course.vue | 14 +- pages/active/detail.vue | 4404 +++++++++-------- pages/active/my.vue | 115 +- 6 files changed, 2320 insertions(+), 2253 deletions(-) diff --git a/packages/packageBuy/pages/shopDetail/shopDetail.vue b/packages/packageBuy/pages/shopDetail/shopDetail.vue index 0d90996..b63e5ec 100644 --- a/packages/packageBuy/pages/shopDetail/shopDetail.vue +++ b/packages/packageBuy/pages/shopDetail/shopDetail.vue @@ -64,7 +64,7 @@ 商品详情 - + @@ -927,7 +927,16 @@ } } - + + + }, + getPoster: function() { + var that = this; + uni.getImageInfo({ + src: that.info.active_playbill || '../../static/750x500.jpg', // 头像 + success: res => { + that.poster = res.path; + that.getAvatar(); + } + }); + }, + getAvatar: function() { + let userProfile = uni.getStorageSync('user_profile'); + + if (!weixin.isNull(userProfile)) { + console.log(userProfile.avatarUrl) + console.log(this.imgAvatar) + uni.getImageInfo({ + src: userProfile.avatarUrl, // 头像 + success: rlogo => { + this.imgAvatar = rlogo.path; + console.log(this.imgAvatar) + this.draw(); + } + }); + } else { + this.imgAvatar = "/static/avatar.jpg"; + console.log(this.imgAvatar) + this.draw(); + } + }, + shareOpen() { + uni.showLoading({ + title: '加载中' + }); + var that = this; + this.$refs.shareCode.open(); + this.getPoster(); + }, + draw: function() { + var that = this; + uni.request({ + url: this.baseUrl + '/api/member/get-wxa-qrcode', + method: 'GET', + data: { + path: 'pages/active/detail', + scene: 'id=' + this.info.id + '&promotion_id=' + this.user_info.id + }, + success: r => { + if (r.data.status === 1) { + uni.getImageInfo({ + src: this.baseUrl + r.data.data, // 二维码 + success: res => { + var ctx = uni.createCanvasContext('firstCanvas') + + + var w = SCREEN_WIDTH * 0.8; + var h = this.shareHeight * this.scare; + // ctx.fillStyle = '#fff'; + // ctx.fillRect(0, 0, 214, 342); + ctx.drawImage('../../static/bg_haibao@2x.jpg', 0, 0, + w, h + ); //(SCREEN_HEIGHT - 50 - SCREEN_WIDTH * 0.8 * 1.65) /2, SCREEN_WIDTH * 0.8, SCREEN_WIDTH * 0.8 * 1.5); + + ctx.drawImage('../../static/bg_haibao1.png', 20, 40, + w - + 40, h - 100); + /* SCREEN_WIDTH * + 0.15, (SCREEN_HEIGHT - SCREEN_WIDTH * 0.6 * 1.65) / + 2, SCREEN_WIDTH * 0.695, SCREEN_WIDTH * 0.6 * 1.5); */ + + ctx.drawImage(this.poster, 20, 40, + w - + 40, (h - 60 - 60) * 0.5); + /* SCREEN_WIDTH * 0.15, (SCREEN_HEIGHT - SCREEN_WIDTH * + 0.6 * 1.65) / + 2, SCREEN_WIDTH * 0.695, SCREEN_WIDTH * 0.695 / 1.6); */ + + // ctx.font = "22rpx bold"; + // // 设置颜色 + // ctx.fillStyle = "#fff"; + // // 绘制文字(参数:要写的字,x坐标,y坐标) + // ctx.fillText(this.info.active_name, 20, 50); + + ctx.font = "16rpx bold"; + // 设置颜色 + ctx.fillStyle = "#000"; + // 绘制文字(参数:要写的字,x坐标,y坐标) + let active_title = this.info.template == '新' ? '课程' : '活动' + ctx.fillText(active_title, 40, (h + 50) * 0.5 - 10); + + ctx.font = "14rpx bold"; + // 设置颜色 + ctx.fillStyle = "#3377b7"; + // 绘制文字(参数:要写的字,x坐标,y坐标) + + let packagesFirst = this.info + let active_time = this.info.template == '新' ? '上课时间:' : + '活动时间:' + let active_add = this.info.template == '新' ? '上课地点:' : + '活动地点:' + let active_name = this.info.active_name.length > 17 ? this + .info.active_name.substring(0, 17) : this.info + .active_name + let active_name1 = this.info.active_name.length > 17 ? this + .info.active_name.substring(17, this.info.active_name + .length) : '' + + ctx.fillText("" + active_name, 40, (h + 50) * 0.5 + 20); + ctx.fillText("" + active_name1, 40, (h + 50) * 0.5 + 40); + ctx.fillText(active_time + this.info.start_date + ' ' + + this.info.start_time, 40, (h + 50) * 0.5 + 50 + 20); + // ctx.fillText("结束时间:" + this.info.end_date, 40, (h + 50) * 0.5 + 50 + 40); + let address = this.info.address.length > 14 ? this.info + .address.substring(0, 14) : this.info.address + let address1 = this.info.address.length > 14 ? this.info + .address.substring(14, this.info.address.length) : '' + + ctx.fillText(active_add + address, 40, (h + 50) * 0.5 + + 50 + 40); + ctx.fillText(address1, 40, (h + 50) * 0.5 + 50 + 60); + // ctx.fillText(active_add + this.info.apply_end, 40, (h + 50) * 0.5 + 60 + 60); + + // let user_info = uni.getStorageSync("user_info_yunyubang"); + + // let userProfile = uni.getStorageSync('user_profile'); + + // var img = this.imgAvatar; + // uni.getImageInfo({ + // src: userProfile.avatarUrl, // 头像 + // success: rlogo => { + // img = rlogo.path; + + // } + // }); + // that.circleImg(ctx, + // img, + // 40, h - 50 - w * 0.15, + // w * 0.15 / 2); + + // ctx.font = "12rpx normal"; + // // 设置颜色 + // ctx.fillStyle = "#000"; + // // 绘制文字(参数:要写的字,x坐标,y坐标) + // // if(packagesFirst.template!='新'){ + + // // } + // if (!weixin.isNull(this.user_info.name)) + // ctx.fillText(this.user_info.name, + // 40, h - 40); + // else + // ctx.fillText("", + // 40, h - 40); + + + this.circleImg(ctx, res.path, w - 40 - w * 0.2, h - 65 - + w * + 0.2, w * 0.2 / 2); + + ctx.draw(), + // r: 半径 + setTimeout(() => { + uni.canvasToTempFilePath({ + canvasId: 'firstCanvas', + fileType: 'jpg', + success: (res) => { + this.shareBtnDisplay = + 'flex' + uni.hideLoading(); + this.img = this.info + .poster; + this.sharePath = res + .tempFilePath; + }, + }) + }, 100) + } + }) + } else { + uni.hideLoading() + this.$refs.shareCode.close() + this.alert(r.data.msg) + } + } + }) + + }, + circleImg: function(ctx, img, x, y, r) { + ctx.save() + var d = 2 * r; + var cx = x + r; + var cy = y + r; + ctx.arc(cx, cy, r, 0, 2 * Math.PI); + + ctx.clip(); + ctx.drawImage(img, x, y, d, d); + ctx.restore(); + }, + shareClose() { + this.$refs.shareCode.close() + }, + open() { + this.$refs.popup.open('top') + + }, + close() { + this.$refs.popup.close() + }, + //保存图片时,h5端不能直接保存,只能通过预览长按保存 + save() { + + let _this = this; + // #ifdef H5 + uni.previewImage({ + urls: [_this.sharePath] + }) + // #endif + // #ifdef APP-PLUS||MP-WEIXIN + uni.saveImageToPhotosAlbum({ + filePath: _this.sharePath, + success: function() { + _this.$refs.shareCode.close() + _this.alert('保存成功') + } + }); + // #endif + }, + + getDate(type) { + const date = new Date(); + let year = date.getFullYear(); + let month = date.getMonth() + 1; + let day = date.getDate(); + + if (type === 'start') { + year = year - 60; + } else if (type === 'end') { + year = year + 2; + } + month = month > 9 ? month : '0' + month; + day = day > 9 ? day : '0' + day; + return `${year}-${month}-${day}`; + }, + getNowTime() { + const date = new Date(); + let year = date.getFullYear(); + let month = date.getMonth() + 1; + let day = date.getDate(); + let hours = date.getHours() + let minutes = date.getMinutes() + let seconds = date.getSeconds() + month = month > 9 ? month : '0' + month; + day = day > 9 ? day : '0' + day; + return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; + }, + bindDateChange: function(e) { + this.form.budget_date = e.target.value + }, + compareDate(d1, d2) { + let reg = new RegExp('-', 'g') + return ((new Date(d1.replace(reg, '/'))) > (new Date(d2.replace(reg, '/')))) + }, + toBuy() { + + if (!this.isOrder) { + return + } + + let user_info = weixin.getUserInfoCache(); + + if (weixin.isNull(user_info.user_info.phone)) { + this.showPhone = true; + return false; + //this.getUserProfile(); + } + + if (weixin.isNull(this.form.name) || weixin.isNull(this.form.budget_date) || + weixin.isNull(this.form.phone) || weixin.isNull(this.form.sex) || + weixin.isNull(this.form.area) || weixin.isNull(this.form.hospital)) { + this.showPop = true; + if (weixin.isNull(this.form.name) || this.form.name == '微信用户') { + this.alert('请输入真实会员姓名') + return + } + if (weixin.isNull(this.form.sex)) { + this.alert('请选择性别') + return + } + if (weixin.isNull(this.form.budget_date)) { + this.alert('请选择预产日期') + return + } + if (weixin.isNull(this.form.area) || this.form.area == '请选择区域') { + this.alert('请选择区域') + return + } + if (weixin.isNull(this.form.hospital) || this.form.hospital == '请选择建卡医院') { + this.alert('请选择建卡医院') + return + } + + + if (weixin.isNull(this.form.phone)) { + this.alert('请填写手机号') + return + } + // if (weixin.isNull(this.form.address)) { + // this.alert('请填写地址') + // return + // } + + return false; + } + // 此处用法为在js中调用,需要写uni.$u.throttle() + uni.$u.throttle(this.joinActive, 1000); + + }, + joinActive() { + this.form.merchant_id = this.info.shop_id + this.form.active_id = this.info.id + this.form.active_name = this.info.active_name + if (this.form.promotion) { + this.form.spread_member_id = this.form.promotion + } + // this.form.member_id = 14521 + console.log(this.form) + // return + weixin.request({ + method: 'POST', + api: "/api/member/active-apply", + data: this.form, + utilSuccess: res => { + console.log("res", res) + setTimeout(function() { + uni.showToast({ + icon: 'success', + title: res.msg, + duration: 3000 + }) + }, 500) + + this.showPop = false + }, + utilFail: err => { + console.log(err, 'err'); + setTimeout(function() { + uni.showToast({ + icon: 'none', + title: err, + duration: 3000 + }) + }, 500) + + } + }) + }, + gotoDetail: function(e) { + var id = e.currentTarget.dataset.id + uni.navigateTo({ + url: "../shopDetail/shopDetail?id=" + id + }) + }, + loadInfo: function() { + let that = this + that.loadView() + weixin.request({ + api: '/api/member/active-show/', + method: 'GET', + data: { + id: this.id + }, + utilSuccess: r => { + //r.data.poster = this.baseUrl + r.data.poster; + if (r.company_ids) { + r.companyList = JSON.parse(r.company_ids) + } + this.info = r; + let apply_end = r.apply_end + let apply_start = r.apply_start + let enddate = r.end_date + " " + r.end_time + let nowtime = that.getNowTime() + if (r.audit_status == 2) { + that.isOrder = false + that.isOrderText = "不可报名" + return + } + if (that.compareDate(apply_start, nowtime)) { + that.isOrder = false + that.isOrderText = "报名未开始" + } else if (that.compareDate(nowtime, apply_end) || that.compareDate(nowtime, + enddate)) { + that.isOrder = false + that.isOrderText = "报名截止" + } else { + that.isOrder = true + that.isOrderText = "立即参加" + } + }, + utilFail: r => { + console.log(r); + } + }) + }, + loadPage: function() { + var that = this; + weixin.request({ + bindThis: that, + api: '/api/member/get-products', + customLoading: false, + data: { + page: 1, + page_size: 3 + }, + utilSuccess: function(r) { + var res = r.data.data; + + for (var m of res) { + m.poster = (weixin.isNull(m.poster) ? "../../static/750x500.jpg" : + m.poster_url) + if (m.created_at.indexOf('T') > 0) + m.created_at = m.created_at.split("T")[0] + " " + m.created_at.split("T")[ + 1] + .split(".")[0] + } + + that.dataList = res; + }, + utilFail: function(res) { + util.alert(res); + } + }); + }, + loadView: function() { + var that = this; + weixin.request({ + bindThis: that, + api: '/api/member/other/pv-count', + customLoading: false, + data: { + url: '/api/member/active-show', + body: 'id=' + that.id + }, + utilSuccess: function(r) { + console.log("r", r) + that.viewCounts = r.total + }, + utilFail: function(res) { + util.alert(res); + } + }); + } + + } + } + + + \ No newline at end of file diff --git a/pages/active/my.vue b/pages/active/my.vue index 7baf362..b271e75 100644 --- a/pages/active/my.vue +++ b/pages/active/my.vue @@ -58,9 +58,9 @@ + 申请取消 核销码 查看 - @@ -149,18 +149,27 @@ txt: "全部", is_used:"" }, - // { - // state: "unpaid", - // txt: "待支付" - // }, { state: "ongoing", txt: "待参加", - is_used:0 + is_used:1 }, { state: "finished", txt: "已参加", - is_used:1 + is_used:3 + }], + statusNames:[{ + id:0, + name:'申请取消' + },{ + id:1, + name:'待参加' + },{ + id:2, + name:'已取消' + },{ + id:3, + name:'已参加' }], user_info: {}, openid: "" @@ -207,6 +216,41 @@ url: "/pages/active/detail?id=" + id }) }, + cancelActive(apply){ + var that = this; + var id = apply[0]['id'] + uni.showModal({ + title:'是否确认取消活动?', + success:(res)=>{ + if(res.confirm){ + weixin.request({ + api: '/api/member/active-member-canceled', + method: 'POST', + data: { + id:id + }, + utilSuccess: res => { + uni.showToast({ + title: "申请取消成功" + }) + + that.list = [] + that.getOrderList(1) + }, + utilFail: res => { + uni.showToast({ + title: res + }) + } + }) + }else if(res.cancel){ + console.log("dianjiquxiao") + } + } + + }) + + }, showCode(item,apply){ if(apply.length<1){ return @@ -251,48 +295,6 @@ }) }, - goPay(id) { - var that = this; - weixin.request({ - api: '/api/member/order-payment', - method: 'GET', - data: { - order_id: id, - openid: this.openid - }, - utilSuccess: res => { - - weixin.getOpenidInfo(() => {}, true); - setTimeout(function() { - uni.hideLoading(); - that.showPop = false; - }, 100); - try { - let payParams = JSON.parse(res.jsApiParameters) - payParams.provider = 'wxpay' - payParams.success = result => { - that.status = "ongoing"; - that.loadData(that.currentPage); - } - payParams.fail = result => { - console.log(result); - } - wx.requestPayment(payParams); - - } catch (err) { - console.log(err) - } finally { - // finallyCode - 无论 try / catch 结果如何都会执行的代码块 - } - }, - utilFail: res => { - uni.showToast({ - title: res - }) - console.log(res); - } - }) - }, getOrderList(page) { const userInfo = uni.getStorageSync('userInfo') uni.showLoading({ @@ -304,12 +306,12 @@ page_size: 6, token: userInfo.access_token, myself:1, - is_used:this.is_used, + state:this.is_used, } if (this.status != "") { data = { ...data, - state: this.status + // state: this.status }; } var that = this; @@ -334,7 +336,12 @@ for (var m of r.data.data) { if(m.apply){ - m.statusName = m.apply[0]['used_time']?'已参加':"待参加" + for(var s of that.statusNames){ + if(m.apply[0]['state']==s.id){ + m.statusName = s.name + } + } + // m.statusName = m.apply[0]['used_time']?'已参加':"待参加" } } @@ -450,7 +457,9 @@ .status { font-size: 28rpx; font-weight: 400; - color: #666666; + color: #666666; + width: 160rpx; + text-align: right; } }