| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- const app = getApp();
- Page({
- data: {
- },
- onLoad: function (options) {
- var that = this;
- that.setData({
- Containnerheight: main.getWindowHeight(),
- });
- if (options.search) {
- wx.setNavigationBarTitle({
- title: options.search
- });
- }
- else if (options.type==1) {
- wx.setNavigationBarTitle({
- title: "今日的任务"
- });
- }
- },
- 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,
- });
- 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,
- })
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|