my_activity.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <view class="content">
  3. <div class="actives">
  4. <div
  5. v-for="(active, idx) in activeListCopy"
  6. :key="idx"
  7. class="actives-item"
  8. @click="goDeatil(active.id)"
  9. >
  10. <div class="active-content">
  11. <div class="img-box"><img :src="active.url" alt="" /></div>
  12. <div class="right">
  13. <div class="right-title">{{ active.title }}</div>
  14. <div class="right-inf">
  15. <div class="inf-type right-item" style="width: 17%">
  16. <div
  17. :class="{ color: active.type == 1 }"
  18. class="originColor"
  19. ></div>
  20. <div>{{ active.type == 1 ? "线上" : "线下" }}</div>
  21. </div>
  22. <div class="inf-way right-item">
  23. {{ active.way }}
  24. </div>
  25. <div class="inf-date right-item">
  26. {{ active.date }}
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="readShare">
  32. <div v-show="active.status == '0'" class="active-tips-box wait-color">
  33. 活动待开始
  34. </div>
  35. <div v-show="active.status == '1'" class="active-tips-box ing-color">
  36. 活动进行中
  37. </div>
  38. <div v-show="active.status == '2'" class="active-tips-box end-color">
  39. 活动已结束
  40. </div>
  41. <div class="read">浏览 {{ active.read }}</div>
  42. <div class="share">分享 {{ active.share }}</div>
  43. </div>
  44. </div>
  45. </div>
  46. </view>
  47. </template>
  48. <script>
  49. import md5 from "@/common/md5.js";
  50. export default {
  51. data() {
  52. return {
  53. message: "我的活动",
  54. themeColor: "#007AFF",
  55. mode: "selector",
  56. typeActive: true,
  57. indexType: 0,
  58. indexState: 0,
  59. activeList: [
  60. // {
  61. // url: "/static/activity/1.png",
  62. // title: "400场讲座,200门课程,免费送上门!就等你申请",
  63. // way: "区人力资源局",
  64. // date: "2021-08-08",
  65. // read: 322,
  66. // share: 1,
  67. // type: 1, //1线上
  68. // },
  69. // {
  70. // url: "/static/activity/2.png",
  71. // title: "智能制造商标品牌培育系列培训活动",
  72. // way: "市场监督管理局",
  73. // date: "2021-08-07",
  74. // read: 322,
  75. // share: 1,
  76. // type: 2, //2线下
  77. // },
  78. ],
  79. activeListCopy: [],
  80. };
  81. },
  82. onLoad() {
  83. this.getActive();
  84. },
  85. methods: {
  86. goDeatil(id) {
  87. uni.navigateTo({
  88. url: "/pages/activity/activity_deatil?id=" + id,
  89. });
  90. },
  91. getActive() {
  92. let md5Sign = md5(
  93. "method=" +
  94. "activity" +
  95. "&timestamp=" +
  96. getApp().globalData.globalTimestamp +
  97. "&secret=" +
  98. getApp().globalData.secret
  99. );
  100. let url =
  101. getApp().globalData.shareUrl +
  102. "api/api.php" +
  103. "?method=activity&source=activity&action=my_list&timestamp=" +
  104. getApp().globalData.globalTimestamp +
  105. "&sign=" +
  106. md5Sign;
  107. let postData = {
  108. // page: 1,
  109. // page_size: 15,
  110. openId:getApp().globalData.open_id
  111. };
  112. uni.request({
  113. url: url,
  114. method: "POST",
  115. header: {
  116. "content-type": "application/x-www-form-urlencoded",
  117. },
  118. data: postData,
  119. success: (res) => {
  120. // console.log(res);
  121. if (res.data.code === 200) {
  122. let list = res.data.data.list;
  123. this.activeList = list.map((item) => {
  124. /*
  125. url: "/static/activity/2.png",
  126. title: "智能制造商标品牌培育系列培训活动",
  127. way: "市场监督管理局",
  128. date: "2021-08-07",
  129. read: 322,
  130. share: 1,
  131. type: 0, //0线下
  132. */
  133. let ob = {
  134. url: "",
  135. title: "",
  136. way: "",
  137. date: "",
  138. read: 0,
  139. share: 0,
  140. type: "",
  141. status:'',
  142. id: "",
  143. status: 0,
  144. };
  145. ob.url = getApp().globalData.shareUrl + item.pic_url;
  146. ob.title = item.name;
  147. ob.way = item.sponsor;
  148. let time = this.$options.filters["globalTime"](item.start_time);
  149. let timeSecond = this.$options.filters["globalTime"](item.end_time);
  150. ob.date = time + "至" + timeSecond;
  151. ob.read = parseInt(item.base_read_count) + parseInt(item.real_read_count);
  152. ob.share =parseInt(item.real_repost_count) +parseInt(item.base_repost_count);
  153. ob.type = item.type;
  154. ob.status = item.status;
  155. ob.id = item.id;
  156. ob.status = item.status;
  157. return ob;
  158. });
  159. this.activeListCopy = this.activeList;
  160. }
  161. },
  162. fail: () => {
  163. console.log("连接失败");
  164. },
  165. });
  166. },
  167. },
  168. };
  169. </script>
  170. <style lang="scss" scoped>
  171. .content {
  172. display: flex;
  173. flex-direction: column;
  174. align-items: center;
  175. width: 100%;
  176. .choose-box {
  177. padding: 20rpx 0;
  178. width: 100%;
  179. display: flex;
  180. position: fixed;
  181. height: 50rpx;
  182. top: 0;
  183. margin-bottom: 50rpx;
  184. .type,
  185. .state {
  186. width: 50%;
  187. display: flex;
  188. justify-content: center;
  189. position: relative;
  190. .packer {
  191. width: 100%;
  192. .picker_title {
  193. z-index: 99;
  194. width: 100%;
  195. height: 100%;
  196. display: flex;
  197. justify-content: center;
  198. }
  199. }
  200. }
  201. .type::after,
  202. .state::after {
  203. z-index: -1;
  204. content: "";
  205. position: absolute;
  206. right: 30%;
  207. top: 20%;
  208. width: 0;
  209. height: 0;
  210. border-top: 15rpx solid rgb(173, 173, 173);
  211. border-left: 15rpx solid transparent;
  212. border-right: 15rpx solid transparent;
  213. }
  214. }
  215. .actives {
  216. width: 90%;
  217. display: flex;
  218. flex-direction: column;
  219. align-items: center;
  220. .actives-item {
  221. // height: 150rpx;
  222. width: 100%;
  223. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  224. border-radius: 32rpx;
  225. margin-top: 20px;
  226. padding: 20rpx;
  227. display: flex;
  228. flex-direction: column;
  229. .active-content {
  230. display: flex;
  231. .img-box {
  232. margin-right: 20rpx;
  233. width: 120rpx;
  234. height: 120rpx;
  235. img {
  236. width: 100%;
  237. height: 100%;
  238. border-radius: 10%;
  239. }
  240. }
  241. .right {
  242. width: 80%;
  243. height: 120rpx;
  244. box-sizing: border-box;
  245. display: flex;
  246. flex-direction: column;
  247. justify-content: space-between;
  248. .right-title {
  249. margin-bottom: 20rpx;
  250. font-size: 27rpx;
  251. font-weight: 600;
  252. letter-spacing: 3rpx;
  253. }
  254. .right-inf {
  255. font-size: 21rpx;
  256. flex-wrap: wrap;
  257. display: flex;
  258. color: $uni-text-color-grey;
  259. .inf-type {
  260. margin-right: 10rpx;
  261. display: flex;
  262. align-items: center;
  263. .originColor {
  264. margin-right: 8rpx;
  265. height: 20rpx;
  266. width: 20rpx;
  267. border-radius: 50%;
  268. background-color: #ffcf86;
  269. }
  270. }
  271. .inf-way {
  272. margin-right: 20rpx;
  273. }
  274. }
  275. }
  276. }
  277. .readShare {
  278. display: flex;
  279. justify-content: flex-end;
  280. font-size: 20rpx;
  281. color: rgba(0, 0, 0, 0.3);
  282. margin-top: 20rpx;
  283. align-items: center;
  284. .active-tips-box {
  285. font-size: 22rpx;
  286. padding: 10rpx;
  287. border-radius: 10rpx;
  288. color: #fff;
  289. margin-right: 50rpx;
  290. }
  291. .wait-color {
  292. background-color: #AEE359;
  293. }
  294. .ing-color {
  295. background-color: #00A8EA;
  296. }
  297. .end-color {
  298. background-color: #d7d7d7;
  299. }
  300. .read {
  301. margin-right: 60rpx;
  302. }
  303. }
  304. }
  305. }
  306. }
  307. .active {
  308. color: $uni-color-primary;
  309. }
  310. .color {
  311. background-color: #589cff !important;
  312. }
  313. </style>