index.vue 9.6 KB

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