Fix:3116 【商城小程序】全国特产,搜索页面,右上角需要增加购物车按钮,右上角红点显示当前购物车商品数,点击进入购物车页面
This commit is contained in:
@@ -15,6 +15,11 @@
|
||||
mode="scaleToFill"
|
||||
@click="searchHandle"></image>
|
||||
</view>
|
||||
<view @click="goShoppingCart()" class="item animated bounceIn">
|
||||
<view class="iconfont icon-gouwuche1">
|
||||
<text class="num bg-color-lightred" v-if="CartCount > 0">{{ CartCount > 99 ? '99+' : CartCount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="line-location flex ai-center">
|
||||
<image :src="webUrl+'/20220903142929759087.png'" mode="scaleToFill"></image>
|
||||
@@ -84,6 +89,10 @@ import { fetchNormal, getCategory } from "@/api/store"
|
||||
import { pageListenMixins } from '@/mixins/pageListenMixins'
|
||||
import ProductWindow from '@/components/ProductWindow'
|
||||
import goCartMixin from '@/mixins/goCartMixins'
|
||||
import { mapGetters } from 'vuex'
|
||||
import {
|
||||
getCartCount,
|
||||
} from '@/api/store'
|
||||
export default {
|
||||
name: 'NativeListPage',
|
||||
components: {
|
||||
@@ -92,6 +101,7 @@ export default {
|
||||
mixins: [pageListenMixins, goCartMixin],
|
||||
data() {
|
||||
return {
|
||||
CartCount: 0,
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
keyword: '',
|
||||
dataList: [],
|
||||
@@ -103,13 +113,29 @@ export default {
|
||||
pageKeyId: ''
|
||||
}
|
||||
},
|
||||
computed: mapGetters(['isLogin', 'location', 'userInfo']),
|
||||
onLoad(option) {
|
||||
const cityId = option.cityId
|
||||
this.cityId = cityId
|
||||
this.pageKeyId = `goodsProductList_cityId_${cityId}`
|
||||
this.init()
|
||||
this.getCartCount()
|
||||
},
|
||||
methods: {
|
||||
// 获取购物车数量
|
||||
getCartCount () {
|
||||
const isLogin = this.isLogin
|
||||
if (isLogin) {
|
||||
getCartCount({
|
||||
numType: 0
|
||||
}).then(res => {
|
||||
this.CartCount = res.data.count
|
||||
})
|
||||
}
|
||||
},
|
||||
goShoppingCart() {
|
||||
this.$yrouter.switchTab('/pages/cart')
|
||||
},
|
||||
init() {
|
||||
const memCityName = uni.getStorageSync('cityName')
|
||||
if (memCityName.length) {
|
||||
@@ -181,14 +207,33 @@ export default {
|
||||
|
||||
<style scoped lang="less">
|
||||
@import "@/assets/css/product.less";
|
||||
|
||||
.iconfont{
|
||||
position: relative;
|
||||
}
|
||||
.item .iconfont.icon-gouwuche1 .num {
|
||||
right: -15rpx !important;
|
||||
top: -15rpx!important;
|
||||
font-size: 20rpx;
|
||||
position: absolute;
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
background: #C52733 !important;
|
||||
color: #fff;
|
||||
border-radius: 50%;
|
||||
text-align: center;
|
||||
padding: 2rpx;
|
||||
}
|
||||
.pkg-product-list {
|
||||
height: 100vh;
|
||||
overflow-y: hidden;
|
||||
|
||||
.top-box {
|
||||
height: 82rpx;
|
||||
background: #FF564A;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: #fff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.line-location {
|
||||
|
||||
Reference in New Issue
Block a user