index.vue 9.5 KB

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