index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <div class="user-content">
  3. <div class="user-name">
  4. <img src="/images/component/default.png"/>
  5. <p>{{loadUserInfo.userName}}</p>
  6. <span @click="onclick()">{{listName}}<i class="iconfont icon-arrow-down"></i></span>
  7. <ul class="supdown" v-if="down">
  8. <li @click="onDown('-1')">店铺关注</li>
  9. <li @click="onDown('0')">器件收藏</li>
  10. <li @click="onDown('1')">全部收藏</li>
  11. </ul>
  12. </div>
  13. <div class="shop-list" v-if="isShop" v-for="item in focusPage.content">
  14. <h3>{{item.storeName}}</h3>
  15. <div class="list-item">
  16. <div class="item-img">
  17. <i :style="getBackground(item.storeInfo.type)"></i>
  18. <img :src="item.storeInfo.logoUrl || '/images/component/default.png'">
  19. </div>
  20. <div class="list-item-phone">
  21. <p>电话:<span>{{item.storeInfo.enterprise.enTel}}</span></p>
  22. <p>传真:<span>{{item.storeInfo.enterprise.enFax}}</span></p>
  23. <p>商家介绍: <nuxt-link :to="'/mobile/merchantDescription/'+item.storeInfo.uuid">点击查看</nuxt-link></p>
  24. <i class="iconfont icon-shoucang" @click="cancelFocus('store', item)"></i>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="detail-brand" v-for="(item, index) in collectSave.content" v-if="isDevice">
  29. <nuxt-link :to="'/mobile/brand/componentDetail/'+ item.componentinfo.uuid">
  30. <div class="brand-item">
  31. <p>型号:<span>{{item.componentinfo.code}}</span></p>
  32. <p>品牌:<span>{{item.componentinfo.brand.nameCn}}</span></p>
  33. <p>产品描述:<span>{{item.componentinfo.kind.nameCn}}</span></p>
  34. <i class="iconfont icon-shoucang" @click="cancelFocus('product', item)"></i>
  35. </div>
  36. </nuxt-link>
  37. </div>
  38. <div class="none-state" v-if="!(collectSave.content&&collectSave.content.length>0 || focusPage.content&&focusPage.content.length > 0)">
  39. <img src="/images/mobile/@2x/shoucangkongzhuangtai@2x.png">
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. export default {
  45. layout: 'main',
  46. data () {
  47. return {
  48. userName: '',
  49. down: false,
  50. count: '',
  51. page: '',
  52. type: '',
  53. listName: '全部收藏',
  54. isShop: true,
  55. isDevice: true
  56. }
  57. },
  58. fetch ({ store }) {
  59. return Promise.all([
  60. store.dispatch('product/saveStores', { count: 25, page: 1, type: 'component' }),
  61. store.dispatch('loadUserInfo'),
  62. store.dispatch('shop/StoreFocusPage', { count: 5, page: 1 })
  63. ])
  64. },
  65. methods: {
  66. onclick () {
  67. this.down = !this.down
  68. },
  69. onDown (type) {
  70. if (type === '-1') {
  71. this.listName = '店铺关注'
  72. this.isShop = true
  73. this.isDevice = false
  74. this.down = false
  75. }
  76. if (type === '0') {
  77. this.listName = '器件收藏'
  78. this.isDevice = true
  79. this.isShop = false
  80. this.down = false
  81. }
  82. if (type === '1') {
  83. this.listName = '全部收藏'
  84. this.isDevice = true
  85. this.isShop = true
  86. this.down = false
  87. }
  88. },
  89. cancelFocus: function (type, item) {
  90. console.log(item)
  91. if (type === 'store') {
  92. this.$http.post('/trade/storeFocus/delete/storeId', [item.storeid])
  93. .then(response => {
  94. window.location.reload()
  95. })
  96. } else {
  97. // /trade/collection/
  98. this.$http.delete('/trade/collection/' + item.id)
  99. .then(response => {
  100. window.location.reload()
  101. })
  102. }
  103. },
  104. getBackground: function (type) {
  105. let style = 'background: url('
  106. if (type === 'AGENCY') {
  107. style += '/images/mobile/@2x/shop/daili@2x.png'
  108. } else if (type === 'DISTRIBUTION') {
  109. style += '/images/mobile/@2x/shop/jingxiao@2x.png'
  110. } else if (type === 'ORIGINAL_FACTORY') {
  111. style += '/images/mobile/@2x/shop/yuanchang@2x.png'
  112. }
  113. style += ')no-repeat; background-size: .65rem .33rem;'
  114. return style
  115. }
  116. },
  117. computed: {
  118. collectSave () {
  119. return this.$store.state.product.common.collectList.data
  120. },
  121. loadUserInfo () {
  122. return this.$store.state.option.user.data
  123. },
  124. focusPage () {
  125. return this.$store.state.shop.storeInfo.focusPage.data
  126. }
  127. }
  128. }
  129. </script>
  130. <style scoped lang="scss">
  131. .user-content{
  132. margin-bottom: .98rem;
  133. background: #dfe2e4;
  134. .none-state{
  135. text-align: center;
  136. padding:1.5rem 0;
  137. background: #fff;
  138. margin-top:.1rem;
  139. width:100%;
  140. img{
  141. margin:0 auto;
  142. width:3rem;
  143. hight:3rem;
  144. }
  145. }
  146. .user-name{
  147. padding:.14rem .38rem .09rem .34rem;
  148. background:#fff;
  149. display:flex;
  150. align-items: center;
  151. width:100%;
  152. position:relative;
  153. .supdown{
  154. position:absolute;
  155. top:1rem;
  156. right:.3rem;
  157. z-index:1000;
  158. width:1.7rem;
  159. background:#616264;
  160. border-radius:.1rem;
  161. padding-left:.18rem;
  162. li{
  163. font-size: .28rem;
  164. color:#ffffff;
  165. height: .32rem;
  166. line-height: .32rem;
  167. margin: .2rem 0;
  168. }
  169. }
  170. img{
  171. display: inline-block;
  172. width:1.25rem;
  173. height:1.25rem;
  174. border:.04rem solid #c5dbfc;
  175. border-radius: .05rem;
  176. }
  177. p{
  178. font-size:.32rem;
  179. margin:0;
  180. margin-left:.25rem;
  181. flex:1;
  182. }
  183. span{
  184. font-size:.28rem;
  185. color:#53a0f7;
  186. }
  187. }
  188. .shop-list {
  189. background:#fff;
  190. margin-top:.12rem;
  191. padding-bottom:.28rem;
  192. &:hover{
  193. background: #e1e1e1;
  194. }
  195. h3{
  196. font-size:.32rem;
  197. line-height: .8rem;
  198. margin:0;
  199. margin-left:.27rem;
  200. margin-bottom:.14rem;
  201. }
  202. .list-item{
  203. width:6.77rem;
  204. margin-left:.39rem;
  205. justify-content: space-around;
  206. display:inline-flex;
  207. .item-img{
  208. width:2.42rem;
  209. i{
  210. display:block;
  211. position:absolute;
  212. width:.65rem;
  213. height:.33rem;
  214. background: url(/images/mobile/@2x/shop/daili@2x.png)no-repeat;
  215. background-size: .65rem .33rem;
  216. }
  217. img{
  218. border:.02rem solid #418bf6;
  219. width:2.4rem;
  220. height:1.69rem;
  221. }
  222. }
  223. .list-item-phone{
  224. width:3.95rem;
  225. padding-top:.18rem;
  226. position:relative;
  227. p{
  228. font-size:.28rem;
  229. line-height: .45rem;
  230. margin:0;
  231. }
  232. i{
  233. display:block;
  234. position:absolute;
  235. top:.1rem;
  236. right:.1rem;
  237. font-size:.4rem;
  238. color:#ff7800;
  239. }
  240. }
  241. }
  242. }
  243. .detail-brand{
  244. background: #f8fcff;
  245. width:100%;
  246. margin-top:.12rem;
  247. min-height:1.5rem;
  248. padding:.2rem 0;
  249. .brand-item{
  250. width:7rem;
  251. margin:0 auto;
  252. border-radius:.1rem;
  253. background: #fff;
  254. padding:.2rem;
  255. position:relative;
  256. &:active{
  257. background: #e1e1e1;
  258. }
  259. p{
  260. font-size:.28rem;
  261. line-height:.4rem;
  262. color:#333;
  263. margin:0;
  264. span{}
  265. }
  266. i{
  267. display:block;
  268. position:absolute;
  269. top:.2rem;
  270. right:.1rem;
  271. font-size:.4rem;
  272. color:#ff7800;
  273. }
  274. }
  275. div.active{
  276. background: #d4d;
  277. }
  278. }
  279. }
  280. </style>