list.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <view class="content">
  3. <!-- 导航 -->
  4. <view class="nav">
  5. <view class="leftView" @click="back">
  6. <image src="../../static/mobile/backBtn.png" mode=""
  7. style="width: 22rpx; height: 40rpx; padding-left: 24rpx;"></image>
  8. </view>
  9. <view class="navTitle">{{topName}}</view>
  10. <view class="rightView">
  11. <image src="../../static/mobile/icon_search@2x.png" mode="" class="rightImg" style="margin-left: 40rpx;"
  12. @click="goSearch"></image>
  13. </view>
  14. </view>
  15. <!-- content -->
  16. <view class="top" v-if="comment.length != 0">{{comment}}</view>
  17. <!-- item -->
  18. <view class="itemBg">
  19. <view v-for="(item,index) in itemArr" :key="index" class="twoItem" :class="{line:index>0}" @click="goDetail(item)">
  20. <image :src="item.LogoImg" mode="" class="img2"></image>
  21. <view class="rightItem">
  22. <view class="title">{{item.Title}}</view>
  23. <view class="title2">{{item.Comment}}</view>
  24. </view>
  25. </view>
  26. </view>
  27. <!-- 上拉 加载更多 -->
  28. <view class="noMore" v-if="noMoreShow">没有更多数据</view>
  29. <!-- 无数据空白页 -->
  30. <nodata v-if="itemArr.length==0"></nodata>
  31. <view class="gotop" @click="gotoTop">
  32. <image src="../../static/pcimg/btn_top@2x.png" mode="" class="gotopImg"></image>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import nodata from '../../components/nodata/nodata.vue'
  38. export default {
  39. components: {
  40. nodata,
  41. },
  42. data() {
  43. return {
  44. topName: '',
  45. topCode: '',
  46. comment: '',
  47. page: 1,
  48. itemArr: [],
  49. noMoreShow: false,
  50. }
  51. },
  52. onLoad(opt) {
  53. console.log('opt', opt);
  54. this.topName = opt.topName
  55. this.topCode = opt.topCode
  56. this.comment = opt.comment
  57. this.page = 1
  58. this.getItemData()
  59. // uni.setNavigationBarTitle({
  60. // title: this.topName
  61. // })
  62. },
  63. methods: {
  64. gotoTop(){
  65. uni.pageScrollTo({
  66.       scrollTop: 0, duration: 300
  67.     });
  68. },
  69. goDetail(item){
  70. uni.navigateTo({
  71. url:'detail?id=' + item.ID
  72. })
  73. },
  74. getItemData() {
  75. uni.showLoading({
  76. title: '加载中'
  77. })
  78. let url = 'trainingOpenApiV2/groupPageData',
  79. params = {
  80. page: this.page,
  81. limit: 10,
  82. parentCode: this.topCode,
  83. }
  84. this.$http(url, params, 'GET').then(res => {
  85. uni.hideLoading();
  86. var data = res.data
  87. // 处理 undefined和null转为空白字符串
  88. for (const key in data) {
  89. data[key] = this.$praseStrEmpty(data[key])
  90. }
  91. if (this.page == 1) {
  92. this.itemArr = data.Items
  93. } else {
  94. this.itemArr = this.itemArr.concat(data.Items)
  95. }
  96. if (data.Items.length < 10) {
  97. this.noMoreShow = true
  98. } else {
  99. this.noMoreShow = false
  100. }
  101. if (this.itemArr.length == 0) {
  102. this.noMoreShow = false
  103. }
  104. })
  105. },
  106. goSearch() {
  107. uni.navigateTo({
  108. url: 'search'
  109. })
  110. },
  111. back() {
  112. uni.navigateBack({
  113. })
  114. },
  115. // 下拉刷新 上拉加载更多
  116. onPullDownRefresh() {
  117. this.page = 1;
  118. this.getItemData()
  119. // this.getDetailData()
  120. setTimeout(function() {
  121. uni.stopPullDownRefresh();
  122. }, 1000);
  123. },
  124. onReachBottom() {
  125. this.page++;
  126. this.getItemData()
  127. }
  128. }
  129. }
  130. </script>
  131. <style scoped>
  132. .content {
  133. min-height: 100vh;
  134. background-color: #FFFFFF;
  135. padding-top: 88rpx;
  136. padding-bottom: 20rpx;
  137. }
  138. .nav {
  139. position: fixed;
  140. left: 0;
  141. top: 0;
  142. width: 100vw;
  143. height: 88rpx;
  144. background-color: #FFFFFF;
  145. display: flex;
  146. justify-content: space-between;
  147. align-items: center;
  148. z-index: 999;
  149. border-bottom: #eeeeee 2rpx solid;
  150. }
  151. .navTitle {
  152. font-size: 36rpx;
  153. font-weight: bold;
  154. color: #3c3c3c;
  155. overflow: hidden;
  156. text-overflow: ellipsis;
  157. white-space: nowrap;
  158. width: 600rpx;
  159. text-align: center;
  160. line-height: 44rpx;
  161. }
  162. .leftView {
  163. /* width: 30%; */
  164. width: 80rpx;
  165. }
  166. .rightView {
  167. /* width: 30%; */
  168. width: 80rpx;
  169. display: flex;
  170. justify-content: flex-end;
  171. padding-right: 24rpx;
  172. }
  173. .rightImg {
  174. width: 40rpx;
  175. height: 40rpx;
  176. }
  177. .commend {
  178. position: fixed;
  179. left: 0;
  180. top: 90rpx;
  181. width: calc(100vw - 50rpx);
  182. background-color: #FFFFFF;
  183. padding: 0 25rpx 30rpx;
  184. z-index: 999;
  185. height: 140rpx;
  186. }
  187. .top {
  188. background-color: #FFFFFF;
  189. padding: 40rpx 74rpx;
  190. color: #999999;
  191. font-size: 24rpx;
  192. text-align: center;
  193. }
  194. .itemBg {
  195. background-color: #FFFFFF;
  196. padding: 0 24rpx;
  197. }
  198. .twoItem {
  199. display: flex;
  200. background-color: #FFFFFF;
  201. padding: 30rpx 0;
  202. }
  203. .line {
  204. border-top: #eeeeee 2rpx solid;
  205. }
  206. .title {
  207. font-size: 28rpx;
  208. font-weight: bold;
  209. color: #3c3c3c;
  210. /* 隐藏文字显示 ...不换行 */
  211. overflow: hidden;
  212. text-overflow: ellipsis;
  213. white-space: nowrap;
  214. }
  215. .title2 {
  216. font-size: 24rpx;
  217. color: #999999;
  218. //超过固定行数 隐藏
  219. display: -webkit-box;
  220. overflow: hidden;
  221. text-overflow: ellipsis;
  222. word-wrap: break-word;
  223. white-space: normal !important;
  224. -webkit-line-clamp: 3;
  225. -webkit-box-orient: vertical;
  226. margin: 14rpx 0;
  227. }
  228. .img2 {
  229. width: 240rpx;
  230. height: 135rpx;
  231. border-radius: 10rpx;
  232. }
  233. .rightItem {
  234. margin-left: 30rpx;
  235. width: calc(100vw - 300rpx);
  236. }
  237. .noMore {
  238. text-align: center;
  239. line-height: 50rpx;
  240. color: #999999;
  241. font-size: 28rpx;
  242. }
  243. .gotopImg{
  244. width: 100rpx;
  245. height: 100rpx;
  246. }
  247. .gotop{
  248. position: fixed;
  249. right: 15rpx;
  250. bottom: 100rpx;
  251. cursor: pointer;
  252. }
  253. </style>