index.vue 13 KB

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