From b4200f52489176de1c1179b9e79dcb14c96a1828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=B7=E6=B4=8B=E4=B9=8B=E5=A3=B0?= Date: Thu, 18 Oct 2018 19:26:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 2 +- components/gameentry/gentry.js | 47 +++++++++++++++++++++++++++++++-- pages/game/index.json | 2 +- pages/getphoneInfo/index.js | 48 ++++++++++++++++++++-------------- pages/getuserinfo/index.js | 23 +++++++++++----- pages/index/index.js | 9 +++++-- pages/index/index.wxml | 2 +- pages/phoneinput/phoneinput.js | 18 ++++++++++--- project.config.json | 2 +- 9 files changed, 116 insertions(+), 37 deletions(-) diff --git a/app.json b/app.json index fc272a3..fab9bca 100644 --- a/app.json +++ b/app.json @@ -1,6 +1,7 @@ { "pages": [ "pages/index/index", + "pages/game/index", "pages/edit/edit", "pages/cartest/cartest", "pages/actdetail/actdetail", @@ -30,7 +31,6 @@ "pages/passCar/couponDetail/couponDetail", "pages/managelicenseplate/managelicenseplate", "pages/payrule/payrule", - "pages/game/index", "pages/grade/grade" ], "tabBar": { diff --git a/components/gameentry/gentry.js b/components/gameentry/gentry.js index 3a1d955..118878b 100644 --- a/components/gameentry/gentry.js +++ b/components/gameentry/gentry.js @@ -1,4 +1,6 @@ // pages/index/sw/index.js +const Http = require("../../utils/HttpBasics"); +var config = require("../../config/config.js"); Component({ properties: { gamedata: { @@ -12,8 +14,49 @@ Component({ }, methods:{ gotogame: function (e) { - wx.navigateTo({ - url: '/pages/game/index?url=' + e.target.dataset.data.url + "&id=" + e.target.dataset.data.id + "&gameId=" + e.target.dataset.data.gameId, + let that=this; + Http.post({ + url: config.api.checkPhoneStatus, + data: {} + }) + .then(res => { + console.log(res); + var data = { + couponChannelId: "" + that.data.couponChannelId, + couponId: "" + that.data.couponId + }; + if (that.data.couponChannelId == null) { + var data = { + couponId: "" + that.data.couponId + }; + } + wx.navigateTo({ + url: '/pages/game/index?url=' + e.target.dataset.data.url + "&id=" + e.target.dataset.data.id + "&gameId=" + e.target.dataset.data.gameId, + }) + }) + .catch(err => { + if (err.code == 11005) { + // 用户手机未授权 + /** + * 将值传到用户手机号授权的页面 + * + */ + wx.redirectTo({ + url: "/pages/getphoneInfo/index?path=index" + }); + } else if (err.code == 11006){ + // 用户手机已加密 + wx.redirectTo({ + url: "/pages/phoneinput/phoneinput?path=index" + }); + }else { + wx.showToast({ + title: err.message, + image: "../../assets/img/fail.png", + duration: 2000, + mask: false + }); + } }) }, a: function () { diff --git a/pages/game/index.json b/pages/game/index.json index 0d6ac40..bfbf839 100644 --- a/pages/game/index.json +++ b/pages/game/index.json @@ -2,5 +2,5 @@ "usingComponents": { }, - "navigationBarTitleText": "" + "navigationBarTitleText": "富茂小游戏" } \ No newline at end of file diff --git a/pages/getphoneInfo/index.js b/pages/getphoneInfo/index.js index 4cc1038..3a227bf 100755 --- a/pages/getphoneInfo/index.js +++ b/pages/getphoneInfo/index.js @@ -5,9 +5,13 @@ Page({ data: { canIUse: wx.canIUse("button.open-type.getPhoneNumber"), couponChannelId: "", - couponId: "" + couponId: "", + path:null }, onLoad: function (options) { + if(options.path=='index'){ + this.path = options.path + } var that = this; console.log(options); if (options.couponChannelId && options.couponId) { @@ -52,25 +56,31 @@ Page({ console.log(that.data.couponId); console.log("这是从立即支付传回来的值 因为用户没有授权手机号"); app.globalData.phone = res.data.phone; - wx.showToast({ - title: res.data.msg, - icon: "success", - success: function (res) { - if (that.data.couponChannelId && that.data.couponId) { - wx.redirectTo({ - url: "/pages/coupon/detail/index?couponChannelId=" + - that.data.couponChannelId + - "&couponId=" + - that.data.couponId + - "&flag=pay" - }) - } else { - wx.switchTab({ - url: '/pages/passCar/passCar', - }) + if (that.path == 'index') { + wx.reLaunch({ + url: "/pages/game/index" + }) + } else { + wx.showToast({ + title: res.data.msg, + icon: "success", + success: function (res) { + if (that.data.couponChannelId && that.data.couponId) { + wx.redirectTo({ + url: "/pages/coupon/detail/index?couponChannelId=" + + that.data.couponChannelId + + "&couponId=" + + that.data.couponId + + "&flag=pay" + }) + } else { + wx.switchTab({ + url: '/pages/passCar/passCar', + }) + } } - } - }); + }); + } }, function (error) { wx.showToast({ diff --git a/pages/getuserinfo/index.js b/pages/getuserinfo/index.js index 19c9b4c..77880d7 100755 --- a/pages/getuserinfo/index.js +++ b/pages/getuserinfo/index.js @@ -3,10 +3,14 @@ var app = getApp(); const Http = require("../../utils/HttpBasics"); Page({ data: { - canIUse: wx.canIUse("button.open-type.getUserInfo") + canIUse: wx.canIUse("button.open-type.getUserInfo"), + path:null }, onLoad: function(options) { var that = this; + if (options.path == 'index') { + this.path = options.path + } Http.get({ url: config.api.marketicon, data: { @@ -24,6 +28,7 @@ Page({ }, bindGetUserInfo: function(e) { + let that=this; console.log(e); var iv = e.detail.iv; var encryptedData = e.detail.encryptedData; @@ -38,11 +43,17 @@ Page({ }).then( function(res) { console.log(res); - console.log("授权个人信息返回的数据") - //返回主页 - wx.switchTab({ - url: "/pages/index/index" - }); + console.log("授权个人信息返回的数据", that.path) + if(that.path=='index'){ + wx.reLaunch({ + url: "/pages/game/index" + }); + }else{ + //返回主页 + wx.switchTab({ + url: "/pages/index/index" + }); + } }, function(error) { wx.showToast({ diff --git a/pages/index/index.js b/pages/index/index.js index 6344361..c7dd268 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -13,6 +13,7 @@ Page({ gamedata:{}, couponId:'',//游戏返回时传回的字段 played:false,//从游戏页面跳回首页返回true + havePlayEd: app.globalData.havePlayEd, page: 1 // 刷新进入页面时已经加载了第一页数据,onReachBottom时 page++,从第2页开始加载 }, swiperChange: function(e) { @@ -25,7 +26,6 @@ Page({ url: '../game/index', }) }, - /** * 生命周期函数--监听页面初次渲染完成 */ @@ -68,6 +68,10 @@ Page({ }) }, onShow:function(){ + // console.log(app.globalData.havePlayEd) + this.setData({ + havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd:false + }) let num = wx.getStorageSync('couponNum'); if (num =='couponNum'){ wx.showTabBarRedDot({ @@ -155,7 +159,7 @@ Page({ } Http.setToken(res.data.token); that.checkUserCarStatus(); - that.getUserInfo(); + // that.getUserInfo(); that.getBannerlist(); if (app.couponChannelListCallback) { app.couponChannelListCallback(app.globalData.token); @@ -269,6 +273,7 @@ Page({ wx.getUserInfo({ success: res => { // 可以将 res 发送给后台解码出 unionId + debugger console.log("getUserInfo", res); } }); diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 58a66cb..936062a 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -7,5 +7,5 @@ 独家福利,抢完即止 - + \ No newline at end of file diff --git a/pages/phoneinput/phoneinput.js b/pages/phoneinput/phoneinput.js index 69d2813..f8a081f 100644 --- a/pages/phoneinput/phoneinput.js +++ b/pages/phoneinput/phoneinput.js @@ -10,9 +10,13 @@ Page({ retry: false, time: 60, couponChannelId: null, - couponId:null + couponId:null, + path:null }, onLoad: function (options) { + if(options.path=='index'){ + this.path = options.path + } var that = this; console.log(options); that.setData({ @@ -39,9 +43,15 @@ Page({ } }) .then(res => { - wx.redirectTo({ - url: '/pages/coupon/detail/index?couponChannelId=' + that.data.couponChannelId + '&couponId=' + that.data.couponId + "&flag=pay", - }) + if(that.path!=null){ + wx.redirectTo({ + url: "/pages/index/index" + }) + }else{ + wx.redirectTo({ + url: '/pages/coupon/detail/index?couponChannelId=' + that.data.couponChannelId + '&couponId=' + that.data.couponId + "&flag=pay", + }) + } }) .catch(error => { wx.showToast({ diff --git a/project.config.json b/project.config.json index 24c5fbf..48c9f0c 100644 --- a/project.config.json +++ b/project.config.json @@ -4,7 +4,7 @@ "ignore": [] }, "setting": { - "urlCheck": false, + "urlCheck": true, "es6": true, "postcss": true, "minified": true,