StoreDetail.vue 11 KB

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