mineCollect.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view>
  3. <statusBar :item="navBarData"></statusBar>
  4. <view class="collectBox">
  5. <view class="collect_length">
  6. <span>共{{ collArr.length }}条收藏</span>
  7. </view>
  8. <!-- <view class="classBox" @click="gotoWeb(index)" v-for="(item,index) in classList" :key="index"> -->
  9. <view class="classBox" v-for="(item,index) in classList" :key="index">
  10. <view class="classTitle">
  11. <span>{{ item.acName }}</span>
  12. <image src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/Collect_yellow.png" mode="aspectFill" @click="coll" :data-e="item"></image>
  13. <!-- <image :src="collArr.includes(item.acId) ? pic2 : '' " style="width: 28rpx; height: 26rpx" mode="aspectFill" @click="coll" :data-e="item"></image> -->
  14. </view>
  15. <view class="classContent">
  16. <view class="contentLeft">
  17. <view class="constDate">
  18. <span class="manage">类型</span>
  19. <span>|</span>
  20. <span class="c_data">{{item.Crdate}}</span>
  21. <!-- <span class="c_time">21:07</span> -->
  22. </view>
  23. <view class="classIntro">
  24. <span>{{ item.brief }}</span>
  25. </view>
  26. </view>
  27. <view class="contentRight">
  28. <image :src="item.pic" mode="aspectFill"></image>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. navBarData: {
  40. title: '我的收藏',
  41. btn: 1
  42. },
  43. collArr: [],
  44. classList: [],
  45. };
  46. },
  47. methods: {
  48. getData() {
  49. let data = {
  50. oid: this.$store.state.user.openid, //用户id
  51. }
  52. this.$request('/selectColl', 'POST', data).then(res => {
  53. this.collArr = JSON.parse(res[0][0].coll)
  54. // let a=this.collArr.join(', ');
  55. // return console.log({a});
  56. let data = {
  57. oid: this.$store.state.user.openid, //用户id
  58. list: this.collArr
  59. }
  60. // return console.log(data);
  61. this.$request('/selectCollList', 'POST', data).then(res => {
  62. console.log(res);
  63. // this.collArr=res[0]
  64. this.classList = res[0]
  65. })
  66. })
  67. },
  68. // 这里获取的活动肯定是已收藏的,就不用判断直接删除就可以了
  69. coll(event){
  70. console.log(this.$store.state.user.openid);
  71. let aId=event.currentTarget.dataset.e.acId
  72. // 先获取用户收藏信息
  73. let data={
  74. oid:this.$store.state.user.openid, //用户id
  75. }
  76. this.$request('/selectColl','POST',data).then(res=>{
  77. let colls=JSON.parse(res[0][0].coll)
  78. // 把未取消收藏的数据提取出来
  79. const newArray = colls.filter(item => item !== aId);
  80. let arr3={
  81. oid:this.$store.state.user.openid, //用户id
  82. acid:JSON.stringify(newArray)
  83. }
  84. this.$request('/updateColl','POST',arr3).then(res=>{
  85. // 删除后重新获取数据进行渲染
  86. this.getData()
  87. })
  88. })
  89. },
  90. },
  91. onShow() {
  92. this.getData()
  93. }
  94. }
  95. </script>
  96. <style lang="scss">
  97. .collectBox {
  98. margin: 0 30rpx;
  99. // margin-bottom: 30rpx;
  100. padding-bottom: 50rpx;
  101. .collect_length {
  102. width: 100%;
  103. height: 40rpx;
  104. font-size: 24rpx;
  105. font-weight: 400;
  106. color: #00000099;
  107. display: flex;
  108. align-items: center;
  109. margin-top: 6px;
  110. margin-bottom: 6px;
  111. }
  112. .classBox {
  113. width: 100%;
  114. height: 248rpx;
  115. background-color: #fff;
  116. border-radius: 20rpx;
  117. padding: 0 16rpx;
  118. margin-bottom: 20rpx;
  119. .classTitle {
  120. display: flex;
  121. padding-top: 15px;
  122. justify-content: space-between;
  123. margin-bottom: 6px;
  124. span {
  125. font-size: 32rpx;
  126. font-weight: 500;
  127. }
  128. image {
  129. width: 32rpx;
  130. height: 32rpx;
  131. }
  132. }
  133. .classContent {
  134. width: 100%;
  135. display: flex;
  136. justify-content: space-between;
  137. .contentLeft {
  138. display: flex;
  139. flex-direction: column;
  140. .constDate {
  141. display: flex;
  142. margin-bottom: 6px;
  143. span {
  144. color: #00000066;
  145. font-size: 24rpx;
  146. font-weight: 400;
  147. &.manage {
  148. border: 1px #00B2B6 solid;
  149. font-size: 10px;
  150. display: flex;
  151. white-space: nowrap;
  152. justify-content: center;
  153. align-items: center;
  154. padding: 1px 6px;
  155. border-radius: 3px;
  156. margin-right: 10rpx;
  157. color: #00B2B6;
  158. font-weight: 600;
  159. }
  160. &:nth-child(2) {
  161. color: #E7E7E7;
  162. ;
  163. margin-left: 4px;
  164. }
  165. &:nth-child(3) {
  166. margin-left: 6px;
  167. }
  168. &:nth-child(4) {
  169. margin-left: 6px;
  170. }
  171. }
  172. }
  173. .classIntro {
  174. width: 93%;
  175. span {
  176. color: #00000099;
  177. font-size: 28rpx;
  178. display: -webkit-box;
  179. word-break: break-all;
  180. text-overflow: ellipsis;
  181. overflow: hidden;
  182. -webkit-box-orient: vertical;
  183. -webkit-line-clamp: 2;
  184. /*设置 需要显示的行数*/
  185. line-height: 23px;
  186. }
  187. }
  188. }
  189. .contentRight {
  190. image {
  191. width: 182rpx;
  192. height: 132rpx;
  193. border-radius: 8rpx;
  194. }
  195. }
  196. }
  197. }
  198. }
  199. </style>