index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. export default {
  69. data() {
  70. return {
  71. pickerState: "状态",
  72. pickerType: "类型",
  73. message: "找活动",
  74. themeColor: "#007AFF",
  75. mode: "selector",
  76. typeActive: true,
  77. indexType: 0,
  78. indexState: 0,
  79. pickerTypeArray: [
  80. {
  81. label: "全部",
  82. value: 1,
  83. },
  84. {
  85. label: "线上",
  86. value: 2,
  87. },
  88. {
  89. label: "线下",
  90. value: 3,
  91. },
  92. ],
  93. pickerStateArray: [
  94. {
  95. label: "全部",
  96. value: 1,
  97. },
  98. {
  99. label: "待开始",
  100. value: 2,
  101. },
  102. {
  103. label: "已开始",
  104. value: 3,
  105. },
  106. {
  107. label: "已结束",
  108. value: 4,
  109. },
  110. ],
  111. activeList: [
  112. {
  113. url: "/static/activity/1.png",
  114. title: "400场讲座,200门课程,免费送上门!就等你申请",
  115. way: "区人力资源局",
  116. date: "2021-08-08",
  117. read: 322,
  118. share: 1,
  119. type: 1, //1线上
  120. },
  121. {
  122. url: "/static/activity/2.png",
  123. title: "智能制造商标品牌培育系列培训活动",
  124. way: "市场监督管理局",
  125. date: "2021-08-07",
  126. read: 322,
  127. share: 1,
  128. type: 0, //0线下
  129. },
  130. ],
  131. };
  132. },
  133. onLoad() {},
  134. methods: {
  135. bindPickerChange(e, op) {
  136. console.log(e);
  137. switch (op) {
  138. case "type":
  139. this.indexType = e.detail.value;
  140. this.pickerType = this.pickerTypeArray[this.indexType].label;
  141. this.typeActive = true;
  142. break;
  143. case "state":
  144. this.indexState = e.detail.value;
  145. this.pickerState = this.pickerStateArray[this.indexState].label;
  146. this.typeActive = false;
  147. }
  148. this.index = e.detail.value;
  149. },
  150. goDeatil(id = 1) {
  151. console.log(123);
  152. uni.navigateTo({
  153. url: "/pages/activity/activity_deatil?id=" + id,
  154. });
  155. },
  156. },
  157. };
  158. </script>
  159. <style lang="scss" scoped>
  160. .content {
  161. display: flex;
  162. flex-direction: column;
  163. align-items: center;
  164. width: 100%;
  165. .choose-box {
  166. padding: 20rpx 0;
  167. width: 100%;
  168. display: flex;
  169. position: fixed;
  170. height: 50rpx;
  171. top: 0;
  172. margin-bottom: 50rpx;
  173. .type,
  174. .state {
  175. width: 50%;
  176. display: flex;
  177. justify-content: center;
  178. position: relative;
  179. .packer {
  180. width: 100%;
  181. .picker_title {
  182. z-index: 99;
  183. width: 100%;
  184. height: 100%;
  185. display: flex;
  186. justify-content: center;
  187. }
  188. }
  189. }
  190. .type::after,
  191. .state::after {
  192. z-index: -1;
  193. content: "";
  194. position: absolute;
  195. right: 30%;
  196. top: 20%;
  197. width: 0;
  198. height: 0;
  199. border-top: 15rpx solid rgb(173, 173, 173);
  200. border-left: 15rpx solid transparent;
  201. border-right: 15rpx solid transparent;
  202. }
  203. }
  204. .actives {
  205. margin-top: 50rpx;
  206. padding: 0 40rpx;
  207. display: flex;
  208. flex-direction: column;
  209. .actives-item {
  210. height: 150rpx;
  211. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  212. border-radius: 32rpx;
  213. margin-top: 20px;
  214. padding: 50rpx;
  215. display: flex;
  216. flex-direction: column;
  217. .active-content {
  218. display: flex;
  219. .img-box {
  220. margin-right: 20rpx;
  221. width: 120rpx;
  222. height: 120rpx;
  223. img {
  224. width: 100%;
  225. height: 100%;
  226. }
  227. }
  228. .right {
  229. height: 120rpx;
  230. box-sizing: border-box;
  231. display: flex;
  232. flex-direction: column;
  233. .right-title {
  234. margin-bottom: 20rpx;
  235. font-size: 27rpx;
  236. font-weight: 600;
  237. letter-spacing: 3rpx;
  238. }
  239. .right-inf {
  240. display: flex;
  241. font-size: 22rpx;
  242. color: $uni-text-color-grey;
  243. .inf-type {
  244. margin-right: 20rpx;
  245. display: flex;
  246. align-items: center;
  247. .originColor {
  248. margin-right: 8rpx;
  249. height: 25rpx;
  250. width: 25rpx;
  251. border-radius: 50%;
  252. background-color: #ffcf86;
  253. }
  254. }
  255. .inf-way {
  256. margin-right: 20rpx;
  257. }
  258. }
  259. }
  260. }
  261. .readShare {
  262. display: flex;
  263. justify-content: flex-end;
  264. font-size: 20rpx;
  265. color: rgba(0, 0, 0, 0.3);
  266. margin-top: 20rpx;
  267. .read {
  268. margin-right: 60rpx;
  269. }
  270. }
  271. }
  272. }
  273. }
  274. .active {
  275. color: $uni-color-primary;
  276. }
  277. .color {
  278. background-color: #589cff !important;
  279. }
  280. </style>