my_activity.vue 8.8 KB

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