|
1
|
// pages/me/follow.js
|
1
|
// pages/me/follow.js
|
|
|
|
2
|
+import util from '../../utils/util';
|
|
|
|
3
|
+import App from '../../utils/api';
|
|
|
|
4
|
+const {regeneratorRuntime} = global
|
|
2
|
Page({
|
5
|
Page({
|
|
3
|
|
6
|
|
|
4
|
- /**
|
|
|
|
5
|
- * 页面的初始数据
|
|
|
|
6
|
- */
|
|
|
|
7
|
- data: {
|
|
|
|
8
|
-
|
|
|
|
9
|
- },
|
|
|
|
10
|
-
|
|
|
|
11
|
- /**
|
|
|
|
12
|
- * 生命周期函数--监听页面加载
|
|
|
|
13
|
- */
|
|
|
|
14
|
- onLoad: function (options) {
|
|
|
|
15
|
-
|
|
|
|
16
|
- },
|
|
|
|
17
|
-
|
|
|
|
18
|
- /**
|
|
|
|
19
|
- * 生命周期函数--监听页面初次渲染完成
|
|
|
|
20
|
- */
|
|
|
|
21
|
- onReady: function () {
|
|
|
|
22
|
-
|
|
|
|
23
|
- },
|
|
|
|
24
|
-
|
|
|
|
25
|
- /**
|
|
|
|
26
|
- * 生命周期函数--监听页面显示
|
|
|
|
27
|
- */
|
|
|
|
28
|
- onShow: function () {
|
|
|
|
29
|
-
|
|
|
|
30
|
- },
|
|
|
|
31
|
-
|
|
|
|
32
|
- /**
|
|
|
|
33
|
- * 生命周期函数--监听页面隐藏
|
|
|
|
34
|
- */
|
|
|
|
35
|
- onHide: function () {
|
|
|
|
36
|
-
|
|
|
|
37
|
- },
|
|
|
|
38
|
-
|
|
|
|
39
|
- /**
|
|
|
|
40
|
- * 生命周期函数--监听页面卸载
|
|
|
|
41
|
- */
|
|
|
|
42
|
- onUnload: function () {
|
7
|
+ /**
|
|
|
|
8
|
+ * 页面的初始数据
|
|
|
|
9
|
+ */
|
|
|
|
10
|
+ data: {
|
|
|
|
11
|
+ sellers:[],
|
|
|
|
12
|
+ hasMore:true,
|
|
|
|
13
|
+ },
|
|
|
|
14
|
+
|
|
|
|
15
|
+ /**
|
|
|
|
16
|
+ * 生命周期函数--监听页面加载
|
|
|
|
17
|
+ */
|
|
|
|
18
|
+ onLoad: function (options) {
|
|
|
|
19
|
+
|
|
|
|
20
|
+ },
|
|
|
|
21
|
+
|
|
|
|
22
|
+ /**
|
|
|
|
23
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
|
24
|
+ */
|
|
|
|
25
|
+ onReady: function () {
|
|
|
|
26
|
+
|
|
|
|
27
|
+ },
|
|
|
|
28
|
+
|
|
|
|
29
|
+ /**
|
|
|
|
30
|
+ * 生命周期函数--监听页面显示
|
|
|
|
31
|
+ */
|
|
|
|
32
|
+ onShow: function () {
|
|
|
|
33
|
+ if(this.hasMore){
|
|
|
|
34
|
+ this.getPos()
|
|
|
|
35
|
+ }
|
|
|
|
36
|
+ },
|
|
43
|
|
37
|
|
|
44
|
- },
|
38
|
+ /**
|
|
|
|
39
|
+ * 生命周期函数--监听页面隐藏
|
|
|
|
40
|
+ */
|
|
|
|
41
|
+ onHide: function () {
|
|
45
|
|
42
|
|
|
46
|
- /**
|
|
|
|
47
|
- * 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
48
|
- */
|
|
|
|
49
|
- onPullDownRefresh: function () {
|
43
|
+ },
|
|
50
|
|
44
|
|
|
51
|
- },
|
45
|
+ /**
|
|
|
|
46
|
+ * 生命周期函数--监听页面卸载
|
|
|
|
47
|
+ */
|
|
|
|
48
|
+ onUnload: function () {
|
|
52
|
|
49
|
|
|
53
|
- /**
|
|
|
|
54
|
- * 页面上拉触底事件的处理函数
|
|
|
|
55
|
- */
|
|
|
|
56
|
- onReachBottom: function () {
|
50
|
+ },
|
|
57
|
|
51
|
|
|
58
|
- },
|
52
|
+ /**
|
|
|
|
53
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
54
|
+ */
|
|
|
|
55
|
+ onPullDownRefresh: function () {
|
|
59
|
|
56
|
|
|
60
|
- /**
|
|
|
|
61
|
- * 用户点击右上角分享
|
|
|
|
62
|
- */
|
|
|
|
63
|
- onShareAppMessage: function () {
|
57
|
+ },
|
|
64
|
|
58
|
|
|
|
|
59
|
+ /**
|
|
|
|
60
|
+ * 页面上拉触底事件的处理函数
|
|
|
|
61
|
+ */
|
|
|
|
62
|
+ onReachBottom: function (e) {
|
|
|
|
63
|
+ console.log(e)
|
|
|
|
64
|
+ if(this.hasMore){
|
|
|
|
65
|
+ this.GetCollectionSellerList();
|
|
65
|
}
|
66
|
}
|
|
|
|
67
|
+ },
|
|
|
|
68
|
+ offset:1,
|
|
|
|
69
|
+ size:10,
|
|
|
|
70
|
+ hasMore:true,
|
|
|
|
71
|
+ GetCollectionSellerList(){
|
|
|
|
72
|
+ App.Customer.GetCollectionSellerList({
|
|
|
|
73
|
+ openid:getApp().openid,
|
|
|
|
74
|
+ lat:this.location.latitude,
|
|
|
|
75
|
+ lng:this.location.longitude,
|
|
|
|
76
|
+ offset:this.offset,
|
|
|
|
77
|
+ size:this.size,
|
|
|
|
78
|
+ }).then(res=>{
|
|
|
|
79
|
+ let sellers=res.data;
|
|
|
|
80
|
+ let sellersLength=sellers.length;
|
|
|
|
81
|
+ this.hasMore=sellersLength>=this.size
|
|
|
|
82
|
+ if(this.hasMore){
|
|
|
|
83
|
+ this.offset+=1
|
|
|
|
84
|
+ }
|
|
|
|
85
|
+ sellers.forEach((seller,si) => {
|
|
|
|
86
|
+ seller.distance = parseInt(seller.distance);
|
|
|
|
87
|
+ if (seller.distance > 1000) {
|
|
|
|
88
|
+ seller.distance = (seller.distance / 1000).toFixed(2) + '公里'
|
|
|
|
89
|
+ } else {
|
|
|
|
90
|
+ seller.distance += '米';
|
|
|
|
91
|
+ }
|
|
|
|
92
|
+ if(seller.seller_tel){
|
|
|
|
93
|
+ seller.seller_tel=seller.seller_tel.split(',');
|
|
|
|
94
|
+ }else{
|
|
|
|
95
|
+ seller.seller_tel=[]
|
|
|
|
96
|
+ }
|
|
|
|
97
|
+
|
|
|
|
98
|
+ })
|
|
|
|
99
|
+
|
|
|
|
100
|
+ this.setData({
|
|
|
|
101
|
+ sellers:[...this.data.sellers,...sellers],
|
|
|
|
102
|
+ hasMore:this.hasMore,
|
|
|
|
103
|
+ })
|
|
|
|
104
|
+ })
|
|
|
|
105
|
+ },
|
|
|
|
106
|
+ getPos(){
|
|
|
|
107
|
+ this._getPos().then(res => {
|
|
|
|
108
|
+ console.log('wx.getLocation.then', res);
|
|
|
|
109
|
+ this.location=res
|
|
|
|
110
|
+ this.GetCollectionSellerList();
|
|
|
|
111
|
+ }).catch((e) => {
|
|
|
|
112
|
+ console.log('wx.getLocation.catch', e);
|
|
|
|
113
|
+ if ('getLocation:fail auth deny' == e.errMsg || 'getLocation:fail:auth denied' == e.errMsg) {
|
|
|
|
114
|
+ this.selectComponent('#showModal').options({
|
|
|
|
115
|
+ header: '定位失败',
|
|
|
|
116
|
+ body: '需要地理位置授权'
|
|
|
|
117
|
+ }).show();
|
|
|
|
118
|
+ } else {
|
|
|
|
119
|
+ setTimeout(() => {
|
|
|
|
120
|
+ this.getPos()
|
|
|
|
121
|
+ }, 500)
|
|
|
|
122
|
+ }
|
|
|
|
123
|
+
|
|
|
|
124
|
+ })
|
|
|
|
125
|
+ },
|
|
|
|
126
|
+ _getPos(){
|
|
|
|
127
|
+ return new Promise((success, fail) => {
|
|
|
|
128
|
+ wx.getLocation({
|
|
|
|
129
|
+ type: 'gcj02',
|
|
|
|
130
|
+ success: (res) => {
|
|
|
|
131
|
+ success(res)
|
|
|
|
132
|
+ },
|
|
|
|
133
|
+ fail: (res) => {
|
|
|
|
134
|
+ fail(res)
|
|
|
|
135
|
+ },
|
|
|
|
136
|
+ complete: (res) => {
|
|
|
|
137
|
+ console.log('wx.getLocation', res)
|
|
|
|
138
|
+ }
|
|
|
|
139
|
+ });
|
|
|
|
140
|
+ })
|
|
|
|
141
|
+ },
|
|
|
|
142
|
+ gotoDetail(e){
|
|
|
|
143
|
+ wx.navigateTo({
|
|
|
|
144
|
+ url:'/pages/reserve/detail?id='+util.attr(e,'sid')
|
|
|
|
145
|
+ })
|
|
|
|
146
|
+ },
|
|
66
|
}) |
147
|
}) |