123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537 |
- <template>
- <view class="content">
- <view class="content-top">
- <view class="top-banner">
- <u-swiper :list="bannerList" class="banner"></u-swiper>
- </view>
- </view>
- <view class="content-bottom">
- <!-- 接单信息 -->
- <view class="bottom-new-notice" v-if="orderTime" @click="checkOrderDetail()">
- <view class="notice-content">
- <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>
- <view class="notice-content-item"></view>
- </view>
- </view>
- <!-- 下单 -->
- <view class="bottom-order flex justify_between align_center">
- <view class="order-type flex flex_column justify_center" @click="gotoSaoMa">
- <u-image src="/static/index/home_icon_code.png" width="186rpx" height="144rpx"></u-image>
- <view class="type type-saoma">扫码下单</view>
- <view class="type-info">在线下单</view>
- </view>
- <view class="order-type flex flex_column justify_center" @click="gotoYueYu">
- <u-image src="/static/index/home_icon.png" width="176rpx" height="164rpx"></u-image>
- <view class="type">自主下单</view>
- <view class="type-info">免费上门回收</view>
- </view>
- </view>
- <!-- 收回统计 -->
- <view class="statistics-title">今日上门回收价格</view>
- <view>
- <!-- 纸张类 -->
- <view class="statistics-box" v-if="rubbishPaperList.length">
- <view class="rubbishType-type">
- {{rubbishPaperName ? rubbishPaperName :''}}
- </view>
- <swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
- <swiper-item v-for="(item,index) in rubbishPaperList" :key="index">
- <view class="flex rubbish">
- <view v-for="key in item" class="rubbishType-item">
- <u-image :src="key.image" width="92" height="92"></u-image>
- <span>{{key.name ? key.name :''}}</span><span>{{key.customerPrice ? (key.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
- </view>
- </view>
- </swiper-item>
- </swiper>
- </view>
- <!-- 塑料类 -->
- <view class="statistics-box" v-if="rubbishSLList.length">
- <view class="rubbishType-type">
- {{rubbishSLName ? rubbishSLName :''}}
- </view>
- <swiper class="swiper" :indicator-dots="indicatorDotsSL" :autoplay="autoplay" :interval="interval" :duration="duration">
- <swiper-item v-for="(item,index) in rubbishSLList" :key="index">
- <view class="flex rubbish">
- <view v-for="key in item" class="rubbishType-item">
- <u-image :src="key.image" width="92" height="92"></u-image>
- <span>{{key.name ? key.name :''}}</span><span>{{key.customerPrice ? (key.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
- </view>
- </view>
- </swiper-item>
- </swiper>
- </view>
- <!-- 金属类 -->
- <view class="statistics-box" v-if="rubbishJSList.length">
- <view class="rubbishType-type">
- {{rubbishJSName ? rubbishJSName :''}}
- </view>
- <swiper class="swiper" :indicator-dots="indicatorDotsJS" :autoplay="autoplaySL" :interval="interval" :duration="duration">
- <swiper-item v-for="(item,index) in rubbishJSList" :key="index">
- <view class="flex rubbish">
- <view v-for="key in item" class="rubbishType-item">
- <u-image :src="key.image" width="92" height="92"></u-image>
- <span>{{key.name ? key.name :''}}</span><span>{{key.customerPrice ? (key.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
- </view>
- </view>
- </swiper-item>
- </swiper>
- </view>
- <!-- 衣物类 -->
- <view class="statistics-box" v-if="rubbishYWList.length">
- <view class="rubbishType-type">
- {{rubbishYWName ? rubbishYWName :''}}
- </view>
- <swiper class="swiper" :indicator-dots="indicatorDotsYW" :autoplay="autoplaySL" :interval="interval" :duration="duration">
- <swiper-item v-for="(item,index) in rubbishYWList" :key="index">
- <view class="flex rubbish">
- <view v-for="key in item" class="rubbishType-item">
- <u-image :src="key.image" width="92" height="92"></u-image>
- <span>{{key.name ? key.name :''}}</span><span>{{key.customerPrice ? (key.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
- </view>
- </view>
- </swiper-item>
- </swiper>
- </view>
- <view class="nodata" v-if="rubbishPriceList.length==0">
- <u-empty src="/static/def_result.png" :text="noDataText" icon-size="260" ></u-empty>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {getBannerList,geRubbishType,orderStatus} from '@/api/index'
- import { checkLogin } from '@/api/login.js'
- export default {
- components: { },
- data() {
- return {
- yuYueBtn:{
- background: "#4F88F7",
- borderRadius: "12px",
- color:'#fff',
- },
- hasLogin:false, // 是否登录
- noDataText:"", // 未登录提示文字
- orderTime:'', // 创建时间
- bannerList:[],
- rubbishPaperName:"",
- rubbishSLName:"",
- rubbishYWName:"",
- rubbishJSName:"",
- rubbishPaperList:[],
- rubbishSLList:[],
- rubbishYWList:[],
- rubbishJSList:[],
- rubbishPriceList:[],
- orderId:'' ,// 订单id
- indicatorDots: true,
- autoplay: false,
- interval: 2000,
- duration: 500,
- indicatorDotsSL:false,
- indicatorDotsJS:false,
- indicatorDotsYW:false
- }
- },
- onLoad() {
- this.geRubbishTypeList()
- this.pageInit()
- },
- onUnload() {
-
- },
- onShareAppMessage(res) {
- },
- onShareTimeline(res) {
- },
- onShow() {
- this.geRubbishTypeList()
- checkLogin().then(res => {
- this.hasLogin=res.status==200
- if(this.hasLogin){
- this.pageInit()
- }else{
- this.noDataText="您尚未登录或登录已过期,完成登录后可查看数据信息!"
- }
- })
- },
- methods: {
- pageInit() {
- this.orderTime=''
- this.getBanner()
- this.getOrderStatus()
- this.checkUpdate()
- },
- // 获取banner图
- getBanner(){
- getBannerList().then(res=>{
- if(res.status==200){
- this.bannerList=res.data || []
- }
- })
- },
- // 获取订单状态
- getOrderStatus(){
- orderStatus().then(res=>{
- if(res.status==200){
- this.orderId=res.data.id
- this.orderTime=res.data.createDate
- }
- })
- },
- // 查看订单详情
- checkOrderDetail(){
- uni.navigateTo({
- url:`/pages/order/orderDetails?id=${this.orderId}`
- })
- },
- // 获取垃圾分类
- geRubbishTypeList(){
- geRubbishType().then(res=>{
- if(res.status==200){
- this.rubbishPriceList=res.data
- const a= res.data.find(item=>item.code=='PAPER')
- const b= res.data.find(item=>item.code=='PLASTIC')
- const c= res.data.find(item=>item.code=='CLOTHES')
- const d= res.data.find(item=>item.code=='METAL')
- console.log(res.data,a,b,c,d,'000000000000000')
- /* 纸张类 */
- if(a){
- if (a.rubbishTypeVOList.length > 4) {
- this.indicatorDots=true
- let num=Math.ceil(a.rubbishTypeVOList.length/4)
- let arr = []
- for (var i = 0; i < num; i++) {
- arr[i]=a.rubbishTypeVOList.slice(i*4,(i+1)*4)
- console.log(arr,'===========arr')
- }
- this.rubbishPaperList= arr
- } else {
- this.indicatorDots=false
- this.rubbishPaperList = a.rubbishTypeVOList.length?[a.rubbishTypeVOList]:[]
- }
- console.log(this.rubbishPaperList, '--------aaaaaa')
- }
- this.rubbishPaperList.map(item=>{
- item.map(item=>{
- if(item.code=='YELLOW_PAPER'){
- item.image='/static/index/icon_aper_yellow.png'
- }
- if(item.code=='COLOUR_PAPER'){
- item.image='/static/index/icon_aper_flower.png'
- }
- if(item.code=='BOOK_PAPER'){
- item.image='/static/index/icon_book.png'
- }
- if(item.code=='MAGAZINE'){
- item.image='/static/index/icon_magazine.png'
- }
- if(item.code=='OTHER_PAPER'){
- item.image='/static/index/icon_aper_miscellaneous.png'
- }
- if(item.code=='NEWS_PAPER'){
- item.image='/static/index/icon_newspaper.png'
- }
- })
- })
- // 塑料类
- if(b){
- if (b.rubbishTypeVOList.length > 4) {
- this.indicatorDotsSL=true
- let num=Math.ceil(a.rubbishTypeVOList.length/4)
- let arr = []
- for (var i = 0; i < num; i++) {
- arr[i]=a.rubbishTypeVOList.slice(i*4,(i+1)*4)
- console.log(arr,'===========arr')
- }
- this.rubbishSLList= arr
- } else {
- this.indicatorDotsSL=false
- this.rubbishSLList = b.rubbishTypeVOList.length?[b.rubbishTypeVOList]:[]
- }
- console.log(this.rubbishSLList, '--------aaaaaa')
- }
- this.rubbishSLList.map(item=>{
- item.map(item=>{
- if(item.code=='PLASTIC_WHITE'){
- item.image='/static/index/icon_frame_white.png'
- }
- if(item.code=='PLASTIC_BLACK'){
- item.image='/static/index/icon_frame_black.png'
- }
- if(item.code=='PMMA'){
- item.image='/static/index/icon_acrylic.png'
- }
- if(item.code=='PLASTIC_LUCENCY'){
- item.image='/static/index/icon_bottle.png'
- }
- })
- })
- // 衣物
- if(c){
- if (c.rubbishTypeVOList.length > 4) {
- this.indicatorDotsJS=true
- let num=Math.ceil(a.rubbishTypeVOList.length/4)
- let arr = []
- for (var i = 0; i < num; i++) {
- arr[i]=a.rubbishTypeVOList.slice(i*4,(i+1)*4)
- console.log(arr,'===========arr')
- }
- this.rubbishYWList= arr
- } else {
- this.indicatorDotsJS=false
- this.rubbishYWList =c.rubbishTypeVOList.length?[c.rubbishTypeVOList]:[]
- }
- console.log(this.rubbishYWList, '--------aaaaaa')
- }
- this.rubbishYWList.map(item=>{
- item.map(item=>{
- if(item.code=='SIMPLE_CLOTHES'){
- item.image='/static/index/icon_clothes.png'
- }
- })
- })
- // 金属
- if(d){
- if (d.rubbishTypeVOList.length > 4) {
- this.indicatorDotsYW=true
- let num=Math.ceil(a.rubbishTypeVOList.length/4)
- let arr = []
- for (var i = 0; i < num; i++) {
- arr[i]=a.rubbishTypeVOList.slice(i*4,(i+1)*4)
- console.log(arr,'===========arr')
- }
- this.rubbishJSList= arr
- } else {
- this.indicatorDotsYW=false
- this.rubbishJSList =d.rubbishTypeVOList.length?[d.rubbishTypeVOList]:[]
- }
- console.log(this.rubbishJSList, '--------aaaaaa')
- }
- this.rubbishJSList.map(item=>{
- item.map(item=>{
- if(item.code=='THIN_IRON'){
- item.image='/static/index/icon_iron_thin.png'
- }
- if(item.code=='THICK_IRON'){
- item.image='/static/index/icon_iron_thick.png'
- }
- if(item.code=='STAINLESS_IRON'){
- item.image='/static/index/icon_steel.png'
- }
- })
- })
- this.rubbishPaperName=a?a.name:''
- this.rubbishSLName=b?b.name:''
- this.rubbishYWName=c?c.name:''
- this.rubbishJSName=d?d.name:''
- }
- })
- },
- // 扫码下单
- gotoSaoMa(){
- if(this.hasLogin){
- wx.scanCode({
- success: (res)=> {
- uni.navigateTo({
- url: '/pages/index/order'
- })
- }
- })
- }else{
- this.loginModal()
- }
- },
- // 自主下单
- gotoYueYu(){
- if(this.hasLogin){
- uni.navigateTo({
- url: '/pages/index/order'
- })
- }else{
- this.loginModal()
- }
- },
- // 未登录弹窗
- loginModal(){
- uni.showModal({
- title: '提示',
- content: '您尚未登录或登录已过期,请登录后使用',
- success: (res)=> {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/login/login'
- })
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- },
- // 检查更新
- checkUpdate(){
- if (uni.canIUse('getUpdateManager')) {
- const updateManager = uni.getUpdateManager()
- updateManager.onCheckForUpdate(function (res) {
- console.log('onCheckForUpdate====', res)
- // 请求完新版本信息的回调
- if (res.hasUpdate) {
- console.log('res.hasUpdate====')
- updateManager.onUpdateReady(function () {
- uni.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success: function (res) {
- console.log('success====', res)
- // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate()
- }
- }
- })
- })
- updateManager.onUpdateFailed(function () {
- // 新的版本下载失败
- uni.showModal({
- title: '已经有新版本了哟~',
- content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
- })
- })
- }
- })
- }
- },
-
- }
- }
- </script>
- <style lang="scss" scoped>
- .content {
- width: 100%;
- height: 100vh;
- display: flex;
- flex-direction: column;
- padding: 0;
- .content-top{
- .top-banner{
- padding: 20upx 30upx 0;
- .banner{
- width:100%;
- height: 140px;
- }
- }
- }
- .content-bottom{
- padding: 0 30upx 30upx;
- background-color: #f5f5f5;
- .bottom-new-notice{
- background-image: url('../../static/home_bg_expressage.png');
- background-size: 100% 100%;
- height:220upx;
- margin-top: 30upx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 20upx 30upx;
- .notice-content{
- .notice-content-item{
- margin: 15upx 0;
- display: flex;
- align-items: center;
- .item-title{
- display: inline-block;
- margin-left: 20upx;
- }
- }
- .notice-content-item:last-child{
- font-size: 26upx;
- font-family: PingFang SC;
- font-weight: 400;
- color: #7C7D7E;
- }
- }
- .notice-static{
- width:186upx;
- height: 108upx;
- background-image: url('../../static/home_sign_rider.png');
- background-size:100% 100%;
- .notice-static-text{
- position: relative;
- top:21upx;
- left:85upx
- }
- }
- }
- .bottom-zhiyin{
- margin: 30upx 0;
- }
- .bottom-order{
- padding: 50upx 86upx;
- margin:30upx 0 56upx;
- background: #FFFFFF;
- box-shadow: 0px 18px 35px rgba(1, 136, 209, 0.1);
- opacity: 1;
- border-radius: 12px;
- .order-type{
- text-align: center;
- .type{
- font-size: 42upx;
- font-weight: bold;
- color: #000000;
- margin-top: 10upx;
- }
- .type-saoma{
- margin-top: 35upx;
- }
- .type-info{
- color:#999999;
- font-size: 24upx;
- font-weight: 400;
- margin-top: 10upx;
- }
- }
- }
- .statistics-title{
- font-size: 36upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #191919;
- opacity: 1;
- margin-bottom: 30upx;
- }
- .statistics-box{
- padding: 20upx 30upx;
- margin-bottom: 30upx;
- background-color: #FFFFFF;
- border-radius: 12px;
- .rubbishType-type{
- margin-bottom: 36upx;
- font-size: 28upx;
- font-weight: 400;
- color: #000000;
- }
- .rubbish{
- font-size:24upx;
- // overflow-x: scroll;
- .rubbishType-item{
- display: flex;
- flex-direction: column;
- align-items: center;
- min-width: 24.5%;
- }
- }
- .swiper{
- height: 200rpx;
- }
- }
- .statistics-box:last-child{
- margin-bottom:0 ;
- }
- }
- }
- </style>
|