StoreDetail.vue 14 KB

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