store.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <div class="mobile-center">
  3. <div class="com-mobile-header mobile-center-header">
  4. <a @click="goBack()"><i class="iconfont icon-fanhui"></i></a>
  5. <p>店铺关注</p>
  6. <p class="en-name"><img :src="`/images/mobile/center/${user.data.enterprise.uu ? 'en' : 'self'}.png`" alt="">{{currentEnName}}</p>
  7. </div>
  8. <div class="mobile-content">
  9. <search-header :expandClass="'outClass'" @searchAction="onSearch" :useMatchRule="false" :outerKeyword="keyword" :placeholder="'店铺名/品牌/物料名称/型号'"></search-header>
  10. <div v-if="storeList.content.length" class="shop-list" v-bind:key="item.id" v-for="item in storeList.content" @click.prevent="goStoreDetail(item.uuid || item.storeInfo.uuid)">
  11. <h3>{{item.storeName}}</h3>
  12. <div class="list-item">
  13. <div class="item-img" v-if="item.storeInfo">
  14. <img :src="getBackground(item.storeInfo && item.storeInfo.type)" />
  15. <img :src="item.storeInfo.logoUrl || '/images/component/default.png'">
  16. </div>
  17. <div class="item-img" v-else>
  18. <img :src="getBackground(item.item)" />
  19. <img :src="item.logoUrl || '/images/component/default.png'">
  20. </div>
  21. <div class="list-item-phone" v-if="item.storeInfo">
  22. <!--电话:<a :href="'tel:' + item.enterprise.enTel" >{{item.enterprise.enTel}}</a>-->
  23. <p @click.stop="" v-if="item.storeInfo.enterprise.enTel">电话:<a :href="'tel:' + item.storeInfo.enterprise.enTel" >{{item.storeInfo.enterprise.enTel}}</a></p>
  24. <p v-else>电话:<span>{{item.storeInfo.enterprise.enTel || '-'}}</span></p>
  25. <p @click.stop="" v-if="item.storeInfo.enterprise.enPhone">手机:<a :href="'tel:' + item.storeInfo.enterprise.enPhone" >{{item.storeInfo.enterprise.enPhone}}</a></p>
  26. <p v-else>手机:<span>{{item.storeInfo.enterprise.enPhone || '-'}}</span></p>
  27. <p>传真:<span>{{item.storeInfo.enterprise.enFax || '-'}}</span></p>
  28. <!--<p>联系商家:<a @click="selectStoreInfo(item, $event)">点击查看</a></p>-->
  29. <!--<i class="iconfont icon-shoucang" @click.stop="cancelFocus(item, $event)" style="color:#2d8cf0">-->
  30. <span @click.stop="cancelFocus(item, $event)">
  31. <i class="iconfont icon-shoucang1" style="color:#2d8cf0"></i>
  32. <span class="focus">已关注</span>
  33. </span>
  34. <!--</i>-->
  35. </div>
  36. <div class="list-item-phone" v-else>
  37. <template v-if="item.enterprise">
  38. <!--电话:<a :href="'tel:' + item.enterprise.enTel" >{{item.enterprise.enTel}}</a>-->
  39. <p @click.stop="" v-if="item.enterprise.enTel">电话:<a :href="'tel:' + item.enterprise.enTel" >{{item.enterprise.enTel}}</a></p>
  40. <p v-else>电话:<span>{{item.enterprise.enTel || '-'}}</span></p>
  41. <p @click.stop="" v-if="item.enterprise.enPhone">手机:<a :href="'tel:' + item.enterprise.enPhone" >{{item.enterprise.enPhone}}</a></p>
  42. <p v-else>手机:<span>{{item.enterprise.enPhone || '-'}}</span></p>
  43. <p>传真:<span>{{item.enterprise.enFax || '-'}}</span></p>
  44. <!--<p>联系商家:<a @click="selectStoreInfo(item, $event)">点击查看</a></p>-->
  45. <span @click.stop="cancelFocus(item, $event, 'choose')">
  46. <i class="iconfont icon-shoucang1" :class="item.isFocus == 'true' ? 'icon-shoucang1' : 'icon-shoucang2'" :style="item.isFocus === 'true'?'color:#2d8cf0':''"></i>
  47. <span class="focus" v-text="item.isFocus == 'true' ? '已关注' : '未关注'" :class="item.isFocus == 'true' ? '' : 'right01'" >已关注</span>
  48. </span>
  49. </template>
  50. <!--<i class="iconfont icon-shoucang" :style="item.isFocus === 'true'?'color:#2d8cf0':'color:#bbb'"></i>-->
  51. </div>
  52. </div>
  53. </div>
  54. <empty-status v-if="!storeList.content.length" :type="'collect'" :showLink="true" :text="'抱歉,暂无店铺关注'"></empty-status>
  55. </div>
  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>商家地址:{{storeInfo.enAddress || storeInfo.address || '-'}}</div>-->
  61. <!--<div class="content-line link-url">在线咨询</div>-->
  62. <div v-if="storeInfo.enTel">致电:<a :href="'tel:' + storeInfo.enTel" target="_blank" class="content-line link-url">{{storeInfo.enTel || '-'}}</a></div>
  63. <div v-else>暂无联系方式</div>
  64. <!--<div>邮件:<a :href="'mailto:' + storeInfo.enEmail" target="_blank" class="content-line link-url">{{storeInfo.enEmail || '-'}}</a></div>-->
  65. </div>
  66. </div>
  67. </div>
  68. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  69. <pull-up :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="onPullUpAction"></pull-up>
  70. </div>
  71. </template>
  72. <script>
  73. import {SearchHeader} from '~components/mobile/base'
  74. import { RemindBox, PullUp, EmptyStatus } from '~components/mobile/common'
  75. import axios from '~plugins/axios'
  76. export default {
  77. middleware: 'authenticated',
  78. layout: 'mobileNoHeader',
  79. data () {
  80. return {
  81. remindText: '',
  82. timeoutCount: 0,
  83. page: 1,
  84. count: 10,
  85. isChange: false,
  86. storeList: [],
  87. showStoreInfo: false,
  88. storeInfo: {},
  89. keyword: '',
  90. field: '',
  91. searchShow: false
  92. }
  93. },
  94. // watch: {
  95. // 'storeCollectList.data': {
  96. // handler: function (val) {
  97. // if (this.isChange) {
  98. // this.storeList = val.content
  99. // this.isChange = false
  100. // } else {
  101. // this.storeList = [...this.storeList, ...val.content]
  102. // }
  103. // },
  104. // immediate: true
  105. // }
  106. // },
  107. computed: {
  108. storeCollectList () {
  109. return this.storeList
  110. },
  111. fetching () {
  112. return this.storeCollectList.fetching
  113. },
  114. allPage () {
  115. return Math.floor(this.storeCollectList.totalElements / this.storeCollectList.size) + Math.floor(this.storeCollectList.totalElements % this.storeCollectList.size > 0 ? 1 : 0)
  116. }
  117. },
  118. async asyncData() {
  119. let { data } = await axios.get(`/trade/storeFocus/page`, {params: { count: 10, page: 1 }})
  120. console.log(data)
  121. return {
  122. storeList: data
  123. }
  124. },
  125. components: {
  126. RemindBox,
  127. PullUp,
  128. EmptyStatus,
  129. SearchHeader
  130. },
  131. methods: {
  132. async goBack() {
  133. if (this.searchShow === true) {
  134. //这里 是测试语句
  135. this.searchShow = false
  136. this.keyword = ''
  137. let { data } = await this.$http.get(`/trade/storeFocus/page`, {params: { count: 10, page: 1 }})
  138. this.storeList = data
  139. } else {
  140. this.goLastPage()
  141. }
  142. },
  143. onSearch(keyObj) {
  144. if (keyObj.keyword === '') {
  145. this.onRemind('请输入搜索关键字')
  146. return
  147. }
  148. this.searchShow = true
  149. this.keyword = keyObj.keyword
  150. this.field = keyObj.type && keyObj.type !== 'store' ? keyObj.type : ''
  151. this.isChange = true
  152. this.down = false
  153. this.page = 1
  154. this.reloadData()
  155. },
  156. async reloadData () {
  157. let { data } = await this.$http.get('/api/store-service/stores', {params: { page: this.page, count: this.count, type: 'ORIGINAL_FACTORY-DISTRIBUTION-AGENCY-CONSIGNMENT', keyword: this.keyword || null, field: this.field, op: 'similar' }})
  158. let _pull = []
  159. for (let i = 0; i < data.content.length; i++) {
  160. _pull.push(findStoreFocusInMobil({id: data.content[i].id}))
  161. }
  162. Promise.all(_pull)
  163. .then(result => {
  164. if (result) {
  165. for (let i = 0; i < result.length; i++) {
  166. this.$set(data.content[i], 'isFocus', result[i] ? result[i].data : 'false')
  167. }
  168. }
  169. })
  170. this.storeList = data
  171. },
  172. onRemind: function (str) {
  173. this.remindText = str
  174. this.timeoutCount++
  175. },
  176. cancelFocus(item, event, _tp) {
  177. if (_tp) {
  178. if (item.isFocus === 'false') {
  179. this.$http.post('/trade/storeFocus/save', {storeName: item.storeName, storeid: item.id})
  180. .then(response => {
  181. item.isFocus = 'true'
  182. this.onRemind('关注成功')
  183. })
  184. } else {
  185. this.$http.post('/trade/storeFocus/delete/storeId', [item.id])
  186. .then(response => {
  187. item.isFocus = 'false'
  188. this.onRemind('取消成功')
  189. })
  190. }
  191. } else {
  192. event.stopPropagation()
  193. this.$http.post('/trade/storeFocus/delete/storeId', [item.storeid])
  194. .then(response => {
  195. this.onRemind('取消成功')
  196. this.isChange = true
  197. axios.get(`/trade/storeFocus/page`, {params: { count: 10, page: 1 }}).then(res => {
  198. this.storeList = res.data
  199. })
  200. }, err => {
  201. this.onRemind(err.response.data || '取消失败')
  202. })
  203. }
  204. },
  205. async reloadList() {
  206. if (this.searchShow) {
  207. let { data } = await this.$http.get('/api/store-service/stores', {params: { page: this.page, count: this.count, type: 'ORIGINAL_FACTORY-DISTRIBUTION-AGENCY-CONSIGNMENT', keyword: this.keyword || null, field: this.field, op: 'similar' }})
  208. let _pull = []
  209. for (let i = 0; i < data.content.length; i++) {
  210. _pull.push(findStoreFocusInMobil({id: data.content[i].id}))
  211. }
  212. Promise.all(_pull)
  213. .then(result => {
  214. if (result) {
  215. for (let i = 0; i < result.length; i++) {
  216. this.$set(data.content[i], 'isFocus', result[i] ? result[i].data : 'false')
  217. }
  218. }
  219. })
  220. this.storeList.content = [...this.storeList.content, ...data.content]
  221. } else {
  222. let { data } = await axios.get(`/trade/storeFocus/page`, {params: {count: 10, page: this.page}})
  223. this.storeList.content = [...this.storeList.content, ...data.content]
  224. }
  225. },
  226. onPullUpAction: function () {
  227. this.page++
  228. this.reloadList()
  229. },
  230. getBackground: function (type) {
  231. let url = ''
  232. if (type === 'AGENCY') {
  233. url += '/images/mobile/@2x/shop/agency.png'
  234. } else if (type === 'DISTRIBUTION') {
  235. url += '/images/mobile/@2x/shop/distribution.png'
  236. } else if (type === 'ORIGINAL_FACTORY') {
  237. url += '/images/mobile/@2x/shop/original_factory.png'
  238. } else if (type === 'CONSIGNMENT') {
  239. url = '/images/mobile/@2x/shop/consignment.png'
  240. }
  241. return url
  242. },
  243. goStoreDetail: function (uuid) {
  244. this.$router.push('/mobile/shop/' + uuid)
  245. },
  246. selectStoreInfo: function (store, event) {
  247. event.stopPropagation()
  248. this.storeInfo = store.storeInfo.enterprise || {}
  249. this.showStoreInfo = true
  250. },
  251. checkInfo: function (str) {
  252. return str && str.trim() !== ''
  253. }
  254. }
  255. }
  256. function findStoreFocusInMobil (store) {
  257. return axios.get('/trade/storeFocus/ifFocus?storeid=' + store.id)
  258. }
  259. </script>
  260. <style lang="scss" scoped>
  261. .mobile-content {
  262. padding-top: 1.26rem !important;
  263. }
  264. .mobile-content .com-mobile-header {
  265. position: relative;
  266. background: #fff;
  267. border-bottom: .1rem solid #dfe2e4;
  268. height: auto;
  269. padding: 0.25rem 0;
  270. line-height: normal;
  271. z-index: 1;
  272. }
  273. .shop-list {
  274. background:#fff;
  275. border-bottom: .1rem solid #dfe2e4;
  276. padding: .14rem 0 .14rem 0;
  277. &:first-child {
  278. border-top: .1rem solid #dfe2e4;
  279. }
  280. h3{
  281. font-size: .32rem;
  282. line-height: .4rem;
  283. margin: 0 0 0 .27rem;
  284. overflow: hidden;
  285. text-overflow: ellipsis;
  286. white-space: nowrap;
  287. padding-top: .1rem;
  288. position: relative;
  289. top: .1rem;
  290. }
  291. .list-item{
  292. width:6.77rem;
  293. margin-left:.39rem;
  294. .item-img{
  295. width:2.4rem;
  296. vertical-align: middle;
  297. display: inline-block;
  298. img{
  299. &:nth-child(2) {
  300. width:2.4rem;
  301. height:1.69rem;
  302. border: 1px solid #eee;
  303. }
  304. &:nth-child(1) {
  305. position:absolute;
  306. width:.65rem;
  307. height:.33rem;
  308. }
  309. }
  310. }
  311. .list-item-phone{
  312. width:3.95rem;
  313. padding:.18rem 0;
  314. position:relative;
  315. display: inline-block;
  316. vertical-align: middle;
  317. margin-left: .26rem;
  318. p{
  319. font-size:.28rem;
  320. line-height: .67rem;
  321. margin:0;
  322. overflow: hidden;
  323. text-overflow: ellipsis;
  324. white-space: nowrap;
  325. width: 3.2rem;
  326. }
  327. i{
  328. display:block;
  329. position:absolute;
  330. top: -.06rem;
  331. right: -.18rem;
  332. font-size:.5rem;
  333. width: .6rem;
  334. height: .6rem;
  335. text-align: center;
  336. line-height: .6rem;
  337. }
  338. span.focus{
  339. position: absolute;
  340. top: .55rem;
  341. right: -.28rem;
  342. font-size: .28rem;
  343. color: #008bf7;
  344. }
  345. }
  346. }
  347. &:active {
  348. background: #e1e1e1;
  349. }
  350. }
  351. </style>