my_activity.vue 8.0 KB

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