123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- // pages/point/point.js
- var BASEURL = require('../../utils/wxconstant.js')
- var baseUrl = BASEURL.BaseUrl()
- var baseutils = require('../../utils/baseUtils.js')
- var netUtil = require('../../utils/network.js')
- var pageSize = 1
- var isregistered
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- // tab切换
- currentTab: 0,
- clientHeight: '',
- idAddPoint:'idAddPoint',
- idMinusPoint:'idMinusPoint',
- /**
- * 页面配置
- */
- winWidth: 0,
- winHeight: 0,
- addList:[],
- minusList:[],
- points_rank:{}
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that = this
- /**
- * 获取系统信息
- */
- wx.getSystemInfo({
- success: function (res) {
- that.setData({
- winWidth: res.windowWidth,
- winHeight: res.windowHeight,
- clientHeight: res.windowHeight
- });
- }
- })
-
- },
-
- gotoWxlogin:function(){
- wx.showModal({
- title: '提示',
- content: '您当前尚未进行微信授权登录,是否立即前往?',
- success: function (res) {
- if (res.confirm) {
- wx.switchTab({
- url: '../mine/mine',
- })
- } else if (res.cancel) {
- return
- }
- }
- })
-
- },
- getHisPointData: function () {
- var that = this
- var data = {
- openid: wx.getStorageSync('openid'),
- pageCount:20,
- pageSize: pageSize
- }
- var url = baseUrl + BASEURL.getUrl.getAllRank
- netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
- if(res.data.success && res.data.data){
- if(pageSize == 1){
- that.setData({
- addList: res.data.data.addList,
- minusList: res.data.data.minusList,
- points_rank: res.data.data.points_rank
- })
- }else{
- that.setData({
- addList: [...that.data.addList, ...res.data.data.addList],
- minusList: [...that.data.minusList, ...res.data.data.minusList],
- points_rank: [...that.data.points_rank, ...res.data.data.points_rank],
- })
- }
- }
- }, function (res) {
- wx.showToast({
- title: '加载数据失败',
- icon: 'none',
- duration: 2000
- })
- })
- },
- btnClick: function (event) {
- var that = this
- var id = event.currentTarget.id
- var wxnickName = wx.getStorageSync('wxnickName')
- console.log('wxnickName', wxnickName)
- if (!wxnickName) {
- wx.showModal({
- title: '提示',
- content: '您当前尚未进行微信授权登录,是否立即前往?',
- success: function (res) {
- if (res.confirm) {
- wx.switchTab({
- url: '../mine/mine',
- })
- } else if (res.cancel) {
- return
- }
- }
- })
- return
- } else if (!isregistered) {
- wx.showModal({
- title: '提示',
- content: '您当前尚未与企业关联绑定,是否立即去绑定?',
- success: function (res) {
- if (res.confirm) {
- wx.navigateTo({
- url: '../bindphone/bindphone',
- })
- } else if (res.cancel) {
- return
- }
- }
- })
- return
- }
- if (id == that.data.idAddPoint){
- wx.navigateTo({
- url: '../pointapply/pointapply',
- })
- } else if (id == that.data.idMinusPoint){
- wx.navigateTo({
- url: '../minusapply/minusapply',
- })
- }
- },
- addListClick:function(event){
- // console.log("点击了", event.currentTarget.dataset.item)
- var itemdata = event.currentTarget.dataset.item
- wx.navigateTo({
- url: '../pointapply/pointapply?getisDetails=' + true + '&getItemdata=' + JSON.stringify(itemdata),
- })
- },
- minusListClick: function (event){
- var itemdata = event.currentTarget.dataset.item
- wx.navigateTo({
- url: '../minusapply/minusapply?getisDetails=' + true + '&getItemdata=' + JSON.stringify(itemdata),
- })
- },
- /**
- * 点击tab切换
- */
- swichNav: function (e) {
- var that = this;
- // console.log('swichNav=', e)
- if (this.data.currentTab == e.target.dataset.current) {
- return false;
- } else {
- that.setData({
- currentTab: e.target.dataset.current
- })
- }
- },
- /**
- * 滑动切换tab
- */
- bindChange: function (e) {
- var that = this;
- if (e.detail.source == 'touch') {
- that.setData({ currentTab: e.detail.current });
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- isregistered = wx.getStorageSync('isregistered')
- if (isregistered) {
- this.getHisPointData()
- } else {
- // that.gotoWxlogin()
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- var that = this
- wx.showNavigationBarLoading() //在标题栏中显示加载
- pageSize = 1
- that.getHisPointData()
- //模拟加载
- setTimeout(function () {
- // complete
- wx.hideNavigationBarLoading() //完成停止加载
- wx.stopPullDownRefresh() //停止下拉刷新
- }, 500);
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- pageSize++;
- this.getHisPointData()
- wx.showNavigationBarLoading();
- var that = this;
- setTimeout(function () { wx.hideNavigationBarLoading() }, 2000);
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|