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

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