index.vue 9.5 KB

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