金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

240 lines
5.4 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view>
  3. <lf-nav :showIcon="true" bgColor="transparent" :spreadOut="false"></lf-nav>
  4. <view class="head">
  5. <image class="img" mode="aspectFill" :src="activity_content.topic.image"></image>
  6. <view class="title">{{activity_content.topic.name}}</view>
  7. </view>
  8. <scroll-view :style="{height: autoHeight}" :scroll-y="true" :refresher-enabled="true"
  9. :refresher-triggered="isRefresher" @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
  10. <view class="content">
  11. <view class="card" v-for="(item, index) in list" :key="index" @click="$url('/pages/shop/goodsdetail?id='+ item.goods.id)">
  12. <view class="goods-img">
  13. <image class="img" :src="item.goods.img"></image>
  14. <!-- <view class="ranking">
  15. <view class="top">{{ item+1 }}</view>
  16. <view class="down"></view>
  17. </view> -->
  18. </view>
  19. <view class="goods-info">
  20. <view>
  21. <view class="lf-line-2 title">{{item.goods.name}}</view>
  22. <view class="desc">月销量{{item.goods.sale_count}}</view>
  23. </view>
  24. <view class="lf-row-between">
  25. <view class="price">
  26. <text>¥{{item.goods.sell_price}}</text>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <!-- 空数据的情况 -->
  32. <view class="loading-more">
  33. <text v-if="list.length != 0" :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
  34. <lf-nocontent src="/static/images/empty.png" v-else></lf-nocontent>
  35. </view>
  36. </view>
  37. </scroll-view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data(){
  43. return {
  44. page: 1,
  45. topic_id: 1,
  46. activity_content: '',
  47. list: [],
  48. isPage: true,
  49. loadingClass: true,
  50. loadingText: '正在加载中',
  51. scrollH: 0,
  52. nav_height: 0,
  53. isRefresher: true,
  54. }
  55. },
  56. onLoad(){
  57. let info = uni.getSystemInfoSync();
  58. this.scrollH = info.screenHeight;
  59. this.getActivityList();
  60. },
  61. computed: {
  62. autoHeight() {
  63. return `calc(${this.scrollH}px - ${this.nav_height}px - 430rpx)`;
  64. }
  65. },
  66. methods: {
  67. // 页面触底,加载下一页
  68. onScrolltolower() {
  69. if (this.isPage) {
  70. this.page = this.page + 1;
  71. this.getActivityList();
  72. }
  73. },
  74. // 下拉刷新处理
  75. refreshFn(options) {
  76. this.page = 1;
  77. this.isPage = true;
  78. this.loadingClass = true;
  79. this.list = []
  80. this.loadingText = '正在加载中';
  81. this.getActivityList(options);
  82. },
  83. // scroll-view 下拉刷新
  84. onRefresherrefresh() {
  85. this.isRefresher = true;
  86. this.refreshFn({
  87. type: 'scrollRefresh'
  88. });
  89. },
  90. getActivityList(options = {}){
  91. this.$http.get({
  92. api: 'api/topic/list',
  93. data: {
  94. topic_id: this.topic_id,
  95. page: this.page
  96. },
  97. header: {
  98. Authorization: this.$cookieStorage.get('user_token')
  99. }
  100. }).then(res => {
  101. this.activity_content = res.data.data
  102. console.log('====',res.data.data)
  103. let isPage = this.page < res.data.data.goods.total ? true : false;
  104. this.isPage = isPage;
  105. if (!isPage) {
  106. this.loadingClass = false;
  107. this.loadingText = '没有更多数据啦~';
  108. }
  109. if (options.type == 'pageRefresh') {
  110. uni.stopPullDownRefresh();
  111. } else if (options.type == 'scrollRefresh') {
  112. this.isRefresher = false;
  113. }
  114. if (this.page == 1) {
  115. this.list = res.data.data.goods.data;
  116. } else {
  117. this.list.push(...res.data.data.goods.data);
  118. }
  119. })
  120. },
  121. }
  122. }
  123. </script>
  124. <style>
  125. page{
  126. background-color: #F8F8F8;
  127. }
  128. </style>
  129. <style lang="scss" scoped="scoped">
  130. .head{
  131. width: 750rpx;
  132. height: 430rpx;
  133. position: relative;
  134. .img{
  135. width: 100%;
  136. height: 100%;
  137. }
  138. .title{
  139. position: absolute;
  140. left: 0;
  141. top: 0;
  142. width: 100%;
  143. height: 100%;
  144. display: flex;
  145. justify-content: center;
  146. align-items: center;
  147. font-size: 60rpx;
  148. color: #FFFFFF;
  149. font-weight: bold;
  150. font-family: '楷体';
  151. }
  152. }
  153. .content{
  154. padding: 30rpx 32rpx;
  155. .card{
  156. width: 686rpx;
  157. height: 260rpx;
  158. background: #FFFFFF;
  159. border-radius: 20rpx;
  160. box-sizing: border-box;
  161. padding: 30rpx;
  162. display: flex;
  163. &:nth-child(n+2){
  164. margin-top: 30rpx;
  165. }
  166. .goods-img{
  167. width: 200rpx;
  168. height: 200rpx;
  169. border-radius: 10rpx;
  170. overflow: hidden;
  171. position: relative;
  172. margin-right: 15rpx;
  173. .img{
  174. width: 100%;
  175. height: 100%;
  176. background-color: #EEEEEE;
  177. }
  178. .ranking{
  179. position: absolute;
  180. top: 0;
  181. left: 0;
  182. width: 36rpx;
  183. height: 56rpx;
  184. overflow: hidden;
  185. .top{
  186. width: 36rpx;
  187. height: 36rpx;
  188. background-color: #15716E;
  189. position: relative;
  190. z-index: 3;
  191. text-align: center;
  192. color: #FFFFFF;
  193. font-size: 28rpx;
  194. }
  195. .down{
  196. width: 36rpx;
  197. height: 36rpx;
  198. background-color: #15716E;
  199. transform: rotate(45deg);
  200. margin-top: -26rpx;
  201. position: relative;
  202. z-index: 1;
  203. }
  204. }
  205. }
  206. .goods-info{
  207. width: 410rpx;
  208. height: 200rpx;
  209. display: flex;
  210. flex-direction: column;
  211. justify-content: space-between;
  212. .title{
  213. font-size: 28rpx;
  214. color: #222222;
  215. }
  216. .desc{
  217. width: max-content;
  218. height: 35rpx;
  219. border-radius: 18rpx;
  220. background-color: #E9F2F2;
  221. font-size: 24rpx;
  222. color: #15716E;
  223. display: flex;
  224. justify-content: center;
  225. align-items: center;
  226. margin-top: 10rpx;
  227. padding: 0 10rpx;
  228. }
  229. .price>text:nth-child(1){
  230. font-size: 32rpx;
  231. color: #222222;
  232. font-weight: bold;
  233. }
  234. }
  235. }
  236. }
  237. </style>