diff --git a/app.js b/app.js index ce49c6b..1e3b73b 100644 --- a/app.js +++ b/app.js @@ -3,6 +3,7 @@ const Http = require("./utils/HttpBasics"); App({ data: {}, onLaunch: function(options) { + console.log("onUnload ") var that = this; that.globalData.sceneAddress = options.scene; }, diff --git a/app.json b/app.json index ca01d16..ee35fd2 100644 --- a/app.json +++ b/app.json @@ -1,6 +1,7 @@ { "pages": [ "pages/index/index", + "pages/login/index", "pages/bargain/bargainDatail/bargainDatail", "pages/bargain/bargain", "pages/cardorder/index/index", @@ -22,7 +23,6 @@ "pages/order/detail/index", "pages/order/index/index", "pages/success/index", - "pages/login/index", "pages/park/park", "pages/ques/ques", "pages/passCar/passCar", @@ -36,6 +36,7 @@ "pages/payrule/payrule", "pages/grade/grade", "pages/game/index", + "pages/login/gameentry/gentry", "pages/index/gameentry/gentry", "pages/specialcourtesy/specialcourtesy", "pages/discountCardList/discountCardList", @@ -61,7 +62,7 @@ "selectedColor": "#00C0FF", "list": [ { - "pagePath": "pages/index/index", + "pagePath": "pages/login/index", "iconPath": "assets/images/home-n.png", "selectedIconPath": "assets/images/home-y.png", "text": "首页" @@ -83,7 +84,7 @@ "window": { "backgroundTextStyle": "red", "navigationBarBackgroundColor": "#02C0FF", - "navigationBarTitleText": "WeChat", + "navigationBarTitleText": "", "navigationBarTextStyle": "white" }, "networkTimeout": { diff --git a/assets/images/home.png b/assets/images/home.png new file mode 100644 index 0000000..e039a6e Binary files /dev/null and b/assets/images/home.png differ diff --git a/config/config.js b/config/config.js index 231e260..534b3b9 100755 --- a/config/config.js +++ b/config/config.js @@ -3,8 +3,8 @@ var appId = extConfig.appId; var config = { // url: "https://ciformall.youlane.cn/C/api", // url:"https://c.malls.iformall.com/C/api", - // url:'https://ctest.malls.iformall.com/C/api', - url:'http://10.100.33.69:7000/C/api', + url:'https://ctest.malls.iformall.com/C/api', + // url:'http://10.100.33.70:7000/C/api', // url: 'http://202.165.179.86:4000/C/api', api: { /** @@ -219,7 +219,7 @@ var config = { }, weapp: { - AppId: "wxea71200db93d756b" + AppId: "wx649b3be73c1afe47" }, ErrorCode: { diff --git a/pages/bargain/bargain.wxml b/pages/bargain/bargain.wxml index 9c4e65b..60d44ed 100644 --- a/pages/bargain/bargain.wxml +++ b/pages/bargain/bargain.wxml @@ -41,7 +41,7 @@ - + diff --git a/pages/bargain/bargainDatail/bargainDatail.js b/pages/bargain/bargainDatail/bargainDatail.js index 0c85742..342f454 100644 --- a/pages/bargain/bargainDatail/bargainDatail.js +++ b/pages/bargain/bargainDatail/bargainDatail.js @@ -51,6 +51,11 @@ Page({ showButton:false }) }, + goback:function(){ + wx.reLaunch({ + url: '/pages/index/index', + }) + }, /** * 更多砍价商品 */ diff --git a/pages/bargain/bargainDatail/bargainDatail.wxml b/pages/bargain/bargainDatail/bargainDatail.wxml index 08c0a41..9756b4d 100644 --- a/pages/bargain/bargainDatail/bargainDatail.wxml +++ b/pages/bargain/bargainDatail/bargainDatail.wxml @@ -58,11 +58,12 @@ + - + diff --git a/pages/bargain/bargainDatail/bargainDatail.wxss b/pages/bargain/bargainDatail/bargainDatail.wxss index 4123b26..d4dd49b 100644 --- a/pages/bargain/bargainDatail/bargainDatail.wxss +++ b/pages/bargain/bargainDatail/bargainDatail.wxss @@ -224,9 +224,31 @@ text-align: center; } .btns .fl{ + width: 250rpx; color: #fff; background:rgba(255,169,2,1); box-shadow:0px 8px 8px 1px rgba(255,169,2,0.32); + margin-left: 22rpx; +} +.goback{ + position: relative; + float: left; + width:122rpx!important; + height:95rpx; + background:rgba(255,255,255,1); + line-height: 95rpx; + border:1rpx solid rgba(227,227,227,1); + box-shadow:0px 8px 8px 1px rgba(189,189,189,0.32); + border-radius:48rpx; +} +.goback image{ + position: absolute; + width: 60rpx; + left: 0; + right: 0; + top: 0; + bottom: 0; + margin: auto; } .btns .fl text{ display: block; @@ -240,6 +262,7 @@ font-size: 30rpx; color: #fff; line-height: 95rpx; + width: 271rpx; background:linear-gradient(90deg,rgba(236,59,45,1) 0%,rgba(248,98,52,1) 100%); box-shadow:0px 8px 8px 1px rgba(246,93,51,0.32); } @@ -285,7 +308,6 @@ padding: 30rpx 0; } .btns01 button{ - color: #fff; color:rgba(254,254,254,1); width:650rpx; height:85rpx; @@ -317,7 +339,7 @@ text-align: center; border: none; } -.status button::after{ border: none; } +button::after{ border: none; } .status button:nth-of-type(1){ background:linear-gradient(90deg,rgba(236,59,45,1) 0%,rgba(248,98,52,1) 100%); border:1px solid rgba(236,59,45,1); diff --git a/pages/index/gameentry/gentry.js b/pages/index/gameentry/gentry.js index bf984d5..a3185cf 100644 --- a/pages/index/gameentry/gentry.js +++ b/pages/index/gameentry/gentry.js @@ -56,4 +56,11 @@ Page({ onReachBottom: function () { }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } }) \ No newline at end of file diff --git a/pages/index/gameentry/gentry.json b/pages/index/gameentry/gentry.json index 9e26dfe..8835af0 100644 --- a/pages/index/gameentry/gentry.json +++ b/pages/index/gameentry/gentry.json @@ -1 +1,3 @@ -{} \ No newline at end of file +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js index 3cb244e..1887fd7 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -1,163 +1,28 @@ - const Http = require("../../utils/HttpBasics"); const imgurl = require("../../utils/imgurl"); const config = require("../../config/config"); const QR = require("../../utils/memberqrcode.js"); let app = getApp(); Page({ + /** + * 页面的初始数据 + */ data: { - newUrl: imgurl.new.url, - icon001: imgurl.icon001.url, - icon002: imgurl.icon002.url, - icon003: imgurl.icon003.url, - icon004: imgurl.icon004.url, - market: app.globalData.market, - list: [], - loading: true, - swiperCurrent: 0, - title: null, - desc: null, - scrollTop: 0, - showGame: false, - gamedata: {}, - couponId: '',//游戏返回时传回的字段 - played: false,//从游戏页面跳回首页返回true - havePlayEd: app.globalData.havePlayEd, - staticGamedata: {}, - showIf: false, - page: 1 // 刷新进入页面时已经加载了第一页数据,onReachBottom时 page++,从第2页开始加载 - }, - gotodiscountCardList:function(){ - wx.navigateTo({ - url: '/pages/discountCardList/discountCardList' - }) }, - gotoRushBuy:function(){ - wx.navigateTo({ - url: '/pages/rushToBuy/index', - }) - }, - qrcode: function (e) { - var that = this; - that.setData({ - showQrcode: true - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function(options) { + let that = this; wx.showToast({ - title: '生成中...', - icon: 'loading', + title: '加载中', + icon: "loading", duration: 2000 - }); - console.log(e) - var st = setTimeout(function () { - wx.hideToast() - var size = that.setCanvasSize(); - var url = JSON.stringify({ - END: "C", - TYPE: "memberCode", - ID: that.data.memberId, - }); - that.createQrCode(url, "mycanvas2", size.w, size.h); - that.setData({ - maskHidden: true - }); - clearTimeout(st); - }, 1000) - }, - hideQrcode: function () { - let that = this; - that.setData({ - showQrcode: false }) - }, - //适配不同屏幕大小的canvas - setCanvasSize: function () { - var size = {}; - try { - var res = wx.getSystemInfoSync(); - var scale = 750 / 500; - //不同屏幕下canvas的适配比例;设计稿是750宽 - var width = res.windowWidth / scale; - var height = width; - //canvas画布为正方形 - size.w = width; - size.h = height; - } catch (e) { - // Do something when catch error - console.log("获取设备信息失败" + e); - } - return size; - }, - createQrCode: function (url, canvasId, cavW, cavH) { - //调用插件中的draw方法,绘制二维码图片 - QR.api.draw(url, canvasId, cavW, cavH); - }, - swiperChange: function (e) { - this.setData({ - swiperCurrent: e.detail.current - }); - }, - gotogame: function () { - let that = this; - Http.post({ - url: config.api.checkPhoneStatus, - data: {} - }) - .then(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=' + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId, - }) - }) - .catch(err => { - if (err.code == 11005) { - // 用户手机未授权 - /** - * 将值传到用户手机号授权的页面 - * - */ - wx.redirectTo({ - url: "/pages/getphoneInfo/index?path=index&url=" + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId, - }); - } else if (err.code == 11006) { - // 用户手机已加密 - wx.redirectTo({ - url: "/pages/phoneinput/phoneinput?path=index&url=" + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId, - }); - } else { - wx.showToast({ - title: err.message, - icon: 'none', - duration: 2000, - mask: false - }); - } - }) - }, - mySpecial:function(){ - console.log("special"); - wx.navigateTo({ - url: '/pages/specialcourtesy/specialcourtesy', - }) - }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onLoad: function (options) { - wx.setStorageSync('imgurl', imgurl) - if (options.played == "true") { - this.setData({ - played: true - }) - } - var that = this; + console.log(options); + console.log("----------------------------------options---------------------------------------") + wx.setStorageSync('options', JSON.stringify(options)) + wx.setStorageSync('imgurl', imgurl) if (decodeURIComponent(options.scene) == "undefined") { that.setData({ scene: 0 @@ -168,91 +33,16 @@ Page({ }); } app.getLocation(); - if (options.couponChannelId && options.couponId||options.orderId) { - that.userLogin(options.couponChannelId, options.couponId,options.orderId); + if (options.couponChannelId && options.couponId || options.orderId) { + that.userLogin(options.couponChannelId, options.couponId, options.orderId); } else { that.userLogin() } - Http.get({ - url: config.api.getWeapNote, - data: { - appId: config.weapp.AppId, - } - }) - .then(res => { - let weapNote = JSON.parse(res.data.weapNote); - that.setData({ - desc: weapNote.firstpage.desc, - title: weapNote.firstpage.title - }) - }) - .catch(err => { - wx.showModal({ - title: "提示", - content:err.errMsg, - showCancel:false - }); - }); - }, - onShow: function () { - this.setData({ - havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd : false - }) - let num = wx.getStorageSync('couponNum'); - if (num == 'couponNum') { - wx.showTabBarRedDot({ - index: 2 - }) - }; - }, - // 会员码获取 - getmemberId: function (token){ - let that = this; - Http.get({ - url: config.api.getScore, - data: { - token: token - } - }).then(res => { - console.log(res) - that.setData({ - levelName: res.data.levelName - }) - if (res.data.nickName) { - that.setData({ - ismember: true, - memberId: res.data.id - }) - var size = this.setCanvasSize(); - var initUrl = JSON.stringify({ flagid: res.data.id }); - that.createQrCode(initUrl, "mycanvas1", size.w, size.h); - } - }) - .catch(err => { - wx.showModal({ - title: '提示', - content: err.message, - showCancel: false - }) - }) - }, - /** - * - * @param {code,page} - * 子组件向父组件传值 - */ - onGetCode: function (e) { - this.setData({ - code: e.detail.val, - page: e.detail.pageNum, - }); - console.log(e.detail.val) - console.log(e.detail.pageNum) }, /** * 用户登录 */ - userLogin: function (couponChannelId, couponId,orderId) { + userLogin: function(couponChannelId, couponId, orderId) { var that = this; // 登录 wx.login({ @@ -260,7 +50,7 @@ Page({ code }) => { wx.getSystemInfo({ - success: function (res) { + success: function(res) { that.setData({ systemInfo: JSON.stringify(res) }) @@ -285,246 +75,80 @@ Page({ }; } Http.post({ - url: config.api.login, - data: usrdata - }) + url: config.api.login, + data: usrdata + }) .then(res => { + that.setData({ + showPages: true + }) app.globalData.token = res.data.token; - if (res.data.token){ - that.getGameOne(res.data.token) - that.getStaticGame(res.data.token) - that.getmemberId(res.data.token); - } Http.setToken(res.data.token); - that.checkUserCarStatus(); - that.getUserInfo(); - that.getBannerlist(); - if (app.couponChannelListCallback) { - app.couponChannelListCallback(app.globalData.token); + if(orderId){ + wx.redirectTo({ + url: '/pages/bargain/bargainDatail/bargainDatail?orderId='+orderId, + }) + }else{ + wx.switchTab({ + url: '/pages/login/index', + }) } - if (app.couponListCallback) { - app.couponListCallback(app.globalData.token); - } - if (app.businessListCallback) { - app.businessListCallback(app.globalData.token); - } - that.checkuerstatus(couponChannelId, couponId,orderId); - }) .catch(err => { wx.showToast({ title: err.message, - icon:"none" + icon: "none" }) }); } }); }, - checkuerstatus(couponChannelId, couponId,orderId) { - Http.post({ - url: config.api.checkUserStatus, - data: {} - }) - .then(res => { - if (couponChannelId && couponId) { - wx.navigateTo({ - url: `/pages/coupon/detail/index?couponChannelId=${couponChannelId}&couponId=${couponId}`, - }) - }else if(orderId){ - wx.navigateTo({ - url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${orderId}&from='${"discount"}`, - }) - } - }) - .catch(err => { - if (err.code == 11004) { - // 用户昵称未授权 - if (couponChannelId && couponId) { - wx.redirectTo({ - url: `/pages/getuserinfo/index?couponChannelId=${couponChannelId}&couponId=${couponId}` - }); - } else if (orderId) { - wx.redirectTo({ - url: `/pages/getuserinfo/index?orderId=${orderId}&from='${"discount"}` - }); - } else { - wx.redirectTo({ - url: '/pages/getuserinfo/index' - }); - } - } - }); - }, - getStaticGame(token) { - let _this = this; - Http.get({ - url: config.api.getGame, - data: { - triggleAction: 2, - token: token - } - }).then(res => { - if (res.data.id) { - _this.setData({ - showIf:true - }) - } - _this.setData({ - staticGamedata: res.data - }) - }) - .catch(err => { - console.log(err) - }) - }, - getGameOne: function (token) { - let _this = this; - Http.get({ - url: config.api.getGame, - data:{ - triggleAction: 1, - token: token - } - }).then(res => { - if (res.data.id) { - _this.setData({ - showGame: true - }) - } - _this.setData({ - gamedata: res.data - }) - }) - .catch(err => { - console.log(err) - }) - }, /** - * banner + * 生命周期函数--监听页面初次渲染完成 */ - getBannerlist: function () { - let that = this; - Http.get({ - url: config.api.bannerlist, - data: { - pageNum: 1, - pageSize: 7 - } - }).then(res => { - that.setData({ - list: res.data.list - }); - }); + onReady: function() { + }, /** - * 检查用户是否有车 + * 生命周期函数--监听页面显示 */ - checkUserCarStatus: function () { - var that = this; - Http.get({ - url: config.api.userCarCount, - data: {} - }).then(res => { - if (res.data > 0) { - // 用户名下有车 - app.globalData.phone = res.data.phone; - app.globalData.supportCar = true; - // 共同登录 - that.userCarLogin(); - } - }); + onShow: function() { + }, + /** - * car共同登录 + * 生命周期函数--监听页面隐藏 */ - userCarLogin: function () { - var that = this; - if (!app.globalData.carLogin) { - // 共同登录 - Http.post({ - url: config.api.carInit, - data: { - phone: app.globalData.phone - } - }).then(res => { - app.globalData.carLogin = true; - app.globalData.parkVendor = res.data.vendor; - if (res.data.token != "undefined") { - app.globalData.etcpToken = res.data.token; - } - }); - } + onHide: function() { + }, + /** - * 获取用户信息 + * 生命周期函数--监听页面卸载 */ - getUserInfo: function () { - // 获取用户信息 - wx.getSetting({ - success: res => { - if (res.authSetting["scope.userInfo"]) { - // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 - wx.getUserInfo({ - success: res => { - // 可以将 res 发送给后台解码出 unionId - } - }); - } - } - }); - }, - gotoBargain:function(){ - wx.navigateTo({ - url: '/pages/bargain/bargain' - }) + onUnload: function() { + }, + /** - * 刷新 - */ - onPullDownRefresh: function (e) { - let that = this; - that.userLogin(); - that.setData({ - page:1 - }) - if (that.data.code == 0 || that.data.code == undefined) { - that.selectComponent("#lists").getList(0, 1, "refresh"); - wx.stopPullDownRefresh(); - } else { - that.selectComponent("#lists").getList(that.data.code, 1, "refresh"); - wx.stopPullDownRefresh(); - }; + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function() { + }, - //加载更多 - onReachBottom: function () { - let that = this; - that.data.page++; - that.setData({ - page: that.data.page - }); - console.log("加载更多页数"+that.data.page); - console.log("加载更多key"+that.data.code); - //父组件获得子组件的方法 - //如果code == 0 - if (that.data.code == 0 || that.data.code == undefined) { - that.selectComponent("#lists").getList(0, that.data.page); - } else { - that.selectComponent("#lists").getList(that.data.code, that.data.page); - } + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function() { + }, - // 用户点击右上角分享 - onShareAppMessage: function () { - return { - title: this.data.title, - desc: this.data.desc, - success: function (res) { - wx.showToast({ - title: "分享成功", - duration: 1000, - icon: "success" - }); - } - }; + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function() { + } -}); \ No newline at end of file +}) \ No newline at end of file diff --git a/pages/index/index.json b/pages/index/index.json index a1eae9a..0475e69 100644 --- a/pages/index/index.json +++ b/pages/index/index.json @@ -1,11 +1,4 @@ { - "usingComponents": { - "c-banner": "../../components/banner/index", - "discount-card": "../../components/discountCard/index", - "c-rushToBuy": "./rushToBuy/index", - "c-coupons": "./coupons/index", - "g-entry": "../../components/gameentry/gentry" - }, - "navigationBarTitleText": "首页", - "enablePullDownRefresh": true -} + "usingComponents": {}, + "navigationBarBackgroundColor": "#fff" +} \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 2b29058..8b13789 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -1,38 +1 @@ - - - - - - - 限时抢购 - - - - 消费卡 - - - - 砍价专场 - - - - 会员权益 - - - - - - - - - - - - - - {{levelName}} - - diff --git a/pages/index/index.wxss b/pages/index/index.wxss index a82447e..cc09ba5 100644 --- a/pages/index/index.wxss +++ b/pages/index/index.wxss @@ -1,124 +1,6 @@ -.index-position { - background: rgba(0, 0, 0, 0.5); - height: 88rpx; - position: absolute; - top: 0; +Page{ + height: 100%; width: 100%; - font-family: PingFangSC-Semibold; - font-size: 30rpx; - color: #fff; - letter-spacing: 0.75rpx; - z-index: 9; - line-height: 88rpx; - overflow: hidden; -} - -page { - width: 100%; - height: auto !important; - overflow-x: hidden; -} - -.txt { - margin-left: 20rpx; -} - -.game-entry { - width: 690rpx; - height: 140rpx; - margin: 57rpx auto 0; -} - -.gameimg { - display: block; - width: 100%; - height: 140rpx; -} - -.section { - padding: 0 20rpx; - display: flex; - justify-content: space-around; - text-align: center; - margin-top: 40rpx; -} - -.section >view image { - display: block; - margin: 0 auto; -} -.section >view image { - width: 80rpx; - height: 80rpx; - margin-bottom: 14rpx; -} -.section text { - height: 23rpx; - font-size: 24rpx; - color: rgba(51, 51, 51, 1); - display: block; - margin-top: 0rpx; -} - -.showQrcode { - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: 1000; - background: rgba(0, 0, 0, 0.6); -} - -.qrcode image { - width: 70rpx; - margin-right: 20rpx; -} - -.showQrcode { - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: 1000; - background: rgba(0, 0, 0, 0.6); -} - -.canvas-box { - position: fixed; - width: 500rpx; - overflow: hidden; - left: 0; - top: 200rpx; - right: 0; - margin: auto; - background: #fff; - border-radius: 16rpx; - z-index:100; - padding-bottom: 30rpx; -} - -.showQrcode text { - display: block; - text-align: center; - font-size: 28rpx; -} - -.button { - width: 414rpx; - text-align: center; - margin: 0 auto; - height: 80rpx; - line-height: 80rpx; - background: rgba(255, 255, 255, 1); - border-radius: 10rpx; - font-size: 32rpx; - color: rgba(2, 192, 255, 1); - overflow: hidden; - margin-top: 38rpx; -} -.memberIds{ - padding-top: 30rpx; - font-size: 30rpx; + background:#fff; + opacity: 0; } \ No newline at end of file diff --git a/pages/index/coupons/index.js b/pages/login/coupons/index.js similarity index 100% rename from pages/index/coupons/index.js rename to pages/login/coupons/index.js diff --git a/pages/index/coupons/index.json b/pages/login/coupons/index.json similarity index 100% rename from pages/index/coupons/index.json rename to pages/login/coupons/index.json diff --git a/pages/index/coupons/index.wxml b/pages/login/coupons/index.wxml similarity index 100% rename from pages/index/coupons/index.wxml rename to pages/login/coupons/index.wxml diff --git a/pages/index/coupons/index.wxss b/pages/login/coupons/index.wxss similarity index 100% rename from pages/index/coupons/index.wxss rename to pages/login/coupons/index.wxss diff --git a/pages/login/gameentry/gentry.js b/pages/login/gameentry/gentry.js new file mode 100644 index 0000000..bf984d5 --- /dev/null +++ b/pages/login/gameentry/gentry.js @@ -0,0 +1,59 @@ +// pages/index/gameentry/gentry.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, +}) \ No newline at end of file diff --git a/pages/login/gameentry/gentry.json b/pages/login/gameentry/gentry.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/pages/login/gameentry/gentry.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/pages/login/gameentry/gentry.wxml b/pages/login/gameentry/gentry.wxml new file mode 100644 index 0000000..ad0a5e7 --- /dev/null +++ b/pages/login/gameentry/gentry.wxml @@ -0,0 +1,2 @@ + +pages/index/gameentry/gentry.wxml diff --git a/pages/login/gameentry/gentry.wxss b/pages/login/gameentry/gentry.wxss new file mode 100644 index 0000000..c729821 --- /dev/null +++ b/pages/login/gameentry/gentry.wxss @@ -0,0 +1 @@ +/* pages/index/gameentry/gentry.wxss */ \ No newline at end of file diff --git a/pages/login/index.js b/pages/login/index.js index 42789dc..9aaf4e4 100644 --- a/pages/login/index.js +++ b/pages/login/index.js @@ -1,30 +1,476 @@ -var config = require("../../config/config.js"); const Http = require("../../utils/HttpBasics"); +const imgurl = require("../../utils/imgurl"); +const config = require("../../config/config"); +const QR = require("../../utils/memberqrcode.js"); +let app = getApp(); Page({ - data: {}, - getPhoneNumber: function(e) { - wx.navigateBack({ - delta: 1 + data: { + newUrl: imgurl.new.url, + icon001: imgurl.icon001.url, + icon002: imgurl.icon002.url, + icon003: imgurl.icon003.url, + icon004: imgurl.icon004.url, + market: app.globalData.market, + list: [], + loading: true, + swiperCurrent: 0, + title: null, + desc: null, + scrollTop: 0, + showGame: false, + gamedata: {}, + couponId: '', //游戏返回时传回的字段 + played: false, //从游戏页面跳回首页返回true + havePlayEd: app.globalData.havePlayEd, + staticGamedata: {}, + showIf: false, + showPages: false, + page: 1 // 刷新进入页面时已经加载了第一页数据,onReachBottom时 page++,从第2页开始加载 + }, + gotodiscountCardList: function() { + wx.navigateTo({ + url: '/pages/discountCardList/discountCardList' + }) + }, + gotoRushBuy: function() { + wx.navigateTo({ + url: '/pages/rushToBuy/index', + }) + }, + qrcode: function(e) { + var that = this; + that.setData({ + showQrcode: true + }) + wx.showToast({ + title: '生成中...', + icon: 'loading', + duration: 2000 + }); + console.log(e) + var st = setTimeout(function() { + wx.hideToast() + var size = that.setCanvasSize(); + var url = JSON.stringify({ + END: "C", + TYPE: "memberCode", + ID: that.data.memberId, + }); + that.createQrCode(url, "mycanvas2", size.w, size.h); + that.setData({ + maskHidden: true + }); + clearTimeout(st); + }, 1000) + }, + hideQrcode: function() { + let that = this; + that.setData({ + showQrcode: false + }) + }, + //适配不同屏幕大小的canvas + setCanvasSize: function() { + var size = {}; + try { + var res = wx.getSystemInfoSync(); + var scale = 750 / 500; + //不同屏幕下canvas的适配比例;设计稿是750宽 + var width = res.windowWidth / scale; + var height = width; + //canvas画布为正方形 + size.w = width; + size.h = height; + } catch (e) { + // Do something when catch error + console.log("获取设备信息失败" + e); + } + return size; + }, + createQrCode: function(url, canvasId, cavW, cavH) { + //调用插件中的draw方法,绘制二维码图片 + QR.api.draw(url, canvasId, cavW, cavH); + }, + swiperChange: function(e) { + this.setData({ + swiperCurrent: e.detail.current }); }, - onLoad() { + gotogame: function() { + let that = this; + Http.post({ + url: config.api.checkPhoneStatus, + data: {} + }) + .then(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=' + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId, + }) + }) + .catch(err => { + if (err.code == 11005) { + // 用户手机未授权 + /** + * 将值传到用户手机号授权的页面 + * + */ + wx.redirectTo({ + url: "/pages/getphoneInfo/index?path=index&url=" + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId, + }); + } else if (err.code == 11006) { + // 用户手机已加密 + wx.redirectTo({ + url: "/pages/phoneinput/phoneinput?path=index&url=" + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId, + }); + } else { + wx.showToast({ + title: err.message, + icon: 'none', + duration: 2000, + mask: false + }); + } + }) + }, + mySpecial: function() { + console.log("special"); + wx.navigateTo({ + url: '/pages/specialcourtesy/specialcourtesy', + }) + }, + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onLoad: function(options) { + let that = this; + let optionss = JSON.parse(wx.getStorageSync('options')); + console.log(optionss); + console.log("-------------------------------------------optionssss------------------------------------") + if (options.played == "true") { + that.setData({ + played: true + }) + } + if (optionss.couponChannelId && optionss.couponId || optionss.orderId) { + that.userLogin(optionss.couponChannelId, optionss.couponId, optionss.orderId); + } else { + that.userLogin() + } + }, + onShow: function() { + this.setData({ + havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd : false + }) + let num = wx.getStorageSync('couponNum'); + if (num == 'couponNum') { + wx.showTabBarRedDot({ + index: 2 + }) + }; + }, + // 会员码获取 + getmemberId: function(token) { let that = this; Http.get({ - url: config.api.marketicon, - data: { - appId: config.weapp.AppId - } - }).then(res=>{ + url: config.api.getScore, + data: { + token: token + } + }).then(res => { + console.log(res) that.setData({ - mallImgUrl: res.data.mallImgUrl + levelName: res.data.levelName + }) + if (res.data.nickName) { + that.setData({ + ismember: true, + memberId: res.data.id + }) + var size = this.setCanvasSize(); + var initUrl = JSON.stringify({ + flagid: res.data.id + }); + that.createQrCode(initUrl, "mycanvas1", size.w, size.h); + } + }) + .catch(err => { + wx.showModal({ + title: '提示', + content: err.message, + showCancel: false + }) + }) + }, + /** + * + * @param {code,page} + * 子组件向父组件传值 + */ + onGetCode: function(e) { + this.setData({ + code: e.detail.val, + page: e.detail.pageNum, + }); + console.log(e.detail.val) + console.log(e.detail.pageNum) + }, + /** + * 用户登录 + */ + userLogin: function(couponChannelId, couponId, orderId) { + var that = this; + // 登录 + that.getGameOne(app.globalData.token) + that.getStaticGame(app.globalData.token) + that.getmemberId(app.globalData.token); + that.checkUserCarStatus(); + that.getUserInfo(); + that.getBannerlist(); + if (app.couponChannelListCallback) { + app.couponChannelListCallback(app.globalData.token); + } + if (app.couponListCallback) { + app.couponListCallback(app.globalData.token); + } + if (app.businessListCallback) { + app.businessListCallback(app.globalData.token); + } + that.checkuerstatus(couponChannelId, couponId, orderId); + Http.get({ + url: config.api.getWeapNote, + data: { + appId: config.weapp.AppId, + } + }) + .then(res => { + let weapNote = JSON.parse(res.data.weapNote); + that.setData({ + desc: weapNote.firstpage.desc, + title: weapNote.firstpage.title + }) + }) + .catch(err => { + wx.showModal({ + title: "提示", + content: err.errMsg, + showCancel: false }); - }).catch(err => { - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false }); + }, + checkuerstatus(couponChannelId, couponId, orderId) { + Http.post({ + url: config.api.checkUserStatus, + data: {} + }) + .then(res => { + if (couponChannelId && couponId) { + wx.navigateTo({ + url: `/pages/coupon/detail/index?couponChannelId=${couponChannelId}&couponId=${couponId}`, + }) + } else if (orderId) { + wx.navigateTo({ + url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${orderId}&from='${"discount"}`, + }) + } + }) + .catch(err => { + if (err.code == 11004) { + // 用户昵称未授权 + if (couponChannelId && couponId) { + wx.redirectTo({ + url: `/pages/getuserinfo/index?couponChannelId=${couponChannelId}&couponId=${couponId}` + }); + } else if (orderId) { + wx.redirectTo({ + url: `/pages/getuserinfo/index?orderId=${orderId}&from='${"discount"}` + }); + } else { + wx.redirectTo({ + url: '/pages/getuserinfo/index' + }); + } + } + }); + }, + getStaticGame(token) { + let _this = this; + Http.get({ + url: config.api.getGame, + data: { + triggleAction: 2, + token: token + } + }).then(res => { + if (res.data.id) { + _this.setData({ + showIf: true + }) + } + _this.setData({ + staticGamedata: res.data + }) + }) + .catch(err => { + console.log(err) + }) + }, + getGameOne: function(token) { + let _this = this; + Http.get({ + url: config.api.getGame, + data: { + triggleAction: 1, + token: token + } + }).then(res => { + if (res.data.id) { + _this.setData({ + showGame: true + }) + } + _this.setData({ + gamedata: res.data + }) + }) + .catch(err => { + console.log(err) + }) + }, + /** + * banner + */ + getBannerlist: function() { + let that = this; + Http.get({ + url: config.api.bannerlist, + data: { + pageNum: 1, + pageSize: 7 + } + }).then(res => { + that.setData({ + list: res.data.list + }); + }); + }, + + /** + * 检查用户是否有车 + */ + checkUserCarStatus: function() { + var that = this; + Http.get({ + url: config.api.userCarCount, + data: {} + }).then(res => { + if (res.data > 0) { + // 用户名下有车 + app.globalData.phone = res.data.phone; + app.globalData.supportCar = true; + // 共同登录 + that.userCarLogin(); + } + }); + }, + /** + * car共同登录 + */ + userCarLogin: function() { + var that = this; + if (!app.globalData.carLogin) { + // 共同登录 + Http.post({ + url: config.api.carInit, + data: { + phone: app.globalData.phone + } + }).then(res => { + app.globalData.carLogin = true; + app.globalData.parkVendor = res.data.vendor; + if (res.data.token != "undefined") { + app.globalData.etcpToken = res.data.token; + } + }); + } + }, + /** + * 获取用户信息 + */ + getUserInfo: function() { + // 获取用户信息 + wx.getSetting({ + success: res => { + if (res.authSetting["scope.userInfo"]) { + // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 + wx.getUserInfo({ + success: res => { + // 可以将 res 发送给后台解码出 unionId + } + }); + } + } + }); + }, + gotoBargain: function() { + wx.navigateTo({ + url: '/pages/bargain/bargain' }) + }, + /** + * 刷新 + */ + onPullDownRefresh: function(e) { + let that = this; + that.userLogin(); + that.setData({ + page: 1 + }) + if (that.data.code == 0 || that.data.code == undefined) { + that.selectComponent("#lists").getList(0, 1, "refresh"); + wx.stopPullDownRefresh(); + } else { + that.selectComponent("#lists").getList(that.data.code, 1, "refresh"); + wx.stopPullDownRefresh(); + }; + }, + //加载更多 + onReachBottom: function() { + let that = this; + that.data.page++; + that.setData({ + page: that.data.page + }); + console.log("加载更多页数" + that.data.page); + console.log("加载更多key" + that.data.code); + //父组件获得子组件的方法 + //如果code == 0 + if (that.data.code == 0 || that.data.code == undefined) { + that.selectComponent("#lists").getList(0, that.data.page); + } else { + that.selectComponent("#lists").getList(that.data.code, that.data.page); + } + }, + // 用户点击右上角分享 + onShareAppMessage: function() { + return { + title: this.data.title, + desc: this.data.desc, + success: function(res) { + wx.showToast({ + title: "分享成功", + duration: 1000, + icon: "success" + }); + } + }; } -}); +}); \ No newline at end of file diff --git a/pages/login/index.json b/pages/login/index.json index ddeacd2..a1eae9a 100644 --- a/pages/login/index.json +++ b/pages/login/index.json @@ -1,6 +1,11 @@ { - "usingComponents": { - "i-button": "../../dist/button/index" - }, - "navigationBarTitleText": "登录" - } \ No newline at end of file + "usingComponents": { + "c-banner": "../../components/banner/index", + "discount-card": "../../components/discountCard/index", + "c-rushToBuy": "./rushToBuy/index", + "c-coupons": "./coupons/index", + "g-entry": "../../components/gameentry/gentry" + }, + "navigationBarTitleText": "首页", + "enablePullDownRefresh": true +} diff --git a/pages/login/index.wxml b/pages/login/index.wxml index 63bb575..eada370 100644 --- a/pages/login/index.wxml +++ b/pages/login/index.wxml @@ -1,9 +1,38 @@ - -