ComponentDetail.vue 7.3 KB

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