index.vue 11 KB

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