index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <view class="content">
  3. <view class="header">
  4. <view>
  5. <text v-if="searchForm.beginDate">{{searchForm.beginDate}}至{{searchForm.endDate}}</text>
  6. <text v-else>全部</text>
  7. <u-image v-if="hasLogin" @click="openScreen=true" class="filter-img" width="36rpx" height="36rpx" src="/static/filter.png"></u-image>
  8. </view>
  9. <!-- 总计 -->
  10. <view class="header-cont">
  11. <view class="cont-item">
  12. <text>其它垃圾</text>
  13. <text v-if="!titleStatus" class="other">{{otherTotal}}kg</text>
  14. <u-loading :show="titleStatus"></u-loading>
  15. </view>
  16. <view class="cont-item">
  17. <text>厨余垃圾</text>
  18. <text v-if="!titleStatus" class="chuyu">{{chuyuTotal}}kg</text>
  19. <u-loading :show="titleStatus"></u-loading>
  20. </view>
  21. <view class="cont-item">
  22. <text>建筑垃圾</text>
  23. <text v-if="!titleStatus" class="jianzhu">{{jianzhuTotal}}kg</text>
  24. <u-loading :show="titleStatus"></u-loading>
  25. </view>
  26. </view>
  27. </view>
  28. <scroll-view class="scroll-con" :scroll-top="scrollTop" scroll-y @scrolltolower="onreachBottom">
  29. <!-- 列表数据 -->
  30. <view class="cell-item" v-for="item in listdata">
  31. <view class="cell-item-title" >
  32. <view>
  33. <text>{{item.createDate}}</text>
  34. </view>
  35. <view @click="intoPage(item)">
  36. <span class="view">查看详情</span>
  37. <u-icon name="arrow-right" color="#999999" size="28"></u-icon>
  38. </view>
  39. </view>
  40. <view class="cell-item-cont">
  41. <!-- 其他垃圾 -->
  42. <view class="cont-item">
  43. <u-image src="/static/index/other.png"></u-image>
  44. <text>{{item.gatherOther? (item.gatherOther/1000).toFixed(3)/1 :0}}kg</text>
  45. </view>
  46. <!-- 厨余垃圾 -->
  47. <view class="cont-item">
  48. <u-image src="/static/index/chuyu.png"></u-image>
  49. <text>{{item.gatherKitchen ? (item.gatherKitchen/1000).toFixed(3)/1 :0}}kg</text>
  50. </view>
  51. <!-- 建筑垃圾 -->
  52. <view class="cont-item">
  53. <u-image src="/static/index/jianzhu.png"></u-image>
  54. <text>{{item.gatherBuilding ? (item.gatherBuilding/1000).toFixed(3)/1 :0}}kg</text>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="nodata" v-if="listdata.length==0 && status!='loading'">
  59. <u-empty :text="noDataText" mode="list"></u-empty>
  60. </view>
  61. <view class="loadmore">
  62. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  63. </view>
  64. </scroll-view>
  65. <view @click="intoPage()" class="footer">
  66. <!-- <u-icon name="edit-pen" size="30"></u-icon> -->
  67. <text>垃圾数据录入</text>
  68. </view>
  69. <!-- 筛选弹框 -->
  70. <search-modal v-if="openScreen" :visible="openScreen" :defaultParams="searchForm" @refresh="refresh" @close="openScreen=false"></search-modal>
  71. </view>
  72. </template>
  73. <script>
  74. import searchModal from './searchModal.vue'
  75. import {gatherList,gatherTotal} from '@/api/index.js'
  76. import { checkLogin } from '@/api/login.js'
  77. import moment from 'moment'
  78. import getDate from '@/libs/getDate.js'
  79. export default {
  80. components: { searchModal },
  81. data() {
  82. return {
  83. hasLogin: false, // 是否登录
  84. listdata: [], // 列表数据
  85. otherTotal: 0, // 其它垃圾总和
  86. jianzhuTotal: 0, // 建筑垃圾总和
  87. chuyuTotal: 0, // 厨余垃圾总和
  88. pageNo: 1, // 当前页码
  89. pageSize: 10, // 每页条数
  90. total: 0, // 数据总条数
  91. noDataText: '暂无数据', // 列表请求状态提示语
  92. status: 'loadmore', // 加载中状态
  93. titleStatus: false, // 顶部加载中状态
  94. openScreen: false, // 是否打开筛选
  95. searchForm: { // 查询条件
  96. beginDate: getDate.getRecentday().starttime, // 创建时间默认筛选近7天
  97. endDate: getDate.getRecentday().endtime, // 创建时间默认筛选近7天
  98. },
  99. scrollTop: 0, // 滚动条位置
  100. }
  101. },
  102. onLoad() {
  103. // 开启分享
  104. uni.showShareMenu({
  105. withShareTicket: true,
  106. menus: ['shareAppMessage', 'shareTimeline']
  107. })
  108. },
  109. onUnload() {
  110. },
  111. onShareAppMessage(res) {
  112. },
  113. onShareTimeline(res) {
  114. },
  115. onShow() {
  116. checkLogin().then(res => {
  117. this.hasLogin = res.status == 200
  118. if(this.hasLogin){
  119. this.pageInit()
  120. } else {
  121. this.noDataText = '您尚未登录或登录已过期,完成登录后可查看录入信息!'
  122. }
  123. })
  124. },
  125. methods: {
  126. pageInit() {
  127. this.pageNo = 1
  128. this.pageSize = 10
  129. this.total = 0
  130. this.scrollTop = 0
  131. this.searchForm.beginDate = getDate.getRecentday().starttime
  132. this.searchForm.endDate = getDate.getRecentday().endtime
  133. console.log(this.searchForm,'this.searchForm')
  134. this.searchHandle()
  135. this.getTotal()
  136. },
  137. // 获取查询参数 刷新列表
  138. refresh(params){
  139. this.searchForm = params
  140. this.listdata = []
  141. this.total = 0
  142. this.searchHandle(1)
  143. this.getTotal()
  144. },
  145. // 搜索查询
  146. searchHandle (pageNo) {
  147. this.status = "loading"
  148. pageNo ? this.pageNo = pageNo : null
  149. gatherList({
  150. pageNo: this.pageNo,
  151. pageSize: this.pageSize,
  152. beginDate: this.searchForm.beginDate?moment(this.searchForm.beginDate).format('YYYY-MM-DD 00:00:00'):'',
  153. endDate: this.searchForm.endDate ? moment(this.searchForm.endDate).format('YYYY-MM-DD 23:59:59'):'',
  154. }).then(res => {
  155. if (res.status == 200) {
  156. if(this.pageNo>1){
  157. this.listdata = this.listdata.concat(res.data.list || [])
  158. }else{
  159. this.listdata = res.data.list || []
  160. this.scrollTop = 0
  161. }
  162. this.total = res.data.count || 0
  163. this.noDataText = '暂无数据'
  164. } else {
  165. this.noDataText = res.message
  166. this.listdata = []
  167. this.total = 0
  168. }
  169. this.status = "loadmore"
  170. })
  171. },
  172. // scroll-view到底部加载更多
  173. onreachBottom() {
  174. console.log(111111)
  175. if(this.listdata.length < this.total){
  176. this.pageNo += 1
  177. this.searchHandle()
  178. }else{
  179. uni.showToast({ title: '已经到底了', icon: 'none' })
  180. this.status = "nomore"
  181. }
  182. },
  183. // 总计
  184. getTotal(){
  185. this.titleStatus = true
  186. gatherTotal({
  187. beginDate: this.searchForm.beginDate,
  188. endDate: this.searchForm.endDate}).then(res=>{
  189. if(res.status==200){
  190. this.otherTotal=res.data.GATHER_OTHER ? (res.data.GATHER_OTHER/1000).toFixed(3)/1:0
  191. this.jianzhuTotal=res.data.GATHER_BUILDING ? (res.data.GATHER_BUILDING/1000).toFixed(3)/1:0
  192. this.chuyuTotal=res.data.GATHER_KITCHEN? (res.data.GATHER_KITCHEN/1000).toFixed(3)/1:0
  193. }
  194. console.log(res)
  195. this.titleStatus = false
  196. })
  197. },
  198. // 打开垃圾数据录入页面
  199. intoPage(item) {
  200. const flag=item ? item.gatherId : ''
  201. console.log(flag,'---------hangid,;;;;')
  202. let url = flag ? `/pages/index/addData?id=${flag}` : `/pages/index/addData`
  203. // uni.navigateTo({
  204. // url: url
  205. // })
  206. if(!this.hasLogin){
  207. uni.showModal({
  208. title: '提示',
  209. content: '您尚未登录或登录已过期,请登录后使用',
  210. success: (res)=> {
  211. if (res.confirm) {
  212. uni.navigateTo({
  213. url: '/pages/login/login'
  214. })
  215. } else if (res.cancel) {
  216. console.log('用户点击取消');
  217. }
  218. }
  219. });
  220. } else {
  221. uni.navigateTo({
  222. url: url
  223. })
  224. }
  225. }
  226. }
  227. }
  228. </script>
  229. <style lang="scss" scoped>
  230. .content {
  231. width: 100%;
  232. height: 100vh;
  233. display: flex;
  234. flex-direction: column;
  235. justify-content: center;
  236. align-items: center;
  237. .header{
  238. width: 100%;
  239. background-color: #FFFFFF;
  240. display: flex;
  241. flex-direction: column;
  242. border-radius: 15upx;
  243. padding: 30upx;
  244. box-shadow: 0upx 3upx 6upx #eee;
  245. margin-bottom: 20upx;
  246. :first-child {
  247. display: flex;
  248. justify-content: space-between;
  249. align-items: center;
  250. }
  251. .header-cont{
  252. margin-top: 20upx;
  253. display: flex;
  254. align-items: center;
  255. justify-content: space-around;
  256. .cont-item{
  257. display: flex;
  258. flex-direction: column;
  259. align-items: center;
  260. text{
  261. line-height: 50upx;
  262. }
  263. text:last-child{
  264. font-weight: 600;
  265. font-size: 28upx;
  266. }
  267. }
  268. .other{
  269. color: #FB1E1E;
  270. }
  271. .chuyu{
  272. color: #FCAE53;
  273. }
  274. .jianzhu{
  275. color: #4EACFA;
  276. }
  277. }
  278. .filter-img{
  279. padding: 10upx;
  280. }
  281. }
  282. .scroll-con{
  283. flex: 1;
  284. width: 100%;
  285. -webkit-box-flex:1;
  286. -webkit-flex:1;
  287. -ms-flex:1;
  288. overflow: auto;
  289. .cell-item{
  290. width: 100%;
  291. background-color: #fff;
  292. border-radius: 15upx;
  293. // padding: 20upx;
  294. box-shadow: 0upx 3upx 6upx #eee;
  295. .cell-item-title{
  296. padding: 20upx 20upx 10upx;
  297. width: 100%;
  298. display: flex;
  299. justify-content: space-between;
  300. // border-bottom: 1px solid #e6e6e6;
  301. .view{
  302. color: #999999;
  303. margin-right: 12upx;
  304. }
  305. }
  306. .cell-item-cont{
  307. width: 100%;
  308. display: flex;
  309. justify-content: space-between;
  310. padding: 20upx;
  311. margin-bottom: 20upx;
  312. .cont-item{
  313. display: flex;
  314. flex-direction: column;
  315. align-items: center;
  316. width: 33%;
  317. // border-right: 1px solid #e6e6e6;
  318. :first-child {
  319. width: 120upx;
  320. height: 120upx;
  321. margin-bottom: 20upx;
  322. }
  323. }
  324. :last-child {
  325. border: none;
  326. }
  327. }
  328. }
  329. }
  330. .footer{
  331. z-index: 9999;
  332. // position: absolute;
  333. // bottom: 30upx;
  334. // margin: 20upx;
  335. width: 95%;
  336. height: 80upx;
  337. background-color: #0DC55F;
  338. opacity: 1;
  339. border-radius: 50upx;
  340. color: #fff;
  341. font-size: 30rpx;
  342. display: flex;
  343. align-items: center;
  344. justify-content: center;
  345. }
  346. }
  347. </style>