listBlock1.vue 8.9 KB

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