index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="content">
  3. <view class="header">
  4. <view @click="openScreen=true">
  5. <text v-if="searchForm.beginDate">{{searchForm.beginDate}} 至 {{searchForm.endDate}}</text>
  6. <text v-else>全部</text>
  7. <u-icon name="arrow-right" color="#9DA8B5" size="30"></u-icon>
  8. <!-- <u-image class="filter-img" width="36rpx" height="36rpx" src="/static/filter.png"></u-image> -->
  9. </view>
  10. <!-- 总计 -->
  11. <view class="header-cont">
  12. 总计:回收重量{{totalWeight}}kg,支出金额{{totalMoney}}元
  13. </view>
  14. </view>
  15. <view class="list-cont">
  16. <view class="item-title">
  17. 详细记录
  18. </view>
  19. <view class="table">
  20. <view>日期</view>
  21. <view>重量(kg)</view>
  22. <view>金额(元)</view>
  23. </view>
  24. <scroll-view class="scroll-con" :scroll-top="scrollTop" scroll-y @scrolltolower="onreachBottom">
  25. <!-- 列表数据 -->
  26. <view class="table item" v-for="item in listdata" :key="item.id">
  27. <view>{{item.reserveFinishDate}}</view>
  28. <view>{{item.totalAllWeight/1000}}</view>
  29. <view>{{item.originalAllAmount}}</view>
  30. </view>
  31. <view class="nodata" v-if="listdata.length==0 && status!='loading'">
  32. <u-empty :text="noDataText" mode="list"></u-empty>
  33. </view>
  34. <view class="loadmore">
  35. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  36. </view>
  37. </scroll-view>
  38. </view>
  39. <!-- 筛选弹框 -->
  40. <search-modal v-if="openScreen" :visible="openScreen" :defaultParams="searchForm" @refresh="refresh" @close="openScreen=false"></search-modal>
  41. </view>
  42. </template>
  43. <script>
  44. import searchModal from './searchModal.vue'
  45. import {recycleOrderReserve,recycleOrderReserveSum} from '@/api/index.js'
  46. import { checkLogin } from '@/api/login.js'
  47. import moment from 'moment'
  48. import getDate from '@/libs/getDate.js'
  49. export default {
  50. components: { searchModal },
  51. data() {
  52. return {
  53. listdata: [], // 列表数据
  54. pageNo: 1, // 当前页码
  55. pageSize: 10, // 每页条数
  56. total: 0, // 数据总条数
  57. noDataText: '暂无数据', // 列表请求状态提示语
  58. status: 'loadmore', // 加载中状态
  59. openScreen: false, // 是否打开筛选
  60. searchForm: { // 查询条件
  61. beginDate: moment().startOf('year').format('YYYY-MM-DD'), // 创建时间默认筛选近7天
  62. endDate: moment().format('YYYY-MM-DD'), // 创建时间默认筛选近7天
  63. },
  64. scrollTop: 0, // 滚动条位置
  65. totalWeight: 0, // 总重量
  66. totalMoney: 0, //总金额
  67. }
  68. },
  69. onLoad() {
  70. this.searchHandle(1)
  71. this.getTotal()
  72. // 开启分享
  73. uni.showShareMenu({
  74. withShareTicket: true,
  75. menus: ['shareAppMessage', 'shareTimeline']
  76. })
  77. },
  78. onShow() {
  79. },
  80. methods: {
  81. // 打开查询弹窗
  82. openSearch(){
  83. if(this.hasLogin){
  84. this.openScreen = true
  85. }
  86. },
  87. // 获取查询参数 刷新列表
  88. refresh(params){
  89. this.searchForm = params
  90. this.listdata = []
  91. this.total = 0
  92. this.searchHandle(1)
  93. this.getTotal()
  94. },
  95. // 搜索查询
  96. searchHandle (pageNo) {
  97. this.status = "loading"
  98. this.pageNo = pageNo ? pageNo : this.pageNo
  99. recycleOrderReserve({
  100. pageNo: this.pageNo,
  101. pageSize: this.pageSize,
  102. beginRecycleDate: this.searchForm.beginDate?moment(this.searchForm.beginDate).format('YYYY-MM-DD 00:00:00'):'',
  103. endRecycleDate: this.searchForm.endDate ? moment(this.searchForm.endDate).format('YYYY-MM-DD 23:59:59'):'',
  104. }).then(res => {
  105. if (res.status == 200) {
  106. if(this.pageNo>1){
  107. this.listdata = this.listdata.concat(res.data.list || [])
  108. }else{
  109. this.listdata = res.data.list || []
  110. this.scrollTop = 0
  111. }
  112. this.total = res.data.count || 0
  113. this.noDataText = '暂无数据'
  114. } else {
  115. this.noDataText = res.message
  116. this.listdata = []
  117. this.total = 0
  118. }
  119. this.status = "loadmore"
  120. })
  121. },
  122. // scroll-view到底部加载更多
  123. onreachBottom() {
  124. console.log(111111)
  125. if(this.listdata.length < this.total){
  126. this.pageNo += 1
  127. this.searchHandle()
  128. }else{
  129. uni.showToast({ title: '已经到底了', icon: 'none' })
  130. this.status = "nomore"
  131. }
  132. },
  133. // 总计
  134. getTotal(){
  135. recycleOrderReserveSum({
  136. beginRecycleDate: this.searchForm.beginDate?moment(this.searchForm.beginDate).format('YYYY-MM-DD 00:00:00'):'',
  137. endRecycleDate: this.searchForm.endDate ? moment(this.searchForm.endDate).format('YYYY-MM-DD 23:59:59'):''}).then(res=>{
  138. if(res.status==200){
  139. this.totalWeight = res.data.totalAllWeight/1000
  140. this.totalMoney = res.data.originalAllAmount
  141. }
  142. console.log(res)
  143. })
  144. },
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. .content {
  150. width: 100%;
  151. height: 100vh;
  152. display: flex;
  153. flex-direction: column;
  154. justify-content: center;
  155. align-items: center;
  156. padding: 0;
  157. .header{
  158. width: 100%;
  159. background-color: #FFFFFF;
  160. display: flex;
  161. flex-direction: column;
  162. margin-bottom: 20upx;
  163. font-size: 30rpx;
  164. color: #191919;
  165. view:first-child {
  166. display: flex;
  167. justify-content: space-between;
  168. align-items: center;
  169. padding: 28rpx 32rpx;
  170. }
  171. .header-cont{
  172. background: rgba(255, 209, 0, 0.4);
  173. padding: 20rpx 32rpx;
  174. }
  175. .filter-img{
  176. padding: 10upx;
  177. }
  178. }
  179. .list-cont{
  180. flex: 1;
  181. width: 100%;
  182. -webkit-box-flex:1;
  183. -webkit-flex:1;
  184. -ms-flex:1;
  185. background-color: #fff;
  186. padding: 0 32rpx;
  187. .item-title{
  188. padding: 28rpx 0rpx;
  189. font-size: 34rpx;
  190. color: #191919;
  191. }
  192. .table{
  193. padding: 20rpx 0;
  194. display: flex;
  195. font-size: 28rpx;
  196. view{
  197. width: 33%;
  198. text-align: center;
  199. }
  200. }
  201. .item{
  202. border-bottom: 1px solid #E5E5E5;
  203. }
  204. }
  205. .scroll-con{
  206. flex: 1;
  207. width: 100%;
  208. -webkit-box-flex:1;
  209. -webkit-flex:1;
  210. -ms-flex:1;
  211. overflow: auto;
  212. .item:last-of-type{
  213. border-bottom: none;
  214. }
  215. }
  216. .footer{
  217. z-index: 9999;
  218. // position: absolute;
  219. // bottom: 30upx;
  220. // margin: 20upx;
  221. width: 95%;
  222. height: 80upx;
  223. background-color: #0DC55F;
  224. opacity: 1;
  225. border-radius: 50upx;
  226. color: #fff;
  227. font-size: 30rpx;
  228. display: flex;
  229. align-items: center;
  230. justify-content: center;
  231. }
  232. }
  233. </style>