| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- const app = getApp();
- Page({
- data: {
- },
- onLoad: function (options) {
- wx.hideShareMenu();
- var that = this;
- var Search="",IsToday=0;
- if (options.search) {
- Search=options.search;
- wx.setNavigationBarTitle({
- title: options.search
- });
- }
- else if (options.type==1) {
- IsToday = 1;
- wx.setNavigationBarTitle({
- title: "今日的任务"
- });
- }
- that.setData({
- Search: Search,
- IsToday: IsToday,
- Count:options.Count,
- Containnerheight: main.getWindowHeight(),
- });
- },
- onPullDownRefresh:function(){
- var that = this;
- that.getList();
- wx.stopPullDownRefresh();
- },
- onShow:function(){
- var that = this;
- that.getList();
- },
- getList: function () {
- var list=wx.getStorageSync("CardList");
- var len=20;
- for(var i=0;i<list.length;i++){
- var item=list[i];
- item.Content[1].ContentStr = replaceString(item.Content[1].Content);
- if (item.Content[1].ContentStr.length > len)
- item.Content[1].ContentStr = replaceString(item.Content[1].ContentStr.substr(0, len)) + "...";
-
- item.Content[2].ContentStr = replaceString(item.Content[2].Content);
- if (item.Content[2].ContentStr.length > len)
- item.Content[2].ContentStr = replaceString(item.Content[2].ContentStr.substr(0, len)) + "...";
-
- var imageUrl = getImage(item.Content[1].Content);
- if (!imageUrl && item.Content[2].Content)
- imageUrl = getImage(item.Content[2].Content);
- if (!imageUrl && item.Content[3].Content)
- imageUrl = getImage(item.Content[3].Content);
- if (imageUrl)
- item.ImageUrl=imageUrl;
- }
- this.setData({
- List:list,
- });
- wx.hideLoading();
- function getImage(str){
- var result="";
- if (str.indexOf("[图]")>=0){
- result = str.substring(str.indexOf("[图]") + 3, str.indexOf("[/图]"));
- }
- return result;
- }
- function replaceString(str){
- str = str.replace(/\[读]/g, "");
- str = str.replace(/\[\/读\]/g, "");
- str = str.replace(/\[图]/g, "");
- str = str.replace(/\[\/图\]/g, "");
- var str2="";
- if (str.indexOf("[读") >= 0) {
- str2 = str.substr(str.indexOf("[读"));
- str2 = str2.substring(0, str2.indexOf("]") + 1);
- }
- str = str.replace(str2, "");
- if (str.indexOf("[读") >= 0) {
- str2 = str.substr(str.indexOf("[读"));
- str2 = str2.substring(0, str2.indexOf("]") + 1);
- }
- str = str.replace(str2, "");
- str = str.replace(/\[线]/g, "");
- str = str.replace(/\[\/线\]/g, "");
- str = main.encryptUrl(str);
- return str;
- }
- },
- onPreview: function (e) {
- var id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: './preview?type=show&id='+id,
- })
- },
- gotoNextPage: function (e) {
- wx.showLoading({
- title: '请稍候',
- });
- var that = this;
- var id = e.currentTarget.dataset.id;
- var url = 'GetMiaoguoCardList?UserID=' + app.globalData.userInfo.UserID+"&IsToday="+that.data.IsToday + "&PageID=" + id;
- if (that.data.Search)
- url += "&Key=" + that.data.Search;
- main.getData(url, function (data) {
- if (data) {
- var list = wx.getStorageSync("CardList");
- for(var i=0;i<data.List.length;i++){
- list.push(data.List[i]);
- }
- wx.setStorageSync("CardList", list);
- that.getList();
- }
- });
- },
- addCard:function(){
- wx.redirectTo({
- url: './add?type=add&id=0',
- });
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|