index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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 || 0}}</view>
  29. <view>{{item.originalAllAmount || 0}}</view>
  30. </view>
  31. <view class="nodata" v-if="listdata.length==0 && status!='loading'">
  32. <u-empty src="/static/def_result.png" :text="noDataText" icon-size="260"></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.totalWeight = 0
  92. this.totalMoney = 0
  93. this.searchHandle(1)
  94. this.getTotal()
  95. },
  96. // 搜索查询
  97. searchHandle (pageNo) {
  98. this.status = "loading"
  99. this.pageNo = pageNo ? pageNo : this.pageNo
  100. recycleOrderReserve({
  101. pageNo: this.pageNo,
  102. pageSize: this.pageSize,
  103. beginRecycleDate: this.searchForm.beginDate?moment(this.searchForm.beginDate).format('YYYY-MM-DD 00:00:00'):'',
  104. endRecycleDate: this.searchForm.endDate ? moment(this.searchForm.endDate).format('YYYY-MM-DD 23:59:59'):'',
  105. }).then(res => {
  106. if (res.status == 200) {
  107. if(this.pageNo>1){
  108. this.listdata = this.listdata.concat(res.data.list || [])
  109. }else{
  110. this.listdata = res.data.list || []
  111. this.scrollTop = 0
  112. }
  113. this.total = res.data.count || 0
  114. this.noDataText = '暂无数据'
  115. } else {
  116. this.noDataText = res.message
  117. this.listdata = []
  118. this.total = 0
  119. }
  120. this.status = "loadmore"
  121. })
  122. },
  123. // scroll-view到底部加载更多
  124. onreachBottom() {
  125. console.log(111111)
  126. if(this.listdata.length < this.total){
  127. this.pageNo += 1
  128. this.searchHandle()
  129. }else{
  130. uni.showToast({ title: '已经到底了', icon: 'none' })
  131. this.status = "nomore"
  132. }
  133. },
  134. // 总计
  135. getTotal(){
  136. recycleOrderReserveSum({
  137. beginRecycleDate: this.searchForm.beginDate?moment(this.searchForm.beginDate).format('YYYY-MM-DD 00:00:00'):'',
  138. endRecycleDate: this.searchForm.endDate ? moment(this.searchForm.endDate).format('YYYY-MM-DD 23:59:59'):''}).then(res=>{
  139. if(res.status==200 && res.data){
  140. this.totalWeight = res.data.totalAllWeight/1000 || 0
  141. this.totalMoney = res.data.originalAllAmount || 0
  142. } else {
  143. this.totalWeight = 0
  144. this.totalMoney = 0
  145. }
  146. console.log(res)
  147. })
  148. },
  149. }
  150. }
  151. </script>
  152. <style lang="scss" scoped>
  153. .content {
  154. width: 100%;
  155. height: 100vh;
  156. display: flex;
  157. flex-direction: column;
  158. justify-content: center;
  159. align-items: center;
  160. padding: 0;
  161. .header{
  162. width: 100%;
  163. background-color: #FFFFFF;
  164. display: flex;
  165. flex-direction: column;
  166. margin-bottom: 20upx;
  167. font-size: 30rpx;
  168. color: #191919;
  169. view:first-child {
  170. display: flex;
  171. justify-content: space-between;
  172. align-items: center;
  173. padding: 28rpx 32rpx;
  174. }
  175. .header-cont{
  176. background: rgba(255, 209, 0, 0.4);
  177. padding: 20rpx 32rpx;
  178. }
  179. .filter-img{
  180. padding: 10upx;
  181. }
  182. }
  183. .list-cont{
  184. flex: 1;
  185. width: 100%;
  186. -webkit-box-flex:1;
  187. -webkit-flex:1;
  188. -ms-flex:1;
  189. background-color: #fff;
  190. padding: 0 32rpx;
  191. .item-title{
  192. padding: 28rpx 0rpx;
  193. font-size: 34rpx;
  194. color: #191919;
  195. }
  196. .table{
  197. padding: 20rpx 0;
  198. display: flex;
  199. font-size: 28rpx;
  200. view{
  201. width: 33%;
  202. text-align: center;
  203. }
  204. }
  205. .item{
  206. border-bottom: 1px solid #E5E5E5;
  207. }
  208. }
  209. .scroll-con{
  210. flex: 1;
  211. width: 100%;
  212. -webkit-box-flex:1;
  213. -webkit-flex:1;
  214. -ms-flex:1;
  215. overflow: auto;
  216. .item:last-of-type{
  217. border-bottom: none;
  218. }
  219. .nodata{
  220. padding-top: 120rpx;
  221. }
  222. }
  223. .footer{
  224. width: 95%;
  225. height: 80upx;
  226. background-color: #0DC55F;
  227. opacity: 1;
  228. border-radius: 50upx;
  229. color: #fff;
  230. font-size: 30rpx;
  231. display: flex;
  232. align-items: center;
  233. justify-content: center;
  234. }
  235. }
  236. </style>