patrol_record.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <view class="page-container">
  3. <view class="search-wrapper">
  4. <view class="query">
  5. <u-row customStyle="margin-bottom: 10px" gutter="20">
  6. <u-col span="9">
  7. <u--input
  8. @focus="timeShow = true"
  9. v-model="startTimeXd"
  10. placeholder="开始日期 ~ 结束日期"
  11. prefixIcon="calendar"
  12. prefixIconStyle="font-size: 22px;color: #909399"
  13. @input="handleSearch"
  14. @change="change"
  15. ></u--input>
  16. </u-col>
  17. <u-col span="3">
  18. <view class="query-btn" @click="show = !show">
  19. <view class="query-btn-icon">
  20. </view>
  21. <view class="query-btn-text">筛选</view>
  22. </view>
  23. </u-col>
  24. </u-row>
  25. </view>
  26. </view>
  27. <scroll-view class="list-container" scroll-y="true" @scrolltolower="loadMore">
  28. <view v-if="recordList.length === 0 && loadStatus !== 'loading'" class="empty-list">
  29. <text>暂无上货记录</text>
  30. </view>
  31. <view @click="detail(record.id)" v-for="record in recordList" :key="record.id" class="record-card">
  32. <view class="card-decorator"></view>
  33. <view class="card-content">
  34. <view class="card-header">
  35. <uni-icons type="shop-filled" size="20" color="#3c82f8"></uni-icons>
  36. <text class="record-id">{{ record.storeName }}</text>
  37. </view>
  38. <view class="details-section">
  39. <view class="detail-row">
  40. <text class="detail-label">巡店时间</text>
  41. <text class="detail-value">{{ record.getTime }}</text>
  42. </view>
  43. <view class="detail-row">
  44. <text class="detail-label">上货奖励</text>
  45. <text class="detail-value reward">{{ record.point==null?"0":record.point }}积分</text>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <uni-load-more :status="loadStatus"></uni-load-more>
  51. </scroll-view>
  52. <u-popup :show="show" mode="bottom" @close="show = false" >
  53. <view class="popup-content">
  54. <view class="popup-text">筛选</view>
  55. <u-row customStyle="margin-bottom: 10px">
  56. <u-col span="3">
  57. <view class="explain">选择日期</view>
  58. </u-col>
  59. <u-col span="9">
  60. <u--input
  61. v-model="startTimeXd"
  62. placeholder="开始日期 ~ 结束日期"
  63. prefixIcon="calendar"
  64. prefixIconStyle="font-size: 22px;color: #909399"
  65. @focus="timeShow = true"
  66. ></u--input>
  67. </u-col>
  68. </u-row>
  69. <u-row customStyle="margin-bottom: 10px">
  70. <u-col span="3">
  71. <view class="explain">门店名称</view>
  72. </u-col>
  73. <u-col span="9">
  74. <u--input v-model="searchQuery"
  75. placeholder="请输入内容"
  76. border="surround"
  77. ></u--input>
  78. </u-col>
  79. </u-row>
  80. <view class="popup-btn">
  81. <u-button @click="handleSearch" class="popup-btn-one">搜索</u-button>
  82. <u-button @click="resetForm" class="popup-btn-one" type="primary">重置</u-button>
  83. </view>
  84. </view>
  85. </u-popup>
  86. <u-calendar @close="timeShow = false" :show="timeShow" :mode="mode" @confirm="confirm"></u-calendar>
  87. </view>
  88. </template>
  89. <script>
  90. import {xundianRecord} from "@/api/hexiao";
  91. export default {
  92. data() {
  93. return {
  94. startTime: '',
  95. endTime: '',
  96. timeShow: false,
  97. startTimeXd:"",
  98. mode: 'range',
  99. show:false,
  100. searchQuery: '',
  101. recordList: [],
  102. ywyId:0,
  103. pagination: {
  104. page: 1,
  105. limit: 10,
  106. },
  107. loadStatus: 'more', // 'more'-加载前, 'loading'-加载中, 'noMore'-没有更多了
  108. isLoading: false,
  109. };
  110. },
  111. onLoad(opt) {
  112. // 页面加载时获取第一页数据
  113. if(opt.id){
  114. this.ywyId = opt.id
  115. }
  116. this.fetchRecords(true);
  117. },
  118. // 监听下拉刷新
  119. onPullDownRefresh() {
  120. this.fetchRecords(true);
  121. },
  122. methods: {
  123. detail(id){
  124. uni.navigateTo({ url: `/pages/cjx/hexiao/ywy/patrol_detail?id=`+id });
  125. },
  126. // 核心:获取记录列表数据
  127. async fetchRecords(isRefresh = false) {
  128. if (this.isLoading || (this.loadStatus === 'noMore' && !isRefresh)) {
  129. return;
  130. }
  131. if (isRefresh) {
  132. this.pagination.page = 1;
  133. this.recordList = [];
  134. this.loadStatus = 'more';
  135. }
  136. this.isLoading = true;
  137. this.loadStatus = 'loading';
  138. // 在这里替换成您真实的 uni.request API 调用
  139. console.log(`正在请求第 ${this.pagination.page} 页数据...`);
  140. let data = {
  141. pageIndex:this.pagination.page,
  142. pageSize:this.pagination.limit,
  143. storeName:this.searchQuery,
  144. startTime:this.startTime,
  145. endTime:this.endTime
  146. };
  147. if(this.ywyId>0){
  148. data.ywyId = this.ywyId
  149. }
  150. xundianRecord(data).then(res=>{
  151. let mockData = res.data.records;
  152. if (mockData.length > 0) {
  153. this.recordList = [...this.recordList, ...mockData];
  154. this.pagination.page++;
  155. this.loadStatus = 'more';
  156. } else {
  157. this.loadStatus = 'noMore';
  158. }
  159. this.isLoading = false;
  160. uni.stopPullDownRefresh(); // 停止下拉刷新动画
  161. });
  162. // --- [模拟API请求结束] ---
  163. },
  164. resetForm(){
  165. this.searchQuery = "";
  166. this.startTime = "";
  167. this.endTime = "";
  168. this.startTimeXd = "";
  169. },
  170. confirm(e) {
  171. this.startTime = e[0];
  172. this.endTime = e[e.length-1];
  173. this.startTimeXd = e[0]+' ~ '+e[e.length-1];
  174. if(!this.show){
  175. this.handleSearch()
  176. }
  177. this.timeShow = false;
  178. },
  179. // 上拉加载更多
  180. loadMore() {
  181. this.fetchRecords();
  182. },
  183. // 搜索
  184. handleSearch() {
  185. // 在实际项目中,搜索应该调用API,这里为简单起见只做前端筛选
  186. this.fetchRecords(true);
  187. }
  188. }
  189. }
  190. </script>
  191. <style lang="scss" scoped>
  192. .page-container {
  193. display: flex;
  194. flex-direction: column;
  195. height: 100vh;
  196. background-color: #f5f6fa;
  197. }
  198. .search-wrapper {
  199. padding: 20rpx;
  200. background-color: #ffffff;
  201. border-bottom: 1rpx solid #f0f0f0;
  202. }
  203. .search-bar {
  204. display: flex;
  205. align-items: center;
  206. background-color: #f5f6fa;
  207. border-radius: 50rpx;
  208. padding: 0 25rpx;
  209. height: 70rpx;
  210. }
  211. .search-input {
  212. flex: 1;
  213. font-size: 28rpx;
  214. margin-left: 15rpx;
  215. }
  216. .placeholder {
  217. color: #b0b0b0;
  218. }
  219. .list-container {
  220. flex: 1;
  221. height: 100%; // 必须给scroll-view一个明确的高度
  222. }
  223. .empty-list {
  224. text-align: center;
  225. color: #999;
  226. padding-top: 150rpx;
  227. }
  228. .record-card {
  229. background-color: #ffffff;
  230. border-radius: 16rpx;
  231. margin: 20rpx;
  232. position: relative;
  233. overflow: hidden;
  234. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  235. }
  236. .card-decorator {
  237. position: absolute;
  238. left: 0;
  239. top: 0;
  240. bottom: 0;
  241. width: 8rpx;
  242. background-color: #e3efff;
  243. }
  244. .card-content {
  245. padding: 30rpx;
  246. padding-left: 40rpx;
  247. }
  248. .card-header {
  249. display: flex;
  250. align-items: center;
  251. padding-bottom: 20rpx;
  252. border-bottom: 1rpx solid #f5f5f5;
  253. .record-id {
  254. font-size: 30rpx;
  255. font-weight: bold;
  256. color: #333;
  257. margin-left: 15rpx;
  258. }
  259. }
  260. .details-section {
  261. padding-top: 10rpx;
  262. }
  263. .detail-row {
  264. display: flex;
  265. justify-content: space-between;
  266. align-items: center;
  267. padding: 15rpx 0;
  268. font-size: 28rpx;
  269. .detail-label {
  270. color: #666;
  271. }
  272. .detail-value {
  273. color: #333;
  274. }
  275. &.product-item .detail-label {
  276. color: #333; // 商品名称颜色深一些
  277. font-weight: 400;
  278. }
  279. .reward {
  280. color: #ff9900;
  281. font-weight: 500;
  282. }
  283. }
  284. .query-btn {
  285. background-color: #409eff;
  286. color: #fff;
  287. padding: 20rpx;
  288. border-radius: 10rpx;
  289. height: 34rpx;
  290. display: flex;
  291. justify-content: center;
  292. align-items: center;
  293. }
  294. .query-btn-icon {
  295. height: 32rpx;
  296. width: 32rpx;
  297. background-image:
  298. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/queryIoc.png");
  299. background-size: cover;
  300. background-position: center;
  301. background-repeat: no-repeat;
  302. }
  303. .query-btn-text {
  304. font-weight: 400;
  305. font-size: 30rpx;
  306. color: #F5F5F5;
  307. }
  308. .popup-content{
  309. height: 25vh;
  310. padding: 10px;
  311. }
  312. .popup-text{
  313. font-family: PingFang SC;
  314. font-weight: bold;
  315. font-size: 36rpx;
  316. color: #1C1E1D;
  317. text-align: center;
  318. margin-bottom: 10px;
  319. }
  320. .popup-btn{
  321. display: flex;
  322. justify-content: space-around;
  323. }
  324. .popup-btn-one{
  325. width: 275rpx;
  326. height: 70rpx;
  327. background: linear-gradient(0deg, #6FA4FE, #488CFF);
  328. box-shadow: 0rpx 9rpx 16rpx 0rpx rgba(153,153,153,0.35);
  329. border-radius: 35rpx;
  330. }
  331. </style>