金诚优选前端代码
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.

341 lines
11 KiB

  1. <template>
  2. <view>
  3. <lf-nav :spreadOut="true" :showIcon="true" bgColor="#fff" title="收藏"></lf-nav>
  4. <view v-if="tab_list.length">
  5. <u-tabs :list="tab_list" active-color="#15716E" inactive-color='#777777' :is-scroll="true" :current="title_current" @change="titletabChange"></u-tabs>
  6. </view>
  7. <view v-if="title_current==0">
  8. <view class="lf-p-30 lf-flex" v-for="(item,index) of tab_list[title_current].list" :key="index">
  9. <image class="collect-img" src="https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png" mode="aspectFill"></image>
  10. <view class="lf-flex-column lf-m-l-20" style="width: 480rpx;min-height: 160rpx;justify-content: space-between;">
  11. <view class="lf-font-36 lf-color-black lf-line-1">luckin coffee 瑞幸瑞幸咖啡瑞幸咖啡瑞幸咖啡瑞幸咖啡咖啡</view>
  12. <view class="lf-font-24 lf-color-777">餐饮·美食18件在售</view>
  13. <view class="lf-font-24 lf-color-777">
  14. <text class="lf-iconfont icon-dizhi lf-font-20 lf-color-primary"></text>
  15. <text class="lf-m-l-10">L2</text>
  16. </view>
  17. </view>
  18. <view class="lf-iconfont icon-shoucang lf-font-38" style="color: #FF9D9D;"></view>
  19. </view>
  20. <view class="loading-more">
  21. <text :class="{'loading-more-text': tab_list[title_current].loadingClass}" v-if="tab_list[title_current].list.length">{{ tab_list[title_current].loadingText }}</text>
  22. <lf-nocontent v-else></lf-nocontent>
  23. </view>
  24. </view>
  25. <view class="lf-p-b-30 lf-m-t-30" v-else>
  26. <lf-waterfall :list="tab_list[title_current].list" :ifsale="false" ref="uWaterfall"></lf-waterfall>
  27. <view class="loading-more">
  28. <text :class="{'loading-more-text': tab_list[title_current].loadingClass}" v-if="tab_list[title_current].list.length">{{ tab_list[title_current].loadingText }}</text>
  29. <lf-nocontent v-else></lf-nocontent>
  30. </view>
  31. </view>
  32. <u-back-top :scrollTop="pageScrollTop"></u-back-top>
  33. </view>
  34. </template>
  35. <script>
  36. import lfWaterfall from '@/components/lf-waterfall-shopdetails/lf-waterfall.vue';
  37. export default {
  38. data() {
  39. let _public = {
  40. page: 1,
  41. isPage: true,
  42. loadingClass: true,
  43. loadingText: '正在加载中'
  44. }
  45. return {
  46. tab_list: [
  47. {
  48. name:'品牌',
  49. type: 'jc_brand',
  50. ..._public
  51. },
  52. {
  53. name:'商品',
  54. type: 'jc_goods',
  55. ..._public
  56. }
  57. ],
  58. title_current:0,
  59. list: [
  60. {
  61. id: 10,
  62. original_price: "4111.00",
  63. picture: "https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png",
  64. pictures: ["https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png"],
  65. price: "2412.00",
  66. product_id: 1008,
  67. sale: 0,
  68. title: "三亚悦榕庄(Banyan Tree Sanya Resort and Spa)"
  69. },
  70. {
  71. id: 10,
  72. original_price: "4111.00",
  73. picture: "https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png",
  74. pictures: ["https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png"],
  75. price: "2412.00",
  76. product_id: 1008,
  77. sale: 0,
  78. title: "三亚悦榕庄(Banyan Tree Sanya Resort and Spa)"
  79. },
  80. {
  81. id: 10,
  82. original_price: "4111.00",
  83. picture: "https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png",
  84. pictures: ["https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png"],
  85. price: "2412.00",
  86. product_id: 1008,
  87. sale: 0,
  88. title: "三亚悦榕庄(Banyan Tree Sanya Resort and Spa)"
  89. },
  90. {
  91. id: 10,
  92. original_price: "4111.00",
  93. picture: "https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png",
  94. pictures: ["https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png"],
  95. price: "2412.00",
  96. product_id: 1008,
  97. sale: 0,
  98. title: "三亚悦榕庄(Banyan Tree Sanya Resort and Spa)"
  99. }
  100. ],
  101. show_count: 0,
  102. windowHeight: 0,
  103. scrollH: 0,
  104. nav_height: 0,
  105. isRefresher: true
  106. }
  107. },
  108. computed: {
  109. autoHeight(){
  110. return `calc(${this.scrollH}px - ${this.nav_height}px - 86rpx)`;
  111. }
  112. },
  113. components: {
  114. lfWaterfall
  115. },
  116. onShow(){
  117. let info = uni.getSystemInfoSync();
  118. this.scrollH = info.screenHeight;
  119. this.getData();
  120. },
  121. methods: {
  122. titletabChange(index){
  123. this.title_current = index;
  124. this.getData();
  125. },
  126. getData(options = {}) {
  127. let tab_item = this.tab_list[this.title_current];
  128. this.$http
  129. .get({
  130. api: 'api/collect',
  131. data: {
  132. type: tab_item.type
  133. },
  134. header: {
  135. Authorization: this.$cookieStorage.get('user_token')
  136. },
  137. })
  138. .then(res => {
  139. console.log(res.data)
  140. if (res.data.code == 200) {
  141. let isPage = res.data.data.next_page_url == null?false:true;
  142. tab_item.isPage = isPage;
  143. if(!isPage) {
  144. tab_item.loadingClass = false;
  145. tab_item.loadingText = '没有更多数据啦~';
  146. }
  147. if(options.type == 'pageRefresh') {
  148. uni.stopPullDownRefresh();
  149. }else if(options.type == 'scrollRefresh') {
  150. console.log('进入了')
  151. this.isRefresher = false;
  152. }
  153. if(tab_item.page == 1) {
  154. tab_item.list = res.data.data.data;
  155. }else {
  156. tab_item.list.push(...res.data.data.data);
  157. }
  158. console.log('当前列表数据',tab_item.list)
  159. } else {
  160. wx.showModal({
  161. content: '请下拉页面刷新重试',
  162. showCancel: false
  163. });
  164. }
  165. wx.hideLoading();
  166. })
  167. .catch(() => {
  168. wx.hideLoading();
  169. });
  170. },
  171. // 滑块下标值变化
  172. swiperChange(event){
  173. this.title_current = event.detail.current;
  174. if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  175. this.getData();
  176. },
  177. // 页面触底,加载下一页
  178. onScrolltolower(){
  179. let tab_item = this.tab_list[this.title_current];
  180. if(tab_item.isPage){
  181. tab_item.page = tab_item.page + 1;
  182. this.getData();
  183. }
  184. },
  185. // scroll-view 下拉刷新
  186. onRefresherrefresh(){
  187. this.$u.throttle(() => {
  188. this.clearTabItem({type: 'scrollRefresh'});
  189. }, 200);
  190. },
  191. clearTabItem(options){
  192. let tab_item = this.tab_list[this.title_current];
  193. tab_item.page = 1;
  194. tab_item.isPage = true;
  195. tab_item.isRefresher = true;
  196. tab_item.loadingClass = true;
  197. tab_item.loadingText = '正在加载中';
  198. tab_item.list = [];
  199. this.getData(options);
  200. // this.$refs.uWaterfallFather[this.title_current].clear();
  201. }
  202. }
  203. }
  204. </script>
  205. <style lang="scss" scoped>
  206. .collect-img {
  207. width: 150rpx;
  208. height: 150rpx;
  209. border-radius: 5rpx;
  210. }
  211. /deep/.u-scroll-box {
  212. display: flex;
  213. justify-content: center;
  214. align-items: center;
  215. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  216. }
  217. /deep/.u-scroll-box .u-tab-bar {
  218. background-color: #15716E!important;
  219. width: 80rpx!important;
  220. position: absolute;
  221. left: 0;
  222. bottom: -12rpx;
  223. }
  224. /deep/ .u-tab-item {
  225. font-size: 28rpx!important;
  226. }
  227. // loading加载
  228. .loading-more {
  229. align-items: center;
  230. justify-content: center;
  231. padding-top: 10px;
  232. padding-bottom: 10px;
  233. text-align: center;
  234. font-size: 28rpx;
  235. color: #999;
  236. }
  237. .loading-more-text::before {
  238. content: '';
  239. width: 20px;
  240. height: 20px;
  241. display: inline-block;
  242. vertical-align: middle;
  243. -webkit-animation: weuiLoading 1s steps(12, end) infinite;
  244. animation: weuiLoading 1s steps(12, end) infinite;
  245. background-repeat: no-repeat;
  246. background-image: url("data:image/svg+xml;charset=utf8, %3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 100 100'%3E%3Cpath fill='none' d='M0 0h100v100H0z'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23E9E9E9' rx='5' ry='5' transform='translate(0 -30)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23989697' rx='5' ry='5' transform='rotate(30 105.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%239B999A' rx='5' ry='5' transform='rotate(60 75.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23A3A1A2' rx='5' ry='5' transform='rotate(90 65 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23ABA9AA' rx='5' ry='5' transform='rotate(120 58.66 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23B2B2B2' rx='5' ry='5' transform='rotate(150 54.02 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23BAB8B9' rx='5' ry='5' transform='rotate(180 50 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23C2C0C1' rx='5' ry='5' transform='rotate(-150 45.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23CBCBCB' rx='5' ry='5' transform='rotate(-120 41.34 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23D2D2D2' rx='5' ry='5' transform='rotate(-90 35 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23DADADA' rx='5' ry='5' transform='rotate(-60 24.02 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23E2E2E2' rx='5' ry='5' transform='rotate(-30 -5.98 65)'/%3E%3C/svg%3E");
  247. background-size: 100%;
  248. }
  249. @keyframes weuiLoading {
  250. 0% {
  251. transform: rotate3d(0, 0, 1, 0deg);
  252. }
  253. 100% {
  254. transform: rotate3d(0, 0, 1, 360deg);
  255. }
  256. }
  257. .list-warter {
  258. border-radius: 20rpx;
  259. margin: 10px 5px;
  260. margin-top: 0px;
  261. background-color: #ffffff;
  262. // padding: 8px;
  263. position: relative;
  264. overflow: hidden;
  265. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  266. }
  267. .u-close {
  268. position: absolute;
  269. top: 32rpx;
  270. right: 32rpx;
  271. }
  272. .list-image {
  273. width: 100%;
  274. border-radius: 4px;
  275. }
  276. .list-title {
  277. font-size: 28rpx;
  278. font-weight: bold;
  279. color: $u-main-color;
  280. }
  281. .list-label{
  282. position: absolute;
  283. bottom: 0;
  284. right: 0;
  285. background-color: rgba(0,0,0,0.5);
  286. width: 140rpx;
  287. height: 48rpx;
  288. border-radius: 20rpx 0rpx 0rpx 0rpx;
  289. font-size: 22rpx;
  290. color: #FFFFFF;
  291. line-height: 48rpx;
  292. text-align: center;
  293. }
  294. .list-tag {
  295. display: flex;
  296. margin-top: 5px;
  297. }
  298. .list-tag-owner {
  299. background-color: $u-type-error;
  300. color: #FFFFFF;
  301. display: flex;
  302. align-items: center;
  303. padding: 4rpx 14rpx;
  304. border-radius: 50rpx;
  305. font-size: 20rpx;
  306. line-height: 1;
  307. }
  308. .list-tag-text {
  309. border: 1px solid $u-type-primary;
  310. color: $u-type-primary;
  311. margin-left: 10px;
  312. border-radius: 50rpx;
  313. line-height: 1;
  314. padding: 4rpx 14rpx;
  315. display: flex;
  316. align-items: center;
  317. border-radius: 50rpx;
  318. font-size: 20rpx;
  319. }
  320. .list-price {
  321. font-size: 30rpx;
  322. color: $u-type-error;
  323. margin-top: 5px;
  324. display: flex;
  325. align-items: center;
  326. }
  327. </style>