index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="content">
  3. <view class="header">
  4. <image src="/static/attract/u2043.png" alt="" class="header-image" />
  5. </view>
  6. <view class="attracts">
  7. <view class="activity-theme">活动主题</view>
  8. <view
  9. class="notice-content-box"
  10. v-for="(item, index) in attractList"
  11. :key="index"
  12. style="justify-content: start"
  13. @click="goAttractDeatil(item.id, item.time_type)"
  14. :class="{ unclick: item.time_type == 0 }"
  15. >
  16. <image
  17. :src="item.pic_url"
  18. mode="aspectFill"
  19. style="
  20. width: 112rpx;
  21. height: 112rpx;
  22. margin-right: 20rpx;
  23. border-radius: 10rpx;
  24. "
  25. ></image>
  26. <view class="notice-content" style="width: 75%">
  27. <view class="notice-content-font">{{ item.title }}</view>
  28. <view class="attract-content">{{ item.desc }}</view>
  29. <view
  30. class="notice-content-time"
  31. style="margin-top: 20rpx"
  32. v-if="item.time_type == 1"
  33. >时间:{{ item.time | globalTime }}</view
  34. >
  35. <view class="notice-content-time" style="margin-top: 20rpx" v-else
  36. >时间:待定</view
  37. >
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import md5 from "@/common/md5.js";
  45. export default {
  46. data() {
  47. return {
  48. attractList: [
  49. // {
  50. // url: "/static/attract/1.png",
  51. // title: "工业互联网",
  52. // subtitle: "工业互联网是全球工业系统与高级计算、分析、...",
  53. // time: "2021-09-05",
  54. // },
  55. // {
  56. // url: "/static/attract/2.png",
  57. // title: "生产性服务业",
  58. // subtitle: "生产性服务业是指为保持工业生产过程的连续性...",
  59. // time: "2021-09-05",
  60. // },
  61. ],
  62. };
  63. },
  64. onLoad() {
  65. this.getAttract();
  66. },
  67. methods: {
  68. goAttractDeatil(id, type) {
  69. if (type == 0) return;
  70. uni.navigateTo({
  71. url: "/pages/attract/attract_deatil?id=" + id,
  72. });
  73. },
  74. getAttract() {
  75. let md5Sign = md5(
  76. "method=" +
  77. "common" +
  78. "&timestamp=" +
  79. getApp().globalData.globalTimestamp +
  80. "&secret=" +
  81. getApp().globalData.secret
  82. );
  83. let url =
  84. getApp().globalData.shareUrl +
  85. "api/api.php" +
  86. "?method=common&source=business&action=list&timestamp=" +
  87. getApp().globalData.globalTimestamp +
  88. "&sign=" +
  89. md5Sign;
  90. let postData = {
  91. // page: 1,
  92. // page_size: 5,
  93. };
  94. uni.request({
  95. url: url,
  96. method: "POST",
  97. header: {
  98. "content-type": "application/x-www-form-urlencoded",
  99. },
  100. data: postData,
  101. success: (res) => {
  102. if (res.data.code === 200) {
  103. console.log(res.data.data.list);
  104. res.data.data.list.forEach((item) => {
  105. item.pic_url = getApp().globalData.shareUrl + item.pic_url;
  106. });
  107. this.attractList = res.data.data.list;
  108. }
  109. },
  110. fail: () => {
  111. console.log("连接失败");
  112. },
  113. });
  114. },
  115. },
  116. };
  117. </script>
  118. <style lang="scss" scoped>
  119. .unclick {
  120. background-color: #bfbfbf !important;
  121. }
  122. .content {
  123. box-sizing: border-box;
  124. display: flex;
  125. flex-direction: column;
  126. .header {
  127. .header-image {
  128. width: 100%;
  129. height: 350rpx;
  130. }
  131. }
  132. .attracts {
  133. display: flex;
  134. box-sizing: border-box;
  135. // justify-content: center;
  136. padding: 80rpx;
  137. padding-top: 30rpx;
  138. align-items: center;
  139. flex-direction: column;
  140. .activity-theme {
  141. font-size: 28rpx;
  142. font-weight: 600;
  143. border-left: 10rpx solid #02a7f0;
  144. padding-left: 20rpx;
  145. width: 100%;
  146. justify-items: start;
  147. margin-bottom: 10rpx;
  148. }
  149. .notice-content-box {
  150. width: 100%;
  151. display: flex;
  152. padding: 30rpx;
  153. background-color: #ffffff;
  154. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  155. border-radius: 32rpx;
  156. margin-top: 20rpx;
  157. justify-content: space-between;
  158. .notice-content-font {
  159. font-size: 26rpx;
  160. color: #0d1937;
  161. font-weight: 600;
  162. overflow: hidden;
  163. text-overflow: ellipsis;
  164. white-space: nowrap;
  165. }
  166. .attract-content {
  167. color: #697594;
  168. font-weight: 600;
  169. font-size: 20rpx;
  170. margin-top: 8rpx;
  171. overflow: hidden;
  172. text-overflow: ellipsis;
  173. white-space: nowrap;
  174. }
  175. .notice-content-time {
  176. font-size: 18rpx;
  177. letter-spacing: 0.02em;
  178. color: #cfcfcf;
  179. margin-right: 14rpx;
  180. }
  181. }
  182. }
  183. }
  184. </style>