CommodityInfo.vue 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. <template>
  2. <div>
  3. <div class="menu-com row">
  4. <div class="menu-title col-md-12">
  5. <nuxt-link to="/">商城首页</nuxt-link> >
  6. <nuxt-link to="/eCommerce/home/origin" v-if="storeInfo.type == 'AGENCY' || storeInfo.type == 'DISTRIBUTION'" title="代理经销">代理经销</nuxt-link>
  7. <nuxt-link to="/eCommerce/home/factory" v-if="storeInfo.type == 'ORIGINAL_FACTORY'" title="原厂专区">原厂专区</nuxt-link>
  8. <nuxt-link :to="'/store/' + storeInfo.uuid" v-if="storeInfo.type == 'CONSIGNMENT'" title="库存寄售">库存寄售</nuxt-link>
  9. >
  10. <span v-if="storeInfo.type != 'CONSIGNMENT'"><nuxt-link :to="'/store/' + storeInfo.uuid" :title="storeInfo.storeName" v-text="storeInfo.storeName">storeInfo.storeName</nuxt-link>> </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="/images/floor/specificPrice-store.png" alt="" class="specific-price" v-if="isConsignment && isSpecificPriceTag(commodity.tag)">
  18. <img :src="commodity.img || '/images/store/common/default.png'" style="width: 256px;height: 256px;"/>
  19. <div class="box">
  20. <img v-if="commodity.status === 602" src="/images/store/isSellOut.png" alt="">
  21. </div>
  22. </div>
  23. <div class="content">
  24. <div class="code">
  25. <span v-text="commodity.code"></span>
  26. </div>
  27. <div class="commodity-info-detail">
  28. <div class="com-info" v-if="commodity.status !== 613">
  29. <span class="name">&nbsp;</span>
  30. <span class="money">
  31. <span v-if="fragment.currency == 'RMB'"></span>
  32. <span v-if="fragment.currency == 'USD'">$</span>
  33. <span>{{fragment.price | currency}}</span>
  34. </span>
  35. </div>
  36. <div class="com-info">
  37. <span class="name">&nbsp;</span><span v-text="commodity.brandNameEn"></span>
  38. </div>
  39. <div class="com-info">
  40. <span class="name no-letter">物料名称</span><span v-text="commodity.kindNameCn || '无物料名称信息'"></span>
  41. </div>
  42. <div class="com-info">
  43. <span class="name">&nbsp;</span><span v-text="commodity.spec || '无规格信息'"></span>
  44. </div>
  45. <div class="com-info">
  46. <span class="name">&nbsp;</span><a @click="toAttach(component.attach)" v-if="component.attach">规格书</a><span v-if="!component.attach">暂无信息</span>
  47. </div>
  48. <div class="com-info">
  49. <span class="name">&nbsp;</span><span v-text="commodity.packaging || '无包装信息'"></span>
  50. </div>
  51. <div class="com-info">
  52. <span class="name" style="letter-spacing: 1.5px;">最小包装数</span><span v-text="commodity.minPackQty || '无最小包装数信息'"></span>
  53. </div>
  54. <div class="com-info">
  55. <span class="name">&nbsp;</span><span v-text="commodity.reserve || 0"></span><em style="margin-left: 3px;">PCS</em>
  56. <span v-text="commodity.minBuyQty || 1"></span>个起订)
  57. <span :class="commodity.breakUp?'div-sell can-div-sell':'div-sell not-div-sell'" v-if="commodity.breakUp">可拆卖</span>
  58. </div>
  59. <div class="com-info">
  60. <span class="name">&nbsp;</span>
  61. <div class="delivery">
  62. <span v-text="commodity.b2cMinDelivery || 0"></span>
  63. <span v-if="commodity.b2cMaxDelivery && commodity.b2cMaxDelivery !== commodity.b2cMinDelivery">-</span>
  64. <span v-if="commodity.b2cMaxDelivery && commodity.b2cMaxDelivery !== commodity.b2cMinDelivery" v-text="commodity.b2cMaxDelivery || 0"></span>
  65. <span>(天)</span>
  66. </div>
  67. </div>
  68. <div class="com-info form-inline" v-if="commodity.status !== 602 && commodity.status !== 612 && commodity.status !== 613">
  69. <span class="name">&nbsp;</span>
  70. <div class="input-group" style="width: 120px">
  71. <div :class="fragment.canSub ? ' input-group-addon operate':'input-group-addon'" @click="fragment.canSub ?subNum():''" :style="!fragment.canSub ?'cursor: not-allowed;':''">-</div>
  72. <input type="text" class="form-control" placeholder="数量" v-model="fragment.num" @change="inputNum()" @input="onInput()" style="padding: 0;min-width: 100px;text-align: center;"/>
  73. <div :class="fragment.canAdd ?'input-group-addon operate':'input-group-addon'" @click="fragment.canAdd ?addNum():''" :style="!fragment.canAdd ?'cursor: not-allowed;':''">+</div>
  74. <!-- <div class="input-group-addon operate" @click="subNum()">-</div>
  75. <input type="text" class="form-control" placeholder="数量" v-model="fragment.num" @change="inputNum()"style="padding: 0;min-width: 100px;text-align: center;"/>
  76. <div class="input-group-addon operate" @click="addNum()">+</div>-->
  77. </div>
  78. ×
  79. <!--<div class="select">
  80. <select class="form-control" :disabled="commodity.currencyName != 'RMB-USD'" v-model="fragment.currency" @change="changeCurrency()">
  81. <option value="RMB">RMB</option>
  82. <option value="USD">USD</option>
  83. </select>
  84. </div>-->
  85. <div class="select">
  86. <span v-if="fragment.currency == 'RMB'"></span>
  87. <span v-if="fragment.currency == 'USD'">$</span>
  88. <span>{{(fragment.price || 0) | currency}}</span>
  89. <span v-if="fragment.currency == 'RMB'" class="tax"> ( 含税 ) </span>
  90. </div>
  91. <span class="money">
  92. <span v-if="fragment.currency == 'RMB'"></span>
  93. <span v-if="fragment.currency == 'USD'">$</span>
  94. <span>{{calculate | currencyShort}}</span>
  95. </span>
  96. </div>
  97. <div class="button" v-if="commodity.status !== 602 && commodity.status !== 612 && commodity.status !== 613">
  98. <button class="btn btn-default btn-primary" @click="buyNow(false, commodity)">加入购物车</button>
  99. <button class="btn btn-default btn-now" @click="buyNow(true, commodity)">立即购买</button>
  100. </div>
  101. <div class="button" v-if="commodity.status === 613 || commodity.status === 602">
  102. <button class="btn btn-default btn-primary" @click="immediatelyClick(commodity, $event)">立即询价</button>
  103. </div>
  104. <div class="warn-area" v-if="commodity.status === 602 || commodity.status === 612" v-text="commodity.status === 602 ? '此产品已售罄':'此产品已下架'"></div>
  105. </div>
  106. <div class="price-block" v-if="commodity.status !== 613">
  107. <div class="commodity-price">
  108. <div class="title">价格梯度</div>
  109. <div class="table">
  110. <div class="head">
  111. <div class="fragment">梯度/pcs</div>
  112. <div class="price" v-if="commodity.currencyName == 'RMB'">单价¥(含税)</div>
  113. <div class="price" v-if="commodity.currencyName == 'USD'">单价$</div>
  114. </div>
  115. <ul class="list-unstyled list-inline">
  116. <li v-for="price in commodity.prices">
  117. <div class="fragment">
  118. <span v-text="price.start"></span>+
  119. </div>
  120. <div class="price" v-if="commodity.currencyName == 'RMB'">
  121. <span v-if="price.rMBPrice">{{price.rMBPrice || 0 | currency}}</span>
  122. </div>
  123. <div class="price" v-if="commodity.currencyName == 'USD'">
  124. <span v-if="price.uSDPrice">{{price.uSDPrice || 0 | currency}}</span>
  125. </div>
  126. </li>
  127. </ul>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. <el-dialog
  135. title="我要询价"
  136. :visible.sync="hasDialog">
  137. <div class="form_dialog">
  138. <ul class="list-inline">
  139. <li class="form-item">
  140. <span>品牌:</span>
  141. <p v-text="applyObj.brand ? spliceString(applyObj.brand, 90) : '-'">32432</p>
  142. </li>
  143. <li class="form-item">
  144. <span>物料名称:</span>
  145. <p v-text="applyObj.prodName ? spliceString(applyObj.prodName, 90) : '-'">32</p>
  146. </li>
  147. <li class="form-item">
  148. <span>型号:</span>
  149. <p v-text="applyObj.cmpCode ? spliceString(applyObj.cmpCode, 90) : '-'">32432</p>
  150. </li>
  151. <li class="form-item">
  152. <span>规格:</span>
  153. <p v-text="applyObj.spec ? spliceString(applyObj.spec, 90) : '-'">32432</p>
  154. </li>
  155. <li class="form-item">
  156. <span><i>*</i>截止日期:</span>
  157. <el-date-picker
  158. :class="{'error': !validObj.deadline}"
  159. v-model="applyObj.deadline"
  160. type="date"
  161. :picker-options="pickerOptions"
  162. @change="setDeadLineValid"
  163. :editable="false"
  164. :clearable="true"
  165. size="mini">
  166. </el-date-picker>
  167. </li>
  168. <li class="form-item">
  169. <span>封装:</span>
  170. <input type="text" class="form-control" v-model="applyObj.encapsulation"/>
  171. </li>
  172. <!--<li class="form-item">-->
  173. <!--<span>单价预算:</span>-->
  174. <!--<select v-model="applyObj.currency" class="form-control" style="width:40px;">-->
  175. <!--<option value="RMB">¥</option>-->
  176. <!--<option value="USD">$</option>-->
  177. <!--</select>-->
  178. <!--<input type="number" v-model="applyObj.unitPrice" class="form-control" :class="{'error': !validObj.unitPrice}"/>-->
  179. <!--</li>-->
  180. <!--<li class="form-item">-->
  181. <!--<span>生产日期:</span>-->
  182. <!--<input type="text" class="form-control" v-model="applyObj.produceDate"/>-->
  183. <!--</li>-->
  184. <li class="form-item">
  185. <span>采购数量(PCS):</span>
  186. <input type="number" class="form-control" v-model="applyObj.amount" :class="{'error': !validObj.amount}"/>
  187. </li>
  188. </ul>
  189. </div>
  190. <span slot="footer" class="dialog-footer">
  191. <button @click="authorityInterceptor(baseUrls.userPublishSeek, goPublish)" :disabled="isClick">询价提交</button>
  192. </span>
  193. </el-dialog>
  194. </div>
  195. </template>
  196. <script>
  197. function initFragment (commodity) {
  198. if (!commodity) {
  199. return {}
  200. }
  201. let fragment = {}
  202. let prices = commodity.prices.length > 0 ? commodity.prices[0] : {}
  203. fragment.num = commodity.minBuyQty
  204. fragment.prices = prices
  205. if (commodity.currencyName !== 'USD') {
  206. fragment.currency = 'RMB'
  207. } else {
  208. fragment.currency = 'USD'
  209. }
  210. if (fragment.currency !== 'USD') {
  211. fragment.price = prices.rMBPrice
  212. } else {
  213. fragment.price = prices.uSDPrice
  214. }
  215. fragment.canAdd = true
  216. fragment.canSub = false
  217. return fragment
  218. }
  219. function getFragment (commodity, fragment) {
  220. // 判断是否小于第一分段的起订量
  221. if (commodity.prices[0].start > fragment.num) {
  222. fragment.num = commodity.prices[0].start
  223. }
  224. // 获取分段的信息
  225. let prices = commodity.prices
  226. for (let i = 0; i < prices.length; i++) {
  227. if (fragment.num <= prices[i].end) {
  228. fragment.prices = prices[i]
  229. break
  230. }
  231. }
  232. }
  233. export default {
  234. name: 'commodity-info',
  235. data () {
  236. return {
  237. isClick: false,
  238. applyObj: {
  239. cmpCode: '',
  240. brand: '',
  241. unitPrice: '',
  242. currency: 'RMB',
  243. prodName: '',
  244. spec: '',
  245. encapsulation: '',
  246. produceDate: '',
  247. amount: '',
  248. deadline: ''
  249. },
  250. validObj: {
  251. unitPrice: true,
  252. amount: true,
  253. deadline: true
  254. },
  255. pickerOptions: {
  256. disabledDate (time) {
  257. // 大于等于今天 小于三个月后
  258. return time.getTime() < Date.now() - 1000 * 60 * 60 * 24 || time.getTime() > Date.now() + 1000 * 60 * 60 * 24 * 30 * 3
  259. }
  260. },
  261. hasDialog: false,
  262. fragment: {
  263. currency: 'RMB',
  264. num: 0,
  265. price: 0,
  266. canAdd: true,
  267. canSub: true}
  268. }
  269. },
  270. watch: {
  271. fragment: function (val, oldVal) {
  272. }
  273. },
  274. filters: {
  275. currencyShort: function (num) {
  276. if (typeof num === 'number' && num > 0) {
  277. if (num <= 0.01) {
  278. num = 0.01
  279. } else {
  280. if (num.toString().indexOf('.') === -1) {
  281. num += '.00'
  282. } else {
  283. let inputStr = num.toString()
  284. let arr = inputStr.split('.')
  285. let floatNum = arr[1]
  286. if (floatNum && arr[0]) {
  287. if (floatNum.length > 2) {
  288. num = inputStr.substring(0, arr[0].length + 3)
  289. if (Number(floatNum.charAt(2)) >= 1) {
  290. num = (Math.ceil(Number(num) * 100) + 1) / 100
  291. let inputStr1 = num.toString()
  292. let arr1 = inputStr1.split('.')
  293. let floatNum1 = arr1[1]
  294. if (num.toString().indexOf('.') === -1) {
  295. num += '.00'
  296. }
  297. if (floatNum1 && floatNum1.length === 1) {
  298. num = num + '0'
  299. }
  300. }
  301. } else if (floatNum.length === 1) {
  302. num = num + '0'
  303. }
  304. }
  305. }
  306. }
  307. }
  308. return num
  309. },
  310. currency: function (num) {
  311. if (typeof num === 'number' && num > 0) {
  312. if (num <= 0.000001) {
  313. num = 0.000001
  314. } else {
  315. if (num.toString().indexOf('.') === -1) {
  316. num += '.00'
  317. } else {
  318. let inputStr = num.toString()
  319. let arr = inputStr.split('.')
  320. let floatNum = arr[1]
  321. if (floatNum && arr[0]) {
  322. if (floatNum.length > 6) {
  323. num = inputStr.substring(0, arr[0].length + 7)
  324. if (Number(floatNum.charAt(6)) > 4) {
  325. num = (Number(num) * 1000000 + 1) / 1000000
  326. }
  327. } else if (floatNum.length === 1) {
  328. num = num + '0'
  329. }
  330. }
  331. }
  332. }
  333. }
  334. return num
  335. }
  336. },
  337. computed: {
  338. storeInfo () {
  339. return this.$store.state.shop.storeInfo.store.data
  340. },
  341. commodity () {
  342. let commodity = this.$store.state.shop.storeInfo.commodity.data
  343. this.fragment = initFragment(commodity)
  344. return commodity
  345. },
  346. component () {
  347. return this.$store.state.shop.storeInfo.component.data
  348. },
  349. calculate () {
  350. this.fragment.total = this.fragment.price * Math.pow(10, 6) * this.fragment.num
  351. return Math.ceil(this.fragment.total) / Math.pow(10, 6)
  352. },
  353. user () {
  354. return this.$store.state.option.user
  355. },
  356. isConsignment () {
  357. return this.storeInfo.type === 'CONSIGNMENT'
  358. }
  359. },
  360. mounted () {
  361. this.$nextTick(() => {
  362. this.loadSaveHistory()
  363. })
  364. },
  365. methods: {
  366. isSpecificPriceTag: function (tag) {
  367. return tag && tag.indexOf('特价') !== -1
  368. },
  369. onInput () {
  370. let prices = this.commodity.prices
  371. if (prices && prices.length) {
  372. let _this = this
  373. for (let i = 0; i < prices.length; i++) {
  374. if (_this.fragment.num >= prices[i].start && _this.fragment.num <= prices[i].end) {
  375. _this.fragment.price = _this.fragment.currency === 'RMB' ? prices[i].rMBPrice : prices[i].uSDPrice
  376. break
  377. }
  378. }
  379. }
  380. },
  381. loadSaveHistory () {
  382. if (this.user.logged) {
  383. this.$store.dispatch('shop/saveHistory', {id: this.commodity.batchCode})
  384. }
  385. },
  386. changeCurrency () {
  387. if (this.fragment.currency === 'RMB') {
  388. this.fragment.price = this.fragment.prices.rMBPrice
  389. } else if (this.fragment.currency === 'USD') {
  390. this.fragment.price = this.fragment.prices.uSDPrice
  391. }
  392. },
  393. changeNum: function (newNum) {
  394. let pack = this.commodity.perQty || this.commodity.minPackQty
  395. let buy = this.commodity.minBuyQty
  396. let reserve = this.commodity.reserve
  397. let breakUp = this.commodity.breakUp
  398. if (!newNum) {
  399. this.fragment.num = buy
  400. } else {
  401. newNum = parseInt(newNum)
  402. if (breakUp) {
  403. if (newNum < buy) {
  404. this.$message.error('最小起订量为' + buy)
  405. this.fragment.num = buy
  406. this.fragment.canSub = false
  407. this.fragment.canAdd = true
  408. } else if (newNum > reserve) {
  409. this.$message.error('库存不足')
  410. this.fragment.num = reserve
  411. this.fragment.canAdd = false
  412. this.fragment.canSub = true
  413. } else {
  414. this.fragment.canSub = true
  415. this.fragment.canAdd = true
  416. this.fragment.num = newNum
  417. newNum === buy && (this.fragment.canSub = false)
  418. newNum === reserve && (this.fragment.canAdd = false)
  419. }
  420. } else {
  421. if (newNum < buy) {
  422. this.$message.error('最小起订量为' + buy)
  423. this.fragment.num = buy
  424. this.fragment.canSub = false
  425. if (newNum > reserve) {
  426. this.$message.error('库存不足')
  427. this.fragment.num = reserve - (reserve % pack)
  428. this.fragment.canAdd = false
  429. }
  430. } else if (newNum > reserve) {
  431. this.fragment.canSub = true
  432. this.fragment.canAdd = false
  433. this.$message.error('库存不足')
  434. this.fragment.num = reserve - (reserve % pack)
  435. } else {
  436. this.fragment.canSub = true
  437. this.fragment.canAdd = true
  438. let remainder = newNum % pack
  439. if (remainder !== 0) {
  440. // console.log(this.fragment.num)
  441. this.$message.error('不支持拆包且包装量为' + pack)
  442. // 这个直接赋值的,应该给这个值进行判断(Math.floor(newNum / pack) + 1) * pack
  443. let res = (Math.floor(newNum / pack) + 1) * pack
  444. this.fragment.num = res > reserve ? Math.floor(newNum / pack) * pack : res
  445. } else {
  446. this.fragment.num = newNum
  447. }
  448. newNum === buy && (this.fragment.canSub = false)
  449. newNum === reserve && (this.fragment.canAdd = false)
  450. }
  451. }
  452. }
  453. },
  454. subNum () {
  455. let pack = this.commodity.perQty || this.commodity.minPackQty
  456. let newNum = 0
  457. if (this.commodity.breakUp) {
  458. newNum = this.fragment.num - 1
  459. } else {
  460. newNum = this.fragment.num - pack
  461. }
  462. this.changeNum(newNum)
  463. getFragment(this.commodity, this.fragment)
  464. this.onInput()
  465. },
  466. addNum () {
  467. let pack = this.commodity.perQty || this.commodity.minPackQty
  468. let newNum = 0
  469. if (this.commodity.breakUp) {
  470. newNum = this.fragment.num + 1
  471. } else {
  472. newNum = this.fragment.num + pack
  473. }
  474. this.changeNum(newNum)
  475. getFragment(this.commodity, this.fragment)
  476. this.onInput()
  477. },
  478. inputNum () {
  479. if ((/^[\d]*$/).test(this.fragment.num)) {
  480. this.changeNum(this.fragment.num)
  481. getFragment(this.commodity, this.fragment)
  482. } else {
  483. this.$message.error('请输入整数')
  484. this.fragment.num = this.commodity.minBuyQty
  485. }
  486. },
  487. buyNow: function (isBuy, item) {
  488. if (!this.$store.state.option.user.logged) {
  489. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  490. if (response.data) {
  491. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
  492. }
  493. })
  494. } else {
  495. if (item) {
  496. if (isBuy) {
  497. this.$http.post('/trade/order/buyNow', [{
  498. uuid: item.uuid,
  499. batchCode: item.batchCode,
  500. number: this.fragment.num,
  501. storeid: item.storeid,
  502. storeUuid: item.storeid,
  503. currencyName: item.currencyName,
  504. minPackQty: item.minPackQty
  505. }])
  506. .then(response => {
  507. if (response.data.success) {
  508. if (response.data.message) {
  509. this.$message({
  510. message: response.data.message,
  511. type: 'success'
  512. })
  513. window.setTimeout(function () {
  514. window.location.href = '/user#/order/pay/' + this.baseUtils.enidfilter(response.data.data.orderid)
  515. }, 1000)
  516. } else {
  517. window.location.href = '/user#/order/pay/' + this.baseUtils.enidfilter(response.data.data.orderid)
  518. }
  519. } else {
  520. if (response.data.data && response.data.data.unvailable === 1) {
  521. this.$message.error('产品信息已失效,请刷新界面')
  522. } else {
  523. this.$message.error(response.data.message)
  524. }
  525. }
  526. }, err => {
  527. // console.log(err)
  528. if (item.minBuyQty > item.reserve) {
  529. this.$message.error('商品' + item.code + '的库存已经不满足最小起订量')
  530. }
  531. })
  532. } else {
  533. // this.$store.dispatch('user/addCar', {uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty})
  534. this.$http.post('/trade/cart/add', {
  535. uuid: item.uuid,
  536. batchCode: item.batchCode,
  537. number: this.fragment.num,
  538. storeid: item.storeid,
  539. storeUuid: item.storeid,
  540. currencyName: item.currencyName,
  541. minPackQty: item.minPackQty
  542. })
  543. .then(response => {
  544. if (response.data.success) {
  545. if (response.data.message) {
  546. this.$message({
  547. message: '添加购物车成功,但商品信息有更新',
  548. type: 'success'
  549. })
  550. } else {
  551. this.$message({
  552. message: '添加购物车成功',
  553. type: 'success'
  554. })
  555. }
  556. } else {
  557. if (response.data.code === 2) {
  558. this.$message.error(response.data.message + ',请刷新页面')
  559. } else {
  560. this.$message.error(response.data.message)
  561. }
  562. }
  563. })
  564. }
  565. }
  566. }
  567. },
  568. toAttach: function (url) {
  569. if (this.user.logged) {
  570. if (url && url !== '1') {
  571. window.open(url)
  572. } else {
  573. this.$message.error('规格书地址错误')
  574. }
  575. } else {
  576. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  577. if (response.data) {
  578. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
  579. }
  580. })
  581. }
  582. },
  583. // 格式化字符串长度
  584. spliceString (str, length) {
  585. return str && str.length ? this.baseUtils.spliceStr(str, length) : '暂无信息'
  586. },
  587. // 弹出询价界面
  588. immediatelyClick (type, event) {
  589. event.stopPropagation()
  590. if (!this.user.logged) {
  591. this.$router.push('/auth/login?returnUrl=' + window.location.href)
  592. } else {
  593. this.hasDialog = true
  594. this.applyObj.cmpCode = type.code
  595. this.applyObj.brand = type.brandNameEn
  596. this.applyObj.spec = type.spec
  597. this.applyObj.prodName = type.kindNameCn
  598. }
  599. },
  600. // 时间格式化
  601. setDeadLineValid: function () {
  602. if(this.applyObj.deadline === '') {return ''}
  603. this.applyObj.deadline = this.baseUtils.formatDate(this.baseUtils.getFullDay(new Date(this.applyObj.deadline)), 'yyyy-MM-dd hh:mm:ss')
  604. this.validObj.deadline = true
  605. },
  606. // 检查单价预算
  607. checkUnitPrice () {
  608. this.validObj.unitPrice = this.applyObj.unitPrice === '' ? true : this.applyObj.unitPrice > 0 && this.applyObj.unitPrice < 100000000
  609. if (!this.validObj.unitPrice && this.applyObj.unitPrice <= 0) {
  610. this.$message.error('单价必须是大于0的数字')
  611. }
  612. return this.validObj.unitPrice
  613. },
  614. // 检查采购数量
  615. checkAmount () {
  616. this.validObj.amount = this.applyObj.amount === '' ? true : this.applyObj.amount > 0 && this.applyObj.amount < 1000000000
  617. return this.validObj.amount
  618. },
  619. // 检查时间是否有输入
  620. checkDeadline () {
  621. this.validObj.deadline = Boolean(this.applyObj.deadline)
  622. return this.validObj.deadline
  623. },
  624. // 检查各个字段输入正常数据
  625. checkAll () {
  626. return this.checkDeadline() && this.checkUnitPrice() && this.checkAmount()
  627. },
  628. emptyForm () {
  629. for (let attr in this.applyObj) {
  630. this.applyObj[attr] = attr === 'currency' ? 'RMB' : ''
  631. }
  632. },
  633. // 请求询价信息
  634. goPublish () {
  635. let _this = this
  636. this.isClick = true
  637. setTimeout(function () {
  638. _this.isClick = false
  639. }, 1000)
  640. if (this.checkAll()) {
  641. let inquiry = {}
  642. let inquiryItem = {}
  643. if (this.user.data.enterprise) {
  644. inquiry.enUU = this.user.data.enterprise.uu
  645. }
  646. let date = new Date()
  647. let currency = this.applyObj.unitPrice ? this.applyObj.currency : null
  648. inquiry.recorderUU = this.user.data.userUU
  649. inquiry.code = 'MALL' + date.getTime()
  650. inquiry.date = date
  651. inquiry.recorder = this.user.data.userName
  652. inquiry.endDate = this.applyObj.deadline
  653. inquiry.sourceapp = 'MALL'
  654. inquiry.amount = 1
  655. inquiryItem.userUU = this.user.data.userUU
  656. inquiryItem.source = 'MALL'
  657. inquiryItem.userName = this.user.data.userName
  658. inquiryItem.userTel = this.user.data.userTel
  659. inquiryItem.needquantity = this.applyObj.amount
  660. inquiryItem.inbrand = this.applyObj.brand
  661. inquiryItem.currency = currency
  662. inquiryItem.cmpCode = this.applyObj.cmpCode.toUpperCase()
  663. inquiryItem.unitPrice = this.applyObj.unitPrice
  664. inquiryItem.produceDate = this.applyObj.produceDate
  665. inquiryItem.date = date
  666. inquiryItem.endDate = this.applyObj.deadline
  667. inquiryItem.encapsulation = this.applyObj.encapsulation
  668. inquiryItem.spec = this.applyObj.spec
  669. inquiryItem.prodTitle = this.applyObj.prodName
  670. let inquiryItems = []
  671. inquiryItems.push(inquiryItem)
  672. inquiry.inquiryItems = inquiryItems
  673. inquiry.currency = this.applyObj.unitPrice ? this.applyObj.currency : null
  674. this.$http.post('/inquiry/buyer/save', inquiry)
  675. .then(res => {
  676. this.$message.success('发布成功')
  677. this.hasDialog = false
  678. this.emptyForm()
  679. }, error => {
  680. // console.log(error)
  681. this.$message.error('发布失败')
  682. })
  683. } else {
  684. if (!this.validObj.deadline) {
  685. this.$message.error('截止日期不能为空')
  686. } else if (!this.validObj.amount) {
  687. this.$message.error('请输入正确的数值')
  688. }
  689. }
  690. }
  691. }
  692. }
  693. </script>
  694. <style type="text/scss" lang="scss">
  695. .btn-buy-now {
  696. background-color: #5078CB;
  697. color: #fff;
  698. width: 80px;
  699. height: 30px;
  700. font-size: 12px;
  701. border: 1px solid #5078cb;
  702. position: relative;
  703. }
  704. .btn-add-cart {
  705. margin-top: 10px;
  706. color: #214797;
  707. width: 80px;
  708. height: 30px;
  709. font-size: 12px;
  710. background-color: #fff;
  711. border: 1px solid #e8e8e8;
  712. }
  713. .btn-buy-now:hover{
  714. background: #214797;
  715. }
  716. .btn-buy-now.disabled,
  717. .btn-buy-now.disabled:focus{
  718. background-color: #d1d2d3!important;
  719. border: none!important;
  720. outline: none;
  721. color: #fff!important;
  722. cursor: not-allowed;
  723. }
  724. .el-dialog{
  725. width: 680px!important;
  726. .el-dialog__header{
  727. background: #4290f7;
  728. line-height: 40px;
  729. padding: 0 20px 0;
  730. display:block;
  731. .el-dialog__title{
  732. color:#fff;
  733. }
  734. .el-dialog__headerbtn:hover .el-dialog__close, .el-dialog__headerbtn:focus .el-dialog__close{
  735. color:#fff;
  736. }
  737. }
  738. .el-dialog__body{
  739. padding: 10px 20px;
  740. }
  741. .el-dialog__footer{
  742. text-align: center;
  743. button{
  744. display:inline-block;
  745. background: #3c7cf5;
  746. color:#fff;
  747. font-size: 14px;
  748. line-height: 30px;
  749. height:30px;
  750. padding:0 10px;
  751. box-shadow: none;
  752. border: 0;
  753. border-radius:5px;
  754. }
  755. }
  756. }
  757. .form_dialog{
  758. .el-date-editor--date{
  759. width: 230px;
  760. &.error {
  761. input {
  762. border: 1px solid #f4645f !important;
  763. }
  764. }
  765. }
  766. ul{
  767. li{
  768. width:50%;
  769. font-size: 14px;
  770. color:#666;
  771. vertical-align: top;
  772. margin-bottom:15px;
  773. &.form-item {
  774. position: relative;
  775. p{
  776. margin:0;
  777. margin-left:80px;
  778. word-break: break-all;
  779. word-wrap: break-word;
  780. }
  781. span {
  782. float:left;
  783. width: 112px;
  784. text-align: right;
  785. display: inline-block;
  786. color:#3c7cf5;
  787. i {
  788. position: relative;
  789. top: 2px;
  790. right: 5px;
  791. color: #e41515;
  792. }
  793. }
  794. ul {
  795. line-height: normal;
  796. position: absolute;
  797. top: 19px;
  798. left: 79px;
  799. background: #fff;
  800. border: 1px solid #b5b5b5;
  801. z-index: 1;
  802. max-height: 120px;
  803. overflow-y: auto;
  804. overflow-x: hidden;
  805. border-radius: 3px;
  806. width: 114px;
  807. font-size: 12px;
  808. li {
  809. height: 24px;
  810. line-height: 24px;
  811. cursor: pointer;
  812. overflow: hidden;
  813. text-overflow: ellipsis;
  814. white-space: nowrap;
  815. padding: 0 5px;
  816. &:hover {
  817. background: #ddd;
  818. }
  819. }
  820. }
  821. select {
  822. width: 40px;
  823. position: absolute;
  824. height: 20px;
  825. background: url('/images/applyPurchase/select.png')no-repeat right;
  826. background-position-x: 23px;
  827. padding: 0 0 0 7px;
  828. border-radius: 0;
  829. & + input {
  830. padding-left: 45px;
  831. }
  832. }
  833. .el-input {
  834. width: 198px;
  835. }
  836. input {
  837. font-size: 14px;
  838. width: 198px;
  839. height: 20px;
  840. line-height: 20px;
  841. border-radius: 2px;
  842. padding: 0 3px;
  843. box-shadow: none;
  844. -webkit-box-shadow: none;
  845. -moz-box-shadow: none;
  846. &.error {
  847. border-color: #f4645f!important;
  848. }
  849. }
  850. }
  851. }
  852. }
  853. }
  854. .container.commodity {
  855. width: 1190px;
  856. padding-left: 0;
  857. padding-right: 0;
  858. }
  859. .commodity .commodity-detail {
  860. width: 100%;
  861. display: inline-block;
  862. font-size: 0;
  863. }
  864. .commodity-detail .img{
  865. float: left;
  866. width: 258px;
  867. height: 320px;
  868. position: relative;
  869. }
  870. .commodity-detail .img >img {
  871. border: 1px solid #D6D3CE;
  872. }
  873. .commodity-detail .img .specific-price {
  874. position: absolute;
  875. left: 0;
  876. top: 0;
  877. border: none;
  878. }
  879. .commodity-detail .img .box {
  880. height: 62px;
  881. position: relative;
  882. }
  883. .commodity-detail .img .box img {
  884. position: absolute;
  885. right: 3px;
  886. bottom: 64px;
  887. }
  888. .commodity-detail .content {
  889. width: 932px;
  890. float: left;
  891. font-size: 14px;
  892. }
  893. .commodity-detail .content {
  894. padding-left: 20px;
  895. }
  896. .commodity-detail .content .code {
  897. font-size: 24px;
  898. color: rgb(50, 50, 50);
  899. font-weight: 600;
  900. border-bottom: 1px solid #D6D3CE;
  901. line-height: 40px;
  902. }
  903. .commodity-detail .content .code span{
  904. word-break: break-all;
  905. }
  906. .commodity-detail .content .com-info {
  907. font-size: 14px;
  908. line-height: 26px;
  909. }
  910. .commodity-detail .content .com-info em {
  911. font-size: 14px;
  912. line-height: 26px;
  913. font-style: normal;
  914. }
  915. .input-group .input-group-operate {
  916. padding: 6px 12px;
  917. font-size: 14px;
  918. font-weight: 400;
  919. line-height: 1;
  920. color: #555;
  921. text-align: center;
  922. background-color: #eee;
  923. border: 1px solid #ccc;
  924. border-radius: 4px;
  925. }
  926. .input-group .input-group-operate:last-child {
  927. border-bottom-left-radius: 0;
  928. border-top-left-radius: 0;
  929. }
  930. .input-group .input-group-operate:first-child {
  931. border-bottom-right-radius: 0;
  932. border-top-right-radius: 0;
  933. }
  934. .content .com-info .name {
  935. display: inline-block;
  936. width: 80px;
  937. letter-spacing: 15px;
  938. }
  939. .content .com-info .no-letter {
  940. letter-spacing: 1.5px;
  941. }
  942. .content .com-info a{
  943. color: #1162a4;
  944. }
  945. .content .com-info:hover a{
  946. color: #23527c;
  947. }
  948. .content .warn-area {
  949. font-size: 16px;
  950. font-weight: bold;
  951. color: #333;
  952. margin-top: 15px;
  953. }
  954. .commodity-info-detail {
  955. float: left;
  956. padding-top: 10px;
  957. width: 582px;
  958. }
  959. .price-block {
  960. float: right;
  961. width: 330px;
  962. margin-top: 10px;
  963. height: 220px;
  964. }
  965. .commodity-price {
  966. line-height: 30px;
  967. text-align: center;
  968. border: 1px solid #D6D3CE;
  969. }
  970. .commodity-price .title {
  971. background-color: #f7f7f7;
  972. border-bottom: 1px solid #D6D3CE;
  973. }
  974. .commodity-price .head {
  975. border-bottom: 1px solid #D6D3CE;
  976. }
  977. .commodity-price .fragment {
  978. display: inline-block;
  979. width: 150px;
  980. }
  981. .commodity-price .price {
  982. width: 150px;
  983. display: inline-block;
  984. }
  985. .com-info div.select {
  986. display: inline-block;
  987. font-weight: 600;
  988. color: red;
  989. font-size: 14px;
  990. }
  991. .com-info div.select .tax {
  992. font-weight: normal;
  993. color: black;
  994. font-size: 12px;
  995. }
  996. .com-info .operate {
  997. cursor: pointer;
  998. }
  999. .com-info .operate:hover, .com-info .operate:link {
  1000. background-color: #00B83F;
  1001. color: white;
  1002. }
  1003. .com-info .money {
  1004. font-weight: 600;
  1005. color: red;
  1006. font-size: 14px;
  1007. }
  1008. .com-info select {
  1009. border-radius: 4px;
  1010. width: 120px!important;
  1011. }
  1012. ul.list-inline {
  1013. margin: 0;
  1014. }
  1015. .commodity-price ul.list-inline li {
  1016. padding-left: 0;
  1017. padding-right: 0;
  1018. border-bottom: 1px dashed #D6D3CE;
  1019. }
  1020. .commodity-price .table {
  1021. margin-bottom: 0;
  1022. }
  1023. .commodity-price ul>li:last-child {
  1024. border-bottom: none;
  1025. }
  1026. div.button {
  1027. padding-top: 20px;
  1028. float: left;
  1029. }
  1030. button.btn-now {
  1031. border: 1px solid #3D76C6;
  1032. color: #3D76C6;
  1033. margin-left: 30px;
  1034. }
  1035. .com-info .delivery {
  1036. display: inline;
  1037. }
  1038. #commodity-info-fragment{
  1039. margin-bottom: 20px;
  1040. }
  1041. .commodity-detail .content .com-info .div-sell {
  1042. font-size: 12px;
  1043. height: 16px;
  1044. line-height: 16px;
  1045. color: #fff;
  1046. padding: 0 5px;
  1047. display: inline-block;
  1048. position: relative;
  1049. }
  1050. .commodity-detail .content .com-info .can-div-sell {
  1051. background: #5078cb;
  1052. }
  1053. .commodity-detail .content .com-info .not-div-sell {
  1054. background: #fc8200;
  1055. }
  1056. .commodity-detail .content .com-info .can-div-sell:before {
  1057. content: '';
  1058. position: absolute;
  1059. left: -8px;
  1060. top: 10px;
  1061. border-left: 8px solid transparent;
  1062. border-bottom: 6px solid #5078cb;
  1063. }
  1064. .commodity-detail .content .com-info .not-div-sell:before {
  1065. content: '';
  1066. position: absolute;
  1067. left: -8px;
  1068. top: 10px;
  1069. border-left: 8px solid transparent;
  1070. border-bottom: 6px solid #fc8200;
  1071. }
  1072. </style>