StoreDetail.vue 13 KB

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