index.vue 4.6 KB

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