index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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. uni.navigateTo({
  289. url: '/pages/recoveryPrice/index'
  290. })
  291. },
  292. // 进入待处理订单详情
  293. intoWaitOrderDetail(item) {
  294. uni.navigateTo({
  295. url: '/pages/order/waitOrderDetail?orderNo=' + item.orderReserveNo
  296. })
  297. },
  298. // 导航
  299. openLocation(item) {
  300. uni.openLocation({
  301. latitude: item.lat - 0,
  302. longitude: item.lng - 0,
  303. name: item.name,
  304. address: item.contactAddress
  305. });
  306. },
  307. // 未登录弹窗
  308. loginModal() {
  309. uni.showModal({
  310. title: '提示',
  311. content: '您尚未登录或登录已过期,请登录后使用',
  312. success: (res) => {
  313. if (res.confirm) {
  314. uni.navigateTo({
  315. url: '/pages/login/login'
  316. })
  317. } else if (res.cancel) {
  318. console.log('用户点击取消');
  319. }
  320. }
  321. });
  322. },
  323. // 点击开始或停止接单
  324. changeWorkStateFun(flag) {
  325. if (flag == 0) {
  326. console.log(flag)
  327. this.$refs.openModal.open()
  328. } else{
  329. changeWorkState({
  330. workStatus: flag
  331. }).then(res => {
  332. if (res.status == 200) {
  333. this.getWorkStatus()
  334. }
  335. })
  336. }
  337. },
  338. onOk(){
  339. changeWorkState({
  340. workStatus: 0
  341. }).then(res => {
  342. if (res.status == 200) {
  343. this.$refs.openModal.close()
  344. this.getWorkStatus()
  345. }
  346. })
  347. }
  348. }
  349. }
  350. </script>
  351. <style lang="scss">
  352. page {
  353. width: 100%;
  354. height: 100%;
  355. background-color: #fff;
  356. }
  357. .content {
  358. width: 100%;
  359. height: 100%;
  360. display: flex;
  361. flex-direction: column;
  362. background-color: #fff;
  363. padding: 0 32rpx;
  364. color: #191919;
  365. .header {
  366. width: 100%;
  367. font-size: 36rpx;
  368. display: flex;
  369. justify-content: space-between;
  370. align-items: center;
  371. padding: 16upx 0;
  372. view:last-of-type {
  373. font-size: 32rpx;
  374. color: #4F88F7;
  375. text {
  376. margin-right: 10rpx;
  377. }
  378. }
  379. }
  380. .header-total {
  381. width: 100%;
  382. background: linear-gradient(214deg, #4F88F7 0%, #2D74FE 100%);
  383. border-radius: 24rpx;
  384. color: #fff;
  385. margin: 20rpx 0;
  386. height: 224rpx;
  387. .title {
  388. padding: 18rpx 34rpx;
  389. font-size: 32rpx;
  390. }
  391. }
  392. .header-cont {
  393. display: flex;
  394. align-items: center;
  395. justify-content: space-between;
  396. flex: 1;
  397. padding: 20rpx 34rpx;
  398. .cont-item {
  399. display: flex;
  400. flex-direction: column;
  401. align-items: center;
  402. text {
  403. line-height: 50upx;
  404. font-size: 48upx;
  405. font-family: Arial;
  406. font-style: italic;
  407. }
  408. view {
  409. font-size: 24upx;
  410. }
  411. }
  412. }
  413. .btn-view {
  414. width: 100%;
  415. height: 100rpx;
  416. border-radius: 24rpx;
  417. text-align: center;
  418. line-height: 100rpx;
  419. font-size: 36rpx;
  420. margin: 20rpx 0;
  421. }
  422. .start-btn {
  423. border: 1px solid #4F88F7;
  424. color: #4F88F7;
  425. }
  426. .end-btn {
  427. border: 1px solid #FF2C5C;
  428. color: #FF2C5C;
  429. }
  430. // item样式
  431. .list {
  432. .title {
  433. padding: 24rpx;
  434. font-size: 36rpx;
  435. }
  436. .nodata {
  437. padding-top: 100rpx;
  438. }
  439. }
  440. .list-item {
  441. display: flex;
  442. align-items: center;
  443. font-size: 28upx;
  444. .cont-item-right {
  445. padding: 30upx 0upx;
  446. min-height: 220rpx;
  447. margin-left: 20upx;
  448. border-bottom: 1px solid #E5E5E5;
  449. font-size: 34rpx;
  450. color: #222222;
  451. width: 0;
  452. .location-icon {
  453. width: 20rpx;
  454. height: 20rpx;
  455. margin: 0 10rpx;
  456. }
  457. .do-btn {
  458. width: 120rpx;
  459. height: 48rpx;
  460. border: 1px solid #4F88F7;
  461. border-radius: 28rpx;
  462. font-size: 24rpx;
  463. color: #4F88F7;
  464. text-align: center;
  465. line-height: 48rpx;
  466. }
  467. .bold {
  468. font-weight: 600;
  469. }
  470. .greey {
  471. font-size: 28rpx;
  472. color: #424D5E;
  473. }
  474. .greey-font {
  475. font-size: 28rpx;
  476. color: #666666;
  477. line-height: 44rpx;
  478. }
  479. .dizhi {
  480. margin-right: 36rpx;
  481. flex: 1;
  482. line-height: 44rpx;
  483. word-break: break-all;
  484. }
  485. .btn {
  486. width: 132rpx;
  487. height: 52rpx;
  488. background: #FFD100;
  489. opacity: 1;
  490. border-radius: 28rpx;
  491. text-align: center;
  492. line-height: 52rpx;
  493. color: #191919;
  494. font-size: 28rpx;
  495. }
  496. }
  497. &:last-child .cont-item-right {
  498. border-bottom: none;
  499. }
  500. .type {
  501. line-height: 50rpx;
  502. }
  503. .mark {
  504. padding: 6rpx 16rpx;
  505. border-radius: 12rpx;
  506. font-size: 22rpx;
  507. background-color: #EFEFEF;
  508. color: #666666;
  509. margin-right: 20rpx;
  510. margin-bottom: 10rpx;
  511. }
  512. .mark-left {
  513. border: 1px solid #BB8415;
  514. color: #BB8415;
  515. margin-right: 20rpx;
  516. }
  517. .mark-right {
  518. border: 1px solid #FF6824;
  519. color: #FF6824;
  520. }
  521. }
  522. }
  523. </style>