index.vue 13 KB

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