Commit fd3f483e authored by ljd's avatar ljd

页面滚动

parent 047475bb
<template>
<div id="app">
<router-view />
</div>
</template>
<style lang="less">
@import './assets/css/base.css';
@import './assets/css/base_pc.css';
@import './assets/css/common.less';
@import './assets/css/custom.less';
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
</style>
/* 修改原生的滚动条 */
::-webkit-scrollbar {
/* 血槽宽度 */
width: 8px;
height: 8px;
}
::-webkit-scrollbar-thumb {
/* 拖动条 */
background: rgba(0, 0, 0, 0.3);
border-radius: 6px;
}
::-webkit-scrollbar-track {
/* 背景槽 */
background: #ddd;
border-radius: 6px;
}
\ No newline at end of file
import Vue from 'vue' import Vue from 'vue'
import App from './App.vue' import App from './App_pc.vue'
import router from './router/index' import router from './router/index'
// import store from './store' // import store from './store'
import 'lib-flexible' import 'lib-flexible'
......
<template> <template>
<div class="about" v-show="!loading"> <div class="about">
<!-- <mt-header title="材料辅料选择"> <!-- <mt-header title="材料辅料选择">
<router-link slot="left" to="/"> <router-link slot="left" to="/">
<mt-button icon="back" /> <mt-button icon="back" />
</router-link> </router-link>
</mt-header> --> </mt-header> -->
<div class="goods"> <div class="goods" v-loading="loading">
<div class="menu-wrapper" ref="menuWrapper"> <div class="menu-wrapper" ref="menuWrapper">
<ul> <ul>
<li <li
...@@ -57,9 +57,6 @@ import { ...@@ -57,9 +57,6 @@ import {
getAppreciationService, getAppreciationService,
getVap getVap
} from '@/api/haier/order/service' } from '@/api/haier/order/service'
import { Toast, Indicator } from 'mint-ui'
import BScroll from 'better-scroll'
import shopcart from '@/views/pc/haier/components/goods/shopcart.vue' import shopcart from '@/views/pc/haier/components/goods/shopcart.vue'
import cartcontrol from '@/views/pc/haier/components/goods/cartcontrol' import cartcontrol from '@/views/pc/haier/components/goods/cartcontrol'
...@@ -140,18 +137,13 @@ export default { ...@@ -140,18 +137,13 @@ export default {
}, },
methods: { methods: {
foodPageScorll() { foodPageScorll() {
const foodList = this.$refs.foodsWrapper.getElementsByClassName(
'food-list-hook'
)
const foodWrapper = document.getElementsByClassName( const foodWrapper = document.getElementsByClassName(
'foods-wrapper' 'foods-wrapper'
) )
console.log(foodWrapper, 'foodWrapper')
foodWrapper[0].addEventListener('scroll', el => { foodWrapper[0].addEventListener('scroll', el => {
this.scrollY = foodWrapper[0].scrollTop this.scrollY = foodWrapper[0].scrollTop
}) })
}, },
getOrderId(orderId) { getOrderId(orderId) {
this.orderId = orderId || '6099514' this.orderId = orderId || '6099514'
this.getList() this.getList()
...@@ -198,22 +190,16 @@ export default { ...@@ -198,22 +190,16 @@ export default {
} }
}) })
this.loading = false this.loading = false
Indicator.close()
if (txt !== '') { if (txt !== '') {
Toast({ this.$message.error(txt)
message: txt,
duration: 3000
})
return false return false
} }
this.$nextTick(() => { this.$nextTick(() => {
this.foodPageScorll() this.foodPageScorll()
// this._initScroll()
this._calculateHeight() this._calculateHeight()
}) })
}).catch((error) => { }).catch((error) => {
this.loading = false this.loading = false
Indicator.close()
console.log(error) console.log(error)
}) })
}, },
...@@ -225,9 +211,7 @@ export default { ...@@ -225,9 +211,7 @@ export default {
this.$refs.food.show() this.$refs.food.show()
}, },
selectMenu(index, event) { selectMenu(index, event) {
// if (!event._constructed) { let offsetTop = 0
// return
// }
const foodList = this.$refs.foodsWrapper.getElementsByClassName( const foodList = this.$refs.foodsWrapper.getElementsByClassName(
'food-list-hook' 'food-list-hook'
) )
...@@ -241,21 +225,9 @@ export default { ...@@ -241,21 +225,9 @@ export default {
} else { } else {
el = foodList[foodList.length - 1] el = foodList[foodList.length - 1]
} }
offsetTop = el.offsetTop
this.currentTime = new Date().getTime() this.currentTime = new Date().getTime()
window.scrollTo(0, 1000) foodWrapper[0].scrollTo(0, offsetTop)
// this.foodsScroll.scrollToElement(el, 0)
},
_initScroll() {
this.menuScroll = new BScroll(this.$refs.menuWrapper, {
click: true
})
this.foodsScroll = new BScroll(this.$refs.foodsWrapper, {
probeType: 3,
click: true
})
this.foodsScroll.on('scroll', pos => {
this.scrollY = Math.abs(Math.round(pos.y))
})
}, },
_calculateHeight() { _calculateHeight() {
const foodList = this.$refs.foodsWrapper.getElementsByClassName( const foodList = this.$refs.foodsWrapper.getElementsByClassName(
...@@ -375,4 +347,5 @@ export default { ...@@ -375,4 +347,5 @@ export default {
.goods .foods-wrapper{overflow: auto;} .goods .foods-wrapper{overflow: auto;}
.goods .menu-wrapper{overflow: auto;} .goods .menu-wrapper{overflow: auto;}
.goods .menu-wrapper .menu-item{cursor: pointer;} .goods .menu-wrapper .menu-item{cursor: pointer;}
.shopcart .shopcart-list .list-content{overflow: auto;}
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment