my_activity.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. // margin-top: 50rpx;
  221. display: flex;
  222. flex-direction: column;
  223. align-items: center;
  224. .actives-item {
  225. width: 100%;
  226. // height: 150rpx;
  227. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  228. border-radius: 32rpx;
  229. // margin-top: 20px;
  230. padding: 20rpx;
  231. display: flex;
  232. flex-direction: column;
  233. margin-bottom: 20rpx;
  234. .active-content {
  235. display: flex;
  236. .img-box {
  237. margin-right: 20rpx;
  238. width: 120rpx;
  239. height: 120rpx;
  240. img {
  241. width: 100%;
  242. height: 100%;
  243. border-radius: 10%;
  244. }
  245. }
  246. .right {
  247. width: 80%;
  248. // height: 120rpx;
  249. box-sizing: border-box;
  250. display: flex;
  251. flex-direction: column;
  252. justify-content: space-between;
  253. .right-title {
  254. width: 100%;
  255. margin-bottom:10rpx;
  256. font-size: 32rpx;
  257. // font-weight: 600;
  258. letter-spacing: 3rpx;
  259. overflow: hidden;
  260. text-overflow: ellipsis;
  261. white-space: nowrap;
  262. }
  263. .right-inf {
  264. flex-wrap: wrap;
  265. display: flex;
  266. font-size: 26rpx;
  267. align-items: center;
  268. color: $uni-text-color-grey;
  269. .right-item{
  270. margin-bottom: 10rpx;
  271. }
  272. .inf-type {
  273. margin-right: 10rpx;
  274. display: flex;
  275. align-items: center;
  276. .originColor {
  277. margin-right: 8rpx;
  278. height: 20rpx;
  279. width: 20rpx;
  280. border-radius: 50%;
  281. background-color: #ffcf86;
  282. }
  283. }
  284. .inf-way {
  285. margin-right: 20rpx;
  286. }
  287. .inf-date {
  288. white-space: nowrap;
  289. }
  290. }
  291. }
  292. }
  293. .readShare {
  294. display: flex;
  295. justify-content: flex-end;
  296. font-size: 26rpx;
  297. color: rgba(0, 0, 0, 0.3);
  298. margin-top: 20rpx;
  299. align-items: center;
  300. .active-tips-box {
  301. font-size: 28rpx;
  302. padding: 10rpx;
  303. border-radius: 10rpx;
  304. color: #fff;
  305. margin-right: 50rpx;
  306. }
  307. .wait-color {
  308. background-color: #aee359;
  309. }
  310. .ing-color {
  311. background-color: #00a8ea;
  312. }
  313. .end-color {
  314. background-color: #d7d7d7;
  315. }
  316. .read {
  317. width: 20%;
  318. text-align: center;
  319. // margin-right: 60rpx;
  320. }
  321. .share {
  322. width: 20%;
  323. text-align: center;
  324. }
  325. }
  326. }
  327. }
  328. }
  329. .active {
  330. color: $uni-color-primary;
  331. }
  332. .color {
  333. background-color: #589cff !important;
  334. }
  335. </style>