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

545 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
  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.picture" 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.img}}
  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">
  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 src="/static/images/empty.png" 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. call(){
  178. uni.makePhoneCall({
  179. phoneNumber: String(this.detail.tel)
  180. })
  181. },
  182. initGoodsTabs(){
  183. let _public = {
  184. isRefresher: false,
  185. loadingClass: true,
  186. loadingText: '正在加载中',
  187. page: 1,
  188. isPage: true
  189. };
  190. this.tab_list = [{
  191. name: '综合',
  192. list: [],
  193. ..._public
  194. },{
  195. name: '销量',
  196. list: [],
  197. ..._public
  198. },{
  199. name: '上新',
  200. list: [],
  201. ..._public
  202. },{
  203. name: '价格',
  204. list: [],
  205. ..._public
  206. }]
  207. },
  208. getData() {
  209. let par = {
  210. brand_id: this.brand_id
  211. }
  212. let orderBy = ['','sale_count','updated_at','sell_price'][this.current];
  213. if(orderBy){
  214. par.orderBy = orderBy;
  215. }
  216. if(this.search_val){
  217. par.keyword = this.search_val;
  218. }
  219. this.$http.get({
  220. api: 'api/store/list',
  221. data: par
  222. }).then(res => {
  223. console.log("getDat", res);
  224. let tab_item = this.tab_list[this.current];
  225. let isPage = false; // TODO 默认没有下一页
  226. tab_item.isPage = isPage;
  227. if(!isPage){
  228. tab_item.loadingClass = false;
  229. tab_item.loadingText = '没有更多数据啦~';
  230. }
  231. tab_item.isRefresher = false;
  232. let data_list = res.data.data || [];
  233. let list = data_list.map(item => {
  234. return {
  235. id: item.id,
  236. original_price: item.market_price,
  237. picture: item.img,
  238. pictures: [item.img],
  239. price: item.min_price,
  240. product_id: item.brand_id,
  241. sale: item.sale_count,
  242. title: item.name
  243. }
  244. })
  245. if(tab_item.page == 1){
  246. tab_item.list = list;
  247. }else{
  248. tab_item.list.push(...list);
  249. }
  250. })
  251. },
  252. search(event){
  253. this.clearTabItem();
  254. this.getData();
  255. },
  256. // 滑块下标值变化
  257. swiperChange(event){
  258. this.current = event.detail.current;
  259. if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  260. this.clearTabItem();
  261. this.getData();
  262. },
  263. // 页面触底,加载下一页
  264. onScrolltolower(){
  265. let tab_item = this.tab_list[this.current];
  266. if(tab_item.isPage){
  267. tab_item.page = tab_item.page + 1;
  268. this.getData();
  269. }
  270. },
  271. // scroll-view 下拉刷新
  272. onRefresherrefresh(){
  273. this.$u.throttle(() => {
  274. this.clearTabItem();
  275. this.getData();
  276. }, 200);
  277. },
  278. clearTabItem(){
  279. let tab_item = this.tab_list[this.current];
  280. tab_item.page = 1;
  281. tab_item.isPage = true;
  282. tab_item.isRefresher = true;
  283. tab_item.loadingClass = true;
  284. tab_item.loadingText = '正在加载中';
  285. tab_item.list = [];
  286. this.$set(this.tab_list, this.current, tab_item);
  287. this.$refs.uWaterfallFather[this.current].clear();
  288. }
  289. },
  290. onShareAppMessage(){
  291. return {
  292. title: `给你分享一家店铺[${this.detail.name}],我觉得很不错哦~`,
  293. path: '/pages/route/index?route=shop&id='+ this.brand_id
  294. }
  295. }
  296. }
  297. </script>
  298. <style>
  299. page {
  300. background-color: white;
  301. }
  302. </style>
  303. <style lang="scss" scoped>
  304. .search-icon {
  305. position: relative;
  306. bottom: 0;
  307. left: 54rpx;
  308. }
  309. /deep/.input-placeholder{
  310. color: #777;
  311. font-size: 28rpx;
  312. }
  313. .rom-search {
  314. width: 686rpx;
  315. height: 60rpx;
  316. background: #F4F8F8;
  317. border-radius: 30rpx;
  318. padding-left: 74rpx;
  319. font-size: 28rpx;
  320. }
  321. .recommend-box{
  322. display: flex;
  323. justify-content: space-between;
  324. padding: 30rpx 32rpx;
  325. flex-wrap: wrap;
  326. }
  327. .goods-rom {
  328. border-radius: 20rpx;
  329. width: 333rpx;
  330. height: max-content;
  331. background-color: white;
  332. box-shadow: 0px 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  333. &:nth-child(2n) {
  334. margin-right: 0;
  335. }
  336. &:nth-child(n + 3) {
  337. margin-top: 20rpx;
  338. }
  339. }
  340. .introduct {
  341. padding: 30rpx 32rpx;
  342. }
  343. .com{
  344. width: 100%;
  345. height: 100%;
  346. box-sizing: border-box;
  347. padding: 0rpx 28rpx;
  348. }
  349. .shop-head {
  350. width: 100%;
  351. height: 400rpx;
  352. position: relative;
  353. }
  354. .shop-flex {
  355. display: flex;
  356. padding: 30rpx;
  357. }
  358. .shop-title {
  359. width: 686rpx;
  360. height: 274rpx;
  361. border-radius: 20rpx;
  362. background-color: white;
  363. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  364. margin: 0 auto;
  365. position: relative;
  366. top: -32rpx;
  367. }
  368. .shop-img {
  369. width: 90rpx;
  370. height: 90rpx;
  371. margin-right: 15rpx;
  372. border-radius: 5rpx;
  373. }
  374. .shop-function {
  375. width: 80rpx;
  376. height: 80rpx;
  377. border-radius: 50%;
  378. font-size: 40rpx;
  379. }
  380. .function-total {
  381. display: flex;
  382. justify-content: space-between;
  383. padding: 0 65rpx 0 65rpx;
  384. }
  385. .menu-btn{
  386. margin: 0;
  387. padding: 0;
  388. background-color: transparent;
  389. line-height: 1.5;
  390. }
  391. /deep/.u-scroll-box {
  392. display: flex;
  393. justify-content: center;
  394. align-items: center;
  395. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  396. }
  397. /deep/.u-scroll-box .u-tab-bar {
  398. background-color: #15716E!important;
  399. width: 80rpx!important;
  400. position: absolute;
  401. left: 0;
  402. bottom: -12rpx;
  403. }
  404. /deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
  405. background-color: #15716E!important;
  406. width: 56rpx!important;
  407. position: absolute;
  408. height: 5rpx!important;
  409. left: 8rpx;
  410. bottom: -4rpx;
  411. }
  412. /deep/ .u-tab-item {
  413. font-size: 28rpx!important;
  414. }
  415. //价格筛选伪类
  416. // /deep/.special_tab .u-tab-item:nth-child(4n) ::after{
  417. // font-size: 48rpx!important;
  418. // content: '';
  419. // color: red;
  420. // }
  421. // loading加载
  422. .loading-more {
  423. align-items: center;
  424. justify-content: center;
  425. padding-top: 10px;
  426. padding-bottom: 10px;
  427. text-align: center;
  428. font-size: 28rpx;
  429. color: #999;
  430. }
  431. .loading-more-text::before {
  432. content: '';
  433. width: 20px;
  434. height: 20px;
  435. display: inline-block;
  436. vertical-align: middle;
  437. -webkit-animation: weuiLoading 1s steps(12, end) infinite;
  438. animation: weuiLoading 1s steps(12, end) infinite;
  439. background-repeat: no-repeat;
  440. 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");
  441. background-size: 100%;
  442. }
  443. @keyframes weuiLoading {
  444. 0% {
  445. transform: rotate3d(0, 0, 1, 0deg);
  446. }
  447. 100% {
  448. transform: rotate3d(0, 0, 1, 360deg);
  449. }
  450. }
  451. .list-warter {
  452. border-radius: 20rpx;
  453. margin: 10px 5px;
  454. margin-top: 0px;
  455. background-color: #ffffff;
  456. // padding: 8px;
  457. position: relative;
  458. overflow: hidden;
  459. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  460. }
  461. .u-close {
  462. position: absolute;
  463. top: 32rpx;
  464. right: 32rpx;
  465. }
  466. .list-image {
  467. width: 100%;
  468. border-radius: 4px;
  469. }
  470. .list-title {
  471. font-size: 28rpx;
  472. font-weight: bold;
  473. color: $u-main-color;
  474. }
  475. .list-label{
  476. position: absolute;
  477. bottom: 0;
  478. right: 0;
  479. background-color: rgba(0,0,0,0.5);
  480. width: 140rpx;
  481. height: 48rpx;
  482. border-radius: 20rpx 0rpx 0rpx 0rpx;
  483. font-size: 22rpx;
  484. color: #FFFFFF;
  485. line-height: 48rpx;
  486. text-align: center;
  487. }
  488. .list-tag {
  489. display: flex;
  490. margin-top: 5px;
  491. }
  492. .list-tag-owner {
  493. background-color: $u-type-error;
  494. color: #FFFFFF;
  495. display: flex;
  496. align-items: center;
  497. padding: 4rpx 14rpx;
  498. border-radius: 50rpx;
  499. font-size: 20rpx;
  500. line-height: 1;
  501. }
  502. .list-tag-text {
  503. border: 1px solid $u-type-primary;
  504. color: $u-type-primary;
  505. margin-left: 10px;
  506. border-radius: 50rpx;
  507. line-height: 1;
  508. padding: 4rpx 14rpx;
  509. display: flex;
  510. align-items: center;
  511. border-radius: 50rpx;
  512. font-size: 20rpx;
  513. }
  514. .list-price {
  515. font-size: 30rpx;
  516. color: $u-type-error;
  517. margin-top: 5px;
  518. display: flex;
  519. align-items: center;
  520. }
  521. </style>