index.vue 11 KB

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