From 8eac1998337d9c7d80c7eade4d3051b39142f129 Mon Sep 17 00:00:00 2001 From: meo <18801474720@163.com> Date: Tue, 6 Nov 2018 17:08:31 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=88=B8=E8=AF=A6=E6=83=85=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=E4=BA=AE=E5=BA=A6=E5=8E=BB=E6=8E=89][=E4=BF=AE?= =?UTF-8?q?=E6=94=B9]:=E5=88=B8=E8=AF=A6=E6=83=85=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=E4=BA=AE=E5=BA=A6=E5=8E=BB=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/couponorder/detail/index.js | 90 +++++---- pages/couponorder/index/index.js | 17 +- pages/index/coupons/index.js | 49 +++-- pages/index/index.js | 242 ++++++++++++----------- pages/order/detail/index.js | 17 +- pages/order/index/index.js | 2 +- pages/orderquanma/index.js | 66 ++++--- pages/passCar/couponList/couponList.wxss | 4 +- 8 files changed, 255 insertions(+), 232 deletions(-) diff --git a/pages/couponorder/detail/index.js b/pages/couponorder/detail/index.js index 7cfbcb4..523105b 100644 --- a/pages/couponorder/detail/index.js +++ b/pages/couponorder/detail/index.js @@ -1,13 +1,13 @@ const util = require("../../../utils/util"); const config = require("../../../config/config.js"); const Http = require("../../../utils/HttpBasics"); - +let app = getApp(); //券详情页面 Page({ data: { code: "", data: { - salePrice:null, + salePrice: null, price: null, usePrice: null }, @@ -17,14 +17,12 @@ Page({ //存储计时器 setInter: "", staticGamedata: {}, - showIf:false, + showIf: false, }, - onUnload: function() { + onUnload:function(){ + console.log("onUnload"); let that = this; clearInterval(that.data.setInter); - wx.setScreenBrightness({ - value: that.data.sight, - }) }, gotogame: function () { let that = this; @@ -50,31 +48,30 @@ Page({ staticGamedata: res.data }) }) - .catch(err => { - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false - }); - }) + .catch(err => { + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); + }) }, - onLoad: function(options) { + // onShow(options) { + // setTimeout(function () { + // wx.setScreenBrightness({ + // value: 0.7, + // }) + // }, 200) + // }, + onLoad: function (options) { let that = this; - setTimeout(function() { - wx.setScreenBrightness({ - value: 0.7, - }) - }, 200), - that.setData({ - sight: options.sight, - code: options.quancode, - couponorderstatus: options.couponorderstatus - }); - - + that.setData({ + code: options.quancode, + couponorderstatus: options.couponorderstatus + }); //获得优惠券的详情 - that.data.setInter = setInterval(function() { + that.data.setInter = setInterval(function () { if ( options.quancode && that.data.couponorderstatus == 0 @@ -85,6 +82,7 @@ Page({ couponOrderId: options.quancode } }).then(res => { + console.log(res); that.setData({ couponorderstatus: res.data.couponOrderStatus, data: res.data @@ -108,14 +106,14 @@ Page({ createDate: util.formatTime(that.data.data.createDate, "yyyy-MM-dd hh:mm:ss") }); }) - .catch(err => { - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false - }); - }) + .catch(err => { + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); + }) } }, 2000); @@ -140,16 +138,16 @@ Page({ util.barcode("barcode", options.quancode, 510, 100); util.qrcode("qrcode", options.quancode, 350, 350); }) - .catch(err => { - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false - }); - }) + .catch(err => { + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); + }) }, - phone: function() { + phone: function () { let that = this; if (that.data.data.merchantLinkPhone) { wx.makePhoneCall({ diff --git a/pages/couponorder/index/index.js b/pages/couponorder/index/index.js index a6e3782..7fd5207 100644 --- a/pages/couponorder/index/index.js +++ b/pages/couponorder/index/index.js @@ -1,6 +1,7 @@ const util = require("../../../utils/util.js"); const config = require("../../../config/config.js"); const Http = require("../../../utils/HttpBasics"); +let app = getApp(); Page({ data: { tabs: [{ @@ -40,14 +41,12 @@ Page({ }) wx.hideTabBarRedDot({ index:2 - }), - wx.getScreenBrightness({ - success:function(res){ - that.setData({ - sight:res.value - }) - } - }); + }) + // wx.getScreenBrightness({ + // success:function(res){ + // app.globalData.sight = res.value; + // } + // }); }, //点击跳转到券详情页面 gotouse: function (e) { @@ -58,7 +57,7 @@ Page({ } wx.navigateTo({ url: `/pages/couponorder/detail/index?quancode=${ - e.currentTarget.dataset.quancode}&couponorderstatus=${mystatus}&sight=${this.data.sight}` + e.currentTarget.dataset.quancode}&couponorderstatus=${mystatus}` }); }, getList(key, pageNum) { diff --git a/pages/index/coupons/index.js b/pages/index/coupons/index.js index 8135376..52473ba 100644 --- a/pages/index/coupons/index.js +++ b/pages/index/coupons/index.js @@ -8,7 +8,7 @@ Component({ * 组件的属性列表 */ properties: { - loading: { + loading: { type: Boolean, value: '' }, @@ -33,7 +33,7 @@ Component({ pageNum: 1, // 设置加载的第几次,默认是第一次 pageSize: 10, //返回数据的个数 searchLoadingComplete: false, //“没有数据”的变量,默认false,隐藏 - allow_load: true // 是否允许继续加载标识 默认 true 允许,false 加载完成 + allow_load: true, // 是否允许继续加载标识 默认 true 允许,false 加载完成 }, /** * 组件的方法列表 @@ -51,7 +51,6 @@ Component({ detail }) { let that = this; - // 切换tab时重新初始化下list 和 allow_load that.setData({ current_scroll: detail.key, @@ -70,11 +69,23 @@ Component({ this.triggerEvent("myevent", myEventDetail); }, - getList(key, pageNum) { + getList(key, pageNum, from) { var that = this; + console.log("pageNum------>"+pageNum); + /** + * from==refresh + * 表示是从下拉刷新进来的 + */ app.couponListCallback = token => { Http.setToken(token); // 券list获取 + if (from == 'refresh') { + that.setData({ + allow_load: true, + list: [], + }) + console.log(that.data.list); + } if (that.data.allow_load) { that.setData({ loading: true, @@ -103,28 +114,28 @@ Component({ /** * 加载完成 */ - if (pageNum >= res.data.pages) { - if(res.data.pages == 0||res.data.pages == 1){ + if (res.data.pages == 0 || res.data.pages == 1) { that.setData({ allow_load: true, loading: false, content: "" }); - }else{ + } + else { that.setData({ allow_load: false, loading: true, - content: "——— 再拉裤子就掉了啦 ———" + content: "——— 再拉裤子就掉了啦 ———", }); - } + } } if (pageNum == 1) { that.setData({ list: [], }) } - + var tmpArr = that.data.list; tmpArr.push.apply(tmpArr, res.data.list); that.setData({ @@ -144,7 +155,7 @@ Component({ loading: false, }) }, 1400); - } + } else { that.setData({ loading: true, @@ -180,14 +191,14 @@ Component({ tabs: res.data.list }); }) - .catch(err => { - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false - }); - }) + .catch(err => { + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); + }) }; if (app.globalData.token && app.globalData.token != null) { app.businessListCallback(app.globalData.token); diff --git a/pages/index/index.js b/pages/index/index.js index 9acb5a0..a3bca82 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -6,94 +6,94 @@ Page({ data: { market: app.globalData.market, list: [], - loading:true, + loading: true, swiperCurrent: 0, - title:'', - desc:'', + title: null, + desc: null, scrollTop: 0, - showGame:false, - gamedata:{}, - couponId:'',//游戏返回时传回的字段 - played:false,//从游戏页面跳回首页返回true + showGame: false, + gamedata: {}, + couponId: '',//游戏返回时传回的字段 + played: false,//从游戏页面跳回首页返回true havePlayEd: app.globalData.havePlayEd, - staticGamedata:{}, - showIf:false, + staticGamedata: {}, + showIf: false, page: 1 // 刷新进入页面时已经加载了第一页数据,onReachBottom时 page++,从第2页开始加载 }, - swiperChange: function(e) { + swiperChange: function (e) { this.setData({ swiperCurrent: e.detail.current }); }, - gotogame:function(){ - let that = this; - Http.post({ - url: config.api.checkPhoneStatus, - data: {} - }) - .then(res => { + 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 = { - 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.errMsg, - icon: 'none', - duration: 2000, - mask: false - }); - } + } + 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.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); + } + }) }, /** * 生命周期函数--监听页面初次渲染完成 */ - onLoad: function(options) { - if(options.played=="true"){ + onLoad: function (options) { + if (options.played == "true") { this.setData({ - played:true + played: true }) } var that = this; - if (decodeURIComponent(options.scene)=="undefined"){ + if (decodeURIComponent(options.scene) == "undefined") { that.setData({ scene: 0 }); - }else{ + } else { that.setData({ scene: decodeURIComponent(options.scene) }); } app.getLocation(); - if (options.couponChannelId && options.couponId){ + if (options.couponChannelId && options.couponId) { that.userLogin(options.couponChannelId, options.couponId); - }else{ + } else { that.userLogin() } Http.get({ @@ -102,67 +102,57 @@ Page({ 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 => { - console.log(err); - if (err.errMsg == '请求超时,请检查您的网络设置!') { + .then(res => { + let weapNote = JSON.parse(res.data.weapNote); that.setData({ - loading: false, - loadingtext: "请求超时,请检查您的网络设置!" + desc: weapNote.firstpage.desc, + title: weapNote.firstpage.title }) - } - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false + }) + .catch(err => { + console.log(err); + if (err.errMsg == '请求超时,请检查您的网络设置!') { + that.setData({ + loading: false, + loadingtext: "请求超时,请检查您的网络设置!" + }) + } + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); }); - }); }, - onShow:function(){ + onShow: function () { this.setData({ - havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd:false + havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd : false }) let num = wx.getStorageSync('couponNum'); - if (num =='couponNum'){ + if (num == 'couponNum') { wx.showTabBarRedDot({ index: 2 }) }; }, /** - * 下拉刷新 + * + * @param {code,page} + * 子组件向父组件传值 */ - onPullDownRefresh: function(e) { - let that = this; - that.userLogin(); - if (that.data.code == 0 || that.data.code == undefined) { - that.selectComponent("#lists").getList(0, 1); - wx.stopPullDownRefresh(); - } else { - that.selectComponent("#lists").getList(that.data.code, 1); - wx.stopPullDownRefresh(); - }; - }, - - onGetCode: function(e) { - //子组件传递给父组件的值 + onGetCode: function (e) { this.setData({ code: e.detail.val, - page: e.detail.pageNum + page: e.detail.pageNum, }); + console.log(e.detail.val) + console.log(e.detail.pageNum) }, - /** * 用户登录 */ - userLogin: function (couponChannelId,couponId) { + userLogin: function (couponChannelId, couponId) { var that = this; // 登录 wx.login({ @@ -195,13 +185,12 @@ Page({ }; } Http.post({ - url: config.api.login, - data: usrdata - }) + url: config.api.login, + data: usrdata + }) .then(res => { app.globalData.token = res.data.token; if (res.data.token){ - that.getGameOne(res.data.token) that.getStaticGame(res.data.token) } @@ -226,7 +215,7 @@ Page({ } }); }, - checkuerstatus(couponChannelId, couponId){ + checkuerstatus(couponChannelId, couponId) { Http.post({ url: config.api.checkUserStatus, data: {} @@ -249,16 +238,16 @@ Page({ wx.redirectTo({ url: '/pages/getuserinfo/index' }); - } + } } }); }, - getStaticGame(token){ + getStaticGame(token) { let _this = this; Http.get({ url: config.api.getGame, data: { - triggleAction:2, + triggleAction: 2, token: token } }).then(res => { @@ -275,8 +264,8 @@ Page({ console.log(err) }) }, - getGameOne:function(token){ - let _this=this; + getGameOne: function (token) { + let _this = this; Http.get({ url: config.api.getGame, data:{ @@ -284,13 +273,13 @@ Page({ token: token } }).then(res => { - if (res.data.id){ + if (res.data.id) { _this.setData({ showGame: true }) } _this.setData({ - gamedata:res.data + gamedata: res.data }) }) .catch(err => { @@ -300,7 +289,7 @@ Page({ /** * banner */ - getBannerlist: function() { + getBannerlist: function () { let that = this; Http.get({ url: config.api.bannerlist, @@ -318,7 +307,7 @@ Page({ /** * 检查用户是否有车 */ - checkUserCarStatus: function() { + checkUserCarStatus: function () { var that = this; Http.get({ url: config.api.userCarCount, @@ -336,7 +325,7 @@ Page({ /** * car共同登录 */ - userCarLogin: function() { + userCarLogin: function () { var that = this; if (!app.globalData.carLogin) { // 共同登录 @@ -357,7 +346,7 @@ Page({ /** * 获取用户信息 */ - getUserInfo: function() { + getUserInfo: function () { // 获取用户信息 wx.getSetting({ success: res => { @@ -372,13 +361,32 @@ Page({ } }); }, - //下拉加载更多 - onReachBottom: 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(); + }; + }, + //加载更多 + 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) { @@ -388,11 +396,11 @@ Page({ } }, // 用户点击右上角分享 - onShareAppMessage: function() { + onShareAppMessage: function () { return { title: this.data.title, desc: this.data.desc, - success: function(res) { + success: function (res) { wx.showToast({ title: "分享成功", duration: 1000, diff --git a/pages/order/detail/index.js b/pages/order/detail/index.js index 20b34d9..2bb93f6 100644 --- a/pages/order/detail/index.js +++ b/pages/order/detail/index.js @@ -34,7 +34,7 @@ Page({ e.currentTarget.dataset.subtitle }&remark=${e.currentTarget.dataset.remark}&couponorderstatus=${ e.currentTarget.dataset.couponorderstatus - }&sight=${that.data.sight}` + }` }); } else { wx.navigateTo({ @@ -44,7 +44,7 @@ Page({ e.currentTarget.dataset.subtitle }&remark=${e.currentTarget.dataset.remark}&couponorderstatus=${ that.data.mystatus - }&sight=${that.data.sight}` + }` }); } }, @@ -212,13 +212,12 @@ Page({ */ onShow: function () { let that = this; - wx.getScreenBrightness({ - success: function (res) { - that.setData({ - sight: res.value - }) - } - }); + // wx.getScreenBrightness({ + // success: function (res) { + // app.globalData.sight=res.value; + // console.log(app.globalData.sight); + // } + // }); }, /** diff --git a/pages/order/index/index.js b/pages/order/index/index.js index 1e7c667..5970b14 100644 --- a/pages/order/index/index.js +++ b/pages/order/index/index.js @@ -160,5 +160,5 @@ Page({ page: that.data.page }); that.getList(that.data.current_scroll, that.data.page); - } + }, }); \ No newline at end of file diff --git a/pages/orderquanma/index.js b/pages/orderquanma/index.js index a53bd69..efb1c0a 100644 --- a/pages/orderquanma/index.js +++ b/pages/orderquanma/index.js @@ -1,23 +1,18 @@ let util = require("../../utils/util"); let Http = require("../../utils/HttpBasics"); let config = require("../../config/config.js"); +let app = getApp(); Page({ data: { code: "", //存储计时器 setInter: "" }, - onLoad: function(options) { + onLoad: function (options) { let that = this; - setTimeout(function () { - wx.setScreenBrightness({ - value: 0.7, - }) - }, 200), util.barcode("barcode", options.quancode, 500, 100); util.qrcode("qrcode", options.quancode, 350, 350); that.setData({ - sight: options.sight, code: options.quancode, title: options.title, subtitle: options.subtitle, @@ -27,7 +22,7 @@ Page({ /** * 如果没有核销 */ - that.data.setInter = setInterval(function() { + that.data.setInter = setInterval(function () { if (that.data.couponorderstatus == 0) { Http.get({ url: config.api.getStatus, @@ -35,6 +30,7 @@ Page({ couponOrderId: options.quancode } }).then(res => { + console.log(res); that.setData({ couponorderstatus: res.data.CouponOrderStatus }); @@ -48,17 +44,16 @@ Page({ prevPage.setData({ mystatus: res.data.CouponOrderStatus }); - } }) - .catch(err => { - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false - }); - }) + .catch(err => { + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); + }) } }, 2000); @@ -77,14 +72,14 @@ Page({ couponorderstatus: res.data.CouponOrderStatus }); }) - .catch(err => { - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false - }); - }) + .catch(err => { + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); + }) } /** * couponorderstatus @@ -92,11 +87,22 @@ Page({ * 1 已经核销成功 */ }, - onUnload: function() { + // onShow(options) { + // console.log("屏幕的亮度") + // setTimeout(function () { + // wx.setScreenBrightness({ + // value: 1, + // }) + // }, 200) + // }, + onUnload: function () { let that = this; clearInterval(that.data.setInter); - wx.setScreenBrightness({ - value: that.data.sight, - }) - } + }, + // onHide:function(){ + // console.log(app.globalData.sight) + // wx.setScreenBrightness({ + // value: app.globalData.sight, + // }) + // } }); diff --git a/pages/passCar/couponList/couponList.wxss b/pages/passCar/couponList/couponList.wxss index 6a2206f..1535780 100644 --- a/pages/passCar/couponList/couponList.wxss +++ b/pages/passCar/couponList/couponList.wxss @@ -165,9 +165,11 @@ .nocoupon button { background: #00c0ff; color: #fff; - font-style: 30rpx; + font-size: 36rpx; width: 100%; border-radius: 60rpx; + height: 88rpx; + line-height: 88rpx; } .loading {