index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <div class="user-content">
  3. <div class="user-name">
  4. <img src="/images/component/default.png"/>
  5. <div class="user-info">
  6. <p v-text="userInfo.data.userName"></p>
  7. <p v-text="enterpriseInfo.enName"></p>
  8. </div>
  9. <span @click="onclick()">{{listName}}<i class="iconfont icon-arrow-down"></i></span>
  10. <ul class="supdown" v-if="down">
  11. <li @click="onDown('1')" v-show="!isDevice || !isShop">全部收藏</li>
  12. <li @click="onDown('-1')" v-show="isDevice || !isShop">店铺关注</li>
  13. <li @click="onDown('0')" v-show="!isDevice || isShop">器件收藏</li>
  14. </ul>
  15. </div>
  16. <div class="collect-list-type" v-if="focusPage.totalElements > 0 && isShop">
  17. <p>店铺</p>
  18. </div>
  19. <div class="shop-list" v-if="isShop" v-for="item in focusPage.content" @click="goStoreDetail(item.storeInfo.uuid)">
  20. <h3>{{item.storeName}}</h3>
  21. <div class="list-item">
  22. <div class="item-img">
  23. <img :src="getBackground(item.storeInfo.type)" />
  24. <img :src="item.storeInfo.logoUrl || '/images/component/default.png'">
  25. </div>
  26. <div class="list-item-phone">
  27. <p>电话:<span>{{item.storeInfo.enterprise.enTel}}</span></p>
  28. <p>传真:<span>{{item.storeInfo.enterprise.enFax}}</span></p>
  29. <p>联系商家:<a @click="selectStoreInfo(item, $event)">点击查看</a></p>
  30. <i class="iconfont icon-shoucang" @click="cancelFocus('store', item, $event)"></i>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="collect-list-type" v-if="collectSave.totalElements > 0 && isDevice">
  35. <p>器件</p>
  36. </div>
  37. <div class="detail-brand" v-for="(item, index) in collectSave.content" v-if="isDevice" @click="goComponentDetail(item.componentinfo.uuid)">
  38. <a>
  39. <div class="brand-item">
  40. <p>型号:<span>{{item.componentinfo.code}}</span></p>
  41. <p>品牌:<span>{{item.componentinfo.brand.nameCn}}</span></p>
  42. <p>产品描述:<span>{{item.componentinfo.kind.nameCn}}</span></p>
  43. <i class="iconfont icon-shoucang" @click="cancelFocus('product', item, $event)"></i>
  44. </div>
  45. </a>
  46. </div>
  47. <div class="none-state" v-if="(collectSave.totalElements == 0 && !isShop) || (focusPage.totalElements == 0 && !isDevice) || (collectSave.totalElements == 0 && focusPage.totalElements == 0)">
  48. <img src="/images/mobile/@2x/empty-collect.png">
  49. <p v-text="getRemindText()"></p>
  50. <nuxt-link to="/">返回首页</nuxt-link>
  51. </div>
  52. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  53. <div class="mobile-modal" v-if="showStoreInfo">
  54. <div class="mobile-modal-box">
  55. <div class="mobile-modal-header">联系方式<i @click="showStoreInfo = false" class="icon-guanbi iconfont"></i></div>
  56. <div class="mobile-modal-content">
  57. <div v-if="checkInfo(storeInfo.enAddress || storeInfo.address)">商家地址:{{storeInfo.enAddress || storeInfo.address}}</div>
  58. <!--<div class="content-line link-url">在线咨询</div>-->
  59. <div v-if="checkInfo(storeInfo.enTel)">致电:<a :href="'tel:' + storeInfo.enTel" target="_blank" class="content-line link-url">{{storeInfo.enTel}}</a></div>
  60. <div v-if="checkInfo(storeInfo.enEmail)">邮件:<a :href="'mailto:' + storeInfo.enEmail" target="_blank" class="content-line link-url">{{storeInfo.enEmail}}</a></div>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import RemindBox from '~components/mobile/common/RemindBox.vue'
  68. export default {
  69. layout: 'mobile',
  70. data () {
  71. return {
  72. userName: '',
  73. down: false,
  74. count: '',
  75. page: '',
  76. type: '',
  77. listName: '全部收藏',
  78. isShop: true,
  79. isDevice: true,
  80. collectResult: '取消成功',
  81. timeoutCount: 0,
  82. showStoreInfo: false,
  83. storeInfo: {}
  84. }
  85. },
  86. components: {
  87. RemindBox
  88. },
  89. fetch ({ store }) {
  90. return Promise.all([
  91. store.dispatch('product/saveStores', { count: 100, page: 1, type: 'component' }),
  92. store.dispatch('shop/StoreFocusPage', { count: 100, page: 1 })
  93. ])
  94. },
  95. methods: {
  96. onclick () {
  97. this.down = !this.down
  98. },
  99. onDown (type) {
  100. if (type === '-1') {
  101. this.listName = '店铺关注'
  102. this.isShop = true
  103. this.isDevice = false
  104. this.down = false
  105. }
  106. if (type === '0') {
  107. this.listName = '器件收藏'
  108. this.isDevice = true
  109. this.isShop = false
  110. this.down = false
  111. }
  112. if (type === '1') {
  113. this.listName = '全部收藏'
  114. this.isDevice = true
  115. this.isShop = true
  116. this.down = false
  117. }
  118. },
  119. cancelFocus: function (type, item, event) {
  120. event.stopPropagation()
  121. if (type === 'store') {
  122. this.$http.post('/trade/storeFocus/delete/storeId', [item.storeid])
  123. .then(response => {
  124. this.$store.dispatch('shop/StoreFocusPage', { count: 100, page: 1 })
  125. this.timeoutCount++
  126. })
  127. } else {
  128. // /trade/collection/
  129. this.$http.delete('/trade/collection/' + item.id)
  130. .then(response => {
  131. this.$store.dispatch('product/saveStores', { count: 100, page: 1, type: 'component' })
  132. this.timeoutCount++
  133. })
  134. }
  135. },
  136. getBackground: function (type) {
  137. let url = ''
  138. if (type === 'AGENCY') {
  139. url += '/images/mobile/@2x/shop/daili@2x.png'
  140. } else if (type === 'DISTRIBUTION') {
  141. url += '/images/mobile/@2x/shop/jingxiao@2x.png'
  142. } else if (type === 'ORIGINAL_FACTORY') {
  143. url += '/images/mobile/@2x/shop/yuanchang@2x.png'
  144. }
  145. return url
  146. },
  147. goStoreDetail: function (uuid) {
  148. this.$router.push('/mobile/shop/' + uuid)
  149. },
  150. goComponentDetail: function (uuid) {
  151. this.$router.push('/mobile/brand/componentDetail/' + uuid)
  152. },
  153. getRemindText: function () {
  154. if (this.isDevice && !this.isShop) {
  155. return '抱歉,暂无器件收藏'
  156. } else if (!this.isDevice && this.isShop) {
  157. return '抱歉,暂无店铺关注'
  158. } else {
  159. return '抱歉,暂无收藏记录'
  160. }
  161. },
  162. selectStoreInfo: function (store, event) {
  163. event.stopPropagation()
  164. this.storeInfo = store.storeInfo.enterprise || {}
  165. this.showStoreInfo = true
  166. },
  167. checkInfo: function (str) {
  168. return str && str.trim() !== ''
  169. }
  170. },
  171. computed: {
  172. collectSave () {
  173. return this.$store.state.product.common.collectList.data
  174. },
  175. userInfo () {
  176. return this.$store.state.option.user
  177. },
  178. enterpriseInfo () {
  179. let ens = this.userInfo.data.enterprises
  180. // if (ens && ens.length) {
  181. // return ens.find(item => item.current) || {enName: this.userInfo.data.userName + '(个人账户)'}
  182. // } else {
  183. // return {enName: this.userInfo.data.userName + '(个人账户)'}
  184. // }
  185. if (ens && ens.length) {
  186. for (let i = 0; i < ens.length; i++) {
  187. if (ens[i].current) {
  188. return ens[i]
  189. }
  190. }
  191. }
  192. return {enName: this.userInfo.data.userName + '(个人账户)'}
  193. },
  194. focusPage () {
  195. return this.$store.state.shop.storeInfo.focusPage.data
  196. }
  197. }
  198. }
  199. </script>
  200. <style scoped lang="scss">
  201. .user-content{
  202. margin-bottom: .98rem;
  203. background: #dfe2e4;
  204. .none-state{
  205. text-align: center;
  206. padding:1.5rem 0;
  207. background: #fff;
  208. margin-top:.1rem;
  209. width:100%;
  210. img{
  211. margin:0 auto;
  212. width: 4.08rem;
  213. height: 2.62rem;
  214. }
  215. p {
  216. font-size: .32rem;
  217. color: #999;
  218. margin: 1.19rem 0 0 0;
  219. }
  220. a {
  221. display: block;
  222. font-size: .28rem;
  223. color: #fff;
  224. width: 1.88rem;
  225. height: .54rem;
  226. line-height: .54rem;
  227. background: #418bf6;
  228. margin: .7rem auto 0;
  229. border-radius: .05rem;
  230. }
  231. }
  232. .user-name{
  233. padding:.14rem 0 .2rem .34rem;
  234. background:#fff;
  235. width:100%;
  236. position:relative;
  237. border-bottom: .1rem solid #dfe2e4;
  238. .supdown{
  239. position:absolute;
  240. top:.8rem;
  241. right:.3rem;
  242. z-index:10;
  243. width:1.7rem;
  244. background:#616264;
  245. border-radius:.1rem;
  246. li{
  247. font-size: .28rem;
  248. color:#ffffff;
  249. height: .32rem;
  250. line-height: .32rem;
  251. margin: .4rem 0;
  252. text-align: center;
  253. }
  254. }
  255. img{
  256. display: inline-block;
  257. width:1.25rem;
  258. height:1.25rem;
  259. border:.04rem solid #c5dbfc;
  260. border-radius: .05rem;
  261. vertical-align: middle;
  262. }
  263. .user-info {
  264. margin-left:.25rem;
  265. display: inline-block;
  266. vertical-align: middle;
  267. p{
  268. font-size:.3rem;
  269. margin:0;
  270. font-weight: bold;
  271. display: block;
  272. overflow: hidden;
  273. text-overflow: ellipsis;
  274. white-space: nowrap;
  275. width: 3.92rem;
  276. &:nth-child(2) {
  277. font-weight: normal;
  278. margin-top: .3rem;
  279. }
  280. }
  281. }
  282. span{
  283. font-size:.28rem;
  284. color:#53a0f7;
  285. position: relative;
  286. bottom: .3rem;
  287. }
  288. }
  289. .shop-list {
  290. background:#fff;
  291. border-bottom: .1rem solid #dfe2e4;
  292. padding-bottom:.28rem;
  293. h3{
  294. font-size:.32rem;
  295. line-height: .8rem;
  296. margin:0;
  297. margin-left:.27rem;
  298. margin-bottom:.14rem;
  299. }
  300. .list-item{
  301. width:6.77rem;
  302. margin-left:.39rem;
  303. .item-img{
  304. width:2.4rem;
  305. vertical-align: middle;
  306. display: inline-block;
  307. img{
  308. &:nth-child(2) {
  309. width:2.4rem;
  310. height:1.69rem;
  311. border: .04rem solid #eee;
  312. }
  313. &:nth-child(1) {
  314. position:absolute;
  315. width:.65rem;
  316. height:.33rem;
  317. }
  318. }
  319. }
  320. .list-item-phone{
  321. width:3.95rem;
  322. padding:.18rem 0;
  323. position:relative;
  324. display: inline-block;
  325. vertical-align: middle;
  326. margin-left: .26rem;
  327. p{
  328. font-size:.28rem;
  329. line-height: .67rem;
  330. margin:0;
  331. overflow: hidden;
  332. text-overflow: ellipsis;
  333. white-space: nowrap;
  334. width: 3.2rem;
  335. }
  336. i{
  337. display:block;
  338. position:absolute;
  339. top: -.06rem;
  340. right: -.18rem;
  341. font-size:.5rem;
  342. color:#ff7800;
  343. width: .6rem;
  344. height: .6rem;
  345. text-align: center;
  346. line-height: .6rem;
  347. }
  348. }
  349. }
  350. &:active {
  351. background: #e1e1e1;
  352. }
  353. }
  354. .detail-brand{
  355. background: #fff;
  356. width:100%;
  357. min-height:1.5rem;
  358. padding:.2rem 0;
  359. border-bottom: .1rem solid #dfe2e4;
  360. &:nth-child(1) {
  361. margin-top:.1rem;
  362. }
  363. .brand-item{
  364. width:7rem;
  365. margin:0 auto;
  366. border-radius:.1rem;
  367. background: #fff;
  368. padding:.2rem;
  369. position:relative;
  370. &:active{
  371. background: #e1e1e1;
  372. }
  373. p{
  374. font-size:.28rem;
  375. line-height:.4rem;
  376. color:#333;
  377. margin:0;
  378. }
  379. i{
  380. display:block;
  381. position:absolute;
  382. top:.2rem;
  383. right:.1rem;
  384. font-size:.5rem;
  385. color:#ff7800;
  386. width: .6rem;
  387. height: .6rem;
  388. line-height: .6rem;
  389. text-align: center;
  390. }
  391. }
  392. div.active{
  393. background: #d4d;
  394. }
  395. }
  396. .collect-list-type {
  397. background: #fff;
  398. border-bottom: .04rem solid #acacac;
  399. p {
  400. font-size: .32rem;
  401. margin: 0 0 0 .13rem;
  402. width: .92rem;
  403. text-align: center;
  404. line-height: .5rem;
  405. border-bottom: .06rem solid #418bf6;
  406. }
  407. }
  408. }
  409. </style>