You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

moreHighMsg.vue 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <div class="content">
  3. <div class="item" v-for="(item,index) in state.highMsgData" :key='index' @click="link(item)">
  4. <div class="left-content">
  5. <div class="description">{{item.title}}</div>
  6. <div class="mark">{{item.copywriting}}</div>
  7. </div>
  8. <image :src="fileURLList + item.imgUrl"></image>
  9. </div>
  10. <view style="text-align: center;margin: 20rpx;" v-if="state.flags">我是有底线的</view>
  11. </div>
  12. </template>
  13. <script setup lang="ts">
  14. import { fileURL, fileURLList } from "@/datas/fileURL.js";
  15. import {onLoad, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
  16. import { queryHighMsg } from "@/utils/network/api.js";
  17. import { reactive } from "vue";
  18. import { requestNew } from "@/utils/network/request.js";
  19. import { navTo } from "@/utils/utils";
  20. import { getCodeName } from "@/datas/queryKey.js";
  21. const state = reactive({
  22. highMsgData: [],
  23. flags: false,
  24. page: 1,
  25. })
  26. onLoad(() => {
  27. highMsg(); //高速快讯
  28. })
  29. // 下拉刷新
  30. onPullDownRefresh(() => {
  31. state.page = 1
  32. state.highMsgData = []
  33. state.flags = false
  34. console.log('refresh');
  35. setTimeout(() => {
  36. highMsg()
  37. uni.stopPullDownRefresh()
  38. }, 500);
  39. })
  40. // 触底加载
  41. onReachBottom(() => {
  42. if (state.highMsgData.length < state.page * 8) return state.flags = true
  43. console.log("触底了")
  44. state.page++
  45. highMsg()
  46. })
  47. // 高速快讯查询接口
  48. const highMsg = () => {
  49. let options = {
  50. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  51. data: {
  52. pageNo: state.page,
  53. pageSize: 8
  54. }, //请求参数
  55. method: "POST", //提交方式(默认POST)
  56. showLoading: true, //是否显示加载中(默认显示)
  57. };
  58. //调用方式
  59. requestNew(queryHighMsg, options).then((res) => {
  60. console.log("高速快讯查询接口", res.data);
  61. state.highMsgData = [...res.result, ...state.highMsgData]
  62. console.log("state.highMsgData", state.highMsgData)
  63. for (var i = 0; i < state.highMsgData.length; i++) {
  64. state.highMsgData[i]["copywriting"] = getCodeName('COPYWRITING', state.highMsgData[i]["copywriting"])
  65. }
  66. state.highMsgData.sort(function (a, b) {
  67. return a.sequence - b.sequence//正序
  68. })
  69. })
  70. .catch((err) => {
  71. });
  72. }
  73. const link = (item) => {
  74. if (item.type == 1) {
  75. const params = encodeURIComponent(JSON.stringify(item.hyperLink))
  76. uni.navigateTo({
  77. url: `/subpackage/personal-center/webview?url=` + params
  78. })
  79. } else if (item.type == 2) {
  80. navTo(item.hyperLink)
  81. } else if (item.type == 3) {
  82. const items = encodeURIComponent(JSON.stringify(item))
  83. uni.navigateTo({
  84. url: `/subpackage/orders/moreHighMsg/textDetails?item=`+items
  85. })
  86. } else if (item.type == 4) {
  87. uni.navigateToMiniProgram({
  88. appId: item.hyperLink,
  89. path: item.speedUrl,
  90. success(res) {
  91. console.log(res);
  92. },
  93. complete(res) {
  94. console.log(res);
  95. },
  96. fail(res) {
  97. console.log(res);
  98. // 未成功跳转到车主小程序
  99. },
  100. });
  101. }
  102. }
  103. </script>
  104. <style scoped>
  105. .content {
  106. background-color: #eef7f7;
  107. overflow: hidden;
  108. min-height: 100vh;
  109. }
  110. .item {
  111. width: 95%;
  112. margin: 0 auto;
  113. margin-top: 30rpx;
  114. background-color: white;
  115. display: flex;
  116. padding: 20rpx 30rpx;
  117. box-sizing: border-box;
  118. justify-content: space-between;
  119. border-radius: 14rpx;
  120. font-size: 30rpx;
  121. }
  122. .item>image {
  123. width: 100rpx;
  124. height: 100rpx;
  125. border-radius: 10rpx;
  126. }
  127. .mark {
  128. font-size: 22rpx;
  129. display: inline-block;
  130. text-align: center;
  131. background: #bae0f1;
  132. border-radius: 6rpx;
  133. color: #0a8f8a;
  134. padding: 4rpx 8rpx;
  135. margin-top: 16rpx;
  136. }
  137. .left-content {
  138. width: 70%;
  139. }
  140. .description {
  141. overflow: hidden;
  142. -webkit-line-clamp: 2;
  143. text-overflow: ellipsis;
  144. display: -webkit-box;
  145. -webkit-box-orient: vertical;
  146. }
  147. </style>