StoreDetail.vue 13 KB

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