Commit 57086c9903bc87aa42eecf51e4a7adcab1b18603

Authored by wangfan
1 parent 8b11da96

c端预定

@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 <view class="info flex-tb"> 7 <view class="info flex-tb">
8 <view class="name Semibold">{{seller.sellername}}</view> 8 <view class="name Semibold">{{seller.sellername}}</view>
9 <view wx:if="{{hasStat}}" class="stat"> 9 <view wx:if="{{hasStat}}" class="stat">
10 - <stat stat="3.0"></stat> 10 + <stat stat="{{seller.score}}"></stat>
11 </view> 11 </view>
12 <view class="text">{{seller.cate[0].name?seller.cate[0].name+' | ':''}}距当前位置{{seller.distance}}</view> 12 <view class="text">{{seller.cate[0].name?seller.cate[0].name+' | ':''}}距当前位置{{seller.distance}}</view>
13 <view class="price flex-lr"> 13 <view class="price flex-lr">
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 })
1 <!--pages/me/follow.wxml--> 1 <!--pages/me/follow.wxml-->
2 <nav>订好座,就用一键订</nav> 2 <nav>订好座,就用一键订</nav>
3 <view class="pages"> 3 <view class="pages">
4 - <view class="flex-vc empty"> 4 + <view class="flex-vc empty" wx:if="{{sellers.length<1}}">
5 <image src="http://qn.colorcun.com/custom/lite-online/image/follow-empty.png"></image> 5 <image src="http://qn.colorcun.com/custom/lite-online/image/follow-empty.png"></image>
6 <view>您还没有收藏任何餐厅哦</view> 6 <view>您还没有收藏任何餐厅哦</view>
7 </view> 7 </view>
8 - <view class="follow">  
9 - <sb-tr seller="{{}}" hasStat="{{true}}"></sb-tr> 8 + <view class="follow" wx:else="">
  9 + <view class="seller" wx:for="{{sellers}}" wx:key="sellers.key" bindtap="gotoDetail" data-sid="{{item.id}}">
  10 + <sb-tr seller="{{item}}" hasStat="{{true}}"></sb-tr>
  11 + </view>
  12 + <view class="seller flex-vc" wx:if="{{!hasMore}}">没有更多了</view>
10 </view> 13 </view>
11 </view> 14 </view>
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 .pages{ 2 .pages{
3 width: 90%; 3 width: 90%;
4 margin: 0 auto; 4 margin: 0 auto;
  5 + font-size: 30rpx;
5 } 6 }
6 .empty{margin-top: 230rpx;} 7 .empty{margin-top: 230rpx;}
7 .empty image{ 8 .empty image{
@@ -11,4 +12,10 @@ @@ -11,4 +12,10 @@
11 .empty view{ 12 .empty view{
12 font-size: 28rpx; 13 font-size: 28rpx;
13 margin-top: 86rpx; 14 margin-top: 86rpx;
  15 +}
  16 +.follow {
  17 + padding-bottom: 50rpx;
  18 +}
  19 +.follow .seller{
  20 + padding-top:20rpx;
14 } 21 }
@@ -175,4 +175,7 @@ export default { @@ -175,4 +175,7 @@ export default {
175 175
176 //顾客收藏、取消收藏店铺 176 //顾客收藏、取消收藏店铺
177 'App.Customer.SetCollectionRel':null, 177 'App.Customer.SetCollectionRel':null,
  178 +
  179 + //顾客收藏的店铺列表
  180 + 'App.Customer.GetCollectionSellerList':null,
178 } 181 }