ComponentDetail.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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 || '/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.brand.id}`">{{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 :href="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'
  67. export default {
  68. name: 'ComponentDetail',
  69. data () {
  70. return {
  71. dialogVisible: false
  72. }
  73. },
  74. mounted () {
  75. this.collectList()
  76. },
  77. computed: {
  78. lists () {
  79. return this.$store.state.componentDetail.detail
  80. },
  81. list () {
  82. return this.lists.data
  83. },
  84. user () {
  85. return this.$store.state.option.user
  86. },
  87. colList () {
  88. return this.$store.state.product.common.collectList.data
  89. },
  90. collectList () {
  91. // let _this = this
  92. if (this.lists.data.properties && this.lists.data.properties.length > 0) {
  93. let id = this.lists.data.properties[0].componentId
  94. let store = this.colList
  95. if (store) {
  96. for (let i = 0; i < store.length; i++) {
  97. if (store[i].componentid === id) {
  98. // _this.isShow = true
  99. return true
  100. }
  101. }
  102. }
  103. }
  104. // _this.isShow = false
  105. return false
  106. }
  107. },
  108. components: {
  109. ComponentMenu
  110. },
  111. methods: {
  112. collect (id) {
  113. if (this.user.logged) {
  114. this.dialogVisible = true
  115. let kind = 2
  116. this.$store.dispatch('product/saveEntity', {componentid: id, kind: kind})
  117. this.collectList = true
  118. } else {
  119. this.$http.get('/login/page').then(response => {
  120. if (response.data) {
  121. this.$router.push('/auth/login')
  122. }
  123. })
  124. }
  125. }
  126. }
  127. }
  128. </script>
  129. <style scoped>
  130. .header-text {
  131. text-align: center;
  132. font-size: 20px;
  133. color: #008B00;
  134. margin-top: 0;
  135. }
  136. .componentDetail .el-dialog__wrapper .focus-btn a{
  137. color: #fff;
  138. }
  139. .componentDetail .container {
  140. width: 1190px;
  141. padding: 0;
  142. }
  143. .detail{
  144. margin-bottom: 20px;
  145. }
  146. .componentDetail .container .component-img {
  147. width: 260px;
  148. height: 260px;
  149. display: table-cell;
  150. border:1px solid #ccc;
  151. text-align: center;
  152. vertical-align: middle;
  153. }
  154. .componentDetail .container .component-img a {
  155. display: table-cell;
  156. width: 258px;
  157. height: 258px;
  158. text-align: center;
  159. vertical-align: middle;
  160. }
  161. .componentDetail .container .component-img img {
  162. max-width: 258px;
  163. max-height: 258px;
  164. }
  165. .componentDetail .blue {
  166. color: #214797;
  167. }
  168. .componentDetail .container .component-message {
  169. width: 910px;
  170. display: table-cell;
  171. padding-left: 20px;
  172. margin-left: 10px;
  173. }
  174. .componentDetail .container .component-message .message-code {
  175. font-size: 24px;
  176. color: rgb(50,50,50);
  177. font-weight: 700;
  178. line-height: 40px;
  179. }
  180. .componentDetail .container .component-message .hr-grey {
  181. height: 1px;
  182. width: 100%;
  183. background-color: #ccc;
  184. }
  185. .componentDetail .container .component-message .row {
  186. margin: 12px 0;
  187. width: 890px;
  188. height: 16px;
  189. }
  190. .componentDetail .container .component-message .message-item {
  191. float:left;
  192. width:60px;
  193. text-align: justify;
  194. text-align-last: justify;
  195. font-size: 14px;
  196. }
  197. .componentDetail .container .component-message .colon {
  198. float:left;
  199. margin: 0 10px;
  200. }
  201. .componentDetail .container .component-message .message-body {
  202. float: left;
  203. font-size: 14px;
  204. }
  205. .componentDetail .container .component-message .message-body a {
  206. color: #337ab7;
  207. }
  208. .componentDetail .container .component-message .message-body:hover a{
  209. color: #23527c;
  210. }
  211. .componentDetail .message-item:first-child {
  212. padding-left: 0;
  213. }
  214. .componentDetail .container .storeIns{
  215. margin-top: 20px;
  216. width: 1190px;
  217. height: 48px;
  218. line-height: 48px;
  219. }
  220. .componentDetail .container .storeIns .sign {
  221. display: table-cell;
  222. vertical-align: middle;
  223. font-size: 14px;
  224. }
  225. .componentDetail .container .storeIns .storeInList {
  226. display: table-cell;
  227. }
  228. .componentDetail .container .storeIn {
  229. width: 98px;
  230. height: 49px;
  231. line-height: 30px;
  232. float: left;
  233. border: 1px solid #ccc;
  234. text-align: center;
  235. vertical-align: middle;
  236. margin-right: 15px;
  237. cursor: pointer;
  238. }
  239. .componentDetail .container .storeIn-active {
  240. width: 98px;
  241. float: left;
  242. border: 1px solid #5078cb;
  243. text-align: center;
  244. vertical-align: middle;
  245. margin-right: 15px;
  246. cursor: pointer;
  247. }
  248. .componentDetail .container .storeIn a,.componentDetail .storeIn-active a {
  249. display: table-cell;
  250. height: 46px;
  251. width: 98px;
  252. text-align: center;
  253. vertical-align: middle;
  254. }
  255. .componentDetail .storeIn a>img,.componentDetail .storeIn-active a>img {
  256. max-width: 95px;
  257. max-height: 46px;
  258. }
  259. </style>