index.vue 4.2 KB

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