my-shop.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. <template>
  2. <view class="container shop clearfix" :style="{paddingTop:CustomBar+'px'}">
  3. <!-- 主页内容 -->
  4. <view class="container-shop tui-skeleton">
  5. <!-- 轮播 -->
  6. <view class="shop-search">
  7. <text class="iconfont icon-sousuo"></text>
  8. <input class="input" maxlength="20" type="text" value="" v-model.trim="listQuery.keyword" confirm-type="search" @confirm="SubMitSearch()" placeholder="搜索本店铺商品" />
  9. </view>
  10. <view class="product-supplier" @click="goSupplier">
  11. <view class="logo"><img :src="shopLogo" alt=""></view>
  12. <view class="main">
  13. <view class="name">{{ shopName }}</view>
  14. <view class="massgs">
  15. <view class="label">满意度:</view>
  16. <view class="p-stars">
  17. <uni-stars :stars="6" :iconClass="iconClass" :iconColor="iconColor" :fontSize="36" :widthInfo="176"></uni-stars>
  18. </view>
  19. <view class="acount">
  20. <text> {{ normalNum }} </text>件商品
  21. </view>
  22. </view>
  23. </view>
  24. <view class="right"><text class="iconfont icon-xiayibu"></text></view>
  25. </view>
  26. <banner :list="bannerImageList"></banner>
  27. </view>
  28. <view class="container-section tui-skeleton">
  29. <view class="tab-title">主推商品</view>
  30. <view class="section-product clearfix">
  31. <view class="floor-item" v-for="(item, index) in recommendList" :key="index" @click.stop="navToDetailPage(item.id)">
  32. <image class="item-img tui-skeleton-fillet" :src="item.image" mode="aspectFill"></image>
  33. <view class="floor-item-content">
  34. <view class="title tui-skeleton-rect">
  35. <text class="mclap">{{item.name}}</text>
  36. </view>
  37. <view class="" v-if="hasLogin">
  38. <view v-if="userIdentity == 4">
  39. <view class="title-none" v-show="item.priceFlag == '1'">
  40. <text class="p big">¥未公开价格</text>
  41. </view>
  42. <view class="title-none" v-show="item.priceFlag == '2'">
  43. <text class="p big">¥价格仅会员可见</text>
  44. </view>
  45. <view class="price tui-skeleton-rect" v-show="item.priceFlag == '0'" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  46. <text class="p sm">¥</text>
  47. <text class="p big">{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price ) | NumFormat}}</text>
  48. <template v-if="item.actStatus==1">
  49. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  50. {{item.promotions.name}}<text v-if="hasLogin && item.priceFlag != '1'">:¥{{item.price | NumFormat}}</text>
  51. </view>
  52. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  53. </template>
  54. <template v-if="item.actStatus ==0 && item.ladderPriceFlag==1">
  55. <view class="floor-tags">阶梯价格</view>
  56. </template>
  57. </view>
  58. </view>
  59. <view v-else>
  60. <view class="title-none" v-if="item.priceFlag == '1'">
  61. <text class="p big">未公开价格</text>
  62. </view>
  63. <view class="price tui-skeleton-rect" v-else :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  64. <text class="p sm">¥</text>
  65. <text class="p big">{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price ) | NumFormat}}</text>
  66. <template v-if="item.actStatus==1">
  67. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  68. {{item.promotions.name}}<text v-if="hasLogin && item.priceFlag != '1'">:¥{{item.price | NumFormat}}</text>
  69. </view>
  70. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  71. </template>
  72. <template v-if="item.actStatus ==0 && item.ladderPriceFlag==1">
  73. <view class="floor-tags">阶梯价格</view>
  74. </template>
  75. </view>
  76. </view>
  77. </view>
  78. <view v-else class="no-price">
  79. <view class="p-stars">
  80. <text class="p-no">¥</text>
  81. <uni-grader :grade="Number(item.priceGrade)"></uni-grader>
  82. <template v-if="item.actStatus==1">
  83. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  84. {{item.promotions.name}}<text v-if="hasLogin && item.priceFlag != '1'">:¥{{item.price | NumFormat}}</text>
  85. </view>
  86. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  87. </template>
  88. <template v-if="item.actStatus ==0 && item.ladderPriceFlag==1">
  89. <view class="floor-tags">阶梯价格</view>
  90. </template>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. <view class="container-section tui-skeleton">
  98. <view class="tab-title">全部商品</view>
  99. <view class="section-product clearfix">
  100. <view class="floor-item" v-for="(item, index) in productList" :key="index" @click.stop="navToDetailPage(item.p_id)">
  101. <image class="item-img tui-skeleton-fillet" :src="item.p_image" mode="aspectFill"></image>
  102. <view class="floor-item-content">
  103. <view class="title tui-skeleton-rect">
  104. <text class="mclap">{{item.p_name}}</text>
  105. </view>
  106. <view class="" v-if="hasLogin">
  107. <view v-if="userIdentity == 4">
  108. <view class="title-none" v-show="item.p_price_flag == '1'">
  109. <text class="p big">¥未公开价格</text>
  110. </view>
  111. <view class="title-none" v-show="item.p_price_flag == '2'">
  112. <text class="p big">¥价格仅会员可见</text>
  113. </view>
  114. <view class="price tui-skeleton-rect" v-show="item.p_price_flag == '0'" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  115. <text class="p sm">¥</text>
  116. <text class="p big">{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price ) | NumFormat}}</text>
  117. <template v-if="item.actStatus==1">
  118. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  119. {{item.promotions.name}}<text v-if="hasLogin && item.p_price_flag != '1'">:¥{{item.price | NumFormat}}</text>
  120. </view>
  121. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  122. </template>
  123. <template v-if="item.actStatus ==0 && item.ladderPriceFlag==1">
  124. <view class="floor-tags">阶梯价格</view>
  125. </template>
  126. </view>
  127. </view>
  128. <view v-else>
  129. <view class="title-none" v-if="item.p_price_flag == '1'">
  130. <text class="p big">未公开价格</text>
  131. </view>
  132. <view class="price tui-skeleton-rect" v-else :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  133. <text class="p sm">¥</text>
  134. <text class="p big">{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price ) | NumFormat}}</text>
  135. <template v-if="item.actStatus==1">
  136. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  137. {{item.promotions.name}}<text v-if="hasLogin && item.p_price_flag != '1'">:¥{{item.price | NumFormat}}</text>
  138. </view>
  139. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  140. </template>
  141. <template v-if="item.actStatus ==0 && item.ladderPriceFlag==1">
  142. <view class="floor-tags">阶梯价格</view>
  143. </template>
  144. </view>
  145. </view>
  146. </view>
  147. <view v-else class="no-price">
  148. <view class="p-stars">
  149. <text class="p-no">¥</text>
  150. <uni-grader :grade="Number(item.p_price_grade)"></uni-grader>
  151. </view>
  152. </view>
  153. </view>
  154. </view>
  155. </view>
  156. </view>
  157. <!-- 侧边 -->
  158. <scroll-top v-if="isScrollTop"></scroll-top>
  159. </view>
  160. </template>
  161. <script>
  162. import { mapState,mapMutations} from 'vuex';
  163. import banner from '@/components/cm-module/supplier/banner.vue'
  164. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  165. import authorize from '@/common/config/authorize.js'
  166. export default {
  167. components:{
  168. banner,
  169. uniGrader
  170. },
  171. data() {
  172. return {
  173. userID:0,
  174. shopId:0,
  175. iconClass:'icon-aixin',
  176. iconColor:'#ff9100',
  177. isScrollTop:false,
  178. shopName:'',
  179. shopLogo:'',
  180. normalNum:0,
  181. bannerImageList:[],
  182. recommendList:[],
  183. productList:[],
  184. listQuery:{
  185. keyword: '',
  186. pageSize: 10,
  187. pageNum: 1,
  188. id:0
  189. },
  190. total:0
  191. }
  192. },
  193. onLoad(option) {
  194. this.listQuery.id = this.shopId = option.shopId
  195. console.log(this.shopId)
  196. console.log(this.listQuery.id)
  197. this.InitShopDataInfo()
  198. },
  199. filters: {
  200. NumFormat:function(text) {//处理金额
  201. return Number(text).toFixed(2);
  202. },
  203. },
  204. computed: {
  205. ...mapState(['hasLogin','userInfo','isActivity'])
  206. },
  207. methods: {
  208. ...mapMutations(['login','logout']),
  209. InitShopDataInfo(){//初始化请求数据
  210. this.GetSupplierHomeBanner()
  211. this.GetSupplierHomeDeatils()
  212. this.GetSupplierHomeProduct()
  213. this.GetSupplierHomeProductList()
  214. },
  215. GetSupplierHomeBanner(){//轮播图
  216. this.ShopService.GetSupplierHomeBanner({supplierId:this.shopId}).then(response =>{
  217. this.bannerImageList = response.data;
  218. }).catch(error =>{
  219. this.$util.msg(error.msg,2000)
  220. })
  221. },
  222. GetSupplierHomeDeatils(){//商铺详情
  223. this.ShopService.GetSupplierHomeDeatils({supplierId:this.shopId}).then(response =>{
  224. let data = response.data
  225. this.normalNum = data.normalNum
  226. this.shopName = data.name
  227. this.shopLogo = data.logo
  228. }).catch(error =>{
  229. this.$util.msg(error.msg,2000)
  230. })
  231. },
  232. GetSupplierHomeProduct(){//主推商品
  233. this.ShopService.GetSupplierHomeProduct({supplierId:this.shopId}).then(response =>{
  234. let data = response.data
  235. this.QueryProductPrice(data)
  236. }).catch(error =>{
  237. this.$util.msg(error.msg,2000)
  238. })
  239. },
  240. GetSupplierHomeProductList(){//全部商品
  241. this.ShopService.GetSupplierHomeProductList(this.listQuery).then(response =>{
  242. let data = JSON.parse(response.data)
  243. let dataList = data.items
  244. console.log(data)
  245. this.total = data.total
  246. this.productList = dataList
  247. this.QueryProductPrice1(this.productList)
  248. }).catch(error =>{
  249. this.$util.msg(error.msg,2000)
  250. })
  251. },
  252. GetMoreSupplierHomeProductList(){//加载分页
  253. this.listQuery.pageNum +=1
  254. this.ShopService.GetSupplierHomeProductList(this.listQuery).then(response =>{
  255. let data = JSON.parse(response.data)
  256. console.log(data)
  257. this.total = data.total
  258. this.productList = this.productList.concat(data.items)
  259. this.QueryProductPrice1(this.productList)
  260. }).catch(error =>{
  261. this.$util.msg(error.msg,2000)
  262. })
  263. },
  264. QueryProductPrice(data){//处理主推商品商品或者活动价格
  265. let productIdArr = [];
  266. let productIds ='';
  267. data.map(item=>{// 0公开价格 1不公开价格 2仅对会员机构公开
  268. productIdArr.push(item.id)
  269. })
  270. productIds = productIdArr.join(",");
  271. this.ProductService.querySearchProductPrice({userId: this.userID,productIds:productIds}).then(response =>{
  272. this.recommendList = this.ReturnNewProducts(data,response.data);
  273. console.log(this.recommendList)
  274. }).catch(error =>{
  275. this.$util.msg(error.msg,2000)
  276. })
  277. },
  278. QueryProductPrice1(data){//获取商品或者活动价格
  279. let productIdArr = [];
  280. let productIds ='';
  281. data.map(item=>{// 0公开价格 1不公开价格 2仅对会员机构公开
  282. productIdArr.push(item.p_id)
  283. })
  284. productIds = productIdArr.join(",");
  285. this.ProductService.querySearchProductPrice({userId: this.userID,productIds:productIds}).then(response =>{
  286. this.productList = this.ReturnNewProducts1(data,response.data);
  287. console.log(this.productList)
  288. }).catch(error =>{
  289. this.$util.msg(error.msg,2000)
  290. })
  291. },
  292. ReturnNewProducts(listA,listB){
  293. let NewArray = []
  294. listA.map(item=>{
  295. for (let i = 0; i < listB.length; i++) {
  296. if( item.id == listB[i].productId ){
  297. NewArray.push(Object.assign(item,listB[i]))
  298. }
  299. }
  300. });
  301. return NewArray
  302. },
  303. ReturnNewProducts1(listA,listB){
  304. let NewArray = []
  305. listA.map(item=>{
  306. for (let i = 0; i < listB.length; i++) {
  307. if( item.p_id == listB[i].productId ){
  308. NewArray.push(Object.assign(item,listB[i]))
  309. }
  310. }
  311. });
  312. return NewArray
  313. },
  314. SubMitSearch() {//搜索
  315. if (this.searchInputVal == '') {
  316. this.$util.msg('请输入商品关键词',2000);
  317. }else{
  318. this.listQuery.pageNum = 1
  319. this.GetSupplierHomeProductList()
  320. }
  321. },
  322. goSupplier(){//跳供应商资料页
  323. this.$api.navigateTo('/supplier/pages/user/supplier?shopId='+this.shopId)
  324. },
  325. navToDetailPage(id) {//跳转商品详情页
  326. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  327. }
  328. },
  329. onPageScroll(e){//实时获取到滚动的值
  330. if(e.scrollTop>400){
  331. this.isScrollTop = true
  332. }else{
  333. this.isScrollTop = false
  334. }
  335. },
  336. onPullDownRefresh() {//下拉刷新
  337. this.listQuery.pageNum = 1
  338. this.productList =[]
  339. this.InitShopDataInfo()
  340. uni.stopPullDownRefresh()
  341. },
  342. onReachBottom() {//上滑加载分页
  343. if(this.total > this.productList.length){
  344. this.loadding = true
  345. this.pullUpOn = true
  346. this.GetMoreSupplierHomeProductList()
  347. }
  348. },
  349. onShow(){
  350. }
  351. }
  352. </script>
  353. <style lang="scss">
  354. page{
  355. background-color: #F7F7F7;
  356. }
  357. .shop{
  358. width: 100%;
  359. height: auto;
  360. }
  361. .container-shop{
  362. width: 100%;
  363. height: auto;
  364. padding:24rpx;
  365. box-sizing: border-box;
  366. background-color: #FFFFFF;
  367. }
  368. .shop-search{
  369. width: 100%;
  370. height: 66rpx;
  371. border-radius: 33rpx;
  372. background-color: #F7F7F7;
  373. box-sizing: border-box;
  374. padding: 0 20rpx;
  375. .icon-sousuo{
  376. width: 60rpx;
  377. height: 66rpx;
  378. display: block;
  379. float: left;
  380. color: #707070;
  381. line-height: 66rpx;
  382. text-align: center;
  383. font-size: 36rpx;
  384. }
  385. .input{
  386. width: 600rpx;
  387. height: 66rpx;
  388. box-sizing: border-box;
  389. padding: 0 20rpx;
  390. color: #666666;
  391. overflow: hidden;
  392. font-size: $font-size-24;
  393. }
  394. }
  395. .product-supplier{
  396. width: 100%;
  397. height: 140rpx;
  398. padding: 30rpx 0 10rpx 0;
  399. box-sizing: border-box;
  400. background-color: #FFFFFF;
  401. position: relative;
  402. box-sizing: border-box;
  403. .logo{
  404. width: 128rpx;
  405. height: 92rpx;
  406. float: left;
  407. border: 1px solid #efefef;
  408. border-radius: 6rpx;
  409. image{
  410. width: 100%;
  411. height: 100%;
  412. display: block;
  413. border-radius: 6rpx;
  414. }
  415. }
  416. .main{
  417. width: 470rpx;
  418. height: 92rpx;
  419. float: left;
  420. margin-left: 20rpx;
  421. .name{
  422. width: 100%;
  423. line-height: 46rpx;
  424. float: left;
  425. font-size: $font-size-28;
  426. color: $text-color;
  427. float: right;
  428. overflow: hidden;
  429. text-overflow:ellipsis;
  430. white-space: nowrap;
  431. text-align: left;
  432. }
  433. .massgs{
  434. width: 100%;
  435. line-height: 46rpx;
  436. float: left;
  437. font-size: $font-size-24;
  438. color: #999999;
  439. .label{
  440. float: left;
  441. }
  442. .p-stars{
  443. float: left;
  444. margin-left: 20rpx;
  445. }
  446. .acount{
  447. float: right;
  448. text{
  449. color: $color-system;
  450. }
  451. }
  452. }
  453. }
  454. .icon-xiayibu{
  455. line-height: 154rpx;
  456. display: inline-block;
  457. position: absolute;
  458. width: 48rpx;
  459. top: 0;
  460. right: 0;
  461. color: #b2b2b2;
  462. }
  463. }
  464. .container-section{
  465. width: 100%;
  466. height: auto;
  467. background-color: #F7F7F7;
  468. box-sizing: border-box;
  469. padding: 0 24rpx;
  470. .tab-title{
  471. width: 100%;
  472. height: 88rpx;
  473. line-height: 88rpx;
  474. font-size: $font-size-30;
  475. font-weight: bold;
  476. }
  477. .section-product{
  478. width: 100%;
  479. height: auto;
  480. .floor-item{
  481. width: 341rpx;
  482. height: auto;
  483. margin-right: 20rpx;
  484. font-size: $font-size-24;
  485. color: $text-color;
  486. background: #FFFFFF;
  487. line-height: 36rpx;
  488. border-radius: 2rpx;
  489. margin-bottom: 20rpx;
  490. float: left;
  491. box-sizing: border-box;
  492. padding-bottom: 16rpx;
  493. &:nth-child(2n){
  494. margin-right: 0;
  495. }
  496. .item-img{
  497. width: 341rpx;
  498. height: 341rpx;
  499. border-radius: 2rpx 2rpx 0 0;
  500. display: block;
  501. margin-bottom: 20rpx;
  502. }
  503. .floor-item-content{
  504. width: 311rpx;
  505. padding: 0 15rpx;
  506. }
  507. .floor-item-act{
  508. display: block;
  509. width: 100%;
  510. height: 68rpx;
  511. text-align: center;
  512. box-sizing: border-box;
  513. padding: 16rpx 0;
  514. margin-top: 8rpx;
  515. .floor-tags{
  516. float: left;
  517. height: 36rpx;
  518. border-radius: 4rpx;
  519. background-color: rgba(225, 86, 22, 0.1);
  520. line-height: 36rpx;
  521. color: $color-system;
  522. text-align: center;
  523. display: inline-block;
  524. padding:0 16rpx;
  525. font-size: $font-size-20;
  526. }
  527. }
  528. .title-none{
  529. font-size: $font-size-26;
  530. color: #FF2A2A;
  531. line-height: 44rpx;
  532. .btn{
  533. display: inline-block;
  534. float: right;
  535. width: 112rpx;
  536. height: 44rpx;
  537. background: $btn-confirm;
  538. line-height: 44rpx;
  539. font-size: $font-size-24;
  540. color: #FFFFFF;
  541. text-align: center;
  542. border-radius: 22rpx;
  543. margin-top: 17rpx;
  544. }
  545. }
  546. .title{
  547. width: 100%;
  548. height: 72rpx;
  549. display: flex;
  550. flex-direction: column;
  551. margin-bottom: 10rpx;
  552. .mclap{
  553. width: 100%;
  554. line-height: 36rpx;
  555. text-overflow:ellipsis;
  556. display: -webkit-box;
  557. word-break: break-all;
  558. -webkit-box-orient: vertical;
  559. -webkit-line-clamp: 2;
  560. overflow: hidden;
  561. font-size: 26rpx;
  562. }
  563. }
  564. .no-price{
  565. height: 54rpx;
  566. line-height: 54rpx;
  567. display: flex;
  568. box-sizing: border-box;
  569. .p-no{
  570. font-size: $font-size-30;
  571. color: $text-color;
  572. display: block;
  573. float: left;
  574. }
  575. .p-stars{
  576. width: 230rpx;
  577. float: left;
  578. }
  579. }
  580. .price{
  581. color: #FF2A2A;
  582. line-height: 44rpx;
  583. &.none{
  584. text-decoration: line-through;
  585. color: #999999;
  586. }
  587. .sm{
  588. font-size: $font-size-24;
  589. }
  590. .big{
  591. font-size: $font-size-28;
  592. }
  593. }
  594. }
  595. }
  596. }
  597. </style>