index.vue 11 KB

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