const app = getApp()
var util = require('../../utils/util.js')
Component({
data: {
cards: []
},
properties: {
},
lifetimes: {
attached: function() {
this.readdata()
}
},
pageLifetimes: {
show: function() {
this.readdata()
}
},
ready: function() {
},
methods: {
getinfo: function() {
let token = wx.getStorageSync('token')
wx.request({
url: app.globalData.b_info,
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded',
'cookie': token
},
data: {
token
},
success: res => {
console.log(res.data)
let list = Array.prototype.slice.call(res.data);
list.forEach(item => {
let img = {
url: "/static/images/my_banji.png",
width: 80,
height: 80,
circle: true
}
let title = {
text: item.classname,
color: "#1C9ADC",
size: 34
}
let tag = {
text: util.formatTimeToYmd(item.jointime) + '加入',
color: "#1C9ADC",
size: 28
}
let header = {
bgcolor: "F7F7F7",
line: true
}
item['classid'] = item.classid
item['creator'] = item.creator
item['img'] = img
item['title'] = title
item['tag'] = tag
item['header'] = header
item['createtime'] = util.formatTimeToYmd(item.createtime)
})
this.setData({
cards: list
})
wx.setStorageSync('teacherinfo', list)
}
})
},
readdata: function() {
let data = wx.getStorageSync('teacherinfo')
if (data) {
this.setData({
cards: data
})
} else {
this.getinfo()
}
}
},
})
转载请注明原文地址:https://ipadbbs.8miu.com/read-42090.html