diff --git a/pages/nongKe/cloud_entrepot/index.vue b/pages/nongKe/cloud_entrepot/index.vue index d2a0cb2..1d3f8ae 100644 --- a/pages/nongKe/cloud_entrepot/index.vue +++ b/pages/nongKe/cloud_entrepot/index.vue @@ -17,8 +17,9 @@ --> + - + @@ -59,15 +60,12 @@ 全部 - + - - - @@ -75,11 +73,10 @@ :circular="true" previous-margin='0rpx' next-margin='0rpx' :current="current" :disable-touch="true"> - - @@ -97,15 +94,15 @@ - - - {{item.tit}} - - + - + + + {{item.tit}} + + @@ -135,10 +132,14 @@ ¥30.00 - - + + + @@ -159,9 +160,11 @@ - + - + @@ -178,7 +181,7 @@ - + 去结算 @@ -256,10 +259,15 @@ import { goShopDetail } from '@/libs/order.js' + import { + postCartAdd, + } from '@/api/store.js'; export default { data() { let src = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/13'; return { + trnList: [], + act_cart: false, appInfo: {}, pocls: "", type: "", @@ -280,8 +288,10 @@ showtit: true, cartList: [], activeClass: 'activeClass', - headtop: "", + headtop: 0, page_num: 1, + act_img: "", + cartTagInfo: {}, actList: [{ tit: '综合', act: "", @@ -337,14 +347,15 @@ .in(this) .select('.content') .boundingClientRect(rect => { - // console.log(rect) - if (rect.top <= this.headtop) { + if (rect.top <= (this.headtop + 16)) { this.pocls = 'fixed' this.act_swiper = 'act_swiper' + this.act_img = 'act_img' } else { this.pocls = '' this.act_swiper = '' + this.act_img = '' } }) @@ -352,11 +363,19 @@ if (this.headtop) return uni.createSelectorQuery() .in(this) - .select('.flag') + .select('.flags') .boundingClientRect(rect => { this.headtop = rect.top }) .exec(); + uni.createSelectorQuery() + .in(this) + .select('.cart') + .boundingClientRect(rect => { + this.cartTagInfo = rect + }) + .exec(); + }, onPullDownRefresh() { uni.stopPullDownRefresh() @@ -374,14 +393,11 @@ this.cartList[0].list.forEach(e => { this.totalMoney = this.totalMoney + Number(e.productAttr.price) * e.cart_num }) - - }) getCartCounts().then(res => { this.goodsNum = res.data[0].count }) }, - godDetail(item) { goShopDetail(item, this.uid).then(res => { if (this.isLogin) { @@ -442,8 +458,46 @@ }) }, - addcart(price) { - this.tot_price += Number(price) + addcart(i) { + 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) { this.showPop = false @@ -469,6 +523,12 @@ category_id: this.cloudList[this.current].category_id }).then(res => { this.goodsList = res.data.list + this.goodsList.forEach(item => { + this.trnList.push({ + left: 0, + bottom: 0 + }) + }) }) // console.log(this.cloudList) data.length < 1 ? Toast("暂无云仓") : ''; @@ -478,6 +538,16 @@ \ No newline at end of file