index.vue 13 KB

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