listBlock1.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <template>
  2. <view class="">
  3. <view class="listBlock1" v-for="(i,index) in classList" :key="index" @click="gotoLink" :data-link="i.link">
  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"></image>
  8. </view>
  9. </view>
  10. <view class="right">
  11. <view class="title">
  12. <view class="bqZ-font" :class="i.acshape=='线下活动'?'tag':'tag1'"> {{i.acshape}}</view>
  13. <view class="titTxt btn-font" style="">
  14. {{i.acName}}
  15. </view>
  16. </view>
  17. <view class="introduce">
  18. <view class="bri">
  19. {{ i.brief }}
  20. <!-- {{ i.address }} -->
  21. </view>
  22. <view class="tim">
  23. {{ i.create_at }}
  24. </view>
  25. </view>
  26. <view class="operate">
  27. <view class="left">
  28. <view class="add fz-font">已报名{{i.bnum}}/{{i.pers}}人</view>
  29. </view>
  30. <view class="Oright" v-if="!indexId" @click.stop="gotoDetail" :data-aid="i.acId">
  31. <view class="text">报名</view>
  32. <view class="arrow">
  33. <image src="https://teacherapi.cocorobo.cn/teaching-file/static/mine/arrow-right-blue.png"
  34. mode="aspectFill"></image>
  35. </view>
  36. </view>
  37. <view class="Oright" v-if="indexId">
  38. <view class="mon">¥<text style="font-size: 40rpx;">{{i.cost}}</text> </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. name: "listBlock1",
  48. // computed: {
  49. // ...mapState(['msgpop']) // 将 Vuex 中的 items 映射为组件的计算属性
  50. // },
  51. props: {
  52. classList: {
  53. type: Array,
  54. default () {
  55. return [];
  56. },
  57. },
  58. indexId: {
  59. type: Number,
  60. default () {
  61. return 0;
  62. },
  63. },
  64. },
  65. // props:['classList'],
  66. data() {
  67. return {
  68. // 收藏list
  69. collArr: [],
  70. // 节流阀
  71. stopTimer: 0,
  72. timer: null,
  73. // animationDataArr: [],
  74. // 收藏悬浮窗
  75. collpopulShow: false,
  76. // 决定悬浮窗显示哪些内容0 取消 1收藏
  77. collAoff: 0,
  78. // subArr: [],
  79. pic_coll: 'https://teacherapi.cocorobo.cn/teaching-file/static/Stara.png',
  80. pic_coll2: 'https://teacherapi.cocorobo.cn/teaching-file/static/mine/Collect_yellow.png',
  81. // pic_sub: 'https://teacherapi.cocorobo.cn/teaching-file/static/yym/Vector (Stroke).png',
  82. // pic_sub2: '../../static/mine/dingyue_blue.png'
  83. };
  84. },
  85. onShow() {},
  86. methods: {
  87. // 收藏事件
  88. coll(event) {
  89. const value = this.$store.state.user.openid;
  90. if (!value) {
  91. uni.showToast({
  92. title: '未登录,请登录',
  93. icon: 'none'
  94. })
  95. setTimeout(this.goLog, 1000)
  96. return
  97. }
  98. if (this.stopTimer) return uni.showToast({
  99. icon: 'none',
  100. title: '点击过快'
  101. })
  102. this.stopTimer = 1
  103. setTimeout(() => {
  104. this.stopTimer = 0
  105. }, 500)
  106. // return console.log(event);
  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. // console.log(111);
  191. // this.timer=setInterval(() => {
  192. // if(this.animationDataArr.length>0){
  193. // console.log(this.animationDataArr.length);
  194. // this.animationDataArr.unshift()
  195. // }
  196. // }, 1500)
  197. const value = this.$store.state.user.openid;
  198. if (!value) return this.collArr = []
  199. // 触发收藏事件
  200. // console.log('触发收藏事件');
  201. // this.collArr: [],
  202. let data = {
  203. oid: this.$store.state.user.openid, //用户id
  204. type: 0
  205. }
  206. this.$request('/selectOperator', 'POST', data).then(res => {
  207. // console.log('获取收藏', res);
  208. // 每次调用前清零,防止push叠加错误
  209. this.collArr = []
  210. // 将acid遍历到collArr中
  211. res[0].forEach(i => {
  212. this.collArr.push(i.acId)
  213. })
  214. // console.log(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. flex: 1;
  273. font-weight: bold;
  274. overflow: hidden;
  275. text-overflow: ellipsis;
  276. white-space: nowrap;
  277. }
  278. }
  279. .introduce {
  280. font-size: 24rpx;
  281. display: flex;
  282. justify-content: space-between;
  283. .bri {
  284. width: 250rpx;
  285. color: #a7a7a7;
  286. overflow: hidden;
  287. text-overflow: ellipsis;
  288. white-space: nowrap;
  289. }
  290. .tim {
  291. color: #a7a7a7;
  292. }
  293. }
  294. .operate {
  295. display: flex;
  296. justify-content: space-between;
  297. .left {
  298. display: flex;
  299. align-items: baseline;
  300. position: relative;
  301. width: 60%;
  302. .add {
  303. position: absolute;
  304. bottom: 0;
  305. left: 0;
  306. width: 100%;
  307. padding-left: 3rpx;
  308. color: rgba(0, 0, 0, 0.6) !important;
  309. }
  310. }
  311. .Oright {
  312. // width: 80px;
  313. display: flex;
  314. justify-content: flex-end;
  315. align-items: center;
  316. .mon {
  317. color: rgba(246, 135, 23, 1);
  318. font-weight: 700;
  319. font-size: 34rpx;
  320. }
  321. .text {
  322. font-size: 24rpx;
  323. color: #3081E8;
  324. }
  325. .arrow {
  326. display: flex;
  327. justify-content: center;
  328. margin-top: 5rpx;
  329. image {
  330. width: 32rpx;
  331. height: 32rpx;
  332. }
  333. }
  334. }
  335. }
  336. }
  337. .tag {
  338. border: 1px rgba(0, 178, 182, 1) solid;
  339. flex-shrink: 0;
  340. letter-spacing: 2rpx;
  341. width: 104rpx;
  342. height: 32rpx;
  343. display: flex;
  344. white-space: nowrap;
  345. justify-content: center;
  346. align-items: center;
  347. border-radius: 4rpx;
  348. margin-right: 10rpx;
  349. color: rgba(0, 178, 182, 1);
  350. line-height: 32rpx;
  351. }
  352. .tag1 {
  353. border: 1px rgba(0, 86, 168, 1) solid;
  354. flex-shrink: 0;
  355. letter-spacing: 2rpx;
  356. width: 104rpx;
  357. height: 32rpx;
  358. display: flex;
  359. white-space: nowrap;
  360. justify-content: center;
  361. align-items: center;
  362. border-radius: 4rpx;
  363. margin-right: 10rpx;
  364. color: rgba(0, 86, 168, 1);
  365. line-height: 32rpx;
  366. }
  367. }
  368. </style>