| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- import common from '../../utils/util';
- import server from '../../utils/main';
- const app = getApp()
- Page({
- data: {
- version: app.globalData.version,
- FileUrl: app.globalData.fileUrl,
- IsEdit: false,
- ListHeight: 1320,
- SelectedCount: 0,
- },
- onLoad: function () {
- this.setData({
- Containnerheight: server.getWindowHeight(),
- });
- this.getList();
- },
- getList: function () {
- var that = this;
- var list = wx.getStorageSync("AnswerList");
- if (list && list.length > 0) {
- var arr = [];
- for (var i = 0; i < list.length; i++) {
- list[i].Selected = false;
- arr.push(list[i]);
- }
- var ListHeight = 1320;
- var ListHeight2 = 1490;
- var ListHeight3 = arr.length * 130 + 20;
- if (arr.length > 10) {
- ListHeight = 1320 + (arr.length - 10) * 130;
- ListHeight2 = 1490 + (arr.length - 10) * 130;
- }
- that.setData({
- AnswerList: arr,
- ListHeight: ListHeight,
- ListHeight2: ListHeight2,
- ListHeight3: ListHeight3,
- });
- }
- },
- selectItem: function (e) {
- if (e.currentTarget.dataset.id) {
- var id = e.currentTarget.dataset.id;
- if (this.data.IsEdit) {
- var count = 0;
- var list = this.data.AnswerList;
- for (var i = 0; i < list.length; i++) {
- if (id == list[i].AnswerID) {
- list[i].Selected = !list[i].Selected;
- }
- if (list[i].Selected)
- count++;
- }
- this.setData({
- AnswerList: list,
- SelectedCount: count,
- });
- }
- else {
- wx.navigateTo({
- url: '../main/item?id=' + id,
- });
- }
- }
- },
- deleteItem: function () {
- var list = this.data.AnswerList;
- for (var i = list.length - 1; i >= 0; i--) {
- if (list[i].Selected) {
- list.splice(i, 1);
- }
- }
- list.sort(function (a, b) {
- if (a.CreateTime == b.CreateTime) {
- return b.AnswerID - b.AnswerID;
- } else {
- return b.CreateTime > a.CreateTime;
- }
- });
- this.setData({
- AnswerList: list,
- SelectedCount: 0,
- });
- wx.setStorageSync("AnswerList", list);
- },
- btnEdit: function () {
- var that = this;
- that.data.IsEdit = !that.data.IsEdit;
- for (var i = 0; i < that.data.AnswerList.length; i++) {
- that.data.AnswerList[i].Selected = false;
- }
- that.setData({
- IsEdit: that.data.IsEdit,
- AnswerList: that.data.AnswerList,
- });
- },
- onShareAppMessage: function () {
- return {
- title: '',
- path: 'pages/index/index',
- success: function (res) {
- },
- fail: function (err) {
- console.log(err);
- },
- complete: function (res) {
- console.log(res);
- },
- }
- },
- })
|