index.vue 11 KB

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