index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <div class="shop">
  3. <div class="shop-top">
  4. <p><i class="iconfont icon-dianpu1"></i><span>{{list.totalElements}}</span>家店铺</p>
  5. <span @click="onClick()">{{downName}} <i class="iconfont icon-arrow-down"></i></span>
  6. <ul class="supdown" v-if="down">
  7. <li @click="onDown('ORIGINAL_FACTORY-DISTRIBUTION-AGENCY' )" v-show="downName !== '全部'">全部</li>
  8. <li @click="onDown('ORIGINAL_FACTORY')" v-show="downName !== '原厂'">原厂</li>
  9. <li @click="onDown('AGENCY')" v-show="downName !== '代理'">代理</li>
  10. <li @click="onDown('DISTRIBUTION')" v-show="downName !== '经销'">经销</li>
  11. </ul>
  12. </div>
  13. <div class="shop-list" v-for="item in searchLists" @click="goStoreDetail(item.uuid)">
  14. <h3>{{item.storeName}}</h3>
  15. <div class="list-item">
  16. <div class="item-img">
  17. <i :style="'background:url(' + isType(item.type) + ')no-repeat 0 0/.65rem .33rem;'"></i>
  18. <img :src="item.logoUrl || '/images/component/default.png'">
  19. </div>
  20. <div class="list-item-phone">
  21. <p>电话:<span>{{item.enterprise.enTel}}</span></p>
  22. <p>传真:<span>{{item.enterprise.enFax}}</span></p>
  23. <!--<p>商家介绍: <nuxt-link :to="'/mobile/merchantDescription/'+item.uuid">点击查看</nuxt-link></p>-->
  24. <i class="iconfont icon-shoucang" :style="item.isFocus=='true'?'color:#ff7800':'color:#bbb'" @click="focusStore(item, $event)"></i>
  25. </div>
  26. </div>
  27. </div>
  28. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  29. <loading v-show="isSearchingMore"></loading>
  30. </div>
  31. </template>
  32. <script>
  33. import {RemindBox, Loading} from '~components/mobile/common'
  34. export default {
  35. layout: 'mobile',
  36. data () {
  37. return {
  38. page: 1,
  39. count: 10,
  40. types: 'ORIGINAL_FACTORY-DISTRIBUTION-AGENCY',
  41. down: false,
  42. downName: '全部',
  43. isFocus: true,
  44. collectResult: '收藏成功',
  45. timeoutCount: 0,
  46. isSearchingMore: false,
  47. searchLists: [],
  48. isChange: false
  49. }
  50. },
  51. components: {
  52. RemindBox,
  53. Loading
  54. },
  55. fetch ({ store }) {
  56. return Promise.all([
  57. store.dispatch('provider/findStoreListInMobil', { page: 1, count: 10, types: 'ORIGINAL_FACTORY-DISTRIBUTION-AGENCY' })
  58. ])
  59. },
  60. computed: {
  61. list () {
  62. let list = this.$store.state.provider.stores.storeList.data
  63. if (this.isChange) {
  64. this.searchLists = []
  65. this.page = 1
  66. this.isChange = false
  67. } else {
  68. this.searchLists = this.searchLists.concat(list.content)
  69. this.isSearchingMore = false
  70. }
  71. return list
  72. },
  73. allPage () {
  74. return this.list.totalPages
  75. }
  76. },
  77. mounted: function () {
  78. let _this = this
  79. _this.$nextTick(function () {
  80. window.addEventListener('scroll', function () {
  81. _this.scroll()
  82. }, false)
  83. })
  84. },
  85. methods: {
  86. scroll: function () {
  87. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  88. if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchingMore && this.page < this.allPage) {
  89. this.getMoreStore()
  90. }
  91. },
  92. getMoreStore: function () {
  93. if (!this.isSearchingMore) {
  94. this.page++
  95. this.isSearchingMore = true
  96. this.$store.dispatch('provider/findStoreListInMobil', { page: this.page, count: this.count, types: this.types })
  97. }
  98. },
  99. isType (type) {
  100. let bgurl = ''
  101. if (type === 'ORIGINAL_FACTORY') {
  102. bgurl = '/images/mobile/@2x/shop/yuanchang@2x.png'
  103. }
  104. if (type === 'DISTRIBUTION') {
  105. bgurl = '/images/mobile/@2x/shop/jingxiao@2x.png'
  106. }
  107. if (type === 'AGENCY') {
  108. bgurl = '/images/mobile/@2x/shop/daili@2x.png'
  109. }
  110. return bgurl
  111. },
  112. onClick () {
  113. this.down = !this.down
  114. },
  115. onDown (type) {
  116. this.isChange = true
  117. this.down = !this.down
  118. this.types = type
  119. if (type === 'ORIGINAL_FACTORY') {
  120. this.downName = '原厂'
  121. } else if (type === 'DISTRIBUTION') {
  122. this.downName = '经销'
  123. } else if (type === 'AGENCY') {
  124. this.downName = '代理'
  125. } else if (type === 'ORIGINAL_FACTORY-DISTRIBUTION-AGENCY') {
  126. this.downName = '全部'
  127. }
  128. this.$store.dispatch('provider/findStoreListInMobil', { page: 1, count: 10, types: type })
  129. },
  130. focusStore: function (item, $event) {
  131. // item.isFocus = item.isFocus === 'false' ? 'true' : 'false'
  132. $event.stopPropagation()
  133. if (item.isFocus === 'false') {
  134. this.$http.post('/trade/storeFocus/save', {storeName: item.storeName, storeid: item.id})
  135. .then(response => {
  136. item.isFocus = 'true'
  137. this.collectResult = '收藏成功'
  138. this.timeoutCount++
  139. })
  140. } else {
  141. this.$http.post('/trade/storeFocus/delete/storeId', [item.id])
  142. .then(response => {
  143. item.isFocus = 'false'
  144. this.collectResult = '取消成功'
  145. this.timeoutCount++
  146. })
  147. }
  148. },
  149. goStoreDetail: function (uuid) {
  150. this.$router.push('/mobile/shop/' + uuid)
  151. }
  152. }
  153. }
  154. </script>
  155. <style scoped lang="scss">
  156. .shop{
  157. margin-bottom: .98rem;
  158. min-height: 10rem;
  159. background: #e2e4e6;
  160. .shop-top{
  161. display:inline-flex;
  162. justify-content: space-between;
  163. align-items: center;
  164. width:100%;
  165. height:1.14rem;
  166. padding:0 .3rem;
  167. position:relative;
  168. background:#fff;
  169. .supdown{
  170. position:absolute;
  171. top:.8rem;
  172. right:.2rem;
  173. z-index:100;
  174. background:#616264;
  175. border-radius:.1rem;
  176. li{
  177. font-size: .28rem;
  178. color:#ffffff;
  179. height: .32rem;
  180. line-height: .32rem;
  181. margin: .4rem .3rem;
  182. }
  183. }
  184. p{
  185. font-size:.24rem;
  186. color:#000;
  187. i{
  188. font-size: .53rem;
  189. color:#418ef7;
  190. }
  191. span{
  192. font-size:.3rem;
  193. color:#f94f28;
  194. margin:0 .1rem;
  195. }
  196. }
  197. >span{
  198. font-size:.28rem;
  199. color:#53a0f7;
  200. }
  201. }
  202. .shop-list {
  203. background:#fff;
  204. margin-top:.12rem;
  205. padding-bottom:.28rem;
  206. /*&:hover{*/
  207. /*background: #e1e1e1;*/
  208. /*}*/
  209. h3{
  210. font-size:.32rem;
  211. line-height: .8rem;
  212. margin:0;
  213. margin-left:.27rem;
  214. margin-bottom:.14rem;
  215. }
  216. .list-item{
  217. width:6.77rem;
  218. margin-left:.39rem;
  219. justify-content: space-around;
  220. display:inline-flex;
  221. .item-img{
  222. position:relative;
  223. width:2.42rem;
  224. height:1.69rem;
  225. i{
  226. display:block;
  227. position:absolute;
  228. width:.65rem;
  229. height:.33rem;
  230. }
  231. img{
  232. display:inline-block;
  233. width:100%;
  234. height:100%;
  235. border:.02rem solid #eee;
  236. }
  237. }
  238. .list-item-phone{
  239. width:3.95rem;
  240. padding:.18rem 0;
  241. position:relative;
  242. p{
  243. font-size:.28rem;
  244. line-height: .67rem;
  245. margin:0;
  246. overflow: hidden;
  247. text-overflow: ellipsis;
  248. white-space: nowrap;
  249. width: 3.2rem;
  250. }
  251. i{
  252. display:block;
  253. position:absolute;
  254. top: 0;
  255. right: 0;
  256. font-size:.4rem;
  257. color:#ff7800;
  258. }
  259. i.active{
  260. color:#333;
  261. }
  262. }
  263. }
  264. &:active {
  265. background: #e1e1e1;
  266. }
  267. }
  268. }
  269. </style>