123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- <template>
- <view class="" >
- <view class="listBlock1" v-for="(i,index) in classList" :key="index+'a'">
- <view class="img cell-img">
- <image :src="i.pic" mode="aspectFill"></image>
- </view>
-
- <view class="right">
- <view class="">
- <view class="title">
- <view class="tag bqZ-font">类型</view>
-
- <text class="btn-font" style="">
- {{i.acName}}
- </text>
- </view>
- <view class="introduce fwb-font">
- {{ i.brief }}
- </view>
-
- </view>
-
- <view class="operate">
- <view class="left">
- <view class="opr" style="padding-right: 25rpx" @click="coll" :data-e="i">
- <view class="icon">
- <image :src="collArr.includes(i.acId) ? pic_coll2 : pic_coll "
- style="width: 28rpx; height: 26rpx" mode="aspectFill"></image>
- </view>
- <text class="fz-font">收藏</text>
- </view>
- <view class="opr" @click="sub" :data-e="i">
- <view class="icon">
- <image :src="subArr.includes(i.acId) ? pic_sub2 : pic_sub "
- style="width: 22rpx; height: 26rpx" mode="aspectFill"></image>
- </view>
- <text class="fz-font">订阅</text>
- </view>
- </view>
- <view class="">
- <button class="btn sBtn-font" @click.stop="join">
- 立即参与
- </button>
- </view>
- </view>
- </view>
- </view>
-
- </view>
- </template>
- <script>
- export default {
- name:"listBlock1",
- props: {
- classList: {
- type: Array,
- default () {
- return [];
- },
- },
- indexId: {
- type: Number,
- },
- },
- // props:['classList'],
- data() {
- return {
- collArr:[],
- subArr:[],
- // collArr.includes(i.acId) ? 'http://43.139.158.220:5007/img/static/yym/Star 1 (Stroke).png' : 'http://43.139.158.220:5007/img/static/yym/Vector (Stroke).png'
- pic_coll:'http://43.139.158.220:5007/img/static/yym/Star 1 (Stroke).png',
- pic_coll2:'https://teacherapi.cocorobo.cn/teaching-file/static//mine/Collect_yellow.png',
- pic_sub:'http://43.139.158.220:5007/img/static/yym/Vector (Stroke).png',
- pic_sub2:'../../static/mine/dingyue_blue.png'
- };
- },
-
- methods:{
- // 收藏事件
- coll(event){
- // console.log(event.currentTarget.dataset.e);
- console.log(this.$store.state.user.openid);
- let aId=event.currentTarget.dataset.e.acId
- // 先获取用户收藏信息
- let data={
- oid:this.$store.state.user.openid, //用户id
- }
- this.$request('/selectColl','POST',data).then(res=>{
- // console.log('获取收藏信息',res);
- // return console.log('获取收藏信息',res[0][0].coll=='');
- let res2
- let colls
- if(res[0][0].coll!==null && res[0][0].coll !==""){
- colls=JSON.parse(res[0][0].coll)
- console.log('获取收藏信息',colls);
- // 判断收藏表是否包含这个活动
- res2 = colls.some((e)=>{
- return e == aId
- })
- // console.log(res2);
- }
-
- // return console.log('2',res2);
- // 第一次存储返回值为null,然后存储收藏
- if(res[0][0].coll==null || res[0][0].coll==""){
- // 然后进行存储活动到用户coll字段
- let arr={
- oid:this.$store.state.user.openid, //用户id
- acid:JSON.stringify([aId])
- }
- this.$request('/updateColl','POST',arr).then(res=>{
- this.$request('/selectColl','POST',data).then(res=>{
- this.collArr=JSON.parse(res[0][0].coll)
- })
- })
- // 当数组中没有这个收藏活动时添加收藏
- }else if(!res2){
- colls.push(aId)
- let arr2={
- oid:this.$store.state.user.openid, //用户id
- acid:JSON.stringify(colls)
- }
- this.$request('/updateColl','POST',arr2).then(res=>{
- this.$request('/selectColl','POST',data).then(res=>{
- this.collArr=JSON.parse(res[0][0].coll)
- })
- })
- // 取消收藏
- }else if(res2){
- const newArray = colls.filter(item => item !== aId);
- let arr3={
- oid:this.$store.state.user.openid, //用户id
- acid:JSON.stringify(newArray)
- }
- this.$request('/updateColl','POST',arr3).then(res=>{
- this.$request('/selectColl','POST',data).then(res=>{
- this.collArr=JSON.parse(res[0][0].coll)
- })
- })
- }
- })
- },
-
- // 订阅事件
- sub(event){
- console.log(this.$store.state.user.openid);
- let aId=event.currentTarget.dataset.e.acId
- // 先获取用户订阅信息
- let data={
- oid:this.$store.state.user.openid, //用户id
- }
- this.$request('/selectSub','POST',data).then(res=>{
- // console.log('获取订阅信息',res);
- // return console.log('获取订阅信息',res[0][0].coll=='');
- let res2
- let subs
- if(res[0][0].sub!==null && res[0][0].sub !==""){
- subs=JSON.parse(res[0][0].sub)
- console.log('获取订阅信息',subs);
- // 判断订阅表是否包含这个活动
- res2 = subs.some((e)=>{
- return e == aId
- })
- // console.log(res2);
- }
-
- // return console.log('2',res2);
- // 第一次存储返回值为null,然后存储订阅
- if(res[0][0].sub==null || res[0][0].sub==""){
- // 然后进行存储活动到用户coll字段
- let arr={
- oid:this.$store.state.user.openid, //用户id
- acid:JSON.stringify([aId])
- }
- this.$request('/updateSub','POST',arr).then(res=>{
- this.$request('/selectSub','POST',data).then(res=>{
- this.subArr=JSON.parse(res[0][0].sub)
- })
- })
- // 当数组中没有这个订阅活动时添加订阅
- }else if(!res2){
- subs.push(aId)
- let arr2={
- oid:this.$store.state.user.openid, //用户id
- acid:JSON.stringify(subs)
- }
- this.$request('/updateSub','POST',arr2).then(res=>{
- this.$request('/selectSub','POST',data).then(res=>{
- this.subArr=JSON.parse(res[0][0].sub)
- })
- })
- // 取消订阅
- }else if(res2){
- const newArray = subs.filter(item => item !== aId);
- let arr3={
- oid:this.$store.state.user.openid, //用户id
- acid:JSON.stringify(newArray)
- }
- this.$request('/updateSub','POST',arr3).then(res=>{
- this.$request('/selectSub','POST',data).then(res=>{
- this.subArr=JSON.parse(res[0][0].sub)
- })
- })
- }
- })
- },
- join() {
- const value = this.$store.state.user.openid;
- if (value == '') {
- uni.navigateTo({
- url: "/pages/login_Wechat/login_Wechat",
- });
- return 1;
- } else {
- //推荐课程
- const urls = [
- "https://szptxnjys.yuketang.cn/pro/portal/about/szpt-99Q00351166273N",
- "https://szptxnjys.yuketang.cn/pro/portal/about/szpt-99Q00330324841N",
- "https://szptxnjys.yuketang.cn/pro/portal/about/szpt-99Q00231455802N",
- "https://szptxnjys.yuketang.cn/pro/portal/about/szpt-99Q00406339964N",
- ];
- let index = this.indexId;
- if (index >= 0 && index < urls.length) {
- const url = urls[index];
- uni.navigateTo({
- url: "/pages/skipone/skipone?url=" + encodeURIComponent(url),
- });
- }
- }
- },
- getdata(){
- let data={
- oid:this.$store.state.user.openid, //用户id
- }
- this.$request('/selectColl','POST',data).then(res=>{
- this.collArr=JSON.parse(res[0][0].coll)
- console.log('进来就显示',this.collArr);
- })
- },
- getSub(){
- let data={
- oid:this.$store.state.user.openid, //用户id
- }
- this.$request('/selectSub','POST',data).then(res=>{
- this.subArr=JSON.parse(res[0][0].sub)
- console.log('进来就显示',this.subArr);
- })
- }
- },
- // created () {
- // this.getdata()
- // }
- }
- </script>
- <style lang="scss">
- .listBlock1{
- display: flex;
- justify-content: space-between;
- // margin-bottom: 10px;
- background-color: #ffffff;
- padding: 20rpx 30rpx;
- .img {
- width: 160rpx;
- height: 160rpx;
-
- image {
- width: 100%;
- height: 100%;
- border-radius: 10rpx;
- }
- }
-
- .right {
- padding-left: 20rpx;
- flex: 1;
- // height: 300px;
- width: 100rpx;
- display: flex;
- flex-direction: column;
- // align-content: flex-end ;
- justify-content: space-between;
- // align-content: space-between;
-
- .title {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- margin-bottom: 15rpx;
-
- // margin-bottom: 10rpx;
-
-
- text {
- font-weight: bold;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- }
-
- .introduce {
- // font-size: 28rpx;
- color: #a7a7a7;
- // padding: 20rpx 0;
- // width: 560rpx;
- height: 40rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- .operate {
- display: flex;
- justify-content: space-between;
- // align-items: baseline;
- align-items: flex-end;
-
- .left {
- display: flex;
- // justify-content: space-between;
- // align-items: center;
- align-items: baseline;
-
- // width: 200rpx;
- .opr {
- display: flex;
- align-items: center;
-
- .icon {
- width: 32rpx;
- height: 32rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- }
-
- text {
- padding-left: 3rpx;
- color: #666666;
- }
- }
-
-
-
- }
-
- .btn {
- z-index: 5;
- border: none;
- padding: 0;
- text-align: center;
- // padding: 8px, 24px, 8px, 24px;
- background-color: rgba(48, 129, 232, 1);
- color: #fff;
- border-radius: 100rpx;
- float: right;
- width: 144rpx;
- height: 48rpx;
- line-height: 48rpx;
- letter-spacing: 1px;
- }
- }
- }
-
- .tag {
- border: 1px #00b2b6 solid;
- flex-shrink: 0;
- letter-spacing: 2rpx;
- width: 64rpx;
- height: 32rpx;
- display: flex;
- white-space: nowrap;
- justify-content: center;
- align-items: center;
- border-radius: 4rpx;
- margin-right: 10rpx;
- color: #00b2b6;
- line-height: 32rpx;
- }
- }
-
- </style>
|