Task:点击购物车图标加入购物车

This commit is contained in:
modendeveloper
2025-01-14 23:42:33 +08:00
parent f8b6d72a59
commit 46b858b700
10 changed files with 485 additions and 24 deletions
+1
View File
@@ -21,6 +21,7 @@
<view class="flex jc-between ai-center">
<text class="price">¥{{ item.price }}</text>
<image
@click.stop="$emit('add', item)"
:src="webUrl + '/home/icon-cart.png'"
class="btn"
/>
+16 -2
View File
@@ -248,6 +248,7 @@
v-else
:item="item"
@view="goGoodsCon(item)"
@add="addToCart(item)"
/>
</view>
</view>
@@ -284,6 +285,7 @@
v-else
:item="item"
@view="goGoodsCon(item)"
@add="addToCart(item)"
/>
</view>
</view>
@@ -323,6 +325,15 @@
@click="setTopHandle"
/>
</u-back-top>
<ProductWindow
ref="attrWindow"
:attr="attr"
:cartNum="cart_num"
:showOk="true"
@changeFun="changeFun"
@ok="handleOk"
paddingBottom="200rpx"
/>
<xdd-tabbar :curr-index="0" />
</view>
</template>
@@ -334,6 +345,8 @@ import { getCouponReceive } from '@/api/user'
import { getHomeData, getShareImage } from '@/api/public'
import { sharpBannar } from '@/api/goods'
import { pageListenMixins } from '@/mixins/pageListenMixins'
import ProductWindow from '@/components/ProductWindow'
import goCartMixin from '@/mixins/goCartMixins'
import {
getCurAddress,
getLocationPromise,
@@ -344,9 +357,10 @@ export default {
name: 'IndexPage',
components: {
XddTabbar,
XddProductItem
XddProductItem,
ProductWindow
},
mixins: [pageListenMixins],
mixins: [pageListenMixins, goCartMixin],
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
+14 -3
View File
@@ -56,7 +56,7 @@
<information :landmarkDataId="landmarkDataId"></information>
</view>
<view v-if="actived === 4">
<goods :goods="goods" v-if="goods.length > 0"></goods>
<goods :goods="goods" v-if="goods.length > 0" @add='addToCart($event, "productId")'></goods>
<!-- <image
v-if="isCompleteLoadGood"
:src="webUrl + '/home/no-data-bg.png'"
@@ -76,6 +76,14 @@
:show-avatar="false"
/>
<shareImg ref="shareImg"></shareImg>
<ProductWindow
ref="attrWindow"
:attr="attr"
:cartNum="cart_num"
:showOk="true"
@changeFun="changeFun"
@ok="handleOk"
/>
</view>
</template>
@@ -87,10 +95,12 @@ import {
} from "@/api/product"
import goods from "./components/goods.vue"
import { pageListenMixins } from '@/mixins/pageListenMixins'
import goCartMixin from '@/mixins/goCartMixins'
import projects from './components/projects.vue'
import culture from "./components/culture.vue"
import information from "./components/information.vue"
import shareImg from "./components/shareImg.vue"
import ProductWindow from '@/components/ProductWindow'
export default {
name: 'LandMarkPage',
components: {
@@ -98,9 +108,10 @@ export default {
projects,
culture,
information,
shareImg
shareImg,
ProductWindow
},
mixins: [pageListenMixins],
mixins: [pageListenMixins, goCartMixin],
data() {
return {
actived: 1,
+14 -9
View File
@@ -29,7 +29,7 @@
<image :src="webUrl+'/20210806121714655368.png'" mode="" style="width: 36rpx;height: 36rpx;"></image>
</view>
</view>
<view v-if="couponListLimit2ToShow.length > 0 || attr.productSelect.earnPoints" class="v12-mt-1 v12-mb-3">
<view v-if="couponListLimit2ToShow.length > 0 || attr.productSelect.earnPoints" class="v12-mt-1 v12-mb-1">
<view class="cell flex jc-between ai-center">
<view v-if="couponListLimit2ToShow.length > 0" class="v12-justify-start">
<view
@@ -43,13 +43,7 @@
</view>
</view>
</view>
<view
v-if="attr.productSelect.earnPoints"
:class="couponListLimit2ToShow.length > 0 ? 'earn-points' : ''"
class="value value2 v12-font-24 v12-primary-text"
>
预计获得{{ attr.productSelect.earnPoints }}积分
</view>
<view
v-if="couponListLimit2ToShow.length > 0"
class="value value2 v12-font-24 v12-primary-text"
@@ -60,6 +54,13 @@
</view>
</view>
</view>
<view
v-if="attr.productSelect.earnPoints"
:class="couponListLimit2ToShow.length > 0 ? 'earn-points' : ''"
class="value value2 v12-font-24 v12-primary-text"
>
预计获得{{ attr.productSelect.earnPoints }}积分
</view>
</view>
<view class="introduce bold">{{ storeInfo.storeName }}</view>
<rich-text class="subInfo" :nodes="storeInfo.storeInfo" v-if="storeInfo.storeInfo"/>
@@ -1009,6 +1010,7 @@ export default {
// 产品详情接口
productCon() {
const from = this.location
if (this.$deviceType == 'app') {
from.from = 'app'
}
@@ -1332,6 +1334,8 @@ export default {
goCat(news) {
const that = this
const productSelect = this.getAttrItemData(this.attrValue)
console.log(this.attr);
// 打开属性
if (that.attrValue) {
// 默认选中了属性,但是没有打开过属性弹窗还是自动打开让用户查看默认选中的属性
@@ -2070,7 +2074,8 @@ export default {
}
.earn-points {
flex: 1;
padding: 0 0 0 12rpx;
// padding: 0 0 0 12rpx;
margin-bottom: 10rpx;
box-sizing: border-box;
}
</style>
+17 -4
View File
@@ -76,7 +76,10 @@
</view>
<view class="vip-money">¥{{ force2Decimal(item.otPrice) }}</view>
</view>
<view class="sale">已售{{ item.sales }}件</view>
<view class="" @click.stop="addToCart(item)">
<image class="logo" :src="webUrl+'/orderIcon/组 355.png'" mode="" style="margin-right:0; width: 34rpx; height:34rpx"/>
</view>
<!-- <view class="sale">已售{{ item.sales }}件</view> -->
</view>
</view>
</view>
@@ -160,26 +163,36 @@
v-if="searchType === 'good' && loadend && list.length === 0"
/>
</view>
<ProductWindow
ref="attrWindow"
:attr="attr"
:cartNum="cart_num"
:showOk="true"
@changeFun="changeFun"
@ok="handleOk"
/>
</view>
</template>
<script>
import { getProducts, getHotels } from '@/api/store'
import ProductWindow from '@/components/ProductWindow'
import { mapGetters } from 'vuex'
import NP from 'number-precision'
import NoGoodData from '@/components/good/NoData'
import Recommend from '@/components/Recommend'
import goCartMixin from '@/mixins/goCartMixins'
export default {
name: 'GoodsList',
components: {
NoGoodData,
ProductWindow,
Recommend
},
data: function () {
mixins: [goCartMixin],
data () {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
list: [],
query: {
page: 1,