|
@@ -190,15 +190,7 @@
|
|
|
|
|
|
|
|
|
<!-- 组件 -->
|
|
|
- <productWindow v-if="attr.cartAttr" :attr="attr" :isShow="1" :iSplus="1" @myevent="onMyEvent"
|
|
|
- @ChangeAttr="ChangeAttr" @ChangeCartNum="ChangeCartNum" @attrVal="attrVal" @iptCartNum="iptCartNum"
|
|
|
- id="product-window" :is_vip="is_vip" @getImg="showImg" :is_virtual="storeInfo.isSale">
|
|
|
- </productWindow>
|
|
|
- <!-- <cus-previewImg ref="cusPreviewImg" :list="skuArr" @changeSwitch="changeSwitch"
|
|
|
- @shareFriend="listenerActionSheet" /> -->
|
|
|
- <couponListWindow :coupon="coupon" v-if="coupon" @ChangCouponsClone="ChangCouponsClone" @ChangCoupons="ChangCoupons"
|
|
|
- @ChangCouponsUseState="ChangCouponsUseState" @tabCouponType="tabCouponType">
|
|
|
- </couponListWindow>
|
|
|
+
|
|
|
<!-- 分享按钮 -->
|
|
|
<view class="generate-posters acea-row row-middle" :class="posters ? 'on' : ''">
|
|
|
<!-- #ifndef MP -->
|
|
@@ -288,23 +280,13 @@ let sysHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
|
|
|
let windWidth = uni.getSystemInfoSync().windowWidth
|
|
|
import {detailGroupon, goodsDetail,bindParentId} from '@/api/groupon.js'
|
|
|
import {
|
|
|
- getGoodsDetail, getUserAddressByUserId, postBeforeCheck, getAvailableCheck
|
|
|
- , postLinkedUrl
|
|
|
+postBeforeCheck
|
|
|
} from "@/api/home.js";
|
|
|
-import {
|
|
|
- getProductDetail,
|
|
|
- getProductCode,
|
|
|
- collectAdd,
|
|
|
- collectDel,
|
|
|
- postCartAdd,
|
|
|
-} from "@/api/store.js";
|
|
|
+
|
|
|
import {
|
|
|
getUserInfo,
|
|
|
- userShare
|
|
|
} from "@/api/user.js";
|
|
|
-import {
|
|
|
- getCoupons
|
|
|
-} from "@/api/api.js";
|
|
|
+
|
|
|
import {
|
|
|
getCartCounts
|
|
|
} from "@/api/order.js";
|
|
@@ -321,22 +303,16 @@ import detail from './detail/index.vue'
|
|
|
import cusPreviewImg from "@/components/cusPreviewImg/index.vue";
|
|
|
import productConSwiperGroupbuying from "@/components/productConSwiperGroupbuying";
|
|
|
import couponListWindow from "@/components/couponListWindow";
|
|
|
-import productWindow from "@/components/productWindow";
|
|
|
import userEvaluation from "@/components/userEvaluation";
|
|
|
-import shareRedPackets from "@/components/shareRedPackets";
|
|
|
import kefuIcon from "@/components/kefuIcon";
|
|
|
import {
|
|
|
- silenceBindingSpread,
|
|
|
updateURLParameter
|
|
|
} from "@/utils";
|
|
|
-import ClipboardJS from "@/plugin/clipboard/clipboard.js";
|
|
|
// #ifdef MP
|
|
|
import authorize from "@/components/Authorize";
|
|
|
// #endif
|
|
|
// #ifdef APP-PLUS
|
|
|
-import {
|
|
|
- TOKENNAME
|
|
|
-} from "@/config/app.js";
|
|
|
+
|
|
|
// #endif
|
|
|
import { HTTP_REQUEST_URL } from '@/config/app';
|
|
|
let app = getApp();
|
|
@@ -350,7 +326,6 @@ export default {
|
|
|
components: {
|
|
|
productConSwiperGroupbuying,
|
|
|
couponListWindow,
|
|
|
- productWindow,
|
|
|
userEvaluation,
|
|
|
kefuIcon,
|
|
|
cusPreviewImg,
|
|
@@ -495,12 +470,6 @@ export default {
|
|
|
+ "&inviteCode=" + this.$Cache.get('INVITE_CODE_LOGIN')
|
|
|
+ "&zoneType=" + 8
|
|
|
})
|
|
|
- // this.$forceUpdate()
|
|
|
- // this.id = this.$Cache.get('GOOD_ID_LOGIN')
|
|
|
- // this.getGoodsDetails();
|
|
|
- // this.getCouponList();
|
|
|
- // this.getCartCount();
|
|
|
- // this.downloadFilePromotionCode();
|
|
|
}
|
|
|
},
|
|
|
deep: true,
|
|
@@ -569,7 +538,6 @@ export default {
|
|
|
|
|
|
|
|
|
console.log("受邀的推荐码:" + options.inviteCode);
|
|
|
- console.log("受邀的商品id:" + options.id);
|
|
|
|
|
|
var pages = getCurrentPages();
|
|
|
that.returnShow = pages.length === 1 ? false : true;
|
|
@@ -618,8 +586,6 @@ export default {
|
|
|
//记录推广人uid
|
|
|
if (options.spid) app.globalData.spid = options.spid;
|
|
|
// #endif
|
|
|
- // that.getGoodsDetails();
|
|
|
- // that.getCouponList(0);
|
|
|
uni.hideLoading();
|
|
|
|
|
|
},500)
|
|
@@ -628,18 +594,6 @@ export default {
|
|
|
},
|
|
|
onReady: function () {
|
|
|
this.isNodes++;
|
|
|
- // this.$nextTick(function () {
|
|
|
- // // #ifdef MP
|
|
|
- // const menuButton = uni.getMenuButtonBoundingClientRect();
|
|
|
- // const query = uni.createSelectorQuery().in(this);
|
|
|
- // query
|
|
|
- // .select("#home")
|
|
|
- // .boundingClientRect((data) => {
|
|
|
- // this.homeTop = menuButton.top * 2 + menuButton.height - data.height || 0;
|
|
|
- // })
|
|
|
- // .exec();
|
|
|
- // // #endif
|
|
|
- // });
|
|
|
},
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
@@ -759,11 +713,6 @@ export default {
|
|
|
this.scrollLeft = this.scrollLeftOld + 54
|
|
|
},
|
|
|
|
|
|
-
|
|
|
- // 分享关闭
|
|
|
- listenerActionClose: function () {
|
|
|
-
|
|
|
- },
|
|
|
openImg (index) {
|
|
|
uni.previewImage({
|
|
|
current: index,
|
|
@@ -835,30 +784,7 @@ export default {
|
|
|
boxStatus (data) {
|
|
|
this.showAnimate = data;
|
|
|
},
|
|
|
- goActivity: function (e) {
|
|
|
- let item = e;
|
|
|
- if (item.type === "1") {
|
|
|
- uni.navigateTo({
|
|
|
- url: `/pages/activity/goods_seckill_details/index?id=${item.id}&time=${item.time}&status=1`,
|
|
|
- });
|
|
|
- } else if (item.type === "2") {
|
|
|
- uni.navigateTo({
|
|
|
- url: `/pages/activity/goods_bargain_details/index?id=${item.id}&bargain=${this.uid}`,
|
|
|
- });
|
|
|
- } else {
|
|
|
- uni.navigateTo({
|
|
|
- url: `/pages/activity/goods_combination_details/index?id=${item.id}`,
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- /**
|
|
|
- * 购物车手动填写
|
|
|
- *
|
|
|
- */
|
|
|
- iptCartNum: function (e) {
|
|
|
- // this.attr.productSelect.totalStock = this.attr.productSelect.totalStock - e;
|
|
|
- this.$set(this.attr.productSelect, "totalSales", e);
|
|
|
- },
|
|
|
+
|
|
|
// 后退
|
|
|
returns () {
|
|
|
// #ifdef H5
|
|
@@ -923,9 +849,7 @@ export default {
|
|
|
// this.getUserInfo();
|
|
|
// this.get_product_collect();
|
|
|
},
|
|
|
- ChangCouponsClone: function () {
|
|
|
- this.$set(this.coupon, "coupon", false);
|
|
|
- },
|
|
|
+
|
|
|
/*
|
|
|
* 获取用户信息
|
|
|
*/
|
|
@@ -936,32 +860,7 @@ export default {
|
|
|
that.$set(that, "is_money_level", res.data.is_money_level);
|
|
|
});
|
|
|
},
|
|
|
- /**
|
|
|
- * 购物车数量加和数量减
|
|
|
- *
|
|
|
- */
|
|
|
- ChangeCartNum: function (changeValue) {
|
|
|
- //changeValue:是否 加|减
|
|
|
- //获取当前变动属性
|
|
|
- //如果没有属性,赋值给商品默认库存
|
|
|
- let productSelect = this.attr.productSelect;
|
|
|
- //无属性值即库存为0;不存在加减;
|
|
|
- if (productSelect === undefined) return;
|
|
|
- let stock = productSelect.totalStock || 0;
|
|
|
- if (changeValue) {
|
|
|
- this.attr.productSelect.totalSales++;
|
|
|
- if (this.attr.productSelect.totalSales > stock) {
|
|
|
- this.$set(this.attr.productSelect, "totalSales", stock ? stock : 1);
|
|
|
- this.$set(this, "totalSales", stock ? stock : 1);
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.attr.productSelect.totalSales--;
|
|
|
- if (this.attr.productSelect.totalSales < 1) {
|
|
|
- this.$set(this.attr.productSelect, "totalSales", 1);
|
|
|
- this.$set(this, "totalSales", 1);
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
+
|
|
|
attrVal (val) {
|
|
|
this.$set(
|
|
|
this.attr.productAttr[val.indexw],
|
|
@@ -994,15 +893,7 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- /**
|
|
|
- * 领取完毕移除当前页面领取过的优惠券展示
|
|
|
- */
|
|
|
- ChangCoupons: function (e) {
|
|
|
- let coupon = e;
|
|
|
- let couponList = this.$util.ArrayRemove(this.couponList, "id", coupon.id);
|
|
|
- this.$set(this, "couponList", couponList);
|
|
|
- this.getCouponList();
|
|
|
- },
|
|
|
+
|
|
|
|
|
|
setClientHeight: function () {
|
|
|
let that = this;
|
|
@@ -1026,12 +917,10 @@ export default {
|
|
|
this.isShowBottom = this.getIsShowBottom(res.data.grouponEndTime)
|
|
|
if (this.isShowBottom ){
|
|
|
this.bottomHeight = '150rpx'
|
|
|
- console.log(this.bottomHeight,this.isShowBottom)
|
|
|
}
|
|
|
setTimeout(() =>{
|
|
|
this.getFirstGoodsTop(res.data.goodsList[0].id);
|
|
|
},2000)
|
|
|
- console.log('+++++++++++isShowBottom++++++++++++++',this.isShowBottom)
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -1040,9 +929,6 @@ export default {
|
|
|
let endDate = new Date(date)
|
|
|
let newDate = new Date();
|
|
|
|
|
|
- console.log('+++++++++++endDate++++++++++++++',endDate)
|
|
|
- console.log('+++++++++++newDate++++++++++++++',newDate)
|
|
|
- console.log(newDate)
|
|
|
if (endDate.getTime() > newDate.getTime()){
|
|
|
return true
|
|
|
}else{
|
|
@@ -1131,152 +1017,8 @@ export default {
|
|
|
success: function () { },
|
|
|
});
|
|
|
},
|
|
|
- getUserAddressByUserId () {
|
|
|
- getUserAddressByUserId({
|
|
|
- userId: this.$store.state.app.uid,
|
|
|
- type: 1
|
|
|
- }).then(res => {
|
|
|
- this.attrAddrValue = res.data
|
|
|
- if (this.attrAddrValue.id) {
|
|
|
- this.getAvailableCheck()
|
|
|
- } else {
|
|
|
- this.DefaultSelect();
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- /**
|
|
|
- * 默认选中属性
|
|
|
- *
|
|
|
- */
|
|
|
- DefaultSelect: function () {
|
|
|
- //找到第一个可销售的规格
|
|
|
- if (this.skuArr.length >= 0) {
|
|
|
- this.skuArr.every(value => {
|
|
|
- if (value.canSale) {
|
|
|
- this.attrValue = value.spceName
|
|
|
- this.storeInfo.obtainIntegral = value.obtainIntegral - 0
|
|
|
- // 处理分享
|
|
|
- if (this.storeInfo.zoneType == 8) {
|
|
|
- this.sharePacket.priceName = this.storeInfo.obtainIntegral
|
|
|
- }
|
|
|
- this.storeInfo.salePrice = value.salePrice - 0
|
|
|
- this.storeInfo.totalStock = value.stock - 0
|
|
|
- this.attr.attrValueId = value.id
|
|
|
- this.availableCheck = true
|
|
|
- return false;
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- uni.hideLoading();
|
|
|
- },
|
|
|
- // 可销售检测
|
|
|
- getAvailableCheck () {
|
|
|
- getAvailableCheck({
|
|
|
- goodsInfoId: this.id,
|
|
|
- userAddressId: this.attrAddrValue.id
|
|
|
- }).then(res => {
|
|
|
- //处理缺货的规格
|
|
|
- let ban = res.data.ban
|
|
|
- if (ban !== undefined) {
|
|
|
- this.storeInfo.goodsSpecList.forEach((value, key) => {
|
|
|
- if (ban.includes(value.id - 0) || ban.includes(value.optionId - 0)) {
|
|
|
- this.storeInfo.goodsSpecList[key].canSale = false
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- // this.availableCheck = res.success
|
|
|
- this.DefaultSelect();
|
|
|
- })
|
|
|
- },
|
|
|
- /**
|
|
|
- * 获取优惠券
|
|
|
- *
|
|
|
- */
|
|
|
- getCouponList (type) {
|
|
|
- let that = this,
|
|
|
- obj = {
|
|
|
- page: 1,
|
|
|
- limit: 20,
|
|
|
- product_id: that.id,
|
|
|
- };
|
|
|
- if (type !== undefined || type !== null) {
|
|
|
- obj.type = type;
|
|
|
- }
|
|
|
- getCoupons(obj).then((res) => {
|
|
|
- that.$set(that.coupon, "count", res.data.count);
|
|
|
- if (type === undefined || type === null) {
|
|
|
- let count = [...that.coupon.count],
|
|
|
- indexs = "";
|
|
|
- let index = count.findIndex((item) => item);
|
|
|
- let delCount = that.coupon.count,
|
|
|
- newDelCount = [];
|
|
|
- let countIndex = 0;
|
|
|
- delCount.forEach((item, index) => {
|
|
|
- if (item === 0) {
|
|
|
- countIndex = index;
|
|
|
- } else {
|
|
|
- newDelCount.push(item);
|
|
|
- }
|
|
|
- });
|
|
|
- if (newDelCount.length == 3) {
|
|
|
- indexs = 2;
|
|
|
- } else if (newDelCount.length == 2) {
|
|
|
- if (countIndex === 2) {
|
|
|
- indexs = 1;
|
|
|
- } else {
|
|
|
- indexs = 2;
|
|
|
- }
|
|
|
- } else {
|
|
|
- indexs = delCount.findIndex((item) => item === count[index]);
|
|
|
- }
|
|
|
- that.$set(that.coupon, "type", indexs);
|
|
|
- that.getCouponList(indexs);
|
|
|
- } else {
|
|
|
- that.$set(that.coupon, "list", res.data.list);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- ChangCouponsUseState (index) {
|
|
|
- let that = this;
|
|
|
- that.coupon.list[index].is_use = true;
|
|
|
- that.$set(that.coupon, "list", that.coupon.list);
|
|
|
- that.$set(that.coupon, "coupon", false);
|
|
|
- },
|
|
|
- /**
|
|
|
- *
|
|
|
- *
|
|
|
- * 收藏商品
|
|
|
- */
|
|
|
- setCollect: function () {
|
|
|
- if (this.isLogin === false) {
|
|
|
- toLogin();
|
|
|
- } else {
|
|
|
- let that = this;
|
|
|
- if (this.storeInfo.userCollect) {
|
|
|
- collectDel([this.storeInfo.id]).then((res) => {
|
|
|
- that.$set(
|
|
|
- that.storeInfo,
|
|
|
- "userCollect",
|
|
|
- !that.storeInfo.userCollect
|
|
|
- );
|
|
|
- return that.$util.Tips({
|
|
|
- title: res.msg,
|
|
|
- });
|
|
|
- });
|
|
|
- } else {
|
|
|
- collectAdd(this.storeInfo.id).then((res) => {
|
|
|
- that.$set(
|
|
|
- that.storeInfo,
|
|
|
- "userCollect",
|
|
|
- !that.storeInfo.userCollect
|
|
|
- );
|
|
|
- return that.$util.Tips({
|
|
|
- title: res.msg,
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
+
|
|
|
+
|
|
|
// 跳转到地址列表
|
|
|
selecAddrAttr: function () {
|
|
|
uni.navigateTo({
|
|
@@ -1293,158 +1035,12 @@ export default {
|
|
|
this.$set(this.attr, "productSelect", this.storeInfo);
|
|
|
this.$set(this, "isOpen", true);
|
|
|
},
|
|
|
- /**
|
|
|
- * 打开优惠券插件
|
|
|
- */
|
|
|
- couponTap: function () {
|
|
|
- let that = this;
|
|
|
- if (that.isLogin === false) {
|
|
|
- toLogin();
|
|
|
- } else {
|
|
|
- that.getCouponList();
|
|
|
- that.$set(that.coupon, "coupon", true);
|
|
|
- }
|
|
|
- },
|
|
|
+
|
|
|
onMyEvent: function () {
|
|
|
this.$set(this.attr, "cartAttr", false);
|
|
|
this.$set(this, "isOpen", false);
|
|
|
},
|
|
|
- /**
|
|
|
- * 打开属性加入购物车
|
|
|
- *
|
|
|
- */
|
|
|
- joinCart: function (e) {
|
|
|
- //是否登录
|
|
|
- if (this.isLogin === false) {
|
|
|
- toLogin();
|
|
|
- } else {
|
|
|
- //判断是否有地址
|
|
|
- if (!this.attrAddrValue && !this.attrAddrValue.id) {
|
|
|
- this.goCat();
|
|
|
- } else {
|
|
|
- this.$util.Tips({
|
|
|
- title: this.$t(`请先至个人中心设置默认地址`),
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- goCart () {
|
|
|
- uni.switchTab({
|
|
|
- url: '/pages/order_addcart/order_addcart'
|
|
|
- })
|
|
|
- },
|
|
|
- /*
|
|
|
- * 加入购物车
|
|
|
- */
|
|
|
- goCat: function (news) {
|
|
|
- let that = this
|
|
|
- that.currentPage = false;
|
|
|
- this.storeInfo.totalSales = this.attr.productSelect.totalSales
|
|
|
- this.$set(this.attr, "productSelect", this.storeInfo);
|
|
|
- //打开属性
|
|
|
- if (that.attrValue) {
|
|
|
- //默认选中了属性,但是没有打开过属性弹窗还是自动打开让用户查看默认选中的属性
|
|
|
- that.attr.cartAttr = !that.isOpen ? true : false;
|
|
|
- } else {
|
|
|
- if (that.isOpen) that.attr.cartAttr = true;
|
|
|
- else that.attr.cartAttr = !that.attr.cartAttr;
|
|
|
- }
|
|
|
- //只有关闭属性弹窗时进行加入购物车
|
|
|
- if (that.attr.cartAttr === true && that.isOpen === false)
|
|
|
- return (that.isOpen = true);
|
|
|
- //如果有属性,没有选择,提示用户选择
|
|
|
- // if (
|
|
|
- // that.attr.productAttr.length &&
|
|
|
- // productSelect === undefined &&
|
|
|
- // that.isOpen === true
|
|
|
- // )
|
|
|
- // return that.$util.Tips({
|
|
|
- // title: that.$t(`产品库存不足,请选择其它属性`),
|
|
|
- // });
|
|
|
- // if (that.attr.productSelect.totalSales <= 0) {
|
|
|
- // that.attr.productSelect.totalSales = 1;
|
|
|
- // that.isOpen = false;
|
|
|
- // return that.$util.Tips({
|
|
|
- // title: that.$t(`请选择数量`),
|
|
|
- // });
|
|
|
- // }
|
|
|
- postBeforeCheck({
|
|
|
- goodsSpecId: that.attr.attrValueId,
|
|
|
- num: that.attr.productSelect.totalSales,
|
|
|
- userAddressId: that.attrAddrValue.id
|
|
|
- }).then(function (res) {
|
|
|
- that.isOpen = false;
|
|
|
- that.attr.cartAttr = false;
|
|
|
- if (res.success) {
|
|
|
- uni.navigateTo({
|
|
|
- url: "/pages/goods/order_confirm/index?num=" + that.attr.productSelect.totalSales + "&productId=" +
|
|
|
- that.attr.productSelect.id
|
|
|
- + "&freight=" + res.data.freight
|
|
|
- + "&addressId=" + that.attrAddrValue.id
|
|
|
- + "&goodsSpecId=" + that.attr.attrValueId
|
|
|
- + "&obtainIntegral=" + that.storeInfo.obtainIntegral,
|
|
|
- });
|
|
|
- } else {
|
|
|
- that.$util.Tips({
|
|
|
- title: that.$t(`所选商品属性不支持下单`),
|
|
|
- success: () => {
|
|
|
- // that.getCartCount(true);
|
|
|
- },
|
|
|
- });
|
|
|
- }
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- that.isOpen = false;
|
|
|
- return that.$util.Tips({
|
|
|
- title: err,
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
- /**
|
|
|
- * 获取购物车数量
|
|
|
- * @param boolean 是否展示购物车动画和重置属性
|
|
|
- */
|
|
|
- getCartCount: function (isAnima) {
|
|
|
- let that = this;
|
|
|
- const isLogin = that.isLogin;
|
|
|
- if (isLogin) {
|
|
|
- getCartCounts().then((res) => {
|
|
|
- that.CartCount = res.data.count;
|
|
|
- this.$store.commit(
|
|
|
- "indexData/setCartNum",
|
|
|
- that.CartCount > 99 ? "..." : that.CartCount + ""
|
|
|
- );
|
|
|
- // uni.setTabBarBadge({
|
|
|
- // index: Number(uni.getStorageSync('FOOTER_ADDCART')) || 2,
|
|
|
- // text: that.CartCount + ''
|
|
|
- // })
|
|
|
- //加入购物车后重置属性
|
|
|
- if (isAnima) {
|
|
|
- that.animated = true;
|
|
|
- setTimeout(function () {
|
|
|
- that.animated = false;
|
|
|
- }, 500);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- /**
|
|
|
- * 立即购买
|
|
|
- */
|
|
|
- goBuy: function (e) {
|
|
|
- if (this.isLogin === false) {
|
|
|
- toLogin();
|
|
|
- } else {
|
|
|
- //判断是否有地址
|
|
|
- if (this.attrAddrValue && this.attrAddrValue.id) {
|
|
|
- this.goCat(true);
|
|
|
- } else {
|
|
|
- this.$util.Tips({
|
|
|
- title: this.$t(`请先配置送至地址`),
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
+
|
|
|
goBuyNew(){
|
|
|
let goodsArr = []
|
|
|
this.storeInfo.goodsList.forEach(e => {
|