CommodityInfo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <div>
  3. <div class="menu-com row">
  4. <div class="menu-title col-md-12">
  5. <a href=".">商城首页</a> >
  6. <a href="provider/home" v-if="storeInfo.type == 'AGENCY' || storeInfo.type == 'DISTRIBUTION'" title="代理经销">代理经销</a>
  7. <a href="provider/factories" v-if="storeInfo.type == 'ORIGINAL_FACTORY'" title="原厂专区">原厂专区</a>
  8. <a :href="'/store/' + storeInfo.uuid" v-if="storeInfo.type == 'CONSIGNMENT'" title="库存寄售">库存寄售</a>
  9. >
  10. <span v-if="storeInfo.type != 'CONSIGNMENT'"><a :href="'/store/' + storeInfo.uuid" :title="storeInfo.storeName" v-text="storeInfo.storeName">storeInfo.storeName</a>> </span>
  11. <span>产品详情</span>
  12. </div>
  13. </div>
  14. <div id="commodity-info-fragment">
  15. <div class="commodity-detail">
  16. <div class="img">
  17. <img :src="commodity.img || '/images/store/common/default.png'" style="width: 256px;height: 256px;"/>
  18. <div class="box"></div>
  19. </div>
  20. <div class="content">
  21. <div class="code">
  22. <span v-text="commodity.code"></span>
  23. </div>
  24. <div class="commodity-info-detail">
  25. <div class="com-info">
  26. <span class="name">价&nbsp;格</span>:
  27. <span class="money">
  28. <span v-if="fragment.currency == 'RMB'">¥</span>
  29. <span v-if="fragment.currency == 'USD'">$</span>
  30. <span v-text="fragment.price"></span>
  31. </span>
  32. </div>
  33. <div class="com-info">
  34. <span class="name">品&nbsp;牌</span>:<span v-text="commodity.brandNameEn"></span>
  35. </div>
  36. <div class="com-info">
  37. <span class="name">类&nbsp;目</span>:<span v-text="commodity.kindNameCn"></span>
  38. </div>
  39. <div class="com-info">
  40. <span class="name">下&nbsp;载</span>:<a target="_blank" :href="component.attach">{{component.attach ? '规格书' : '暂无信息'}}</a>
  41. </div>
  42. <div class="com-info">
  43. <span class="name">包&nbsp;装</span>:<span v-text="commodity.packaging || '无包装信息'"></span>
  44. </div>
  45. <div class="com-info">
  46. <span class="name">封&nbsp;装</span>:<span v-text="commodity.encapsulation || '无封装信息'"></span>
  47. </div>
  48. <div class="com-info">
  49. <span class="name">库&nbsp;存</span>:<span v-text="commodity.reserve || 0"></span>
  50. (<span v-text="commodity.minBuyQty || 1"></span>个起订)
  51. </div>
  52. <div class="com-info">
  53. <span class="name">货&nbsp;期</span>:
  54. <div class="delivery">
  55. <span v-text="commodity.b2cMinDelivery || 0"></span>-
  56. <span v-text="commodity.b2cMaxDelivery || 0"></span>
  57. <span>(天)</span>
  58. </div>
  59. </div>
  60. <div class="com-info form-inline">
  61. <span class="name">数&nbsp;量</span>:
  62. <div class="input-group" style="width: 120px">
  63. <div class="input-group-addon operate" @click="subNum()" :disabled="!fragment.canAdd">-</div>
  64. <input type="text" class="form-control" placeholder="数量" v-model="fragment.num" @change="inputNum()"/>
  65. <div class="input-group-addon operate" @click="addNum()" :disabled="!fragment.canSub">+</div>
  66. </div>
  67. ×
  68. <div class="select">
  69. <select class="form-control" :disabled="commodity.currencyName != 'RMB-USD'" v-model="fragment.currency" @change="changeCurrency()">
  70. <option value="RMB">RMB</option>
  71. <option value="USD">USD</option>
  72. </select>
  73. </div>
  74. <span class="money">
  75. <span v-if="fragment.currency == 'RMB'">¥</span>
  76. <span v-if="fragment.currency == 'USD'">$</span>
  77. <span v-text="calculate || 0"></span>
  78. </span>
  79. </div>
  80. <div class="button" ng-controller="GoodsPickUpCtrl">
  81. <button class="btn btn-default btn-primary" ng-click="addToCart(commodity, false, fragment.num, fragment.currency)">加入购物车</button>
  82. <button class="btn btn-default btn-now" ng-click="addToCart(commodity, true, fragment.num, fragment.currency)">立即购买</button>
  83. </div>
  84. </div>
  85. <div class="price-block">
  86. <div class="commodity-price">
  87. <div class="title">价格梯度</div>
  88. <div class="table">
  89. <div class="head">
  90. <div class="fragment">数量</div>
  91. <div class="price">单价¥(含税)</div>
  92. <div class="price">单价$</div>
  93. </div>
  94. <ul class="list-unstyled list-inline">
  95. <li v-for="price in commodity.prices">
  96. <div class="fragment">
  97. <span v-text="price.start"></span>+
  98. </div>
  99. <div class="price">
  100. <span v-if="price.rMBPrice" v-text="price.rMBPrice ||0"></span>
  101. </div>
  102. <div class="price">
  103. <span v-if="price.uSDPrice" v-text="price.uSDPrice || 0"></span>
  104. </div>
  105. </li>
  106. </ul>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </template>
  115. <script>
  116. function initFragment (commodity) {
  117. if (!commodity) {
  118. return {}
  119. }
  120. let fragment = {}
  121. let prices = commodity.prices[0]
  122. fragment.num = commodity.minBuyQty
  123. fragment.prices = prices
  124. if (commodity.currencyName !== 'USD') {
  125. fragment.currency = 'RMB'
  126. } else {
  127. fragment.currency = 'USD'
  128. }
  129. if (fragment.currency !== 'USD') {
  130. fragment.price = prices.rMBPrice
  131. } else {
  132. fragment.price = prices.uSDPrice
  133. }
  134. return fragment
  135. }
  136. function getFragment (commodity, fragment) {
  137. // 判断是否小于第一分段的起订量
  138. if (commodity.prices[0].start > fragment.num) {
  139. fragment.num = commodity.prices[0].start
  140. }
  141. // 获取分段的信息
  142. let prices = commodity.prices
  143. for (let i = 0; i < prices.length; i++) {
  144. if (fragment.num <= prices[i].end) {
  145. fragment.prices = prices[i]
  146. break
  147. }
  148. }
  149. }
  150. export default {
  151. name: 'commodity-info',
  152. data () {
  153. return {
  154. fragment: { currency: 'RMB', num: 0, price: 0, canAdd: true }
  155. }
  156. },
  157. computed: {
  158. storeInfo () {
  159. return this.$store.state.shop.storeInfo.store.data
  160. },
  161. commodity () {
  162. let commodity = this.$store.state.shop.storeInfo.commodity.data
  163. this.fragment = initFragment(commodity)
  164. return commodity
  165. },
  166. component () {
  167. return this.$store.state.shop.storeInfo.component.data
  168. },
  169. calculate () {
  170. this.fragment.total = this.fragment.price * this.fragment.num
  171. return this.fragment.total
  172. }
  173. },
  174. methods: {
  175. changeCurrency () {
  176. if (this.fragment.currency === 'RMB') {
  177. this.fragment.price = this.fragment.prices.rMBPrice
  178. } else if (this.fragment.currency === 'USD') {
  179. this.fragment.price = this.fragment.prices.uSDPrice
  180. }
  181. },
  182. subNum () {
  183. let newNum = this.fragment.num - this.commodity.minPackQty
  184. if (newNum >= this.commodity.minBuyQty) {
  185. this.fragment.num = newNum
  186. } else {
  187. this.fragment.canSub = false
  188. }
  189. this.fragment.canAdd = true
  190. getFragment(this.commodity, this.fragment)
  191. },
  192. addNum () {
  193. let newNum = this.fragment.num + this.commodity.minPackQty
  194. if (newNum <= this.commodity.reserve) {
  195. this.fragment.num = newNum
  196. } else {
  197. this.fragment.canAdd = false
  198. }
  199. this.fragment.canSub = true
  200. getFragment(this.commodity, this.fragment)
  201. },
  202. inputNum () {
  203. if (this.fragment.num < this.commodity.minBuyQty) {
  204. this.fragment.num = this.commodity.minBuyQty
  205. } else if (this.fragment.num > this.commodity.reserve) {
  206. this.fragment.num = this.commodity.reserve
  207. }
  208. getFragment(this.commodity, this.fragment)
  209. }
  210. }
  211. }
  212. </script>
  213. <style scoped>
  214. .container.commodity {
  215. width: 1190px;
  216. padding-left: 0px;
  217. padding-right: 0px;
  218. font-family: "Microsoft Yahei", "微软雅黑";
  219. }
  220. .commodity .commodity-detail {
  221. width: 100%;
  222. display: inline-block;
  223. font-size: 0px;
  224. }
  225. .commodity-detail .img{
  226. float: left;
  227. width: 258px;
  228. height: 320px;
  229. }
  230. .commodity-detail .img img {
  231. border: 1px solid #D6D3CE;
  232. }
  233. .commodity-detail .img .box {
  234. height: 62px;
  235. }
  236. .commodity-detail .content {
  237. width: 932px;
  238. float: left;
  239. font-size: 14px;
  240. }
  241. .commodity-detail .content {
  242. padding-left: 20px;
  243. }
  244. .commodity-detail .content .code {
  245. font-size: 24px;
  246. color: rgb(50, 50, 50);
  247. font-weight: 600;
  248. border-bottom: 1px solid #D6D3CE;
  249. line-height: 40px;
  250. }
  251. .commodity-detail .content .com-info {
  252. font-size: 14px;
  253. font-family: "Microsoft Yahei", "微软雅黑";
  254. line-height: 26px;
  255. }
  256. .input-group .input-group-operate {
  257. padding: 6px 12px;
  258. font-size: 14px;
  259. font-weight: 400;
  260. line-height: 1;
  261. color: #555;
  262. text-align: center;
  263. background-color: #eee;
  264. border: 1px solid #ccc;
  265. border-radius: 4px;
  266. }
  267. .input-group .input-group-operate:last-child {
  268. border-bottom-left-radius: 0px;
  269. border-top-left-radius: 0px;
  270. }
  271. .input-group .input-group-operate:first-child {
  272. border-bottom-right-radius: 0px;
  273. border-top-right-radius: 0px;
  274. }
  275. .content .com-info .name {
  276. letter-spacing: 15px;
  277. }
  278. .commodity-info-detail {
  279. float: left;
  280. padding-top: 10px;
  281. width: 582px;
  282. }
  283. .price-block {
  284. float: right;
  285. width: 330px;
  286. margin-top: 10px;
  287. height: 220px;
  288. }
  289. .commodity-price {
  290. line-height: 30px;
  291. text-align: center;
  292. border: 1px solid #D6D3CE;
  293. }
  294. .commodity-price .title {
  295. background-color: #f7f7f7;
  296. border-bottom: 1px solid #D6D3CE;
  297. }
  298. .commodity-price .head {
  299. border-bottom: 1px solid #D6D3CE;
  300. }
  301. .commodity-price .fragment {
  302. display: inline-block;
  303. width: 70px;
  304. }
  305. .commodity-price .price {
  306. width: 123px;
  307. display: inline-block;
  308. }
  309. .com-info div.select {
  310. display: inline-block;
  311. }
  312. .com-info .operate {
  313. cursor: pointer;
  314. }
  315. .com-info .operate:hover, .com-info .operate:link {
  316. background-color: #00B83F;
  317. color: white;
  318. }
  319. .com-info .money {
  320. font-weight: 600;
  321. color: red;
  322. }
  323. .com-info select {
  324. border-radius: 4px;
  325. width: 120px!important;
  326. }
  327. ul.list-inline {
  328. margin: 0px;
  329. }
  330. .commodity-price ul.list-inline li {
  331. padding-left: 0px;
  332. padding-right: 0px;
  333. border-bottom: 1px dashed #D6D3CE;
  334. }
  335. .commodity-price .table {
  336. margin-bottom: 0px;
  337. }
  338. .commodity-price ul>li:last-child {
  339. border-bottom: none;
  340. }
  341. div.button {
  342. padding-top: 20px;
  343. float: left;
  344. }
  345. button.btn-now {
  346. border: 1px solid #3D76C6;
  347. color: #3D76C6;
  348. margin-left: 30px;
  349. }
  350. .com-info .delivery {
  351. display: inline;
  352. }
  353. #commodity-info-fragment{
  354. margin-bottom: 20px;
  355. }
  356. </style>