index.vue 5.0 KB

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