StoreDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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=='detail'?'mobile-switch-btn active':'mobile-switch-btn'" @click="activeType='detail'">介绍</span>
  11. <span :class="activeType=='product'?'mobile-switch-btn active':'mobile-switch-btn'" @click="activeType='product'">产品</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>
  21. <tr>
  22. <th>型号/品牌</th>
  23. <th>包装</th>
  24. <th>数量</th>
  25. <th>单价</th>
  26. <th>交期(天)</th>
  27. </tr>
  28. </thead>
  29. <tbody>
  30. <tr v-for="commodity in searchLists" @click="goProductDetail(commodity.uuid)">
  31. <td class="store-name">
  32. <div>{{commodity.code}}</div>
  33. <div>{{commodity.brandNameCn}}</div>
  34. </td>
  35. <td>
  36. <div v-if="!commodity.packaging && !commodity.breakUp && !commodity.produceDate">-</div>
  37. <div>{{commodity.packaging}}</div>
  38. <div>{{commodity.breakUp?'可拆卖':'不可拆卖'}}</div>
  39. <div>{{commodity.produceDate}}</div>
  40. </td>
  41. <td>
  42. <div v-if="!commodity.prices || commodity.prices.length == 0">-</div>
  43. <div v-for="price in commodity.prices">{{price.start}}+</div>
  44. </td>
  45. <td>
  46. <div v-if="!commodity.prices || commodity.prices.length == 0">
  47. <span>—</span>
  48. </div>
  49. <div v-for="price in commodity.prices" class="price-level">
  50. <span v-if="commodity.currencyName.indexOf('RMB')!==-1">¥{{price.rMBPrice | currency}}</span>
  51. <span v-if="commodity.currencyName.indexOf('USD')!==-1">${{price.uSDPrice | currency}}</span>
  52. </div>
  53. </td>
  54. <td>
  55. <div v-if="commodity.b2cMinDelivery">
  56. <span>{{commodity.b2cMinDelivery}}</span>
  57. <span v-if="commodity.b2cMaxDelivery && commodity.b2cMaxDelivery !== commodity.b2cMinDelivery">-</span>
  58. <span v-if="commodity.b2cMaxDelivery && commodity.b2cMaxDelivery !== commodity.b2cMinDelivery">{{commodity.b2cMaxDelivery}}</span>
  59. </div>
  60. <div v-if="commodity.minBuyQty"><span class="order-tag">订</span>{{commodity.minBuyQty}}起订</div>
  61. <div v-if="!commodity.b2cMinDelivery">
  62. <span>—</span>
  63. </div>
  64. </td>
  65. </tr>
  66. </tbody>
  67. </table>
  68. <div v-if="!commodities.content || commodities.content.length == 0" class="no-product">
  69. <img src="/images/mobile/@2x/car@2x.png" alt="">
  70. <div>抱歉,暂无产品信息</div>
  71. </div>
  72. </div>
  73. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  74. <loading v-show="isSearchingMore"></loading>
  75. <login-box @onLoginBoxClose="showLoginBox = false" v-if="showLoginBox"></login-box>
  76. </div>
  77. </template>
  78. <script>
  79. import {RemindBox, Loading, LoginBox} from '~components/mobile/common'
  80. export default {
  81. data () {
  82. return {
  83. activeType: 'detail',
  84. collectResult: '收藏成功',
  85. timeoutCount: 0,
  86. isSearchingMore: false,
  87. searchLists: [],
  88. page: 1,
  89. showLoginBox: 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. },
  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. tr {
  293. th {
  294. font-weight: bold;
  295. text-align: center;
  296. height: .78rem;
  297. line-height: .78rem;
  298. }
  299. }
  300. }
  301. tbody {
  302. tr {
  303. background: #fff;
  304. border-bottom: 0.2rem solid #f7f7f7;
  305. td {
  306. padding: .2rem .1rem;
  307. text-align: left;
  308. div {
  309. overflow: hidden;
  310. text-overflow: ellipsis;
  311. white-space: nowrap;
  312. margin-bottom: .2rem;
  313. max-width: 1.58rem;
  314. &:last-child {
  315. margin-bottom: 0;
  316. }
  317. }
  318. .price-level:last-child {
  319. color: #fc5708;
  320. }
  321. .order-tag {
  322. display: inline-block;
  323. font-size: .18rem;
  324. color: #fff;
  325. font-weight: bold;
  326. background: #ee1717;
  327. height: .27rem;
  328. width: .27rem;
  329. line-height: .27rem;
  330. text-align: center;
  331. border-radius: .05rem;
  332. position: relative;
  333. top: -.03rem;
  334. }
  335. }
  336. &:active {
  337. background: #e1e1e1;
  338. }
  339. }
  340. }
  341. }
  342. .no-store {
  343. background: #fff;
  344. padding-top: 1rem;
  345. img {
  346. display: block;
  347. text-align: center;
  348. margin: 0 auto;
  349. margin-bottom: .45rem;
  350. width: 3.31rem;
  351. height: 2.13rem;
  352. }
  353. div {
  354. width: 5.27rem;
  355. margin: 0 auto;
  356. text-align: center;
  357. line-height: .4rem;
  358. color: #999;
  359. .link-url {
  360. color: #01a44e;
  361. }
  362. }
  363. }
  364. }
  365. .no-product {
  366. background: #fff;
  367. padding-top: 1rem;
  368. img {
  369. display: block;
  370. text-align: center;
  371. margin: 0 auto;
  372. margin-bottom: .45rem;
  373. width: 3.31rem;
  374. height: 2.13rem;
  375. }
  376. div {
  377. width: 5.27rem;
  378. margin: 0 auto;
  379. text-align: center;
  380. line-height: .4rem;
  381. font-size: .32rem;
  382. color: #999;
  383. }
  384. }
  385. }
  386. </style>