123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428 |
- <template>
- <view class="">
- <view class="listBlock1" v-for="(i,index) in classList" :key="index" @click="gotoDetail" :data-aid="i.acId">
- <view class="img cell-img">
- <image :src="i.pic" mode="aspectFill"></image>
- <view class="starView" @click.stop="coll" :data-e="i">
- <image class="star" :src="collArr.includes(i.acId) ? pic_coll2 : pic_coll " mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="right">
- <view class="title">
- <view class="bqZ-font" style="font-size: 20rpx;" :class="i.acshape=='线下活动'?'tag':'tag1'">
- {{i.acshape}}
- </view>
- <view class="titTxt btn-font" style="font-size:34rpx ;">
- {{i.acName}}
- </view>
- </view>
- <view class="introduce">
- <view class="bri">
- <!-- {{ i.brief }} -->
- <!-- {{ i.address }} -->
- 深圳职业技术大学
- </view>
- <view class="tim">
- {{ i.create_at }}
- </view>
- </view>
- <view class="operate">
- <view class="left">
- <view class="add fz-font">已报名{{i.bnum}}人</view>
- </view>
- <!-- <view class="Oright" v-if="!indexId" @click.stop="gotoDetail" :data-aid="i.acId"> -->
- <view class="Oright" v-if="!indexId">
- <view class="text">{{ i.signNum?'已报名':'报名' }}</view>
- <view class="arrow">
- <image src="https://teacherapi.cocorobo.cn/teaching-file/static/mine/arrow-right-blue.png"
- mode="aspectFill"></image>
- </view>
- </view>
- <view class="Oright" v-if="indexId">
- <view class="mon">¥<text style="font-size: 40rpx;">{{i.cost}}</text> </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: "listBlock1",
- // computed: {
- // ...mapState(['msgpop']) // 将 Vuex 中的 items 映射为组件的计算属性
- // },
- props: {
- classList: {
- type: Array,
- default () {
- return [];
- },
- },
- indexId: {
- type: Number,
- default () {
- return 0;
- },
- },
- },
- data() {
- return {
- // 收藏list
- collArr: [],
- // 节流阀
- stopTimer: 0,
- timer: null,
- // 收藏悬浮窗
- collpopulShow: false,
- // 决定悬浮窗显示哪些内容0 取消 1收藏
- collAoff: 0,
- // subArr: [],
- pic_coll: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/Vstar21707269669382.png',
- pic_coll2: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/VStar1707269577778.png',
- };
- },
- onShow() {},
- methods: {
- // 收藏事件
- coll(event) {
- const value = this.$store.state.user.openid;
- if (!value) {
- uni.showToast({
- title: '未登录,请登录',
- icon: 'none'
- })
- setTimeout(this.goLog, 1000)
- return
- }
- if (this.stopTimer) return uni.showToast({
- icon: 'none',
- title: '点击过快'
- })
- this.stopTimer = 1
- setTimeout(() => {
- this.stopTimer = 0
- }, 500)
- let aId = event.currentTarget.dataset.e.acId
-
- // let type= event.currentTarget.dataset.e.type
- //判断是否收藏
- let iscoll = null
- // 查询是否收藏过
- let data = {
- acid: aId,
- oid: this.$store.state.user.openid, //用户id
- ty: 0
- }
- this.$request('/selectOneOperator', 'POST', data).then(res => {
- // console.log('查询是否收藏过',res);
- res[0].length ? iscoll = true : iscoll = false;
- // iscoll为true表示已经收藏过,执行删除 为true则收藏
- if (iscoll) {
- // this.animationDataArr.push({
- // collAoff: 0
- // })
- this.$store.dispatch('asyncUpdatemsg', {
- collAoff: 0
- })
- // this.praiseMe()
- // console.log('执行删除');
- this.$request('/deleteOperator', 'POST', data).then(res => {
- this.getdata()
- setTimeout(() => {
- this.$store.dispatch('asyncDelMsg')
- }, 1500)
- })
- } else {
- // this.animationDataArr.push({
- // collAoff: 1
- // })
- // console.log('msgpop',this.$store.state.msgpop);
- this.$store.dispatch('asyncUpdatemsg', {
- collAoff: 1
- })
- // let aaa={collAoff: 1}
- // console.log('执行添加');
- this.$request('/insertOperator', 'POST', data).then(res => {
- this.getdata()
- // console.log(this.h);
- setTimeout(() => {
- this.$store.dispatch('asyncDelMsg')
- }, 1500)
- })
- }
- })
- },
- // 跳转到详情页
- gotoDetail(e) {
- const value = this.$store.state.user.openid;
- if (!value) {
- uni.showToast({
- title: '未登录,请登录',
- icon: 'none'
- })
- setTimeout(this.goLog, 1000)
- return
- }
- let aid = e.currentTarget.dataset.aid;
- uni.navigateTo({
- url: `/pages/activityDetailNew/activityDetailNew?acId=${aid}`
- });
- },
- //跳转到第三方链接
- gotoLink(e) {
- const value = this.$store.state.user.openid;
- if (!value) {
- uni.showToast({
- title: '未登录,请登录',
- icon: 'none'
- })
- setTimeout(this.goLog, 1000)
- return
- }
- let link = e.currentTarget.dataset.link;
- uni.navigateTo({
- url: "/pages/skipone/skipone?url=" + encodeURIComponent(link),
- });
- },
- // 获取收藏事件
- getdata() {
- // this.timer=setInterval(() => {
- // if(this.animationDataArr.length>0){
- // console.log(this.animationDataArr.length);
- // this.animationDataArr.unshift()
- // }
- // }, 1500)
- const value = this.$store.state.user.openid;
- if (!value) return this.collArr = []
- // 触发收藏事件
- // console.log('触发收藏事件');
- // this.collArr: [],
- let data = {
- oid: this.$store.state.user.openid, //用户id
- type: 0
- }
- this.$request('/selectOperator', 'POST', data).then(res => {
- // console.log('获取收藏', res);
- // 每次调用前清零,防止push叠加错误
- this.collArr = []
- // 将acid遍历到collArr中
- res[0].forEach(i => {
- this.collArr.push(i.acId)
- })
- // console.log(111);
- // console.log('this.collArr',this.collArr);
- })
- },
- goLog() {
- uni.navigateTo({
- url: "/pages/login_Wechat/login_Wechat",
- });
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- .listBlock1 {
- display: flex;
- justify-content: space-between;
- background-color: #ffffff;
- padding: 20rpx 30rpx;
- width: 750rpx;
- .img {
- width: 160rpx;
- height: 160rpx;
- flex-shrink: 0;
- position: relative;
- .starView {
- width: 40rpx;
- height: 40rpx;
- box-sizing: content-box;
- padding-bottom: 10rpx;
- padding-left: 10rpx;
- position: absolute;
- right: 0rpx;
- top: 0rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .star {
- width: 30rpx;
- height: 30rpx;
- }
- image {
- width: 100%;
- height: 100%;
- border-radius: 10rpx;
- }
- }
- .right {
- padding-left: 20rpx;
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .title {
- display: flex;
- width: 500rpx;
- justify-content: flex-start;
- align-items: center;
- .titTxt {
- color: rgba(0, 0, 0, 0.8);
- flex: 1;
- font-weight: bold;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- }
- .introduce {
- font-size: 24rpx;
- display: flex;
- justify-content: space-between;
- .bri {
- width: 250rpx;
- color: #a7a7a7;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .tim {
- color: #a7a7a7;
- }
- }
- .operate {
- display: flex;
- justify-content: space-between;
- .left {
- display: flex;
- align-items: baseline;
- position: relative;
- width: 60%;
- .add {
- position: absolute;
- bottom: 0;
- left: 0;
- width: 100%;
- padding-left: 3rpx;
- color: rgba(0, 0, 0, 0.6) !important;
- }
- }
- .Oright {
- // width: 80px;
- display: flex;
- justify-content: flex-end;
- align-items: center;
- .mon {
- color: rgba(246, 135, 23, 1);
- font-weight: 700;
- font-size: 34rpx;
- }
- .text {
- font-size: 24rpx;
- color: #3081E8;
- }
- .arrow {
- display: flex;
- justify-content: center;
- margin-top: 5rpx;
- image {
- width: 32rpx;
- height: 32rpx;
- }
- }
- }
- }
- }
- .tag {
- border: 1px rgba(0, 178, 182, 1) solid;
- flex-shrink: 0;
- letter-spacing: 2rpx;
- // width: 104rpx;
- // height: 36rpx;
- padding: 2rpx 4rpx;
- display: flex;
- white-space: nowrap;
- justify-content: center;
- align-items: center;
- border-radius: 4rpx;
- margin-right: 10rpx;
- color: rgba(0, 178, 182, 1);
- line-height: 32rpx;
- }
- .tag1 {
- flex-shrink: 0;
- letter-spacing: 2rpx;
- // width: 104rpx;
- // height: 36rpx;
- padding: 2rpx 4rpx;
- display: flex;
- white-space: nowrap;
- justify-content: center;
- align-items: center;
- border-radius: 4rpx;
- margin-right: 10rpx;
- line-height: 32rpx;
- border: 1px rgba(0, 86, 168, 1) solid;
- color: rgba(0, 86, 168, 1);
- }
- }
- </style>
|