store.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div class="mobile-center">
  3. <div class="com-mobile-header">
  4. <a @click="goLastPage"><i class="iconfont icon-fanhui"></i></a>
  5. <p>店铺关注</p>
  6. </div>
  7. <div class="mobile-content">
  8. <div v-if="storeList.length" class="shop-list" v-bind:key="item.id" v-for="item in storeList" @click="goStoreDetail(item.storeInfo.uuid)">
  9. <h3>{{item.storeName}}</h3>
  10. <div class="list-item">
  11. <div class="item-img">
  12. <img :src="getBackground(item.storeInfo.type)" />
  13. <img :src="item.storeInfo.logoUrl || '/images/component/default.png'">
  14. </div>
  15. <div class="list-item-phone">
  16. <p>电话:<span>{{item.storeInfo.enterprise ? item.storeInfo.enterprise.enTel : '-'}}</span></p>
  17. <p>传真:<span>{{item.storeInfo.enterprise ? item.storeInfo.enterprise.enFax : '-'}}</span></p>
  18. <p>联系商家:<a @click="selectStoreInfo(item, $event)">点击查看</a></p>
  19. <i class="iconfont icon-shoucang" @click="cancelFocus(item, $event)"></i>
  20. </div>
  21. </div>
  22. </div>
  23. <empty-status v-if="!storeList.length" :type="'collect'" :showLink="true" :text="'抱歉,暂无店铺关注'"></empty-status>
  24. </div>
  25. <div class="mobile-modal" v-if="showStoreInfo" @touchmove="preventTouchMove($event)">
  26. <div class="mobile-modal-box">
  27. <div class="mobile-modal-header">联系方式<i @click="showStoreInfo = false" class="icon-guanbi iconfont"></i></div>
  28. <div class="mobile-modal-content">
  29. <div>商家地址:{{storeInfo.enAddress || storeInfo.address || '-'}}</div>
  30. <!--<div class="content-line link-url">在线咨询</div>-->
  31. <div>致电:<a :href="'tel:' + storeInfo.enTel" target="_blank" class="content-line link-url">{{storeInfo.enTel || '-'}}</a></div>
  32. <div>邮件:<a :href="'mailto:' + storeInfo.enEmail" target="_blank" class="content-line link-url">{{storeInfo.enEmail || '-'}}</a></div>
  33. </div>
  34. </div>
  35. </div>
  36. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  37. <pull-up :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="onPullUpAction"></pull-up>
  38. </div>
  39. </template>
  40. <script>
  41. import { RemindBox, PullUp, EmptyStatus } from '~components/mobile/common'
  42. export default {
  43. middleware: 'authenticated',
  44. layout: 'mobileNoHeader',
  45. data () {
  46. return {
  47. remindText: '',
  48. timeoutCount: 0,
  49. page: 1,
  50. count: 10,
  51. isChange: false,
  52. storeList: [],
  53. showStoreInfo: false,
  54. storeInfo: {}
  55. }
  56. },
  57. watch: {
  58. 'storeCollectList.data': {
  59. handler: function (val) {
  60. if (this.isChange) {
  61. this.storeList = val.content
  62. this.isChange = false
  63. } else {
  64. this.storeList = [...this.storeList, ...val.content]
  65. }
  66. },
  67. immediate: true
  68. }
  69. },
  70. computed: {
  71. storeCollectList () {
  72. return this.$store.state.shop.storeInfo.focusPage
  73. },
  74. fetching () {
  75. return this.storeCollectList.fetching
  76. },
  77. allPage () {
  78. return Math.floor(this.storeCollectList.data.totalElements / this.storeCollectList.data.size) + Math.floor(this.storeCollectList.data.totalElements % this.storeCollectList.data.size > 0 ? 1 : 0)
  79. }
  80. },
  81. fetch ({ store }) {
  82. return Promise.all([
  83. // 获取店铺关注列表
  84. store.dispatch('shop/StoreFocusPage', { count: 10, page: 1 })
  85. ])
  86. },
  87. components: {
  88. RemindBox,
  89. PullUp,
  90. EmptyStatus
  91. },
  92. methods: {
  93. onRemind: function (str) {
  94. this.remindText = str
  95. this.timeoutCount++
  96. },
  97. cancelFocus: function (item, event) {
  98. event.stopPropagation()
  99. this.$http.post('/trade/storeFocus/delete/storeId', [item.storeid])
  100. .then(response => {
  101. this.onRemind('取消收藏成功')
  102. this.isChange = true
  103. this.page = 1
  104. this.reloadList()
  105. }, err => {
  106. this.onRemind(err.response.data || '取消收藏失败')
  107. })
  108. },
  109. reloadList: function () {
  110. this.$store.dispatch('shop/StoreFocusPage', { count: this.count, page: this.page })
  111. },
  112. onPullUpAction: function () {
  113. this.page++
  114. this.reloadList()
  115. },
  116. getBackground: function (type) {
  117. let url = ''
  118. if (type === 'AGENCY') {
  119. url += '/images/mobile/@2x/shop/agency.png'
  120. } else if (type === 'DISTRIBUTION') {
  121. url += '/images/mobile/@2x/shop/distribution.png'
  122. } else if (type === 'ORIGINAL_FACTORY') {
  123. url += '/images/mobile/@2x/shop/original_factory.png'
  124. } else if (type === 'CONSIGNMENT') {
  125. url = '/images/mobile/@2x/shop/consignment.png'
  126. }
  127. return url
  128. },
  129. goStoreDetail: function (uuid) {
  130. this.$router.push('/mobile/shop/' + uuid)
  131. },
  132. selectStoreInfo: function (store, event) {
  133. event.stopPropagation()
  134. this.storeInfo = store.storeInfo.enterprise || {}
  135. this.showStoreInfo = true
  136. },
  137. checkInfo: function (str) {
  138. return str && str.trim() !== ''
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. .shop-list {
  145. background:#fff;
  146. border-bottom: .1rem solid #dfe2e4;
  147. padding: .14rem 0 .14rem 0;
  148. &:first-child {
  149. border-top: .1rem solid #dfe2e4;
  150. }
  151. h3{
  152. font-size: .32rem;
  153. line-height: .4rem;
  154. margin: 0 0 0 .27rem;
  155. overflow: hidden;
  156. text-overflow: ellipsis;
  157. white-space: nowrap;
  158. padding-top: .1rem;
  159. position: relative;
  160. top: .1rem;
  161. }
  162. .list-item{
  163. width:6.77rem;
  164. margin-left:.39rem;
  165. .item-img{
  166. width:2.4rem;
  167. vertical-align: middle;
  168. display: inline-block;
  169. img{
  170. &:nth-child(2) {
  171. width:2.4rem;
  172. height:1.69rem;
  173. border: 1px solid #eee;
  174. }
  175. &:nth-child(1) {
  176. position:absolute;
  177. width:.65rem;
  178. height:.33rem;
  179. }
  180. }
  181. }
  182. .list-item-phone{
  183. width:3.95rem;
  184. padding:.18rem 0;
  185. position:relative;
  186. display: inline-block;
  187. vertical-align: middle;
  188. margin-left: .26rem;
  189. p{
  190. font-size:.28rem;
  191. line-height: .67rem;
  192. margin:0;
  193. overflow: hidden;
  194. text-overflow: ellipsis;
  195. white-space: nowrap;
  196. width: 3.2rem;
  197. }
  198. i{
  199. display:block;
  200. position:absolute;
  201. top: -.06rem;
  202. right: -.18rem;
  203. font-size:.5rem;
  204. color:#ff7800;
  205. width: .6rem;
  206. height: .6rem;
  207. text-align: center;
  208. line-height: .6rem;
  209. }
  210. }
  211. }
  212. &:active {
  213. background: #e1e1e1;
  214. }
  215. }
  216. </style>