index.vue 9.1 KB

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