Refactor(商品详情):规格是否无库存通过接口查询
This commit is contained in:
@@ -25,6 +25,15 @@ export function getProductDetail(id, data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 商品规格选中
|
||||||
|
* */
|
||||||
|
export function getProductSkuBySelected(id, data) {
|
||||||
|
return request.get("api/product/getSkuBySelected/" + id, data, {
|
||||||
|
login: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 商品分销二维码
|
* 商品分销二维码
|
||||||
* */
|
* */
|
||||||
|
|||||||
@@ -19,21 +19,25 @@
|
|||||||
<view class="iconfont icon-guanbi" @click="closeAttr"></view>
|
<view class="iconfont icon-guanbi" @click="closeAttr"></view>
|
||||||
</view>
|
</view>
|
||||||
<view class="productWinList">
|
<view class="productWinList">
|
||||||
<view class="item" v-for="(item, indexw) in attr.productAttr" :key="indexw">
|
<view
|
||||||
|
class="item"
|
||||||
|
v-for="(item, index) in attr.productAttr"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
<view class="title">{{ item.attrName }}</view>
|
<view class="title">{{ item.attrName }}</view>
|
||||||
<view class="listn acea-row v12-justify-start">
|
<view class="listn acea-row v12-justify-start">
|
||||||
<view
|
<view
|
||||||
v-for="(itemn, indexn) in item.attrValue"
|
v-for="(subItem, subIndex) in item.attrValue"
|
||||||
:key="indexn"
|
:key="subIndex"
|
||||||
:class="{
|
:class="{
|
||||||
'actived': item.index == indexn,
|
'actived': item.index == subIndex,
|
||||||
'disabled': getAttrItemData(itemn.attr).stock === 0
|
'disabled': !subItem.canUsed
|
||||||
}"
|
}"
|
||||||
class="itemn v12-radius-40"
|
class="itemn v12-radius-40"
|
||||||
@click="tapAttr(indexw, indexn, itemn)"
|
@click="tapAttr(index, subIndex, subItem)"
|
||||||
>
|
>
|
||||||
{{ itemn.attr }}
|
{{ subItem.attr }}
|
||||||
<text v-if="getAttrItemData(itemn.attr).stock === 0" class="less-tag" style="color: #fff !important;">缺货</text>
|
<text v-if="!subItem.canUsed" class="less-tag" style="color: #fff !important;">缺货</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -88,56 +92,42 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
previewImg:function(imgUrl){
|
previewImg(imgUrl) {
|
||||||
uni.previewImage({
|
uni.previewImage({
|
||||||
urls:[imgUrl]
|
urls:[imgUrl]
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
closeAttr: function() {
|
closeAttr() {
|
||||||
this.$emit("changeFun", { action: "changeattr", value: false })
|
this.$emit("changeFun", { action: "changeattr", value: false })
|
||||||
},
|
},
|
||||||
CartNumDes: function() {
|
CartNumDes() {
|
||||||
this.$emit("changeFun", { action: "ChangeCartNum", value: false })
|
this.$emit("changeFun", { action: "ChangeCartNum", value: false })
|
||||||
},
|
},
|
||||||
CartNumAdd: function() {
|
CartNumAdd() {
|
||||||
this.$emit("changeFun", { action: "ChangeCartNum", value: 1 })
|
this.$emit("changeFun", { action: "ChangeCartNum", value: 1 })
|
||||||
},
|
},
|
||||||
getAttrItemData(attr) {
|
tapAttr(index, subIndex, subItem) {
|
||||||
let result = {
|
// 缺货的点击了没效果
|
||||||
stock: 0
|
if (!subItem.canUsed) {
|
||||||
}
|
|
||||||
if (this.attr.productAttr.length === 1) {
|
|
||||||
this.productValueArr.map(item => {
|
|
||||||
if (item.attrItemkey === attr) {
|
|
||||||
result = item
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
result.stock = 1
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
},
|
|
||||||
tapAttr: function(indexw, indexn, itemn) {
|
|
||||||
if (this.getAttrItemData(itemn.attr).stock === 0) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 修改商品规格不生效的原因:
|
// 修改商品规格不生效的原因:
|
||||||
// H5端下面写法,attr更新,但是除H5外其他端不支持,
|
// H5端下面写法,attr更新,但是除H5外其他端不支持,
|
||||||
// 尽量避免下面的骚写法,不要在子组件内更新props
|
// 尽量避免下面的骚写法,不要在子组件内更新props
|
||||||
// 这里修改是为了能获取到被选中的属性
|
// 这里修改是为了能获取到被选中的属性
|
||||||
this.attr.productAttr[indexw].index = indexn
|
this.attr.productAttr[index].index = subIndex
|
||||||
const value = this.getCheckedValue().sort().join(",")
|
const value = this.getCheckedValue().sort().join(",")
|
||||||
this.$emit("changeFun", {
|
this.$emit("changeFun", {
|
||||||
action: "ChangeAttr",
|
action: "ChangeAttr",
|
||||||
value: {
|
value: {
|
||||||
value,
|
value,
|
||||||
indexw,
|
index,
|
||||||
indexn
|
subIndex
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 获取被选中属性
|
// 获取被选中属性
|
||||||
getCheckedValue: function() {
|
getCheckedValue() {
|
||||||
const productAttr = this.attr.productAttr
|
const productAttr = this.attr.productAttr
|
||||||
const value = []
|
const value = []
|
||||||
for (let i = 0; i < productAttr.length; i++) {
|
for (let i = 0; i < productAttr.length; i++) {
|
||||||
|
|||||||
+309
-277
@@ -451,10 +451,11 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<ProductWindow
|
<ProductWindow
|
||||||
v-on:changeFun="changeFun"
|
v-if="productValueArr.length > 0"
|
||||||
:attr="attr"
|
:attr="attr"
|
||||||
:product-value-arr="productValueArr"
|
:product-value-arr="productValueArr"
|
||||||
:cartNum="cart_num"
|
:cartNum="cart_num"
|
||||||
|
@changeFun="changeFun"
|
||||||
/>
|
/>
|
||||||
<ServiceWin ref="serviceWin" :info="storeInfo.guarantee" />
|
<ServiceWin ref="serviceWin" :info="storeInfo.guarantee" />
|
||||||
<StorePoster v-on:setPosterImageStatus="setPosterImageStatus" :posterImageStatus="posterImageStatus"
|
<StorePoster v-on:setPosterImageStatus="setPosterImageStatus" :posterImageStatus="posterImageStatus"
|
||||||
@@ -482,29 +483,47 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ProductConSwiper from "@/components/ProductConSwiper";
|
import ProductConSwiper from '@/components/ProductConSwiper'
|
||||||
import UserEvaluation from "@/components/UserEvaluation";
|
import UserEvaluation from '@/components/UserEvaluation'
|
||||||
import ProductWindow from "@/components/ProductWindow";
|
import ProductWindow from '@/components/ProductWindow'
|
||||||
import StorePoster from "@/components/StorePoster";
|
import StorePoster from '@/components/StorePoster'
|
||||||
import ShareInfo from "@/components/ShareInfo";
|
import ShareInfo from '@/components/ShareInfo'
|
||||||
import CountDown from "@/components/CountDown";
|
import CountDown from '@/components/CountDown'
|
||||||
import ServiceWin from "@/components/ServiceWin";
|
import ServiceWin from '@/components/ServiceWin'
|
||||||
import {getCartCount, getProductCode, getProductDetail, postCartAdd} from "@/api/store";
|
import {
|
||||||
import {userBindParent} from "@/api/user";
|
getCartCount,
|
||||||
import {handleQrCode, isWeixin} from "@/utils";
|
getProductCode,
|
||||||
import {getHomeData} from "@/api/public";
|
getProductDetail,
|
||||||
import {getDailyGoods, getPreSale, getYxStoreSeckill} from "@/api/goods";
|
postCartAdd,
|
||||||
import {mapGetters} from "vuex";
|
getProductSkuBySelected
|
||||||
import {diffDay, formatDateTime} from "@/utils/index";
|
} from '@/api/store'
|
||||||
import {getCurAddress, getLocation, getUrlParam} from "@/utils/common.js";
|
import { userBindParent } from '@/api/user'
|
||||||
import cookie from "@/utils/store/cookie";
|
import { handleQrCode, isWeixin } from '@/utils'
|
||||||
import {famousGoodsShareImage, secKillGoodsShareImage} from "@/api/share";
|
import { getHomeData } from '@/api/public'
|
||||||
import CouponsPopup from "@/components/CouponsPopup.vue"
|
import {
|
||||||
import {addProduct, checkProduct, removeProduct} from "@/api/favorite";
|
getDailyGoods,
|
||||||
|
getPreSale,
|
||||||
|
getYxStoreSeckill
|
||||||
|
} from '@/api/goods'
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
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 {
|
||||||
|
addProduct,
|
||||||
|
checkProduct,
|
||||||
|
removeProduct
|
||||||
|
} from '@/api/favorite'
|
||||||
import { pageListenMixins } from '@/mixins/pageListenMixins'
|
import { pageListenMixins } from '@/mixins/pageListenMixins'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "GoodsCon",
|
name: 'GoodsCon',
|
||||||
components: {
|
components: {
|
||||||
CountDown,
|
CountDown,
|
||||||
ProductConSwiper,
|
ProductConSwiper,
|
||||||
@@ -518,16 +537,17 @@ export default {
|
|||||||
mixins: [pageListenMixins],
|
mixins: [pageListenMixins],
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
isProductInfoExpand: true, //商品信息是否展开
|
// 商品信息是否展开
|
||||||
|
isProductInfoExpand: true,
|
||||||
shareInfoStatus: false,
|
shareInfoStatus: false,
|
||||||
weixinStatus: false,
|
weixinStatus: false,
|
||||||
mapShow: false,
|
mapShow: false,
|
||||||
mapKey: "",
|
mapKey: '',
|
||||||
posterData: {
|
posterData: {
|
||||||
image: "",
|
image: '',
|
||||||
title: "",
|
title: '',
|
||||||
price: "",
|
price: '',
|
||||||
code: ""
|
code: ''
|
||||||
},
|
},
|
||||||
posterImageStatus: false,
|
posterImageStatus: false,
|
||||||
animated: false,
|
animated: false,
|
||||||
@@ -540,22 +560,23 @@ export default {
|
|||||||
productAttr: [],
|
productAttr: [],
|
||||||
productSelect: {}
|
productSelect: {}
|
||||||
},
|
},
|
||||||
isOpen: false, //是否打开属性组件
|
// 是否打开属性组件
|
||||||
|
isOpen: false,
|
||||||
productValueArr: [],
|
productValueArr: [],
|
||||||
id: null,
|
id: null,
|
||||||
partnerId: null,
|
partnerId: null,
|
||||||
activityId: 0, // v4 add
|
activityId: 0, // v4 add
|
||||||
source: "", // v4 add
|
source: '', // v4 add
|
||||||
preInfo: {},
|
preInfo: {},
|
||||||
killInfo: {},
|
killInfo: {},
|
||||||
dayInfo: {},
|
dayInfo: {},
|
||||||
storeInfo: {},
|
storeInfo: {},
|
||||||
couponList: {},
|
couponList: {},
|
||||||
attrTxt: "请选择",
|
attrTxt: '请选择',
|
||||||
attrValue: "",
|
attrValue: '',
|
||||||
cart_num: 1, // 购买数量
|
cart_num: 1, // 购买数量
|
||||||
replyCount: "",
|
replyCount: '',
|
||||||
replyChance: "",
|
replyChance: '',
|
||||||
reply: [],
|
reply: [],
|
||||||
priceName: 0,
|
priceName: 0,
|
||||||
CartCount: 0,
|
CartCount: 0,
|
||||||
@@ -563,7 +584,7 @@ export default {
|
|||||||
banner: [{}, {}],
|
banner: [{}, {}],
|
||||||
swiperRecommend: {
|
swiperRecommend: {
|
||||||
pagination: {
|
pagination: {
|
||||||
el: ".swiper-pagination",
|
el: '.swiper-pagination',
|
||||||
clickable: true
|
clickable: true
|
||||||
},
|
},
|
||||||
autoplay: false,
|
autoplay: false,
|
||||||
@@ -575,8 +596,8 @@ export default {
|
|||||||
goodList: [],
|
goodList: [],
|
||||||
systemStore: {},
|
systemStore: {},
|
||||||
qqmapsdk: null,
|
qqmapsdk: null,
|
||||||
productConClass: "product-con",
|
productConClass: 'product-con',
|
||||||
tempName: "",
|
tempName: '',
|
||||||
merBestProducts: [],
|
merBestProducts: [],
|
||||||
buyNotice: null,
|
buyNotice: null,
|
||||||
isWenwan: 0,
|
isWenwan: 0,
|
||||||
@@ -592,19 +613,18 @@ export default {
|
|||||||
qualifications: []
|
qualifications: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: mapGetters(["isLogin", "location", "userInfo"]),
|
computed: mapGetters(['isLogin', 'location', 'userInfo']),
|
||||||
onShareAppMessage() {
|
onShareAppMessage() {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
let result;
|
let result;
|
||||||
let params = `?id=${this.id}&partnerId=${this.userInfo.uid}`;
|
let params = `?id=${this.id}&partnerId=${this.userInfo.uid}`
|
||||||
if (this.source === 'famous') {
|
if (this.source === 'famous') {
|
||||||
result = await famousGoodsShareImage(this.id);
|
result = await famousGoodsShareImage(this.id)
|
||||||
}
|
}
|
||||||
if (this.source === 'kill') {
|
if (this.source === 'kill') {
|
||||||
result = await secKillGoodsShareImage(this.activityId);
|
result = await secKillGoodsShareImage(this.activityId)
|
||||||
params += `&activityId=${this.activityId}`
|
params += `&activityId=${this.activityId}`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result?.status === 200) {
|
if (result?.status === 200) {
|
||||||
resolve({
|
resolve({
|
||||||
title: this.storeInfo.storeName,
|
title: this.storeInfo.storeName,
|
||||||
@@ -620,12 +640,11 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onLoad: function (options) {
|
onLoad(options) {
|
||||||
// test data
|
// test data
|
||||||
console.log("getLaunchOptionsSync", uni.getLaunchOptionsSync());
|
console.log("getLaunchOptionsSync", uni.getLaunchOptionsSync())
|
||||||
console.log("getEnterOptionsSync", uni.getEnterOptionsSync());
|
console.log("getEnterOptionsSync", uni.getEnterOptionsSync())
|
||||||
uni.removeStorageSync('couponId')
|
uni.removeStorageSync('couponId')
|
||||||
|
|
||||||
const from = options.from
|
const from = options.from
|
||||||
const id = options.id
|
const id = options.id
|
||||||
switch (from) {
|
switch (from) {
|
||||||
@@ -669,28 +688,27 @@ export default {
|
|||||||
this.pageKeyId = `product_from_common_productId_${id}`
|
this.pageKeyId = `product_from_common_productId_${id}`
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
const url = handleQrCode()
|
||||||
let url = handleQrCode();
|
|
||||||
if (url && url.productId) {
|
if (url && url.productId) {
|
||||||
this.id = url.productId;
|
this.id = url.productId
|
||||||
} else if (options.id) {
|
} else if (options.id) {
|
||||||
this.id = options.id || null;
|
this.id = options.id || null
|
||||||
this.partnerId = options.partnerId || null;
|
this.partnerId = options.partnerId || null
|
||||||
this.activityId = this._route.query.activityId;
|
this.activityId = this._route.query.activityId
|
||||||
this.source = this._route.query.from || "";
|
this.source = this._route.query.from || ''
|
||||||
} else {
|
} else {
|
||||||
let obj = uni.getEnterOptionsSync();
|
const obj = uni.getEnterOptionsSync()
|
||||||
if (options.scene != null || obj.query.scene != null) {
|
if (options.scene != null || obj.query.scene != null) {
|
||||||
let query = options ? decodeURIComponent(options.scene) : decodeURIComponent(obj.query.scene);
|
const query = options ? decodeURIComponent(options.scene) : decodeURIComponent(obj.query.scene)
|
||||||
this.id = getUrlParam(query, "id") || null;
|
this.id = getUrlParam(query, 'id') || null
|
||||||
this.partnerId = getUrlParam(query, "partnerId") || null;
|
this.partnerId = getUrlParam(query, 'partnerId') || null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.partnerId) cookie.set("spread", this.partnerId);
|
if (this.partnerId) cookie.set('spread', this.partnerId)
|
||||||
|
|
||||||
// 已登录状态的扫码进入绑定一下上级
|
// 已登录状态的扫码进入绑定一下上级
|
||||||
if (url != null && url.spread != null) {
|
if (url != null && url.spread != null) {
|
||||||
let urlSpread = parseInt(url.spread);
|
const urlSpread = parseInt(url.spread);
|
||||||
if (!Number.isNaN(urlSpread)) {
|
if (!Number.isNaN(urlSpread)) {
|
||||||
//绑定上级
|
//绑定上级
|
||||||
userBindParent({
|
userBindParent({
|
||||||
@@ -702,23 +720,19 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.productCon()
|
||||||
setTimeout(() => {
|
this.fetchCompanyDatea()
|
||||||
this.productCon();
|
|
||||||
this.fetchCompanyDatea();
|
|
||||||
|
|
||||||
switch (this.source) {
|
switch (this.source) {
|
||||||
case "pre":
|
case "pre":
|
||||||
this.getPreInfo();
|
this.getPreInfo()
|
||||||
break;
|
break
|
||||||
case "kill":
|
case "kill":
|
||||||
this.getKillInfo();
|
this.getKillInfo()
|
||||||
break;
|
break
|
||||||
case "day":
|
case "day":
|
||||||
this.getDayInfo();
|
this.getDayInfo()
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
}, 500)
|
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
this.getMapData()
|
this.getMapData()
|
||||||
@@ -726,9 +740,9 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
posterImageStatus(status) {
|
posterImageStatus(status) {
|
||||||
if (status) {
|
if (status) {
|
||||||
this.productConClass = "noscroll product-con";
|
this.productConClass = 'noscroll product-con'
|
||||||
} else {
|
} else {
|
||||||
this.productConClass = "product-con";
|
this.productConClass = 'product-con'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
attr: {
|
attr: {
|
||||||
@@ -749,7 +763,7 @@ export default {
|
|||||||
qualifications: this.qualifications
|
qualifications: this.qualifications
|
||||||
}
|
}
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url:'/pages/shop/GoodsCon/qualifications?mer=' + JSON.stringify(merInfo),
|
url: '/pages/shop/GoodsCon/qualifications?mer=' + JSON.stringify(merInfo)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goRoom() {
|
goRoom() {
|
||||||
@@ -767,7 +781,7 @@ export default {
|
|||||||
url: `/pkg_common/views/room?id=${this.storeInfo.merId}&name=${this.storeInfo.merName}¶ms=${JSON.stringify(params)}`
|
url: `/pkg_common/views/room?id=${this.storeInfo.merId}&name=${this.storeInfo.merName}¶ms=${JSON.stringify(params)}`
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goodsDetail: function (item) {
|
goodsDetail(item) {
|
||||||
this.$yrouter.push({
|
this.$yrouter.push({
|
||||||
path: '/pages/shop/GoodsCon/index',
|
path: '/pages/shop/GoodsCon/index',
|
||||||
query: {
|
query: {
|
||||||
@@ -776,34 +790,31 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
async getMapData() {
|
async getMapData() {
|
||||||
let location = uni.getStorageSync("location");
|
let location = uni.getStorageSync('location')
|
||||||
|
|
||||||
if (location.length === 0) {
|
if (location.length === 0) {
|
||||||
const map = await getLocation();
|
const map = await getLocation()
|
||||||
if (map.length > 1) {
|
if (map.length > 1) {
|
||||||
const {latitude, longitude} = map[1];
|
const {latitude, longitude} = map[1]
|
||||||
let address = await getCurAddress(latitude, longitude);
|
let address = await getCurAddress(latitude, longitude)
|
||||||
address = address[1].data.result.ad_info;
|
address = address[1].data.result.ad_info
|
||||||
location = address.province + address.city + address.district;
|
location = address.province + address.city + address.district
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.postAddress = location
|
||||||
this.postAddress = location;
|
|
||||||
},
|
},
|
||||||
// 获取当前位置经纬度
|
// 获取当前位置经纬度
|
||||||
handleLoacation(toast) {
|
handleLoacation(toast) {
|
||||||
let that = this;
|
const that = this
|
||||||
uni.getLocation({
|
uni.getLocation({
|
||||||
type: 'gcj02',
|
type: 'gcj02',
|
||||||
success: async (res) => {
|
success: async (res) => {
|
||||||
// 获取到经纬度后根据实际业务做处理,下面业务逻辑仅供参考
|
// 获取到经纬度后根据实际业务做处理,下面业务逻辑仅供参考
|
||||||
|
|
||||||
const map = await getLocation();
|
const map = await getLocation();
|
||||||
if (map.length > 1) {
|
if (map.length > 1) {
|
||||||
const {latitude, longitude} = map[1];
|
const {latitude, longitude} = map[1]
|
||||||
let address = await getCurAddress(latitude, longitude);
|
let address = await getCurAddress(latitude, longitude)
|
||||||
address = address[1].data.result.ad_info;
|
address = address[1].data.result.ad_info
|
||||||
that.postAddress = address.province + address.city + address.district;
|
that.postAddress = address.province + address.city + address.district
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: err => {
|
fail: err => {
|
||||||
@@ -883,44 +894,44 @@ export default {
|
|||||||
},
|
},
|
||||||
changeExEnd() {
|
changeExEnd() {
|
||||||
if (this.exSliceEnd === 3) {
|
if (this.exSliceEnd === 3) {
|
||||||
this.exSliceEnd = this.storeInfo.exPropertiesData.length;
|
this.exSliceEnd = this.storeInfo.exPropertiesData.length
|
||||||
} else {
|
} else {
|
||||||
this.exSliceEnd = 3;
|
this.exSliceEnd = 3
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// v4 预售
|
// v4 预售
|
||||||
getPreInfo() {
|
getPreInfo() {
|
||||||
getPreSale(this.activityId).then(({ data }) => {
|
getPreSale(this.activityId).then(({ data }) => {
|
||||||
var now = new Date().getTime();
|
const now = new Date().getTime();
|
||||||
var nowStr = formatDateTime(now, 'yyyy-MM-dd');
|
const nowStr = formatDateTime(now, 'yyyy-MM-dd');
|
||||||
data.surplus = diffDay(nowStr, data.stopTime.substring(0, 10))
|
data.surplus = diffDay(nowStr, data.stopTime.substring(0, 10))
|
||||||
this.preInfo = data;
|
this.preInfo = data
|
||||||
this.handleAttr(data);
|
this.handleAttr(data)
|
||||||
}).catch(err => console.warn("err=", err))
|
}).catch(err => console.warn("err=", err))
|
||||||
},
|
},
|
||||||
// v4 秒杀
|
// v4 秒杀
|
||||||
getKillInfo() {
|
getKillInfo() {
|
||||||
getYxStoreSeckill(this.activityId).then(({ data }) => {
|
getYxStoreSeckill(this.activityId).then(({ data }) => {
|
||||||
let stopTime = data.storeInfo.stopTime;
|
const stopTime = data.storeInfo.stopTime
|
||||||
let stopDate = new Date(stopTime.replace(/-/g, "/"));
|
const stopDate = new Date(stopTime.replace(/-/g, "/"))
|
||||||
data.stop = Math.floor(stopDate.getTime() / 1000);
|
data.stop = Math.floor(stopDate.getTime() / 1000)
|
||||||
this.killInfo = data
|
this.killInfo = data
|
||||||
this.handleAttr(data);
|
this.handleAttr(data)
|
||||||
}).catch(err => console.warn("err=", err))
|
}).catch(err => console.warn("err=", err))
|
||||||
},
|
},
|
||||||
// v4 每日特价
|
// v4 每日特价
|
||||||
getDayInfo() {
|
getDayInfo() {
|
||||||
getDailyGoods(this.activityId).then(({ data }) => {
|
getDailyGoods(this.activityId).then(({ data }) => {
|
||||||
let stopTime = data.stopTime;
|
const stopTime = data.stopTime
|
||||||
let stopDate = new Date(stopTime.replace(/-/g, "/"));
|
const stopDate = new Date(stopTime.replace(/-/g, "/"))
|
||||||
data.stop = Math.floor(stopDate.getTime() / 1000);
|
data.stop = Math.floor(stopDate.getTime() / 1000)
|
||||||
this.dayInfo = data
|
this.dayInfo = data
|
||||||
this.handleAttr(data);
|
this.handleAttr(data)
|
||||||
}).catch(err => console.warn("err=", err))
|
}).catch(err => console.warn("err=", err))
|
||||||
},
|
},
|
||||||
// 关联商品规格
|
// 关联商品规格
|
||||||
handleAttr(data) {
|
handleAttr(data) {
|
||||||
this.$set(this.attr, "productAttr", data.productAttr)
|
this.$set(this.attr, 'productAttr', data.productAttr)
|
||||||
this.productValueArr = []
|
this.productValueArr = []
|
||||||
for (const key in data.productValue) {
|
for (const key in data.productValue) {
|
||||||
this.productValueArr.push({
|
this.productValueArr.push({
|
||||||
@@ -930,66 +941,66 @@ export default {
|
|||||||
}
|
}
|
||||||
this.DefaultSelect()
|
this.DefaultSelect()
|
||||||
},
|
},
|
||||||
fetchCompanyDatea: function () {
|
fetchCompanyDatea() {
|
||||||
var that = this;
|
const that = this
|
||||||
getHomeData().then(res => {
|
getHomeData().then(res => {
|
||||||
that.buyNotice = res.data.buyNotice.replace(
|
that.buyNotice = res.data.buyNotice.replace(
|
||||||
/\<img/gi,
|
/\<img/gi,
|
||||||
'<img style="max-width:100%;height:auto;"'
|
'<img style="max-width:100%;height:auto;"'
|
||||||
);
|
)
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
force2Decimal(v) {
|
force2Decimal(v) {
|
||||||
return this.$force2Decimal(v);
|
return this.$force2Decimal(v)
|
||||||
},
|
},
|
||||||
goShoppingCart() {
|
goShoppingCart() {
|
||||||
this.$yrouter.switchTab("/pages/cart");
|
this.$yrouter.switchTab('/pages/cart')
|
||||||
},
|
},
|
||||||
goStoreList() {
|
goStoreList() {
|
||||||
this.$yrouter.push({
|
this.$yrouter.push({
|
||||||
path: "/pages/shop/StoreList/index"
|
path: '/pages/shop/StoreList/index'
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
goEvaluateList(id) {
|
goEvaluateList(id) {
|
||||||
this.$yrouter.push({
|
this.$yrouter.push({
|
||||||
path: "/pages/shop/EvaluateList/index",
|
path: '/pages/shop/EvaluateList/index',
|
||||||
query: {
|
query: {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
// 2022/9/28 add
|
// 2022/9/28 add
|
||||||
goStore() {
|
goStore() {
|
||||||
this.$yrouter.push({
|
this.$yrouter.push({
|
||||||
path: "/pagesInn/inn/innHome",
|
path: '/pagesInn/inn/innHome',
|
||||||
query: {
|
query: {
|
||||||
id: this.systemStore.id
|
id: this.systemStore.id
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
showChang: function (data) {
|
showChang(data) {
|
||||||
this.$yrouter.push({
|
this.$yrouter.push({
|
||||||
path: "/pages/map/index",
|
path: '/pages/map/index',
|
||||||
query: data
|
query: data
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
setShareInfoStatus: function () {
|
setShareInfoStatus() {
|
||||||
this.shareInfoStatus = !this.shareInfoStatus;
|
this.shareInfoStatus = !this.shareInfoStatus
|
||||||
this.posters = false;
|
this.posters = false
|
||||||
},
|
},
|
||||||
shareCode: function () {
|
shareCode() {
|
||||||
var that = this;
|
const that = this
|
||||||
getProductCode(that.id).then(res => {
|
getProductCode(that.id).then(res => {
|
||||||
that.posterData.code = res.data.code;
|
that.posterData.code = res.data.code
|
||||||
that.listenerActionSheet();
|
that.listenerActionSheet()
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
setPosterImageStatus: function () {
|
setPosterImageStatus() {
|
||||||
this.posterImageStatus = !this.posterImageStatus;
|
this.posterImageStatus = !this.posterImageStatus
|
||||||
this.posters = false;
|
this.posters = false
|
||||||
},
|
},
|
||||||
// 产品详情接口
|
// 产品详情接口
|
||||||
productCon: function () {
|
productCon() {
|
||||||
const from = this.location
|
const from = this.location
|
||||||
if (this.$deviceType == 'app') {
|
if (this.$deviceType == 'app') {
|
||||||
from.from = 'app'
|
from.from = 'app'
|
||||||
@@ -1016,6 +1027,12 @@ export default {
|
|||||||
...data.productValue[key]
|
...data.productValue[key]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 初始化认为所有的规格都是可以选的
|
||||||
|
this.attr.productAttr.map(item => {
|
||||||
|
item.attrValue.map(subItem => {
|
||||||
|
subItem.canUsed = true
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
this.attr.defaultSku = data.defaultSku
|
this.attr.defaultSku = data.defaultSku
|
||||||
this.attr.defaultSkuIndex = data.defaultSkuIndex
|
this.attr.defaultSkuIndex = data.defaultSkuIndex
|
||||||
@@ -1069,7 +1086,6 @@ export default {
|
|||||||
this.$set(this, 'goodList', goodArray)
|
this.$set(this, 'goodList', goodArray)
|
||||||
this.DefaultSelect()
|
this.DefaultSelect()
|
||||||
this.getCartCount()
|
this.getCartCount()
|
||||||
|
|
||||||
// 动态配置share
|
// 动态配置share
|
||||||
this.$set(this, 'share', {
|
this.$set(this, 'share', {
|
||||||
title: this.storeInfo.storeName,
|
title: this.storeInfo.storeName,
|
||||||
@@ -1097,14 +1113,13 @@ export default {
|
|||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
//默认选中属性;
|
// 默认选中属性
|
||||||
DefaultSelect: function () {
|
DefaultSelect() {
|
||||||
const productAttr = this.attr.productAttr
|
const productAttr = this.attr.productAttr
|
||||||
for (let i = 0; i < productAttr.length; i++) {
|
for (let i = 0; i < productAttr.length; i++) {
|
||||||
this.$set(productAttr[i], "index", this.attr.defaultSkuIndex[i]);
|
this.$set(productAttr[i], "index", this.attr.defaultSkuIndex[i])
|
||||||
}
|
}
|
||||||
|
const skuKey = (this.attr.defaultSku || []).join(',')
|
||||||
const skuKey = this.attr.defaultSku?.join(',')
|
|
||||||
if (!skuKey) {
|
if (!skuKey) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1112,267 +1127,284 @@ export default {
|
|||||||
if (productSelect && productAttr.length) {
|
if (productSelect && productAttr.length) {
|
||||||
this.$set(
|
this.$set(
|
||||||
this.attr.productSelect,
|
this.attr.productSelect,
|
||||||
"store_name",
|
'store_name',
|
||||||
this.storeInfo.storeName
|
this.storeInfo.storeName
|
||||||
);
|
)
|
||||||
this.$set(this.attr.productSelect, "image", productSelect.image);
|
this.$set(this.attr.productSelect, 'image', productSelect.image)
|
||||||
this.$set(this.attr.productSelect, "price", productSelect.price);
|
this.$set(this.attr.productSelect, 'price', productSelect.price)
|
||||||
this.$set(this.attr.productSelect, "otPrice", productSelect.otPrice);
|
this.$set(this.attr.productSelect, 'otPrice', productSelect.otPrice)
|
||||||
this.$set(this.attr.productSelect, "stock", productSelect.stock);
|
this.$set(this.attr.productSelect, 'stock', productSelect.stock)
|
||||||
this.$set(this.attr.productSelect, "unique", productSelect.unique);
|
this.$set(this.attr.productSelect, 'unique', productSelect.unique)
|
||||||
this.$set(this.attr.productSelect, "cart_num", 1);
|
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, 'attrValue', skuKey)
|
||||||
this.$set(this, "attrTxt", "已选择");
|
this.$set(this, 'attrTxt', '已选择')
|
||||||
|
this.getSkuActiveStatus(skuKey)
|
||||||
} else if (!productSelect && productAttr.length) {
|
} else if (!productSelect && productAttr.length) {
|
||||||
this.$set(
|
this.$set(
|
||||||
this.attr.productSelect,
|
this.attr.productSelect,
|
||||||
"store_name",
|
'store_name',
|
||||||
this.storeInfo.storeName
|
this.storeInfo.storeName
|
||||||
);
|
)
|
||||||
this.$set(this.attr.productSelect, "image", this.storeInfo.image);
|
this.$set(this.attr.productSelect, 'image', this.storeInfo.image)
|
||||||
this.$set(this.attr.productSelect, "price", this.storeInfo.price);
|
this.$set(this.attr.productSelect, 'price', this.storeInfo.price)
|
||||||
this.$set(this.attr.productSelect, "otPrice", this.storeInfo.otPrice);
|
this.$set(this.attr.productSelect, 'otPrice', this.storeInfo.otPrice)
|
||||||
this.$set(this.attr.productSelect, "stock", 0);
|
this.$set(this.attr.productSelect, 'stock', 0)
|
||||||
this.$set(this.attr.productSelect, "unique", "");
|
this.$set(this.attr.productSelect, 'unique', '')
|
||||||
this.$set(this.attr.productSelect, "cart_num", 0);
|
this.$set(this.attr.productSelect, 'cart_num', 0)
|
||||||
this.$set(this, "attrValue", "");
|
this.$set(this, 'attrValue', '')
|
||||||
this.$set(this, "attrTxt", "请选择");
|
this.$set(this, 'attrTxt', '请选择')
|
||||||
} else if (!productSelect && !productAttr.length) {
|
} else if (!productSelect && !productAttr.length) {
|
||||||
this.$set(
|
this.$set(
|
||||||
this.attr.productSelect,
|
this.attr.productSelect,
|
||||||
"store_name",
|
'store_name',
|
||||||
this.storeInfo.storeName
|
this.storeInfo.storeName
|
||||||
);
|
)
|
||||||
this.$set(this.attr.productSelect, "image", this.storeInfo.image);
|
this.$set(this.attr.productSelect, 'image', this.storeInfo.image)
|
||||||
this.$set(this.attr.productSelect, "price", this.storeInfo.price);
|
this.$set(this.attr.productSelect, 'price', this.storeInfo.price)
|
||||||
this.$set(this.attr.productSelect, "otPrice", this.storeInfo.otPrice);
|
this.$set(this.attr.productSelect, 'otPrice', this.storeInfo.otPrice)
|
||||||
this.$set(this.attr.productSelect, "stock", this.storeInfo.stock);
|
this.$set(this.attr.productSelect, 'stock', this.storeInfo.stock)
|
||||||
this.$set(
|
this.$set(
|
||||||
this.attr.productSelect,
|
this.attr.productSelect,
|
||||||
"unique",
|
'unique',
|
||||||
this.storeInfo.unique || ""
|
this.storeInfo.unique || ''
|
||||||
);
|
)
|
||||||
this.$set(this.attr.productSelect, "cart_num", 1);
|
this.$set(this.attr.productSelect, 'cart_num', 1)
|
||||||
this.$set(this, "attrValue", "");
|
this.$set(this, 'attrValue', '')
|
||||||
this.$set(this, "attrTxt", "请选择");
|
this.$set(this, 'attrTxt', '请选择')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//购物车;
|
// 购物车
|
||||||
ChangeCartNum: function (changeValue) {
|
ChangeCartNum(changeValue) {
|
||||||
// changeValue:是否 加|减
|
// changeValue:是否 加|减
|
||||||
// 获取当前变动属性
|
// 获取当前变动属性
|
||||||
const productSelect = this.getAttrItemData(this.attrValue);
|
const productSelect = this.getAttrItemData(this.attrValue)
|
||||||
// 如果没有属性,赋值给商品默认库存
|
// 如果没有属性,赋值给商品默认库存
|
||||||
if (productSelect === undefined && !this.attr.productAttr.length) {
|
if (productSelect === undefined && !this.attr.productAttr.length) {
|
||||||
productSelect = this.attr.productSelect;
|
productSelect = this.attr.productSelect
|
||||||
}
|
}
|
||||||
//无属性值即库存为0;不存在加减;
|
// 无属性值即库存为0;不存在加减
|
||||||
if (productSelect === undefined) return;
|
if (productSelect === undefined) return
|
||||||
let stock = productSelect.stock || 0;
|
let stock = productSelect.stock || 0
|
||||||
let num = this.attr.productSelect;
|
let num = this.attr.productSelect
|
||||||
if (changeValue) {
|
if (changeValue) {
|
||||||
num.cart_num++;
|
num.cart_num++
|
||||||
if (num.cart_num > stock) {
|
if (num.cart_num > stock) {
|
||||||
if(stock < 1) {
|
if(stock < 1) {
|
||||||
this.$set(this.attr.productSelect, "cart_num", 1);
|
this.$set(this.attr.productSelect, 'cart_num', 1)
|
||||||
this.$set(this, "cart_num", 1);
|
this.$set(this, 'cart_num', 1)
|
||||||
} else {
|
} else {
|
||||||
this.$set(this.attr.productSelect, "cart_num", stock);
|
this.$set(this.attr.productSelect, 'cart_num', stock)
|
||||||
this.$set(this, "cart_num", stock);
|
this.$set(this, 'cart_num', stock)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (num.cart_num < 1) {
|
if (num.cart_num < 1) {
|
||||||
this.$set(this.attr.productSelect, "cart_num", 1);
|
this.$set(this.attr.productSelect, 'cart_num', 1)
|
||||||
this.$set(this, "cart_num", 1);
|
this.$set(this, 'cart_num', 1)
|
||||||
} else {
|
} else {
|
||||||
this.$set(this.attr.productSelect, "cart_num", num.cart_num);
|
this.$set(this.attr.productSelect, 'cart_num', num.cart_num)
|
||||||
this.$set(this, "cart_num", num.cart_num);
|
this.$set(this, 'cart_num', num.cart_num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
num.cart_num--;
|
num.cart_num--
|
||||||
if (num.cart_num < 1) {
|
if (num.cart_num < 1) {
|
||||||
this.$set(this.attr.productSelect, "cart_num", 1);
|
this.$set(this.attr.productSelect, 'cart_num', 1)
|
||||||
this.$set(this, "cart_num", 1);
|
this.$set(this, 'cart_num', 1)
|
||||||
} else {
|
} else {
|
||||||
this.$set(this.attr.productSelect, "cart_num", num.cart_num);
|
this.$set(this.attr.productSelect, 'cart_num', num.cart_num)
|
||||||
this.$set(this, "cart_num", num.cart_num);
|
this.$set(this, 'cart_num', num.cart_num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//将父级向子集多次传送的函数合二为一;
|
// 将父级向子集多次传送的函数合二为一
|
||||||
changeFun: function (opt) {
|
changeFun(opt) {
|
||||||
if (typeof opt !== "object") opt = {};
|
if (typeof opt !== 'object') opt = {}
|
||||||
let action = opt.action || "";
|
let action = opt.action || ''
|
||||||
let value = opt.value === undefined ? "" : opt.value;
|
let value = opt.value === undefined ? '' : opt.value
|
||||||
this.cart_num = 1
|
this.cart_num = 1
|
||||||
this[action] && this[action](value);
|
this[action] && this[action](value)
|
||||||
},
|
},
|
||||||
|
// 打开属性插件
|
||||||
//打开属性插件;
|
selecAttrTap() {
|
||||||
selecAttrTap: function () {
|
this.attr.cartAttr = true
|
||||||
this.attr.cartAttr = true;
|
this.isOpen = true
|
||||||
this.isOpen = true;
|
|
||||||
},
|
},
|
||||||
changeattr: function (msg) {
|
changeattr(msg) {
|
||||||
|
|
||||||
// 修改了规格
|
// 修改了规格
|
||||||
this.attr.cartAttr = msg;
|
this.attr.cartAttr = msg
|
||||||
this.isOpen = false;
|
this.isOpen = false
|
||||||
},
|
},
|
||||||
//选择属性;
|
// 选择属性
|
||||||
ChangeAttr: function (res) {
|
ChangeAttr(res) {
|
||||||
|
const value = res.value
|
||||||
// 修改了规格
|
// 修改了规格
|
||||||
let productSelect = this.getAttrItemData(res.value)
|
let productSelect = this.getAttrItemData(value)
|
||||||
if (productSelect) {
|
if (productSelect) {
|
||||||
this.attr.productAttr[res.indexw].index = res.indexn;
|
this.attr.productAttr[res.index].index = res.subIndex
|
||||||
this.$set(this.attr.productSelect, "image", productSelect.image);
|
this.$set(this.attr.productSelect, 'image', productSelect.image)
|
||||||
this.$set(this.attr.productSelect, "price", productSelect.price);
|
this.$set(this.attr.productSelect, 'price', productSelect.price)
|
||||||
this.$set(this.attr.productSelect, "otPrice", productSelect.otPrice);
|
this.$set(this.attr.productSelect, 'otPrice', productSelect.otPrice)
|
||||||
this.$set(this.attr.productSelect, "stock", productSelect.stock);
|
this.$set(this.attr.productSelect, 'stock', productSelect.stock)
|
||||||
this.$set(this.attr.productSelect, "unique", productSelect.unique);
|
this.$set(this.attr.productSelect, 'unique', productSelect.unique)
|
||||||
this.$set(this.attr.productSelect, "cart_num", 1);
|
this.$set(this.attr.productSelect, 'cart_num', 1)
|
||||||
this.$set(this, "attrValue", res.value);
|
this.$set(this, 'attrValue', value)
|
||||||
this.$set(this, "attrTxt", "已选择");
|
this.$set(this, 'attrTxt', '已选择')
|
||||||
|
this.getSkuActiveStatus(value)
|
||||||
} else {
|
} else {
|
||||||
this.$set(this.attr.productSelect, "image", this.storeInfo.image);
|
this.$set(this.attr.productSelect, 'image', this.storeInfo.image)
|
||||||
this.$set(this.attr.productSelect, "price", this.storeInfo.price);
|
this.$set(this.attr.productSelect, 'price', this.storeInfo.price)
|
||||||
this.$set(this.attr.productSelect, "otPrice", this.storeInfo.otPrice);
|
this.$set(this.attr.productSelect, 'otPrice', this.storeInfo.otPrice)
|
||||||
this.$set(this.attr.productSelect, "stock", 0);
|
this.$set(this.attr.productSelect, 'stock', 0)
|
||||||
this.$set(this.attr.productSelect, "unique", "");
|
this.$set(this.attr.productSelect, 'unique', '')
|
||||||
this.$set(this.attr.productSelect, "cart_num", 0);
|
this.$set(this.attr.productSelect, 'cart_num', 0)
|
||||||
this.$set(this, "attrValue", "");
|
this.$set(this, 'attrValue', '')
|
||||||
this.$set(this, "attrTxt", "请选择");
|
this.$set(this, 'attrTxt', '请选择')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 获取规格组是否能点击(右上角是否有缺货标识)
|
||||||
|
getSkuActiveStatus(selectedSku) {
|
||||||
|
getProductSkuBySelected(this.id, { selectedSku }).then(res => {
|
||||||
|
const { success, data } = res
|
||||||
|
if (success) {
|
||||||
|
for (const key in data) {
|
||||||
|
if (data[key]) {
|
||||||
|
this.attr.productAttr.map(item => {
|
||||||
|
if (item.attrName === key) {
|
||||||
|
item.attrValue.map(subItem => {
|
||||||
|
data[key].map(dataItem => {
|
||||||
|
if (dataItem.sku === subItem.attr) {
|
||||||
|
subItem.canUsed = dataItem.canUsed
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
// 点击加入购物车按钮
|
// 点击加入购物车按钮
|
||||||
joinCart: function () {
|
joinCart() {
|
||||||
if ((this.attr.productSelect.stock === 0 && this.attr.cartAttr) || this.storeInfo.stock === 0) {
|
if ((this.attr.productSelect.stock === 0 && this.attr.cartAttr) || this.storeInfo.stock === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 0=加入购物车
|
// 0=加入购物车
|
||||||
this.goCat(0);
|
this.goCat(0)
|
||||||
},
|
},
|
||||||
//立即购买;
|
// 立即购买
|
||||||
tapBuy: function () {
|
tapBuy() {
|
||||||
if ((this.attr.productSelect.stock === 0 && this.attr.cartAttr) || this.storeInfo.stock === 0) {
|
if ((this.attr.productSelect.stock === 0 && this.attr.cartAttr) || this.storeInfo.stock === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 1=直接购买
|
// 1=直接购买
|
||||||
this.goCat(1);
|
this.goCat(1)
|
||||||
},
|
},
|
||||||
// 加入购物车;
|
// 加入购物车
|
||||||
goCat: function (news) {
|
goCat(news) {
|
||||||
let that = this,
|
const that = this
|
||||||
productSelect = this.getAttrItemData(this.attrValue)
|
const productSelect = this.getAttrItemData(this.attrValue)
|
||||||
// 打开属性
|
// 打开属性
|
||||||
if (that.attrValue) {
|
if (that.attrValue) {
|
||||||
// 默认选中了属性,但是没有打开过属性弹窗还是自动打开让用户查看默认选中的属性
|
// 默认选中了属性,但是没有打开过属性弹窗还是自动打开让用户查看默认选中的属性
|
||||||
that.attr.cartAttr = !that.isOpen ? true : false;
|
that.attr.cartAttr = !that.isOpen ? true : false
|
||||||
} else {
|
} else {
|
||||||
if (that.isOpen) that.attr.cartAttr = true;
|
if (that.isOpen) that.attr.cartAttr = true
|
||||||
else that.attr.cartAttr = !that.attr.cartAttr;
|
else that.attr.cartAttr = !that.attr.cartAttr
|
||||||
}
|
}
|
||||||
|
|
||||||
// 只有关闭属性弹窗时进行加入购物车
|
// 只有关闭属性弹窗时进行加入购物车
|
||||||
if (that.attr.cartAttr === true && that.isOpen === false) {
|
if (that.attr.cartAttr === true && that.isOpen === false) {
|
||||||
return (that.isOpen = true);
|
return (that.isOpen = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果有属性,没有选择,提示用户选择
|
// 如果有属性,没有选择,提示用户选择
|
||||||
if (
|
if (
|
||||||
(that.attr.productAttr.length &&
|
(that.attr.productAttr.length &&
|
||||||
productSelect === undefined &&
|
productSelect === undefined && that.isOpen === true
|
||||||
that.isOpen === true) || productSelect.stock === 0
|
) || productSelect.stock === 0
|
||||||
) {
|
) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "产品库存不足,请选择其他商品",
|
title: "产品库存不足,请选择其他商品",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
duration: 5000
|
duration: 5000
|
||||||
});
|
})
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
const q = {
|
||||||
let q = {
|
|
||||||
productId: that.id,
|
productId: that.id,
|
||||||
cartNum: that.attr.productSelect.cart_num,
|
cartNum: that.attr.productSelect.cart_num,
|
||||||
new: news,
|
new: news,
|
||||||
uniqueId: that.attr.productSelect !== undefined ?
|
uniqueId: that.attr.productSelect !== undefined ?
|
||||||
that.attr.productSelect.unique : ""
|
that.attr.productSelect.unique : ""
|
||||||
};
|
}
|
||||||
|
|
||||||
// v4 新增活动ID
|
// v4 新增活动ID
|
||||||
switch (this.source) {
|
switch (this.source) {
|
||||||
case "pre":
|
case "pre":
|
||||||
q.preSaleId = Number(this.activityId)
|
q.preSaleId = Number(this.activityId)
|
||||||
break;
|
break
|
||||||
case "kill":
|
case "kill":
|
||||||
q.secKillId = Number(this.activityId)
|
q.secKillId = Number(this.activityId)
|
||||||
break;
|
break
|
||||||
case "day":
|
case "day":
|
||||||
q.dailyGoodsId = Number(this.activityId)
|
q.dailyGoodsId = Number(this.activityId)
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
|
postCartAdd(q).then(function (res) {
|
||||||
postCartAdd(q)
|
that.isOpen = false
|
||||||
.then(function (res) {
|
that.attr.cartAttr = false
|
||||||
that.isOpen = false;
|
|
||||||
that.attr.cartAttr = false;
|
|
||||||
if (news) {
|
if (news) {
|
||||||
that.$yrouter.push({
|
that.$yrouter.push({
|
||||||
path: "/pages/order/OrderSubmission/index",
|
path: "/pages/order/OrderSubmission/index",
|
||||||
query: {
|
query: {
|
||||||
id: res.data.cartId
|
id: res.data.cartId
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "添加购物车成功",
|
title: "添加购物车成功",
|
||||||
icon: "success",
|
icon: "success",
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
complete: () => {
|
complete: () => {
|
||||||
that.getCartCount(true);
|
that.getCartCount(true)
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
}
|
||||||
|
}).catch(error => {
|
||||||
that.isOpen = false;
|
that.isOpen = false;
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: error.msg,
|
title: error.msg,
|
||||||
icon: "none",
|
icon: "none",
|
||||||
duration: 5000
|
duration: 5000
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
// 获取购物车数量
|
// 获取购物车数量
|
||||||
getCartCount: function (isAnima) {
|
getCartCount: function (isAnima) {
|
||||||
let that = this;
|
const that = this
|
||||||
const isLogin = that.isLogin;
|
const isLogin = that.isLogin
|
||||||
if (isLogin) {
|
if (isLogin) {
|
||||||
getCartCount({
|
getCartCount({
|
||||||
numType: 0
|
numType: 0
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
that.CartCount = res.data.count;
|
that.CartCount = res.data.count
|
||||||
//加入购物车后重置属性
|
//加入购物车后重置属性
|
||||||
if (isAnima) {
|
if (isAnima) {
|
||||||
that.animated = true;
|
that.animated = true
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
that.animated = false;
|
that.animated = false
|
||||||
}, 500);
|
}, 500)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
listenerActionSheet: function () {
|
listenerActionSheet() {
|
||||||
if (isWeixin() === true) {
|
if (isWeixin() === true) {
|
||||||
this.weixinStatus = true;
|
this.weixinStatus = true
|
||||||
}
|
}
|
||||||
this.posters = true;
|
this.posters = true
|
||||||
},
|
},
|
||||||
listenerActionClose: function () {
|
listenerActionClose() {
|
||||||
this.posters = false;
|
this.posters = false
|
||||||
},
|
},
|
||||||
// v9-2
|
// v9-2
|
||||||
changeCoupons() {
|
changeCoupons() {
|
||||||
|
|||||||
Reference in New Issue
Block a user