|
@@ -48,6 +48,18 @@
|
|
|
|
|
|
<!-- 优惠券活动弹窗 -->
|
|
<!-- 优惠券活动弹窗 -->
|
|
<cm-active-alert></cm-active-alert>
|
|
<cm-active-alert></cm-active-alert>
|
|
|
|
+
|
|
|
|
+ <!-- 返回顶部 -->
|
|
|
|
+ <tui-scroll-top
|
|
|
|
+ :scrollTop="scrollTop"
|
|
|
|
+ :isShare="true"
|
|
|
|
+ :bottom="60"
|
|
|
|
+ :customShare="true"
|
|
|
|
+ @share="onShare"
|
|
|
|
+ ></tui-scroll-top>
|
|
|
|
+
|
|
|
|
+ <!-- 分享弹窗 -->
|
|
|
|
+ <cm-share-popup ref="sharePopup" :data="posterData" type="normal" :safeArea="false"></cm-share-popup>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -57,6 +69,7 @@ import { fetchCouponDisplay } from '@/services/api/coupon.js'
|
|
import { fetchProductFloorList } from '@/services/api/goods.js'
|
|
import { fetchProductFloorList } from '@/services/api/goods.js'
|
|
import { shareDataResult } from '@/common/share.helper.js'
|
|
import { shareDataResult } from '@/common/share.helper.js'
|
|
import { mapActions, mapGetters } from 'vuex'
|
|
import { mapActions, mapGetters } from 'vuex'
|
|
|
|
+import { queryStringify } from '@/common/utils.js'
|
|
|
|
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
@@ -67,27 +80,39 @@ export default {
|
|
floorInfo: {},
|
|
floorInfo: {},
|
|
floorList: [],
|
|
floorList: [],
|
|
couponList: [],
|
|
couponList: [],
|
|
|
|
+ hasCouponWillReceive: false,
|
|
current: 0,
|
|
current: 0,
|
|
isRefresh: false,
|
|
isRefresh: false,
|
|
- couponTipStr: ''
|
|
|
|
|
|
+ couponTipStr: '',
|
|
|
|
+ scrollTop: 0,
|
|
|
|
+ posterData: {}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
- ...mapGetters(['userId', 'accessToken']),
|
|
|
|
|
|
+ ...mapGetters(['userId']),
|
|
bannerList() {
|
|
bannerList() {
|
|
return this.bannerData.map(item => item.image)
|
|
return this.bannerData.map(item => item.image)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ onPageScroll(e) {
|
|
|
|
+ this.scrollTop = e.scrollTop
|
|
|
|
+ },
|
|
onPullDownRefresh() {
|
|
onPullDownRefresh() {
|
|
this.initHomeInfo()
|
|
this.initHomeInfo()
|
|
},
|
|
},
|
|
onShareAppMessage() {
|
|
onShareAppMessage() {
|
|
- const shareData = { type: 0, inviteUserId: this.userId }
|
|
|
|
- return shareDataResult(shareData)
|
|
|
|
|
|
+ // 加密
|
|
|
|
+ const state_str = encodeURIComponent(this.$crypto.encrypt({ type: 0 }))
|
|
|
|
+ return {
|
|
|
|
+ title: '护肤上颜选,正品有好货~',
|
|
|
|
+ path: `/pages/index/index?state_str=${state_str}`,
|
|
|
|
+ imageUrl: this.staticUrl + 'icon-share.png'
|
|
|
|
+ }
|
|
},
|
|
},
|
|
onShow() {
|
|
onShow() {
|
|
|
|
+ this.checkCouponAlert()
|
|
this.fetchCartKindCount() // 购物车商品数量
|
|
this.fetchCartKindCount() // 购物车商品数量
|
|
- this.checkCouponAlert() // 优惠券弹窗
|
|
|
|
|
|
+ this.fetchCouponList()
|
|
},
|
|
},
|
|
onLoad() {
|
|
onLoad() {
|
|
this.initHomeInfo()
|
|
this.initHomeInfo()
|
|
@@ -96,6 +121,14 @@ export default {
|
|
...mapActions('cart', ['fetchCartKindCount']),
|
|
...mapActions('cart', ['fetchCartKindCount']),
|
|
...mapActions('coupon', ['checkCouponAlert']),
|
|
...mapActions('coupon', ['checkCouponAlert']),
|
|
|
|
|
|
|
|
+ // 初始化首页信息
|
|
|
|
+ initHomeInfo() {
|
|
|
|
+ this.fetchCarousel()
|
|
|
|
+ this.fetchNavbar()
|
|
|
|
+ this.fetchFloorData()
|
|
|
|
+ this.fetchCouponList()
|
|
|
|
+ },
|
|
|
|
+
|
|
// 搜索
|
|
// 搜索
|
|
handleToSearch() {
|
|
handleToSearch() {
|
|
this.$router.navigateTo('goods/goods-search')
|
|
this.$router.navigateTo('goods/goods-search')
|
|
@@ -103,7 +136,7 @@ export default {
|
|
|
|
|
|
// 金刚区菜单导航
|
|
// 金刚区菜单导航
|
|
onNavbarClick(navbar) {
|
|
onNavbarClick(navbar) {
|
|
- this.$setStorage('NAVBAR', { type: 'navbar', id: navbar.id })
|
|
|
|
|
|
+ this.$setStorage('NAVBAR', { type: 'navbar', id: navbar.id, title: navbar.name })
|
|
this.$router.navigateTo('goods/goods-list')
|
|
this.$router.navigateTo('goods/goods-list')
|
|
},
|
|
},
|
|
|
|
|
|
@@ -131,7 +164,7 @@ export default {
|
|
|
|
|
|
// 更多商品
|
|
// 更多商品
|
|
onMoreProduct(floor) {
|
|
onMoreProduct(floor) {
|
|
- this.$setStorage('NAVBAR', { type: 'floor', id: floor.id })
|
|
|
|
|
|
+ this.$setStorage('NAVBAR', { type: 'floor', id: floor.id, title: floor.title })
|
|
this.$router.navigateTo('goods/goods-list')
|
|
this.$router.navigateTo('goods/goods-list')
|
|
},
|
|
},
|
|
|
|
|
|
@@ -140,14 +173,6 @@ export default {
|
|
this.$router.navigateTo('others/join-us')
|
|
this.$router.navigateTo('others/join-us')
|
|
},
|
|
},
|
|
|
|
|
|
- // 初始化首页信息
|
|
|
|
- initHomeInfo() {
|
|
|
|
- this.fetchCarousel()
|
|
|
|
- this.fetchNavbar()
|
|
|
|
- this.fetchFloorData()
|
|
|
|
- this.fetchCouponList()
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
// 轮播图跳转
|
|
// 轮播图跳转
|
|
onSwiperClick(index) {
|
|
onSwiperClick(index) {
|
|
const link = this.bannerData[index].link
|
|
const link = this.bannerData[index].link
|
|
@@ -193,8 +218,9 @@ export default {
|
|
// 获取优惠券列表
|
|
// 获取优惠券列表
|
|
async fetchCouponList() {
|
|
async fetchCouponList() {
|
|
try {
|
|
try {
|
|
- this.fetchCouponDisplay() // 获取可领取优惠券类型
|
|
|
|
|
|
+ await this.fetchCouponDisplay() // 获取可领取优惠券类型
|
|
const resultCouponData = await fetchHomeCouponList({ userId: this.userId })
|
|
const resultCouponData = await fetchHomeCouponList({ userId: this.userId })
|
|
|
|
+ this.hasCouponWillReceive = resultCouponData.data && resultCouponData.data.length > 0
|
|
this.couponList = [
|
|
this.couponList = [
|
|
...resultCouponData.data.map(item => {
|
|
...resultCouponData.data.map(item => {
|
|
item.controlType = 'receive'
|
|
item.controlType = 'receive'
|
|
@@ -212,8 +238,10 @@ export default {
|
|
try {
|
|
try {
|
|
const res = await fetchCouponDisplay({ userId: this.userId })
|
|
const res = await fetchCouponDisplay({ userId: this.userId })
|
|
this.couponTipStr = res.data
|
|
this.couponTipStr = res.data
|
|
|
|
+ return res
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.log('获取优惠券类型失败')
|
|
console.log('获取优惠券类型失败')
|
|
|
|
+ return e
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -236,7 +264,13 @@ export default {
|
|
name: '分享券福利'
|
|
name: '分享券福利'
|
|
}
|
|
}
|
|
]
|
|
]
|
|
- return result.filter(item => this.couponTipStr.indexOf(item.id.toString()) > -1)
|
|
|
|
|
|
+ return result.filter(item => this.userId > 0 && this.couponTipStr.indexOf(item.id.toString()) > -1)
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 分享
|
|
|
|
+ onShare() {
|
|
|
|
+ this.posterData = { query: queryStringify({ type: 0 }) }
|
|
|
|
+ this.$refs.sharePopup.open()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|