|
|
|
// pages/me/follow.js
|
|
|
|
import util from '../../utils/util';
|
|
|
|
import App from '../../utils/api';
|
|
|
|
const {regeneratorRuntime} = global
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
sellers:[],
|
|
|
|
hasMore:true,
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
if(this.hasMore){
|
|
|
|
this.getPos()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function () {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom: function (e) {
|
|
|
|
console.log(e)
|
|
|
|
if(this.hasMore){
|
|
|
|
this.GetCollectionSellerList();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
offset:1,
|
|
|
|
size:10,
|
|
|
|
hasMore:true,
|
|
|
|
GetCollectionSellerList(){
|
|
|
|
App.Customer.GetCollectionSellerList({
|
|
|
|
openid:getApp().openid,
|
|
|
|
lat:this.location.latitude,
|
|
|
|
lng:this.location.longitude,
|
|
|
|
offset:this.offset,
|
|
|
|
size:this.size,
|
|
|
|
}).then(res=>{
|
|
|
|
let sellers=res.data;
|
|
|
|
let sellersLength=sellers.length;
|
|
|
|
this.hasMore=sellersLength>=this.size
|
|
|
|
if(this.hasMore){
|
|
|
|
this.offset+=1
|
|
|
|
}
|
|
|
|
sellers.forEach((seller,si) => {
|
|
|
|
seller.distance = parseInt(seller.distance);
|
|
|
|
if (seller.distance > 1000) {
|
|
|
|
seller.distance = (seller.distance / 1000).toFixed(2) + '公里'
|
|
|
|
} else {
|
|
|
|
seller.distance += '米';
|
|
|
|
}
|
|
|
|
if(seller.seller_tel){
|
|
|
|
seller.seller_tel=seller.seller_tel.split(',');
|
|
|
|
}else{
|
|
|
|
seller.seller_tel=[]
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
sellers:[...this.data.sellers,...sellers],
|
|
|
|
hasMore:this.hasMore,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getPos(){
|
|
|
|
this._getPos().then(res => {
|
|
|
|
console.log('wx.getLocation.then', res);
|
|
|
|
this.location=res
|
|
|
|
this.GetCollectionSellerList();
|
|
|
|
}).catch((e) => {
|
|
|
|
console.log('wx.getLocation.catch', e);
|
|
|
|
if ('getLocation:fail auth deny' == e.errMsg || 'getLocation:fail:auth denied' == e.errMsg) {
|
|
|
|
this.selectComponent('#showModal').options({
|
|
|
|
header: '定位失败',
|
|
|
|
body: '需要地理位置授权'
|
|
|
|
}).show();
|
|
|
|
} else {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.getPos()
|
|
|
|
}, 500)
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
},
|
|
|
|
_getPos(){
|
|
|
|
return new Promise((success, fail) => {
|
|
|
|
wx.getLocation({
|
|
|
|
type: 'gcj02',
|
|
|
|
success: (res) => {
|
|
|
|
success(res)
|
|
|
|
},
|
|
|
|
fail: (res) => {
|
|
|
|
fail(res)
|
|
|
|
},
|
|
|
|
complete: (res) => {
|
|
|
|
console.log('wx.getLocation', res)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
},
|
|
|
|
gotoDetail(e){
|
|
|
|
wx.navigateTo({
|
|
|
|
url:'/pages/reserve/detail?id='+util.attr(e,'sid')
|
|
|
|
})
|
|
|
|
},
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|