my_activity.vue 7.9 KB

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