StoreDetail.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. <template>
  2. <div class="store-detail mobile-content">
  3. <div class="store-logo">
  4. <div class="store-logo-box">
  5. <img :src="store.logoUrl || '/images/component/default.png'"/>
  6. <i v-if="showIcon" class="iconfont icon-shoucang" :style="isFocus === 'true'?'color:#ff7800':'color: #ddd'" @click="collectStore"></i>
  7. </div>
  8. </div>
  9. <div class="store-switch-item">
  10. <span :class="activeType=='product'?'mobile-switch-btn active':'mobile-switch-btn'" @click="activeType='product'">产品</span>
  11. <span :class="activeType=='detail'?'mobile-switch-btn active':'mobile-switch-btn'" @click="activeType='detail'">介绍</span>
  12. </div>
  13. <div class="store-info" v-if="activeType=='detail'">
  14. <div class="contact-info">
  15. <h4>联系我们</h4>
  16. <ul class="list-unstyled clearfix">
  17. <li>
  18. <div>电&nbsp;&nbsp;话:</div>
  19. <div v-if="store.enterprise.enTel"><a :href="'tel:' + store.enterprise.enTel" @click="clickTel = true" :class="{'click-tel': clickTel}">{{store.enterprise.enTel}}</a></div>
  20. <div v-else><span>-</span></div>
  21. </li>
  22. <li>
  23. <div>传&nbsp;&nbsp;真:</div>
  24. <div v-if="store.enterprise.enFax"> {{store.enterprise.enFax}}</div>
  25. <div v-else><span>-</span></div>
  26. </li>
  27. <li>
  28. <div>手&nbsp;&nbsp;机:</div>
  29. <div v-if="store.enterprise.enPhone"> <a :href="'tel:' + store.enterprise.enPhone" @click="clickPhone = true" :class="{'click-phone': clickPhone}">{{store.enterprise.enPhone}}</a></div>
  30. <div v-else><span>-</span></div>
  31. </li>
  32. <li>
  33. <div>微&nbsp;&nbsp;信:</div>
  34. <div v-if="store.enterprise.enWeixin"> {{store.enterprise.enWeixin}}</div>
  35. <div v-else><span>-</span></div>
  36. </li>
  37. <li>
  38. <div>Q&nbsp;&nbsp;&nbsp;Q:</div>
  39. <div v-if="store.enterprise.enQQ"> {{store.enterprise.enQQ}}</div>
  40. <div v-else><span>-</span></div>
  41. </li>
  42. <li>
  43. <div>店铺地址:</div>
  44. <div v-if="store.enterprise.address">{{store.enterprise.address}}</div>
  45. <div v-else><span>-</span></div>
  46. </li>
  47. </ul>
  48. </div>
  49. <div class="store-description">
  50. <h4>企业简介</h4>
  51. <p class="content" v-if="store.description">
  52. {{store.description}}
  53. </p>
  54. <div class="com-none-state" v-else>
  55. <p>抱歉,暂无企业简介</p>
  56. </div>
  57. </div>
  58. </div>
  59. <!-- <div class="com-none-state" v-if="activeType=='detail'">
  60. <img src="/images/mobile/@2x/empty-collect.png">
  61. <p>抱歉,暂无店铺简介</p>
  62. <nuxt-link to="/">返回首页</nuxt-link>
  63. </div>-->
  64. <div class="product-store" v-if="activeType == 'product'">
  65. <table v-if="commodities.content&&commodities.content.length > 0">
  66. <thead id="product-head" >
  67. <tr>
  68. <th style="width: 1.77rem;">型号/品牌</th>
  69. <th style="width: 1.75rem;">包装</th>
  70. <th style="width: 2.2rem;">价格梯度</th>
  71. <th style="width: 1.77rem;">交期(天)</th>
  72. </tr>
  73. </thead>
  74. <thead class="active" v-show="isScrollOverTab">
  75. <tr>
  76. <th style="width: 1.77rem;">型号/品牌</th>
  77. <th style="width: 1.75rem;">包装</th>
  78. <th style="width: 2.2rem;">价格梯度</th>
  79. <th style="width: 1.77rem;">交期(天)</th>
  80. </tr>
  81. </thead>
  82. <tbody id="product-body">
  83. <tr v-for="commodity in searchLists" @click="goProductDetail(commodity.uuid)">
  84. <td class="store-name">
  85. <div>{{commodity.code}}</div>
  86. <div>{{commodity.brandNameCn}}</div>
  87. </td>
  88. <td>
  89. <div v-if="!commodity.packaging && !commodity.breakUp && !commodity.produceDate">-</div>
  90. <div>{{commodity.packaging}}</div>
  91. <div>{{commodity.breakUp?'可拆卖':'不可拆卖'}}</div>
  92. <div>{{commodity.produceDate}}</div>
  93. </td>
  94. <td class="price-level-wrap">
  95. <div v-if="!commodity.prices || commodity.prices.length == 0">-</div>
  96. <div class="price-number fl">
  97. <div v-for="price in commodity.prices">{{price.start}}+</div>
  98. </div>
  99. <div class="price-number fr">
  100. <div v-for="price in commodity.prices" class="price-level">
  101. <span v-if="commodity.currencyName.indexOf('RMB')!==-1">¥{{price.rMBPrice | currency}}</span>
  102. <span v-if="commodity.currencyName.indexOf('USD')!==-1">${{price.uSDPrice | currency}}</span>
  103. </div>
  104. </div>
  105. </td>
  106. <td>
  107. <div v-if="commodity.b2cMinDelivery">
  108. <span>{{commodity.b2cMinDelivery}}</span>
  109. <span v-if="commodity.b2cMaxDelivery && commodity.b2cMaxDelivery !== commodity.b2cMinDelivery">-</span>
  110. <span v-if="commodity.b2cMaxDelivery && commodity.b2cMaxDelivery !== commodity.b2cMinDelivery">{{commodity.b2cMaxDelivery}}</span>
  111. </div>
  112. <div v-if="commodity.minBuyQty"><span class="order-tag">订</span>{{commodity.minBuyQty}}起订</div>
  113. <div v-if="commodity.reserve"><span class="order-tag reserve-tag">库</span>{{commodity.reserve}}</div>
  114. <div v-if="!commodity.b2cMinDelivery">
  115. <span>—</span>
  116. </div>
  117. </td>
  118. </tr>
  119. </tbody>
  120. </table>
  121. <div v-if="!commodities.content || commodities.content.length == 0" class="no-product">
  122. <img src="/images/mobile/@2x/car@2x.png" alt="">
  123. <div>抱歉,暂无上架产品信息</div>
  124. </div>
  125. </div>
  126. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  127. <loading v-show="isSearchingMore"></loading>
  128. <login-box @onLoginBoxClose="showLoginBox = false" v-if="showLoginBox"></login-box>
  129. </div>
  130. </template>
  131. <script>
  132. import {RemindBox, Loading, LoginBox} from '~components/mobile/common'
  133. export default {
  134. data () {
  135. return {
  136. activeType: 'product',
  137. collectResult: '收藏成功',
  138. timeoutCount: 0,
  139. clickTel: false,
  140. clickPhone: false,
  141. isSearchingMore: false,
  142. searchLists: [],
  143. page: 1,
  144. showLoginBox: false,
  145. isScrollOverTab: false
  146. }
  147. },
  148. components: {
  149. RemindBox,
  150. Loading,
  151. LoginBox
  152. },
  153. mounted: function () {
  154. let _this = this
  155. _this.$nextTick(function () {
  156. window.addEventListener('scroll', function () {
  157. _this.scroll()
  158. }, false)
  159. })
  160. },
  161. filters: {
  162. currency: function (num) {
  163. if (typeof num === 'number') {
  164. if (num <= 0.000001) {
  165. num = 0.000001
  166. } else {
  167. if (num.toString().indexOf('.') === -1) {
  168. num += '.00'
  169. } else {
  170. let inputStr = num.toString()
  171. let arr = inputStr.split('.')
  172. let floatNum = arr[1]
  173. if (floatNum.length > 6) {
  174. num = inputStr.substring(0, arr[0].length + 7)
  175. if (Number(floatNum.charAt(6)) > 4) {
  176. num = (Number(num) * 1000000 + 1) / 1000000
  177. }
  178. } else if (floatNum.length === 1) {
  179. num = num + '0'
  180. }
  181. }
  182. }
  183. }
  184. return num
  185. }
  186. },
  187. created () {
  188. this.clickTel = false
  189. this.clickPhone = false
  190. },
  191. computed: {
  192. store () {
  193. return this.$store.state.shop.storeInfo.store.data
  194. },
  195. commodities () {
  196. let list = this.$store.state.shop.storeInfo.storeCommodity.data
  197. this.searchLists = this.searchLists.concat(list.content)
  198. this.isSearchingMore = false
  199. return list
  200. },
  201. allPage () {
  202. return this.commodities.totalPages
  203. },
  204. isFocus () {
  205. return this.$store.state.shop.storeInfo.focusList.data
  206. },
  207. user () {
  208. return this.$store.state.option.user
  209. },
  210. showIcon() {
  211. return this.store.uuid !== this.$store.state.option.storeStatus.data.uuid
  212. }
  213. },
  214. methods: {
  215. scroll: function () {
  216. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  217. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchingMore && this.page < this.allPage && this.activeType === 'product') {
  218. this.getMoreCom()
  219. }
  220. let tbodyObj = document.getElementById('product-body')
  221. let theadObj = document.getElementById('product-head')
  222. if (theadObj) {
  223. this.isScrollOverTab = tbodyObj.getBoundingClientRect().top - theadObj.getBoundingClientRect().height - 5 <= theadObj.getBoundingClientRect().height
  224. }
  225. },
  226. getMoreCom: function () {
  227. if (!this.isSearchingMore) {
  228. this.page++
  229. this.isSearchingMore = true
  230. this.pageCommodity({ page: this.page, count: 6 })
  231. }
  232. },
  233. async pageCommodity (pageParams, kindId, keyword) {
  234. let params = { storeid: this.$route.params.uuid, origin: 'store', kindUuid: kindId, code: keyword }
  235. params.page = pageParams.page
  236. params.count = pageParams.count
  237. try {
  238. let { data } = await this.$http.get('/api/commodity/commodities', { params })
  239. this.$store.commit('shop/storeInfo/GET_STORE_COMMODITY_SUCCESS', data)
  240. } catch (err) {
  241. this.$store.commit('shop/storeInfo/GET_STORE_COMMODITY_FAILURE', err)
  242. }
  243. },
  244. goProductDetail: function (uuid) {
  245. if (uuid) {
  246. this.$router.push('/mobile/brand/componentDetail/' + uuid)
  247. } else {
  248. this.collectResult = '卖家上传的产品暂无参数,请联系卖家了解具体详情。'
  249. this.timeoutCount ++
  250. }
  251. },
  252. collectStore: function () {
  253. if (this.user.logged) {
  254. if (this.isFocus === 'false') {
  255. this.$store.dispatch('shop/StoreFocus', {storeName: this.store.storeName, storeid: this.store.id})
  256. .then(response => {
  257. this.$store.dispatch('shop/StoreFocusList', {id: this.store.id})
  258. this.collectResult = '收藏成功'
  259. this.timeoutCount++
  260. })
  261. } else if (this.isFocus === 'true') {
  262. this.$http.post('/trade/storeFocus/delete/storeId', [this.store.id])
  263. .then(response => {
  264. this.$store.dispatch('shop/StoreFocusList', {id: this.store.id})
  265. this.collectResult = '取消成功'
  266. this.timeoutCount++
  267. })
  268. }
  269. } else {
  270. this.showLoginBox = true
  271. }
  272. }
  273. }
  274. }
  275. </script>
  276. <style lang="scss" scoped>
  277. .store-detail {
  278. margin: 0 auto;
  279. margin-bottom: 1.2rem;
  280. text-align: center;
  281. background: #f7f7f7;
  282. height: 100%;
  283. .store-logo {
  284. height: 3.17rem;
  285. width: 6.96rem;
  286. display: inline-block;
  287. margin: .2rem auto;
  288. line-height: 2.13rem;
  289. background: #fff;
  290. text-align: center;
  291. border-radius: .1rem;
  292. background: url('/images/mobile/@2x/brand-bg.png') no-repeat;
  293. background-size: cover;
  294. .store-logo-box {
  295. border: .04rem solid #c7e5fd;
  296. border-radius: .1rem;
  297. height: 2.21rem;
  298. width: 3.73rem;
  299. margin: .5rem auto 0;
  300. background: #fff;
  301. position: relative;
  302. img {
  303. max-height: 2.1rem;
  304. max-width: 3.6rem;
  305. }
  306. >i {
  307. position: absolute;
  308. font-size: .4rem;
  309. background: #fff;
  310. width: .6rem;
  311. height: .6rem;
  312. line-height: .6rem;
  313. border-radius: 100%;
  314. box-shadow: 0 0 .05rem #aaa;
  315. right: -1.44rem;
  316. top: .75rem;
  317. text-align: center;
  318. }
  319. }
  320. }
  321. .store-switch-item {
  322. text-align: center;
  323. background: #fff;
  324. .mobile-switch-btn {
  325. background: #fff;
  326. color: #666;
  327. display: inline-block;
  328. height: .64rem;
  329. font-size: .34rem;
  330. line-height: .64rem;
  331. width: 1.4rem;
  332. &:first-child {
  333. margin-right: 1.78rem;
  334. }
  335. &.active {
  336. color: #fc5708;
  337. border-bottom: .04rem solid #fc5708;
  338. }
  339. }
  340. }
  341. .store-info {
  342. background: #f7f7f7;
  343. width: 100%;
  344. h4{
  345. width: 100%;
  346. text-align: left;
  347. font-size: 0.3rem;
  348. line-height: 0.6rem;
  349. height: 0.6rem;
  350. letter-spacing: 0px;
  351. color: #333;
  352. font-weight: normal;
  353. border-bottom: 1px solid #efeded;
  354. padding-left: 0.11rem;
  355. &:before{
  356. content: '';
  357. display: inline-block;
  358. width: 0.08rem;
  359. height: 0.26rem;
  360. background-color: #145dee;
  361. margin-right: 0.13rem;
  362. position: relative;
  363. top: 0.02rem;
  364. }
  365. }
  366. .contact-info{
  367. background: #fff;
  368. width: 6.96rem;
  369. margin: .2rem auto;
  370. border-radius: .1rem;
  371. ul{
  372. padding: 0.22rem 0rem;
  373. li{
  374. div{
  375. float: left;
  376. font-size: .28rem;
  377. color: #666;
  378. line-height: .53rem;
  379. width:80%;
  380. text-align: left;
  381. &:first-child{
  382. width: 20%;
  383. padding-left: 0.36rem;
  384. text-align: justify;
  385. }
  386. a{
  387. color: #145dee;
  388. }
  389. .click-tel, .click-phone{
  390. color: #f44336;
  391. }
  392. }
  393. &:last-child{
  394. div{
  395. width: 74%;
  396. padding-right:.34rem;
  397. word-wrap: break-word;
  398. &:first-child{
  399. text-align: left;
  400. padding: 0rem 0rem 0rem .36rem;
  401. width: 26%;
  402. }
  403. }
  404. }
  405. }
  406. }
  407. }
  408. .store-description{
  409. background: #fff;
  410. width: 6.96rem;
  411. margin: .2rem auto;
  412. border-radius: .1rem;
  413. .content {
  414. text-indent:2em;
  415. background: #fff;
  416. margin: .2rem auto 0;
  417. padding: .04rem .34rem .4rem .34rem;
  418. width: 100%;
  419. font-size: .28rem;
  420. color: #666;
  421. text-align: left;
  422. height: 95%;
  423. /*box-shadow: 0 .03rem .01rem 0 #cdcbcb96;*/
  424. line-height: .5rem;
  425. word-break: break-all;
  426. }
  427. }
  428. }
  429. .product-store {
  430. margin: .2rem 0 0 0;
  431. table {
  432. width: 100%;
  433. font-size: .28rem;
  434. thead {
  435. background: #d5e5fb;
  436. &.active {
  437. position: fixed;
  438. top: .88rem;
  439. z-index: 2;
  440. }
  441. tr {
  442. th {
  443. font-weight: bold;
  444. text-align: center;
  445. height: .78rem;
  446. line-height: .78rem;
  447. }
  448. }
  449. }
  450. tbody {
  451. tr {
  452. background: #fff;
  453. border-bottom: 0.2rem solid #f7f7f7;
  454. td {
  455. padding: .2rem .1rem;
  456. text-align: left;
  457. &.price-level-wrap {
  458. text-align: center;
  459. }
  460. div {
  461. overflow: hidden;
  462. text-overflow: ellipsis;
  463. white-space: nowrap;
  464. margin-bottom: .2rem;
  465. max-width: 1.58rem;
  466. &:last-child {
  467. margin-bottom: 0;
  468. }
  469. }
  470. .price-level:last-child {
  471. color: #fc5708;
  472. }
  473. .price-number {
  474. display: inline-block;
  475. vertical-align: middle;
  476. margin-bottom: 0;
  477. width: .9rem;
  478. }
  479. .order-tag {
  480. display: inline-block;
  481. font-size: .18rem;
  482. color: #fff;
  483. font-weight: bold;
  484. background: #ee1717;
  485. height: .27rem;
  486. width: .27rem;
  487. line-height: .27rem;
  488. text-align: center;
  489. border-radius: .05rem;
  490. position: relative;
  491. top: -.05rem;
  492. margin-right: .05rem;
  493. &.reserve-tag {
  494. background: #07bb1c;
  495. }
  496. }
  497. }
  498. &:active {
  499. background: #e1e1e1;
  500. }
  501. }
  502. }
  503. }
  504. .no-store {
  505. background: #fff;
  506. padding-top: 1rem;
  507. img {
  508. display: block;
  509. text-align: center;
  510. margin: 0 auto;
  511. margin-bottom: .45rem;
  512. width: 3.31rem;
  513. height: 2.13rem;
  514. }
  515. div {
  516. width: 5.27rem;
  517. margin: 0 auto;
  518. text-align: center;
  519. line-height: .4rem;
  520. color: #999;
  521. .link-url {
  522. color: #01a44e;
  523. }
  524. }
  525. }
  526. }
  527. .no-product {
  528. background: #fff;
  529. padding-top: 1rem;
  530. img {
  531. display: block;
  532. text-align: center;
  533. margin: 0 auto;
  534. margin-bottom: .45rem;
  535. width: 3.31rem;
  536. height: 2.13rem;
  537. }
  538. div {
  539. width: 5.27rem;
  540. margin: 0 auto;
  541. text-align: center;
  542. line-height: .4rem;
  543. font-size: .32rem;
  544. color: #999;
  545. }
  546. }
  547. }
  548. </style>