teachingDetail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. <template>
  2. <!-- 教研室详情 -->
  3. <view class="teachingDetail">
  4. <statusBar :item="navbar"></statusBar>
  5. <!-- 顶部 -->
  6. <view class="backPic" v-for="(item,index) in actItemList" :key="index + 'a' ">
  7. <image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Rectangle 40.png" mode="aspectFill">
  8. </image>
  9. <view class="card">
  10. <view class="cardTop">
  11. <view class="title three-font">{{ item.acName }}</view>
  12. <view class="icons">
  13. <view class="icon" @click="coll">
  14. <image :src="collArr.includes(item.acId) ? pic_coll2 : pic_coll "
  15. style="width: 42rpx;height: 42rpx;" mode="aspectFill"></image>
  16. </view>
  17. <view class="icon" @click="sub">
  18. <image
  19. :src="subArr.includes(item.acId) ? pic_sub2 : pic_sub "
  20. style="width: 38rpx;height: 42rpx;" mode="aspectFill"></image>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="col fz-font">
  25. 成立日期:{{ item.create_at.split('T')[0] }}
  26. </view>
  27. <view class="col fz-font">
  28. 人数:{{ item.pers }}人
  29. </view>
  30. <view class="tag col">
  31. <view class="fz-font">教研标签:</view>
  32. <view class="" style="display: flex;">
  33. <view class="bqZ-font"
  34. style="color: #00b2b6; border: 1px #00b2b6 solid;padding: 2rpx 10rpx;border-radius: 5rpx;font-weight: 600;">
  35. {{ typetext }}
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <!-- 两个大资料文件 -->
  42. <view class="teaData">
  43. <view class="cla">
  44. <view class="tit1 three-font">课程资料</view>
  45. <view class="tit2 fz-font">教研室专属课程</view>
  46. </view>
  47. <view class="cla2">
  48. <view class="tit1 titColor three-font">资源文件</view>
  49. <view class="tit2 titColor fz-font">教研室专属资源</view>
  50. </view>
  51. </view>
  52. <!-- 教研室详情 -->
  53. <view class="" style="padding: 0 30rpx;">
  54. <detailBlock :actItemList='actItemList' :item="judge"></detailBlock>
  55. </view>
  56. <!-- 创建者用户名 -->
  57. <view style="padding: 0 30rpx;">
  58. <view class="creator" v-for="(item,index) in actItemList" :key="index + 'b' ">
  59. <image
  60. :src="item.avatar == null ? 'https://teacherapi.cocorobo.cn/teaching-file/static//mine/Avatar_default.png' : item.avatar"
  61. mode="aspectFill"></image>
  62. <view class="creName btn-font">
  63. {{ item.username }}
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 当前成员 -->
  68. <view style="padding: 0 30rpx; display: none;">
  69. <view class="member">
  70. <view class="memberTop">
  71. <view class="btn-font">当前成员</view>
  72. <view class="fz-font" style="color: rgba(0, 0, 0, 0.4);display: flex;align-items: center;"
  73. @click="gotoMorePer">
  74. <text>查看更多</text>
  75. <image src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png"
  76. style="width: 32rpx;height: 32rpx;" mode="aspectFill"></image>
  77. <!-- <uni-icons type="right"></uni-icons> -->
  78. </view>
  79. </view>
  80. <view class="pers">
  81. <!-- <view class="per" v-for="i in perNum">
  82. <image :src="i.img"></image>
  83. <view class="perName fz-font">
  84. {{i.Name}}
  85. </view>
  86. </view> -->
  87. <view class="per">
  88. <!-- <image :src="item.img"></image> -->
  89. <view class="perName fz-font">
  90. 暂无人员
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 申请加入 -->
  97. <view class="btnBlock">
  98. <button class="btn zw-font" :disabled="isButtonDisabled" @click="applyAdd"
  99. :style="isButtonDisabled ? 'background-color:#87CEFA;' : 'background-colo:#0056a8;'">{{ btnText }}</button>
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. export default {
  105. data() {
  106. return {
  107. navbar: {
  108. title: '教研室详情',
  109. btn: 1
  110. },
  111. isButtonDisabled: false,
  112. btnText: '申请加入',
  113. actItemList: [],
  114. collArr:[],
  115. subArr:[],
  116. clickedAcId:'',
  117. pic_coll:'https://teacherapi.cocorobo.cn/teaching-file/static//yym/Star 1 (Stroke) (2).png',
  118. pic_coll2:'https://teacherapi.cocorobo.cn/teaching-file/static//mine/Collect_yellow.png',
  119. pic_sub:'https://teacherapi.cocorobo.cn/teaching-file/static/yym/Vector (Stroke) (1).png',
  120. pic_sub2:'../../static/mine/dingyue_blue.png',
  121. perNum: [{
  122. Name: '金晶',
  123. img: 'https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 4 (1).png'
  124. },
  125. {
  126. Name: '朱心艺',
  127. img: 'https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 4 (2).png'
  128. },
  129. {
  130. Name: '李红',
  131. img: 'https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 4 (3).png'
  132. },
  133. {
  134. Name: '杨婉',
  135. img: 'https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 4 (4).png'
  136. },
  137. {
  138. Name: '郑元雄',
  139. img: 'https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 4.png'
  140. },
  141. {
  142. Name: '罗佳诚',
  143. img: 'https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 4 (3).png'
  144. }
  145. ],
  146. judge: {
  147. isShow: 0,
  148. info: ""
  149. },
  150. typetext: ''
  151. };
  152. },
  153. methods: {
  154. // 收藏事件
  155. coll(event){
  156. // console.log(event.currentTarget.dataset.e);
  157. console.log(this.$store.state.user.openid);
  158. let aId=this.clickedAcId
  159. // 先获取用户收藏信息
  160. let data={
  161. oid:this.$store.state.user.openid, //用户id
  162. }
  163. this.$request('/selectColl','POST',data).then(res=>{
  164. // console.log('获取收藏信息',res);
  165. // return console.log('获取收藏信息',res[0][0].coll=='');
  166. let res2
  167. let colls
  168. if(res[0][0].coll!==null && res[0][0].coll !==""){
  169. colls=JSON.parse(res[0][0].coll)
  170. console.log('获取收藏信息',colls);
  171. // 判断收藏表是否包含这个活动
  172. res2 = colls.some((e)=>{
  173. return e == aId
  174. })
  175. // console.log(res2);
  176. }
  177. // return console.log('2',res2);
  178. // 第一次存储返回值为null,然后存储收藏
  179. if(res[0][0].coll==null || res[0][0].coll==""){
  180. // 然后进行存储活动到用户coll字段
  181. let arr={
  182. oid:this.$store.state.user.openid, //用户id
  183. acid:JSON.stringify([aId])
  184. }
  185. this.$request('/updateColl','POST',arr).then(res=>{
  186. this.$request('/selectColl','POST',data).then(res=>{
  187. this.collArr=JSON.parse(res[0][0].coll)
  188. })
  189. })
  190. // 当数组中没有这个收藏活动时添加收藏
  191. }else if(!res2){
  192. colls.push(aId)
  193. let arr2={
  194. oid:this.$store.state.user.openid, //用户id
  195. acid:JSON.stringify(colls)
  196. }
  197. this.$request('/updateColl','POST',arr2).then(res=>{
  198. this.$request('/selectColl','POST',data).then(res=>{
  199. this.collArr=JSON.parse(res[0][0].coll)
  200. })
  201. })
  202. // 取消收藏
  203. }else if(res2){
  204. const newArray = colls.filter(item => item !== aId);
  205. let arr3={
  206. oid:this.$store.state.user.openid, //用户id
  207. acid:JSON.stringify(newArray)
  208. }
  209. this.$request('/updateColl','POST',arr3).then(res=>{
  210. this.$request('/selectColl','POST',data).then(res=>{
  211. this.collArr=JSON.parse(res[0][0].coll)
  212. })
  213. })
  214. }
  215. })
  216. },
  217. // 订阅事件
  218. sub(event){
  219. // console.log(event.currentTarget.dataset.e);
  220. console.log(this.$store.state.user.openid);
  221. let aId=this.clickedAcId
  222. // 先获取用户订阅信息
  223. let data={
  224. oid:this.$store.state.user.openid, //用户id
  225. }
  226. this.$request('/selectSub','POST',data).then(res=>{
  227. // console.log('获取订阅信息',res);
  228. // return console.log('获取订阅信息',res[0][0].coll=='');
  229. let res2
  230. let subs
  231. if(res[0][0].sub!==null && res[0][0].sub !==""){
  232. console.log(res);
  233. subs=JSON.parse(res[0][0].sub)
  234. console.log('获取订阅信息',subs);
  235. // 判断订阅表是否包含这个活动
  236. res2 = subs.some((e)=>{
  237. return e == aId
  238. })
  239. // console.log(res2);
  240. }
  241. // return console.log('2',res2);
  242. // 第一次存储返回值为null,然后存储订阅
  243. if(res[0][0].sub==null || res[0][0].sub==""){
  244. // 然后进行存储活动到用户coll字段
  245. let arr={
  246. oid:this.$store.state.user.openid, //用户id
  247. acid:JSON.stringify([aId])
  248. }
  249. this.$request('/updateSub','POST',arr).then(res=>{
  250. this.$request('/selectSub','POST',data).then(res=>{
  251. this.subArr=JSON.parse(res[0][0].sub)
  252. })
  253. })
  254. // 当数组中没有这个订阅活动时添加订阅
  255. }else if(!res2){
  256. subs.push(aId)
  257. let arr2={
  258. oid:this.$store.state.user.openid, //用户id
  259. acid:JSON.stringify(subs)
  260. }
  261. this.$request('/updateSub','POST',arr2).then(res=>{
  262. this.$request('/selectSub','POST',data).then(res=>{
  263. this.subArr=JSON.parse(res[0][0].sub)
  264. })
  265. })
  266. // 取消订阅
  267. }else if(res2){
  268. const newArray = subs.filter(item => item !== aId);
  269. let arr3={
  270. oid:this.$store.state.user.openid, //用户id
  271. acid:JSON.stringify(newArray)
  272. }
  273. this.$request('/updateSub','POST',arr3).then(res=>{
  274. this.$request('/selectSub','POST',data).then(res=>{
  275. this.subArr=JSON.parse(res[0][0].sub)
  276. })
  277. })
  278. }
  279. })
  280. },
  281. gotoMorePer() {
  282. uni.navigateTo({
  283. url: '/pages/dy/dy'
  284. })
  285. },
  286. applyAdd() {
  287. // const clickedAcId = this.actItemList[0].acId;
  288. // console.log(clickedAcId);
  289. uni.navigateTo({
  290. url: '/pages/jys/jys?acId=' + this.clickedAcId
  291. })
  292. },
  293. //判断是否报名
  294. btnEnroll() {
  295. this.$request('/selectActivityEnrollid', "POST", {
  296. acId: this.clickedAcId,
  297. openid: uni.getStorageSync('oId')
  298. }).then(res => {
  299. if (!res[0][0] || !res[0][0].hasOwnProperty('acId')) {
  300. console.log('acId 未定义或不存在');
  301. return
  302. }
  303. // console.log(clickedAcId);
  304. console.log(res[0]);
  305. if (this.clickedAcId === res[0][0].acId) {
  306. this.isButtonDisabled = true
  307. this.btnText = '已加入'
  308. }
  309. })
  310. },
  311. mapTypeToText(type) {
  312. if (type === 0) {
  313. return "直播活动";
  314. } else if (type === 1) {
  315. return "常规教研活动";
  316. } else {
  317. return "专题教研活动";
  318. }
  319. },
  320. getActivity() {
  321. // 获取当前页面的URL
  322. const routes = getCurrentPages();
  323. console.log(routes);
  324. const acId = routes[1].options.acId ? routes[1].options.acId : routes[2].options.acId
  325. let data = {
  326. acId: acId,
  327. ty: 2
  328. }
  329. this.$request('/selectActivityID', "POST", data).then(res => {
  330. // console.log(res[0]);
  331. // this.activeList=[...this.activeList,...res[0]]
  332. this.actItemList = res[0]
  333. this.typetext = this.mapTypeToText(this.actItemList.type);
  334. this.clickedAcId = this.actItemList[0].acId;
  335. this.btnEnroll()
  336. })
  337. },
  338. getdata(){
  339. let data={
  340. oid:this.$store.state.user.openid, //用户id
  341. }
  342. this.$request('/selectColl','POST',data).then(res=>{
  343. this.collArr=JSON.parse(res[0][0].coll)
  344. console.log('进来就显示',this.collArr);
  345. })
  346. },
  347. getSub(){
  348. let data={
  349. oid:this.$store.state.user.openid, //用户id
  350. }
  351. this.$request('/selectSub','POST',data).then(res=>{
  352. this.subArr=JSON.parse(res[0][0].sub)
  353. console.log('进来就显示',this.subArr);
  354. })
  355. }
  356. },
  357. onShow() {
  358. this.getActivity()
  359. this.getdata()
  360. this.getSub()
  361. }
  362. }
  363. </script>
  364. <style lang="scss">
  365. .teachingDetail {
  366. padding-bottom: 80px;
  367. .backPic {
  368. width: 750rpx;
  369. position: relative;
  370. image {
  371. width: 100%;
  372. display: block;
  373. }
  374. .card {
  375. position: absolute;
  376. width: 690rpx;
  377. height: 256rpx;
  378. bottom: 10px;
  379. left: 50%;
  380. padding: 30rpx;
  381. background-color: rgba(0, 0, 0, 0.26);
  382. border-radius: 10px;
  383. transform: translate(-50%, 0);
  384. border: 1rpx #667870 solid;
  385. color: #ffffff;
  386. // display: flex;
  387. // flex-direction: column;
  388. // justify-content: space-between;
  389. .cardTop {
  390. display: flex;
  391. justify-content: space-between;
  392. .title {
  393. // padding-bottom: 20rpx;
  394. margin-bottom: 20rpx;
  395. width: 506rpx;
  396. height: 48rpx;
  397. color: #ffffff;
  398. font-family: PingFang SC;
  399. // font-weight: 550;
  400. overflow: hidden;
  401. text-overflow: ellipsis;
  402. white-space: nowrap;
  403. }
  404. .icons {
  405. flex: 1;
  406. display: flex;
  407. align-items: center;
  408. justify-content: space-between;
  409. .icon {
  410. width: 48rpx;
  411. height: 48rpx;
  412. display: flex;
  413. align-items: center;
  414. justify-content: center;
  415. }
  416. }
  417. }
  418. .col {
  419. margin-bottom: 10rpx;
  420. font-weight: 100;
  421. color: #f0edea;
  422. // font-size: 30rpx;
  423. }
  424. .tag {
  425. display: flex;
  426. }
  427. }
  428. // background-image: url(https://teacherapi.cocorobo.cn/teaching-file/static//resource/jqr.png);
  429. }
  430. .teaData {
  431. width: 750rpx;
  432. display: flex;
  433. padding: 20rpx 30rpx;
  434. justify-content: space-between;
  435. // padding: 20px 0;
  436. .cla {
  437. width: 49%;
  438. background: linear-gradient(to bottom, #fcfcff 30%, #e8ecfd 100%);
  439. border-radius: 10px;
  440. padding: 35rpx 30rpx;
  441. color: #424f85;
  442. .tit1 {
  443. // font-size: 38rpx;
  444. margin-bottom: 10rpx;
  445. font-weight: bold;
  446. }
  447. .tit2 {
  448. // font-size: 22px;
  449. // font-size: 30rpx;
  450. // margin-bottom: 5px;
  451. }
  452. }
  453. .cla2 {
  454. width: 45%;
  455. background: linear-gradient(to bottom, #fcfcff 10%, #fef3ea 100%);
  456. border-radius: 10px;
  457. padding: 35rpx 30rpx;
  458. color: #855e42;
  459. .tit1 {
  460. // font-size: 38rpx;
  461. margin-bottom: 10rpx;
  462. font-weight: bold;
  463. }
  464. .tit2 {
  465. // font-size: 22px;
  466. // margin-bottom: 5px;
  467. // font-size: 30rpx;
  468. }
  469. }
  470. }
  471. .creator {
  472. display: flex;
  473. padding: 30rpx;
  474. background-color: #ffffff;
  475. align-items: center;
  476. margin-top: 20rpx;
  477. border-radius: 10px;
  478. image {
  479. width: 96rpx;
  480. height: 96rpx;
  481. border-radius: 50%;
  482. margin-right: 20rpx;
  483. }
  484. .creName {
  485. font-weight: bold;
  486. }
  487. }
  488. .member {
  489. background-color: #ffffff;
  490. margin-top: 20rpx;
  491. padding: 30rpx;
  492. border-radius: 10px;
  493. margin-bottom: 30rpx;
  494. .memberTop {
  495. display: flex;
  496. justify-content: space-between;
  497. margin-bottom: 10px;
  498. }
  499. .pers {
  500. display: flex;
  501. justify-content: space-between;
  502. align-items: center;
  503. .per {
  504. display: flex;
  505. flex-direction: column;
  506. image {
  507. width: 72rpx;
  508. height: 72rpx;
  509. border-radius: 50%;
  510. }
  511. .perName {
  512. // font-size: 14px;
  513. text-align: center;
  514. }
  515. }
  516. }
  517. }
  518. .btnBlock {
  519. position: fixed;
  520. bottom: 0;
  521. width: 750rpx;
  522. background-color: #ffffff;
  523. // padding: 20px 0;
  524. padding: 2vh 0;
  525. .btn {
  526. width: 432rpx;
  527. height: 88rpx;
  528. font-weight: 500;
  529. display: flex;
  530. justify-content: center;
  531. align-items: center;
  532. margin: auto;
  533. background-color: #0056a8;
  534. color: #ffffff;
  535. }
  536. }
  537. }
  538. </style>