CommodityInfo.vue 11 KB

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