diff --git a/app.js b/app.js index d4cb62e..3368b5d 100644 --- a/app.js +++ b/app.js @@ -41,6 +41,7 @@ App({ data: usrdata }) .then(res => { + wx.setStorageSync('openId',res.data.openId) if (res.data && res.data.score) { if (res.data.score != 0) { that.globalData.score = res.data.score; diff --git a/components/advertisement/advertisement.js b/components/advertisement/advertisement.js new file mode 100644 index 0000000..b7669e2 --- /dev/null +++ b/components/advertisement/advertisement.js @@ -0,0 +1,68 @@ +// components/advertisement.js +const Http = require("../../utils/HttpBasics"); +var config = require("../../config/config.js"); +Component({ + properties: { + ggdata: { + type: Object, + value: {} + } + }, + data: { + flag: false, + alphaData: null, + gameUrl: '' + }, + methods: { + gotoGg: function (e) { + let that = this; + Http.get({ + url: config.api.checkPhoneStatus, + data: {} + }) + .then(res => { + console.log(e.currentTarget.dataset) + wx.navigateTo({ + url: '/pages/coupon/detail/index?couponChannelId=' + e.currentTarget.dataset.data.produceId , + }) + }) + .catch(err => { + if (err.code == 11005) { + // 用户手机未授权 + /** + * 将值传到用户手机号授权的页面 + * + */ + wx.redirectTo({ + url: "/pages/getphoneInfo/index?path=index&pagePath=" + e.currentTarget.dataset.data.pagePath + "&id=" + e.currentTarget.dataset.data.id + "&couponChannelId=" + e.currentTarget.dataset.data.produceId + }); + } else if (err.code == 11006) { + // 用户手机已加密 + wx.redirectTo({ + url: "/pages/phoneinput/phoneinput?path=index&pagePath=" + e.target.dataset.data.pagePath + "&id=" + e.currentTarget.dataset.data.id + "&couponChannelId=" + e.currentTarget.dataset.data.produceId + }); + } else { + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); + } + }) + }, + a: function () { + this.setData({ flag: false }) + }, + closeGg: function () { + let that = this; + var animation = wx.createAnimation({}) + // animation.opacity(0).step({ duration: 1000 }) + setTimeout(function () { + that.setData({ flag: true }) + }, 500) + animation.rotateZ(180).scale(0).opacity(0.5).step({ duration: 1000 }) + that.setData({ alphaData: animation.export() }); + }, + }, +}); diff --git a/components/advertisement/advertisement.json b/components/advertisement/advertisement.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/components/advertisement/advertisement.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/components/advertisement/advertisement.wxml b/components/advertisement/advertisement.wxml new file mode 100644 index 0000000..6eac179 --- /dev/null +++ b/components/advertisement/advertisement.wxml @@ -0,0 +1,10 @@ + + diff --git a/components/advertisement/advertisement.wxss b/components/advertisement/advertisement.wxss new file mode 100644 index 0000000..88025ae --- /dev/null +++ b/components/advertisement/advertisement.wxss @@ -0,0 +1,37 @@ +/* components/advertisement.wxss */ +.b1{ + position:fixed; + width:100%; + height:100%; + top:0px; + background:rgba(0,0,0,0.8); + overflow: hidden; + z-index: 1000; +} +.t_w{ + position:relative; +} +.b2{ + width: 90%; + margin:45% auto; + overflow: hidden; + border-radius: 10rpx; +} +.t_image{ + border-radius: 16rpx; + display: block; + margin: 0 auto; +} +.cancel_icon{ + position: absolute; + right: 300rpx; + bottom: -200rpx; +} +.line{ + width:2rpx; + height: 75rpx; + background: #fff; + position: absolute; + right: 340rpx; + bottom: -125rpx; +} \ No newline at end of file diff --git a/components/hot/index.js b/components/hot/index.js index f846bfc..7ed9f76 100644 --- a/components/hot/index.js +++ b/components/hot/index.js @@ -128,7 +128,7 @@ Component({ e.currentTarget.dataset.targetad }` }); - }, + }, }, ready() { app.couponChannelListCallback = (token,val) => { diff --git a/config/config.js b/config/config.js index 4db2127..2b23156 100755 --- a/config/config.js +++ b/config/config.js @@ -171,6 +171,10 @@ var config = { * 小程序获取游戏路径 */ getGame:'/game/getOne', + /** + * 小程序获取广告路径 + */ + getGg: '/floatingLayer/getFloatingLayer', /** * 小程序某一个游戏信息 */ diff --git a/index/index.js b/index/index.js index 799f171..2a559fd 100644 --- a/index/index.js +++ b/index/index.js @@ -74,7 +74,10 @@ Page({ display: 'none', display1: 'none', optionsData: null, - page: 1 // 刷新进入页面时已经加载了第一页数据,onReachBottom时 page++,从第2页开始加载 + page: 1 ,// 刷新进入页面时已经加载了第一页数据,onReachBottom时 page++,从第2页开始加载 + openId:'', + showGg: false, + ggdata:{} }, alphaClick: function(even) { var animation = wx.createAnimation({}) @@ -189,6 +192,12 @@ Page({ this.getLocation(); let that = this; let optionss; + let openId = wx.getStorageSync('openId') + if(openId){ + that.setData({ + openId:openId + }) + } if (wx.getStorageSync('options')){ optionss = JSON.parse(wx.getStorageSync('options')); } @@ -284,7 +293,7 @@ Page({ levelName: res.data.levelName, upgradePercent: res.data.upgradePercent, upgradeScore: res.data.upgradeScore, - memberId: res.data.id + memberId: res.data.id, }) }) .catch(err => { @@ -347,6 +356,7 @@ Page({ that.topicShow(); that.getxsList(); that.getMallInfo(app.globalData.token); + if (app.couponChannelListCallback) { app.couponChannelListCallback(app.globalData.token); } @@ -363,8 +373,10 @@ Page({ } }) .then(res => { - that.getGameOne(app.globalData.token) + console.log(res) + // that.getGameOne(app.globalData.token) that.getStaticGame(app.globalData.token) + that.getGg(app.globalData.token) let weapNote = JSON.parse(res.data.weapNote); that.setData({ desc: weapNote.firstpage.desc, @@ -372,8 +384,9 @@ Page({ }) }) .catch(err => { - that.getGameOne(app.globalData.token) + // that.getGameOne(app.globalData.token) that.getStaticGame(app.globalData.token) + that.getGg(app.globalData.token) wx.showModal({ title: "提示", content: err.errMsg, @@ -616,6 +629,42 @@ Page({ e.currentTarget.dataset.couponchannelid }&couponId=${e.currentTarget.dataset.couponid}` }); + }, + //浮层广告 + getGg: function (token) { + let that = this + Http.get({ + url: config.api.getGg, + data: { + token: token, + appId: config.weapp.AppId, + openId: that.data.openId + } + }).then(res => { + console.log(res) + if (res.data.id) { + that.setData({ + showGg: true, + }) + console.log(that.data.showGg,1111111111111) + } else { + that.setData({ + showGg: false + }) + that.getGameOne(app.globalData.token) + console.log(that.data.showGg,222222222222222222) + } + that.setData({ + ggdata: res.data + }) + }) + .catch(err => { + this.setData({ + showGg: false + }) + that.getGameOne(app.globalData.token) + that.alphaClick(); + }) }, /** * 刷新 diff --git a/index/index.json b/index/index.json index f502a8d..6f75e0c 100644 --- a/index/index.json +++ b/index/index.json @@ -5,6 +5,7 @@ "c-coupons": "../pages/main/coupons/index", "g-entry": "../components/gameentry/gentry", "c-hot": "../components/hot/index", + "c-advertisement":"../components/advertisement/advertisement", "navbar": "../components/navbar/navbar" }, "enablePullDownRefresh": true, diff --git a/index/index.wxml b/index/index.wxml index 40e47a6..ee80a87 100644 --- a/index/index.wxml +++ b/index/index.wxml @@ -105,7 +105,10 @@ + + +