StoreDetail.vue 12 KB

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