index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view class="app-page">
  3. <view class="good-list">
  4. <template v-for="(item,index) in mList">
  5. <view class="good-item" @click="toDetails(item.code)">
  6. <u--image width='120rpx' height='120rpx' radius="10rpx" mode="widthFix" :src="item.cover"
  7. :fade="true" duration="450" customStyle="margin-top:32rpx;margin-bottom:32rpx;" />
  8. <view class="good-item-content">
  9. <view class="good-name-box">
  10. <!-- <image mode="heightFix" :src="`${$getImgBaseUrl()}tiktok-log.png`"></image> -->
  11. <text>{{item.name}}</text>
  12. </view>
  13. <text class="good-desc">{{item.remark}}</text>
  14. <view class="good-bottom">
  15. <text class="good-time">{{item.create_at}}</text>
  16. <view class="good-view-box">
  17. <image :src="`${$getImgBaseUrl()}ic-view.png`" mode="heightFix"></image>
  18. <text>{{item.num_read}}</text>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <u-line :color="index !== mList.length - 1 ? '#E9E9E9' : '#00000000'" length="calc(100%)"
  24. customStyle="margin-bottom:4rpx;"></u-line>
  25. </template>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. getNews,
  32. } from "@/common/api/common.js";
  33. export default {
  34. data() {
  35. return {
  36. page: 1,
  37. mList: []
  38. }
  39. },
  40. computed: {
  41. searchData() {
  42. return {
  43. limit: 20,
  44. page: this.page,
  45. mark: '帮助中心'
  46. }
  47. }
  48. },
  49. onLoad(options) {},
  50. onReady() {
  51. uni.startPullDownRefresh({
  52. })
  53. },
  54. onPullDownRefresh() {
  55. this.page = 1;
  56. uni.stopPullDownRefresh()
  57. this.mList = []
  58. this.getNews();
  59. },
  60. onReachBottom() {
  61. this.page++;
  62. this.getNews()
  63. },
  64. methods: {
  65. toDetails(code) {
  66. uni.navigateTo({
  67. url: '/subPages/helpDetails/index?code=' + code
  68. })
  69. },
  70. getNews() {
  71. uni.showLoading({
  72. })
  73. const data = this.searchData;
  74. getNews(data)
  75. .then((res) => {
  76. uni.hideLoading();
  77. console.log("getNews==>", res.data)
  78. if (res.data) {
  79. if (this.page === 1) {
  80. this.mList = res.data.list;
  81. } else {
  82. this.mList = this.mList.concat(res.data.list);
  83. }
  84. } else {
  85. if (this.page != 1) {
  86. this.page;
  87. } else {
  88. this.mList = []
  89. }
  90. }
  91. })
  92. .catch(() => {
  93. if (this.page != 1) {
  94. this.page--;
  95. }
  96. uni.hideLoading();
  97. });
  98. },
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .app-page {
  104. width: 100%;
  105. display: flex;
  106. align-items: center;
  107. flex-direction: column;
  108. }
  109. .good-list {
  110. background: white;
  111. display: flex;
  112. flex-basis: 0;
  113. flex-direction: column;
  114. width: 100%;
  115. align-items: center;
  116. }
  117. .good-item {
  118. width: calc(100% - 40rpx);
  119. display: flex;
  120. flex-direction: row;
  121. }
  122. .good-item-content {
  123. flex: 1;
  124. margin-left: 20rpx;
  125. display: flex;
  126. flex-direction: column;
  127. justify-content: space-between;
  128. }
  129. .good-name-box {
  130. display: flex;
  131. margin-top: 28rpx;
  132. flex-direction: row;
  133. align-items: center;
  134. image {
  135. width: 30rpx;
  136. height: 30rpx;
  137. display: block;
  138. }
  139. text {
  140. font-size: 32rpx;
  141. font-family: PingFang SC-Bold, PingFang SC;
  142. font-weight: bold;
  143. color: #1D161F;
  144. // margin-left: 10rpx;
  145. overflow: hidden;
  146. text-overflow: ellipsis;
  147. -webkit-line-clamp: 1;
  148. display: -webkit-box;
  149. -webkit-box-orient: vertical;
  150. }
  151. }
  152. .good-desc {
  153. font-size: 22rpx;
  154. font-family: PingFang SC-Medium, PingFang SC;
  155. font-weight: 500;
  156. color: #2C2C2C;
  157. margin-top: 8rpx;
  158. }
  159. .good-bottom {
  160. display: flex;
  161. flex-direction: row;
  162. align-items: center;
  163. margin-bottom: 30rpx;
  164. justify-content: space-between;
  165. .good-time {
  166. font-size: 22rpx;
  167. font-family: PingFang SC-Medium, PingFang SC;
  168. font-weight: 500;
  169. color: #B7B7B7;
  170. }
  171. .good-view-box {
  172. display: flex;
  173. flex-direction: row;
  174. align-items: center;
  175. image {
  176. height: 16rpx;
  177. width: 22rpx;
  178. display: block;
  179. }
  180. text {
  181. font-size: 22rpx;
  182. font-family: PingFang SC-Medium, PingFang SC;
  183. font-weight: 500;
  184. color: #B7B7B7;
  185. margin-left: 6rpx;
  186. }
  187. }
  188. }
  189. </style>