SsCommonProblem.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="problem hover-scale">
  3. <view class="problem-content">
  4. <view class="header">
  5. <image class="header-logo" :src="getStaticImageUrl('/images/common_problem.png')" fit="contain" />
  6. <view class="header-content">
  7. <view class="header-title">常见问题</view>
  8. <view class="header-subject">聚焦商贸投资热点,回应企业民生关切</view>
  9. <button class="refresh" @tap="refresh">
  10. <view v-if="loading" class="refresh-loading">
  11. <uni-icons type="spinner-cycle" size="28rpx" color="#ffef7c" />
  12. </view>
  13. <uni-icons v-else type="refreshempty" size="24rpx" color="#ffef7c" />
  14. 换一换
  15. </button>
  16. </view>
  17. </view>
  18. <view class="problem-list">
  19. <view class="problem-item" v-if="problems" v-for="(item, index) in problems" @tap="quickSend(item.questionContent)">{{ index + 1 }}.{{ item.questionContent }}</view>
  20. </view>
  21. </view>
  22. <image class="problem-image" fit="contain" :src="getStaticImageUrl('/images/bg011.png')" />
  23. </view>
  24. </template>
  25. <script>
  26. import { RequestApi } from '@/api/requestApi';
  27. export default {
  28. data() {
  29. return {
  30. loading: false,
  31. problems: [],
  32. search: {
  33. keyword: '',
  34. page: 1,
  35. size: 6
  36. }
  37. };
  38. },
  39. mounted() {
  40. this.getCommonQuestions();
  41. },
  42. methods: {
  43. getCommonQuestions() {
  44. this.loading = true;
  45. RequestApi.getCommonQuestionsRandom(this.search.keyword, this.search.page, this.search.size)
  46. .then((result) => {
  47. this.problems = result.records;
  48. })
  49. .finally(() => {
  50. this.loading = false;
  51. });
  52. },
  53. refresh() {
  54. this.getCommonQuestions();
  55. },
  56. quickSend(msg) {
  57. this.$emit('quickSend', msg)
  58. }
  59. }
  60. };
  61. </script>
  62. <style scoped lang="scss">
  63. @keyframes spin {
  64. 0% {
  65. transform: rotate(0deg);
  66. }
  67. 100% {
  68. transform: rotate(360deg);
  69. }
  70. }
  71. .problem {
  72. border-radius: 40rpx;
  73. position: relative;
  74. overflow: hidden;
  75. color: #ffffff;
  76. background: linear-gradient(180deg, #5a92f8, #2943d6);
  77. box-shadow: 0 8rpx 40rpx 0 rgba(52, 149, 239, 0.4);
  78. margin-bottom: 32rpx;
  79. .problem-content {
  80. position: relative;
  81. z-index: 2;
  82. padding: 48rpx 40rpx;
  83. .header {
  84. display: flex;
  85. align-items: center;
  86. margin-bottom: 48rpx;
  87. .header-logo {
  88. width: 68rpx;
  89. height: 68rpx;
  90. margin-right: 16rpx;
  91. }
  92. .header-content {
  93. width: calc(100% - 85rpx);
  94. position: relative;
  95. .header-title {
  96. font-size: 32rpx;
  97. font-weight: bold;
  98. margin-bottom: 10rpx;
  99. line-height: 28rpx;
  100. cursor: pointer;
  101. }
  102. .header-subject {
  103. font-size: 26rpx;
  104. font-weight: 400;
  105. line-height: 28rpx;
  106. cursor: pointer;
  107. }
  108. .refresh-loading {
  109. animation: spin 3s linear infinite;
  110. }
  111. .refresh {
  112. position: absolute;
  113. right: 0;
  114. top: 0;
  115. padding: 0;
  116. line-height: 24rpx;
  117. font-size: 24rpx;
  118. height: 24rpx;
  119. color: #ffef7c;
  120. background-color: transparent;
  121. border: 0;
  122. border-radius: 0;
  123. display: flex;
  124. align-items: center;
  125. .refresh-icon {
  126. }
  127. &:after,
  128. &::after {
  129. border: 0;
  130. }
  131. }
  132. }
  133. }
  134. .problem-list {
  135. .problem-item {
  136. font-size: 26rpx;
  137. line-height: 26rpx;
  138. margin-bottom: 24rpx;
  139. cursor: pointer;
  140. white-space: nowrap; /* 强制文本不换行 */
  141. overflow: hidden; /* 隐藏超出容器的内容 */
  142. text-overflow: ellipsis; /* 超出部分显示省略号 */
  143. &:last-child {
  144. margin-bottom: 0;
  145. }
  146. }
  147. }
  148. }
  149. .problem-image {
  150. position: absolute;
  151. width: 254rpx;
  152. height: 250rpx;
  153. bottom: 32rpx;
  154. right: 24rpx;
  155. z-index: 1;
  156. background-size: contain;
  157. }
  158. }
  159. </style>