|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- // pages/myReplace/myReplace.js
- const app = getApp();
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- dataList:[],//需要展示的数据
- newData:[],
- pageNum:1,//页码,
- count:10,//每页条数
- total:0,//总条数
- total_page:0,//总页数
- mydeg: 0,
- myTicketArrows: true,
- historydeg: -90,
- historyTicketArrows: false,
-
-
- dataList2:[],//需要展示的数据
- newData2:[],
- pageNum2:1,//页码,
- count2:10,//每页条数
- total2:0,//总条数
- total_page2:0,//总页数
-
- myText:"",//"我的代金券"文案
- myHistory:"",
- index:1,//代金券还是菜品券
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var index = options.index;
- this.data.index = index
- if(index==1){
- this.setData({
- myText:"我的代金券",
- myHistory:"代金券使用记录"
- })
- }else{
- this.setData({
- myText:"我的菜品券",
- myHistory:"菜品券使用记录"
- })
- }
- wx.setNavigationBarTitle({
- title: this.data.myText,
- })
- if (app.globalData.openId){
- this.getDataList();
- this.historyList();
- }else{
- app.globalData.openidSuccessFuc = this.getDataList;
- app.globalData.openidSuccessFuc = this.historyList;
- }
- },
- getDataList:function(index){
- let params = {
- item_type:this.data.index,
- cur_page:this.data.pageNum,
- show_num:this.data.count,
- }
- app.wxRequest(app.globalData.httpUrl + 'front/buy/pendinglist', params, e => {
- console.log(e)
- if (e.code == 200) {
- for(var i=0;i<e.data.length;i++){
- this.data.newData.push(e.data[i]);
- }
- this.setData({
- dataList:this.data.newData
- })
- this.data.total_page = e.total_page;
- }
- }, this)
- },
- getBot:function(){//scroll触底事件
- if(this.data.pageNum<this.data.total_page){
- this.data.pageNum++;
- this.getDataList();
- }else{
- wx.showToast({
- title: '没有更多数据了',
- icon:"none"
- })
- }
- },
- lookMyTicket:function(){
- this.setData({
- myTicketArrows: !this.data.myTicketArrows,
- })
- if (this.data.myTicketArrows){
- this.setData({
- mydeg: 0,
- })
- }else{
- this.setData({
- mydeg: -90,
- })
- }
- },
- lookHistory:function(){
- this.setData({
- historyTicketArrows: !this.data.historyTicketArrows,
- })
- if (this.data.historyTicketArrows) {
- this.setData({
- historydeg: 0,
- })
- } else {
- this.setData({
- historydeg: -90,
- })
- }
- },
- lower:function(){//检测上拉是否到底
- console.log("到底了")
- if(this.data.pageNum2<this.data.total_page2){
- this.data.pageNum2++;
- this.historyList();
- }else{
- wx.showToast({
- title: '没有更多数据了',
- icon:"none"
- })
- }
- },
- historyList:function(){
- let params = {
- item_type:this.data.index,
- cur_page:this.data.pageNum2,
- show_num:this.data.count2,
- }
- app.wxRequest(app.globalData.httpUrl + 'front/buy/usehistory', params, e => {
- console.log(e)
- if (e.code == 200) {
- for(var i=0;i<e.data.length;i++){
- this.data.newData2.push(e.data[i]);
- }
- this.setData({
- dataList2:this.data.newData2
- })
- this.data.total_page = e.total_page2;
- }
- }, this)
- },
- giveTicket:function(e){//赠送优惠券
- var id = e.target.dataset.id;
- wx.navigateTo({
- url: '../givePage/givePage?id=' + id+"&type="+this.data.index+"&type="+this.data.index,
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- }
- })
|