您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

moreHighMsg.vue 3.7KB

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