index.vue 14 KB

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