云仓加入购物车

This commit is contained in:
THK3121 2023-09-11 18:59:59 +08:00
parent 8203989bff
commit e4966cdb51

View File

@ -132,10 +132,14 @@
30.00 30.00
</view> </view>
</view> </view>
<view class="good_price_r" @click="addcart(item.price)"> <!-- :style="{'transform': `translateY(${trnList[index].bottom}) translateX(${trnList[index].left})`,'transition':'1s'}" -->
<u--image class="act_class" :showLoading="true" <view class="good_price_r" @click.stop="addcart(item)">
<u--image :class="'act_class'+index" class="act_class"
:showLoading="true" src="/static/images/LHYC/J.png"
width="49.07rpx" height="49.07rpx"></u--image>
<!-- <u--image class="act_class" :showLoading="true"
src="/static/images/LHYC/J.png" width="49.07rpx" src="/static/images/LHYC/J.png" width="49.07rpx"
height="49.07rpx"></u--image> height="49.07rpx"></u--image> -->
</view> </view>
</view> </view>
@ -156,9 +160,11 @@
</view> </view>
</view> </view>
<view class="card" :style="`bottom:${appInfo.bottom}px`"> <view class="card" :style="`bottom:${appInfo.bottom}px`"
@click="navgo('/pages/order_addcart/order_addcart')">
<view class="left"> <view class="left">
<view class="" style="position: relative;"> <view class="cart" :class="{act_cart:act_cart}"
style="position: relative;z-index: 9999999;">
<u--image :showLoading="true" src="/static/images/LHYC/GWC.png" width="63.09rpx" <u--image :showLoading="true" src="/static/images/LHYC/GWC.png" width="63.09rpx"
height="63.09rpx"></u--image> height="63.09rpx"></u--image>
@ -175,7 +181,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class="right" @click="navgo('/pages/order_addcart/order_addcart')"> <view class="right">
去结算 去结算
</view> </view>
</view> </view>
@ -253,10 +259,15 @@
import { import {
goShopDetail goShopDetail
} from '@/libs/order.js' } from '@/libs/order.js'
import {
postCartAdd,
} from '@/api/store.js';
export default { export default {
data() { data() {
let src = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/13'; let src = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/13';
return { return {
trnList: [],
act_cart: false,
appInfo: {}, appInfo: {},
pocls: "", pocls: "",
type: "", type: "",
@ -280,6 +291,7 @@
headtop: 0, headtop: 0,
page_num: 1, page_num: 1,
act_img: "", act_img: "",
cartTagInfo: {},
actList: [{ actList: [{
tit: '综合', tit: '综合',
act: "", act: "",
@ -302,7 +314,6 @@
this.cartFn() this.cartFn()
uni.getSystemInfo({ uni.getSystemInfo({
success: (res) => { success: (res) => {
console.log(res)
this.winHeight = res.windowHeight this.winHeight = res.windowHeight
this.appInfo = res.safeAreaInsets this.appInfo = res.safeAreaInsets
}, },
@ -336,7 +347,6 @@
.in(this) .in(this)
.select('.content') .select('.content')
.boundingClientRect(rect => { .boundingClientRect(rect => {
// console.log(rect)
if (rect.top <= (this.headtop + 16)) { if (rect.top <= (this.headtop + 16)) {
this.pocls = 'fixed' this.pocls = 'fixed'
this.act_swiper = 'act_swiper' this.act_swiper = 'act_swiper'
@ -356,17 +366,16 @@
.select('.flags') .select('.flags')
.boundingClientRect(rect => { .boundingClientRect(rect => {
this.headtop = rect.top this.headtop = rect.top
console.log(rect.top)
}) })
.exec(); .exec();
// uni.createSelectorQuery() uni.createSelectorQuery()
// .in(this) .in(this)
// .select('.content_sift') .select('.cart')
// .boundingClientRect(rect => { .boundingClientRect(rect => {
// // this.headtop += rect.height this.cartTagInfo = rect
// console.log(this.headtop) })
// }) .exec();
// .exec();
}, },
onPullDownRefresh() { onPullDownRefresh() {
uni.stopPullDownRefresh() uni.stopPullDownRefresh()
@ -384,14 +393,11 @@
this.cartList[0].list.forEach(e => { this.cartList[0].list.forEach(e => {
this.totalMoney = this.totalMoney + Number(e.productAttr.price) * e.cart_num this.totalMoney = this.totalMoney + Number(e.productAttr.price) * e.cart_num
}) })
}) })
getCartCounts().then(res => { getCartCounts().then(res => {
this.goodsNum = res.data[0].count this.goodsNum = res.data[0].count
}) })
}, },
godDetail(item) { godDetail(item) {
goShopDetail(item, this.uid).then(res => { goShopDetail(item, this.uid).then(res => {
if (this.isLogin) { if (this.isLogin) {
@ -452,8 +458,46 @@
}) })
}, },
addcart(price) { addcart(i) {
this.tot_price += Number(price) let data = {
cart_num: 1,
is_new: 0,
product_attr_unique: i.sku[''].unique,
product_id: i.product_id,
product_type: i.product_type,
spread_id: "",
}
let that = this
let res = postCartAdd({
...data
}).then((res, err) => {
this.act_cart = true
this.cartFn()
uni.showToast({
title: "加入成功",
duration: 1000,
})
}).catch(err => {
// this.act_cart = false
uni.showToast({
title: err,
icon: "none",
duration: 1000,
})
})
setTimeout(() => {
that.act_cart = false
}, 500)
// let that = this
// uni.createSelectorQuery().in(this).select(`.act_class${i}`).boundingClientRect(data1 => {
// that.trnList[i].left = this.cartTagInfo.left - data1.left + 'px';
// that.trnList[i].bottom = this.cartTagInfo.top - data1.top + 'px';
// console.log(that.trnList[i])
// }).exec();
// this.tot_price += Number(price)
}, },
all(index) { all(index) {
this.showPop = false this.showPop = false
@ -479,6 +523,12 @@
category_id: this.cloudList[this.current].category_id category_id: this.cloudList[this.current].category_id
}).then(res => { }).then(res => {
this.goodsList = res.data.list this.goodsList = res.data.list
this.goodsList.forEach(item => {
this.trnList.push({
left: 0,
bottom: 0
})
})
}) })
// console.log(this.cloudList) // console.log(this.cloudList)
data.length < 1 ? Toast("暂无云仓") : ''; data.length < 1 ? Toast("暂无云仓") : '';
@ -493,6 +543,11 @@
z-index: 99999999; z-index: 99999999;
} }
.act_cart {
transition: 0.5s;
transform: scale(1.1);
}
.box { .box {
position: relative; position: relative;
@ -511,6 +566,7 @@
.active_swiper { .active_swiper {
transform: scale(1.3); transform: scale(1.3);
// transform: translateX() translateY();
} }
@ -538,14 +594,15 @@
} }
.act_class { .act_class {
transition: 1s; transition: 0.5s;
} }
.act_class:active { .act_class:active {
transform: scale(2); transform: scale(2);
// transform: translate(-500rpx, 500rpx);
} }
.content_act { .content_act {
width: 100vw; width: 100vw;
position: absolute; position: absolute;
@ -703,6 +760,10 @@
align-items: center; align-items: center;
width: 60vw; width: 60vw;
.good_price_r {
z-index: 9;
}
.good_price_l { .good_price_l {
display: flex; display: flex;
@ -764,6 +825,7 @@
.card { .card {
width: 720rpx; width: 720rpx;
z-index: 999999;
// margin:auto; // margin:auto;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
@ -853,6 +915,7 @@
} }
} }
.body-wrapper { .body-wrapper {
width: 694.74rpx; width: 694.74rpx;
display: flex; display: flex;
@ -919,4 +982,8 @@
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
.cart {
z-index: 999;
}
</style> </style>