index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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 ellipsis-one">{{item.contactAddress}}</view>
  50. <view @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.reserveWeight}}kg</view>
  56. <view class="flex">
  57. <view v-for="key in item.orderReserveItemEntityList" :key="key.id" class="mark">
  58. {{key.typeName}}
  59. </view>
  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: 'loadmore', // 加载中状态
  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. checkLogin().then(res => {
  112. this.hasLogin = res.status == 200
  113. if(this.hasLogin){
  114. this.getCurPosition()
  115. this.getTotalData()
  116. this.getWorkStatus()
  117. } else {
  118. this.noDataText = '您尚未登录或登录已过期!'
  119. }
  120. })
  121. },
  122. methods: {
  123. // 检查更新
  124. checkUpdate(){
  125. if (uni.canIUse('getUpdateManager')) {
  126. const updateManager = uni.getUpdateManager()
  127. updateManager.onCheckForUpdate(function (res) {
  128. console.log('onCheckForUpdate====', res)
  129. // 请求完新版本信息的回调
  130. if (res.hasUpdate) {
  131. console.log('res.hasUpdate====')
  132. updateManager.onUpdateReady(function () {
  133. uni.showModal({
  134. title: '更新提示',
  135. content: '新版本已经准备好,是否重启应用?',
  136. success: function (res) {
  137. console.log('success====', res)
  138. // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
  139. if (res.confirm) {
  140. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  141. updateManager.applyUpdate()
  142. }
  143. }
  144. })
  145. })
  146. updateManager.onUpdateFailed(function () {
  147. // 新的版本下载失败
  148. uni.showModal({
  149. title: '已经有新版本了哟~',
  150. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  151. })
  152. })
  153. }
  154. })
  155. }
  156. },
  157. // 获取骑手状态
  158. getWorkStatus() {
  159. WorkStatusGet().then(res=>{
  160. if(res.status==200){
  161. this.workStatus = res.data[0].workStatus
  162. }
  163. })
  164. },
  165. // 获取当前位置
  166. getCurPosition () {
  167. let _this = this
  168. uni.getLocation({
  169. type: 'wgs84', // 默认wgs84
  170. success: function(res) {
  171. console.log(res,'------')
  172. let lat = res.latitude
  173. let lng = res.longitude
  174. // 查询订单信息
  175. _this.getList(lat,lng)
  176. },
  177. fail: function(res) {
  178. console.log(res)
  179. // 查询订单信息
  180. _this.getList()
  181. }
  182. });
  183. },
  184. // 待处理订单信息
  185. getList (lat,lng) {
  186. // let lat = this.currentPosition.lat
  187. // let lng = this.currentPosition.lng
  188. uni.showLoading({
  189. title: '加载中...'
  190. })
  191. waitOrderQuery({handleUserLng:lat,handleUserLat:lng}).then(res => {
  192. console.log(res)
  193. if(res.status == 200){
  194. this.listdata = res.data
  195. this.listdata.forEach(item =>{
  196. item.distance = item.distance ? Math.round(item.distance/1000) : ''
  197. item.reserveTime = moment(item.confirmDate).format('YYYY-MM-DD') + item.reserveTimeTypeDictValue
  198. })
  199. }
  200. uni.hideLoading()
  201. })
  202. },
  203. // 今日统计
  204. getTotalData() {
  205. this.titleStatus = true
  206. reserveTotal({}).then(res=>{
  207. if(res.status == 200) {
  208. this.numTotal = res.data.orderReserveCount || 0
  209. this.weightTotal = res.data.totalAllWeight/1000 || 0
  210. this.moneyTotal = res.data.originalAllAmount || 0
  211. } else {
  212. this.numTotal = 0
  213. this.weightTotal = 0
  214. this.moneyTotal = 0
  215. }
  216. this.titleStatus = false
  217. })
  218. },
  219. // 打开回收价格页面
  220. openPrice(){
  221. uni.navigateTo({
  222. url: '/pages/recoveryPrice/index'
  223. })
  224. },
  225. // 进入待处理订单详情
  226. intoWaitOrderDetail(item){
  227. uni.navigateTo({
  228. url: '/pages/order/waitOrderDetail?orderNo='+item.orderReserveNo
  229. })
  230. },
  231. // 导航
  232. openLocation(item) {
  233. uni.openLocation({
  234. latitude: item.lat - 0,
  235. longitude: item.lng - 0,
  236. name: item.name,
  237. address: item.contactAddress
  238. });
  239. },
  240. // 未登录弹窗
  241. loginModal(){
  242. uni.showModal({
  243. title: '提示',
  244. content: '您尚未登录或登录已过期,请登录后使用',
  245. success: (res)=> {
  246. if (res.confirm) {
  247. uni.navigateTo({
  248. url: '/pages/login/login'
  249. })
  250. } else if (res.cancel) {
  251. console.log('用户点击取消');
  252. }
  253. }
  254. });
  255. },
  256. // 点击开始或停止接单
  257. changeWorkStateFun(flag) {
  258. changeWorkState({workStatus:flag}).then(res=>{
  259. if(res.status == 200) {
  260. this.getWorkStatus()
  261. }
  262. })
  263. }
  264. }
  265. }
  266. </script>
  267. <style lang="scss" >
  268. page{
  269. width: 100%;
  270. height: 100%;
  271. background-color: #fff;
  272. }
  273. .content {
  274. width: 100%;
  275. height: 100%;
  276. display: flex;
  277. flex-direction: column;
  278. background-color: #fff;
  279. padding: 0 32rpx;
  280. color: #191919;
  281. .header{
  282. width: 100%;
  283. font-size: 36rpx;
  284. display: flex;
  285. justify-content: space-between;
  286. align-items: center;
  287. padding: 16upx 0;
  288. view:last-of-type {
  289. font-size: 32rpx;
  290. color: #4F88F7;
  291. text{
  292. margin-right: 10rpx;
  293. }
  294. }
  295. }
  296. .header-total{
  297. width: 100%;
  298. background: linear-gradient(214deg, #4F88F7 0%, #2D74FE 100%);
  299. border-radius: 24rpx;
  300. color: #fff;
  301. margin: 20rpx 0;
  302. height: 224rpx;
  303. .title {
  304. padding: 18rpx 34rpx;
  305. font-size: 32rpx;
  306. }
  307. }
  308. .header-cont{
  309. display: flex;
  310. align-items: center;
  311. justify-content: space-between;
  312. flex: 1;
  313. padding: 20rpx 34rpx;
  314. .cont-item{
  315. display: flex;
  316. flex-direction: column;
  317. align-items: center;
  318. text{
  319. line-height: 50upx;
  320. font-size: 48upx;
  321. font-family: Arial;
  322. font-style:italic;
  323. }
  324. view{
  325. font-size: 24upx;
  326. }
  327. }
  328. }
  329. .btn-view{
  330. width: 100%;
  331. height: 100rpx;
  332. border-radius: 24rpx;
  333. text-align: center;
  334. line-height: 100rpx;
  335. font-size: 36rpx;
  336. margin: 20rpx 0;
  337. }
  338. .start-btn{
  339. border: 1px solid #4F88F7;
  340. color: #4F88F7;
  341. }
  342. .end-btn{
  343. border: 1px solid #FF2C5C;
  344. color: #FF2C5C;
  345. }
  346. // item样式
  347. .list{
  348. .title{
  349. padding: 24rpx;
  350. font-size: 36rpx;
  351. }
  352. .nodata{
  353. padding-top: 100rpx;
  354. }
  355. }
  356. .list-item {
  357. display: flex;
  358. align-items: center;
  359. font-size: 28upx;
  360. .cont-item-right{
  361. padding: 30upx 0upx;
  362. min-height: 220rpx;
  363. margin-left: 20upx;
  364. border-bottom: 1px solid #E5E5E5;
  365. font-size: 34rpx;
  366. color: #222222;
  367. width: 0;
  368. .location-icon{
  369. width: 20rpx;
  370. height: 20rpx;
  371. margin: 0 10rpx;
  372. }
  373. .do-btn{
  374. width: 120rpx;
  375. height: 48rpx;
  376. border: 1px solid #4F88F7;
  377. border-radius: 28rpx;
  378. font-size: 24rpx;
  379. color: #4F88F7;
  380. text-align: center;
  381. line-height: 48rpx;
  382. }
  383. .bold{
  384. font-weight: 600;
  385. }
  386. .greey{
  387. font-size: 28rpx;
  388. color: #424D5E;
  389. }
  390. .greey-font{
  391. font-size: 28rpx;
  392. color: #666666;
  393. line-height: 44rpx;
  394. }
  395. .dizhi{
  396. margin-right: 36rpx;
  397. flex: 1;
  398. line-height: 44rpx;
  399. }
  400. .btn{
  401. width: 132rpx;
  402. height: 52rpx;
  403. background: #FFD100;
  404. opacity: 1;
  405. border-radius: 28rpx;
  406. text-align: center;
  407. line-height: 52rpx;
  408. color: #191919;
  409. font-size: 28rpx;
  410. }
  411. }
  412. &:last-child .cont-item-right {
  413. border-bottom: none;
  414. }
  415. .mark{
  416. padding: 6rpx 16rpx;
  417. border-radius: 12rpx;
  418. font-size: 22rpx;
  419. margin-top: 12rpx;
  420. background-color: #EFEFEF;
  421. color: #666666;
  422. margin-right: 20rpx;
  423. }
  424. .mark-left{
  425. border: 1px solid #BB8415;
  426. color: #BB8415;
  427. margin-right: 20rpx;
  428. }
  429. .mark-right{
  430. border: 1px solid #FF6824;
  431. color: #FF6824;
  432. }
  433. }
  434. }
  435. </style>