fenggu/pages/user/user.js

137 lines
3.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// pages/picture/picture.js
var urlPath = require('../../config.js');
Page({
// 前往下一页
picture() {
wx.navigateTo({ url: '../picture/picture' });
},
again() {
wx.navigateTo({ url: '../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) {
var that = this;
var user = wx.getStorageSync('user');
console.log(user);
that.getImgs();
},
//小于10的格式化函数2变成02
timeFormat(param) {
return param < 10 ? '0' + param : param;
},
//小于0的格式化函数不会出现负数
timeFormin(param) {
return param < 0 ? 0: param;
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
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); //失败
}
}
});
}
})