index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <view class="content">
  3. <view class="header" @click="openPrice">
  4. <text >今日回收价格</text>
  5. <view>
  6. <text>查看详情</text>
  7. <u-icon name="arrow-right" color="#4F88F7" size="28"></u-icon>
  8. </view>
  9. <!-- <u-image v-if="hasLogin" @click="openScreen=true" class="filter-img" width="36rpx" height="36rpx" src="/static/filter.png"></u-image> -->
  10. </view>
  11. <!-- 总计 -->
  12. <view class="header-total">
  13. <view class="title">今日统计</view>
  14. <view class="header-cont">
  15. <view class="cont-item">
  16. <text v-if="!titleStatus" >{{otherTotal}}</text>
  17. <text>完成订单数(个)</text>
  18. <u-loading :show="titleStatus"></u-loading>
  19. </view>
  20. <view class="cont-item">
  21. <text v-if="!titleStatus" >{{chuyuTotal}}</text>
  22. <text>回收重量(kg)</text>
  23. <u-loading :show="titleStatus"></u-loading>
  24. </view>
  25. <view class="cont-item">
  26. <text v-if="!titleStatus" >{{jianzhuTotal}}</text>
  27. <text>交易金额(元)</text>
  28. <u-loading :show="titleStatus"></u-loading>
  29. </view>
  30. </view>
  31. </view>
  32. <!-- 接单按钮 -->
  33. <view class="btn-view start-btn">
  34. 点击开始接单
  35. </view>
  36. <!-- 待处理订单 -->
  37. <view class="list">
  38. <view class="title">
  39. <view>待处理订单(10个)</view>
  40. </view>
  41. <view class="list-item" v-for="item in listdata" :key="item.id">
  42. <u-image class="img-icon" :src="item.icon?item.icon:'../../static/logo.jpg'" border-radius="16" width="160" height="160"></u-image>
  43. <view class="cont-item-right flex_1 flex flex_column justify_between">
  44. <view class="flex align_center justify_between">
  45. <view class="flex_1 bold ellipsis-one">{{item.name}}</view>
  46. <view class="do-btn">去处理</view>
  47. </view>
  48. <view class="greey-font flex align_center justify_between">
  49. <view class="dizhi ellipsis-one">{{item.addrDetail}}</view>
  50. <view class="flex align_center">
  51. <view class="t-icon t-icon-icon_coordinate location-icon"></view>
  52. <text>2.9KM</text>
  53. </view>
  54. </view>
  55. <view class="greey-font">2021.05.10 上午,预估50~100kg</view>
  56. <view class="flex">
  57. <view class="mark">
  58. 纸张类
  59. </view>
  60. <view class="mark">
  61. 金属类
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 筛选弹框 -->
  68. <search-modal v-if="openScreen" :visible="openScreen" :defaultParams="searchForm" @refresh="refresh" @close="openScreen=false"></search-modal>
  69. </view>
  70. </template>
  71. <script>
  72. import searchModal from './searchModal.vue'
  73. import {gatherList,gatherTotal} from '@/api/index.js'
  74. import { checkLogin } from '@/api/login.js'
  75. import moment from 'moment'
  76. import getDate from '@/libs/getDate.js'
  77. export default {
  78. components: { searchModal },
  79. data() {
  80. return {
  81. hasLogin: false, // 是否登录
  82. listdata: [
  83. {
  84. name: '百果园(未央路店)',
  85. addrDetail: '西安市未央区凤城八路海圣诞节回复多少积分',
  86. },
  87. {
  88. name: '百果园(未央路店)',
  89. addrDetail: '西安市未央区凤城八路海圣诞节回复多少积分',
  90. }
  91. ], // 列表数据
  92. otherTotal: 0, // 其它垃圾总和
  93. jianzhuTotal: 0, // 建筑垃圾总和
  94. chuyuTotal: 0, // 厨余垃圾总和
  95. pageNo: 1, // 当前页码
  96. pageSize: 10, // 每页条数
  97. total: 0, // 数据总条数
  98. noDataText: '暂无数据', // 列表请求状态提示语
  99. status: 'loadmore', // 加载中状态
  100. titleStatus: false, // 顶部加载中状态
  101. openScreen: false, // 是否打开筛选
  102. searchForm: { // 查询条件
  103. beginDate: getDate.getRecentday().starttime, // 创建时间默认筛选近7天
  104. endDate: getDate.getRecentday().endtime, // 创建时间默认筛选近7天
  105. },
  106. scrollTop: 0, // 滚动条位置
  107. }
  108. },
  109. onLoad() {
  110. this.checkUpdate()
  111. // 开启分享
  112. uni.showShareMenu({
  113. withShareTicket: true,
  114. menus: ['shareAppMessage', 'shareTimeline']
  115. })
  116. },
  117. onUnload() {
  118. },
  119. onShareAppMessage(res) {
  120. },
  121. onShareTimeline(res) {
  122. },
  123. onShow() {
  124. checkLogin().then(res => {
  125. this.hasLogin = res.status == 200
  126. if(this.hasLogin){
  127. this.pageInit()
  128. } else {
  129. this.noDataText = '您尚未登录或登录已过期,完成登录后可查看录入信息!'
  130. }
  131. })
  132. },
  133. methods: {
  134. pageInit() {
  135. this.pageNo = 1
  136. this.pageSize = 10
  137. this.total = 0
  138. this.scrollTop = 0
  139. this.otherTotal= 0 // 其它垃圾总和
  140. this.jianzhuTotal= 0 // 建筑垃圾总和
  141. this.chuyuTotal= 0 // 厨余垃圾总和
  142. this.searchForm.beginDate = getDate.getRecentday().starttime
  143. this.searchForm.endDate = getDate.getRecentday().endtime
  144. console.log(this.searchForm,'this.searchForm')
  145. this.searchHandle()
  146. this.getTotal()
  147. },
  148. // 检查更新
  149. checkUpdate(){
  150. if (uni.canIUse('getUpdateManager')) {
  151. const updateManager = uni.getUpdateManager()
  152. updateManager.onCheckForUpdate(function (res) {
  153. console.log('onCheckForUpdate====', res)
  154. // 请求完新版本信息的回调
  155. if (res.hasUpdate) {
  156. console.log('res.hasUpdate====')
  157. updateManager.onUpdateReady(function () {
  158. uni.showModal({
  159. title: '更新提示',
  160. content: '新版本已经准备好,是否重启应用?',
  161. success: function (res) {
  162. console.log('success====', res)
  163. // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
  164. if (res.confirm) {
  165. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  166. updateManager.applyUpdate()
  167. }
  168. }
  169. })
  170. })
  171. updateManager.onUpdateFailed(function () {
  172. // 新的版本下载失败
  173. uni.showModal({
  174. title: '已经有新版本了哟~',
  175. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  176. })
  177. })
  178. }
  179. })
  180. }
  181. },
  182. // 打开回收价格页面
  183. openPrice(){
  184. uni.navigateTo({
  185. url: '/pages/recoveryPrice/index'
  186. })
  187. // if(this.hasLogin){
  188. // uni.navigateTo({
  189. // url: '/pages/recoveryPrice/index'
  190. // })
  191. // }
  192. },
  193. // 获取查询参数 刷新列表
  194. refresh(params){
  195. this.searchForm = params
  196. this.listdata = []
  197. this.total = 0
  198. this.searchHandle(1)
  199. this.getTotal()
  200. },
  201. // 搜索查询
  202. searchHandle (pageNo) {
  203. this.status = "loading"
  204. pageNo ? this.pageNo = pageNo : null
  205. gatherList({
  206. pageNo: this.pageNo,
  207. pageSize: this.pageSize,
  208. beginDate: this.searchForm.beginDate?moment(this.searchForm.beginDate).format('YYYY-MM-DD 00:00:00'):'',
  209. endDate: this.searchForm.endDate ? moment(this.searchForm.endDate).format('YYYY-MM-DD 23:59:59'):'',
  210. }).then(res => {
  211. if (res.status == 200) {
  212. if(this.pageNo>1){
  213. this.listdata = this.listdata.concat(res.data.list || [])
  214. }else{
  215. this.listdata = res.data.list || []
  216. this.scrollTop = 0
  217. }
  218. this.total = res.data.count || 0
  219. this.noDataText = '暂无数据'
  220. } else {
  221. this.noDataText = res.message
  222. this.listdata = []
  223. this.total = 0
  224. }
  225. this.status = "loadmore"
  226. })
  227. },
  228. // scroll-view到底部加载更多
  229. onreachBottom() {
  230. console.log(111111)
  231. if(this.listdata.length < this.total){
  232. this.pageNo += 1
  233. this.searchHandle()
  234. }else{
  235. uni.showToast({ title: '已经到底了', icon: 'none' })
  236. this.status = "nomore"
  237. }
  238. },
  239. // 总计
  240. getTotal(){
  241. this.titleStatus = true
  242. gatherTotal({
  243. beginDate: this.searchForm.beginDate?moment(this.searchForm.beginDate).format('YYYY-MM-DD 00:00:00'):'',
  244. endDate: this.searchForm.endDate ? moment(this.searchForm.endDate).format('YYYY-MM-DD 23:59:59'):''}).then(res=>{
  245. if(res.status==200){
  246. const a = res.data.find(item=>item.rubbishType=='GATHER_BUILDING')
  247. const b = res.data.find(item=>item.rubbishType=='GATHER_OTHER')
  248. const c = res.data.find(item=>item.rubbishType=='GATHER_KITCHEN')
  249. this.jianzhuTotal= a ? (a.rubbishWeight/1000).toFixed(3)/1 : '0'
  250. this.chuyuTotal= c ? (c.rubbishWeight/1000).toFixed(3)/1 : '0'
  251. this.otherTotal= b ? (b.rubbishWeight/1000).toFixed(3)/1 : '0'
  252. }
  253. console.log(res)
  254. this.titleStatus = false
  255. })
  256. },
  257. // 打开垃圾数据录入页面
  258. intoPage(item) {
  259. const flag=item ? item.gatherId : ''
  260. console.log(flag,'---------hangid,;;;;')
  261. let url = flag ? `/pages/index/addData?id=${flag}` : `/pages/index/addData`
  262. // uni.navigateTo({
  263. // url: url
  264. // })
  265. if(!this.hasLogin){
  266. uni.showModal({
  267. title: '提示',
  268. content: '您尚未登录或登录已过期,请登录后使用',
  269. success: (res)=> {
  270. if (res.confirm) {
  271. uni.navigateTo({
  272. url: '/pages/login/login'
  273. })
  274. } else if (res.cancel) {
  275. console.log('用户点击取消');
  276. }
  277. }
  278. });
  279. } else {
  280. uni.navigateTo({
  281. url: url
  282. })
  283. }
  284. }
  285. }
  286. }
  287. </script>
  288. <style lang="scss" scoped>
  289. .content {
  290. width: 100%;
  291. height: 100vh;
  292. display: flex;
  293. flex-direction: column;
  294. background-color: #fff;
  295. padding: 0 32rpx;
  296. color: #191919;
  297. .header{
  298. width: 100%;
  299. font-size: 36rpx;
  300. display: flex;
  301. justify-content: space-between;
  302. align-items: center;
  303. padding: 16upx 0;
  304. view:last-of-type {
  305. font-size: 32rpx;
  306. color: #4F88F7;
  307. text{
  308. margin-right: 10rpx;
  309. }
  310. }
  311. }
  312. .header-total{
  313. width: 100%;
  314. background: linear-gradient(214deg, #4F88F7 0%, #2D74FE 100%);
  315. border-radius: 24rpx;
  316. color: #fff;
  317. margin: 20rpx 0;
  318. .title {
  319. padding: 18rpx 34rpx;
  320. font-size: 32rpx;
  321. }
  322. }
  323. .header-cont{
  324. display: flex;
  325. align-items: center;
  326. justify-content: space-between;
  327. padding: 20rpx 34rpx;
  328. .cont-item{
  329. display: flex;
  330. flex-direction: column;
  331. align-items: center;
  332. text{
  333. line-height: 50upx;
  334. }
  335. text:last-of-type{
  336. font-size: 24upx;
  337. }
  338. text:first-of-type{
  339. font-size: 48upx;
  340. font-family: Arial;
  341. font-style:italic;
  342. }
  343. }
  344. }
  345. .btn-view{
  346. width: 100%;
  347. height: 100rpx;
  348. border-radius: 24rpx;
  349. text-align: center;
  350. line-height: 100rpx;
  351. font-size: 36rpx;
  352. margin: 20rpx 0;
  353. }
  354. .start-btn{
  355. border: 1px solid #4F88F7;
  356. color: #4F88F7;
  357. }
  358. .end-btn{
  359. border: 1px solid #FF2C5C;
  360. color: #FF2C5C;
  361. }
  362. // item样式
  363. .list{
  364. .title{
  365. padding: 24rpx;
  366. font-size: 36rpx;
  367. }
  368. }
  369. .list-item {
  370. display: flex;
  371. align-items: center;
  372. font-size: 28upx;
  373. .cont-item-right{
  374. padding: 30upx 0upx;
  375. min-height: 220rpx;
  376. margin-left: 20upx;
  377. border-bottom: 1px solid #E5E5E5;
  378. font-size: 34rpx;
  379. color: #222222;
  380. width: 0;
  381. .location-icon{
  382. width: 20rpx;
  383. height: 20rpx;
  384. margin: 0 10rpx;
  385. }
  386. .do-btn{
  387. width: 120rpx;
  388. height: 48rpx;
  389. border: 1px solid #4F88F7;
  390. border-radius: 28rpx;
  391. font-size: 24rpx;
  392. color: #4F88F7;
  393. text-align: center;
  394. line-height: 48rpx;
  395. }
  396. .bold{
  397. font-weight: 600;
  398. }
  399. .greey{
  400. font-size: 28rpx;
  401. color: #424D5E;
  402. }
  403. .greey-font{
  404. font-size: 28rpx;
  405. color: #666666;
  406. line-height: 44rpx;
  407. }
  408. .dizhi{
  409. margin-right: 36rpx;
  410. flex: 1;
  411. line-height: 44rpx;
  412. }
  413. .btn{
  414. width: 132rpx;
  415. height: 52rpx;
  416. background: #FFD100;
  417. opacity: 1;
  418. border-radius: 28rpx;
  419. text-align: center;
  420. line-height: 52rpx;
  421. color: #191919;
  422. font-size: 28rpx;
  423. }
  424. }
  425. &:last-child .cont-item-right {
  426. border-bottom: none;
  427. }
  428. .mark{
  429. padding: 6rpx 16rpx;
  430. border-radius: 12rpx;
  431. font-size: 22rpx;
  432. margin-top: 12rpx;
  433. background-color: #EFEFEF;
  434. color: #666666;
  435. margin-right: 20rpx;
  436. }
  437. .mark-left{
  438. border: 1px solid #BB8415;
  439. color: #BB8415;
  440. margin-right: 20rpx;
  441. }
  442. .mark-right{
  443. border: 1px solid #FF6824;
  444. color: #FF6824;
  445. }
  446. }
  447. }
  448. </style>