list.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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. }
  156. .leftView {
  157. width: 30%;
  158. }
  159. .rightView {
  160. width: 30%;
  161. display: flex;
  162. justify-content: flex-end;
  163. padding-right: 24rpx;
  164. }
  165. .rightImg {
  166. width: 40rpx;
  167. height: 40rpx;
  168. }
  169. .commend {
  170. position: fixed;
  171. left: 0;
  172. top: 90rpx;
  173. width: calc(100vw - 50rpx);
  174. background-color: #FFFFFF;
  175. padding: 0 25rpx 30rpx;
  176. z-index: 999;
  177. height: 140rpx;
  178. }
  179. .top {
  180. background-color: #FFFFFF;
  181. padding: 40rpx 74rpx;
  182. color: #999999;
  183. font-size: 24rpx;
  184. text-align: center;
  185. }
  186. .itemBg {
  187. background-color: #FFFFFF;
  188. padding: 0 24rpx;
  189. }
  190. .twoItem {
  191. display: flex;
  192. background-color: #FFFFFF;
  193. padding: 30rpx 0;
  194. }
  195. .line {
  196. border-top: #eeeeee 2rpx solid;
  197. }
  198. .title {
  199. font-size: 28rpx;
  200. font-weight: bold;
  201. color: #3c3c3c;
  202. /* 隐藏文字显示 ...不换行 */
  203. overflow: hidden;
  204. text-overflow: ellipsis;
  205. white-space: nowrap;
  206. }
  207. .title2 {
  208. font-size: 24rpx;
  209. color: #999999;
  210. //超过固定行数 隐藏
  211. display: -webkit-box;
  212. overflow: hidden;
  213. text-overflow: ellipsis;
  214. word-wrap: break-word;
  215. white-space: normal !important;
  216. -webkit-line-clamp: 3;
  217. -webkit-box-orient: vertical;
  218. margin: 14rpx 0;
  219. }
  220. .img2 {
  221. width: 240rpx;
  222. height: 135rpx;
  223. border-radius: 10rpx;
  224. }
  225. .rightItem {
  226. margin-left: 30rpx;
  227. width: calc(100vw - 300rpx);
  228. }
  229. .noMore {
  230. text-align: center;
  231. line-height: 50rpx;
  232. color: #999999;
  233. font-size: 28rpx;
  234. }
  235. .gotopImg{
  236. width: 100rpx;
  237. height: 100rpx;
  238. }
  239. .gotop{
  240. position: fixed;
  241. right: 15rpx;
  242. bottom: 100rpx;
  243. cursor: pointer;
  244. }
  245. </style>