ComponentDetail.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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.brand">
  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.brand.nameCn}}</a></div>
  21. </div>
  22. <div class="form-group row" v-if="list.kind">
  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.kind.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 class="btn btn-default btn-stroe">加入收藏</button>-->
  44. <el-button type="text" v-if="!isShow && collectList" @click="collect(list.id)" class="btn btn-default btn-stroe" style="line-height: 26px;">加入收藏</el-button>
  45. <button class="btn btn-default btn-stroe" v-if="isShow && collectList" disabled="disabled">已收藏</button>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. <!--关注-->
  52. <el-dialog
  53. :visible.sync="dialogVisible"
  54. size="tiny"
  55. >
  56. <h3 class="header-text">收藏成功!</h3>
  57. <div class="focus modal-body">
  58. <button type="button" @click="dialogVisible = false" class="btn" style="margin-left:25px;">关&nbsp;&nbsp;闭</button>
  59. <button type="button" class="focus-btn btn btn btn-info" style="margin-left:35px;">
  60. <a href="/user#/home/componentcol" target="_blank">查看我的产品收藏</a>
  61. </button>
  62. </div>
  63. </el-dialog>
  64. </div>
  65. </template>
  66. <script>
  67. import { ComponentMenu } from '~components/product'
  68. export default {
  69. name: 'ComponentDetail',
  70. data () {
  71. return {
  72. dialogVisible: false,
  73. isShow: false
  74. }
  75. },
  76. computed: {
  77. lists () {
  78. // console.log(this.$store.state.componentDetail.detail)
  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. collectList () {
  88. let id = this.lists.data.properties[0].componentId
  89. // console.log(this.lists.data)
  90. let store = this.$store.state.product.common.collectList.data
  91. var _this = this
  92. if (store) {
  93. for (var i = 0; i < store.length; i++) {
  94. if (store[i].componentid === id) {
  95. _this.isShow = true
  96. }
  97. }
  98. }
  99. return true
  100. }
  101. },
  102. mounted () {
  103. this.$nextTick(() => {
  104. this.loadCollectList()
  105. })
  106. },
  107. components: {
  108. ComponentMenu
  109. },
  110. methods: {
  111. loadCollectList () {
  112. this.$store.dispatch('product/saveStores')
  113. },
  114. collect (id) {
  115. if (this.user.logged) {
  116. this.dialogVisible = true
  117. let kind = 2
  118. this.$store.dispatch('product/saveEntity', {componentid: id, kind: kind})
  119. this.isShow = true
  120. } else {
  121. this.$http.get('/login/page').then(response => {
  122. if (response.data) {
  123. this.$router.push('/auth/login')
  124. }
  125. })
  126. }
  127. }
  128. }
  129. }
  130. </script>
  131. <style scoped>
  132. .header-text {
  133. text-align: center;
  134. font-size: 20px;
  135. color: #008B00;
  136. margin-top: 0;
  137. }
  138. .componentDetail .el-dialog__wrapper .focus-btn a{
  139. color: #fff;
  140. }
  141. .componentDetail .container {
  142. width: 1190px;
  143. padding: 0;
  144. }
  145. .detail{
  146. margin-bottom: 20px;
  147. }
  148. .componentDetail .container .component-img {
  149. width: 260px;
  150. height: 260px;
  151. display: table-cell;
  152. border:1px solid #ccc;
  153. text-align: center;
  154. vertical-align: middle;
  155. }
  156. .componentDetail .container .component-img a {
  157. display: table-cell;
  158. width: 258px;
  159. height: 258px;
  160. text-align: center;
  161. vertical-align: middle;
  162. }
  163. .componentDetail .container .component-img img {
  164. max-width: 258px;
  165. max-height: 258px;
  166. }
  167. .componentDetail .blue {
  168. color: #214797;
  169. }
  170. .componentDetail .container .component-message {
  171. width: 910px;
  172. display: table-cell;
  173. padding-left: 20px;
  174. margin-left: 10px;
  175. }
  176. .componentDetail .container .component-message .message-code {
  177. font-size: 24px;
  178. color: rgb(50,50,50);
  179. font-weight: 700;
  180. line-height: 40px;
  181. }
  182. .componentDetail .container .component-message .hr-grey {
  183. height: 1px;
  184. width: 100%;
  185. background-color: #ccc;
  186. }
  187. .componentDetail .container .component-message .row {
  188. margin: 12px 0;
  189. width: 890px;
  190. height: 16px;
  191. }
  192. .componentDetail .container .component-message .message-item {
  193. float:left;
  194. width:60px;
  195. text-align: justify;
  196. text-align-last: justify;
  197. font-size: 14px;
  198. }
  199. .componentDetail .container .component-message .colon {
  200. float:left;
  201. margin: 0 10px;
  202. }
  203. .componentDetail .container .component-message .message-body {
  204. float: left;
  205. font-size: 14px;
  206. }
  207. .componentDetail .message-item:first-child {
  208. padding-left: 0;
  209. }
  210. .componentDetail .container .storeIns{
  211. margin-top: 20px;
  212. width: 1190px;
  213. height: 48px;
  214. line-height: 48px;
  215. }
  216. .componentDetail .container .storeIns .sign {
  217. display: table-cell;
  218. vertical-align: middle;
  219. font-size: 14px;
  220. }
  221. .componentDetail .container .storeIns .storeInList {
  222. display: table-cell;
  223. }
  224. .componentDetail .container .storeIn {
  225. width: 98px;
  226. height: 49px;
  227. line-height: 30px;
  228. float: left;
  229. border: 1px solid #ccc;
  230. text-align: center;
  231. vertical-align: middle;
  232. margin-right: 15px;
  233. cursor: pointer;
  234. }
  235. .componentDetail .container .storeIn-active {
  236. width: 98px;
  237. float: left;
  238. border: 1px solid #5078cb;
  239. text-align: center;
  240. vertical-align: middle;
  241. margin-right: 15px;
  242. cursor: pointer;
  243. }
  244. .componentDetail .container .storeIn a,.componentDetail .storeIn-active a {
  245. display: table-cell;
  246. height: 46px;
  247. width: 98px;
  248. text-align: center;
  249. vertical-align: middle;
  250. }
  251. .componentDetail .storeIn a>img,.componentDetail .storeIn-active a>img {
  252. max-width: 95px;
  253. max-height: 46px;
  254. }
  255. </style>