Commit fc4f87d82cc94d839106f55fe2c411cb533f5823

Authored by iceling
1 parent 00c42d55

服务项目填充分页

pages/user/my_service/my_service.js
1 1 var e = getApp(),
2 2 a = e.globalData.setting,
3 3 os = a,
4   - t = e.request;
  4 + t = e.request,
  5 + d = e.globalData;
5 6 Page({
6 7  
7 8 /**
... ... @@ -13,13 +14,14 @@ Page({
13 14 content: "请将二维码展示给核销员,服务更快捷!"
14 15 },
15 16 iurl: a.imghost,
16   - defimgurl:"/miniapp/images/yyservice/yyxmdefault.jpg",
17   - service_List: null, //服务项目列表
  17 + defimgurl: "/miniapp/images/yyservice/yyxmdefault.jpg",
  18 + service_List: [], //服务项目列表
18 19 is_service_read: 0,
19   - curpage: 1,
  20 + curpage: 1, //当前分页数
  21 + pageSize: 8, //页大小
20 22 total: 0,
21   - ismore: 0,
22   - userinfo: null
  23 + ismore: 0, //是否加载完毕
  24 + userinfo: null,
23 25 },
24 26  
25 27 /**
... ... @@ -44,42 +46,36 @@ Page({
44 46 th.query_service();
45 47 },
46 48 onReachBottom: function() {
47   - if (this.data.total <= 8) return;
  49 + var th = this;
  50 + if (this.data.total <= th.data.pageSize) return;
48 51 if (this.data.ismore) return;
49 52 this.query_service();
50 53 },
51 54 //查询服务项目列表
52 55 query_service: function() {
53 56 var th = this;
54   - var url = "http://172.20.0.13:8085/api/weshop/marketing/reservation/marketing/sm/list";
55   - wx.request({
56   - url: url,
  57 + var url = "/api/weshop/marketing/reservation/sm/page";
  58 + getApp().request.promiseGet(url, {
57 59 data: {
58   - storeId: 1,
59   - userId: 5682130
60   - },
61   - success: function(res) {
62   - if (res.data.code == 0) {
63   -
64   - // th.data.curpage++;
65   - // var arr1 = th.data.service_List;
66   - // var arr2 = res.data.data.pageData;
67   - // var arr3 = [...arr1, ...arr2];
68   -
69   - // var ismore = 0;
70   - // if (arr3.length == res.data.data.total) ismore = 1
71   -
72   - // th.setData({
73   - // service_List: arr3,
74   - // total: res.data.data.total,
75   - // ismore: ismore,
76   - // is_service_read: 1
77   - // }), wx.stopPullDownRefresh(); //停止下拉刷新
78   -
79   - th.setData({
80   - service_List: res.data.data
81   - })
82   - }
  60 + storeId: a.stoid,
  61 + userId: d.user_id,
  62 + page: th.data.curpage,
  63 + pageSize: th.data.pageSize
  64 + }
  65 + }).then(res => {
  66 + if (res.data.code == 0) {
  67 + th.data.curpage++;
  68 + var arr1 = th.data.service_List;
  69 + var arr2 = res.data.data.pageData;
  70 + var arr3 = [...arr1, ...arr2];
  71 + var ismore = 0;
  72 + if (arr3.length == res.data.data.total) ismore = 1
  73 + th.setData({
  74 + service_List: arr3,
  75 + total: res.data.data.total,
  76 + ismore: ismore,
  77 + is_service_read: 1
  78 + }), wx.stopPullDownRefresh(); //停止下拉刷新
83 79 }
84 80 })
85 81 },
... ... @@ -120,7 +116,7 @@ Page({
120 116 return fm;
121 117 },
122 118 //跳转到首页
123   - goto:function(e){
  119 + goto: function(e) {
124 120 var url = e.currentTarget.dataset.url;
125 121 getApp().goto(url);
126 122 }
... ...
pages/user/my_service/my_service.wxml
... ... @@ -6,7 +6,7 @@
6 6  
7 7 <!-- 预约内容 -->
8 8 <!-- 项目框架 -->
9   -<view class="Serviceitems" wx:if="{{service_List.length>=0}}">
  9 +<view class="Serviceitems">
10 10 <!-- 单个项目 -->
11 11 <view class="rel" wx:for="{{service_List}}">
12 12 <view class="abs">
... ... @@ -25,7 +25,7 @@
25 25 </view>
26 26 <view>
27 27 <view class="flex-center">
28   - <image class="itemimage" src="{{item.img==undefined?iurl+defimgurl:iurl+item.img}}" lazy-load="true" data-errorimg="service_List[{{index}}].img" binderror="bind_bnerr1" data-img="{{item.img}}"></image>
  28 + <image class="itemimage" src="{{item.ImageUrl==''?iurl+defimgurl:item.ImageUrl}}" lazy-load="true" data-errorimg="service_List[{{index}}].img" binderror="bind_bnerr1" data-img="{{item.img}}"></image>
29 29 </view>
30 30  
31 31 <view class="flex-center itemName">
... ... @@ -57,7 +57,7 @@
57 57  
58 58 </view>
59 59 <!-- 无服务项目 -->
60   -<view wx:if="{{service_List.length>=0 && is_service_read}}">
  60 +<view wx:if="{{service_List.length<0 && ismore}}">
61 61 <!-- 遮住 -->
62 62 <view class="cover"></view>
63 63 <!-- 无历史服务 -->
... ...