diff --git a/common/api.js b/common/api.js index 604f128..ea08f9f 100644 --- a/common/api.js +++ b/common/api.js @@ -64,6 +64,9 @@ export const API_FANS = '/api/salesman/fans'//获取粉丝列表 export const API_BINDGOODS = '/api/salesman/share'//商品海报分享绑定 export const API_BINDSALES = '/api/salesman/shareMan'//分销海报分享绑定 +export const API_BILLBACKGROUND = '/api/share/img'//海报背景图接口 +export const API_WXBILL = '/api/salesman/qrcode'//微信小程序太阳码 + /* 商户相关 */ export const API_CONFIRM_CODE = '/api/confirm/code'; // 扫码核销 \ No newline at end of file diff --git a/pages/center/invite.vue b/pages/center/invite.vue index 986951e..d56892f 100644 --- a/pages/center/invite.vue +++ b/pages/center/invite.vue @@ -8,20 +8,20 @@ - + - - + + - + @@ -41,10 +41,11 @@ }, showLogin: true, imagePath: '', - + userToken: '', wxCode: '', - onceCode: '' + onceCode: '', + backgroundImg: '' } }, onLoad() { @@ -54,24 +55,37 @@ duration: 1000 }); this.getWxCode() + this.getBackground() }, - methods:{ + methods: { + getBackground() { + let _this = this + _this.$http(_this.API.API_BILLBACKGROUND, { + type: 'telent_share' + }).then(res => { + let img = res.data.img_url + if (img) { + wx.getImageInfo({ + src: img, + success: function(sres) { + _this.backgroundImg = sres.path + console.log('临时路径',_this.backgroundImg) + } + }) + } + }) + }, getWxCode() { - uni.request({ - url: 'http://dev-gxsky.com/api/salesman/qrcode', //仅为示例,并非真实接口地址。 - data: { - scene: 'route=home&id=2&pt=2', - page: 'pages/route/index', - width: '2800' - }, - method: 'POST', - success: (res) => { - this.wxCode = res.data.data.base_url - if (this.wxCode) { - this.getwxCodeImg() - } + this.$http(this.API.API_WXBILL, { + scene: 'route=home&id=2&pt=2', + page: 'pages/route/index', + width: '2800' + }).then(res => { + this.wxCode = res.data.base_url + if (this.wxCode) { + this.getwxCodeImg() } - }); + }) }, //保存二维码 getwxCodeImg() { @@ -84,9 +98,13 @@ encoding: 'base64', success: res => { this.onceCode = wx.env.USER_DATA_PATH + '/pic' + number + '.jpg' - if(this.onceCode) { - console.log('小程序二维码',this.onceCode) + console.log(this.onceCode) + if (this.onceCode && this.backgroundImg) { this.createNewImg() + }else if(!this.onceCode){ + this.$msg('小程序码生成失败!') + }else if(!this.backgroundImg){ + this.$msg('海报背景图生成失败!') } }, fail: err => { @@ -97,7 +115,8 @@ createNewImg() { var that = this; var context = wx.createCanvasContext('mycanvas'); - var path = "../../static/images/bill.png"; + console.log('画布', that.backgroundImg) + var path = that.backgroundImg; context.drawImage(path, 0, 0, 375, 667); //绘制二维码 let wxcode = that.onceCode @@ -115,7 +134,7 @@ canvasId: 'mycanvas', success: function(res) { that.imagePath = res.tempFilePath; - if(that.imagePath) { + if (that.imagePath) { that.canvasHidden = true that.maskHidden = true } @@ -125,7 +144,7 @@ console.log(res); } }); - },900); + }, 900); }, saveBill() { var that = this @@ -166,14 +185,14 @@ width: 100%; height: 366rpx; } - + .mine { display: block; text-align: center; color: #333; margin-top: 44rpx; } - + .code { display: block; text-align: center; @@ -182,7 +201,7 @@ font-weight: bold; margin-top: 30rpx; } - + .who { display: block; margin-top: 80rpx; @@ -190,12 +209,12 @@ color: #333; text-align: center; } - + .inputBox { text-align: center; margin-top: 44rpx; } - + .input { text-align: center; width: 440rpx; @@ -205,7 +224,7 @@ font-size: 32rpx; display: inline-block; } - + .btn { width: 160rpx; height: 88rpx; @@ -218,18 +237,18 @@ line-height: 88rpx; margin-left: 40rpx; } - + button[class="btn"]::after { border: 0; } - + .tishi { display: block; text-align: center; color: #999; margin-top: 30rpx; } - + .shareText { display: block; text-align: center; @@ -237,24 +256,24 @@ font-size: 28rpx; margin-top: 100rpx; } - + .imgBox { text-align: center; width: 100%; margin-top: 60rpx; padding-bottom: 120rpx; } - + .img { display: inline-block; width: 100%; height: 100%; } - + .m_l { margin-left: 180rpx; } - + .zfbtn { display: inline-block; width: 120rpx; @@ -265,15 +284,15 @@ border: 0; padding: 0; } - + button[class="zfbtn"]::after { border: 0; } - + button[class="zfbtn m_l"]::after { border: 0; } - + .imagePathBox { width: 100%; height: 100%; @@ -285,7 +304,7 @@ bottom: 0; z-index: 10; } - + .shengcheng { width: 80%; height: 80%; @@ -295,7 +314,7 @@ margin-left: -40%; z-index: 10; } - + .baocun { display: block; width: 80%; @@ -311,7 +330,7 @@ font-size: 32rpx; border-radius: 44rpx; } - + button[class="baocun"]::after { border: 0; } diff --git a/pages/center/widthdraw.vue b/pages/center/widthdraw.vue index 3520e13..a768036 100644 --- a/pages/center/widthdraw.vue +++ b/pages/center/widthdraw.vue @@ -1,50 +1,6 @@ @@ -52,18 +8,15 @@ export default { data() { return { - num: '', - showClean: false + userInfo: '' } }, methods: { - clearAble() { - this.num = '' - this.showClean = false - }, - showClear() { - this.showClean = true - } + + }, + onLoad(e) { + this.userInfo = uni.getStorageSync('userinfo') || {}; + console.log(this.userInfo) } } diff --git a/pages/goodsDetail/index.vue b/pages/goodsDetail/index.vue index 11d2a61..597db58 100644 --- a/pages/goodsDetail/index.vue +++ b/pages/goodsDetail/index.vue @@ -138,7 +138,8 @@ wxCode: '', onceCode: '', pt: 1, - afterDone: '' + afterDone: '', + backgroundImg: '' } }, computed: { @@ -153,8 +154,25 @@ this.pt = options.pt || 1; this.getGoodsDetail(); this.getWxCode() + this.getBackground() }, methods: { + getBackground() { + let _this = this + _this.$http(_this.API.API_BILLBACKGROUND, { + type: 'goods' + }).then(res => { + let img = res.data.img_url + if (img) { + wx.getImageInfo({ + src: img, + success: function(sres) { + _this.backgroundImg = sres.path + } + }) + } + }) + }, //商品绑定 bindGoods() { var _this = this; @@ -186,21 +204,16 @@ }, getWxCode() { let userInfo = uni.getStorageSync('userinfo') || {}; - uni.request({ - url: 'http://dev-gxsky.com/api/salesman/qrcode', //仅为示例,并非真实接口地址。 - data: { - scene: 'route=goods&pt=2&id='+this.goods_id+'&share_id='+userInfo.id, - page: 'pages/route/index', - width: '2800' - }, - method: 'POST', - success: (res) => { - this.wxCode = res.data.data.base_url - if (this.wxCode) { - this.getwxCodeImg() - } + this.$http(this.API.API_WXBILL, { + scene: 'route=goods&pt=2&id='+this.goods_id+'&share_id='+userInfo.id, + page: 'pages/route/index', + width: '2800' + }).then(res => { + this.wxCode = res.data.base_url + if (this.wxCode) { + this.getwxCodeImg() } - }); + }) }, //海报开始 //保存头像 @@ -223,7 +236,7 @@ createNewImg() { var that = this; var context = wx.createCanvasContext('mycanvas'); - var path = "../../static/images/bill.png"; + var path = that.backgroundImg; context.drawImage(path, 0, 0, 375, 667); //绘制二维码 let wxcode = that.onceCode @@ -286,8 +299,14 @@ duration: 1000 }); wx.hideToast() - if(that.onceCode) { + console.log(that.onceCode) + console.log(that.backgroundImg) + if(that.onceCode&&that.backgroundImg) { that.createNewImg() + }else if(!that.onceCode){ + this.$msg('小程序码生成失败!') + }else if(!that.backgroundImg){ + this.$msg('海报背景图生成失败!') } }, //海报结束 diff --git a/pages/index/index.vue b/pages/index/index.vue index b455c28..7cc1d10 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -70,7 +70,7 @@ this.windowHeight = getApp().globalData.windowHeight; this.getCategoryList(); this.getShareInfo(); - if(this.pt == 1) { + if(this.pt == 2) { this.bindUsders() } },