listBlock1.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <view class="">
  3. <view class="listBlock1" v-for="(i,index) in classList" :key="index" @click="gotoDetail" :data-aid="i.acId">
  4. <view class="img cell-img">
  5. <image :src="i.pic" mode="aspectFill"></image>
  6. <view class="starView" @click.stop="coll" :data-e="i">
  7. <image class="star" :src="collArr.includes(i.acId) ? pic_coll2 : pic_coll " mode="aspectFill">
  8. </image>
  9. </view>
  10. </view>
  11. <view class="right">
  12. <view class="title">
  13. <view class="bqZ-font" style="font-size: 20rpx;" :class="i.acshape=='线下活动'?'tag':'tag1'">
  14. {{i.acshape}}
  15. </view>
  16. <view class="titTxt btn-font" style="font-size:34rpx ;">
  17. {{i.acName}}
  18. </view>
  19. </view>
  20. <view class="introduce">
  21. <view class="bri">
  22. <!-- {{ i.brief }} -->
  23. <!-- {{ i.address }} -->
  24. 深圳职业技术大学
  25. </view>
  26. <view class="tim">
  27. {{ i.create_at }}
  28. </view>
  29. </view>
  30. <view class="operate">
  31. <view class="left">
  32. <view class="add fz-font">已报名{{i.bnum}}人</view>
  33. </view>
  34. <!-- <view class="Oright" v-if="!indexId" @click.stop="gotoDetail" :data-aid="i.acId"> -->
  35. <view class="Oright" v-if="!indexId">
  36. <view class="text">{{ i.signNum?'已报名':'报名' }}</view>
  37. <view class="arrow">
  38. <image src="https://teacherapi.cocorobo.cn/teaching-file/static/mine/arrow-right-blue.png"
  39. mode="aspectFill"></image>
  40. </view>
  41. </view>
  42. <view class="Oright" v-if="indexId">
  43. <view class="mon">¥<text style="font-size: 40rpx;">{{i.cost}}</text> </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. name: "listBlock1",
  53. // computed: {
  54. // ...mapState(['msgpop']) // 将 Vuex 中的 items 映射为组件的计算属性
  55. // },
  56. props: {
  57. classList: {
  58. type: Array,
  59. default () {
  60. return [];
  61. },
  62. },
  63. indexId: {
  64. type: Number,
  65. default () {
  66. return 0;
  67. },
  68. },
  69. },
  70. // props:['classList'],
  71. data() {
  72. return {
  73. // 收藏list
  74. collArr: [],
  75. // 节流阀
  76. stopTimer: 0,
  77. timer: null,
  78. // animationDataArr: [],
  79. // 收藏悬浮窗
  80. collpopulShow: false,
  81. // 决定悬浮窗显示哪些内容0 取消 1收藏
  82. collAoff: 0,
  83. // subArr: [],
  84. pic_coll: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/Vstar21707269669382.png',
  85. pic_coll2: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/VStar1707269577778.png',
  86. // pic_sub: 'https://teacherapi.cocorobo.cn/teaching-file/static/yym/Vector (Stroke).png',
  87. // pic_sub2: '../../static/mine/dingyue_blue.png'
  88. };
  89. },
  90. onShow() {},
  91. methods: {
  92. // 收藏事件
  93. coll(event) {
  94. const value = this.$store.state.user.openid;
  95. if (!value) {
  96. uni.showToast({
  97. title: '未登录,请登录',
  98. icon: 'none'
  99. })
  100. setTimeout(this.goLog, 1000)
  101. return
  102. }
  103. if (this.stopTimer) return uni.showToast({
  104. icon: 'none',
  105. title: '点击过快'
  106. })
  107. this.stopTimer = 1
  108. setTimeout(() => {
  109. this.stopTimer = 0
  110. }, 500)
  111. let aId = event.currentTarget.dataset.e.acId
  112. // let type= event.currentTarget.dataset.e.type
  113. //判断是否收藏
  114. let iscoll = null
  115. // 查询是否收藏过
  116. let data = {
  117. acid: aId,
  118. oid: this.$store.state.user.openid, //用户id
  119. ty: 0
  120. }
  121. this.$request('/selectOneOperator', 'POST', data).then(res => {
  122. // console.log('查询是否收藏过',res);
  123. res[0].length ? iscoll = true : iscoll = false;
  124. // iscoll为true表示已经收藏过,执行删除 为true则收藏
  125. if (iscoll) {
  126. // this.animationDataArr.push({
  127. // collAoff: 0
  128. // })
  129. this.$store.dispatch('asyncUpdatemsg', {
  130. collAoff: 0
  131. })
  132. // this.praiseMe()
  133. // console.log('执行删除');
  134. this.$request('/deleteOperator', 'POST', data).then(res => {
  135. this.getdata()
  136. setTimeout(() => {
  137. this.$store.dispatch('asyncDelMsg')
  138. }, 1500)
  139. })
  140. } else {
  141. // this.animationDataArr.push({
  142. // collAoff: 1
  143. // })
  144. // console.log('msgpop',this.$store.state.msgpop);
  145. this.$store.dispatch('asyncUpdatemsg', {
  146. collAoff: 1
  147. })
  148. // let aaa={collAoff: 1}
  149. // console.log('执行添加');
  150. this.$request('/insertOperator', 'POST', data).then(res => {
  151. this.getdata()
  152. // console.log(this.h);
  153. setTimeout(() => {
  154. this.$store.dispatch('asyncDelMsg')
  155. }, 1500)
  156. })
  157. }
  158. })
  159. },
  160. // 跳转到详情页
  161. gotoDetail(e) {
  162. const value = this.$store.state.user.openid;
  163. if (!value) {
  164. uni.showToast({
  165. title: '未登录,请登录',
  166. icon: 'none'
  167. })
  168. setTimeout(this.goLog, 1000)
  169. return
  170. }
  171. let aid = e.currentTarget.dataset.aid;
  172. uni.navigateTo({
  173. url: `/pages/activityDetailNew/activityDetailNew?acId=${aid}`
  174. });
  175. },
  176. //跳转到第三方链接
  177. gotoLink(e) {
  178. const value = this.$store.state.user.openid;
  179. if (!value) {
  180. uni.showToast({
  181. title: '未登录,请登录',
  182. icon: 'none'
  183. })
  184. setTimeout(this.goLog, 1000)
  185. return
  186. }
  187. let link = e.currentTarget.dataset.link;
  188. uni.navigateTo({
  189. url: "/pages/skipone/skipone?url=" + encodeURIComponent(link),
  190. });
  191. },
  192. // 获取收藏事件
  193. getdata() {
  194. // console.log(111);
  195. // this.timer=setInterval(() => {
  196. // if(this.animationDataArr.length>0){
  197. // console.log(this.animationDataArr.length);
  198. // this.animationDataArr.unshift()
  199. // }
  200. // }, 1500)
  201. const value = this.$store.state.user.openid;
  202. if (!value) return this.collArr = []
  203. // 触发收藏事件
  204. // console.log('触发收藏事件');
  205. // this.collArr: [],
  206. let data = {
  207. oid: this.$store.state.user.openid, //用户id
  208. type: 0
  209. }
  210. this.$request('/selectOperator', 'POST', data).then(res => {
  211. // console.log('获取收藏', res);
  212. // 每次调用前清零,防止push叠加错误
  213. this.collArr = []
  214. // 将acid遍历到collArr中
  215. res[0].forEach(i => {
  216. this.collArr.push(i.acId)
  217. })
  218. // console.log('this.collArr',this.collArr);
  219. })
  220. },
  221. goLog() {
  222. uni.navigateTo({
  223. url: "/pages/login_Wechat/login_Wechat",
  224. });
  225. },
  226. },
  227. }
  228. </script>
  229. <style lang="scss" scoped>
  230. .listBlock1 {
  231. display: flex;
  232. justify-content: space-between;
  233. background-color: #ffffff;
  234. padding: 20rpx 30rpx;
  235. width: 750rpx;
  236. .img {
  237. width: 160rpx;
  238. height: 160rpx;
  239. flex-shrink: 0;
  240. position: relative;
  241. .starView {
  242. width: 40rpx;
  243. height: 40rpx;
  244. box-sizing: content-box;
  245. padding-bottom: 10rpx;
  246. padding-left: 10rpx;
  247. position: absolute;
  248. right: 0rpx;
  249. top: 0rpx;
  250. display: flex;
  251. justify-content: center;
  252. align-items: center;
  253. }
  254. .star {
  255. width: 30rpx;
  256. height: 30rpx;
  257. }
  258. image {
  259. width: 100%;
  260. height: 100%;
  261. border-radius: 10rpx;
  262. }
  263. }
  264. .right {
  265. padding-left: 20rpx;
  266. flex: 1;
  267. display: flex;
  268. flex-direction: column;
  269. justify-content: space-between;
  270. .title {
  271. display: flex;
  272. width: 500rpx;
  273. justify-content: flex-start;
  274. align-items: center;
  275. .titTxt {
  276. color: rgba(0, 0, 0, 0.8);
  277. flex: 1;
  278. font-weight: bold;
  279. overflow: hidden;
  280. text-overflow: ellipsis;
  281. white-space: nowrap;
  282. }
  283. }
  284. .introduce {
  285. font-size: 24rpx;
  286. display: flex;
  287. justify-content: space-between;
  288. .bri {
  289. width: 250rpx;
  290. color: #a7a7a7;
  291. overflow: hidden;
  292. text-overflow: ellipsis;
  293. white-space: nowrap;
  294. }
  295. .tim {
  296. color: #a7a7a7;
  297. }
  298. }
  299. .operate {
  300. display: flex;
  301. justify-content: space-between;
  302. .left {
  303. display: flex;
  304. align-items: baseline;
  305. position: relative;
  306. width: 60%;
  307. .add {
  308. position: absolute;
  309. bottom: 0;
  310. left: 0;
  311. width: 100%;
  312. padding-left: 3rpx;
  313. color: rgba(0, 0, 0, 0.6) !important;
  314. }
  315. }
  316. .Oright {
  317. // width: 80px;
  318. display: flex;
  319. justify-content: flex-end;
  320. align-items: center;
  321. .mon {
  322. color: rgba(246, 135, 23, 1);
  323. font-weight: 700;
  324. font-size: 34rpx;
  325. }
  326. .text {
  327. font-size: 24rpx;
  328. color: #3081E8;
  329. }
  330. .arrow {
  331. display: flex;
  332. justify-content: center;
  333. margin-top: 5rpx;
  334. image {
  335. width: 32rpx;
  336. height: 32rpx;
  337. }
  338. }
  339. }
  340. }
  341. }
  342. .tag {
  343. border: 1px rgba(0, 178, 182, 1) solid;
  344. flex-shrink: 0;
  345. letter-spacing: 2rpx;
  346. // width: 104rpx;
  347. // height: 36rpx;
  348. padding: 2rpx 4rpx;
  349. display: flex;
  350. white-space: nowrap;
  351. justify-content: center;
  352. align-items: center;
  353. border-radius: 4rpx;
  354. margin-right: 10rpx;
  355. color: rgba(0, 178, 182, 1);
  356. line-height: 32rpx;
  357. }
  358. .tag1 {
  359. flex-shrink: 0;
  360. letter-spacing: 2rpx;
  361. // width: 104rpx;
  362. // height: 36rpx;
  363. padding: 2rpx 4rpx;
  364. display: flex;
  365. white-space: nowrap;
  366. justify-content: center;
  367. align-items: center;
  368. border-radius: 4rpx;
  369. margin-right: 10rpx;
  370. line-height: 32rpx;
  371. border: 1px rgba(0, 86, 168, 1) solid;
  372. color: rgba(0, 86, 168, 1);
  373. }
  374. }
  375. </style>