StoreDetail.vue 13 KB

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