index.vue 9.5 KB

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