index.vue 10 KB

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