index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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 activeList"
  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. };
  133. },
  134. onLoad() {
  135. this.getActive();
  136. },
  137. methods: {
  138. bindPickerChange(e, op) {
  139. console.log(e);
  140. switch (op) {
  141. case "type":
  142. this.indexType = e.detail.value;
  143. this.pickerType = this.pickerTypeArray[this.indexType].label;
  144. this.typeActive = true;
  145. break;
  146. case "state":
  147. this.indexState = e.detail.value;
  148. this.pickerState = this.pickerStateArray[this.indexState].label;
  149. this.typeActive = false;
  150. }
  151. this.index = e.detail.value;
  152. },
  153. goDeatil(id) {
  154. uni.navigateTo({
  155. url: "/pages/activity/activity_deatil?id=" + id,
  156. });
  157. },
  158. getActive() {
  159. let md5Sign = md5(
  160. "method=" +
  161. "common" +
  162. "&timestamp=" +
  163. getApp().globalData.globalTimestamp +
  164. "&secret=" +
  165. getApp().globalData.secret
  166. );
  167. let url =
  168. getApp().globalData.shareUrl +
  169. "api/api.php" +
  170. "?method=common&source=activity&action=list&timestamp=" +
  171. getApp().globalData.globalTimestamp +
  172. "&sign=" +
  173. md5Sign;
  174. let postData = {
  175. page: 1,
  176. page_size: 15,
  177. };
  178. uni.request({
  179. url: url,
  180. method: "POST",
  181. header: {
  182. "content-type": "application/x-www-form-urlencoded",
  183. },
  184. data: postData,
  185. success: (res) => {
  186. console.log(res);
  187. if (res.data.code === 200) {
  188. let list = res.data.data.list;
  189. this.activeList = list.map((item) => {
  190. /*
  191. url: "/static/activity/2.png",
  192. title: "智能制造商标品牌培育系列培训活动",
  193. way: "市场监督管理局",
  194. date: "2021-08-07",
  195. read: 322,
  196. share: 1,
  197. type: 0, //0线下
  198. */
  199. let ob = {
  200. url: "",
  201. title: "",
  202. way: "",
  203. date: "",
  204. read: 0,
  205. share: 0,
  206. type: "",
  207. id: "",
  208. };
  209. ob.url = getApp().globalData.shareUrl + item.pic_url;
  210. ob.title = item.name;
  211. ob.way = item.sponsor;
  212. ob.date = this.$options.filters["globalTime"](item.start_time);
  213. ob.read =
  214. parseInt(item.base_read_count) + parseInt(item.real_read_count);
  215. ob.share =
  216. parseInt(item.real_repost_count) +
  217. parseInt(item.base_repost_count);
  218. ob.type = item.type;
  219. ob.id = item.id;
  220. return ob;
  221. });
  222. }
  223. },
  224. fail: () => {
  225. console.log("连接失败");
  226. },
  227. });
  228. },
  229. },
  230. };
  231. </script>
  232. <style lang="scss" scoped>
  233. .content {
  234. display: flex;
  235. flex-direction: column;
  236. align-items: center;
  237. width: 100%;
  238. .choose-box {
  239. padding: 20rpx 0;
  240. width: 100%;
  241. display: flex;
  242. position: fixed;
  243. height: 50rpx;
  244. top: 0;
  245. margin-bottom: 50rpx;
  246. .type,
  247. .state {
  248. width: 50%;
  249. display: flex;
  250. justify-content: center;
  251. position: relative;
  252. .packer {
  253. width: 100%;
  254. .picker_title {
  255. z-index: 99;
  256. width: 100%;
  257. height: 100%;
  258. display: flex;
  259. justify-content: center;
  260. }
  261. }
  262. }
  263. .type::after,
  264. .state::after {
  265. z-index: -1;
  266. content: "";
  267. position: absolute;
  268. right: 30%;
  269. top: 20%;
  270. width: 0;
  271. height: 0;
  272. border-top: 15rpx solid rgb(173, 173, 173);
  273. border-left: 15rpx solid transparent;
  274. border-right: 15rpx solid transparent;
  275. }
  276. }
  277. .actives {
  278. margin-top: 50rpx;
  279. padding: 0 40rpx;
  280. display: flex;
  281. flex-direction: column;
  282. .actives-item {
  283. height: 150rpx;
  284. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  285. border-radius: 32rpx;
  286. margin-top: 20px;
  287. padding: 50rpx;
  288. display: flex;
  289. flex-direction: column;
  290. .active-content {
  291. display: flex;
  292. .img-box {
  293. margin-right: 20rpx;
  294. width: 120rpx;
  295. height: 120rpx;
  296. img {
  297. width: 100%;
  298. height: 100%;
  299. border-radius: 10%;
  300. }
  301. }
  302. .right {
  303. height: 120rpx;
  304. box-sizing: border-box;
  305. display: flex;
  306. flex-direction: column;
  307. justify-content: space-between;
  308. .right-title {
  309. margin-bottom: 20rpx;
  310. font-size: 27rpx;
  311. font-weight: 600;
  312. letter-spacing: 3rpx;
  313. }
  314. .right-inf {
  315. display: flex;
  316. font-size: 22rpx;
  317. color: $uni-text-color-grey;
  318. .inf-type {
  319. margin-right: 20rpx;
  320. display: flex;
  321. align-items: center;
  322. .originColor {
  323. margin-right: 8rpx;
  324. height: 25rpx;
  325. width: 25rpx;
  326. border-radius: 50%;
  327. background-color: #ffcf86;
  328. }
  329. }
  330. .inf-way {
  331. margin-right: 20rpx;
  332. }
  333. }
  334. }
  335. }
  336. .readShare {
  337. display: flex;
  338. justify-content: flex-end;
  339. font-size: 20rpx;
  340. color: rgba(0, 0, 0, 0.3);
  341. margin-top: 20rpx;
  342. .read {
  343. margin-right: 60rpx;
  344. }
  345. }
  346. }
  347. }
  348. }
  349. .active {
  350. color: $uni-color-primary;
  351. }
  352. .color {
  353. background-color: #589cff !important;
  354. }
  355. </style>