index.vue 10 KB

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