index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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.pageInit()
  141. },
  142. onUnload() {
  143. },
  144. onShareAppMessage(res) {
  145. },
  146. onShareTimeline(res) {
  147. },
  148. onShow() {
  149. this.geRubbishTypeList()
  150. checkLogin().then(res => {
  151. this.hasLogin=res.status==200
  152. if(this.hasLogin){
  153. this.pageInit()
  154. }else{
  155. this.noDataText="您尚未登录或登录已过期,完成登录后可查看数据信息!"
  156. }
  157. })
  158. },
  159. methods: {
  160. pageInit() {
  161. this.orderTime=''
  162. this.getBanner()
  163. this.getOrderStatus()
  164. this.checkUpdate()
  165. },
  166. // 获取banner图
  167. getBanner(){
  168. getBannerList().then(res=>{
  169. if(res.status==200){
  170. this.bannerList=res.data || []
  171. }
  172. })
  173. },
  174. // 获取订单状态
  175. getOrderStatus(){
  176. orderStatus().then(res=>{
  177. if(res.status==200){
  178. this.orderId=res.data.id
  179. this.orderTime=res.data.createDate
  180. }
  181. })
  182. },
  183. // 查看订单详情
  184. checkOrderDetail(){
  185. uni.navigateTo({
  186. url:`/pages/order/orderDetails?id=${this.orderId}`
  187. })
  188. },
  189. // 获取垃圾分类
  190. geRubbishTypeList(){
  191. geRubbishType().then(res=>{
  192. if(res.status==200){
  193. this.rubbishPriceList=res.data
  194. const a= res.data.find(item=>item.code=='PAPER')
  195. const b= res.data.find(item=>item.code=='PLASTIC')
  196. const c= res.data.find(item=>item.code=='CLOTHES')
  197. const d= res.data.find(item=>item.code=='METAL')
  198. console.log(res.data,a,b,c,d,'000000000000000')
  199. /* 纸张类 */
  200. if(a){
  201. if (a.rubbishTypeVOList.length > 4) {
  202. this.indicatorDots=true
  203. let num=Math.ceil(a.rubbishTypeVOList.length/4)
  204. let arr = []
  205. for (var i = 0; i < num; i++) {
  206. arr[i]=a.rubbishTypeVOList.slice(i*4,(i+1)*4)
  207. console.log(arr,'===========arr')
  208. }
  209. this.rubbishPaperList= arr
  210. } else {
  211. this.indicatorDots=false
  212. this.rubbishPaperList = a.rubbishTypeVOList.length?[a.rubbishTypeVOList]:[]
  213. }
  214. console.log(this.rubbishPaperList, '--------aaaaaa')
  215. }
  216. this.rubbishPaperList.map(item=>{
  217. item.map(item=>{
  218. if(item.code=='YELLOW_PAPER'){
  219. item.image='/static/index/icon_aper_yellow.png'
  220. }
  221. if(item.code=='COLOUR_PAPER'){
  222. item.image='/static/index/icon_aper_flower.png'
  223. }
  224. if(item.code=='BOOK_PAPER'){
  225. item.image='/static/index/icon_book.png'
  226. }
  227. if(item.code=='MAGAZINE'){
  228. item.image='/static/index/icon_magazine.png'
  229. }
  230. if(item.code=='OTHER_PAPER'){
  231. item.image='/static/index/icon_aper_miscellaneous.png'
  232. }
  233. if(item.code=='NEWS_PAPER'){
  234. item.image='/static/index/icon_newspaper.png'
  235. }
  236. })
  237. })
  238. // 塑料类
  239. if(b){
  240. if (b.rubbishTypeVOList.length > 4) {
  241. this.indicatorDotsSL=true
  242. let num=Math.ceil(a.rubbishTypeVOList.length/4)
  243. let arr = []
  244. for (var i = 0; i < num; i++) {
  245. arr[i]=a.rubbishTypeVOList.slice(i*4,(i+1)*4)
  246. console.log(arr,'===========arr')
  247. }
  248. this.rubbishSLList= arr
  249. } else {
  250. this.indicatorDotsSL=false
  251. this.rubbishSLList = b.rubbishTypeVOList.length?[b.rubbishTypeVOList]:[]
  252. }
  253. console.log(this.rubbishSLList, '--------aaaaaa')
  254. }
  255. this.rubbishSLList.map(item=>{
  256. item.map(item=>{
  257. if(item.code=='PLASTIC_WHITE'){
  258. item.image='/static/index/icon_frame_white.png'
  259. }
  260. if(item.code=='PLASTIC_BLACK'){
  261. item.image='/static/index/icon_frame_black.png'
  262. }
  263. if(item.code=='PMMA'){
  264. item.image='/static/index/icon_acrylic.png'
  265. }
  266. if(item.code=='PLASTIC_LUCENCY'){
  267. item.image='/static/index/icon_bottle.png'
  268. }
  269. })
  270. })
  271. // 衣物
  272. if(c){
  273. if (c.rubbishTypeVOList.length > 4) {
  274. this.indicatorDotsJS=true
  275. let num=Math.ceil(a.rubbishTypeVOList.length/4)
  276. let arr = []
  277. for (var i = 0; i < num; i++) {
  278. arr[i]=a.rubbishTypeVOList.slice(i*4,(i+1)*4)
  279. console.log(arr,'===========arr')
  280. }
  281. this.rubbishYWList= arr
  282. } else {
  283. this.indicatorDotsJS=false
  284. this.rubbishYWList =c.rubbishTypeVOList.length?[c.rubbishTypeVOList]:[]
  285. }
  286. console.log(this.rubbishYWList, '--------aaaaaa')
  287. }
  288. this.rubbishYWList.map(item=>{
  289. item.map(item=>{
  290. if(item.code=='SIMPLE_CLOTHES'){
  291. item.image='/static/index/icon_clothes.png'
  292. }
  293. })
  294. })
  295. // 金属
  296. if(d){
  297. if (d.rubbishTypeVOList.length > 4) {
  298. this.indicatorDotsYW=true
  299. let num=Math.ceil(a.rubbishTypeVOList.length/4)
  300. let arr = []
  301. for (var i = 0; i < num; i++) {
  302. arr[i]=a.rubbishTypeVOList.slice(i*4,(i+1)*4)
  303. console.log(arr,'===========arr')
  304. }
  305. this.rubbishJSList= arr
  306. } else {
  307. this.indicatorDotsYW=false
  308. this.rubbishJSList =d.rubbishTypeVOList.length?[d.rubbishTypeVOList]:[]
  309. }
  310. console.log(this.rubbishJSList, '--------aaaaaa')
  311. }
  312. this.rubbishJSList.map(item=>{
  313. item.map(item=>{
  314. if(item.code=='THIN_IRON'){
  315. item.image='/static/index/icon_iron_thin.png'
  316. }
  317. if(item.code=='THICK_IRON'){
  318. item.image='/static/index/icon_iron_thick.png'
  319. }
  320. if(item.code=='STAINLESS_IRON'){
  321. item.image='/static/index/icon_steel.png'
  322. }
  323. })
  324. })
  325. this.rubbishPaperName=a?a.name:''
  326. this.rubbishSLName=b?b.name:''
  327. this.rubbishYWName=c?c.name:''
  328. this.rubbishJSName=d?d.name:''
  329. }
  330. })
  331. },
  332. // 扫码下单
  333. gotoSaoMa(){
  334. if(this.hasLogin){
  335. wx.scanCode({
  336. success: (res)=> {
  337. uni.navigateTo({
  338. url: '/pages/index/order'
  339. })
  340. }
  341. })
  342. }else{
  343. this.loginModal()
  344. }
  345. },
  346. // 自主下单
  347. gotoYueYu(){
  348. if(this.hasLogin){
  349. uni.navigateTo({
  350. url: '/pages/index/order'
  351. })
  352. }else{
  353. this.loginModal()
  354. }
  355. },
  356. // 未登录弹窗
  357. loginModal(){
  358. uni.showModal({
  359. title: '提示',
  360. content: '您尚未登录或登录已过期,请登录后使用',
  361. success: (res)=> {
  362. if (res.confirm) {
  363. uni.navigateTo({
  364. url: '/pages/login/login'
  365. })
  366. } else if (res.cancel) {
  367. console.log('用户点击取消');
  368. }
  369. }
  370. });
  371. },
  372. // 检查更新
  373. checkUpdate(){
  374. if (uni.canIUse('getUpdateManager')) {
  375. const updateManager = uni.getUpdateManager()
  376. updateManager.onCheckForUpdate(function (res) {
  377. console.log('onCheckForUpdate====', res)
  378. // 请求完新版本信息的回调
  379. if (res.hasUpdate) {
  380. console.log('res.hasUpdate====')
  381. updateManager.onUpdateReady(function () {
  382. uni.showModal({
  383. title: '更新提示',
  384. content: '新版本已经准备好,是否重启应用?',
  385. success: function (res) {
  386. console.log('success====', res)
  387. // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
  388. if (res.confirm) {
  389. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  390. updateManager.applyUpdate()
  391. }
  392. }
  393. })
  394. })
  395. updateManager.onUpdateFailed(function () {
  396. // 新的版本下载失败
  397. uni.showModal({
  398. title: '已经有新版本了哟~',
  399. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  400. })
  401. })
  402. }
  403. })
  404. }
  405. },
  406. }
  407. }
  408. </script>
  409. <style lang="scss" scoped>
  410. .content {
  411. width: 100%;
  412. height: 100vh;
  413. display: flex;
  414. flex-direction: column;
  415. padding: 0;
  416. .content-top{
  417. .top-banner{
  418. padding: 20upx 30upx 0;
  419. .banner{
  420. width:100%;
  421. height: 140px;
  422. }
  423. }
  424. }
  425. .content-bottom{
  426. padding: 0 30upx 30upx;
  427. background-color: #f5f5f5;
  428. .bottom-new-notice{
  429. background-image: url('../../static/home_bg_expressage.png');
  430. background-size: 100% 100%;
  431. height:220upx;
  432. margin-top: 30upx;
  433. display: flex;
  434. justify-content: space-between;
  435. align-items: center;
  436. padding: 20upx 30upx;
  437. .notice-content{
  438. .notice-content-item{
  439. margin: 15upx 0;
  440. display: flex;
  441. align-items: center;
  442. .item-title{
  443. display: inline-block;
  444. margin-left: 20upx;
  445. }
  446. }
  447. .notice-content-item:last-child{
  448. font-size: 26upx;
  449. font-family: PingFang SC;
  450. font-weight: 400;
  451. color: #7C7D7E;
  452. }
  453. }
  454. .notice-static{
  455. width:186upx;
  456. height: 108upx;
  457. background-image: url('../../static/home_sign_rider.png');
  458. background-size:100% 100%;
  459. .notice-static-text{
  460. position: relative;
  461. top:21upx;
  462. left:85upx
  463. }
  464. }
  465. }
  466. .bottom-zhiyin{
  467. margin: 30upx 0;
  468. }
  469. .bottom-order{
  470. padding: 50upx 86upx;
  471. margin:30upx 0 56upx;
  472. background: #FFFFFF;
  473. box-shadow: 0px 18px 35px rgba(1, 136, 209, 0.1);
  474. opacity: 1;
  475. border-radius: 12px;
  476. .order-type{
  477. text-align: center;
  478. .type{
  479. font-size: 42upx;
  480. font-weight: bold;
  481. color: #000000;
  482. margin-top: 10upx;
  483. }
  484. .type-saoma{
  485. margin-top: 35upx;
  486. }
  487. .type-info{
  488. color:#999999;
  489. font-size: 24upx;
  490. font-weight: 400;
  491. margin-top: 10upx;
  492. }
  493. }
  494. }
  495. .statistics-title{
  496. font-size: 36upx;
  497. font-family: PingFang SC;
  498. font-weight: bold;
  499. color: #191919;
  500. opacity: 1;
  501. margin-bottom: 30upx;
  502. }
  503. .statistics-box{
  504. padding: 20upx 30upx;
  505. margin-bottom: 30upx;
  506. background-color: #FFFFFF;
  507. border-radius: 12px;
  508. .rubbishType-type{
  509. margin-bottom: 36upx;
  510. font-size: 28upx;
  511. font-weight: 400;
  512. color: #000000;
  513. }
  514. .rubbish{
  515. font-size:24upx;
  516. // overflow-x: scroll;
  517. .rubbishType-item{
  518. display: flex;
  519. flex-direction: column;
  520. align-items: center;
  521. min-width: 24.5%;
  522. }
  523. }
  524. .swiper{
  525. height: 200rpx;
  526. }
  527. }
  528. .statistics-box:last-child{
  529. margin-bottom:0 ;
  530. }
  531. }
  532. }
  533. </style>