ComponentDetail.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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 @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. this.$router.push('/auth/login')
  115. }
  116. })
  117. }
  118. },
  119. toAttach: function (url) {
  120. console.log(url)
  121. if (url === '1') {
  122. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  123. if (response.data) {
  124. this.$router.push('/auth/login')
  125. }
  126. })
  127. } else {
  128. window.open(url)
  129. }
  130. }
  131. }
  132. }
  133. </script>
  134. <style scoped>
  135. .header-text {
  136. text-align: center;
  137. font-size: 20px;
  138. color: #008B00;
  139. margin-top: 0;
  140. }
  141. .focus button.focus-btn a{
  142. color: #fff;
  143. width: 100%;
  144. height: 100%;
  145. display: inline-block;
  146. }
  147. .focus button.focus-btn{
  148. width: 138px;
  149. height: 36px;
  150. line-height: 36px;
  151. padding: 0;
  152. }
  153. .componentDetail .el-dialog__wrapper .focus-btn a{
  154. color: #fff;
  155. }
  156. .componentDetail .container {
  157. width: 1190px;
  158. padding: 0;
  159. }
  160. .detail{
  161. margin-bottom: 20px;
  162. }
  163. .componentDetail .container .component-img {
  164. width: 260px;
  165. height: 260px;
  166. display: table-cell;
  167. border:1px solid #ccc;
  168. text-align: center;
  169. vertical-align: middle;
  170. }
  171. .componentDetail .container .component-img a {
  172. display: table-cell;
  173. width: 258px;
  174. height: 258px;
  175. text-align: center;
  176. vertical-align: middle;
  177. }
  178. .componentDetail .container .component-img img {
  179. max-width: 258px;
  180. max-height: 258px;
  181. }
  182. .componentDetail .blue {
  183. color: #214797;
  184. }
  185. .componentDetail .container .component-message {
  186. width: 910px;
  187. display: table-cell;
  188. padding-left: 20px;
  189. margin-left: 10px;
  190. }
  191. .componentDetail .container .component-message .message-code {
  192. font-size: 24px;
  193. color: rgb(50,50,50);
  194. font-weight: 700;
  195. line-height: 40px;
  196. }
  197. .componentDetail .container .component-message .hr-grey {
  198. height: 1px;
  199. width: 100%;
  200. background-color: #ccc;
  201. }
  202. .componentDetail .container .component-message .row {
  203. margin: 12px 0;
  204. width: 890px;
  205. height: 16px;
  206. }
  207. .componentDetail .container .component-message .message-item {
  208. float:left;
  209. width:60px;
  210. text-align: justify;
  211. text-align-last: justify;
  212. font-size: 14px;
  213. }
  214. .componentDetail .container .component-message .colon {
  215. float:left;
  216. margin: 0 10px;
  217. }
  218. .componentDetail .container .component-message .message-body {
  219. float: left;
  220. font-size: 14px;
  221. }
  222. .componentDetail .container .component-message .message-body a {
  223. color: #337ab7;
  224. }
  225. .componentDetail .container .component-message .message-body:hover a{
  226. color: #23527c;
  227. }
  228. .componentDetail .message-item:first-child {
  229. padding-left: 0;
  230. }
  231. .componentDetail .container .storeIns{
  232. margin-top: 20px;
  233. width: 1190px;
  234. height: 48px;
  235. line-height: 48px;
  236. }
  237. .componentDetail .container .storeIns .sign {
  238. display: table-cell;
  239. vertical-align: middle;
  240. font-size: 14px;
  241. }
  242. .componentDetail .container .storeIns .storeInList {
  243. display: table-cell;
  244. }
  245. .componentDetail .container .storeIn {
  246. width: 98px;
  247. height: 49px;
  248. line-height: 30px;
  249. float: left;
  250. border: 1px solid #ccc;
  251. text-align: center;
  252. vertical-align: middle;
  253. margin-right: 15px;
  254. cursor: pointer;
  255. }
  256. .componentDetail .container .storeIn-active {
  257. width: 98px;
  258. float: left;
  259. border: 1px solid #5078cb;
  260. text-align: center;
  261. vertical-align: middle;
  262. margin-right: 15px;
  263. cursor: pointer;
  264. }
  265. .componentDetail .container .storeIn a,.componentDetail .storeIn-active a {
  266. display: table-cell;
  267. height: 46px;
  268. width: 98px;
  269. text-align: center;
  270. vertical-align: middle;
  271. }
  272. .componentDetail .storeIn a>img,.componentDetail .storeIn-active a>img {
  273. max-width: 95px;
  274. max-height: 46px;
  275. }
  276. </style>