|
@@ -11,14 +11,13 @@
|
|
<view class="cardTop">
|
|
<view class="cardTop">
|
|
<view class="title three-font">{{ item.acName }}</view>
|
|
<view class="title three-font">{{ item.acName }}</view>
|
|
<view class="icons">
|
|
<view class="icons">
|
|
- <view class="icon">
|
|
|
|
- <image
|
|
|
|
- src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Star 1 (Stroke) (2).png"
|
|
|
|
- style="width: 42rpx;height: 40rpx;" mode="aspectFill"></image>
|
|
|
|
|
|
+ <view class="icon" @click="coll">
|
|
|
|
+ <image :src="collArr.includes(item.acId) ? pic_coll2 : pic_coll "
|
|
|
|
+ style="width: 42rpx;height: 42rpx;" mode="aspectFill"></image>
|
|
</view>
|
|
</view>
|
|
- <view class="icon">
|
|
|
|
|
|
+ <view class="icon" @click="sub">
|
|
<image
|
|
<image
|
|
- src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Vector (Stroke) (1).png"
|
|
|
|
|
|
+ :src="subArr.includes(item.acId) ? pic_sub2 : pic_sub "
|
|
style="width: 38rpx;height: 42rpx;" mode="aspectFill"></image>
|
|
style="width: 38rpx;height: 42rpx;" mode="aspectFill"></image>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
@@ -120,6 +119,13 @@
|
|
isButtonDisabled: false,
|
|
isButtonDisabled: false,
|
|
btnText: '申请加入',
|
|
btnText: '申请加入',
|
|
actItemList: [],
|
|
actItemList: [],
|
|
|
|
+ collArr:[],
|
|
|
|
+ subArr:[],
|
|
|
|
+ clickedAcId:'',
|
|
|
|
+ pic_coll:'https://teacherapi.cocorobo.cn/teaching-file/static//yym/Star 1 (Stroke) (2).png',
|
|
|
|
+ pic_coll2:'https://teacherapi.cocorobo.cn/teaching-file/static//mine/Collect_yellow.png',
|
|
|
|
+ pic_sub:'https://teacherapi.cocorobo.cn/teaching-file/static/yym/Vector (Stroke) (1).png',
|
|
|
|
+ pic_sub2:'../../static/mine/dingyue_blue.png',
|
|
perNum: [{
|
|
perNum: [{
|
|
Name: '金晶',
|
|
Name: '金晶',
|
|
img: 'https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 4 (1).png'
|
|
img: 'https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 4 (1).png'
|
|
@@ -153,31 +159,160 @@
|
|
};
|
|
};
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ // 收藏事件
|
|
|
|
+ coll(event){
|
|
|
|
+ // console.log(event.currentTarget.dataset.e);
|
|
|
|
+ console.log(this.$store.state.user.openid);
|
|
|
|
+ let aId=this.clickedAcId
|
|
|
|
+ // 先获取用户收藏信息
|
|
|
|
+ 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(event.currentTarget.dataset.e);
|
|
|
|
+ console.log(this.$store.state.user.openid);
|
|
|
|
+ let aId=this.clickedAcId
|
|
|
|
+ // 先获取用户订阅信息
|
|
|
|
+ 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 !==""){
|
|
|
|
+ console.log(res);
|
|
|
|
+ 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)
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
gotoMorePer() {
|
|
gotoMorePer() {
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
url: '/pages/dy/dy'
|
|
url: '/pages/dy/dy'
|
|
})
|
|
})
|
|
},
|
|
},
|
|
applyAdd() {
|
|
applyAdd() {
|
|
- const clickedAcId = this.actItemList[0].acId;
|
|
|
|
|
|
+ // const clickedAcId = this.actItemList[0].acId;
|
|
// console.log(clickedAcId);
|
|
// console.log(clickedAcId);
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
- url: '/pages/jys/jys?acId=' + clickedAcId
|
|
|
|
|
|
+ url: '/pages/jys/jys?acId=' + this.clickedAcId
|
|
})
|
|
})
|
|
},
|
|
},
|
|
//判断是否报名
|
|
//判断是否报名
|
|
- btnEnroll(clickedAcId) {
|
|
|
|
|
|
+ btnEnroll() {
|
|
this.$request('/selectActivityEnrollid', "POST", {
|
|
this.$request('/selectActivityEnrollid', "POST", {
|
|
- acId: clickedAcId,
|
|
|
|
|
|
+ acId: this.clickedAcId,
|
|
openid: uni.getStorageSync('oId')
|
|
openid: uni.getStorageSync('oId')
|
|
}).then(res => {
|
|
}).then(res => {
|
|
if (!res[0][0] || !res[0][0].hasOwnProperty('acId')) {
|
|
if (!res[0][0] || !res[0][0].hasOwnProperty('acId')) {
|
|
console.log('acId 未定义或不存在');
|
|
console.log('acId 未定义或不存在');
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- console.log(clickedAcId);
|
|
|
|
|
|
+ // console.log(clickedAcId);
|
|
console.log(res[0]);
|
|
console.log(res[0]);
|
|
- if (clickedAcId === res[0][0].acId) {
|
|
|
|
|
|
+ if (this.clickedAcId === res[0][0].acId) {
|
|
this.isButtonDisabled = true
|
|
this.isButtonDisabled = true
|
|
this.btnText = '已加入'
|
|
this.btnText = '已加入'
|
|
}
|
|
}
|
|
@@ -206,13 +341,33 @@
|
|
// this.activeList=[...this.activeList,...res[0]]
|
|
// this.activeList=[...this.activeList,...res[0]]
|
|
this.actItemList = res[0]
|
|
this.actItemList = res[0]
|
|
this.typetext = this.mapTypeToText(this.actItemList.type);
|
|
this.typetext = this.mapTypeToText(this.actItemList.type);
|
|
- const clickedAcId = this.actItemList[0].acId;
|
|
|
|
- this.btnEnroll(clickedAcId)
|
|
|
|
|
|
+ this.clickedAcId = this.actItemList[0].acId;
|
|
|
|
+ this.btnEnroll()
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ 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);
|
|
|
|
+ })
|
|
|
|
+ }
|
|
},
|
|
},
|
|
onShow() {
|
|
onShow() {
|
|
this.getActivity()
|
|
this.getActivity()
|
|
|
|
+ this.getdata()
|
|
|
|
+ this.getSub()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|