Authored by 肖亚东

消息以及收藏 修改— review by 李其昌

... ... @@ -8,7 +8,6 @@ Page({
*/
data: {
messageTypeList: [],
list: [],
messageInfo: {
isLoading: false,
hasMore: true,
... ... @@ -50,14 +49,14 @@ Page({
if (data && data.code == 200 && data.data) {
let messageTypeList = data.data;
const messageList = messageTypeList.map(item => {
const unReadCount = item.unReadCount > 100 ? '99+' : item.unReadCount;
const list = messageTypeList.map(item => {
const unReadCount = item.unReadCount > 100 ? '99+' : item.unReadCount;
item.unReadCount = unReadCount;
return item;
})
that.setData({
messageTypeList: messageList
messageTypeList: list
})
}
wx.hideLoading();
... ... @@ -84,7 +83,6 @@ Page({
title: '',
})
let that = this;
let params = {
method: 'ufo.users.listInboxs',
uid: '500031152',
... ... @@ -97,12 +95,12 @@ Page({
url: config.domains.api,
params: params,
}).then(data => {
console.log(data)
if (data && data.code == 200 && data.list) {
let list = data.list;
messageInfo.isLoading = false;
messageInfo.productList = messageInfo.productList.concat(list);
messageInfo.messageList = messageInfo.messageList.concat(list);
let hasMore = messageInfo.currentPage < data.totalPage;
messageInfo.hasMore = hasMore;
if (hasMore) {
... ...
... ... @@ -23,7 +23,7 @@
<!-- 消息列表 -->
<view class='message-list'>
<block wx:for="{{list}}" wx:key="{{index}}">
<block wx:for="{{messageInfo.messageList}}" wx:key="{{index}}">
<view class='cell'>
<view class='content'>{{item.content}}</view>
<view class='time'>{{item.readTime}}</view>
... ...
import { GET } from '../../../libs/request/request.js';
import config from '../../../config.js'
Page({
/**
* 页面的初始数据
*/
data: {
collectionInfo: {
isLoading: false,
hasMore: true,
currentPage: 1,
collectionList: [],
},
list: [{ 'default_images': 'http://img11.static.yhbimg.com/goodsimg/2018/10/18/17/01ea80f9b7b26d037e8e2867b1e8d1aad1.jpg', 'price': '9', 'id': '10000082', 'product_name': 'Air Jordan Future GS “Bleached Turquoise”' }, { 'default_images': 'http://img11.static.yhbimg.com/goodsimg/2018/10/18/17/01ea80f9b7b26d037e8e2867b1e8d1aad1.jpg', 'price': '9', 'id': '10000082', 'product_name': 'Air Jordan Future GS “Bleached Turquoise”' }, { 'default_images': 'http://img11.static.yhbimg.com/goodsimg/2018/10/18/17/01ea80f9b7b26d037e8e2867b1e8d1aad1.jpg', 'price': '9', 'id': '10000082', 'product_name': 'Air Jordan Future GS “Bleached Turquoise”' }, { 'default_images': 'http://img11.static.yhbimg.com/goodsimg/2018/10/18/17/01ea80f9b7b26d037e8e2867b1e8d1aad1.jpg', 'price': '9', 'id': '10000082', 'product_name': 'Air Jordan Future GS “Bleached Turquoise”' }],
_triggerObserer: true,
},
... ... @@ -16,6 +25,62 @@ Page({
this.setData({
_triggerObserer: !_triggerObserer,
})
this.fetchCollectionList();
},
fetchCollectionList: function () {
// let that = this;
// let collectionInfo = that.data.collectionInfo;
// console.log('====================================');
// console.log(collectionInfo);
// console.log('====================================');
// if (collectionInfo.isLoading || !collectionInfo.hasMore) {
// return;
// }
// collectionInfo.isLoading = true;
// that.setData({
// collectionInfo
// })
// wx.showLoading({
// title: '',
// })
// let params = {
// method: 'ufo.user.favoriteList',
// uid: '500031152',
// page: collectionInfo.currentPage,
// limit: 20,
// debug: 'XYZ'
// }
// GET({
// url: config.domains.api,
// params: params,
// }).then(data => {
// console.log(data)
// if (data && data.code == 200 && data.list) {
// let list = data.list;
// collectionInfo.isLoading = false;
// collectionInfo.collectionList = collectionInfo.collectionList.concat(list);
// let hasMore = collectionInfo.currentPage < data.totalPage;
// collectionInfo.hasMore = hasMore;
// if (hasMore) {
// collectionInfo.currentPage = collectionInfo.currentPage + 1;
// }
// that.setData({
// collectionInfo,
// })
// }
// }).catch(error => {
// collectionInfo.isLoading = false;
// console.error(error);
// })
},
/**
... ... @@ -57,7 +122,7 @@ Page({
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.fetchCollectionList();
},
/**
... ...
... ... @@ -3,6 +3,6 @@
<!-- 消息列表 -->
<view class='collection-list'>
<product-list list="{{list}}" __triggerObserer="{{ _triggerObserer }}"></product-list>
<product-list list="{{collectionInfo.collectionList}}" __triggerObserer="{{ _triggerObserer }}"></product-list>
</view>
</view>
\ No newline at end of file
... ...