index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <template>
  2. <view class="content">
  3. <view class="content-top">
  4. <view class="top-banner">
  5. <u-swiper :list="bannerList" class="banner"></u-swiper>
  6. </view>
  7. </view>
  8. <view class="content-bottom">
  9. <!-- 接单信息 -->
  10. <view class="bottom-new-notice" v-if="orderTime" @click="checkOrderDetail()">
  11. <view class="notice-content">
  12. <view class="notice-content-item"><u-icon class="icon" name="home_icon_bells" custom-prefix="custom-icon" size="38" color="#333"></u-icon></span><span class="item-title">您于{{orderTime ? orderTime :''}}下单成功,点击查看详情</span></view>
  13. <!-- <view class="notice-content-item"></view> -->
  14. </view>
  15. </view>
  16. <!-- 下单 -->
  17. <view class="bottom-order flex justify_between align_center">
  18. <view class="order-type flex flex_column justify_center" @click="gotoSaoMa">
  19. <u-image src="/static/index/home_icon_code.png" width="186rpx" height="144rpx"></u-image>
  20. <view class="type type-saoma">扫码下单</view>
  21. <view class="type-info">在线下单</view>
  22. </view>
  23. <view class="order-type flex flex_column justify_center" @click="gotoYueYu">
  24. <u-image src="/static/index/home_icon.png" width="176rpx" height="164rpx"></u-image>
  25. <view class="type">自主下单</view>
  26. <view class="type-info">免费上门回收</view>
  27. </view>
  28. </view>
  29. <!-- 收回统计 -->
  30. <view class="statistics-title">今日上门回收价格</view>
  31. <view>
  32. <!-- 纸张类 -->
  33. <view class="statistics-box" v-if="rubbishPaperList.length">
  34. <view class="rubbishType-type">
  35. {{rubbishPaperName ? rubbishPaperName :''}}
  36. </view>
  37. <swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
  38. <swiper-item v-for="(item,index) in rubbishPaperList" :key="index">
  39. <view class="flex rubbish">
  40. <view v-for="key in item" class="rubbishType-item">
  41. <u-image :src="key.image" width="92" height="92"></u-image>
  42. <span>{{key.name ? key.name :''}}</span><span>{{key.customerPrice ? (key.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
  43. </view>
  44. </view>
  45. </swiper-item>
  46. </swiper>
  47. </view>
  48. <!-- 塑料类 -->
  49. <view class="statistics-box" v-if="rubbishSLList.length">
  50. <view class="rubbishType-type">
  51. {{rubbishSLName ? rubbishSLName :''}}
  52. </view>
  53. <swiper class="swiper" :indicator-dots="indicatorDotsSL" :autoplay="autoplay" :interval="interval" :duration="duration">
  54. <swiper-item v-for="(item,index) in rubbishSLList" :key="index">
  55. <view class="flex rubbish">
  56. <view v-for="key in item" class="rubbishType-item">
  57. <u-image :src="key.image" width="92" height="92"></u-image>
  58. <span>{{key.name ? key.name :''}}</span><span>{{key.customerPrice ? (key.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
  59. </view>
  60. </view>
  61. </swiper-item>
  62. </swiper>
  63. </view>
  64. <!-- 金属类 -->
  65. <view class="statistics-box" v-if="rubbishJSList.length">
  66. <view class="rubbishType-type">
  67. {{rubbishJSName ? rubbishJSName :''}}
  68. </view>
  69. <swiper class="swiper" :indicator-dots="indicatorDotsJS" :autoplay="autoplaySL" :interval="interval" :duration="duration">
  70. <swiper-item v-for="(item,index) in rubbishJSList" :key="index">
  71. <view class="flex rubbish">
  72. <view v-for="key in item" class="rubbishType-item">
  73. <u-image :src="key.image" width="92" height="92"></u-image>
  74. <span>{{key.name ? key.name :''}}</span><span>{{key.customerPrice ? (key.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
  75. </view>
  76. </view>
  77. </swiper-item>
  78. </swiper>
  79. </view>
  80. <!-- 衣物类 -->
  81. <view class="statistics-box" v-if="rubbishYWList.length">
  82. <view class="rubbishType-type">
  83. {{rubbishYWName ? rubbishYWName :''}}
  84. </view>
  85. <swiper class="swiper" :indicator-dots="indicatorDotsYW" :autoplay="autoplaySL" :interval="interval" :duration="duration">
  86. <swiper-item v-for="(item,index) in rubbishYWList" :key="index">
  87. <view class="flex rubbish">
  88. <view v-for="key in item" class="rubbishType-item">
  89. <u-image :src="key.image" width="92" height="92"></u-image>
  90. <span>{{key.name ? key.name :''}}</span><span>{{key.customerPrice ? (key.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
  91. </view>
  92. </view>
  93. </swiper-item>
  94. </swiper>
  95. </view>
  96. <view class="nodata" v-if="rubbishPriceList.length==0">
  97. <u-empty src="/static/def_result.png" :text="noDataText" icon-size="260" ></u-empty>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. import {getBannerList,geRubbishType,orderStatus} from '@/api/index'
  105. import { checkLogin } from '@/api/login.js'
  106. export default {
  107. components: { },
  108. data() {
  109. return {
  110. yuYueBtn:{
  111. background: "#4F88F7",
  112. borderRadius: "12px",
  113. color:'#fff',
  114. },
  115. hasLogin:false, // 是否登录
  116. noDataText:"", // 未登录提示文字
  117. orderTime:'', // 创建时间
  118. bannerList:[],
  119. rubbishPaperName:"",
  120. rubbishSLName:"",
  121. rubbishYWName:"",
  122. rubbishJSName:"",
  123. rubbishPaperList:[],
  124. rubbishSLList:[],
  125. rubbishYWList:[],
  126. rubbishJSList:[],
  127. rubbishPriceList:[],
  128. orderId:'' ,// 订单id
  129. indicatorDots: true,
  130. autoplay: false,
  131. interval: 2000,
  132. duration: 500,
  133. indicatorDotsSL:false,
  134. indicatorDotsJS:false,
  135. indicatorDotsYW:false
  136. }
  137. },
  138. onLoad() {
  139. this.geRubbishTypeList()
  140. this.getBanner()
  141. this.pageInit()
  142. },
  143. onUnload() {
  144. },
  145. onShareAppMessage(res) {
  146. },
  147. onShareTimeline(res) {
  148. },
  149. onShow() {
  150. this.getBanner()
  151. this.geRubbishTypeList()
  152. checkLogin().then(res => {
  153. this.hasLogin=res.status==200
  154. if(this.hasLogin){
  155. this.pageInit()
  156. }else{
  157. this.noDataText="您尚未登录或登录已过期,完成登录后可查看数据信息!"
  158. }
  159. })
  160. },
  161. methods: {
  162. pageInit() {
  163. this.orderTime=''
  164. this.getOrderStatus()
  165. this.checkUpdate()
  166. },
  167. // 获取banner图
  168. getBanner(){
  169. getBannerList().then(res=>{
  170. if(res.status==200){
  171. this.bannerList=res.data || []
  172. }
  173. })
  174. },
  175. // 获取订单状态
  176. getOrderStatus(){
  177. orderStatus().then(res=>{
  178. if(res.status==200){
  179. this.orderId=res.data.id
  180. this.orderTime=res.data.createDate
  181. }
  182. })
  183. },
  184. // 查看订单详情
  185. checkOrderDetail(){
  186. uni.navigateTo({
  187. url:`/pages/order/orderDetails?id=${this.orderId}`
  188. })
  189. },
  190. // 获取垃圾分类
  191. geRubbishTypeList(){
  192. geRubbishType().then(res=>{
  193. if(res.status==200){
  194. this.rubbishPriceList=res.data
  195. const a= res.data.find(item=>item.code=='PAPER')
  196. const b= res.data.find(item=>item.code=='PLASTIC')
  197. const c= res.data.find(item=>item.code=='CLOTHES')
  198. const d= res.data.find(item=>item.code=='METAL')
  199. console.log(res.data,a,b,c,d,'000000000000000')
  200. /* 纸张类 */
  201. if(a){
  202. if (a.rubbishTypeVOList.length > 4) {
  203. this.indicatorDots=true
  204. let num=Math.ceil(a.rubbishTypeVOList.length/4)
  205. let arr = []
  206. for (var i = 0; i < num; i++) {
  207. arr[i]=a.rubbishTypeVOList.slice(i*4,(i+1)*4)
  208. console.log(arr,'===========arr')
  209. }
  210. this.rubbishPaperList= arr
  211. } else {
  212. this.indicatorDots=false
  213. this.rubbishPaperList = a.rubbishTypeVOList.length?[a.rubbishTypeVOList]:[]
  214. }
  215. console.log(this.rubbishPaperList, '--------aaaaaa')
  216. }
  217. this.rubbishPaperList.map(item=>{
  218. item.map(item=>{
  219. if(item.code=='YELLOW_PAPER'){
  220. item.image='/static/index/icon_aper_yellow.png'
  221. }
  222. if(item.code=='COLOUR_PAPER'){
  223. item.image='/static/index/icon_aper_flower.png'
  224. }
  225. if(item.code=='BOOK_PAPER'){
  226. item.image='/static/index/icon_book.png'
  227. }
  228. if(item.code=='MAGAZINE'){
  229. item.image='/static/index/icon_magazine.png'
  230. }
  231. if(item.code=='OTHER_PAPER'){
  232. item.image='/static/index/icon_aper_miscellaneous.png'
  233. }
  234. if(item.code=='NEWS_PAPER'){
  235. item.image='/static/index/icon_newspaper.png'
  236. }
  237. })
  238. })
  239. // 塑料类
  240. if(b){
  241. if (b.rubbishTypeVOList.length > 4) {
  242. this.indicatorDotsSL=true
  243. let num=Math.ceil(a.rubbishTypeVOList.length/4)
  244. let arr = []
  245. for (var i = 0; i < num; i++) {
  246. arr[i]=a.rubbishTypeVOList.slice(i*4,(i+1)*4)
  247. console.log(arr,'===========arr')
  248. }
  249. this.rubbishSLList= arr
  250. } else {
  251. this.indicatorDotsSL=false
  252. this.rubbishSLList = b.rubbishTypeVOList.length?[b.rubbishTypeVOList]:[]
  253. }
  254. console.log(this.rubbishSLList, '--------aaaaaa')
  255. }
  256. this.rubbishSLList.map(item=>{
  257. item.map(item=>{
  258. if(item.code=='PLASTIC_WHITE'){
  259. item.image='/static/index/icon_frame_white.png'
  260. }
  261. if(item.code=='PLASTIC_BLACK'){
  262. item.image='/static/index/icon_frame_black.png'
  263. }
  264. if(item.code=='PMMA'){
  265. item.image='/static/index/icon_acrylic.png'
  266. }
  267. if(item.code=='PLASTIC_LUCENCY'){
  268. item.image='/static/index/icon_bottle.png'
  269. }
  270. })
  271. })
  272. // 衣物
  273. if(c){
  274. if (c.rubbishTypeVOList.length > 4) {
  275. this.indicatorDotsJS=true
  276. let num=Math.ceil(a.rubbishTypeVOList.length/4)
  277. let arr = []
  278. for (var i = 0; i < num; i++) {
  279. arr[i]=a.rubbishTypeVOList.slice(i*4,(i+1)*4)
  280. console.log(arr,'===========arr')
  281. }
  282. this.rubbishYWList= arr
  283. } else {
  284. this.indicatorDotsJS=false
  285. this.rubbishYWList =c.rubbishTypeVOList.length?[c.rubbishTypeVOList]:[]
  286. }
  287. console.log(this.rubbishYWList, '--------aaaaaa')
  288. }
  289. this.rubbishYWList.map(item=>{
  290. item.map(item=>{
  291. if(item.code=='SIMPLE_CLOTHES'){
  292. item.image='/static/index/icon_clothes.png'
  293. }
  294. })
  295. })
  296. // 金属
  297. if(d){
  298. if (d.rubbishTypeVOList.length > 4) {
  299. this.indicatorDotsYW=true
  300. let num=Math.ceil(a.rubbishTypeVOList.length/4)
  301. let arr = []
  302. for (var i = 0; i < num; i++) {
  303. arr[i]=a.rubbishTypeVOList.slice(i*4,(i+1)*4)
  304. console.log(arr,'===========arr')
  305. }
  306. this.rubbishJSList= arr
  307. } else {
  308. this.indicatorDotsYW=false
  309. this.rubbishJSList =d.rubbishTypeVOList.length?[d.rubbishTypeVOList]:[]
  310. }
  311. console.log(this.rubbishJSList, '--------aaaaaa')
  312. }
  313. this.rubbishJSList.map(item=>{
  314. item.map(item=>{
  315. if(item.code=='THIN_IRON'){
  316. item.image='/static/index/icon_iron_thin.png'
  317. }
  318. if(item.code=='THICK_IRON'){
  319. item.image='/static/index/icon_iron_thick.png'
  320. }
  321. if(item.code=='STAINLESS_IRON'){
  322. item.image='/static/index/icon_steel.png'
  323. }
  324. })
  325. })
  326. this.rubbishPaperName=a?a.name:''
  327. this.rubbishSLName=b?b.name:''
  328. this.rubbishYWName=c?c.name:''
  329. this.rubbishJSName=d?d.name:''
  330. }
  331. })
  332. },
  333. // 扫码下单
  334. gotoSaoMa(){
  335. if(this.hasLogin){
  336. wx.scanCode({
  337. success: (res)=> {
  338. uni.navigateTo({
  339. url: '/pages/index/order'
  340. })
  341. }
  342. })
  343. }else{
  344. this.loginModal()
  345. }
  346. },
  347. // 自主下单
  348. gotoYueYu(){
  349. if(this.hasLogin){
  350. uni.navigateTo({
  351. url: '/pages/index/order'
  352. })
  353. }else{
  354. this.loginModal()
  355. }
  356. },
  357. // 未登录弹窗
  358. loginModal(){
  359. uni.showModal({
  360. title: '提示',
  361. content: '您尚未登录或登录已过期,请登录后使用',
  362. success: (res)=> {
  363. if (res.confirm) {
  364. uni.navigateTo({
  365. url: '/pages/login/login'
  366. })
  367. } else if (res.cancel) {
  368. console.log('用户点击取消');
  369. }
  370. }
  371. });
  372. },
  373. // 检查更新
  374. checkUpdate(){
  375. if (uni.canIUse('getUpdateManager')) {
  376. const updateManager = uni.getUpdateManager()
  377. updateManager.onCheckForUpdate(function (res) {
  378. console.log('onCheckForUpdate====', res)
  379. // 请求完新版本信息的回调
  380. if (res.hasUpdate) {
  381. console.log('res.hasUpdate====')
  382. updateManager.onUpdateReady(function () {
  383. uni.showModal({
  384. title: '更新提示',
  385. content: '新版本已经准备好,是否重启应用?',
  386. success: function (res) {
  387. console.log('success====', res)
  388. // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
  389. if (res.confirm) {
  390. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  391. updateManager.applyUpdate()
  392. }
  393. }
  394. })
  395. })
  396. updateManager.onUpdateFailed(function () {
  397. // 新的版本下载失败
  398. uni.showModal({
  399. title: '已经有新版本了哟~',
  400. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  401. })
  402. })
  403. }
  404. })
  405. }
  406. },
  407. }
  408. }
  409. </script>
  410. <style lang="scss" scoped>
  411. .content {
  412. width: 100%;
  413. height: 100vh;
  414. display: flex;
  415. flex-direction: column;
  416. padding: 0;
  417. .content-top{
  418. .top-banner{
  419. padding: 20upx 30upx 0;
  420. .banner{
  421. width:100%;
  422. height: 140px;
  423. }
  424. }
  425. }
  426. .content-bottom{
  427. padding: 0 30upx 30upx;
  428. background-color: #f5f5f5;
  429. .bottom-new-notice{
  430. background-image: url('../../static/home_bg_expressage.png');
  431. background-size: 100% 100%;
  432. height:220upx;
  433. margin-top: 30upx;
  434. display: flex;
  435. justify-content: space-between;
  436. align-items: center;
  437. padding: 20upx 30upx;
  438. .notice-content{
  439. .notice-content-item{
  440. margin: 15upx 0;
  441. display: flex;
  442. align-items: center;
  443. .item-title{
  444. display: inline-block;
  445. margin-left: 20upx;
  446. }
  447. }
  448. .notice-content-item:last-child{
  449. font-size: 32rpx;
  450. font-family: PingFang SC;
  451. font-weight: 400;
  452. color: #191919;
  453. }
  454. }
  455. .notice-static{
  456. width:186upx;
  457. height: 108upx;
  458. background-image: url('../../static/home_sign_rider.png');
  459. background-size:100% 100%;
  460. .notice-static-text{
  461. position: relative;
  462. top:21upx;
  463. left:85upx
  464. }
  465. }
  466. }
  467. .bottom-zhiyin{
  468. margin: 30upx 0;
  469. }
  470. .bottom-order{
  471. padding: 50upx 86upx;
  472. margin:30upx 0 56upx;
  473. background: #FFFFFF;
  474. box-shadow: 0px 18px 35px rgba(1, 136, 209, 0.1);
  475. opacity: 1;
  476. border-radius: 12px;
  477. .order-type{
  478. text-align: center;
  479. .type{
  480. font-size: 42upx;
  481. font-weight: bold;
  482. color: #000000;
  483. margin-top: 10upx;
  484. }
  485. .type-saoma{
  486. margin-top: 35upx;
  487. }
  488. .type-info{
  489. color:#999999;
  490. font-size: 24upx;
  491. font-weight: 400;
  492. margin-top: 10upx;
  493. }
  494. }
  495. }
  496. .statistics-title{
  497. font-size: 36upx;
  498. font-family: PingFang SC;
  499. font-weight: bold;
  500. color: #191919;
  501. opacity: 1;
  502. margin-bottom: 30upx;
  503. }
  504. .statistics-box{
  505. padding: 20upx 30upx;
  506. margin-bottom: 30upx;
  507. background-color: #FFFFFF;
  508. border-radius: 12px;
  509. .rubbishType-type{
  510. margin-bottom: 36upx;
  511. font-size: 28upx;
  512. font-weight: 400;
  513. color: #000000;
  514. }
  515. .rubbish{
  516. font-size:24upx;
  517. // overflow-x: scroll;
  518. .rubbishType-item{
  519. display: flex;
  520. flex-direction: column;
  521. align-items: center;
  522. min-width: 24.5%;
  523. }
  524. }
  525. .swiper{
  526. height: 215rpx;
  527. }
  528. }
  529. .statistics-box:last-child{
  530. margin-bottom:0 ;
  531. }
  532. }
  533. }
  534. </style>