ComponentDetail.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <div class="componentDetail">
  3. <div class="container">
  4. <!--<div class="menu">
  5. <component-menu/>
  6. </div>-->
  7. <div class="detail">
  8. <div class="component-img">
  9. <img :src="list.img?list.img:list.brand&&list.brand.logoUrl?list.brand.logoUrl:'/images/component/default.png'"/>
  10. </div>
  11. <div class="component-message">
  12. <div class="message-code">
  13. <span>{{list.code}}</span>
  14. </div>
  15. <div class="hr-grey"></div>
  16. <div class="row">
  17. <div class="form-group row" v-if="list.kind">
  18. <div class="message-item">类目</div>
  19. <div class="colon">:</div>
  20. <div><a class="message-body blue" target="_blank" :href="`/product/kind/${list.kindid}`">{{list.kind.nameCn}}</a></div>
  21. </div>
  22. <div class="form-group row" v-if="list.brand">
  23. <div class="message-item">品牌</div>
  24. <div class="colon">:</div>
  25. <div><a class="message-body blue" target="_blank" :href="`/product/brand/${list.brand.uuid}`">{{list.brand.nameCn}}</a></div>
  26. </div>
  27. <div class="form-group row">
  28. <div class="message-item">总库存量</div>
  29. <div class="colon">:</div>
  30. <div class="message-body">{{list.reserve || '暂无库存'}}</div>
  31. </div>
  32. <div class="form-group row">
  33. <div class="message-item">封装</div>
  34. <div class="colon">:</div>
  35. <div class="message-body">{{list.encapsulation || '暂无信息'}}</div>
  36. </div>
  37. <div class="form-group row">
  38. <div class="message-item">下载</div>
  39. <div class="colon">:</div>
  40. <div class="message-body"><a @click="toAttach(list.attach)" v-if="list.attach">规格书</a><span v-if="!list.attach">暂无规格书</span></div>
  41. </div>
  42. <div class="form-group">
  43. <button type="text" v-if="!collectList" @click="collect(list.id)" class="btn btn-default btn-stroe" style="line-height: 26px;">加入收藏</button>
  44. <button class="btn btn-default btn-stroe" v-if="collectList" disabled="disabled">已收藏</button>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. <!--关注-->
  51. <el-dialog
  52. :visible.sync="dialogVisible"
  53. size="tiny"
  54. >
  55. <h3 class="header-text">收藏成功!</h3>
  56. <div class="focus modal-body">
  57. <button type="button" @click="dialogVisible = false" class="btn" style="margin-left:25px;">关&nbsp;&nbsp;闭</button>
  58. <button type="button" class="focus-btn btn btn btn-info" style="margin-left:35px;">
  59. <a href="/user#/home/componentcol" target="_blank">查看我的产品收藏</a>
  60. </button>
  61. </div>
  62. </el-dialog>
  63. </div>
  64. </template>
  65. <script>
  66. // import ComponentMenu from '~components/product/component/componentMenu.vue'
  67. export default {
  68. name: 'ComponentDetail',
  69. data () {
  70. return {
  71. dialogVisible: false
  72. }
  73. },
  74. computed: {
  75. lists () {
  76. return this.$store.state.componentDetail.detail
  77. },
  78. list () {
  79. return this.lists.data
  80. },
  81. user () {
  82. return this.$store.state.option.user
  83. },
  84. colList () {
  85. return this.$store.state.product.common.collectList.data
  86. },
  87. collectList () {
  88. let id = this.lists.data.id
  89. let store = this.colList
  90. if (store) {
  91. for (let i = 0; i < store.length; i++) {
  92. if (store[i].componentid === id) {
  93. return true
  94. }
  95. }
  96. } else {
  97. return false
  98. }
  99. }
  100. },
  101. // components: {
  102. // ComponentMenu
  103. // },
  104. methods: {
  105. collect (id) {
  106. if (this.user.logged) {
  107. this.dialogVisible = true
  108. let kind = 2
  109. this.$store.dispatch('product/saveEntity', {componentid: id, kind: kind})
  110. // this.collectList = true
  111. } else {
  112. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  113. if (response.data) {
  114. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.host + response.data.baseUrl)
  115. }
  116. })
  117. }
  118. },
  119. toAttach: function (url) {
  120. if (url === '1') {
  121. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  122. if (response.data) {
  123. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.host + response.data.baseUrl)
  124. }
  125. })
  126. } else {
  127. window.open(url)
  128. }
  129. }
  130. }
  131. }
  132. </script>
  133. <style scoped>
  134. .header-text {
  135. text-align: center;
  136. font-size: 20px;
  137. color: #008B00;
  138. margin-top: 0;
  139. }
  140. .focus button.focus-btn a{
  141. color: #fff;
  142. width: 100%;
  143. height: 100%;
  144. display: inline-block;
  145. }
  146. .focus button.focus-btn{
  147. width: 138px;
  148. height: 36px;
  149. line-height: 36px;
  150. padding: 0;
  151. }
  152. .componentDetail .el-dialog__wrapper .focus-btn a{
  153. color: #fff;
  154. }
  155. .componentDetail .container {
  156. width: 1190px;
  157. padding: 0;
  158. }
  159. .detail{
  160. margin-bottom: 20px;
  161. }
  162. .componentDetail .container .component-img {
  163. width: 260px;
  164. height: 260px;
  165. display: table-cell;
  166. border:1px solid #ccc;
  167. text-align: center;
  168. vertical-align: middle;
  169. }
  170. .componentDetail .container .component-img a {
  171. display: table-cell;
  172. width: 258px;
  173. height: 258px;
  174. text-align: center;
  175. vertical-align: middle;
  176. }
  177. .componentDetail .container .component-img img {
  178. max-width: 258px;
  179. max-height: 258px;
  180. }
  181. .componentDetail .blue {
  182. color: #214797;
  183. }
  184. .componentDetail .container .component-message {
  185. width: 910px;
  186. display: table-cell;
  187. padding-left: 20px;
  188. margin-left: 10px;
  189. }
  190. .componentDetail .container .component-message .message-code {
  191. font-size: 24px;
  192. color: rgb(50,50,50);
  193. font-weight: 700;
  194. line-height: 40px;
  195. }
  196. .componentDetail .container .component-message .hr-grey {
  197. height: 1px;
  198. width: 100%;
  199. background-color: #ccc;
  200. }
  201. .componentDetail .container .component-message .row {
  202. margin: 12px 0;
  203. width: 890px;
  204. height: 16px;
  205. }
  206. .componentDetail .container .component-message .message-item {
  207. float:left;
  208. width:60px;
  209. text-align: justify;
  210. text-align-last: justify;
  211. font-size: 14px;
  212. }
  213. .componentDetail .container .component-message .colon {
  214. float:left;
  215. margin: 0 10px;
  216. }
  217. .componentDetail .container .component-message .message-body {
  218. float: left;
  219. font-size: 14px;
  220. }
  221. .componentDetail .container .component-message .message-body a {
  222. color: #337ab7;
  223. }
  224. .componentDetail .container .component-message .message-body:hover a{
  225. color: #23527c;
  226. }
  227. .componentDetail .message-item:first-child {
  228. padding-left: 0;
  229. }
  230. .componentDetail .container .storeIns{
  231. margin-top: 20px;
  232. width: 1190px;
  233. height: 48px;
  234. line-height: 48px;
  235. }
  236. .componentDetail .container .storeIns .sign {
  237. display: table-cell;
  238. vertical-align: middle;
  239. font-size: 14px;
  240. }
  241. .componentDetail .container .storeIns .storeInList {
  242. display: table-cell;
  243. }
  244. .componentDetail .container .storeIn {
  245. width: 98px;
  246. height: 49px;
  247. line-height: 30px;
  248. float: left;
  249. border: 1px solid #ccc;
  250. text-align: center;
  251. vertical-align: middle;
  252. margin-right: 15px;
  253. cursor: pointer;
  254. }
  255. .componentDetail .container .storeIn-active {
  256. width: 98px;
  257. float: left;
  258. border: 1px solid #5078cb;
  259. text-align: center;
  260. vertical-align: middle;
  261. margin-right: 15px;
  262. cursor: pointer;
  263. }
  264. .componentDetail .container .storeIn a,.componentDetail .storeIn-active a {
  265. display: table-cell;
  266. height: 46px;
  267. width: 98px;
  268. text-align: center;
  269. vertical-align: middle;
  270. }
  271. .componentDetail .storeIn a>img,.componentDetail .storeIn-active a>img {
  272. max-width: 95px;
  273. max-height: 46px;
  274. }
  275. </style>