index.vue 13 KB

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