index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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. 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.reserveTimeType
  198. })
  199. }
  200. })
  201. },
  202. // 今日统计
  203. getTotalData() {
  204. this.titleStatus = true
  205. reserveTotal({}).then(res=>{
  206. if(res.status == 200) {
  207. this.numTotal = res.data.orderReserveCount || 0
  208. this.weightTotal = res.data.totalAllWeight/1000 || 0
  209. this.moneyTotal = res.data.originalAllAmount || 0
  210. } else {
  211. this.numTotal = 0
  212. this.weightTotal = 0
  213. this.moneyTotal = 0
  214. }
  215. this.titleStatus = false
  216. })
  217. },
  218. // 打开回收价格页面
  219. openPrice(){
  220. if(this.hasLogin){
  221. uni.navigateTo({
  222. url: '/pages/recoveryPrice/index'
  223. })
  224. } else {
  225. this.loginModal()
  226. }
  227. },
  228. // 进入待处理订单详情
  229. intoWaitOrderDetail(item){
  230. uni.navigateTo({
  231. url: '/pages/order/waitOrderDetail?orderNo='+item.orderReserveNo
  232. })
  233. },
  234. // 导航
  235. openLocation(item) {
  236. uni.openLocation({
  237. latitude: item.lat - 0,
  238. longitude: item.lng - 0,
  239. name: item.name,
  240. address: item.contactAddress
  241. });
  242. },
  243. // 未登录弹窗
  244. loginModal(){
  245. uni.showModal({
  246. title: '提示',
  247. content: '您尚未登录或登录已过期,请登录后使用',
  248. success: (res)=> {
  249. if (res.confirm) {
  250. uni.navigateTo({
  251. url: '/pages/login/login'
  252. })
  253. } else if (res.cancel) {
  254. console.log('用户点击取消');
  255. }
  256. }
  257. });
  258. },
  259. // 点击开始或停止接单
  260. changeWorkStateFun(flag) {
  261. changeWorkState({workStatus:flag}).then(res=>{
  262. if(res.status == 200) {
  263. this.getWorkStatus()
  264. }
  265. })
  266. }
  267. }
  268. }
  269. </script>
  270. <style lang="scss" >
  271. page{
  272. width: 100%;
  273. height: 100%;
  274. background-color: #fff;
  275. }
  276. .content {
  277. width: 100%;
  278. height: 100%;
  279. display: flex;
  280. flex-direction: column;
  281. background-color: #fff;
  282. padding: 0 32rpx;
  283. color: #191919;
  284. .header{
  285. width: 100%;
  286. font-size: 36rpx;
  287. display: flex;
  288. justify-content: space-between;
  289. align-items: center;
  290. padding: 16upx 0;
  291. view:last-of-type {
  292. font-size: 32rpx;
  293. color: #4F88F7;
  294. text{
  295. margin-right: 10rpx;
  296. }
  297. }
  298. }
  299. .header-total{
  300. width: 100%;
  301. background: linear-gradient(214deg, #4F88F7 0%, #2D74FE 100%);
  302. border-radius: 24rpx;
  303. color: #fff;
  304. margin: 20rpx 0;
  305. .title {
  306. padding: 18rpx 34rpx;
  307. font-size: 32rpx;
  308. }
  309. }
  310. .header-cont{
  311. display: flex;
  312. align-items: center;
  313. justify-content: space-between;
  314. padding: 20rpx 34rpx;
  315. .cont-item{
  316. display: flex;
  317. flex-direction: column;
  318. align-items: center;
  319. text{
  320. line-height: 50upx;
  321. font-size: 48upx;
  322. font-family: Arial;
  323. font-style:italic;
  324. }
  325. view{
  326. font-size: 24upx;
  327. }
  328. }
  329. }
  330. .btn-view{
  331. width: 100%;
  332. height: 100rpx;
  333. border-radius: 24rpx;
  334. text-align: center;
  335. line-height: 100rpx;
  336. font-size: 36rpx;
  337. margin: 20rpx 0;
  338. }
  339. .start-btn{
  340. border: 1px solid #4F88F7;
  341. color: #4F88F7;
  342. }
  343. .end-btn{
  344. border: 1px solid #FF2C5C;
  345. color: #FF2C5C;
  346. }
  347. // item样式
  348. .list{
  349. .title{
  350. padding: 24rpx;
  351. font-size: 36rpx;
  352. }
  353. }
  354. .list-item {
  355. display: flex;
  356. align-items: center;
  357. font-size: 28upx;
  358. .cont-item-right{
  359. padding: 30upx 0upx;
  360. min-height: 220rpx;
  361. margin-left: 20upx;
  362. border-bottom: 1px solid #E5E5E5;
  363. font-size: 34rpx;
  364. color: #222222;
  365. width: 0;
  366. .location-icon{
  367. width: 20rpx;
  368. height: 20rpx;
  369. margin: 0 10rpx;
  370. }
  371. .do-btn{
  372. width: 120rpx;
  373. height: 48rpx;
  374. border: 1px solid #4F88F7;
  375. border-radius: 28rpx;
  376. font-size: 24rpx;
  377. color: #4F88F7;
  378. text-align: center;
  379. line-height: 48rpx;
  380. }
  381. .bold{
  382. font-weight: 600;
  383. }
  384. .greey{
  385. font-size: 28rpx;
  386. color: #424D5E;
  387. }
  388. .greey-font{
  389. font-size: 28rpx;
  390. color: #666666;
  391. line-height: 44rpx;
  392. }
  393. .dizhi{
  394. margin-right: 36rpx;
  395. flex: 1;
  396. line-height: 44rpx;
  397. }
  398. .btn{
  399. width: 132rpx;
  400. height: 52rpx;
  401. background: #FFD100;
  402. opacity: 1;
  403. border-radius: 28rpx;
  404. text-align: center;
  405. line-height: 52rpx;
  406. color: #191919;
  407. font-size: 28rpx;
  408. }
  409. }
  410. &:last-child .cont-item-right {
  411. border-bottom: none;
  412. }
  413. .mark{
  414. padding: 6rpx 16rpx;
  415. border-radius: 12rpx;
  416. font-size: 22rpx;
  417. margin-top: 12rpx;
  418. background-color: #EFEFEF;
  419. color: #666666;
  420. margin-right: 20rpx;
  421. }
  422. .mark-left{
  423. border: 1px solid #BB8415;
  424. color: #BB8415;
  425. margin-right: 20rpx;
  426. }
  427. .mark-right{
  428. border: 1px solid #FF6824;
  429. color: #FF6824;
  430. }
  431. }
  432. }
  433. </style>