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

355 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" @click="$url('/pages/shop/shopdetail?id='+ item.collectable.id)">
  9. <image class="collect-img" :src="item.collectable.logo" 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">{{item.collectable.name}}</view>
  12. <view class="lf-font-24 lf-color-777">{{item.collectable.category}}{{item.collectable.goods_count}}件在售</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">{{item.collectable.floor}}</text>
  16. </view>
  17. </view>
  18. <view class="lf-iconfont icon-shoucang2 lf-color-price lf-font-38" style="color: #FF9D9D;" @click.stop="switchCollect(item.collectable.id)"></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 src="/static/images/empty.png" 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 src="/static/images/empty.png" 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. scrollH: 0,
  60. nav_height: 0,
  61. isRefresher: true
  62. }
  63. },
  64. computed: {
  65. autoHeight(){
  66. return `calc(${this.scrollH}px - ${this.nav_height}px - 86rpx)`;
  67. }
  68. },
  69. components: {
  70. lfWaterfall
  71. },
  72. onShow(){
  73. let info = uni.getSystemInfoSync();
  74. this.scrollH = info.screenHeight;
  75. this.getData();
  76. },
  77. methods: {
  78. // 切换商品收藏
  79. switchCollect(id){
  80. let userInfo = this.$cookieStorage.get('user_token') || {};
  81. if(!userInfo){
  82. this.$url('/pages/login/index');
  83. return;
  84. }
  85. this.addCollcet(id)
  86. },
  87. addCollcet(id) {
  88. this.$http.post({
  89. api: 'api/collect/create',
  90. data: {
  91. type:'jc_brand',
  92. collect_id: id,
  93. },
  94. header: {
  95. Authorization: this.$cookieStorage.get('user_token')
  96. }
  97. }).then(res => {
  98. this.$msg(res.data.data);
  99. this.clearTabItem({type: 'scrollRefresh'});
  100. }).catch(err => {
  101. console.log("====", err);
  102. })
  103. },
  104. titletabChange(index){
  105. this.title_current = index;
  106. this.getData();
  107. },
  108. getData(options = {}) {
  109. let tab_item = this.tab_list[this.title_current];
  110. this.$http
  111. .get({
  112. api: 'api/collect',
  113. data: {
  114. type: tab_item.type
  115. },
  116. header: {
  117. Authorization: this.$cookieStorage.get('user_token')
  118. },
  119. })
  120. .then(res => {
  121. console.log(res.data)
  122. if (res.data.code == 200) {
  123. let isPage = res.data.data.next_page_url == null?false:true;
  124. tab_item.isPage = isPage;
  125. if(!isPage) {
  126. tab_item.loadingClass = false;
  127. tab_item.loadingText = '没有更多数据啦~';
  128. }
  129. if(options.type == 'pageRefresh') {
  130. uni.stopPullDownRefresh();
  131. }else if(options.type == 'scrollRefresh') {
  132. this.isRefresher = false;
  133. }
  134. if(tab_item.page == 1) {
  135. if(this.title_current == 0) {
  136. tab_item.list = res.data.data.data;
  137. }else {
  138. let data_list = res.data.data.data || [];
  139. let list = data_list.map(item => {
  140. return {
  141. id: item.id,
  142. original_price: item.collectable.market_price,
  143. picture: item.collectable.img,
  144. pictures: [item.collectable.img],
  145. price: item.collectable.min_price,
  146. product_id: item.collectable.brand_id,
  147. sale: item.collectable.sale_count,
  148. title: item.collectable.name
  149. }
  150. })
  151. tab_item.list = list;
  152. }
  153. }else {
  154. if(this.title_current == 0) {
  155. tab_item.list.push(...res.data.data.data);
  156. }else {
  157. let data_list = res.data.data.data || [];
  158. let list = data_list.map(item => {
  159. return {
  160. id: item.id,
  161. original_price: item.collectable.market_price,
  162. picture: item.collectable.img,
  163. pictures: [item.collectable.img],
  164. price: item.collectable.min_price,
  165. product_id: item.collectable.brand_id,
  166. sale: item.collectable.sale_count,
  167. title: item.collectable.name
  168. }
  169. })
  170. tab_item.list.push(...list);
  171. }
  172. }
  173. } else {
  174. wx.showModal({
  175. content: '请下拉页面刷新重试',
  176. showCancel: false
  177. });
  178. }
  179. wx.hideLoading();
  180. })
  181. .catch(() => {
  182. wx.hideLoading();
  183. });
  184. },
  185. // 滑块下标值变化
  186. swiperChange(event){
  187. this.title_current = event.detail.current;
  188. if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  189. this.getData();
  190. },
  191. // 页面触底,加载下一页
  192. onScrolltolower(){
  193. let tab_item = this.tab_list[this.title_current];
  194. if(tab_item.isPage){
  195. tab_item.page = tab_item.page + 1;
  196. this.getData();
  197. }
  198. },
  199. // scroll-view 下拉刷新
  200. onRefresherrefresh(){
  201. this.$u.throttle(() => {
  202. this.clearTabItem({type: 'scrollRefresh'});
  203. }, 200);
  204. },
  205. clearTabItem(options){
  206. let tab_item = this.tab_list[this.title_current];
  207. tab_item.page = 1;
  208. tab_item.isPage = true;
  209. tab_item.isRefresher = true;
  210. tab_item.loadingClass = true;
  211. tab_item.loadingText = '正在加载中';
  212. tab_item.list = [];
  213. this.getData(options);
  214. // this.$refs.uWaterfallFather[this.title_current].clear();
  215. }
  216. }
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. .collect-img {
  221. width: 150rpx;
  222. height: 150rpx;
  223. border-radius: 5rpx;
  224. }
  225. /deep/.u-scroll-box {
  226. display: flex;
  227. justify-content: center;
  228. align-items: center;
  229. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  230. }
  231. /deep/.u-scroll-box .u-tab-bar {
  232. background-color: #15716E!important;
  233. width: 80rpx!important;
  234. position: absolute;
  235. left: 0;
  236. bottom: -12rpx;
  237. }
  238. /deep/ .u-tab-item {
  239. font-size: 28rpx!important;
  240. }
  241. // loading加载
  242. .loading-more {
  243. align-items: center;
  244. justify-content: center;
  245. padding-top: 10px;
  246. padding-bottom: 10px;
  247. text-align: center;
  248. font-size: 28rpx;
  249. color: #999;
  250. }
  251. .loading-more-text::before {
  252. content: '';
  253. width: 20px;
  254. height: 20px;
  255. display: inline-block;
  256. vertical-align: middle;
  257. -webkit-animation: weuiLoading 1s steps(12, end) infinite;
  258. animation: weuiLoading 1s steps(12, end) infinite;
  259. background-repeat: no-repeat;
  260. 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");
  261. background-size: 100%;
  262. }
  263. @keyframes weuiLoading {
  264. 0% {
  265. transform: rotate3d(0, 0, 1, 0deg);
  266. }
  267. 100% {
  268. transform: rotate3d(0, 0, 1, 360deg);
  269. }
  270. }
  271. .list-warter {
  272. border-radius: 20rpx;
  273. margin: 10px 5px;
  274. margin-top: 0px;
  275. background-color: #ffffff;
  276. // padding: 8px;
  277. position: relative;
  278. overflow: hidden;
  279. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  280. }
  281. .u-close {
  282. position: absolute;
  283. top: 32rpx;
  284. right: 32rpx;
  285. }
  286. .list-image {
  287. width: 100%;
  288. border-radius: 4px;
  289. }
  290. .list-title {
  291. font-size: 28rpx;
  292. font-weight: bold;
  293. color: $u-main-color;
  294. }
  295. .list-label{
  296. position: absolute;
  297. bottom: 0;
  298. right: 0;
  299. background-color: rgba(0,0,0,0.5);
  300. width: 140rpx;
  301. height: 48rpx;
  302. border-radius: 20rpx 0rpx 0rpx 0rpx;
  303. font-size: 22rpx;
  304. color: #FFFFFF;
  305. line-height: 48rpx;
  306. text-align: center;
  307. }
  308. .list-tag {
  309. display: flex;
  310. margin-top: 5px;
  311. }
  312. .list-tag-owner {
  313. background-color: $u-type-error;
  314. color: #FFFFFF;
  315. display: flex;
  316. align-items: center;
  317. padding: 4rpx 14rpx;
  318. border-radius: 50rpx;
  319. font-size: 20rpx;
  320. line-height: 1;
  321. }
  322. .list-tag-text {
  323. border: 1px solid $u-type-primary;
  324. color: $u-type-primary;
  325. margin-left: 10px;
  326. border-radius: 50rpx;
  327. line-height: 1;
  328. padding: 4rpx 14rpx;
  329. display: flex;
  330. align-items: center;
  331. border-radius: 50rpx;
  332. font-size: 20rpx;
  333. }
  334. .list-price {
  335. font-size: 30rpx;
  336. color: $u-type-error;
  337. margin-top: 5px;
  338. display: flex;
  339. align-items: center;
  340. }
  341. </style>