index.vue 14 KB

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