123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- //logs.js
- const util = require('../../utils/util.js')
- var app = getApp();
- Page({
- data: {
- logs: [],
- bannerList: [],
- indicatorDots: true,
- autoplay: true,
- interval: 2000,
- duration: 1000,
- cardList: [],
- hasNext: true,
- page: 0,
- hiddenThis: true,
- appid: 0
- },
- onLoad: function () {
- this.initBanner();
- this.initCardList();
- app.login(this);
- },
- onShow () {
- wx.stopPullDownRefresh()
- },
- onHide () {
- wx.stopPullDownRefresh()
- this.setData({hiddenThis: true})
- },
- initConcact (event) {
- var that = this;
- var tel = wx.getStorageSync('tel') || '0', user_id = wx.getStorageSync('user').user_id || '0', id = event.currentTarget.dataset.id;
- if (user_id != '0' || tel != '0') {
- // 绑定了手机号
- this.setData({hiddenThis: false, appid: id})
- }else{
- // 未绑定手机号
- wx.navigateTo({
- url: "/pages/getPhone/getPhone?from=card&preid=" + id
- })
- }
- },
- initCardList: function () {
- var data = {}, list = [], that = this, hasNext = true;
- that.setData({hidden: false});
- if (that.data.page === 0) {
- list = []
- }else{
- list = that.data.cardList;
- }
- wx.request({
- url: app.globalData.HOST + '/user/CreditCard/list',
- method: "POST",
- data: Object.assign({}, app.globalData.common, {pageId: ++this.data.page}),
- success: function (res) {
- if (res.data.errno == '0') {
- // data = res.data.rst.list;
- list = list.concat(res.data.rst.list)
- hasNext = res.data.rst.pageInfo.hasNext
- }
- that.setData({ cardList: list, hasNext: hasNext});
- },
- complete: function () {
- that.setData({ hidden:true});//加载成功
- wx.stopPullDownRefresh() //停止下拉刷新
- }
- });
- },
- initBanner () {
- var data = [], that = this;
- wx.request({
- url: app.globalData.HOST + '/user/CreditCard/bannerlist',
- method: "POST",
- data: app.globalData.common,
- success: function (res) {
- if (res.data.errno == '0') {
- data = res.data.rst.data;
- }
- that.setData({ bannerList: data});
- },
- complete: function () {
- // that.setData({ hidden:true});//加载成功
- wx.stopPullDownRefresh() //停止下拉刷新
- }
- });
- },
- onPullDownRefresh: function () {
- //下拉
- this.data.page = 0;
- this.initCardList()
- },
- onReachBottom: function () {
- //上拉
- if (this.data.hasNext) {
- this.initCardList()
- }
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.title,
- imageUrl: app.globalData.img,
- path: '/pages/index/index',
- success: function(res) {
- app.noticeModal('分享成功')
- },
- fail: function(res) {
- app.noticeModal('您取消了分享')
- }
- }
- }
- })
|