index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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 @click="intoWaitOrderDetail()" 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. intoWaitOrderDetail(){
  195. uni.navigateTo({
  196. url: '/pages/order/waitOrderDetail'
  197. })
  198. },
  199. // 获取查询参数 刷新列表
  200. refresh(params){
  201. this.searchForm = params
  202. this.listdata = []
  203. this.total = 0
  204. this.searchHandle(1)
  205. this.getTotal()
  206. },
  207. // 搜索查询
  208. searchHandle (pageNo) {
  209. this.status = "loading"
  210. pageNo ? this.pageNo = pageNo : null
  211. gatherList({
  212. pageNo: this.pageNo,
  213. pageSize: this.pageSize,
  214. beginDate: this.searchForm.beginDate?moment(this.searchForm.beginDate).format('YYYY-MM-DD 00:00:00'):'',
  215. endDate: this.searchForm.endDate ? moment(this.searchForm.endDate).format('YYYY-MM-DD 23:59:59'):'',
  216. }).then(res => {
  217. if (res.status == 200) {
  218. if(this.pageNo>1){
  219. this.listdata = this.listdata.concat(res.data.list || [])
  220. }else{
  221. this.listdata = res.data.list || []
  222. this.scrollTop = 0
  223. }
  224. this.total = res.data.count || 0
  225. this.noDataText = '暂无数据'
  226. } else {
  227. this.noDataText = res.message
  228. this.listdata = []
  229. this.total = 0
  230. }
  231. this.status = "loadmore"
  232. })
  233. },
  234. // scroll-view到底部加载更多
  235. onreachBottom() {
  236. console.log(111111)
  237. if(this.listdata.length < this.total){
  238. this.pageNo += 1
  239. this.searchHandle()
  240. }else{
  241. uni.showToast({ title: '已经到底了', icon: 'none' })
  242. this.status = "nomore"
  243. }
  244. },
  245. // 总计
  246. getTotal(){
  247. this.titleStatus = true
  248. gatherTotal({
  249. beginDate: this.searchForm.beginDate?moment(this.searchForm.beginDate).format('YYYY-MM-DD 00:00:00'):'',
  250. endDate: this.searchForm.endDate ? moment(this.searchForm.endDate).format('YYYY-MM-DD 23:59:59'):''}).then(res=>{
  251. if(res.status==200){
  252. const a = res.data.find(item=>item.rubbishType=='GATHER_BUILDING')
  253. const b = res.data.find(item=>item.rubbishType=='GATHER_OTHER')
  254. const c = res.data.find(item=>item.rubbishType=='GATHER_KITCHEN')
  255. this.jianzhuTotal= a ? (a.rubbishWeight/1000).toFixed(3)/1 : '0'
  256. this.chuyuTotal= c ? (c.rubbishWeight/1000).toFixed(3)/1 : '0'
  257. this.otherTotal= b ? (b.rubbishWeight/1000).toFixed(3)/1 : '0'
  258. }
  259. console.log(res)
  260. this.titleStatus = false
  261. })
  262. },
  263. // 打开垃圾数据录入页面
  264. intoPage(item) {
  265. uni.navigateTo({
  266. url: url
  267. })
  268. if(!this.hasLogin){
  269. uni.showModal({
  270. title: '提示',
  271. content: '您尚未登录或登录已过期,请登录后使用',
  272. success: (res)=> {
  273. if (res.confirm) {
  274. uni.navigateTo({
  275. url: '/pages/login/login'
  276. })
  277. } else if (res.cancel) {
  278. console.log('用户点击取消');
  279. }
  280. }
  281. });
  282. } else {
  283. uni.navigateTo({
  284. url: url
  285. })
  286. }
  287. }
  288. }
  289. }
  290. </script>
  291. <style lang="scss" scoped>
  292. .content {
  293. width: 100%;
  294. height: 100vh;
  295. display: flex;
  296. flex-direction: column;
  297. background-color: #fff;
  298. padding: 0 32rpx;
  299. color: #191919;
  300. .header{
  301. width: 100%;
  302. font-size: 36rpx;
  303. display: flex;
  304. justify-content: space-between;
  305. align-items: center;
  306. padding: 16upx 0;
  307. view:last-of-type {
  308. font-size: 32rpx;
  309. color: #4F88F7;
  310. text{
  311. margin-right: 10rpx;
  312. }
  313. }
  314. }
  315. .header-total{
  316. width: 100%;
  317. background: linear-gradient(214deg, #4F88F7 0%, #2D74FE 100%);
  318. border-radius: 24rpx;
  319. color: #fff;
  320. margin: 20rpx 0;
  321. .title {
  322. padding: 18rpx 34rpx;
  323. font-size: 32rpx;
  324. }
  325. }
  326. .header-cont{
  327. display: flex;
  328. align-items: center;
  329. justify-content: space-between;
  330. padding: 20rpx 34rpx;
  331. .cont-item{
  332. display: flex;
  333. flex-direction: column;
  334. align-items: center;
  335. text{
  336. line-height: 50upx;
  337. }
  338. text:last-of-type{
  339. font-size: 24upx;
  340. }
  341. text:first-of-type{
  342. font-size: 48upx;
  343. font-family: Arial;
  344. font-style:italic;
  345. }
  346. }
  347. }
  348. .btn-view{
  349. width: 100%;
  350. height: 100rpx;
  351. border-radius: 24rpx;
  352. text-align: center;
  353. line-height: 100rpx;
  354. font-size: 36rpx;
  355. margin: 20rpx 0;
  356. }
  357. .start-btn{
  358. border: 1px solid #4F88F7;
  359. color: #4F88F7;
  360. }
  361. .end-btn{
  362. border: 1px solid #FF2C5C;
  363. color: #FF2C5C;
  364. }
  365. // item样式
  366. .list{
  367. .title{
  368. padding: 24rpx;
  369. font-size: 36rpx;
  370. }
  371. }
  372. .list-item {
  373. display: flex;
  374. align-items: center;
  375. font-size: 28upx;
  376. .cont-item-right{
  377. padding: 30upx 0upx;
  378. min-height: 220rpx;
  379. margin-left: 20upx;
  380. border-bottom: 1px solid #E5E5E5;
  381. font-size: 34rpx;
  382. color: #222222;
  383. width: 0;
  384. .location-icon{
  385. width: 20rpx;
  386. height: 20rpx;
  387. margin: 0 10rpx;
  388. }
  389. .do-btn{
  390. width: 120rpx;
  391. height: 48rpx;
  392. border: 1px solid #4F88F7;
  393. border-radius: 28rpx;
  394. font-size: 24rpx;
  395. color: #4F88F7;
  396. text-align: center;
  397. line-height: 48rpx;
  398. }
  399. .bold{
  400. font-weight: 600;
  401. }
  402. .greey{
  403. font-size: 28rpx;
  404. color: #424D5E;
  405. }
  406. .greey-font{
  407. font-size: 28rpx;
  408. color: #666666;
  409. line-height: 44rpx;
  410. }
  411. .dizhi{
  412. margin-right: 36rpx;
  413. flex: 1;
  414. line-height: 44rpx;
  415. }
  416. .btn{
  417. width: 132rpx;
  418. height: 52rpx;
  419. background: #FFD100;
  420. opacity: 1;
  421. border-radius: 28rpx;
  422. text-align: center;
  423. line-height: 52rpx;
  424. color: #191919;
  425. font-size: 28rpx;
  426. }
  427. }
  428. &:last-child .cont-item-right {
  429. border-bottom: none;
  430. }
  431. .mark{
  432. padding: 6rpx 16rpx;
  433. border-radius: 12rpx;
  434. font-size: 22rpx;
  435. margin-top: 12rpx;
  436. background-color: #EFEFEF;
  437. color: #666666;
  438. margin-right: 20rpx;
  439. }
  440. .mark-left{
  441. border: 1px solid #BB8415;
  442. color: #BB8415;
  443. margin-right: 20rpx;
  444. }
  445. .mark-right{
  446. border: 1px solid #FF6824;
  447. color: #FF6824;
  448. }
  449. }
  450. }
  451. </style>