123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 |
- <template>
- <view class="box">
- <u-navbar :autoBack="true" title="我的" bgColor="rgba(255,255,255,0)" :placeholder="true" titleStyle="font-weight:bold;color:#121212"></u-navbar>
- <view class="box_tab">
- <u-tabs
- @click="TabBtn"
- :duration="200"
- :list="listTab"
- :lineWidth="25"
- :lineHeight="12"
- :current="id1"
- lineColor="#4E7198"
- :lineColor="`url(${tabImg}) 100% 100%`"
- :activeStyle="{
- color: '#4E7198',
- fontSize: '34rpx'
- }"
- ></u-tabs>
- </view>
- <!-- 投稿 -->
- <view class="pubu">
- <!-- 瀑布流 -->
- <u-checkbox-group v-model="deleteList" placement="column" @change="checkboxChange">
- <uv-waterfall ref="waterfall" v-model="list" :add-time="10" left-gap="10" right-gap="10" :column-gap="columnGap" @changeList="changeList">
- <!-- 第一列数据 -->
- <template v-slot:list1>
- <!-- 为了磨平部分平台的BUG,必须套一层view -->
- <view>
- <view @click="ceshi(index)" v-for="(item, index) in list1" :key="item.id" class="waterfall-item">
- <view class="waterfall-item__image" :style="[imageStyle(item)]">
- <image :src="item.image" mode="widthFix" style="border-radius: 25rpx 60rpx 0rpx 30rpx" :style="{ width: item.width + 'px' }"></image>
- </view>
- <view class="waterfall-item__ft">
- <view class="waterfall-item__ft__title">
- <text class="value">{{ item.title }}</text>
- <view v-if="checkboxShow" class="" style="position: relative">
- <view class="box_checkbox">
- <u-checkbox :value="item.id" :name="item.id" :customStyle="{ marginBottom: '8px' }" shape="circle"></u-checkbox>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- </u-checkbox-group> -->
- </view>
- </template>
- <!-- 第二列数据 -->
- <template v-slot:list2>
- <!-- 为了磨平部分平台的BUG,必须套一层view -->
- <view>
- <!-- <u-checkbox-group v-model="deleteList" placement="column" @change="checkboxChange2"> -->
- <view @click="ceshi(index)" v-for="(item, index) in list2" :key="item.id" class="waterfall-item">
- <view class="waterfall-item__image" :style="[imageStyle(item)]">
- <image :src="item.image" mode="widthFix" style="border-radius: 25rpx 60rpx 0rpx 30rpx" :style="{ width: item.width + 'px' }"></image>
- </view>
- <view class="waterfall-item__ft">
- <view class="waterfall-item__ft__title">
- <text class="value">{{ item.title }}</text>
- <view v-if="checkboxShow" class="" style="position: relative">
- <view class="box_checkbox">
- <u-checkbox :value="item.id" :name="item.id" :customStyle="{ marginBottom: '8px' }" shape="circle"></u-checkbox>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- </uv-waterfall>
- </u-checkbox-group>
- <!-- 底部删除管理 -->
- <view class="guanLi">
- <view style="display: flex; align-items: center" v-if="checkboxShow">
- <view style="margin-right: 260rpx">
- <u-checkbox-group @change="deleteAll" v-model="checkboxValue2" placement="column">
- <u-checkbox :customStyle="{ marginBottom: '8px' }" shape="circle" label="全部"></u-checkbox>
- </u-checkbox-group>
- </view>
- <view class="sc" @click="deleteShow = true">
- <uni-icons type="trash" color=" #ffffff" size="20"></uni-icons>
- <view class="">删除</view>
- </view>
- </view>
- <view class="guanLi2" @click="checkboxShow = !checkboxShow">
- <view class="left_jl">
- <uni-icons type="gear" size="20"></uni-icons>
- </view>
- <view class="">
- <view v-if="checkboxShow" class="left_jl">退出管理</view>
- <view v-else class="left_jl">管理</view>
- </view>
- </view>
- </view>
- </view>
- <!-- 删除弹层 -->
- <u-popup :show="deleteShow" @close="close" mode="center" customStyle="width:600rpx;padding: 30rpx;" round="20rpx">
- <view style="text-align: center">确认是否删除所选内容?</view>
- <view class="bt_box">
- <view class="bt1" @click="deleteShow = false">取消</view>
- <view @click="deleteBtn" class="bt2">删除</view>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- import { guid } from '@/uni_modules/uv-ui-tools/libs/function/index.js';
- let that;
- export default {
- data() {
- return {
- id1: 0,
- main_body_id: '',
- deleteShow: false /* 弹层 */,
- checkboxShow: false /*多选框 */,
- tabImg: 'https://huli-app.wenlvti.net/app_static/minnanhun/image/tab.png',
- listTab: [
- {
- name: '我的投稿',
- tabid: 1
- },
- {
- name: '我的收藏',
- tabid: 2
- },
- {
- name: '我的喜欢',
- tabid: 3
- }
- ],
- list: [],
- list1: [], // 瀑布流第一列数据
- list2: [], // 瀑布流第二列数据
- columnGap: 10,
- checkboxValue2: [],
- deleteList: [] /*, 要删除的 */,
- n: [],
- ad: []
- };
- },
- onLoad(o) {
- that = this;
- this.id1 = o.id;
- this.main_body_id = this.$db.get('main_body_id');
- this.getUserLike(this.id1);
- },
- computed: {
- imageStyle(item) {
- return (item) => {
- const v = uni.upx2px(750) - this.leftGap - this.rightGap - this.columnGap;
- const w = v / 2;
- const rate = w / item.w;
- const h = rate * item.h;
- return {
- width: w + 'px',
- height: h + 'px'
- };
- };
- }
- },
- methods: {
- deleteAll(a) {
- if (a.length > 0) {
- let aa = [];
- this.list.forEach((item, index) => {
- aa.push(item.id);
- });
- this.deleteList = aa;
- } else {
- this.deleteList = [];
- }
- },
- // 导航
- TabBtn(index) {
- that.list = [];
- that.$refs.waterfall.clear();
- that.list1 = [];
- that.list2 = [];
- this.id1 = index.index;
- this.getUserLike(index.index);
- },
- getUserLike(i) {
- if (i == 2) {
- // 我得喜欢
- this.$api.getUserLike(
- {
- main_body_id: this.main_body_id
- },
- function (res) {
- // // 假设res.data是一个包含对象的数组
- res.data.forEach((item) => {
- item.checked = false;
- });
- that.list = res.data;
- // console.log(that.list, '555555555555');
- }
- );
- }
- if (i == 1) {
- this.$api.getUserCollect(
- {
- main_body_id: this.main_body_id
- },
- function (res) {
- console.log('收藏', res);
- that.list = res.data;
- }
- );
- } else {
- that.list = [];
- }
- },
- changeList(e) {
- // console.log(e, '瀑布流');
- this[e.name].push(e.value);
- },
- ceshi(i) {
- console.log(i, 111111111111);
- },
- // 选框
- checkboxChange(n) {
- console.log('change', n);
- this.deleteList = [...this.deleteList, ...n];
- },
- checkboxChange2(n) {
- console.log('change', n);
- this.deleteList = [...this.deleteList, ...n];
- },
- // 删除
- deleteBtn() {
- //取消点赞
- if (this.id1 == 2) {
- this.$api.unLike(
- {
- main_body_id: this.main_body_id,
- content_ids: this.deleteList
- },
- function (res) {
- if (res.code == 1) {
- that.$common.successToShow('删除成功');
- that.deleteShow = false;
- that.list = [];
- that.$refs.waterfall.clear();
- that.list1 = [];
- that.list2 = [];
- that.getUserLike(2);
- } else {
- that.$common.errorToShow('请选择要删除的内容');
- }
- }
- );
- }
- // 取消收藏
- if (this.id1 == 1) {
- this.$api.uncollect(
- {
- main_body_id: this.main_body_id,
- content_ids: this.deleteList
- },
- function (res) {
- if (res.code == 1) {
- that.$common.successToShow('删除成功');
- that.deleteShow = false;
- that.list = [];
- that.$refs.waterfall.clear();
- that.list1 = [];
- that.list2 = [];
- that.getUserLike(1);
- } else {
- that.$common.errorToShow('删除失败请稍后在试');
- }
- }
- );
- }
- },
- close() {
- this.deleteShow = false;
- }
- }
- };
- </script>
- <style>
- /deep/.u-tabs__wrapper__nav__item.data-v-48634e29 {
- padding: 0 40rpx !important;
- }
- /deep/.u-tabs__wrapper__nav__line.data-v-48634e29 {
- bottom: 16rpx !important;
- }
- /deep/.u-tabs__wrapper__nav__item.data-v-48634e29 {
- align-items: end !important;
- }
- .box_checkbox {
- position: absolute;
- top: -50rpx;
- left: 20rpx;
- z-index: 99;
- }
- .box {
- height: auto;
- width: 100%;
- padding-bottom: 80rpx;
- background-color: #f8f8f8;
- }
- .box_tab {
- margin: 45rpx 32rpx 0 32rpx;
- }
- .waterfall-item {
- margin-bottom: 20rpx;
- }
- .waterfall-item__ft {
- position: relative;
- }
- .waterfall-item__ft__title {
- width: 100%;
- height: 65rpx;
- position: absolute;
- bottom: 0;
- left: 0;
- line-height: 65rpx;
- background-color: #ca5642;
- font-size: 30rpx;
- text-align: center;
- color: #ffffff;
- border-radius: 0 0 10rpx 10rpx;
- }
- .pubu {
- margin: 10rpx 32rpx 0 32rpx;
- }
- .title_pubu {
- width: 100%;
- height: 65rpx;
- line-height: 65rpx;
- background-color: #ca5642;
- font-size: 30rpx;
- text-align: center;
- color: #ffffff;
- position: absolute;
- bottom: 0;
- left: 0;
- }
- .box_checkbox {
- position: absolute;
- top: -50rpx;
- left: 20rpx;
- z-index: 99;
- }
- .guanLi {
- display: flex;
- justify-content: flex-end;
- position: fixed;
- bottom: 0;
- left: 0;
- z-index: 99;
- width: 96%;
- background: #ffffff;
- }
- .guanLi2 {
- display: flex;
- align-items: center;
- height: 80rpx;
- /* width: 160rpx; */
- background-color: #efefef;
- }
- .sc {
- display: flex;
- align-items: center;
- height: 80rpx;
- width: 160rpx;
- padding-left: 28rpx;
- color: #ffffff;
- background-color: #ca5642;
- }
- .bt_box {
- display: flex;
- margin-top: 50rpx;
- justify-content: space-around;
- }
- .bt1 {
- width: 244rpx;
- height: 78rpx;
- border: 1px solid #312520;
- border-radius: 39rpx;
- text-align: center;
- line-height: 78rpx;
- color: black;
- }
- .bt2 {
- width: 244rpx;
- height: 78rpx;
- background: #ca5642;
- border-radius: 39rpx;
- text-align: center;
- line-height: 78rpx;
- color: #ffffff;
- }
- </style>
|