index.vue 10 KB

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