CommodityInfo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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 text-center" 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. let fragment = {}
  118. let prices = commodity.prices[0]
  119. fragment.num = commodity.minBuyQty
  120. fragment.prices = prices
  121. if (commodity.currencyName !== 'USD') {
  122. fragment.currency = 'RMB'
  123. } else {
  124. fragment.currency = 'USD'
  125. }
  126. if (fragment.currency !== 'USD') {
  127. fragment.price = prices.rMBPrice
  128. } else {
  129. fragment.price = prices.uSDPrice
  130. }
  131. console.log(fragment)
  132. return fragment
  133. }
  134. function getFragment (commodity, fragment) {
  135. // 判断是否小于第一分段的起订量
  136. if (commodity.prices[0].start > fragment.num) {
  137. fragment.num = commodity.prices[0].start
  138. }
  139. // 获取分段的信息
  140. let prices = commodity.prices
  141. for (let i = 0; i < prices.length; i++) {
  142. if (fragment.num <= prices[i].end) {
  143. fragment.prices = prices[i]
  144. break
  145. }
  146. }
  147. }
  148. export default {
  149. name: 'commodity-info',
  150. data () {
  151. return {
  152. fragment: { currency: 'RMB', num: 0, price: 0, canAdd: true }
  153. }
  154. },
  155. computed: {
  156. storeInfo () {
  157. return this.$store.state.shop.storeInfo.store.data
  158. },
  159. commodity () {
  160. let commodity = this.$store.state.shop.storeInfo.commodity.data
  161. this.fragment = initFragment(commodity)
  162. return commodity
  163. },
  164. component () {
  165. return this.$store.state.shop.storeInfo.component.data
  166. },
  167. calculate () {
  168. this.fragment.total = this.fragment.price * this.fragment.num
  169. return this.fragment.total
  170. }
  171. },
  172. methods: {
  173. changeCurrency () {
  174. if (this.fragment.currency === 'RMB') {
  175. this.fragment.price = this.fragment.prices.rMBPrice
  176. } else if (this.fragment.currency === 'USD') {
  177. this.fragment.price = this.fragment.prices.uSDPrice
  178. }
  179. },
  180. subNum () {
  181. let newNum = this.fragment.num - this.commodity.minPackQty
  182. if (newNum >= this.commodity.minBuyQty) {
  183. this.fragment.num = newNum
  184. } else {
  185. this.fragment.canSub = false
  186. }
  187. this.fragment.canAdd = true
  188. getFragment(this.commodity, this.fragment)
  189. },
  190. addNum () {
  191. let newNum = this.fragment.num + this.commodity.minPackQty
  192. if (newNum <= this.commodity.reserve) {
  193. this.fragment.num = newNum
  194. } else {
  195. this.fragment.canAdd = false
  196. }
  197. this.fragment.canSub = true
  198. getFragment(this.commodity, this.fragment)
  199. },
  200. inputNum () {
  201. if (this.fragment.num < this.commodity.minBuyQty) {
  202. this.fragment.num = this.commodity.minBuyQty
  203. } else if (this.fragment.num > this.commodity.reserve) {
  204. this.fragment.num = this.commodity.reserve
  205. }
  206. getFragment(this.commodity, this.fragment)
  207. }
  208. }
  209. }
  210. </script>
  211. <style scoped>
  212. .container.commodity {
  213. width: 1190px;
  214. padding-left: 0px;
  215. padding-right: 0px;
  216. font-family: "Microsoft Yahei", "微软雅黑";
  217. }
  218. .commodity .commodity-detail {
  219. width: 100%;
  220. display: inline-block;
  221. font-size: 0px;
  222. }
  223. .commodity-detail .img{
  224. float: left;
  225. width: 258px;
  226. height: 320px;
  227. }
  228. .commodity-detail .img img {
  229. border: 1px solid #D6D3CE;
  230. }
  231. .commodity-detail .img .box {
  232. height: 62px;
  233. }
  234. .commodity-detail .content {
  235. width: 932px;
  236. float: left;
  237. font-size: 14px;
  238. }
  239. .commodity-detail .content {
  240. padding-left: 20px;
  241. }
  242. .commodity-detail .content .code {
  243. font-size: 24px;
  244. color: rgb(50, 50, 50);
  245. font-weight: 600;
  246. border-bottom: 1px solid #D6D3CE;
  247. line-height: 40px;
  248. }
  249. .commodity-detail .content .com-info {
  250. font-size: 14px;
  251. font-family: "Microsoft Yahei", "微软雅黑";
  252. line-height: 26px;
  253. }
  254. .input-group .input-group-operate {
  255. padding: 6px 12px;
  256. font-size: 14px;
  257. font-weight: 400;
  258. line-height: 1;
  259. color: #555;
  260. text-align: center;
  261. background-color: #eee;
  262. border: 1px solid #ccc;
  263. border-radius: 4px;
  264. }
  265. .input-group .input-group-operate:last-child {
  266. border-bottom-left-radius: 0px;
  267. border-top-left-radius: 0px;
  268. }
  269. .input-group .input-group-operate:first-child {
  270. border-bottom-right-radius: 0px;
  271. border-top-right-radius: 0px;
  272. }
  273. .content .com-info .name {
  274. letter-spacing: 15px;
  275. }
  276. .commodity-info-detail {
  277. float: left;
  278. padding-top: 10px;
  279. width: 582px;
  280. }
  281. .price-block {
  282. float: right;
  283. width: 330px;
  284. margin-top: 10px;
  285. height: 220px;
  286. }
  287. .commodity-price {
  288. line-height: 30px;
  289. text-align: center;
  290. border: 1px solid #D6D3CE;
  291. }
  292. .commodity-price .title {
  293. background-color: #f7f7f7;
  294. border-bottom: 1px solid #D6D3CE;
  295. }
  296. .commodity-price .head {
  297. border-bottom: 1px solid #D6D3CE;
  298. }
  299. .commodity-price .fragment {
  300. display: inline-block;
  301. width: 70px;
  302. }
  303. .commodity-price .price {
  304. width: 123px;
  305. display: inline-block;
  306. }
  307. .com-info div.select {
  308. display: inline-block;
  309. }
  310. .com-info .operate {
  311. cursor: pointer;
  312. }
  313. .com-info .operate:hover, .com-info .operate:link {
  314. background-color: #00B83F;
  315. color: white;
  316. }
  317. .com-info .money {
  318. font-weight: 600;
  319. color: red;
  320. }
  321. .com-info select {
  322. border-radius: 4px;
  323. width: 120px!important;
  324. }
  325. ul.list-inline {
  326. margin: 0px;
  327. }
  328. .commodity-price ul.list-inline li {
  329. padding-left: 0px;
  330. padding-right: 0px;
  331. border-bottom: 1px dashed #D6D3CE;
  332. }
  333. .commodity-price .table {
  334. margin-bottom: 0px;
  335. }
  336. .commodity-price ul>li:last-child {
  337. border-bottom: none;
  338. }
  339. div.button {
  340. padding-top: 20px;
  341. float: left;
  342. }
  343. button.btn-now {
  344. border: 1px solid #3D76C6;
  345. color: #3D76C6;
  346. margin-left: 30px;
  347. }
  348. .com-info .delivery {
  349. display: inline;
  350. }
  351. #commodity-info-fragment{
  352. margin-bottom: 20px;
  353. }
  354. </style>