StoreDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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'">
  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. showIcon() {
  159. return this.store.uuid !== this.$store.state.option.storeStatus.data.uuid
  160. }
  161. },
  162. methods: {
  163. scroll: function () {
  164. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  165. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchingMore && this.page < this.allPage && this.activeType === 'product') {
  166. this.getMoreCom()
  167. }
  168. let tbodyObj = document.getElementById('product-body')
  169. let theadObj = document.getElementById('product-head')
  170. if (theadObj) {
  171. this.isScrollOverTab = tbodyObj.getBoundingClientRect().top - theadObj.getBoundingClientRect().height - 5 <= theadObj.getBoundingClientRect().height
  172. }
  173. },
  174. getMoreCom: function () {
  175. if (!this.isSearchingMore) {
  176. this.page++
  177. this.isSearchingMore = true
  178. this.pageCommodity({ page: this.page, count: 6 })
  179. }
  180. },
  181. async pageCommodity (pageParams, kindId, keyword) {
  182. let params = { storeid: this.$route.params.uuid, origin: 'store', kindUuid: kindId, code: keyword }
  183. params.page = pageParams.page
  184. params.count = pageParams.count
  185. try {
  186. let { data } = await this.$http.get('/api/commodity/commodities', { params })
  187. this.$store.commit('shop/storeInfo/GET_STORE_COMMODITY_SUCCESS', data)
  188. } catch (err) {
  189. this.$store.commit('shop/storeInfo/GET_STORE_COMMODITY_FAILURE', err)
  190. }
  191. },
  192. goProductDetail: function (uuid) {
  193. if (uuid) {
  194. this.$router.push('/mobile/brand/componentDetail/' + uuid)
  195. } else {
  196. this.collectResult = '卖家上传的产品暂无参数,请联系卖家了解具体详情。'
  197. this.timeoutCount ++
  198. }
  199. },
  200. collectStore: function () {
  201. if (this.user.logged) {
  202. if (this.isFocus === 'false') {
  203. this.$store.dispatch('shop/StoreFocus', {storeName: this.store.storeName, storeid: this.store.id})
  204. .then(response => {
  205. this.$store.dispatch('shop/StoreFocusList', {id: this.store.id})
  206. this.collectResult = '收藏成功'
  207. this.timeoutCount++
  208. })
  209. } else if (this.isFocus === 'true') {
  210. this.$http.post('/trade/storeFocus/delete/storeId', [this.store.id])
  211. .then(response => {
  212. this.$store.dispatch('shop/StoreFocusList', {id: this.store.id})
  213. this.collectResult = '取消成功'
  214. this.timeoutCount++
  215. })
  216. }
  217. } else {
  218. this.showLoginBox = true
  219. }
  220. }
  221. }
  222. }
  223. </script>
  224. <style lang="scss" scoped>
  225. .store-detail {
  226. margin: 0 auto;
  227. margin-bottom: 1.2rem;
  228. text-align: center;
  229. background: #f7f7f7;
  230. height: 100%;
  231. .store-logo {
  232. height: 3.17rem;
  233. width: 6.96rem;
  234. display: inline-block;
  235. margin: .2rem auto;
  236. line-height: 2.13rem;
  237. background: #fff;
  238. text-align: center;
  239. border-radius: .1rem;
  240. background: url('/images/mobile/@2x/brand-bg.png') no-repeat;
  241. background-size: cover;
  242. .store-logo-box {
  243. border: .04rem solid #c7e5fd;
  244. border-radius: .1rem;
  245. height: 2.21rem;
  246. width: 3.73rem;
  247. margin: .5rem auto 0;
  248. background: #fff;
  249. position: relative;
  250. img {
  251. max-height: 2.1rem;
  252. max-width: 3.6rem;
  253. }
  254. >i {
  255. position: absolute;
  256. font-size: .4rem;
  257. background: #fff;
  258. width: .6rem;
  259. height: .6rem;
  260. line-height: .6rem;
  261. border-radius: 100%;
  262. box-shadow: 0 0 .05rem #aaa;
  263. right: -1.44rem;
  264. top: .75rem;
  265. text-align: center;
  266. }
  267. }
  268. }
  269. .store-switch-item {
  270. text-align: center;
  271. background: #fff;
  272. .mobile-switch-btn {
  273. background: #fff;
  274. color: #666;
  275. display: inline-block;
  276. height: .64rem;
  277. font-size: .34rem;
  278. line-height: .64rem;
  279. width: 1.4rem;
  280. &:first-child {
  281. margin-right: 1.78rem;
  282. }
  283. &.active {
  284. color: #fc5708;
  285. border-bottom: .04rem solid #fc5708;
  286. }
  287. }
  288. }
  289. .store-description {
  290. background: #f7f7f7;
  291. width: 100%;
  292. p {
  293. background: #fff;
  294. margin: .2rem auto 0;
  295. padding: .4rem .34rem;
  296. width: 100%;
  297. font-size: .3rem;
  298. color: #666;
  299. text-align: left;
  300. height: 95%;
  301. box-shadow: 0 .03rem .01rem 0 #cdcbcb96;
  302. line-height: .5rem;
  303. }
  304. }
  305. .product-store {
  306. margin: .2rem 0 0 0;
  307. table {
  308. width: 100%;
  309. font-size: .28rem;
  310. thead {
  311. background: #d5e5fb;
  312. &.active {
  313. position: fixed;
  314. top: .88rem;
  315. z-index: 2;
  316. }
  317. tr {
  318. th {
  319. font-weight: bold;
  320. text-align: center;
  321. height: .78rem;
  322. line-height: .78rem;
  323. }
  324. }
  325. }
  326. tbody {
  327. tr {
  328. background: #fff;
  329. border-bottom: 0.2rem solid #f7f7f7;
  330. td {
  331. padding: .2rem .1rem;
  332. text-align: left;
  333. &.price-level-wrap {
  334. text-align: center;
  335. }
  336. div {
  337. overflow: hidden;
  338. text-overflow: ellipsis;
  339. white-space: nowrap;
  340. margin-bottom: .2rem;
  341. max-width: 1.58rem;
  342. &:last-child {
  343. margin-bottom: 0;
  344. }
  345. }
  346. .price-level:last-child {
  347. color: #fc5708;
  348. }
  349. .price-number {
  350. display: inline-block;
  351. vertical-align: middle;
  352. margin-bottom: 0;
  353. width: .9rem;
  354. }
  355. .order-tag {
  356. display: inline-block;
  357. font-size: .18rem;
  358. color: #fff;
  359. font-weight: bold;
  360. background: #ee1717;
  361. height: .27rem;
  362. width: .27rem;
  363. line-height: .27rem;
  364. text-align: center;
  365. border-radius: .05rem;
  366. position: relative;
  367. top: -.05rem;
  368. margin-right: .05rem;
  369. &.reserve-tag {
  370. background: #07bb1c;
  371. }
  372. }
  373. }
  374. &:active {
  375. background: #e1e1e1;
  376. }
  377. }
  378. }
  379. }
  380. .no-store {
  381. background: #fff;
  382. padding-top: 1rem;
  383. img {
  384. display: block;
  385. text-align: center;
  386. margin: 0 auto;
  387. margin-bottom: .45rem;
  388. width: 3.31rem;
  389. height: 2.13rem;
  390. }
  391. div {
  392. width: 5.27rem;
  393. margin: 0 auto;
  394. text-align: center;
  395. line-height: .4rem;
  396. color: #999;
  397. .link-url {
  398. color: #01a44e;
  399. }
  400. }
  401. }
  402. }
  403. .no-product {
  404. background: #fff;
  405. padding-top: 1rem;
  406. img {
  407. display: block;
  408. text-align: center;
  409. margin: 0 auto;
  410. margin-bottom: .45rem;
  411. width: 3.31rem;
  412. height: 2.13rem;
  413. }
  414. div {
  415. width: 5.27rem;
  416. margin: 0 auto;
  417. text-align: center;
  418. line-height: .4rem;
  419. font-size: .32rem;
  420. color: #999;
  421. }
  422. }
  423. }
  424. </style>