index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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);
  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. let stateObj = {
  172. '0' : '全部',
  173. '1' : '待开始',
  174. '2' : '已开始',
  175. '3' : '已结束'
  176. }
  177. state = stateObj[state]
  178. this.activeListCopy = this.activeList.filter((item) => {
  179. return (
  180. (type == 0 || item.type == type) &&
  181. (state == '全部' || item.status == state)
  182. );
  183. });
  184. },
  185. goDeatil(id) {
  186. uni.navigateTo({
  187. url: "/pages/activity/activity_deatil?id=" + id,
  188. });
  189. },
  190. getActive() {
  191. let md5Sign = md5(
  192. "method=" +
  193. "activity" +
  194. "&timestamp=" +
  195. getApp().globalData.globalTimestamp +
  196. "&secret=" +
  197. getApp().globalData.secret
  198. );
  199. let url =
  200. getApp().globalData.shareUrl +
  201. "api/api.php" +
  202. "?method=activity&source=activity&action=list&timestamp=" +
  203. getApp().globalData.globalTimestamp +
  204. "&sign=" +
  205. md5Sign;
  206. let postData = {
  207. // page: 1,
  208. // page_size: 15,
  209. s_cancel : 0
  210. };
  211. uni.request({
  212. url: url,
  213. method: "POST",
  214. header: {
  215. "content-type": "application/x-www-form-urlencoded",
  216. },
  217. data: postData,
  218. success: (res) => {
  219. // console.log(res);
  220. if (res.data.code === 200) {
  221. let list = res.data.data.list;
  222. this.activeList = list.map((item) => {
  223. /*
  224. url: "/static/activity/2.png",
  225. title: "智能制造商标品牌培育系列培训活动",
  226. way: "市场监督管理局",
  227. date: "2021-08-07",
  228. read: 322,
  229. share: 1,
  230. type: 0, //0线下
  231. */
  232. let ob = {
  233. url: "",
  234. title: "",
  235. way: "",
  236. date: "",
  237. read: 0,
  238. share: 0,
  239. type: "",
  240. status: "",
  241. id: "",
  242. status: 0,
  243. };
  244. ob.url = item.pic_url ? getApp().globalData.shareUrl + item.pic_url : '/static/activity/default.png';
  245. ob.title = item.name;
  246. ob.way = item.sponsor;
  247. let time = this.$options.filters["globalTime"](item.start_time);
  248. let timeSecond = this.$options.filters["globalTime"](
  249. item.end_time
  250. );
  251. ob.date = time + " 至 " + timeSecond;
  252. ob.read =
  253. parseInt(item.base_read_count) + parseInt(item.real_read_count);
  254. ob.share =
  255. parseInt(item.real_repost_count) +
  256. parseInt(item.base_repost_count);
  257. ob.type = item.type;
  258. ob.status = item.status;
  259. ob.id = item.id;
  260. ob.status = item.status;
  261. return ob;
  262. });
  263. this.activeListCopy = this.activeList;
  264. }
  265. },
  266. fail: () => {
  267. console.log("连接失败");
  268. },
  269. });
  270. },
  271. },
  272. };
  273. </script>
  274. <style lang="scss" scoped>
  275. .content {
  276. display: flex;
  277. flex-direction: column;
  278. align-items: center;
  279. width: 100%;
  280. .choose-box {
  281. padding: 20rpx 0;
  282. width: 100%;
  283. display: flex;
  284. // position: fixed;
  285. height: 50rpx;
  286. top: 0;
  287. // margin-bottom: 50rpx;
  288. .type,
  289. .state {
  290. width: 50%;
  291. display: flex;
  292. justify-content: center;
  293. position: relative;
  294. .packer {
  295. width: 100%;
  296. .picker_title {
  297. z-index: 99;
  298. width: 100%;
  299. height: 100%;
  300. display: flex;
  301. justify-content: center;
  302. }
  303. }
  304. }
  305. .type::after,
  306. .state::after {
  307. z-index: -1;
  308. content: "";
  309. position: absolute;
  310. right: 30%;
  311. top: 20%;
  312. width: 0;
  313. height: 0;
  314. border-top: 15rpx solid rgb(173, 173, 173);
  315. border-left: 15rpx solid transparent;
  316. border-right: 15rpx solid transparent;
  317. }
  318. }
  319. .actives {
  320. width: 90%;
  321. // margin-top: 50rpx;
  322. display: flex;
  323. flex-direction: column;
  324. align-items: center;
  325. .actives-item {
  326. width: 100%;
  327. // height: 150rpx;
  328. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  329. border-radius: 32rpx;
  330. // margin-top: 20px;
  331. padding: 20rpx;
  332. display: flex;
  333. flex-direction: column;
  334. margin-bottom: 20rpx;
  335. .active-content {
  336. display: flex;
  337. .img-box {
  338. margin-right: 20rpx;
  339. width: 120rpx;
  340. height: 120rpx;
  341. img {
  342. width: 100%;
  343. height: 100%;
  344. border-radius: 10%;
  345. }
  346. }
  347. .right {
  348. width: 80%;
  349. // height: 120rpx;
  350. box-sizing: border-box;
  351. display: flex;
  352. flex-direction: column;
  353. justify-content: space-between;
  354. .right-title {
  355. width: 100%;
  356. margin-bottom:10rpx;
  357. font-size: 32rpx;
  358. // font-weight: 600;
  359. letter-spacing: 3rpx;
  360. overflow: hidden;
  361. text-overflow: ellipsis;
  362. white-space: nowrap;
  363. }
  364. .right-inf {
  365. flex-wrap: wrap;
  366. display: flex;
  367. font-size: 26rpx;
  368. align-items: center;
  369. color: $uni-text-color-grey;
  370. .right-item{
  371. margin-bottom: 10rpx;
  372. }
  373. .inf-type {
  374. margin-right: 10rpx;
  375. display: flex;
  376. align-items: center;
  377. .originColor {
  378. margin-right: 8rpx;
  379. height: 20rpx;
  380. width: 20rpx;
  381. border-radius: 50%;
  382. background-color: #ffcf86;
  383. }
  384. }
  385. .inf-way {
  386. // margin-right: 20rpx;
  387. width: 77%;
  388. overflow: hidden;
  389. text-overflow: ellipsis;
  390. white-space: nowrap;
  391. }
  392. .inf-date {
  393. white-space: nowrap;
  394. }
  395. }
  396. }
  397. }
  398. .readShare {
  399. display: flex;
  400. justify-content: flex-end;
  401. font-size: 26rpx;
  402. color: rgba(0, 0, 0, 0.3);
  403. margin-top: 20rpx;
  404. align-items: center;
  405. .active-tips-box {
  406. font-size: 28rpx;
  407. padding: 10rpx;
  408. border-radius: 10rpx;
  409. color: #fff;
  410. margin-right: 50rpx;
  411. }
  412. .wait-color {
  413. background-color: #aee359;
  414. }
  415. .ing-color {
  416. background-color: #00a8ea;
  417. }
  418. .end-color {
  419. background-color: #d7d7d7;
  420. }
  421. .read {
  422. width: 20%;
  423. text-align: center;
  424. // margin-right: 60rpx;
  425. }
  426. .share {
  427. width: 20%;
  428. text-align: center;
  429. }
  430. }
  431. }
  432. }
  433. }
  434. .active {
  435. color: $uni-color-primary;
  436. }
  437. .color {
  438. background-color: #589cff !important;
  439. }
  440. </style>