index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <view class="content">
  3. <div class="choose-box">
  4. <div class="type" :class="{ active: typeActive }">
  5. <picker
  6. @change="bindPickerChange($event, 'type')"
  7. :value="indexType"
  8. :range="pickerTypeArray"
  9. range-key="label"
  10. class="packer"
  11. >
  12. <view class="picker_title">
  13. {{ pickerType }}
  14. </view>
  15. </picker>
  16. </div>
  17. <div class="state" :class="{ active: !typeActive }">
  18. <picker
  19. @change="bindPickerChange($event, 'state')"
  20. :value="indexState"
  21. :range="pickerStateArray"
  22. range-key="label"
  23. class="packer"
  24. >
  25. <view class="picker_title">
  26. {{ pickerState }}
  27. </view>
  28. </picker>
  29. </div>
  30. </div>
  31. <div class="actives">
  32. <div
  33. v-for="(active, idx) in activeListCopy"
  34. :key="idx"
  35. class="actives-item"
  36. @click="goDeatil(active.id)"
  37. >
  38. <div class="active-content">
  39. <div class="img-box"><img :src="active.url" alt="" /></div>
  40. <div class="right">
  41. <div class="right-title">{{ active.title }}</div>
  42. <div class="right-inf">
  43. <div class="inf-type right-item" style="width: 17%">
  44. <div
  45. :class="{ color: active.type == 1 }"
  46. class="originColor"
  47. ></div>
  48. <div>{{ active.type == 1 ? "线上" : "线下" }}</div>
  49. </div>
  50. <div class="inf-way right-item">
  51. {{ active.way }}
  52. </div>
  53. <div class="inf-date right-item">
  54. {{ active.date }}
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="readShare">
  60. <div v-show="active.status == '待开始'" class="active-tips-box wait-color">
  61. 活动待开始
  62. </div>
  63. <div v-show="active.status == '已开始'" class="active-tips-box ing-color">
  64. 活动进行中
  65. </div>
  66. <div v-show="active.status == '已结束'" class="active-tips-box end-color">
  67. 活动已结束
  68. </div>
  69. <div class="read">浏览 {{ active.read }}</div>
  70. <div class="share">分享 {{ active.share }}</div>
  71. </div>
  72. </div>
  73. </div>
  74. </view>
  75. </template>
  76. <script>
  77. import md5 from "@/common/md5.js";
  78. export default {
  79. data() {
  80. return {
  81. pickerState: "状态",
  82. pickerType: "类型",
  83. message: "找活动",
  84. themeColor: "#007AFF",
  85. mode: "selector",
  86. typeActive: true,
  87. indexType: 0,
  88. indexState: 0,
  89. pickerTypeArray: [
  90. {
  91. label: "全部",
  92. value: 0,
  93. },
  94. {
  95. label: "线上",
  96. value: 1,
  97. },
  98. {
  99. label: "线下",
  100. value: 2,
  101. },
  102. ],
  103. pickerStateArray: [
  104. {
  105. label: "全部",
  106. value: 3,
  107. },
  108. {
  109. label: "待开始",
  110. value: 0,
  111. },
  112. {
  113. label: "已开始",
  114. value: 1,
  115. },
  116. {
  117. label: "已结束",
  118. value: 2,
  119. },
  120. ],
  121. activeList: [
  122. // {
  123. // url: "/static/activity/1.png",
  124. // title: "400场讲座,200门课程,免费送上门!就等你申请",
  125. // way: "区人力资源局",
  126. // date: "2021-08-08",
  127. // read: 322,
  128. // share: 1,
  129. // type: 1, //1线上
  130. // },
  131. // {
  132. // url: "/static/activity/2.png",
  133. // title: "智能制造商标品牌培育系列培训活动",
  134. // way: "市场监督管理局",
  135. // date: "2021-08-07",
  136. // read: 322,
  137. // share: 1,
  138. // type: 2, //2线下
  139. // },
  140. ],
  141. activeListCopy: [],
  142. };
  143. },
  144. onLoad() {
  145. },
  146. onShow() {
  147. this.getActive();
  148. },
  149. methods: {
  150. bindPickerChange(e, op) {
  151. console.log(e.detail.value);
  152. switch (op) {
  153. case "type":
  154. this.indexType = e.detail.value;
  155. this.pickerType = this.pickerTypeArray[this.indexType].label;
  156. this.typeActive = true;
  157. break;
  158. case "state":
  159. this.indexState = e.detail.value;
  160. this.pickerState = this.pickerStateArray[this.indexState].label;
  161. this.typeActive = false;
  162. }
  163. /*
  164. { label: "全部", value: 1, }, { label: "线上", value: 2, }, { label: "线下", value: 3, },
  165. { label: "全部", value: 1, }, { label: "待开始",value: 2,},{label: "已开始",value: 3, }, { label: "已结束",value: 4, },
  166. "status":"活动状态 0:待开始;1:已开始; 2:已结束
  167. "type":"活动类型 1:线上;2 线下"}
  168. */
  169. let type = this.indexType;
  170. let state = this.indexState;
  171. this.activeListCopy = this.activeList.filter((item) => {
  172. return (
  173. (type == 0 || item.type == type) &&
  174. (state == 0 || item.status == state - 1)
  175. );
  176. });
  177. },
  178. goDeatil(id) {
  179. uni.navigateTo({
  180. url: "/pages/activity/activity_deatil?id=" + id,
  181. });
  182. },
  183. getActive() {
  184. let md5Sign = md5(
  185. "method=" +
  186. "activity" +
  187. "&timestamp=" +
  188. getApp().globalData.globalTimestamp +
  189. "&secret=" +
  190. getApp().globalData.secret
  191. );
  192. let url =
  193. getApp().globalData.shareUrl +
  194. "api/api.php" +
  195. "?method=activity&source=activity&action=list&timestamp=" +
  196. getApp().globalData.globalTimestamp +
  197. "&sign=" +
  198. md5Sign;
  199. let postData = {
  200. // page: 1,
  201. // page_size: 15,
  202. s_cancel : 0
  203. };
  204. uni.request({
  205. url: url,
  206. method: "POST",
  207. header: {
  208. "content-type": "application/x-www-form-urlencoded",
  209. },
  210. data: postData,
  211. success: (res) => {
  212. // console.log(res);
  213. if (res.data.code === 200) {
  214. let list = res.data.data.list;
  215. this.activeList = list.map((item) => {
  216. /*
  217. url: "/static/activity/2.png",
  218. title: "智能制造商标品牌培育系列培训活动",
  219. way: "市场监督管理局",
  220. date: "2021-08-07",
  221. read: 322,
  222. share: 1,
  223. type: 0, //0线下
  224. */
  225. let ob = {
  226. url: "",
  227. title: "",
  228. way: "",
  229. date: "",
  230. read: 0,
  231. share: 0,
  232. type: "",
  233. status: "",
  234. id: "",
  235. status: 0,
  236. };
  237. ob.url = getApp().globalData.shareUrl + item.pic_url;
  238. ob.title = item.name;
  239. ob.way = item.sponsor;
  240. let time = this.$options.filters["globalTime"](item.start_time);
  241. let timeSecond = this.$options.filters["globalTime"](
  242. item.end_time
  243. );
  244. ob.date = time + " 至 " + timeSecond;
  245. ob.read =
  246. parseInt(item.base_read_count) + parseInt(item.real_read_count);
  247. ob.share =
  248. parseInt(item.real_repost_count) +
  249. parseInt(item.base_repost_count);
  250. ob.type = item.type;
  251. ob.status = item.status;
  252. ob.id = item.id;
  253. ob.status = item.status;
  254. return ob;
  255. });
  256. this.activeListCopy = this.activeList;
  257. }
  258. },
  259. fail: () => {
  260. console.log("连接失败");
  261. },
  262. });
  263. },
  264. },
  265. };
  266. </script>
  267. <style lang="scss" scoped>
  268. .content {
  269. display: flex;
  270. flex-direction: column;
  271. align-items: center;
  272. width: 100%;
  273. .choose-box {
  274. padding: 20rpx 0;
  275. width: 100%;
  276. display: flex;
  277. // position: fixed;
  278. height: 50rpx;
  279. top: 0;
  280. // margin-bottom: 50rpx;
  281. .type,
  282. .state {
  283. width: 50%;
  284. display: flex;
  285. justify-content: center;
  286. position: relative;
  287. .packer {
  288. width: 100%;
  289. .picker_title {
  290. z-index: 99;
  291. width: 100%;
  292. height: 100%;
  293. display: flex;
  294. justify-content: center;
  295. }
  296. }
  297. }
  298. .type::after,
  299. .state::after {
  300. z-index: -1;
  301. content: "";
  302. position: absolute;
  303. right: 30%;
  304. top: 20%;
  305. width: 0;
  306. height: 0;
  307. border-top: 15rpx solid rgb(173, 173, 173);
  308. border-left: 15rpx solid transparent;
  309. border-right: 15rpx solid transparent;
  310. }
  311. }
  312. .actives {
  313. width: 90%;
  314. // margin-top: 50rpx;
  315. display: flex;
  316. flex-direction: column;
  317. align-items: center;
  318. .actives-item {
  319. width: 100%;
  320. // height: 150rpx;
  321. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  322. border-radius: 32rpx;
  323. // margin-top: 20px;
  324. padding: 20rpx;
  325. display: flex;
  326. flex-direction: column;
  327. .active-content {
  328. display: flex;
  329. .img-box {
  330. margin-right: 20rpx;
  331. width: 120rpx;
  332. height: 120rpx;
  333. img {
  334. width: 100%;
  335. height: 100%;
  336. border-radius: 10%;
  337. }
  338. }
  339. .right {
  340. width: 80%;
  341. height: 120rpx;
  342. box-sizing: border-box;
  343. display: flex;
  344. flex-direction: column;
  345. justify-content: space-between;
  346. .right-title {
  347. width: 100%;
  348. margin-bottom:20rpx;
  349. font-size: 27rpx;
  350. font-weight: 600;
  351. letter-spacing: 3rpx;
  352. overflow: hidden;
  353. text-overflow: ellipsis;
  354. white-space: nowrap;
  355. }
  356. .right-inf {
  357. flex-wrap: wrap;
  358. display: flex;
  359. font-size: 21rpx;
  360. align-items: center;
  361. color: $uni-text-color-grey;
  362. .right-item{
  363. margin-bottom: 10rpx;
  364. }
  365. .inf-type {
  366. margin-right: 10rpx;
  367. display: flex;
  368. align-items: center;
  369. .originColor {
  370. margin-right: 8rpx;
  371. height: 20rpx;
  372. width: 20rpx;
  373. border-radius: 50%;
  374. background-color: #ffcf86;
  375. }
  376. }
  377. .inf-way {
  378. margin-right: 20rpx;
  379. }
  380. .inf-date {
  381. white-space: nowrap;
  382. }
  383. }
  384. }
  385. }
  386. .readShare {
  387. display: flex;
  388. justify-content: flex-end;
  389. font-size: 20rpx;
  390. color: rgba(0, 0, 0, 0.3);
  391. margin-top: 20rpx;
  392. align-items: center;
  393. .active-tips-box {
  394. font-size: 22rpx;
  395. padding: 10rpx;
  396. border-radius: 10rpx;
  397. color: #fff;
  398. margin-right: 50rpx;
  399. }
  400. .wait-color {
  401. background-color: #aee359;
  402. }
  403. .ing-color {
  404. background-color: #00a8ea;
  405. }
  406. .end-color {
  407. background-color: #d7d7d7;
  408. }
  409. .read {
  410. width: 20%;
  411. text-align: center;
  412. // margin-right: 60rpx;
  413. }
  414. .share {
  415. width: 20%;
  416. text-align: center;
  417. }
  418. }
  419. }
  420. }
  421. }
  422. .active {
  423. color: $uni-color-primary;
  424. }
  425. .color {
  426. background-color: #589cff !important;
  427. }
  428. </style>