index.vue 7.8 KB

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