|
...
|
...
|
@@ -2,6 +2,8 @@ |
|
|
|
import util from '../../utils/util';
|
|
|
|
import App from '../../utils/api';
|
|
|
|
const {regeneratorRuntime} = global
|
|
|
|
import PubSub from '../../utils/PubSub'
|
|
|
|
console.log(PubSub)
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -11,14 +13,33 @@ Page({ |
|
|
|
sellers:[],
|
|
|
|
hasMore:true,
|
|
|
|
},
|
|
|
|
|
|
|
|
sellers:[],
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
|
|
|
|
PubSub.on(
|
|
|
|
'follow',
|
|
|
|
data=>{
|
|
|
|
console.log('follow.msg',data)
|
|
|
|
this.formatSellers(data);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
},
|
|
|
|
formatSellers(data){
|
|
|
|
let sellers=[];
|
|
|
|
this.sellers.forEach(seller=>{
|
|
|
|
if(seller.id==data.sid){
|
|
|
|
seller.hasFollow=data.hasFollow
|
|
|
|
}
|
|
|
|
if(seller.hasFollow){
|
|
|
|
sellers.push(seller)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
sellers:sellers
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
...
|
...
|
@@ -30,7 +51,12 @@ Page({ |
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
if(this.hasMore){
|
|
|
|
if(this.hasMore || this.data.sellers.length==0){
|
|
|
|
this.sellers=[]
|
|
|
|
this.offset=1
|
|
|
|
this.setData({
|
|
|
|
sellers:[]
|
|
|
|
})
|
|
|
|
this.getPos()
|
|
|
|
}
|
|
|
|
},
|
|
...
|
...
|
@@ -46,7 +72,7 @@ Page({ |
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
PubSub.off('follow')
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -94,13 +120,14 @@ Page({ |
|
|
|
}else{
|
|
|
|
seller.seller_tel=[]
|
|
|
|
}
|
|
|
|
|
|
|
|
seller.hasFollow=true
|
|
|
|
})
|
|
|
|
|
|
|
|
sellers=[...this.data.sellers,...sellers]
|
|
|
|
this.setData({
|
|
|
|
sellers:[...this.data.sellers,...sellers],
|
|
|
|
sellers:sellers,
|
|
|
|
hasMore:this.hasMore,
|
|
|
|
})
|
|
|
|
this.sellers=sellers
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getPos(){
|
...
|
...
|
|