index.vue 9.1 KB

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