index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  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>{{numTotal}}</text>
  17. <view>完成订单数(个)</view>
  18. </view>
  19. <view class="cont-item">
  20. <text>{{weightTotal}}</text>
  21. <view>回收重量(kg)</view>
  22. </view>
  23. <view class="cont-item">
  24. <text>{{moneyTotal}}</text>
  25. <view>交易金额(元)</view>
  26. </view>
  27. </view>
  28. </view>
  29. <!-- 接单按钮 -->
  30. <view v-show="workStatus==0 && hasLogin" @click="changeWorkStateFun(1)" class="btn-view start-btn">
  31. 点击开始接单
  32. </view>
  33. <view v-show="workStatus==1 && hasLogin" @click="changeWorkStateFun(0)" class="btn-view end-btn">
  34. 接单中(点击停止接单)
  35. </view>
  36. <!-- 待处理订单 -->
  37. <view class="list">
  38. <view v-if="hasLogin" class="title">
  39. <view>待处理订单({{listdata.length}}个)</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.imageHeader:'/static/def_home_shop.png'"
  43. border-radius="16" width="160" height="160"></u-image>
  44. <view @click="intoWaitOrderDetail(item)"
  45. class="cont-item-right flex_1 flex flex_column justify_between">
  46. <view class="flex align_center justify_between">
  47. <view class="flex_1 bold ellipsis-one">{{item.customerName||'--'}}</view>
  48. <view class="do-btn">去处理</view>
  49. </view>
  50. <view class="greey-font flex align_center justify_between">
  51. <view class="greey-font">{{item.createDate}}</view>
  52. <view v-if="item.distance" @click.stop="openLocation(item)" class="flex align_center">
  53. <u-icon class="icon" name="icon_coordinate1" custom-prefix="custom-icon" size="20"
  54. color="#999999"></u-icon>
  55. <text>{{item.distance}}KM</text>
  56. </view>
  57. </view>
  58. <view class="greey-font">{{item.address? item.address:'--'}}</view>
  59. <!-- <view class="greey-font">{{item.reserveTime}}</view>
  60. <view class="type">
  61. <text v-for="(key,index) in item.reserveTypeList" :key="index" class="mark">
  62. {{key}}
  63. </text>
  64. </view> -->
  65. </view>
  66. </view>
  67. <view class="nodata" v-if="listdata.length==0 && status!='loading'">
  68. <u-empty src="/static/def_result.png" :text="noDataText" icon-size="260"></u-empty>
  69. </view>
  70. <view class="loadmore">
  71. <u-loadmore v-if="status=='loading'" :status="status" />
  72. </view>
  73. </view>
  74. <!-- 取消接单弹窗 -->
  75. <uni-popup ref="openModal" type="center">
  76. <uni-popup-dialog content="您确定要停止接单吗?" @confirm="onOk" title="温馨提示"></uni-popup-dialog>
  77. </uni-popup>
  78. <!-- 筛选弹框 -->
  79. <search-modal v-if="openScreen" :visible="openScreen" :defaultParams="searchForm" @refresh="refresh"
  80. @close="openScreen=false"></search-modal>
  81. </view>
  82. </template>
  83. <script>
  84. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  85. import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
  86. import {
  87. waitOrderQuery,
  88. reserveTotal,
  89. changeWorkState,
  90. WorkStatusGet
  91. } from '@/api/index.js'
  92. import {
  93. checkLogin
  94. } from '@/api/login.js'
  95. import moment from 'moment'
  96. import getDate from '@/libs/getDate.js'
  97. export default {
  98. components: {
  99. uniPopup,
  100. uniPopupDialog
  101. },
  102. data() {
  103. return {
  104. hasLogin: false, // 是否登录
  105. listdata: [], // 列表数据
  106. noDataText: '暂无数据', // 列表请求状态提示语
  107. status: 'loading', // 加载中状态
  108. titleStatus: false, // 顶部加载中状态
  109. scrollTop: 0, // 滚动条位置
  110. numTotal: 0, // 完成订单个数
  111. weightTotal: 0, // 回收重量
  112. moneyTotal: 0, // 交易金额
  113. workStatus: '0', // 工作状态 0 不接单 1接单
  114. }
  115. },
  116. onLoad() {
  117. this.checkUpdate()
  118. // 获取当前经纬度
  119. // this.getCurPosition()
  120. // 开启分享
  121. uni.showShareMenu({
  122. withShareTicket: true,
  123. menus: ['shareAppMessage', 'shareTimeline']
  124. })
  125. },
  126. onUnload() {
  127. },
  128. onShareAppMessage(res) {},
  129. onShareTimeline(res) {},
  130. onShow() {
  131. this.status = 'loading'
  132. checkLogin().then(res => {
  133. this.hasLogin = res.status == 200
  134. if (this.hasLogin) {
  135. this.getCurPosition()
  136. this.getTotalData()
  137. this.getWorkStatus()
  138. } else {
  139. this.noDataText = '您尚未登录或登录已过期!'
  140. this.status = 'loadmore'
  141. }
  142. })
  143. },
  144. methods: {
  145. // 检查更新
  146. checkUpdate() {
  147. if (uni.canIUse('getUpdateManager')) {
  148. const updateManager = uni.getUpdateManager()
  149. updateManager.onCheckForUpdate(function(res) {
  150. console.log('onCheckForUpdate====', res)
  151. // 请求完新版本信息的回调
  152. if (res.hasUpdate) {
  153. console.log('res.hasUpdate====')
  154. updateManager.onUpdateReady(function() {
  155. uni.showModal({
  156. title: '更新提示',
  157. content: '新版本已经准备好,是否重启应用?',
  158. success: function(res) {
  159. console.log('success====', res)
  160. // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
  161. if (res.confirm) {
  162. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  163. updateManager.applyUpdate()
  164. }
  165. }
  166. })
  167. })
  168. updateManager.onUpdateFailed(function() {
  169. // 新的版本下载失败
  170. uni.showModal({
  171. title: '已经有新版本了哟~',
  172. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  173. })
  174. })
  175. }
  176. })
  177. }
  178. },
  179. // 获取骑手状态
  180. getWorkStatus() {
  181. WorkStatusGet().then(res => {
  182. if (res.status == 200) {
  183. this.workStatus = res.data[0].workStatus
  184. }
  185. })
  186. },
  187. // 获取当前位置
  188. getCurPosition() {
  189. let _this = this
  190. uni.authorize({
  191. scope: 'scope.userLocation',
  192. success: () => {
  193. console.log(1111111111)
  194. uni.getLocation({
  195. type: 'wgs84', // 默认wgs84
  196. success: function(res) {
  197. console.log(res, '------')
  198. let lat = res.latitude
  199. let lng = res.longitude
  200. // 查询订单信息
  201. _this.getList(lat, lng)
  202. },
  203. fail: function(res) {
  204. console.log(res)
  205. // 查询订单信息
  206. _this.getList()
  207. }
  208. });
  209. },
  210. fail() {
  211. uni.getSetting({
  212. success(res) {
  213. console.log(res.authSetting, 'gggggggggg')
  214. if (!res.authSetting['scope.userLocation']) {
  215. uni.showModal({
  216. title: '提示',
  217. content: '无法展示用户距离,请开启定位功能!',
  218. success: (res) => {
  219. if (res.confirm) {
  220. uni.openSetting({
  221. success(res) {
  222. console.log(res.authSetting,
  223. 'res.authSetting')
  224. },
  225. fail(err) {
  226. console.log(err, 'eeeeeeeee')
  227. }
  228. })
  229. } else if (res.cancel) {
  230. console.log('用户点击取消');
  231. _this.getList()
  232. }
  233. }
  234. });
  235. }
  236. },
  237. fail() {
  238. _this.getList()
  239. }
  240. })
  241. }
  242. })
  243. },
  244. // 截取市以下的地址
  245. getArea(obj,state) {
  246. var index=obj.lastIndexOf("\市");
  247. if(state==0){
  248. obj=obj.substring(0,index);
  249. }else {
  250. obj=obj.substring(index+1,obj.length);
  251. }
  252. return obj;
  253. },
  254. // 待处理订单信息
  255. getList(lat, lng) {
  256. // uni.showLoading({
  257. // title: '加载中...'
  258. // })
  259. waitOrderQuery({
  260. handleUserLng: lng,
  261. handleUserLat: lat
  262. }).then(res => {
  263. console.log(res)
  264. if (res.status == 200) {
  265. this.listdata = res.data
  266. this.listdata.forEach(item => {
  267. item.distance = item.distanct && item.distanct.distance ? (item.distanct
  268. .distance / 1000).toFixed(2) : ''
  269. // item.reserveTime = moment(item.reserveDateBegin).format('YYYY-MM-DD') + item
  270. // .reserveTimeTypeDictValue
  271. // item.reserveTypeList = item.reserveRubbishType.split(',')
  272. if(item.contactAddress){
  273. item.cityAddress=this.getArea(item.contactAddress,1)
  274. }
  275. console.log(item.cityAddress,'-----------item.cityAddress=============')
  276. item.address=(item.houseAddress? item.houseAddress:'')+(item.cityAddress? '('+item.cityAddress+')':'')
  277. })
  278. this.noDataText = '暂无数据'
  279. } else {
  280. this.noDataText = res.message
  281. }
  282. this.status = 'loadmore'
  283. uni.hideLoading()
  284. })
  285. },
  286. // 今日统计
  287. getTotalData() {
  288. this.titleStatus = true
  289. reserveTotal({}).then(res => {
  290. if (res.status == 200 && res.data) {
  291. this.numTotal = res.data.orderReserveCount || 0
  292. this.weightTotal = res.data.totalWeight / 1000 || 0
  293. this.moneyTotal = res.data.originalAmount || 0
  294. } else {
  295. this.numTotal = 0
  296. this.weightTotal = 0
  297. this.moneyTotal = 0
  298. }
  299. this.titleStatus = false
  300. })
  301. },
  302. // 打开回收价格页面
  303. openPrice() {
  304. if(this.hasLogin){
  305. uni.navigateTo({
  306. url: '/pages/recoveryPrice/index'
  307. })
  308. }else{
  309. this.loginModal()
  310. }
  311. },
  312. // 进入待处理订单详情
  313. intoWaitOrderDetail(item) {
  314. uni.navigateTo({
  315. url: '/pages/order/waitOrderDetail?orderNo=' + item.orderReserveNo
  316. })
  317. },
  318. // 导航
  319. openLocation(item) {
  320. uni.openLocation({
  321. latitude: item.lat - 0,
  322. longitude: item.lng - 0,
  323. name: item.name,
  324. address: item.contactAddress
  325. });
  326. },
  327. // 未登录弹窗
  328. loginModal() {
  329. uni.showModal({
  330. title: '提示',
  331. content: '您尚未登录或登录已过期,请登录后使用',
  332. success: (res) => {
  333. if (res.confirm) {
  334. uni.navigateTo({
  335. url: '/pages/login/login'
  336. })
  337. } else if (res.cancel) {
  338. console.log('用户点击取消');
  339. }
  340. }
  341. });
  342. },
  343. // 点击开始或停止接单
  344. changeWorkStateFun(flag) {
  345. if (flag == 0) {
  346. console.log(flag)
  347. this.$refs.openModal.open()
  348. } else{
  349. changeWorkState({
  350. workStatus: flag
  351. }).then(res => {
  352. if (res.status == 200) {
  353. this.getWorkStatus()
  354. }
  355. })
  356. }
  357. },
  358. onOk(){
  359. changeWorkState({
  360. workStatus: 0
  361. }).then(res => {
  362. if (res.status == 200) {
  363. this.$refs.openModal.close()
  364. this.getWorkStatus()
  365. }
  366. })
  367. }
  368. }
  369. }
  370. </script>
  371. <style lang="scss">
  372. page {
  373. width: 100%;
  374. height: 100%;
  375. background-color: #fff;
  376. }
  377. .content {
  378. width: 100%;
  379. height: 100%;
  380. display: flex;
  381. flex-direction: column;
  382. background-color: #fff;
  383. padding: 0 32rpx;
  384. color: #191919;
  385. .header {
  386. width: 100%;
  387. font-size: 36rpx;
  388. display: flex;
  389. justify-content: space-between;
  390. align-items: center;
  391. padding: 16upx 0;
  392. view:last-of-type {
  393. font-size: 32rpx;
  394. color: #4F88F7;
  395. text {
  396. margin-right: 10rpx;
  397. }
  398. }
  399. }
  400. .header-total {
  401. width: 100%;
  402. background: linear-gradient(214deg, #4F88F7 0%, #2D74FE 100%);
  403. border-radius: 24rpx;
  404. color: #fff;
  405. margin: 20rpx 0;
  406. height: 224rpx;
  407. .title {
  408. padding: 18rpx 34rpx;
  409. font-size: 32rpx;
  410. }
  411. }
  412. .header-cont {
  413. display: flex;
  414. align-items: center;
  415. justify-content: space-between;
  416. flex: 1;
  417. padding: 20rpx 34rpx;
  418. .cont-item {
  419. display: flex;
  420. flex-direction: column;
  421. align-items: center;
  422. text {
  423. line-height: 50upx;
  424. font-size: 48upx;
  425. font-family: Arial;
  426. font-style: italic;
  427. }
  428. view {
  429. font-size: 24upx;
  430. }
  431. }
  432. }
  433. .btn-view {
  434. width: 100%;
  435. height: 100rpx;
  436. border-radius: 24rpx;
  437. text-align: center;
  438. line-height: 100rpx;
  439. font-size: 36rpx;
  440. margin: 20rpx 0;
  441. }
  442. .start-btn {
  443. border: 1px solid #4F88F7;
  444. color: #4F88F7;
  445. }
  446. .end-btn {
  447. border: 1px solid #FF2C5C;
  448. color: #FF2C5C;
  449. }
  450. // item样式
  451. .list {
  452. .title {
  453. padding: 24rpx;
  454. font-size: 36rpx;
  455. }
  456. .nodata {
  457. padding-top: 100rpx;
  458. }
  459. }
  460. .list-item {
  461. display: flex;
  462. align-items: center;
  463. font-size: 28upx;
  464. .cont-item-right {
  465. padding: 30upx 0upx;
  466. min-height: 220rpx;
  467. margin-left: 20upx;
  468. border-bottom: 1px solid #E5E5E5;
  469. font-size: 34rpx;
  470. color: #222222;
  471. width: 0;
  472. .location-icon {
  473. width: 20rpx;
  474. height: 20rpx;
  475. margin: 0 10rpx;
  476. }
  477. .do-btn {
  478. width: 120rpx;
  479. height: 48rpx;
  480. border: 1px solid #4F88F7;
  481. border-radius: 28rpx;
  482. font-size: 24rpx;
  483. color: #4F88F7;
  484. text-align: center;
  485. line-height: 48rpx;
  486. }
  487. .bold {
  488. font-weight: 600;
  489. }
  490. .greey {
  491. font-size: 28rpx;
  492. color: #424D5E;
  493. }
  494. .greey-font {
  495. font-size: 28rpx;
  496. color: #666666;
  497. line-height: 44rpx;
  498. }
  499. .dizhi {
  500. margin-right: 36rpx;
  501. flex: 1;
  502. line-height: 44rpx;
  503. word-break: break-all;
  504. }
  505. .btn {
  506. width: 132rpx;
  507. height: 52rpx;
  508. background: #FFD100;
  509. opacity: 1;
  510. border-radius: 28rpx;
  511. text-align: center;
  512. line-height: 52rpx;
  513. color: #191919;
  514. font-size: 28rpx;
  515. }
  516. }
  517. &:last-child .cont-item-right {
  518. border-bottom: none;
  519. }
  520. .type {
  521. line-height: 50rpx;
  522. }
  523. .mark {
  524. padding: 6rpx 16rpx;
  525. border-radius: 12rpx;
  526. font-size: 22rpx;
  527. background-color: #EFEFEF;
  528. color: #666666;
  529. margin-right: 20rpx;
  530. margin-bottom: 10rpx;
  531. }
  532. .mark-left {
  533. border: 1px solid #BB8415;
  534. color: #BB8415;
  535. margin-right: 20rpx;
  536. }
  537. .mark-right {
  538. border: 1px solid #FF6824;
  539. color: #FF6824;
  540. }
  541. }
  542. }
  543. </style>