Feat:优惠券对接

This commit is contained in:
lifizer
2023-12-25 17:16:56 +08:00
parent 847a80f251
commit 18a2fbb8a6
46 changed files with 1360 additions and 858 deletions
+57 -84
View File
@@ -198,39 +198,27 @@
<text v-if="tempName">{{ tempName }}</text>
<text>销量:{{ dayInfo.sales }}{{ dayInfo.unitName }}</text>
</view>
<!-- 优惠券选择开始 -->
<!-- <view
class="coupon acea-row row-between-wrapper"
@click="couponTap"
v-if="couponList.length"
>
<text class="hide line1 acea-row">
<text>优惠券</text>
<text
class="activity"
v-for="(item, couponListEq) in couponList"
:key="couponListEq"
>{{ item.use_min_price }}{{ item.coupon_price }}</text>
</text>
<view class="iconfont icon-jiantou"></view>
</view> -->
<!-- 优惠券选择结束 -->
</view>
<!-- 已选规格开始 -->
<!-- <view class="attribute acea-row row-between-wrapper" @click="selecAttrTap">-->
<!-- <view>-->
<!-- <text>{{ attrTxt }}</text>-->
<!-- <text class="atterTxt">{{ attrValue }}</text>-->
<!-- </view>-->
<!-- <view class="iconfont icon-jiantou"></view>-->
<!-- </view>-->
<!-- 已选规格结束 -->
<!-- v9 优惠券开始 -->
<u-popup :show="show" :round="10" mode="bottom" closeOnClickOverlay @close="changeCoupons()">
<CouponsPopup :two-list="couponList" @close="changeCoupons"/>
</u-popup>
<!-- v9 优惠券结束 -->
<!-- v6服务项目开始 -->
<view class="service-section goods-section" v-if="storeInfo && storeInfo.isTickets!=1">
<view class="cell flex jc-between ai-center" @click="changeCoupons()" v-if="couponList['usable'].length>0">
<view>
<text class="coupon-label tc" v-for="(item,index) in couponList.usable" :key="index" v-if="index<2">
{{ item.couponTitle }}
</text>
</view>
<view class="value">优惠详情
<uni-icons type="right" size="13" color="#707070"></uni-icons>
</view>
</view>
<view class="cell flex jc-between ai-center" @click="selecAttrTap">
<view class="flex ai-center">
<view class="after-title">规格</view>
@@ -459,7 +447,7 @@
</view>
</view>
</view>
<CouponPop v-on:changeFun="changeFun" :coupon="coupon"></CouponPop>
<!-- <CouponPop v-on:changeFun="changeFun" :coupon="coupon"></CouponPop>-->
<ProductWindow v-on:changeFun="changeFun" :attr="attr" :cartNum="cart_num"/>
<StorePoster v-on:setPosterImageStatus="setPosterImageStatus" :posterImageStatus="posterImageStatus"
:posterData="posterData" :goodId="id"></StorePoster>
@@ -488,13 +476,12 @@
<script>
import ProductConSwiper from "@/components/ProductConSwiper";
import UserEvaluation from "@/components/UserEvaluation";
import CouponPop from "@/components/CouponPop";
import ProductWindow from "@/components/ProductWindow";
import StorePoster from "@/components/StorePoster";
import ShareInfo from "@/components/ShareInfo";
import CountDown from "@/components/CountDown";
import {getCartCount, getProductCode, getProductDetail, postCartAdd} from "@/api/store";
import {getCollectAdd, getCollectDel, getCoupon, userBindParent} from "@/api/user";
import {userBindParent} from "@/api/user";
import {handleQrCode, isWeixin} from "@/utils";
import {getHomeData} from "@/api/public";
import {getDailyGoods, getPreSale, getYxStoreSeckill} from "@/api/goods";
@@ -503,6 +490,8 @@ import {diffDay, formatDateTime} from "@/utils/index";
import {getCurAddress, getLocation, getUrlParam} from "@/utils/common.js";
import cookie from "@/utils/store/cookie";
import {famousGoodsShareImage, secKillGoodsShareImage} from "@/api/share";
import CouponsPopup from "@/components/CouponsPopup.vue"
import { formatContent } from '@/utils/util.js'
export default {
name: "GoodsCon",
@@ -510,10 +499,10 @@ export default {
CountDown,
ProductConSwiper,
UserEvaluation,
CouponPop,
ProductWindow,
StorePoster,
ShareInfo
ShareInfo,
CouponsPopup
},
data: function () {
return {
@@ -549,7 +538,7 @@ export default {
killInfo: {},
dayInfo: {},
storeInfo: {},
couponList: [],
couponList: {},
attrTxt: "请选择",
attrValue: "",
cart_num: 1, //购买数量
@@ -581,7 +570,9 @@ export default {
isWenwan: 0,
postAddress: null,
exSliceEnd: 3,
webUrl: this.$VUE_APP_RESOURCES_URL
webUrl: this.$VUE_APP_RESOURCES_URL,
// v9-2
show: false,
};
},
computed: mapGetters(["isLogin", "location", "userInfo"]),
@@ -597,12 +588,18 @@ export default {
params += `&activityId=${this.activityId}`
}
if (result.status === 200) {
if (result?.status === 200) {
resolve({
title: this.storeInfo.storeName,
path: '/pages/shop/GoodsCon/index' + params,
imageUrl: result.data
})
} else {
resolve({
title: this.storeInfo.storeName,
path: '/pages/shop/GoodsCon/index' + params,
imageUrl: this.storeInfo.image
})
}
})
},
@@ -610,6 +607,7 @@ export default {
// test data
console.log("getLaunchOptionsSync", uni.getLaunchOptionsSync());
console.log("getEnterOptionsSync", uni.getEnterOptionsSync());
uni.removeStorageSync('couponId')
let url = handleQrCode();
if (url && url.productId) {
@@ -950,6 +948,10 @@ export default {
if (this.$deviceType == "app") {
from.from = "app";
}
if (that.source === 'kill') {
from.seckillId = that.activityId
}
uni.showLoading({
title: "加载中",
mask: true
@@ -961,7 +963,7 @@ export default {
// /\<img/gi,
// '<img style="display:block;max-width:100%;height:auto;"'
// );
that.$set(that, "storeInfo", res.data.storeInfo);
that.$set(that, "storeInfo", formatContent(res.data.storeInfo));
that.isWenwan = res.data.isWenwan;
// 给 attr 赋值,将请求回来的规格赋值给 attr
@@ -969,7 +971,11 @@ export default {
that.$set(that.attr, "productAttr", res.data.productAttr);
that.$set(that, "productValue", res.data.productValue);
}
that.attr.defaultSku = res.data.defaultSku
that.attr.defaultSkuIndex = res.data.defaultSkuIndex
res.data.couponList['unusable']?.map(item => item.status = 2)
that.$set(that, 'couponList', res.data.couponList)
that.$set(that, "replyCount", res.data.replyCount);
that.$set(that, "replyChance", res.data.replyChance);
that.reply = res.data.reply ? [res.data.reply] : [];
@@ -1028,11 +1034,14 @@ export default {
let productAttr = this.attr.productAttr;
let value = [];
for (let i = 0; i < productAttr.length; i++) {
this.$set(productAttr[i], "index", 0);
value.push(productAttr[i].attrValueArr[0]);
this.$set(productAttr[i], "index", this.attr.defaultSkuIndex[i]);
value.push(productAttr[i].attrValueArr[1]);
}
//sort();排序函数:数字-英文-汉字;
let productSelect = this.productValue[value.sort().join(",")];
// let productSelect = this.productValue[value.sort().join(",")];
const skuKey = this.attr.defaultSku?.join(',')
let productSelect = this.productValue[skuKey]
if (productSelect && productAttr.length) {
this.$set(
this.attr.productSelect,
@@ -1045,7 +1054,8 @@ export default {
this.$set(this.attr.productSelect, "stock", productSelect.stock);
this.$set(this.attr.productSelect, "unique", productSelect.unique);
this.$set(this.attr.productSelect, "cart_num", 1);
this.$set(this, "attrValue", value.sort().join(","));
// this.$set(this, "attrValue", value.sort().join(","));
this.$set(this, "attrValue", skuKey);
this.$set(this, "attrTxt", "已选择");
} else if (!productSelect && productAttr.length) {
this.$set(
@@ -1121,33 +1131,7 @@ export default {
let value = opt.value === undefined ? "" : opt.value;
this[action] && this[action](value);
},
//打开优惠券插件;
couponTap: function () {
let that = this;
that.coupons();
that.coupon.coupon = true;
},
changecoupon: function (msg) {
this.coupon.coupon = msg;
this.coupons();
},
currentcoupon: function (res) {
let that = this;
that.coupon.coupon = false;
that.$set(that.coupon.list[res], "is_use", true);
},
//可领取优惠券接口;
coupons: function () {
let that = this,
q = {
page: 1,
limit: 20
};
getCoupon(q).then(res => {
that.$set(that, "couponList", res.data || []);
that.$set(that.coupon, "list", res.data);
});
},
//打开属性插件;
selecAttrTap: function () {
this.attr.cartAttr = true;
@@ -1184,21 +1168,6 @@ export default {
this.$set(this, "attrTxt", "请选择");
}
},
//收藏商品
setCollect: function () {
let that = this,
id = that.storeInfo.id,
category = "product";
if (that.storeInfo.userCollect) {
getCollectDel(id, category).then(function () {
that.storeInfo.userCollect = !that.storeInfo.userCollect;
});
} else {
getCollectAdd(id, category).then(function () {
that.storeInfo.userCollect = !that.storeInfo.userCollect;
});
}
},
// 点击加入购物车按钮
joinCart: function () {
if (this.isOpen === true && this.attr.productSelect.stock === 0) return;
@@ -1322,7 +1291,11 @@ export default {
},
listenerActionClose: function () {
this.posters = false;
}
},
// v9-2
changeCoupons() {
this.show = !this.show
},
}
};
</script>