index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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.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. // 扫码下单
  262. gotoSaoMa(){
  263. if(this.hasLogin){
  264. wx.scanCode({
  265. success: (res)=> {
  266. uni.navigateTo({
  267. url: '/pages/index/YY'
  268. })
  269. console.log(res,'----------------res===================')
  270. }
  271. })
  272. }else{
  273. this.loginModal()
  274. }
  275. },
  276. // 自主下单
  277. gotoYueYu(){
  278. if(this.hasLogin){
  279. uni.navigateTo({
  280. url: '/pages/index/YY'
  281. })
  282. }else{
  283. this.loginModal()
  284. }
  285. },
  286. // 回收指引
  287. toZY(){
  288. uni.navigateTo({
  289. url: '/pages/index/zhiyin'
  290. })
  291. },
  292. // 未登录弹窗
  293. loginModal(){
  294. uni.showModal({
  295. title: '提示',
  296. content: '您尚未登录或登录已过期,请登录后使用',
  297. success: (res)=> {
  298. if (res.confirm) {
  299. uni.navigateTo({
  300. url: '/pages/login/login'
  301. })
  302. } else if (res.cancel) {
  303. console.log('用户点击取消');
  304. }
  305. }
  306. });
  307. },
  308. // 检查更新
  309. checkUpdate(){
  310. if (uni.canIUse('getUpdateManager')) {
  311. const updateManager = uni.getUpdateManager()
  312. updateManager.onCheckForUpdate(function (res) {
  313. console.log('onCheckForUpdate====', res)
  314. // 请求完新版本信息的回调
  315. if (res.hasUpdate) {
  316. console.log('res.hasUpdate====')
  317. updateManager.onUpdateReady(function () {
  318. uni.showModal({
  319. title: '更新提示',
  320. content: '新版本已经准备好,是否重启应用?',
  321. success: function (res) {
  322. console.log('success====', res)
  323. // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
  324. if (res.confirm) {
  325. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  326. updateManager.applyUpdate()
  327. }
  328. }
  329. })
  330. })
  331. updateManager.onUpdateFailed(function () {
  332. // 新的版本下载失败
  333. uni.showModal({
  334. title: '已经有新版本了哟~',
  335. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  336. })
  337. })
  338. }
  339. })
  340. }
  341. },
  342. }
  343. }
  344. </script>
  345. <style lang="scss" scoped>
  346. .content {
  347. width: 100%;
  348. height: 100vh;
  349. display: flex;
  350. flex-direction: column;
  351. padding: 0;
  352. .content-top{
  353. // width: 100%;
  354. // height:260upx ;
  355. // background-color: #4F88F7;
  356. // border-bottom-left-radius: 50%; /* 左下角 */
  357. // border-bottom-right-radius:50%; /* 右下角 */
  358. // opacity: 1;
  359. .top-banner{
  360. padding: 20upx 30upx 0;
  361. .banner{
  362. width:100%;
  363. height: 140px;
  364. }
  365. }
  366. }
  367. .content-bottom{
  368. padding: 0 30upx 30upx;
  369. background-color: #f5f5f5;
  370. .bottom-new-notice{
  371. background-image: url('../../static/home_bg_expressage.png');
  372. background-size: 100% 100%;
  373. height:220upx;
  374. margin-top: 30upx;
  375. display: flex;
  376. justify-content: space-between;
  377. align-items: center;
  378. padding: 20upx 30upx;
  379. .notice-content{
  380. .notice-content-item{
  381. margin: 15upx 0;
  382. display: flex;
  383. align-items: center;
  384. .item-title{
  385. display: inline-block;
  386. margin-left: 20upx;
  387. }
  388. }
  389. .notice-content-item:last-child{
  390. font-size: 26upx;
  391. font-family: PingFang SC;
  392. font-weight: 400;
  393. color: #7C7D7E;
  394. }
  395. }
  396. .notice-static{
  397. width:186upx;
  398. height: 108upx;
  399. background-image: url('../../static/home_sign_rider.png');
  400. background-size:100% 100%;
  401. .notice-static-text{
  402. position: relative;
  403. top:21upx;
  404. left:85upx
  405. }
  406. }
  407. }
  408. .bottom-zhiyin{
  409. margin: 30upx 0;
  410. }
  411. .bottom-order{
  412. padding: 50upx 86upx;
  413. margin:30upx 0 56upx;
  414. background: #FFFFFF;
  415. box-shadow: 0px 18px 35px rgba(1, 136, 209, 0.1);
  416. opacity: 1;
  417. border-radius: 12px;
  418. .order-type{
  419. text-align: center;
  420. .type{
  421. font-size: 42upx;
  422. font-weight: bold;
  423. color: #000000;
  424. margin-top: 10upx;
  425. }
  426. .type-saoma{
  427. margin-top: 35upx;
  428. }
  429. .type-info{
  430. color:#999999;
  431. font-size: 24upx;
  432. font-weight: 400;
  433. margin-top: 10upx;
  434. }
  435. }
  436. }
  437. .statistics-title{
  438. font-size: 36upx;
  439. font-family: PingFang SC;
  440. font-weight: bold;
  441. color: #191919;
  442. opacity: 1;
  443. margin-bottom: 30upx;
  444. }
  445. .statistics-box{
  446. padding: 20upx 30upx;
  447. margin-bottom: 30upx;
  448. background-color: #FFFFFF;
  449. border-radius: 12px;
  450. .rubbishType-type{
  451. margin-bottom: 36upx;
  452. font-size: 28upx;
  453. font-weight: 400;
  454. color: #000000;
  455. }
  456. .rubbish{
  457. font-size:24upx;
  458. overflow-x: scroll;
  459. .rubbishType-item{
  460. display: flex;
  461. flex-direction: column;
  462. align-items: center;
  463. min-width: 24.5%;
  464. }
  465. }
  466. }
  467. .statistics-box:last-child{
  468. margin-bottom:0 ;
  469. }
  470. }
  471. }
  472. </style>