activityPage.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <view class="activity">
  3. <statusBar :item="navBarData"></statusBar>
  4. <viewX-Case class="mid">
  5. <template #title>
  6. <view class="title three-font">直播活动</view>
  7. </template>
  8. <template #lookMore>
  9. <view class="lookMore fz-font" @click="gotoLiveList">查看更多</view>
  10. </template>
  11. <template #activeBlock>
  12. <view class="activeData" v-for="(item, index) in liveList" :key="index">
  13. <!-- <image src="https://teacherapi.cocorobo.cn/teaching-file/static//activity/bg1.png" mode="aspectFill"></image> -->
  14. <image :src="item.pic" mode="aspectFill" @click="gotoAnnoun" :data-index="index"></image>
  15. <view class="liveBroadcast">
  16. <view class="title">
  17. <view class="tag bqZ-font">类型</view>
  18. <text three-font @click="gotoAnnoun" :data-index="index">{{ item.acName }}</text>
  19. </view>
  20. <view class="operate">
  21. <view class="left">
  22. <view class="img">
  23. <image :src="item.avatar" mode="aspectFill"></image>
  24. </view>
  25. <view class="user fwb-font">{{ item.username }}</view>
  26. </view>
  27. <view class="collection" @click="coll" :data-e="item">
  28. <!-- <view class="" style="display: flex;margin-right: 10rpx;align-items: center;"> -->
  29. <view class="img">
  30. <!-- <image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Vector (Stroke) (2).png"
  31. mode="aspectFill"></image> -->
  32. <image :src="collArr.includes(item.acId) ? pic_coll2 : pic_coll" mode="aspectFill">
  33. </image>
  34. </view>
  35. <text class="fz-font">收藏</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. </viewX-Case>
  42. <viewX-Case style="margin-top: 10px">
  43. <template #title>
  44. <view class="title three-font">常规教研活动</view>
  45. </template>
  46. <template #lookMore>
  47. <view class="lookMore fz-font" @click="lookMore">查看更多</view>
  48. </template>
  49. <template #activeBlock>
  50. <!-- <activity-case v-for="i in 10" :key="i"></activity-case> -->
  51. <teaching-case :activeList="activeList"></teaching-case>
  52. </template>
  53. </viewX-Case>
  54. <view class="" style="height: 30rpx; width: 100%"> </view>
  55. <view class="qiu" @click="fabClick">
  56. <image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/jia.png" mode="aspectFill"></image>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. data() {
  63. return {
  64. navBarData: {
  65. title: "活动", //导航栏标题
  66. btn: 0, //是否显示返回按钮 0不显示 1 显示
  67. },
  68. actData: {
  69. btn: 1,
  70. },
  71. title: "uni-fab",
  72. // 直播活动列表
  73. liveList: [],
  74. // 教研活动列表
  75. activeList: [],
  76. collArr:[],
  77. pic_coll:'http://43.139.158.220:5007/img/static/yym/Star 1 (Stroke).png',
  78. pic_coll2:'https://teacherapi.cocorobo.cn/teaching-file/static//mine/Collect_yellow.png'
  79. };
  80. },
  81. methods: {
  82. // 获取教研活动
  83. getData() {
  84. let data = {
  85. openid: uni.getStorageSync('oId'),
  86. ty: 1,
  87. page: 1, //下拉获取更多的备用字段
  88. lim: 6 //一次获取多少数据
  89. }
  90. this.$request('/selectActivity', "POST", data).then(res => {
  91. console.log(res[0]);
  92. // this.activeList=[...this.activeList,...res[0]]
  93. this.activeList = res[0]
  94. })
  95. },
  96. // 获取直播活动
  97. getData2() {
  98. let data = {
  99. openid: uni.getStorageSync('oId'),
  100. ty: 0,
  101. page: 1, //下拉获取更多的备用字段
  102. lim: 6 //一次获取多少数据
  103. }
  104. this.$request('/selectActivity', "POST", data).then(res => {
  105. console.log(res[0]);
  106. // this.activeList=[...this.activeList,...res[0]]
  107. this.liveList = res[0].slice(0, 6);
  108. })
  109. },
  110. getcoll(){
  111. let data={
  112. oid:this.$store.state.user.openid, //用户id
  113. }
  114. this.$request('/selectColl','POST',data).then(res=>{
  115. this.collArr=JSON.parse(res[0][0].coll)
  116. console.log('进来就显示',this.collArr);
  117. })
  118. },
  119. // 收藏事件
  120. coll(event){
  121. // console.log(event.currentTarget.dataset.e);
  122. console.log(this.$store.state.user.openid);
  123. let aId=event.currentTarget.dataset.e.acId
  124. // 先获取用户收藏信息
  125. let data={
  126. oid:this.$store.state.user.openid, //用户id
  127. }
  128. this.$request('/selectColl','POST',data).then(res=>{
  129. // console.log('获取收藏信息',res);
  130. // return console.log('获取收藏信息',res[0][0].coll=='');
  131. let res2
  132. let colls
  133. if(res[0][0].coll!==null && res[0][0].coll !==""){
  134. colls=JSON.parse(res[0][0].coll)
  135. console.log('获取收藏信息',colls);
  136. // 判断收藏表是否包含这个活动
  137. res2 = colls.some((e)=>{
  138. return e == aId
  139. })
  140. // console.log(res2);
  141. }
  142. // return console.log('2',res2);
  143. // 第一次存储返回值为null,然后存储收藏
  144. if(res[0][0].coll==null || res[0][0].coll==""){
  145. // 然后进行存储活动到用户coll字段
  146. let arr={
  147. oid:this.$store.state.user.openid, //用户id
  148. acid:JSON.stringify([aId])
  149. }
  150. this.$request('/updateColl','POST',arr).then(res=>{
  151. this.$request('/selectColl','POST',data).then(res=>{
  152. this.collArr=JSON.parse(res[0][0].coll)
  153. })
  154. })
  155. // 当数组中没有这个收藏活动时添加收藏
  156. }else if(!res2){
  157. colls.push(aId)
  158. let arr2={
  159. oid:this.$store.state.user.openid, //用户id
  160. acid:JSON.stringify(colls)
  161. }
  162. this.$request('/updateColl','POST',arr2).then(res=>{
  163. this.$request('/selectColl','POST',data).then(res=>{
  164. this.collArr=JSON.parse(res[0][0].coll)
  165. })
  166. })
  167. // 取消收藏
  168. }else if(res2){
  169. const newArray = colls.filter(item => item !== aId);
  170. let arr3={
  171. oid:this.$store.state.user.openid, //用户id
  172. acid:JSON.stringify(newArray)
  173. }
  174. this.$request('/updateColl','POST',arr3).then(res=>{
  175. this.$request('/selectColl','POST',data).then(res=>{
  176. this.collArr=JSON.parse(res[0][0].coll)
  177. })
  178. })
  179. }
  180. })
  181. },
  182. lookMore() {
  183. const value = this.$store.state.user.openid;
  184. if (value == '') {
  185. uni.navigateTo({
  186. url: "/pages/login_Wechat/login_Wechat",
  187. });
  188. } else {
  189. uni.navigateTo({
  190. url: "/pages/activityList/activityList",
  191. });
  192. }
  193. },
  194. gotoLiveList() {
  195. uni.navigateTo({
  196. url: '/pages/liveActivityList/liveActivityList'
  197. })
  198. },
  199. fabClick() {
  200. const value = this.$store.state.user.openid;
  201. if (value == '') {
  202. uni.navigateTo({
  203. url: "/pages/login_Wechat/login_Wechat",
  204. });
  205. } else {
  206. uni.navigateTo({
  207. url: "/pages/publish/publish",
  208. });
  209. }
  210. },
  211. gotoAnnoun(e) {
  212. let edata = e.currentTarget.dataset['index'];
  213. console.log(e.currentTarget.dataset['index'], 123);
  214. const clickedAcId = this.liveList[edata].acId;
  215. console.log(clickedAcId);
  216. const value = this.$store.state.user.openid;
  217. if (value == '') {
  218. uni.navigateTo({
  219. url: "/pages/login_Wechat/login_Wechat",
  220. });
  221. } else {
  222. uni.navigateTo({
  223. url: "/pages/activityDetail/activityDetail?acId=" + clickedAcId + "&ty=0",
  224. });
  225. // const urls = [
  226. // "https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1181",//丽湖职教双创教育国际虚拟教研室启动大会暨双创教育国际论坛圆满举行
  227. // "https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1234",//丽湖职教双创教育国际虚拟教研室 • 常规教研活动 第9期
  228. // "https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1210",//产教融合情境下的双创通识课程建设 | 丽湖职教双创教育国际虚拟教研室常规教研活动第2期顺利举行
  229. // "https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1209",//打造双创“金课” | 丽湖职教双创教育国际虚拟教研室常规
  230. // ];
  231. // if (index >= 0 && index < urls.length) {
  232. // const url = urls[index];
  233. // uni.navigateTo({
  234. // url: "/pages/skipone/skipone?url=" + encodeURIComponent(url),
  235. // });
  236. // }
  237. }
  238. },
  239. },
  240. onShow() {
  241. this.getData()
  242. this.getData2()
  243. this.getcoll()
  244. }
  245. };
  246. </script>
  247. <style lang="scss">
  248. .activity {
  249. .qiu {
  250. width: 90rpx;
  251. height: 90rpx;
  252. position: fixed;
  253. z-index: 19;
  254. right: 30rpx;
  255. bottom: 10vh;
  256. border-radius: 50%;
  257. background-color: rgba(0, 86, 168, 1);
  258. display: flex;
  259. justify-content: center;
  260. align-items: center;
  261. image {
  262. position: absolute;
  263. width: 36rpx;
  264. height: 36rpx;
  265. }
  266. }
  267. .mid {
  268. // margin:20px 0;
  269. .activeData {
  270. width: 460rpx;
  271. display: inline-block;
  272. margin-right: 20px;
  273. image {
  274. width: 100%;
  275. height: 120px;
  276. border-radius: 10px;
  277. margin-bottom: 10px;
  278. }
  279. .liveBroadcast {
  280. flex: 1;
  281. width: 460rpx;
  282. display: flex;
  283. flex-direction: column;
  284. align-content: flex-end;
  285. .title {
  286. display: flex;
  287. align-items: center;
  288. margin-bottom: 10rpx;
  289. .tag {
  290. // border: 1px #00b2b6 solid;
  291. // // font-size: 12px;
  292. // width: 64rpx;
  293. // height: 38rpx;
  294. // display: flex;
  295. // white-space: nowrap;
  296. // justify-content: center;
  297. // align-items: center;
  298. // // padding: 2px 4px;
  299. // padding: 1rpx 4rpx;
  300. // border-radius: 3px;
  301. // margin-right: 10rpx;
  302. // color: #00b2b6;
  303. border: 1px #00b2b6 solid;
  304. font-size: 20rpx;
  305. width: 64rpx;
  306. display: flex;
  307. height: 34rpx;
  308. white-space: nowrap;
  309. justify-content: center;
  310. align-items: center;
  311. // padding: 4px 12px 4px 12px;
  312. border-radius: 5rpx;
  313. margin-right: 10rpx;
  314. color: #00b2b6;
  315. }
  316. text {
  317. // display: -webkit-box;//对象作为弹性伸缩盒子模型显示
  318. // overflow: hidden;//溢出隐藏
  319. // -webkit-box-orient: vertical;//设置伸缩盒子对象的子元素的排列方式
  320. // -webkit-line-clamp: 2;//设置 块元素包含的文本行数
  321. overflow: hidden;
  322. text-overflow: ellipsis;
  323. white-space: nowrap;
  324. }
  325. }
  326. .operate {
  327. display: flex;
  328. justify-content: space-between;
  329. align-items: center;
  330. padding: 20rpx 0;
  331. color: #666666;
  332. // margin-bottom: 20rpx;
  333. // padding-bottom: 20rpx;
  334. .left {
  335. display: flex;
  336. align-items: center;
  337. .img {
  338. width: 48rpx;
  339. height: 48rpx;
  340. margin-right: 10rpx;
  341. image {
  342. width: 100%;
  343. height: 100%;
  344. border-radius: 50%;
  345. }
  346. }
  347. .user {}
  348. }
  349. .collection {
  350. display: flex;
  351. align-items: center;
  352. justify-content: space-between;
  353. width: 88rpx;
  354. height: 32rpx;
  355. position: relative;
  356. .img {
  357. position: absolute;
  358. left: 0;
  359. top: 6rpx;
  360. transform: translate(-130%, 0);
  361. }
  362. image {
  363. width: 27rpx;
  364. height: 25rpx;
  365. display: block;
  366. }
  367. // float: right;
  368. // font-size: 14px;
  369. // padding-top: 10px;
  370. }
  371. }
  372. }
  373. }
  374. .activeData:nth-child(1) {
  375. margin-left: 15px;
  376. }
  377. }
  378. .title {
  379. font-weight: bold;
  380. // color: #999999;
  381. }
  382. .lookMore {
  383. color: #666666;
  384. // font-size: 14px;
  385. }
  386. }
  387. </style>