index.vue 9.2 KB

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