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

538 lines
14 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
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view>
  3. <lf-nav :spreadOut="false" :showIcon="true" bgColor="transparent!important"></lf-nav>
  4. <view class="shop-head">
  5. <image class="lf-w-100 lf-h-100" :src="detail.images[0].path" mode="aspectFill"></image>
  6. </view>
  7. <view class="shop-title">
  8. <view class="shop-flex">
  9. <view class="shop-img">
  10. <image class="shop-img" :src="detail.logo" mode="aspectFill"></image>
  11. </view>
  12. <view>
  13. <view class="lf-color-black lf-font-36">{{ detail.name }}</view>
  14. <view class="lf-font-24 lf-color-black">
  15. <text class="lf-iconfont icon-dizhi lf-font-24 lf-color-primary"></text>
  16. <text class="lf-m-l-10">{{ detail.floor }}</text>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="function-total">
  21. <button class="lf-row-center lf-flex-column menu-btn" @click="$url('/pages/user/my/chatonline')">
  22. <view><text class="lf-iconfont icon-pinglun shop-function"></text></view>
  23. <view class="lf-font-24 lf-color-33">客服</view>
  24. </button>
  25. <button class="lf-row-center lf-flex-column menu-btn" @click="switchCollect">
  26. <view>
  27. <text class="lf-iconfont icon-shoucang2 shop-function lf-color-price" v-if="is_collect"></text>
  28. <text class="lf-iconfont icon-shoucang11 shop-function" v-else></text>
  29. </view>
  30. <view class="lf-font-24 lf-color-333">{{ is_collect ? '已收藏' : '收藏' }}</view>
  31. </button>
  32. <button class="lf-row-center lf-flex-column menu-btn" open-type="share">
  33. <view><text class="lf-iconfont icon-fenxiang shop-function"></text></view>
  34. <view class="lf-font-24 lf-color-333">分享</view>
  35. </button>
  36. </view>
  37. </view>
  38. <view v-if="title_tab.length">
  39. <u-tabs :list="title_tab" active-color="#15716E" inactive-color='#777777' :is-scroll="true" :current="title_current" @change="titletabChange"></u-tabs>
  40. </view>
  41. <!-- 推荐 -->
  42. <view v-if="title_current==0">
  43. <view class="lf-row-between lf-p-l-32 lf-p-t-40 lf-p-r-32">
  44. <view class="lf-font-32 lf-color-black lf-font-bold">在售商品</view>
  45. <view class="lf-font-24 lf-color-555" @click="titletabChange(1)">
  46. <text>查看全部</text>
  47. <text class="lf-iconfont icon-xiangyou lf-font-24 lf-m-l-10"></text>
  48. </view>
  49. </view>
  50. <view class="recommend-box" >
  51. <view class="goods-rom" v-for="(item,index) of detail.goods" :key="index" v-if="detail.goods.length" @click="$url('/pages/shop/goodsdetail?id='+item.id)">
  52. <u-lazy-load threshold="-450" border-radius="8px 8px 0 0" :image="item.img" :index="index">
  53. <view class="list-label">已售{{item.sale_count}}</view>
  54. </u-lazy-load>
  55. <view class="lf-p-20">
  56. <view class="list-title">
  57. {{item.name}}
  58. </view>
  59. <view class="list-price">
  60. <!-- <text>{{item.price}}</text> -->
  61. <lf-price :price="item.min_price"></lf-price>
  62. <text class="lf-m-l-20 lf-font-24 lf-color-666 lf-line-through">{{item.min_market_price}}</text>
  63. </view>
  64. </view>
  65. </view>
  66. <lf-nocontent v-else></lf-nocontent>
  67. </view>
  68. <view class="introduct">
  69. <text class="lf-font-32 lf-color-black">品牌故事</text>
  70. <view class="lf-font-28 lf-color-333 lf-m-t-20">{{ detail.story }}</view>
  71. </view>
  72. </view>
  73. <view class="lf-p-t-30 lf-p-b-30" v-else>
  74. <view class="lf-m-b-30 lf-flex lf-w-100">
  75. <u-icon name="search" class="search-icon"></u-icon>
  76. <input class="rom-search" v-model="search_val" @confirm="search" type="text" placeholder="请输入商品名称" />
  77. </view>
  78. <view class="special_tab">
  79. <u-tabs :list="tab_list" active-color="#15716E" inactive-color='#777777' :is-scroll="true" :current="current" @change="tabChange"></u-tabs>
  80. </view>
  81. <swiper :style="{height: '800rpx', width: '750rpx'}" :current="current" @change="swiperChange">
  82. <swiper-item v-for="(tabItem, tabIndex) in tab_list" :key="tabIndex">
  83. <scroll-view class="com" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="tabItem.isRefresher" @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
  84. <view class="lf-m-t-20"></view>
  85. <lf-waterfall :ifsale="false" :list="tabItem.list" :listlength="tab_list.length" :tabindex='tabIndex' ref="uWaterfallFather"></lf-waterfall>
  86. <view class="loading-more lf-m-b-10">
  87. <text :class="{'loading-more-text': tabItem.loadingClass}" v-if="tabItem.list.length">{{tabItem.loadingText}}</text>
  88. <lf-nocontent v-else></lf-nocontent>
  89. <!-- <view>
  90. {{tabItem.list.length}}
  91. </view> -->
  92. </view>
  93. </scroll-view>
  94. </swiper-item>
  95. </swiper>
  96. </view>
  97. </view>
  98. </template>
  99. <script>
  100. import lfWaterfall from '@/components/lf-waterfall-shopdetails/lf-waterfall.vue';
  101. export default {
  102. components: {
  103. lfWaterfall
  104. },
  105. data() {
  106. return {
  107. title_tab: [
  108. {name:'推荐'},
  109. {name:'商品'}
  110. ],
  111. tab_list: [],
  112. current: 0,
  113. title_current:0,
  114. brand_id: 0,
  115. detail: {},
  116. search_val: '',
  117. is_collect: false
  118. }
  119. },
  120. onLoad(options){
  121. this.brand_id = options.id;
  122. this.getShopDetail();
  123. },
  124. methods: {
  125. // 切换商品收藏
  126. switchCollect(){
  127. let userInfo = this.$cookieStorage.get('user_token') || {};
  128. if(!userInfo){
  129. this.$url('/pages/login/index');
  130. return;
  131. }
  132. this.addCollcet()
  133. },
  134. addCollcet() {
  135. this.$http.post({
  136. api: 'api/collect/create',
  137. data: {
  138. type:'jc_brand',
  139. collect_id: this.brand_id,
  140. },
  141. header: {
  142. Authorization: this.$cookieStorage.get('user_token')
  143. }
  144. }).then(res => {
  145. this.$msg(res.data.data);
  146. this.getShopDetail();
  147. }).catch(err => {
  148. console.log("====", err);
  149. })
  150. },
  151. getShopDetail(){
  152. this.$http.get({
  153. api: 'api/brand/detail',
  154. data: {
  155. brand_id: this.brand_id
  156. },
  157. header: {
  158. Authorization: this.$cookieStorage.get('user_token')
  159. }
  160. }).then(res => {
  161. this.detail = res.data.data;
  162. this.is_collect = Boolean(res.data.data.is_collect) || false;
  163. })
  164. },
  165. tabChange(index){
  166. this.current = index;
  167. this.clearTabItem();
  168. this.getData();
  169. },
  170. titletabChange(index){
  171. this.title_current = index;
  172. if(this.tab_list.length <= 0){
  173. this.initGoodsTabs();
  174. this.getData();
  175. }
  176. },
  177. initGoodsTabs(){
  178. let _public = {
  179. isRefresher: false,
  180. loadingClass: true,
  181. loadingText: '正在加载中',
  182. page: 1,
  183. isPage: true
  184. };
  185. this.tab_list = [{
  186. name: '综合',
  187. list: [],
  188. ..._public
  189. },{
  190. name: '销量',
  191. list: [],
  192. ..._public
  193. },{
  194. name: '上新',
  195. list: [],
  196. ..._public
  197. },{
  198. name: '价格',
  199. list: [],
  200. ..._public
  201. }]
  202. },
  203. getData() {
  204. let par = {
  205. brand_id: this.brand_id
  206. }
  207. let orderBy = ['','sale_count','updated_at','sell_price'][this.current];
  208. if(orderBy){
  209. par.orderBy = orderBy;
  210. }
  211. if(this.search_val){
  212. par.keyword = this.search_val;
  213. }
  214. this.$http.get({
  215. api: 'api/store/list',
  216. data: par
  217. }).then(res => {
  218. console.log("getDat", res);
  219. let tab_item = this.tab_list[this.current];
  220. let isPage = false; // TODO 默认没有下一页
  221. tab_item.isPage = isPage;
  222. if(!isPage){
  223. tab_item.loadingClass = false;
  224. tab_item.loadingText = '没有更多数据啦~';
  225. }
  226. tab_item.isRefresher = false;
  227. let data_list = res.data.data || [];
  228. let list = data_list.map(item => {
  229. return {
  230. id: item.id,
  231. original_price: item.market_price,
  232. picture: item.img,
  233. pictures: [item.img],
  234. price: item.min_price,
  235. product_id: item.brand_id,
  236. sale: item.sale_count,
  237. title: item.name
  238. }
  239. })
  240. if(tab_item.page == 1){
  241. tab_item.list = list;
  242. }else{
  243. tab_item.list.push(...list);
  244. }
  245. })
  246. },
  247. search(event){
  248. this.clearTabItem();
  249. this.getData();
  250. },
  251. // 滑块下标值变化
  252. swiperChange(event){
  253. this.current = event.detail.current;
  254. if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  255. this.clearTabItem();
  256. this.getData();
  257. },
  258. // 页面触底,加载下一页
  259. onScrolltolower(){
  260. let tab_item = this.tab_list[this.current];
  261. if(tab_item.isPage){
  262. tab_item.page = tab_item.page + 1;
  263. this.getData();
  264. }
  265. },
  266. // scroll-view 下拉刷新
  267. onRefresherrefresh(){
  268. this.$u.throttle(() => {
  269. this.clearTabItem();
  270. this.getData();
  271. }, 200);
  272. },
  273. clearTabItem(){
  274. let tab_item = this.tab_list[this.current];
  275. tab_item.page = 1;
  276. tab_item.isPage = true;
  277. tab_item.isRefresher = true;
  278. tab_item.loadingClass = true;
  279. tab_item.loadingText = '正在加载中';
  280. tab_item.list = [];
  281. this.$set(this.tab_list, this.current, tab_item);
  282. this.$refs.uWaterfallFather[this.current].clear();
  283. }
  284. },
  285. onShareAppMessage(){
  286. return {
  287. title: '给你分享了一家店铺,我觉得很不错哦~'
  288. }
  289. }
  290. }
  291. </script>
  292. <style>
  293. page {
  294. background-color: white;
  295. }
  296. </style>
  297. <style lang="scss" scoped>
  298. .search-icon {
  299. position: relative;
  300. bottom: 0;
  301. left: 54rpx;
  302. }
  303. /deep/.input-placeholder{
  304. color: #777;
  305. font-size: 28rpx;
  306. }
  307. .rom-search {
  308. width: 686rpx;
  309. height: 60rpx;
  310. background: #F4F8F8;
  311. border-radius: 30rpx;
  312. padding-left: 74rpx;
  313. font-size: 28rpx;
  314. }
  315. .recommend-box{
  316. display: flex;
  317. justify-content: space-between;
  318. padding: 30rpx 32rpx;
  319. flex-wrap: wrap;
  320. }
  321. .goods-rom {
  322. border-radius: 20rpx;
  323. width: 333rpx;
  324. height: max-content;
  325. background-color: white;
  326. box-shadow: 0px 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  327. &:nth-child(2n) {
  328. margin-right: 0;
  329. }
  330. &:nth-child(n + 3) {
  331. margin-top: 20rpx;
  332. }
  333. }
  334. .introduct {
  335. padding: 30rpx 32rpx;
  336. }
  337. .com{
  338. width: 100%;
  339. height: 100%;
  340. box-sizing: border-box;
  341. padding: 0rpx 28rpx;
  342. }
  343. .shop-head {
  344. width: 100%;
  345. height: 400rpx;
  346. position: relative;
  347. }
  348. .shop-flex {
  349. display: flex;
  350. padding: 30rpx;
  351. }
  352. .shop-title {
  353. width: 686rpx;
  354. height: 274rpx;
  355. border-radius: 20rpx;
  356. background-color: white;
  357. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  358. margin: 0 auto;
  359. position: relative;
  360. top: -32rpx;
  361. }
  362. .shop-img {
  363. width: 90rpx;
  364. height: 90rpx;
  365. margin-right: 15rpx;
  366. }
  367. .shop-function {
  368. width: 80rpx;
  369. height: 80rpx;
  370. border-radius: 50%;
  371. font-size: 40rpx;
  372. }
  373. .function-total {
  374. display: flex;
  375. justify-content: space-between;
  376. padding: 0 65rpx 0 65rpx;
  377. }
  378. .menu-btn{
  379. margin: 0;
  380. padding: 0;
  381. background-color: transparent;
  382. line-height: 1.5;
  383. }
  384. /deep/.u-scroll-box {
  385. display: flex;
  386. justify-content: center;
  387. align-items: center;
  388. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  389. }
  390. /deep/.u-scroll-box .u-tab-bar {
  391. background-color: #15716E!important;
  392. width: 80rpx!important;
  393. position: absolute;
  394. left: 0;
  395. bottom: -12rpx;
  396. }
  397. /deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
  398. background-color: #15716E!important;
  399. width: 56rpx!important;
  400. position: absolute;
  401. height: 5rpx!important;
  402. left: 8rpx;
  403. bottom: -4rpx;
  404. }
  405. /deep/ .u-tab-item {
  406. font-size: 28rpx!important;
  407. }
  408. //价格筛选伪类
  409. // /deep/.special_tab .u-tab-item:nth-child(4n) ::after{
  410. // font-size: 48rpx!important;
  411. // content: '';
  412. // color: red;
  413. // }
  414. // loading加载
  415. .loading-more {
  416. align-items: center;
  417. justify-content: center;
  418. padding-top: 10px;
  419. padding-bottom: 10px;
  420. text-align: center;
  421. font-size: 28rpx;
  422. color: #999;
  423. }
  424. .loading-more-text::before {
  425. content: '';
  426. width: 20px;
  427. height: 20px;
  428. display: inline-block;
  429. vertical-align: middle;
  430. -webkit-animation: weuiLoading 1s steps(12, end) infinite;
  431. animation: weuiLoading 1s steps(12, end) infinite;
  432. background-repeat: no-repeat;
  433. 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");
  434. background-size: 100%;
  435. }
  436. @keyframes weuiLoading {
  437. 0% {
  438. transform: rotate3d(0, 0, 1, 0deg);
  439. }
  440. 100% {
  441. transform: rotate3d(0, 0, 1, 360deg);
  442. }
  443. }
  444. .list-warter {
  445. border-radius: 20rpx;
  446. margin: 10px 5px;
  447. margin-top: 0px;
  448. background-color: #ffffff;
  449. // padding: 8px;
  450. position: relative;
  451. overflow: hidden;
  452. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  453. }
  454. .u-close {
  455. position: absolute;
  456. top: 32rpx;
  457. right: 32rpx;
  458. }
  459. .list-image {
  460. width: 100%;
  461. border-radius: 4px;
  462. }
  463. .list-title {
  464. font-size: 28rpx;
  465. font-weight: bold;
  466. color: $u-main-color;
  467. }
  468. .list-label{
  469. position: absolute;
  470. bottom: 0;
  471. right: 0;
  472. background-color: rgba(0,0,0,0.5);
  473. width: 140rpx;
  474. height: 48rpx;
  475. border-radius: 20rpx 0rpx 0rpx 0rpx;
  476. font-size: 22rpx;
  477. color: #FFFFFF;
  478. line-height: 48rpx;
  479. text-align: center;
  480. }
  481. .list-tag {
  482. display: flex;
  483. margin-top: 5px;
  484. }
  485. .list-tag-owner {
  486. background-color: $u-type-error;
  487. color: #FFFFFF;
  488. display: flex;
  489. align-items: center;
  490. padding: 4rpx 14rpx;
  491. border-radius: 50rpx;
  492. font-size: 20rpx;
  493. line-height: 1;
  494. }
  495. .list-tag-text {
  496. border: 1px solid $u-type-primary;
  497. color: $u-type-primary;
  498. margin-left: 10px;
  499. border-radius: 50rpx;
  500. line-height: 1;
  501. padding: 4rpx 14rpx;
  502. display: flex;
  503. align-items: center;
  504. border-radius: 50rpx;
  505. font-size: 20rpx;
  506. }
  507. .list-price {
  508. font-size: 30rpx;
  509. color: $u-type-error;
  510. margin-top: 5px;
  511. display: flex;
  512. align-items: center;
  513. }
  514. </style>