index.vue 8.2 KB

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