From d10fbbd9e6a678d4af586a58dfd1009348f406ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=99=96?= Date: Sat, 16 Feb 2019 17:15:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E8=B5=A0=E5=88=86=E4=BA=AB=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/ConsumeDetail/ConsumeDetail.js | 23 ++++++++- pages/coupon/detail/index.js | 60 +++++++++++++++++++++- pages/coupon/detail/index.wxml | 9 ++++ pages/coupon/detail/index.wxss | 77 ++++++++++++++++++++++++++++ pages/getphoneInfo/index.js | 8 +-- pages/getuserinfo/index.js | 29 +++++++++-- pages/index/index.js | 20 +++++--- pages/phoneinput/phoneinput.js | 8 +-- utils/imgurl.js | 4 ++ 9 files changed, 218 insertions(+), 20 deletions(-) diff --git a/pages/ConsumeDetail/ConsumeDetail.js b/pages/ConsumeDetail/ConsumeDetail.js index cd9ad70..2b1b381 100644 --- a/pages/ConsumeDetail/ConsumeDetail.js +++ b/pages/ConsumeDetail/ConsumeDetail.js @@ -72,7 +72,7 @@ Page({ let _this = this; return { title: '领取卡', - path: '/pages/index/index?couponChannelId=' + this.data.cardDetail.couponChannelId + '&cuserId=' + this.data.cardDetail.cuserId + '&couponId=' + this.data.cardDetail.couponId + '&coverImg' + this.data.cardDetail.coverImg, + path: '/pages/index/index?couponChannelId=' + this.data.cardDetail.couponChannelId + '&cuserId=' + this.data.cardDetail.cuserId + '&couponId=' + this.data.cardDetail.couponId + '&coverImg=' + this.data.cardDetail.coverImg + '&userName=' + this.data.userName + '&avatarUrl=' + this.data.avatarUrl, imageUrl: this.data.cardDetail.coverImg, success: function (res) { // 转发成功 @@ -145,6 +145,21 @@ Page({ }); }) }, + getUserInfo: function () { + let that = this; + // 获取用户信息 + Http.get({ + url: config.api.getScore, + data: {} + }) + .then(res => { + console.log(res) + that.setData({ + userName: res.data.name, + avatarUrl: res.data.avatarUrl, + }) + }) + }, cardDetail: function(couponOrderId) { let that = this; Http.get({ @@ -162,6 +177,12 @@ Page({ cardDetail: res.data, supportTransfer: res.data.supportTransfer }) + /** + * 若可转赠获取用户头像信息 + */ + if (res.data.supportTransfer){ + that.getUserInfo() + } if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length<=4){ that.setData({ height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx', diff --git a/pages/coupon/detail/index.js b/pages/coupon/detail/index.js index 31a7e98..49a592c 100644 --- a/pages/coupon/detail/index.js +++ b/pages/coupon/detail/index.js @@ -12,6 +12,7 @@ Page({ quesGouUrl: imgurl.ques_gou.url, headbgUrl: imgurl.headbg.url, quesBgUrl: imgurl.ques_bg.url, + close02: imgurl.close02.url, data: { title: null }, @@ -46,7 +47,9 @@ Page({ queueData: null, zIndex: 11, display: "none", - showbutton: false + showbutton: false, + cardData:null, + showCardOffer:false }, phone: function (e) { let that = this; @@ -54,6 +57,14 @@ Page({ phoneNumber: e.target.dataset.merchantlinkphone }); }, + receiveCard(){ + + }, + closeAlert(){ + this.setData({ + showCardOffer:false + }) + }, goback: function () { wx.switchTab({ url: '/pages/login/index', @@ -219,6 +230,9 @@ Page({ d1: sec } }, + /** + * 获取用户信息 + */ onLoad(options) { let that = this; wx.showLoading({ @@ -228,7 +242,12 @@ Page({ * 转赠判断 */ if (options.cuserId){ - + this.setData({ + showCardOffer:true, + cardData:options + }) + console.log(options,22222222222) + // this.getUserInfo() } that.setData({ couponChannelId: options.couponChannelId, @@ -348,6 +367,43 @@ Page({ } }) }, + /** + * + */ + checkPhoneStatus: function () { + let that = this; + Http.post({ + url: config.api.checkPhoneStatus, + data: {} + }) + .then(res => { + console.log(666,'授权成功!') + }) + .catch(err => { + if (err.code == 11005) { + // 用户手机未授权 + /** + * 将值传到用户手机号授权的页面 + * + */ + wx.redirectTo({ + url: "/pages/getphoneInfo/index?path=index&cuserId=" + that.data.cardData.cuserId + "&couponChannelId=" + that.data.cardData.couponChannelId + "&couponId=" + that.data.cardData.couponId + "&userName=" + that.data.cardData.userName + "&coverImg=" + that.data.cardData.coverImg + "&avatarUrl=" + that.data.cardData.avatarUrl, + }); + } else if (err.code == 11006) { + // 用户手机已加密 + wx.redirectTo({ + url: "/pages/phoneinput/phoneinput?path=index&cuserId=" + that.data.cardData.cuserId + "&couponChannelId=" + that.data.cardData.couponChannelId + "&couponId=" + that.data.cardData.couponId + "&userName=" + that.data.cardData.userName + "&coverImg=" + that.data.cardData.coverImg + "&avatarUrl=" + that.data.cardData.avatarUrl, + }); + } else { + wx.showToast({ + title: err.message, + icon: 'none', + duration: 2000, + mask: false + }); + } + }) + }, /** * 发起支付 */ diff --git a/pages/coupon/detail/index.wxml b/pages/coupon/detail/index.wxml index 014d7fe..95ccd8f 100644 --- a/pages/coupon/detail/index.wxml +++ b/pages/coupon/detail/index.wxml @@ -128,4 +128,13 @@ + + + + + + {{cardData.userName+'送您一张消费卡'}} + + + \ No newline at end of file diff --git a/pages/coupon/detail/index.wxss b/pages/coupon/detail/index.wxss index d2d876f..e801988 100644 --- a/pages/coupon/detail/index.wxss +++ b/pages/coupon/detail/index.wxss @@ -527,3 +527,80 @@ button::after{ border: none; } background:rgba(236,59,45,1); box-shadow:0px 8px 8px 1px rgba(246,93,51,0.32); } +.support-tansfer{ + width: 60%; + border-radius: 50rpx; + margin-top: 30rpx; + background: #02C0FF!important; +} +.shaddow{ + z-index: 100; + position:fixed; + width:100%; + height:100%; + top:0px; + background:rgba(0,0,0,0.8); + overflow:hidden; +} +.alert-box{ + position: fixed; + top: 200rpx; + left: 10%; + width: 80%; + height: auto; + padding-bottom: 20rpx; + background: #fff; + z-index: 200; + border-radius: 20rpx; +} +.user-img{ + position: absolute; + top: -50rpx; + left: 250rpx; + /* margin-left: -50rpx; */ + width: 100rpx; + height: 100rpx; + z-index: 300; + border-radius: 50rpx; + background: #fff; + overflow: hidden; +} +.user-img image{ + width: 100rpx; + height: 100rpx; +} +.close{ + position: absolute; + z-index: 300; + right: 26rpx; + top: 26rpx; + width: 26rpx; + height: 26rpx; + overflow: hidden; +} +.close image{ + display: block; + width: 26rpx; + height: 26rpx; +} +.a-title{ + text-align: center; + margin-top: 76rpx; + font-size:36rpx; + font-family:PingFang-SC-Medium; + font-weight:500; + color:rgba(51,51,51,1); + line-height:44rpx; +} +.a-img{ + width: 80%; + border-radius: 20rpx; + height: 294rpx; + overflow: hidden; + text-align: center; + margin: 30rpx auto 0; +} +.a-img image{ + width: 100%; + height: 100%; +} \ No newline at end of file diff --git a/pages/getphoneInfo/index.js b/pages/getphoneInfo/index.js index 03f0fb3..e92a531 100755 --- a/pages/getphoneInfo/index.js +++ b/pages/getphoneInfo/index.js @@ -64,13 +64,13 @@ Page({ /** * fromId若存在来自卡转赠 */ - if (that.path == 'index' && !that.data.paramData.fromId) { + if (that.path == 'index' && !that.data.paramData.cuserId) { wx.redirectTo({ url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId, }) - } else if (that.path == 'index' && that.data.paramData.fromId){ - wx.redirectTo({ - url: "pages/discountCardList/discountCardList?fromId=" + that.data.paramData.fromId + } else if (that.path == 'index' && that.data.paramData.cuserId){ + wx.reLaunch({ + url: "/pages/coupon/detail/index?cuserId=" + that.data.paramData.cuserId + '&couponChannelId='+that.data.paramData.couponChannelId + '&couponId=' + that.data.paramData.couponId + '&coverImg=' +that.data.paramData.coverImg + '&avatarUrl=' + that.data.paramData.avatarUrl + '&userName=' +that.data.paramData.userName }) } else { wx.showToast({ diff --git a/pages/getuserinfo/index.js b/pages/getuserinfo/index.js index 2c905d7..e0551f7 100755 --- a/pages/getuserinfo/index.js +++ b/pages/getuserinfo/index.js @@ -7,16 +7,32 @@ Page({ path:null, couponChannelId: null, couponId:null, + cuserId:null, + coverImg:null }, onLoad: function(options) { var that = this; - if (options.couponChannelId && options.couponId||options.orderId) { + if (options.couponChannelId && options.couponId && !options.cuserId||options.orderId) { that.setData({ couponChannelId: options.couponChannelId, couponId: options.couponId, orderId:options.orderId }) } + /** + * 来自转赠 + */ + if (options.couponChannelId && options.cuserId){ + console.log(1231231231) + that.setData({ + couponChannelId: options.couponChannelId, + couponId: options.couponId, + cuserId: options.cuserId, + coverImg: options.coverImg, + userName: options.userName, + avatarUrl: options.avatarUrl + }) + } if (options.path == 'index') { that.path = options.path } @@ -63,11 +79,18 @@ Page({ }); } else { //返回主页 - if (that.data.couponChannelId && that.data.couponId) { + if (that.data.couponChannelId && that.data.couponId && !that.data.cuserId) { wx.navigateTo({ url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}&couponId=${that.data.couponId}` }); - } else if (that.data.orderId) { + } else if (that.data.couponChannelId && that.data.couponId && that.data.cuserId) { + /** + * 来自转赠 + */ + wx.reLaunch({ + url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}&couponId=${that.data.couponId}&cuserId=${that.data.cuserId}&coverImg=${that.data.coverImg}&userName=${that.data.userName}&avatarUrl=${that.data.avatarUrl}` + }); + } else if (that.data.orderId) { wx.navigateTo({ url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}&from=${"friend"}` }); diff --git a/pages/index/index.js b/pages/index/index.js index 894e6c6..f3bc31f 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -13,6 +13,7 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function(options) { + console.log(options) let that = this; wx.showToast({ title: '加载中', @@ -36,7 +37,7 @@ Page({ /** * 转赠判断 */ - that.userLogin(options.couponChannelId, options.couponId, null, options.cuserId, options.coverImg); + that.userLogin(options.couponChannelId, options.couponId, null, options.cuserId, options.coverImg, options.userName, options.avatarUrl); }else{ that.userLogin(options.couponChannelId, options.couponId, options.orderId); } @@ -44,7 +45,7 @@ Page({ that.userLogin() } }, - checkuerstatus(couponChannelId, couponId, orderId, cuserId, coverImg) { + checkuerstatus(couponChannelId, couponId, orderId, cuserId, coverImg, userName, avatarUrl) { let that = this; Http.post({ url: config.api.checkUserStatus, @@ -60,7 +61,7 @@ Page({ * 转赠判断 */ wx.redirectTo({ - url: `/pages/coupon/detail/index?couponChannelId=${couponChannelId}&couponId=${couponId}&cuserId=${cuserId}&coverImg=${coverImg}`, + url: `/pages/coupon/detail/index?couponChannelId=${couponChannelId}&couponId=${couponId}&cuserId=${cuserId}&coverImg=${coverImg}&userName=${userName}&avatarUrl=${avatarUrl}`, }) } else if (orderId) { wx.redirectTo({ @@ -75,10 +76,17 @@ Page({ .catch(err => { if (err.code == 11004) { // 用户昵称未授权 - if (couponChannelId && couponId) { + if (couponChannelId && couponId && !cuserId) { wx.redirectTo({ url: `/pages/getuserinfo/index?couponChannelId=${couponChannelId}&couponId=${couponId}` }); + } else if (couponChannelId && couponId && cuserId){ + /** + * 转赠判断 + */ + wx.redirectTo({ + url: `/pages/getuserinfo/index?couponChannelId=${couponChannelId}&couponId=${couponId}&cuserId=${cuserId}&coverImg=${coverImg}&userName=${userName}&avatarUrl=${avatarUrl}` + }); } else if (orderId) { wx.redirectTo({ url: `/pages/getuserinfo/index?orderId=${orderId}&from='${"discount"}` @@ -94,7 +102,7 @@ Page({ /** * 用户登录 */ - userLogin: function (couponChannelId, couponId, orderId, cuserId) { + userLogin: function (couponChannelId, couponId, orderId, cuserId, coverImg, userName, avatarUrl) { var that = this; // 登录 wx.login({ @@ -137,7 +145,7 @@ Page({ app.globalData.token = res.data.token; Http.setToken(res.data.token); if (couponChannelId&&couponId || orderId){ - that.checkuerstatus(couponChannelId, couponId, orderId, cuserId, coverImg); + that.checkuerstatus(couponChannelId, couponId, orderId, cuserId, coverImg, userName, avatarUrl); }else{ that.checkuerstatus(); } diff --git a/pages/phoneinput/phoneinput.js b/pages/phoneinput/phoneinput.js index 6cd1e8e..52e1704 100644 --- a/pages/phoneinput/phoneinput.js +++ b/pages/phoneinput/phoneinput.js @@ -51,11 +51,11 @@ Page({ }) }else{ /** - * fromId若存在来自卡转赠 + * cuserId若存在来自卡转赠 */ - if (this.data.paramData.fromId){ - wx.redirectTo({ - url: "pages/discountCardList/discountCardList?fromId=" + that.data.paramData.fromId + if (this.data.paramData.cuserId){ + wx.reLaunch({ + url: "/pages/coupon/detail/index?cuserId=" + that.data.paramData.cuserId + '&couponChannelId=' + + that.data.paramData.couponChannelId + '&couponId=' + + that.data.paramData.couponId + '&coverImg=' + + that.data.paramData.coverImg + '&avatarUrl=' + + that.data.paramData.avatarUrl + '&userName=' + + that.data.paramData.userName }) }else{ wx.redirectTo({ diff --git a/utils/imgurl.js b/utils/imgurl.js index 1e54e33..c340791 100644 --- a/utils/imgurl.js +++ b/utils/imgurl.js @@ -348,4 +348,8 @@ module.exports = { 'url': baseUrl + 'weixin-title.png', 'name': '微信图标' }, + 'close02': { + 'url': baseUrl + 'close02.png', + 'name': '关闭图标' + }, } \ No newline at end of file