listBlock1.vue 8.6 KB

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