index.vue 14 KB

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