12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //logs.js
- const util = require('../../utils/util.js')
- var app = getApp();
- Page({
- data: {
- logs: [],
- bannerList: [],
- indicatorDots: true,
- autoplay: false,
- interval: 2000,
- duration: 1000,
- cardList: [],
- hasNext: true,
- page: 0,
- hasPhone: false
- },
- onLoad: function () {
- this.initBanner();
- this.initCardList();
- app.login();
- this.initConcact(null, true);
- },
- initConcact (event, flag) {
- var that = this, event = event || null, flag = flag || false;
- var tel = wx.getStorageSync('tel') || '0', user_id = wx.getStorageSync('user').user_id || '0', id = 0;
- if (user_id != '0' || tel != '0') {
- that.setData({hasPhone: true})
- }else{
- that.setData({hasPhone: false});
- console.log(flag);
- if (!flag) {
- console.log('test');
- id = event.currentTarget.dataset.id
- wx.navigateTo({
- url: "/pages/getPhone/getPhone?from=card&preid=" + id
- })
- }
- }
- },
- initCardList: function () {
- var data = {}, list = [], that = this, hasNext = true;
- if (that.data.page === 0) {
- list = []
- }else{
- list = that.data.cardList;
- }
- wx.request({
- url: app.globalData.HOST + '/user/CreditCard/list',
- method: "POST",
- data: {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",
- 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()
- }
- }
- })
|