problem description
item needs to add a point and discussion function. At present, the interview shows that it is normal, but after the interview, you need to add the name of the person. I am stuck in this place where setData facilitates local refresh from global to local. The first ten local refreshes can be implemented
. After the failure, I find the error, and every time I drop down, I will change the list to return 0-9. This is java. Backstage
it"s not easy for me to change my backstage. Is there any solution? You can get some ideas
the environmental background of the problems and what methods you have tried
used local refresh
var param = {};
var string = "DiggArray[" + index + "]"
param[string] = res.data.list[index].likeList
_this.setData(param);
can only change the first ten backend returns pageNum:2 after the subscript is updated to another 0-9
related codes
/ / Please paste the code text below (do not replace the code with pictures)
var Api = "https://www.xiabiapp.com"
var app = getApp ()
Page ({
)data: {
Nav: ["", ""],
NavTab: 0,
giftPage: [],
reward: [],
pageNum: 1,
createDate: [],
},
onLoad: function (options) {
var _this = this
wx.request({
url: Api + "/gift/giftPage",
data: {
pageNum: 1,
companyId: app.globalData.companyId
},
header: {
"Content-Type": "application/json"
},
method: "POST",
success(res) {
console.log(res)
var Time = []
var Timeago = []
var gift = res.data.list
for (var i = 0; i < gift.length; iPP) {
var stringTime = gift[i].createDate
var TimeArray = stringTime.replace(/-/g, "/")
var timestamp2 = new Date(TimeArray).getTime()
Time.push(timestamp2)
Timeago.push(getDateDiff(Time[i]))
}
var DiggArray = []
for (var k = 0; k < gift.length; kPP) {
var digg = gift[k].likeList
DiggArray.push(digg)
}
_this.setData({
giftPage: res.data.list,
Timeago: Timeago,
DiggArray: DiggArray
})
}
})
},
NavTab: function (e) {
var NavTab = e.currentTarget.dataset.id
this.setData({
NavTab: NavTab
})
var _this = this
if (NavTab == 0) {
wx.request({
url: Api + "/gift/giftPage",
data: {
pageNum: 1,
companyId: app.globalData.companyId
},
header: {
"Content-Type": "application/json"
},
method: "POST",
success(res) {
console.log(res)
var Time = []
var Timeago = []
var gift = res.data.list
for (var i = 0; i < gift.length; iPP) {
var stringTime = gift[i].createDate
var TimeArray = stringTime.replace(/-/g, "/")
var timestamp2 = new Date(TimeArray).getTime()
Time.push(timestamp2)
Timeago.push(getDateDiff(Time[i]))
}
var DiggArray = []
for (var k = 0; k < gift.length; kPP) {
var digg = gift[k].likeList
DiggArray.push(digg)
}
_this.setData({
giftPage: [],
pageNum: 1
})
_this.setData({
giftPage: res.data.list,
Timeago: Timeago,
DiggArray: DiggArray
})
}
})
} else {
}
},
onReachBottom (e) {
var NavTab = this.data.NavTab
if (NavTab == 0) {
var pageNum = this.data.pageNum
this.setData({
pageNum: pageNum += 1
})
var giftPageArray = []
var TimeagoArray = []
var onDiggArray = []
var _this = this
wx.request({
url: Api + "/gift/giftPage",
data: {
companyId: app.globalData.companyId,
pageNum: pageNum
},
header: {
"content-type": "application/json"
},
method: "POST",
success(res) {
console.log(res)
var Time = []
var Timeago = []
var gift = res.data.list
for (var i = 0; i < gift.length; iPP) {
var stringTime = gift[i].createDate
var TimeArray = stringTime.replace(/-/g, "/")
var timestamp2 = new Date(TimeArray).getTime()
Time.push(timestamp2)
Timeago.push(getDateDiff(Time[i]))
}
var DiggArray = []
for (var k = 0; k < gift.length; kPP) {
var digg = gift[k].likeList
DiggArray.push(digg)
}
onDiggArray = _this.data.DiggArray.concat(DiggArray)
TimeagoArray = _this.data.Timeago.concat(Timeago)
giftPageArray = _this.data.giftPage.concat(res.data.list)
console.log(onDiggArray)
_this.setData({
giftPage: giftPageArray,
Timeago: TimeagoArray,
DiggArray: onDiggArray
})
}
})
} else if (NavTab == 1) {
}
},
digg (e) {
var _this = this
var id = e.currentTarget.dataset.id
var index = e.currentTarget.dataset.index
console.log(index)
var giftPage = this.data.giftPage
_this.setData({
id: id
})
wx.request({
url: Api + "/gift/like",
data: {
userId: app.globalData.userId,
giftId: id
},
header: {
"Content-Type": "application/json"
},
method: "POST",
success(res) {
wx.showToast({
title: "good",
})
wx.request({
url: Api + "/gift/giftPage",
data: {
pageNum: 1,
companyId: app.globalData.companyId
},
header: {
"Content-Type": "application/json"
},
method: "POST",
success(res) {
console.log(res)
// var DiggArray = []
// for (var k = 0; k < gift.length; kPP) {
// var digg = gift[k].likeList
// DiggArray.push(digg)
// }
var param = {};
var string = "DiggArray[" + index + "]"
param[string] = res.data.list[index].likeList
_this.setData(param);
}
})
}
})
},
})
function getDateDiff (dateTimeStamp) {
var result;
var minute = 1000 * 60;
var hour = minute * 60;
var day = hour * 24;
var halfamonth = day * 15;
var month = day * 30;
var now = new Date (). GetTime ();
var diffValue = now-dateTimeStamp;
if (diffValue < 0) {
return;
}
var monthC = diffValue / month;
var weekC = diffValue / (7 * day);
var dayC = diffValue / day;
var hourC = diffValue / hour;
var minC = diffValue / minute;
if (monthC > = 1) {
if (monthC <= 12)
result = "" + parseInt(monthC) + "";
else {
result = "" + parseInt(monthC / 12) + "";
}
} else if (weekC > = 1) {
result = "" + parseInt(weekC) + "";
} else if (dayC > = 1) {
result = "" + parseInt(dayC) + "";
} else if (hourC > = 1) {
result = "" + parseInt(hourC) + "";
} else if (minC > = 1) {
result = "" + parseInt(minC) + "";
} else {
result = "";
}
return result;
};
what result do you expect? What is the error message actually seen?
I hope someone can tell me how to judge the subscript of the new array when the subscript is refreshed when I return in the background