index.vue 13 KB

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