const api = require('../../../utils/api.js'); const login = require('../../../utils/index.js'); Page({ /** * 页面的初始数据 */ data: { items: [{ 'index': 1, 'name': '非常不满意' }, { 'index': 2, 'name': '不满意' }, { 'index': 2, 'name': '一般' }, { 'index': 3, 'name': '满意' }, { 'index': 4, 'name': '非常满意' }], tab:['已评价','未评价'], cur_index:0, page:1, page1:1, type:1, list:[], list1:[], tab_index:0 }, assess:function(e){ wx.navigateTo({ url: e.currentTarget.dataset.url, }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let that=this // wx.setStorageSync('userId', 92) var query = wx.createSelectorQuery(); //选择id query.select('.menus').boundingClientRect(); query.exec(function (res) { that.data.topHeight = res[0].height wx.getSystemInfo({ success: function (res) { that.setData({ clientHeight: res.windowHeight - that.data.topHeight }); } }) }) let getUserInfo = login.default.getUserInfo(); getUserInfo.then((resolve) => { that.data.userInfo = resolve if (!that.data.userInfo.id) { return false } that.req() }) }, req:function(){ let that=this wx.showLoading({ title: '正在加载', }) wx.request({ url: api.evaluateList, data: { userId: that.data.userInfo.id, status: that.data.type, page: that.data.type == 1 ? that.data.page : that.data.page1, rows: 20 }, success(res) { wx.hideLoading(); if(that.data.type==1){ if (res.data.data.items.length < 20) { that.data.isno = true } if (that.data.list) { for (let i = 0; i < res.data.data.items.length; i++) { that.data.list.push(res.data.data.items[i]) } } else { that.data.list = res.data.data.items } that.setData({ list: that.data.list, dixian1: res.data.data.items.length < 20?true:false }) }else{ if (res.data.data.items.length < 20) { that.data.isno1 = true } if (that.data.list1) { for (let i = 0; i < res.data.data.items.length; i++) { that.data.list1.push(res.data.data.items[i]) } } else { that.data.list1 = res.data.data.items } that.setData({ list1: that.data.list1, dixian2: res.data.data.items.length < 20 ? true : false }) } } }) }, scrollbot:function(){ let that = this if(that.data.type==1){ if (that.data.isno) { // wx.showToast({ // title: '没有更多了', // icon: 'none' // }) that.setData({ dixian1: true }) return false; } } else if (that.data.type==0){ if (that.data.isno1) { // wx.showToast({ // title: '没有更多了', // icon: 'none' // }) that.setData({ dixian2:true }) return false; } } if(that.data.type==1){ that.data.page = that.data.page + 1 }else{ that.data.page1 = that.data.page1 + 1 } that.req() }, meunTap:function(e){ this.setData({ cur_index:e.currentTarget.dataset.index, tab_index: e.currentTarget.dataset.index, }) }, swiperChange:function(e){ var that = this if (e.detail.current == 0) { this.data.type = 1 if (that.data.list.length == 0) { that.req() } } else if (e.detail.current == 1) { this.data.type = 0 if(that.data.list1.length==0){ that.req() } } e.currentTarget.dataset.index = e.detail.current this.meunTap(e); this.setData({ tab_index: e.detail.current }) }, nav:function(e){ wx.navigateTo({ url: e.currentTarget.dataset.url }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { let that=this }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })