Commit 047475bb authored by ljd's avatar ljd

内容滚动初始化

parent 11477121
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<input class="input" maxlength="10" v-model="food.count" type="number" /> <input class="input" maxlength="10" v-model="food.count" type="number" />
<!-- {{food.count}} --> <!-- {{food.count}} -->
</div> </div>
<div class="cart-add cart-btn" @click="addCart">+</div> <div class="cart-add cart-btn" @click.stop.prevent="addCart">+</div>
</div> </div>
</template> </template>
...@@ -26,16 +26,16 @@ export default { ...@@ -26,16 +26,16 @@ export default {
}, },
methods: { methods: {
addCart(event) { addCart(event) {
console.log(event,'event') console.log(event, 'event')
// if (!event._constructed) { // if (!event._constructed) {
// return // return
// } // }
// if (!this.food.count) { if (!this.food.count) {
// Vue.set(this.food, 'count', 1) Vue.set(this.food, 'count', 1)
// } else { } else {
// this.food.count++ this.food.count++
// } }
// this.$emit('cart-add', event.target) this.$emit('cart-add', event.target)
}, },
decreaseCart() { decreaseCart() {
if (this.food.count) { if (this.food.count) {
...@@ -79,6 +79,7 @@ export default { ...@@ -79,6 +79,7 @@ export default {
input{font-size:px2px(24);max-width:px2px(150);border-bottom:1px solid #aeb0b3;text-align: center;} input{font-size:px2px(24);max-width:px2px(150);border-bottom:1px solid #aeb0b3;text-align: center;}
} }
.cart-btn{ .cart-btn{
cursor: pointer;
vertical-align:middle; vertical-align:middle;
display:inline-block; display:inline-block;
height:px2px(40); height:px2px(40);
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<script> <script>
import BScroll from 'better-scroll' import BScroll from 'better-scroll'
import cartcontrol from '@/views/h5/haier/components/goods/cartcontrol' import cartcontrol from '@/views/pc/haier/components/goods/cartcontrol'
export default { export default {
components: { components: {
cartcontrol cartcontrol
......
...@@ -58,10 +58,11 @@ import { ...@@ -58,10 +58,11 @@ import {
getVap getVap
} from '@/api/haier/order/service' } from '@/api/haier/order/service'
import { Toast, Indicator } from 'mint-ui' import { Toast, Indicator } from 'mint-ui'
import BScroll from 'better-scroll' import BScroll from 'better-scroll'
import shopcart from '@/views/h5/haier/components/goods/shopcart.vue' import shopcart from '@/views/pc/haier/components/goods/shopcart.vue'
import cartcontrol from '@/views/h5/haier/components/goods/cartcontrol' import cartcontrol from '@/views/pc/haier/components/goods/cartcontrol'
export default { export default {
name: 'HaierOrderService', name: 'HaierOrderService',
components: { components: {
...@@ -119,6 +120,7 @@ export default { ...@@ -119,6 +120,7 @@ export default {
computed: { computed: {
}, },
created() { created() {
this.scrollY = 0
if (this.$route.query.orderId) { if (this.$route.query.orderId) {
this.inApp = false this.inApp = false
this.getOrderId(this.$route.query.orderId) this.getOrderId(this.$route.query.orderId)
...@@ -137,6 +139,19 @@ export default { ...@@ -137,6 +139,19 @@ export default {
}, },
methods: { methods: {
foodPageScorll() {
const foodList = this.$refs.foodsWrapper.getElementsByClassName(
'food-list-hook'
)
const foodWrapper = document.getElementsByClassName(
'foods-wrapper'
)
console.log(foodWrapper, 'foodWrapper')
foodWrapper[0].addEventListener('scroll', el => {
this.scrollY = foodWrapper[0].scrollTop
})
},
getOrderId(orderId) { getOrderId(orderId) {
this.orderId = orderId || '6099514' this.orderId = orderId || '6099514'
this.getList() this.getList()
...@@ -191,10 +206,11 @@ export default { ...@@ -191,10 +206,11 @@ export default {
}) })
return false return false
} }
// this.$nextTick(() => { this.$nextTick(() => {
// this._initScroll() this.foodPageScorll()
// this._calculateHeight() // this._initScroll()
// }) this._calculateHeight()
})
}).catch((error) => { }).catch((error) => {
this.loading = false this.loading = false
Indicator.close() Indicator.close()
...@@ -209,9 +225,9 @@ export default { ...@@ -209,9 +225,9 @@ export default {
this.$refs.food.show() this.$refs.food.show()
}, },
selectMenu(index, event) { selectMenu(index, event) {
if (!event._constructed) { // if (!event._constructed) {
return // return
} // }
const foodList = this.$refs.foodsWrapper.getElementsByClassName( const foodList = this.$refs.foodsWrapper.getElementsByClassName(
'food-list-hook' 'food-list-hook'
) )
...@@ -226,7 +242,8 @@ export default { ...@@ -226,7 +242,8 @@ export default {
el = foodList[foodList.length - 1] el = foodList[foodList.length - 1]
} }
this.currentTime = new Date().getTime() this.currentTime = new Date().getTime()
this.foodsScroll.scrollToElement(el, 0) window.scrollTo(0, 1000)
// this.foodsScroll.scrollToElement(el, 0)
}, },
_initScroll() { _initScroll() {
this.menuScroll = new BScroll(this.$refs.menuWrapper, { this.menuScroll = new BScroll(this.$refs.menuWrapper, {
...@@ -355,5 +372,7 @@ export default { ...@@ -355,5 +372,7 @@ export default {
.cartcontrol .cart-add {display:inline-block;padding:6px;font-size:24px;line-height:24px;color:#00a0dc;} .cartcontrol .cart-add {display:inline-block;padding:6px;font-size:24px;line-height:24px;color:#00a0dc;}
// only for pc // only for pc
.goods .foods-wrapper{overflow: auto;}
.goods .menu-wrapper{overflow: auto;}
.goods .menu-wrapper .menu-item{cursor: pointer;}
</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