123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688 |
- <template>
- <view class="collection-container">
- <JHeader title="我的收藏" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
- <view class="tabsbox">
- <tui-tabs
- style="width: 750upx;padding: 0 0upx 0 0upx;overflow: hidden;" :slider-width="60" :padding="0"
- item-width="375rpx" selected-color="#333333" bold slider-bg-color="#cccccc"
- :tabs="[{ name: '商品' }, { name: '店铺' }]" :current-tab="collectionTypeFlag"
- @change="collectionTypeActive"
- ></tui-tabs>
- </view>
- <view v-if="collectionTypeFlag == 0">
- <view v-if="productInfo.data.length > 0">
- <view class="wid function-box">
- <view v-if="allCheckShow" class="finishbox" @click="allCheckShow = false">完成</view>
- <view v-else class="flex-row-plus editicon-box flex-items fs28" @click="editClick">
- <tui-icon name="edit" :size="40" unit="upx" color="#333333"></tui-icon>
- <text class="mar-left-10">编辑</text>
- </view>
- </view>
- <view class="swipe-box">
- <view v-for="(item, index) in productInfo.data" :key="item.collectId" class="actionBox">
- <tui-swipe-action
- :key="item.collectId" :params="{ index }" :open="item.show" :forbid="allCheckShow"
- :actions="options" :closable="false" @click="productActionClick"
- >
- <template #content>
- <view class="flex-item">
- <view class="item wid flex-row-plus flex-display">
- <view v-show="allCheckShow" class="flex-items selctBtn">
- <tui-icon
- v-if="item.selected == 1" name="circle-fill" :size="40" unit="upx"
- color="#c5aa7b"
- margin="0 30upx 0 0" @click="productItemSel(index, 0)"
- ></tui-icon>
- <tui-icon
- v-else name="circle" :size="40" unit="upx"
- color="#cccccc" margin="0 30upx 0 0"
- @click="productItemSel(index, 1)"
- ></tui-icon>
- </view>
- <view
- class="infoCent flex-items"
- @click.stop="go(`/another-tf/another-serve/goodsDetails/index?shopId=${item.shopId}&productId=${item.productId}&skuId=${item.skuId}`)"
- >
- <image class="product-img default-img" mode="aspectFill" :src="common.seamingImgUrl(item.image)" />
- <view class="title-wrap mar-left-20 priceBox">
- <text
- class="title fs28 font-color-333"
- style="overflow: hidden;word-break: break-all;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 2;"
- >
- {{ item.productName }}
- </text>
- <view class="flex-items">
- <ATFActivityImage :type="item.activityType"></ATFActivityImage>
- <text class="fs40 font-color-C83732">¥</text>
- <text class="fs40 font-color-C83732 mar-right-20">{{ item.price }}</text>
- <text class="font-color-CCC discountsPriceLine fs24">
- ¥{{ item.originalPrice }}
- </text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- </tui-swipe-action>
- </view>
- </view>
- <view v-if="allCheckShow" class="pad-bot-140"></view>
- <view v-show="allCheckShow" class="allcheck-box flex-row-plus flex-sp-between flex-items">
- <view class="left">
- <tui-icon
- v-if="isAllProCheck" name="circle-fill" :size="40" unit="upx"
- color="#c5aa7b" margin="0 30upx 0 0"
- @click="allProductSel(0)"
- ></tui-icon>
- <tui-icon
- v-else name="circle" :size="40" unit="upx"
- color="#cccccc" margin="0 30upx 0 0"
- @click="allProductSel(1)"
- ></tui-icon>
- <text>全选</text>
- </view>
- <view class="right">
- <view class="btn-delete" @click="showCardModalProductDel">删除</view>
- </view>
- </view>
- <view v-if="allCheckShow" class="pad-bot-140"></view>
- </view>
- <view style="padding-bottom: 45upx;">
- <LoadingMore
- :status="!productInfo.isEmpty && !productInfo.data.length
- ? 'loading' : !productInfo.isEmpty && productInfo.data.length && (productInfo.data.length >= productInfo.listTotal) ? 'no-more' : ''"
- >
- </LoadingMore>
- <tui-no-data v-if="productInfo.isEmpty" :fixed="false" style="margin-top: 60upx;">暂无收藏</tui-no-data>
- </view>
- </view>
- <view v-if="collectionTypeFlag == 1">
- <view v-if="storeInfo.data.length > 0">
- <view v-if="allCheckShow" class="finishbox" @click="allCheckShow = false">完成</view>
- <view v-else class="flex-row-plus editicon-box flex-items fs28" @click="editClick">
- <tui-icon name="edit" :size="40" unit="upx" color="#333333"></tui-icon>
- <text class="mar-left-10">编辑</text>
- </view>
- <view class="swipe-box swipeBox">
- <view v-for="(item, index) in storeInfo.data" :key="item.collectId" class="shopBox" :index="index">
- <tui-swipe-action
- :key="item.collectId" :params="{ index }" :open="item.show" :forbid="allCheckShow"
- :actions="options" :closable="false" @click="storeActionClick"
- >
- <template #content>
- <view class="item wid flex-row-plus flex-display">
- <view v-show="allCheckShow" class="selctBtn flex-items">
- <tui-icon
- v-if="item.selected == 1" name="circle-fill" :size="40" unit="upx"
- color="#c5aa7b"
- margin="0 30upx 0 0" @click="storeItemSel(index, 0)"
- ></tui-icon>
- <tui-icon
- v-else name="circle" :size="40" unit="upx"
- color="#cccccc" margin="0 30upx 0 0"
- @click="storeItemSel(index, 1)"
- ></tui-icon>
- </view>
- <view class="infoCent">
- <view class="flex-row-plus flex-sp-between flex-items-plus wid">
- <view class="flex-items-plus flex-row pad-topbot-10">
- <image class="head-img" mode="aspectFill" :src="common.seamingImgUrl(item.shopLogo)" />
- <view class="title-wrap mar-left-20">
- <text
- class="title shopName"
- style="overflow: hidden;word-break: break-all;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 2;"
- >
- {{
- item.shopName }}
- </text>
- <text class="font-color-CCC fs24">{{ item.person }}人关注</text>
- </view>
- </view>
- <view
- class="toStore flex-items-plus fs24"
- @click="go(`/another-tf/another-user/shop/shop-detail?shopId=${item.shopId}`)"
- >
- 进入店铺 >
- </view>
- </view>
- <view v-if="item.productList.length > 0" class="shopImgBox">
- <view
- v-for="(sItem, sIndex) in item.productList" :key="sIndex" class="itemImgBox"
- @click.stop="go(`/another-tf/another-serve/goodsDetails/index?shopId=${sItem.shopId}&productId=${sItem.productId}&skuId=${sItem.skuId}`)"
- >
- <image :src="common.seamingImgUrl(sItem.image)" class="pic-img default-img"></image>
- </view>
- </view>
- </view>
- </view>
- </template>
- </tui-swipe-action>
- </view>
- </view>
- <view v-show="allCheckShow" class="allcheck-box flex-row-plus flex-sp-between flex-items">
- <view class="left">
- <tui-icon
- v-if="isAllStoreCheck" name="circle-fill" :size="40" unit="upx"
- color="#c5aa7b" margin="30upx"
- @click="allStoreSel(0)"
- ></tui-icon>
- <tui-icon
- v-else name="circle" :size="40" unit="upx"
- color="#cccccc" margin="30upx"
- @click="allStoreSel(1)"
- ></tui-icon>
- <text>全选</text>
- </view>
- <view class="right">
- <view class="btn-delete" @click="showCardModalshopDel">删除</view>
- </view>
- </view>
- <view v-if="allCheckShow" class="pad-bot-140"></view>
- </view>
- <view style="padding-bottom: 45upx;">
- <LoadingMore
- :status="!storeInfo.isEmpty && !storeInfo.data.length
- ? 'loading' : !storeInfo.isEmpty && storeInfo.data.length && (storeInfo.data.length >= storeInfo.listTotal) ? 'no-more' : ''"
- >
- </LoadingMore>
- <tui-no-data v-if="storeInfo.isEmpty" :fixed="false" style="margin-top: 60upx;">暂无收藏</tui-no-data>
- </view>
- </view>
- <!-- 删除确认弹窗 -->
- <tui-modal :show="delshow" :custom="true" :fadein="true">
- <view class="Put-box1">
- <view class="text-align fs34 fs-bold">
- 温馨提示
- </view>
- <view v-if="collectionTypeFlag === 0" class="mar-top-40 text-align">
- 是否删除该商品?
- </view>
- <view v-if="collectionTypeFlag === 1" class="mar-top-40 text-align">
- 是否删除该店铺?
- </view>
- <view class="flex-display flex-sp-between">
- <view v-if="collectionTypeFlag === 0" class="btn submit" @click="handleProductDel">确定</view>
- <view v-if="collectionTypeFlag === 1" class="btn submit" @click="handleShopDel">确定</view>
- </view>
- </view>
- <view v-if="delshow" class="cancelDel" @click="delshow = false">
- <tui-icon name="close" :size="60" unit="upx" color="#f0f0f0"></tui-icon>
- </view>
- </tui-modal>
- </view>
- </template>
- <script>
- import { deleteCollectToCollectApi, getAllProductCollectApi, getAllShopStoreCollectApi, updateCollectCancelApi } from '../../../api/anotherTFInterface'
- export default {
- name: 'Collection',
- data() {
- return {
- collectionTypeFlag: 0,
- options: [ {
- name: '删除',
- color: '#fff',
- fontsize: 32,
- width: 80,
- background: '#F15C48'
- } ],
- isAllProCheck: false,
- isAllStoreCheck: false,
- allCheckShow: false,
- delshow: false,
- deleteType: '',
- ids: null,
- productInfo: {
- query: {
- page: 1,
- pageSize: 10
- },
- data: [],
- listTotal: 0,
- isEmpty: false
- },
- storeInfo: {
- query: {
- page: 1,
- pageSize: 10
- },
- data: [],
- listTotal: 0, // 列表数据总数
- isEmpty: false // 列表是否为空
- }
- }
- },
- onShow() {
- if (this.collectionTypeFlag === 0) {
- this.productInfo.query.page = 1
- this.getProductCollectList()
- } else if (this.collectionTypeFlag === 1) {
- this.storeInfo.query.page = 1
- this.getStoreCollectList()
- }
- },
- methods: {
- collectionTypeActive(e) {
- this.collectionTypeFlag = e.index
- // 缓存每个tab里的数据
- if (this.collectionTypeFlag === 0) {
- } else if (this.collectionTypeFlag === 1) {
- if (!this.storeInfo.isEmpty && !this.storeInfo.data.length) this.getStoreCollectList()
- }
- // 每点一个tab就重新进行对它的请求
- // if (this.collectionTypeFlag === 0) {
- // this.productInfo.query.page = 1
- // this.productInfo.data = []
- // this.productInfo.listTotal = 0
- // this.productInfo.isEmpty = false
- // this.getProductCollectList()
- // } else if (this.collectionTypeFlag === 1) {
- // this.storeInfo.query.page = 1
- // this.storeInfo.data = []
- // this.storeInfo.listTotal = 0
- // this.storeInfo.isEmpty = false
- // this.getStoreCollectList()
- // }
- },
- // 收藏商品查询
- getProductCollectList(isLoadmore) {
- uni.showLoading()
- getAllProductCollectApi({ ...this.productInfo.query })
- .then((res) => {
- this.productInfo.listTotal = res.data.total
- if (isLoadmore) {
- this.productInfo.data.push(...res.data.list.map((i) => ({ ...i, show: false, selected: 0 })))
- } else {
- this.productInfo.data = res.data.list.map((i) => ({ ...i, show: false, selected: 0 }))
- }
- this.productInfo.isEmpty = this.productInfo.data.length === 0
- uni.hideLoading()
- })
- .catch(() => {
- uni.hideLoading()
- })
- },
- // 收藏店铺查询
- getStoreCollectList(isLoadmore) {
- uni.showLoading()
- getAllShopStoreCollectApi({ ...this.storeInfo.query })
- .then((res) => {
- this.storeInfo.listTotal = res.data.total
- if (isLoadmore) {
- this.storeInfo.data.push(...res.data.list.map((i) => ({ ...i, show: false, selected: 0 })))
- } else {
- this.storeInfo.data = res.data.list.map((i) => ({ ...i, show: false, selected: 0 }))
- }
- this.storeInfo.isEmpty = this.storeInfo.data.length === 0
- uni.hideLoading()
- })
- .catch(() => {
- uni.hideLoading()
- })
- },
- editClick() {
- this.allCheckShow = true
- this.productInfo.data = this.productInfo.data.map((item) => ({ ...item, show: false }))
- this.storeInfo.data = this.storeInfo.data.map((item) => ({ ...item, show: false }))
- },
- // 打开删除层
- productActionClick(e) {
- this.deleteType = 'one'
- this.delshow = true
- if (e.index == 0) {
- this.ids = this.productInfo.data[e.item.index].collectId
- }
- },
- storeActionClick(e) {
- this.deleteType = 'one'
- this.delshow = true
- if (e.index == 0) {
- this.ids = this.storeInfo.data[e.item.index].collectId
- }
- },
- handleProductDel() {
- if (this.deleteType === 'one') {
- uni.showLoading()
- updateCollectCancelApi({ ids: [ this.ids ] })
- .then((res) => {
- this.delshow = false
- this.ids = null
- uni.hideLoading()
- this.$showToast('删除成功')
- setTimeout(() => {
- this.productInfo.query.page = 1
- this.getProductCollectList()
- }, 2000)
- })
- .catch((e) => {
- uni.hideLoading()
- })
- } else {
- const tempArr = []
- this.productInfo.data.forEach((value, index) => {
- if (value.selected == 1) {
- tempArr.push(value.collectId)
- }
- })
- deleteCollectToCollectApi({ tempArr }).then((res) => {
- this.delshow = false
- uni.hideLoading()
- this.$showToast('删除成功')
- setTimeout(() => {
- this.productInfo.query.page = 1
- this.getProductCollectList()
- }, 2000)
- })
- .catch((res) => {
- this.delshow = false
- uni.hideLoading()
- })
- }
- },
- handleShopDel() {
- if (this.deleteType === 'one') {
- uni.showLoading()
- updateCollectCancelApi({ ids: [ this.ids ] })
- .then((res) => {
- this.delshow = false
- this.ids = null
- uni.hideLoading()
- this.$showToast('删除成功')
- setTimeout(() => {
- this.storeInfo.query.page = 1
- this.getStoreCollectList()
- }, 2000)
- })
- .catch((e) => {
- uni.hideLoading()
- })
- } else {
- uni.showLoading()
- const tempArr = []
- this.storeInfo.data.forEach((value, index) => {
- if (value.selected == 1) {
- tempArr.push(value.collectId)
- }
- })
- deleteCollectToCollectApi({ tempArr }).then((res) => {
- this.delshow = false
- uni.hideLoading()
- this.$showToast('删除成功')
- setTimeout(() => {
- this.storeInfo.query.page = 1
- this.getStoreCollectList()
- }, 2000)
- })
- .catch((res) => {
- this.delshow = false
- uni.hideLoading()
- })
- }
- },
- // 批量删除
- showCardModalProductDel() {
- let isShowProoductDelSubmit = false
- // 商品
- this.productInfo.data.forEach((value, index) => {
- if (value.selected == 1) {
- isShowProoductDelSubmit = true
- }
- })
- if (isShowProoductDelSubmit === true) {
- this.deleteType = 'quantity'
- this.delshow = true
- } else {
- this.$showToast('请先选择要删除的收藏宝贝!')
- }
- },
- showCardModalshopDel() {
- let isShowShopDelSubmit = false
- // 店铺
- this.storeInfo.data.forEach((value, index) => {
- if (value.selected == 1) {
- isShowShopDelSubmit = true
- }
- })
- if (isShowShopDelSubmit === true) {
- this.delshow = true
- } else {
- this.$showToast('请先选择要删除的收藏店铺!')
- }
- },
- // 商品选中
- productItemSel(index, state) {
- this.productInfo.data[index].selected = state
- let proSelectNum = 0
- this.productInfo.data.forEach((value, index) => {
- if (this.productInfo.data[index].selected == 0) {
- this.isAllProCheck = false
- } else {
- proSelectNum++
- }
- })
- if (this.productInfo.data.length == proSelectNum) {
- this.isAllProCheck = true
- }
- },
- // 店铺选中
- storeItemSel(index, state) {
- this.storeInfo.data[index].selected = state
- let storeSelectNum = 0
- this.storeInfo.data.forEach((value, index) => {
- if (this.storeInfo.data[index].selected == 0) {
- this.isAllStoreCheck = false
- } else {
- storeSelectNum++
- }
- })
- if (this.storeInfo.data.length == storeSelectNum) {
- this.isAllStoreCheck = true
- }
- },
- // 全选
- allProductSel(type) {
- this.isAllProCheck = !this.isAllProCheck
- this.productInfo.data.forEach((value, index) => {
- this.productInfo.data[index].selected = type
- })
- },
- allStoreSel(type) {
- this.isAllStoreCheck = !this.isAllStoreCheck
- this.storeInfo.data.forEach((value, index) => {
- this.storeInfo.data[index].selected = type
- })
- }
- },
- onReachBottom() {
- if (this.collectionTypeFlag === 0) {
- if (this.productInfo.data.length < this.productInfo.listTotal) {
- ++this.productInfo.query.page
- this.getProductCollectList(true)
- }
- } else if (this.collectionTypeFlag === 1) {
- if (this.storeInfo.data.length < this.storeInfo.listTotal) {
- ++this.storeInfo.query.page
- this.getStoreCollectList(true)
- }
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .collection-container {
- min-height: 100vh;
- background-color: #F7F7F7;
- box-sizing: border-box;
- .function-box {
- background-color: #F7F7F7;
- }
- .tabsbox {
- margin-top: 4rpx;
- background-color: #FFFFFF;
- }
- .editicon-box {
- display: flex;
- justify-content: flex-end;
- position: relative;
- left: -30rpx;
- padding: 16rpx 0;
- }
- .finishbox {
- display: flex;
- justify-content: flex-end;
- position: relative;
- left: -30rpx;
- padding: 16rpx 0;
- }
- .swipe-box {
- padding: 0 20rpx;
- .actionBox {
- margin-bottom: 20rpx;
- }
- .item {
- display: flex;
- .infoCent {
- padding: 20rpx;
- }
- .selctBtn {
- background: #F7F7F7;
- }
- }
- .shopImgBox {
- display: flex;
- justify-content: end;
- margin-left: 90rpx;
- padding-bottom: 20rpx;
- margin-top: 20rpx;
- .itemImgBox {
- margin-right: 15rpx;
- margin-left: 5rpx;
- image {
- width: 120rpx;
- height: 120rpx;
- border: 2rpx solid #F3F4F5;
- }
- }
- }
- .product-img {
- width: 220rpx;
- flex: 0 0 220rpx;
- height: 220rpx;
- }
- .head-img {
- width: 80rpx;
- flex: 0 0 80rpx;
- height: 80rpx;
- border-radius: 50%;
- }
- .title {
- text-align: left;
- font-size: 28rpx;
- color: #606266;
- height: 165rpx;
- padding-right: 20rpx;
- }
- .shopName {
- height: auto;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- width: 340rpx;
- }
- .toStore {
- width: 100px;
- color: #FFEBC4;
- padding: 0rpx 20rpx;
- height: 52rpx;
- background: #333333;
- margin-right: 15rpx;
- }
- .shopBox {
- margin-bottom: 20rpx;
- }
- }
- .allcheck-box {
- background-color: #FFFFFF;
- width: 100%;
- position: fixed;
- bottom: 0upx;
- .left {
- display: flex;
- flex-direction: row;
- align-items: center;
- font-size: 28upx;
- color: #666;
- }
- .right {
- display: flex;
- flex-direction: row;
- align-items: center;
- box-sizing: border-box;
- }
- .btn-delete {
- width: 232upx;
- height: 104upx;
- line-height: 104upx;
- text-align: center;
- font-size: 28upx;
- color: #FFFFFF;
- background: #C83732;
- }
- }
- .Put-box1 {
- .btn {
- text-align: center;
- margin-top: 40rpx;
- border: 1px solid #333333;
- height: 80upx;
- line-height: 80upx;
- width: 100%;
- color: #333333;
- }
- .submit {
- background-color: #333333;
- color: #FFEBC4;
- }
- }
- .cancelDel {
- position: absolute;
- bottom: -50px;
- left: 45%;
- }
- }
- </style>
|