Commit 7657fdb576f556e65e6c277e4293b5916869566b
1 parent
b5f62d84
手店线上订单搜索
Showing
3 changed files
with
57 additions
and
19 deletions
pages/user/order_list/order_list.js
| @@ -56,6 +56,12 @@ Page({ | @@ -56,6 +56,12 @@ Page({ | ||
| 56 | currentPage2: 1, | 56 | currentPage2: 1, |
| 57 | currentDate: '', | 57 | currentDate: '', |
| 58 | total: 0, //读取时段内记录数量 | 58 | total: 0, //读取时段内记录数量 |
| 59 | + is_no_data2: 0, | ||
| 60 | + is_no_more2: 0, | ||
| 61 | + | ||
| 62 | + | ||
| 63 | + // 搜索内容 | ||
| 64 | + searchContent: '', | ||
| 59 | }, | 65 | }, |
| 60 | onLoad: function(t) { | 66 | onLoad: function(t) { |
| 61 | // 设置日期选择器的结束时间为当前日期 | 67 | // 设置日期选择器的结束时间为当前日期 |
| @@ -1246,7 +1252,7 @@ Page({ | @@ -1246,7 +1252,7 @@ Page({ | ||
| 1246 | }, | 1252 | }, |
| 1247 | 1253 | ||
| 1248 | request_list: function(data, callback){ | 1254 | request_list: function(data, callback){ |
| 1249 | - // console.log('触发上拉刷新'); | 1255 | + // console.log('进入request_list'); |
| 1250 | 1256 | ||
| 1251 | var th = this; | 1257 | var th = this; |
| 1252 | if(this.data.is_load2) return false; //-- 正在加载 | 1258 | if(this.data.is_load2) return false; //-- 正在加载 |
| @@ -1282,7 +1288,7 @@ Page({ | @@ -1282,7 +1288,7 @@ Page({ | ||
| 1282 | th.setData({is_no_more2:1}); | 1288 | th.setData({is_no_more2:1}); |
| 1283 | } | 1289 | } |
| 1284 | } | 1290 | } |
| 1285 | - if(callback) callback(); | 1291 | + if(callback) callback(res); |
| 1286 | } else { | 1292 | } else { |
| 1287 | wx.showToast({ | 1293 | wx.showToast({ |
| 1288 | title: res.data.msg, | 1294 | title: res.data.msg, |
| @@ -1307,6 +1313,10 @@ Page({ | @@ -1307,6 +1313,10 @@ Page({ | ||
| 1307 | }); | 1313 | }); |
| 1308 | if(currentIndex == 0) { | 1314 | if(currentIndex == 0) { |
| 1309 | console.log('线上订单'); | 1315 | console.log('线上订单'); |
| 1316 | + this.setData({ | ||
| 1317 | + startDate: '选择开始时间', | ||
| 1318 | + endDate: '选择结束时间', | ||
| 1319 | + }); | ||
| 1310 | } else if(currentIndex == 1) { | 1320 | } else if(currentIndex == 1) { |
| 1311 | console.log('线下订单'); | 1321 | console.log('线下订单'); |
| 1312 | 1322 | ||
| @@ -1331,40 +1341,67 @@ Page({ | @@ -1331,40 +1341,67 @@ Page({ | ||
| 1331 | endDate: e.detail.value | 1341 | endDate: e.detail.value |
| 1332 | }) | 1342 | }) |
| 1333 | }, | 1343 | }, |
| 1344 | + | ||
| 1345 | + bindInput(e) { | ||
| 1346 | + this.data.searchContent = e.detail.value; | ||
| 1347 | + }, | ||
| 1348 | + | ||
| 1349 | + searchOnline() { | ||
| 1350 | + console.log('online',this.data.searchContent); | ||
| 1351 | + if(this.data.searchContent) { | ||
| 1352 | + console.log(this.data.searchContent); | ||
| 1353 | + } else { | ||
| 1354 | + wx.showToast({ | ||
| 1355 | + title: '您还没有输入搜索内容~', | ||
| 1356 | + icon: 'none', | ||
| 1357 | + }) | ||
| 1358 | + }; | ||
| 1359 | + }, | ||
| 1334 | 1360 | ||
| 1335 | - search() { | 1361 | + searchOffline() { |
| 1362 | + console.log('执行查询'); | ||
| 1336 | let th = this; | 1363 | let th = this; |
| 1337 | let startDate = this.data.startDate; | 1364 | let startDate = this.data.startDate; |
| 1338 | let endDate = this.data.endDate; | 1365 | let endDate = this.data.endDate; |
| 1339 | - | 1366 | + |
| 1367 | + this.data.is_no_data2 = 0; | ||
| 1368 | + | ||
| 1369 | + | ||
| 1340 | if(startDate == '选择开始时间' || endDate == '选择结束时间') { | 1370 | if(startDate == '选择开始时间' || endDate == '选择结束时间') { |
| 1341 | wx.showToast({ | 1371 | wx.showToast({ |
| 1342 | title: '请选择完整的查询时间~', | 1372 | title: '请选择完整的查询时间~', |
| 1343 | icon: 'none', | 1373 | icon: 'none', |
| 1344 | }) | 1374 | }) |
| 1345 | - } | 1375 | + }; |
| 1346 | 1376 | ||
| 1347 | if(new Date(startDate) > new Date(endDate)) { | 1377 | if(new Date(startDate) > new Date(endDate)) { |
| 1348 | wx.showToast({ | 1378 | wx.showToast({ |
| 1349 | - title: '敲黑板!开始时间不能晚于结束时间噢~', | 1379 | + title: '不对噢!开始时间不能晚于结束时间~', |
| 1350 | icon: 'none', | 1380 | icon: 'none', |
| 1351 | }) | 1381 | }) |
| 1352 | - } | 1382 | + return false; |
| 1383 | + }; | ||
| 1353 | 1384 | ||
| 1354 | 1385 | ||
| 1355 | this.request_list({ | 1386 | this.request_list({ |
| 1356 | store_id: os.stoid, | 1387 | store_id: os.stoid, |
| 1357 | user_id: oo.user_id, | 1388 | user_id: oo.user_id, |
| 1358 | page: 1, | 1389 | page: 1, |
| 1359 | - BeginDate:this.data.startDate, | ||
| 1360 | - EndDate: this.data.endDate, | ||
| 1361 | - }, function() { | ||
| 1362 | - th.setData({ | ||
| 1363 | - total: res.data.data.total | ||
| 1364 | - }); | 1390 | + BeginDate: this.data.startDate, |
| 1391 | + EndDate: this.data.endDate | ||
| 1392 | + }, function(res) { | ||
| 1393 | + if(res.data.data.total == 0) { | ||
| 1394 | + wx.showToast({ | ||
| 1395 | + title: '没有找到相关订单', | ||
| 1396 | + icon: 'none', | ||
| 1397 | + duration: 2000 | ||
| 1398 | + }) | ||
| 1399 | + } else { | ||
| 1400 | + th.setData({ | ||
| 1401 | + total: res.data.data.total | ||
| 1402 | + }); | ||
| 1403 | + } | ||
| 1365 | }); | 1404 | }); |
| 1366 | - | ||
| 1367 | - | ||
| 1368 | }, | 1405 | }, |
| 1369 | 1406 | ||
| 1370 | currentDate() { | 1407 | currentDate() { |
pages/user/order_list/order_list.wxml
| @@ -5,8 +5,8 @@ | @@ -5,8 +5,8 @@ | ||
| 5 | <view class="tab {{currentIndex == 1 ? 'active':''}}" data-index="1">线下订单</view> | 5 | <view class="tab {{currentIndex == 1 ? 'active':''}}" data-index="1">线下订单</view> |
| 6 | </view> | 6 | </view> |
| 7 | <view class="search-container flex" wx:if="{{currentIndex == 0}}"> | 7 | <view class="search-container flex" wx:if="{{currentIndex == 0}}"> |
| 8 | - <input class="search-input" type="text" placeholder="请输入您所搜索的商品"/> | ||
| 9 | - <view class="search-btn">搜索</view> | 8 | + <input class="search-input" type="text" placeholder="请输入您所搜索的商品" bindinput="bindInput" bindconfirm="bindInput"/> |
| 9 | + <view class="search-btn" bindtap="searchOnline">搜索</view> | ||
| 10 | </view> | 10 | </view> |
| 11 | <view class="type-navbar fs28" wx:if="{{currentIndex == 0}}"> | 11 | <view class="type-navbar fs28" wx:if="{{currentIndex == 0}}"> |
| 12 | <view class="type-box flex-center" wx:for="{{categories}}" wx:key="{{index}}"> | 12 | <view class="type-box flex-center" wx:for="{{categories}}" wx:key="{{index}}"> |
| @@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
| 26 | <view class="picker">{{endDate}}</view> | 26 | <view class="picker">{{endDate}}</view> |
| 27 | </picker> | 27 | </picker> |
| 28 | </view> | 28 | </view> |
| 29 | - <view class="search-btn search-btn2" bindtap="search">查询</view> | 29 | + <view class="search-btn search-btn2" bindtap="searchOffline">查询</view> |
| 30 | </view> | 30 | </view> |
| 31 | <view class="fs24 c-9 pdt20">注:读取时段内仅{{total}}笔记录</view> | 31 | <view class="fs24 c-9 pdt20">注:读取时段内仅{{total}}笔记录</view> |
| 32 | </view> | 32 | </view> |