fenggu/pages/user/user.js

136 lines
3.2 KiB
JavaScript
Raw Normal View History

// pages/picture/picture.js
var urlPath = require('../../config.js');
Page({
// 前往下一页
picture() {
2021-12-15 05:38:09 +00:00
wx.navigateTo({ url: '/pagesA/pages/picture/picture' });
},
again() {
2021-12-15 05:38:09 +00:00
wx.navigateTo({ url: '/pagesA/pages/sign/sign' });
},
/**
* 页面的初始数据
*/
data: {
img_url:wx.getStorageSync('img_url'),
swiperCurrent:0,
autoplay: false,
interval: 3000,
duration: 800,
//数据
name: wx.getStorageSync('user').name,
nm_number:"0",
//列表
works_list:[],
},
swiperChange: function (e) {
// console.log(e);
this.setData({
swiperCurrent: e.detail.current
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
2021-12-15 05:38:09 +00:00
},
//小于10的格式化函数2变成02
timeFormat(param) {
return param < 10 ? '0' + param : param;
},
//小于0的格式化函数不会出现负数
timeFormin(param) {
return param < 0 ? 0: param;
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
2021-12-15 05:38:09 +00:00
var that = this;
var user = wx.getStorageSync('user');
that.getImgs();
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
onShow:function(){
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().setData({
selected: 3
})
}
},
getImgs:function(){
var that = this;
wx.request({
url: urlPath.getImgs,
header:{
'token': wx.getStorageSync('token')
},
success(res){
if(res.data.code == 0){
if(res.data.data.length > 0){
var works_list = [];
var num = 0;
res.data.data.forEach(function(item, index){
works_list.push({
ids: item.id,
img: urlPath.host + item.pic,
text: item.explain,
number: item.votes,
});
num = num + item.votes;
});
that.setData({
works_list: works_list,
nm_number: num
});
}
}else{
console.log(res); //失败
}
}
});
}
})