index.vue 12 KB

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