index.vue 15 KB

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