index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. <template>
  2. <div class="user-content mobile-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/agency.png'
  140. } else if (type === 'DISTRIBUTION') {
  141. url += '/images/mobile/@2x/shop/distribution.png'
  142. } else if (type === 'ORIGINAL_FACTORY') {
  143. url += '/images/mobile/@2x/shop/original_factory.png'
  144. } else if (type === 'CONSIGNMENT') {
  145. url = '/images/mobile/@2x/shop/consignment.png'
  146. }
  147. return url
  148. },
  149. goStoreDetail: function (uuid) {
  150. this.$router.push('/mobile/shop/' + uuid)
  151. },
  152. goComponentDetail: function (uuid) {
  153. this.$router.push('/mobile/brand/componentDetail/' + uuid)
  154. },
  155. getRemindText: function () {
  156. if (this.isDevice && !this.isShop) {
  157. return '抱歉,暂无器件收藏'
  158. } else if (!this.isDevice && this.isShop) {
  159. return '抱歉,暂无店铺关注'
  160. } else {
  161. return '抱歉,暂无收藏记录'
  162. }
  163. },
  164. selectStoreInfo: function (store, event) {
  165. event.stopPropagation()
  166. this.storeInfo = store.storeInfo.enterprise || {}
  167. this.showStoreInfo = true
  168. },
  169. checkInfo: function (str) {
  170. return str && str.trim() !== ''
  171. }
  172. },
  173. computed: {
  174. collectSave () {
  175. return this.$store.state.product.common.collectList.data
  176. },
  177. userInfo () {
  178. return this.$store.state.option.user
  179. },
  180. enterpriseInfo () {
  181. let ens = this.userInfo.data.enterprises
  182. // if (ens && ens.length) {
  183. // return ens.find(item => item.current) || {enName: this.userInfo.data.userName + '(个人账户)'}
  184. // } else {
  185. // return {enName: this.userInfo.data.userName + '(个人账户)'}
  186. // }
  187. if (ens && ens.length) {
  188. for (let i = 0; i < ens.length; i++) {
  189. if (ens[i].current) {
  190. return ens[i]
  191. }
  192. }
  193. }
  194. return {enName: this.userInfo.data.userName + '(个人账户)'}
  195. },
  196. focusPage () {
  197. return this.$store.state.shop.storeInfo.focusPage.data
  198. }
  199. }
  200. }
  201. </script>
  202. <style scoped lang="scss">
  203. .user-content{
  204. margin-bottom: .98rem;
  205. background: #dfe2e4;
  206. .none-state{
  207. text-align: center;
  208. padding:1.5rem 0;
  209. background: #fff;
  210. margin-top:.1rem;
  211. width:100%;
  212. img{
  213. margin:0 auto;
  214. width: 4.08rem;
  215. height: 2.62rem;
  216. }
  217. p {
  218. font-size: .32rem;
  219. color: #999;
  220. margin: 1.19rem 0 0 0;
  221. }
  222. a {
  223. display: block;
  224. font-size: .28rem;
  225. color: #fff;
  226. width: 1.88rem;
  227. height: .54rem;
  228. line-height: .54rem;
  229. background: #418bf6;
  230. margin: .7rem auto 0;
  231. border-radius: .05rem;
  232. }
  233. }
  234. .user-name{
  235. padding:.14rem 0 .2rem .34rem;
  236. background:#fff;
  237. width:100%;
  238. position:relative;
  239. border-bottom: .1rem solid #dfe2e4;
  240. .supdown{
  241. position:absolute;
  242. top:.8rem;
  243. right:.3rem;
  244. z-index:10;
  245. width:1.7rem;
  246. background:#616264;
  247. border-radius:.1rem;
  248. li{
  249. font-size: .28rem;
  250. color:#ffffff;
  251. height: .32rem;
  252. line-height: .32rem;
  253. margin: .4rem 0;
  254. text-align: center;
  255. }
  256. }
  257. img{
  258. display: inline-block;
  259. width:1.25rem;
  260. height:1.25rem;
  261. border:.04rem solid #c5dbfc;
  262. border-radius: .05rem;
  263. vertical-align: middle;
  264. }
  265. .user-info {
  266. margin-left:.25rem;
  267. display: inline-block;
  268. vertical-align: middle;
  269. p{
  270. font-size:.3rem;
  271. margin:0;
  272. font-weight: bold;
  273. display: block;
  274. overflow: hidden;
  275. text-overflow: ellipsis;
  276. white-space: nowrap;
  277. width: 3.92rem;
  278. &:nth-child(2) {
  279. font-weight: normal;
  280. margin-top: .3rem;
  281. }
  282. }
  283. }
  284. span{
  285. font-size:.28rem;
  286. color:#53a0f7;
  287. position: relative;
  288. bottom: .3rem;
  289. }
  290. }
  291. .shop-list {
  292. background:#fff;
  293. border-bottom: .1rem solid #dfe2e4;
  294. padding: .14rem 0 .14rem 0;
  295. h3{
  296. font-size: .32rem;
  297. line-height: .4rem;
  298. margin: 0 0 0 .27rem;
  299. overflow: hidden;
  300. text-overflow: ellipsis;
  301. white-space: nowrap;
  302. padding-top: .1rem;
  303. position: relative;
  304. top: .1rem;
  305. }
  306. .list-item{
  307. width:6.77rem;
  308. margin-left:.39rem;
  309. .item-img{
  310. width:2.4rem;
  311. vertical-align: middle;
  312. display: inline-block;
  313. img{
  314. &:nth-child(2) {
  315. width:2.4rem;
  316. height:1.69rem;
  317. border: .04rem solid #eee;
  318. }
  319. &:nth-child(1) {
  320. position:absolute;
  321. width:.65rem;
  322. height:.33rem;
  323. }
  324. }
  325. }
  326. .list-item-phone{
  327. width:3.95rem;
  328. padding:.18rem 0;
  329. position:relative;
  330. display: inline-block;
  331. vertical-align: middle;
  332. margin-left: .26rem;
  333. p{
  334. font-size:.28rem;
  335. line-height: .67rem;
  336. margin:0;
  337. overflow: hidden;
  338. text-overflow: ellipsis;
  339. white-space: nowrap;
  340. width: 3.2rem;
  341. }
  342. i{
  343. display:block;
  344. position:absolute;
  345. top: -.06rem;
  346. right: -.18rem;
  347. font-size:.5rem;
  348. color:#ff7800;
  349. width: .6rem;
  350. height: .6rem;
  351. text-align: center;
  352. line-height: .6rem;
  353. }
  354. }
  355. }
  356. &:active {
  357. background: #e1e1e1;
  358. }
  359. }
  360. .detail-brand{
  361. background: #fff;
  362. width:100%;
  363. min-height:1.5rem;
  364. padding:.2rem 0;
  365. border-bottom: .1rem solid #dfe2e4;
  366. &:nth-child(1) {
  367. margin-top:.1rem;
  368. }
  369. .brand-item{
  370. width:7rem;
  371. margin:0 auto;
  372. border-radius:.1rem;
  373. background: #fff;
  374. padding:.2rem;
  375. position:relative;
  376. &:active{
  377. background: #e1e1e1;
  378. }
  379. p{
  380. font-size:.28rem;
  381. line-height:.4rem;
  382. color:#333;
  383. margin:0;
  384. }
  385. i{
  386. display:block;
  387. position:absolute;
  388. top:.2rem;
  389. right:.1rem;
  390. font-size:.5rem;
  391. color:#ff7800;
  392. width: .6rem;
  393. height: .6rem;
  394. line-height: .6rem;
  395. text-align: center;
  396. }
  397. }
  398. div.active{
  399. background: #d4d;
  400. }
  401. }
  402. .collect-list-type {
  403. background: #fff;
  404. border-bottom: .04rem solid #acacac;
  405. p {
  406. font-size: .32rem;
  407. margin: 0 0 0 .13rem;
  408. width: .92rem;
  409. text-align: center;
  410. line-height: .5rem;
  411. border-bottom: .06rem solid #418bf6;
  412. }
  413. }
  414. }
  415. </style>