|
@@ -2,10 +2,12 @@
|
|
<mobile-frame>
|
|
<mobile-frame>
|
|
<view class="main">
|
|
<view class="main">
|
|
<view class="onemain">
|
|
<view class="onemain">
|
|
- <scroll-view scroll-y="true" class="scroll-view" scroll-with-animation :scroll-into-view="topItem" @scroll="handleScroll">
|
|
|
|
|
|
+ <scroll-view scroll-y="true" class="scroll-view" scroll-with-animation :scroll-into-view="topItem"
|
|
|
|
+ @scroll="handleScroll">
|
|
<view class="list-scroll-view" id="top">
|
|
<view class="list-scroll-view" id="top">
|
|
<view class="one">
|
|
<view class="one">
|
|
- <swiper class="swiper" circular :indicator-dots="true" indicator-color="#ffffff" indicator-active-color="#FB1438" :autoplay="true" :interval="3000" :duration="1000">
|
|
|
|
|
|
+ <swiper class="swiper" circular :indicator-dots="true" indicator-color="#ffffff"
|
|
|
|
+ indicator-active-color="#FB1438" :autoplay="true" :interval="3000" :duration="1000">
|
|
<swiper-item class="list" v-for="(item,index) in bannerList" :key="index">
|
|
<swiper-item class="list" v-for="(item,index) in bannerList" :key="index">
|
|
<image class="image" :src="item.url" mode="">
|
|
<image class="image" :src="item.url" mode="">
|
|
</image>
|
|
</image>
|
|
@@ -68,7 +70,8 @@
|
|
</scroll-view>
|
|
</scroll-view>
|
|
</view>
|
|
</view>
|
|
<view class="foot">
|
|
<view class="foot">
|
|
- <uni-goods-nav :options="options" :button-group="buttonGroup" @click="onClick" @buttonClick="buttonClick" />
|
|
|
|
|
|
+ <uni-goods-nav :options="options" :button-group="buttonGroup" @click="onClick"
|
|
|
|
+ @buttonClick="buttonClick" />
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="collect">
|
|
<view class="collect">
|
|
@@ -107,7 +110,8 @@
|
|
<view class="two">
|
|
<view class="two">
|
|
<view class="two_1">规格</view>
|
|
<view class="two_1">规格</view>
|
|
<view class="two_2">
|
|
<view class="two_2">
|
|
- <text v-for="(item,index) in specs" :key="index" @click="toStyle(item,index)" :class="{ 'style': isActive==index}">{{item.name}}</text>
|
|
|
|
|
|
+ <text v-for="(item,index) in specs" :key="index" @click="toStyle(item,index)"
|
|
|
|
+ :class="{ 'style': isActive==index}">{{item.name}}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="thr">
|
|
<view class="thr">
|
|
@@ -184,6 +188,7 @@
|
|
],
|
|
],
|
|
// 商品id
|
|
// 商品id
|
|
id: '',
|
|
id: '',
|
|
|
|
+ user: {},
|
|
// 轮播图
|
|
// 轮播图
|
|
bannerList: [],
|
|
bannerList: [],
|
|
// 商品详情
|
|
// 商品详情
|
|
@@ -246,17 +251,24 @@
|
|
})
|
|
})
|
|
},
|
|
},
|
|
// 收藏
|
|
// 收藏
|
|
- toCollect() {
|
|
|
|
|
|
+ async toCollect() {
|
|
const that = this;
|
|
const that = this;
|
|
- that.collection = !that.collection;
|
|
|
|
- if (that.collection == true) {
|
|
|
|
- uni.showToast({
|
|
|
|
- title: `收藏成功`,
|
|
|
|
- icon: 'none'
|
|
|
|
- })
|
|
|
|
|
|
+ let user = that.user;
|
|
|
|
+ if (user) {
|
|
|
|
+ let res = await that.$api(`/storeGoods`, `POST`, {
|
|
|
|
+ customer: user._id,
|
|
|
|
+ goods: that.id
|
|
|
|
+ });
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.data.msg,
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ that.$set(that, `collection`, res.data.result)
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
- title: `取消成功`,
|
|
|
|
|
|
+ title: '无用户登录无法收藏商品',
|
|
icon: 'none'
|
|
icon: 'none'
|
|
})
|
|
})
|
|
}
|
|
}
|
|
@@ -317,6 +329,7 @@
|
|
key: 'token',
|
|
key: 'token',
|
|
success: async function(res) {
|
|
success: async function(res) {
|
|
let user = that.$jwt(res.data);
|
|
let user = that.$jwt(res.data);
|
|
|
|
+ that.$set(that, `user`, user)
|
|
if (that.Selected) {
|
|
if (that.Selected) {
|
|
let specs_id;
|
|
let specs_id;
|
|
let specs = that.specs.find(i => i.name == that.Selected)
|
|
let specs = that.specs.find(i => i.name == that.Selected)
|
|
@@ -387,6 +400,20 @@
|
|
// 详情数据
|
|
// 详情数据
|
|
async search() {
|
|
async search() {
|
|
const that = this;
|
|
const that = this;
|
|
|
|
+ uni.getStorage({
|
|
|
|
+ key: 'token',
|
|
|
|
+ success: function(res) {
|
|
|
|
+ let user = that.$jwt(res.data);
|
|
|
|
+ if (user) that.$set(that, `user`, user);
|
|
|
|
+ that.searchOther()
|
|
|
|
+ },
|
|
|
|
+ fail: function(err) {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '无用户登录无法查看收藏信息',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ });
|
|
let res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
|
|
let res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
|
|
id: that.id
|
|
id: that.id
|
|
});
|
|
});
|
|
@@ -398,6 +425,17 @@
|
|
that.$set(that, `bannerList`, res.data.goods.file)
|
|
that.$set(that, `bannerList`, res.data.goods.file)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ async searchOther() {
|
|
|
|
+ const that = this;
|
|
|
|
+ let user = that.user;
|
|
|
|
+ let res = await that.$api(`/storeGoods/check`, `GET`, {
|
|
|
|
+ customer: user._id,
|
|
|
|
+ goods: that.id
|
|
|
|
+ });
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ that.$set(that, `collection`, res.data)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|