1
0

sale.js 88 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153
  1. $(function () {
  2. addressInit('cmbProvince', 'cmbCity', 'cmbArea', '---请选择---', '---请选择---', '---请选择---');
  3. $('.sendShow').hide();
  4. openWebSocket();
  5. queryAssistantInfo();
  6. var cwQrcode = new Image();
  7. var cwLogo2 = new Image();
  8. cwQrcode.src = "http://8.135.102.238:8080/statics/img/cw_qrcode.png";
  9. cwLogo2.src = "http://8.135.102.238:8080/statics/img/cw_logo2.png";
  10. vm.queryGoods();
  11. });
  12. window.onbeforeunload = function(){
  13. closeWebSocket();
  14. }
  15. // addressInit('Select1', 'Select2', 'Select3');
  16. function debounce(fn,delay){
  17. var timer=null
  18. return function(){
  19. console.log(timer);
  20. if(timer){
  21. clearTimeout(timer)
  22. }
  23. timer = setTimeout(fn,delay)
  24. }
  25. }
  26. function calculateGoodsPrice(r){
  27. var rMap = r.map;
  28. var barCode = r.goodsDetails.prodBarcode;
  29. var brand = r.goodsDetails.brand;
  30. console.log(rMap);
  31. if(rMap.yhq){
  32. for(var i in rMap.yhq){
  33. vm.coupons.set(i,rMap.yhq[i]);
  34. }
  35. }
  36. // 是否有满减活动
  37. if(rMap.mj){
  38. if(rMap.mj[barCode] && !vm.mj.get(barCode)){
  39. // 该商品是否已经有过满减活动
  40. vm.mj.set(barCode,rMap.mj[barCode]);
  41. }else if(rMap.mj[brand] && !vm.mj.get(brand)){
  42. // 该品牌是否已经有过满减活动
  43. vm.mj.set(brand,rMap.mj[brand]);
  44. }
  45. }
  46. if(rMap.mysy){
  47. // 买的条码, 买的数量,送的条码,送的数量
  48. var mysy = {
  49. buyNum:rMap.mysy.buyNum,
  50. giftBarcode:rMap.mysy.giftBarcode,
  51. sendNum:rMap.mysy.sendNum
  52. };
  53. if(rMap.mysy.brand){
  54. vm.brandGetOneFree.set(rMap.mysy.productBrand,mysy);
  55. }else{
  56. vm.barcodeGetOneFree.set(rMap.mysy.barcode , mysy);
  57. }
  58. }
  59. if(rMap.mz){
  60. if(rMap.mz[barCode] && !vm.mz.get(barCode)){
  61. // 该商品是否已经有过满赠活动
  62. vm.mz.set(barCode,rMap.mz[barCode]);
  63. }else if(rMap.mz[brand] && !vm.mz.get(brand)){
  64. // 该品牌是否已经有过满赠活动
  65. vm.mz.set(brand,rMap.mz[brand]);
  66. }
  67. }
  68. if(rMap.drjbj){
  69. if(!vm.halfPrice.get(rMap.drjbj.barcode)){
  70. vm.halfPrice.set(rMap.drjbj.barcode,1);
  71. }
  72. }
  73. // if(rMap.zhjsp){
  74. // // 遍历该商品所有可能的组合价商品类型
  75. // for(var data in rMap.zhjsp){
  76. // if(!vm.zhjsp.get(data)){
  77. // // 分割组合价商品的条码,并以 条码:0 放入map中
  78. // var barCodeArray = data.toString().split(":");
  79. // var dataMap = new Map();
  80. // console.log(rMap.zhjsp[data]);
  81. // // dataMap.set();
  82. // for(var j = 0 ; j < barCodeArray.length ; j ++){
  83. // dataMap.set(barCodeArray[j],0);
  84. // }
  85. // vm.combinationPrice.set(data,rMap.zhjsp[data][0].combinedPrice)
  86. //
  87. // vm.zhjsp.set(data,dataMap);
  88. // }
  89. // }
  90. //
  91. // }
  92. // calculateGoodsByMj(r.goodsDetails,"add");
  93. calculateGoodsByMysy(r.goodsDetails,"add");
  94. calculateGoodsByMz(r.goodsDetails,"add");
  95. calculateGoodsByHalfPrice(r.goodsDetails,"add");
  96. // calculateGoodsByZhjsp(r);
  97. }
  98. // ==================== 满减==========================
  99. // 满减
  100. function calculateGoodsByMj(goodsDetails,type){
  101. if(vm.mj.get(goodsDetails.prodBarcode)){
  102. fullReduction(goodsDetails,goodsDetails.prodBarcode);
  103. }else if(vm.mj.get(goodsDetails.brand)){
  104. fullReduction(goodsDetails,goodsDetails.brand);
  105. }
  106. }
  107. // 满减的计算内容
  108. function fullReduction(goodsDetails,key){
  109. // 获取满减条件金额
  110. var qualifiedAmount = vm.mj.get(key).qualifiedAmount;
  111. // 获取已累积金额
  112. var money = vm.accumulatedAmount.get(key);
  113. if(isNaN(money)){
  114. money = goodsDetails.retailPrice;
  115. }else{
  116. money = money + goodsDetails.retailPrice;
  117. }
  118. if(money >= qualifiedAmount){
  119. vm.reduceMoney += vm.mj.get(key).deductionAmount; // 达到满减金额,获取扣减的额度
  120. vm.mj.delete(key); // 获取后删除该商品的满减
  121. vm.accumulatedAmount.delete(key); // 删除满减的金额
  122. }else{
  123. vm.accumulatedAmount.set(key,money);
  124. }
  125. }
  126. // ============================= 第二件半价==========================
  127. function calculateGoodsByHalfPrice(goodsDetails,type){
  128. var half = vm.halfPrice.get(goodsDetails.prodBarcode);
  129. if(half){
  130. var discountPrice = goodsDetails.retailPrice / 2;
  131. if(type == "add"){
  132. // 等于一的话,不满足条件
  133. if(half == 1){
  134. vm.halfPrice.set(goodsDetails.prodBarcode,2);
  135. }else if(half == 2){
  136. goodsDetails.actualPaymentAmount = discountPrice;
  137. goodsDetails.discountedPrice = discountPrice;
  138. vm.halfPrice.set(goodsDetails.prodBarcode,1);
  139. }
  140. }else if(type == "minus"){
  141. if(half == 2){
  142. goodsDetails.actualPaymentAmount = goodsDetails.actualPaymentAmount ;
  143. vm.halfPrice.set(goodsDetails.prodBarcode,1);
  144. }else if(half == 1){
  145. goodsDetails.actualPaymentAmount = goodsDetails.actualPaymentAmount - discountPrice;
  146. goodsDetails.discountedPrice = discountPrice;
  147. vm.halfPrice.set(goodsDetails.prodBarcode,2);
  148. }
  149. }
  150. }
  151. }
  152. // ============================= 满赠 ==============================
  153. // 满赠
  154. function calculateGoodsByMz(goodsDetails,type){
  155. // 判断当前支付金额是否满足满赠金额,若满足,直接修改金额为1
  156. var mzGoods = vm.mz.get(goodsDetails.prodBarcode);
  157. if(mzGoods){
  158. var mzPrice = mzGoods.qualifiedAmount;
  159. if(mzPrice < vm.actualPrice && !mzGoods.useMz){
  160. mzGoods.useMz = true;
  161. goodsDetails.actualPaymentAmount = 1;
  162. goodsDetails.discountedPrice = goodsDetails.retailPrice - 1;
  163. }
  164. }
  165. // // 1.满赠的商品是不是自己,遍历满赠商品数组
  166. // isSend(vm.fullGiftCode,goodsDetails,"满赠");
  167. //
  168. // if(vm.mz.get(goodsDetails.prodBarcode)){
  169. // fullGift(goodsDetails,goodsDetails.prodBarcode);
  170. // }else if(vm.mz.get(goodsDetails.brand)){
  171. // fullGift(goodsDetails,goodsDetails.brand);
  172. // }
  173. }
  174. function fullGift(goodsDetails,key){
  175. // 获取满赠条件金额
  176. var qualifiedAmount = vm.mz.get(key).qualifiedAmount;
  177. // 获取已累积金额
  178. var money = vm.accumulatedAmountForFullGift.get(key);
  179. if(isNaN(money)){
  180. money = goodsDetails.retailPrice;
  181. }else{
  182. money = money + goodsDetails.retailPrice;
  183. }
  184. // 达到满赠的要求
  185. if(money >= qualifiedAmount){
  186. // 将满赠的商品放入数组中,重置金额
  187. vm.fullGiftCode.push(vm.mz.get(key).giftBarcode);
  188. vm.mz.delete(key); // 获取后删除该商品的满减
  189. vm.accumulatedAmountForFullGift.delete(key); // 删除满减的金额
  190. // 2.购物车的商品里面是否有满赠的商品
  191. shopCartContain(vm.fullGiftCode,goodsDetails,"满赠");
  192. }else{
  193. vm.accumulatedAmountForFullGift.set(key,money);
  194. }
  195. }
  196. // 买一送一
  197. function calculateGoodsByMysy(goodsDetails,type){
  198. var mysy = vm.barcodeGetOneFree.get(goodsDetails.prodBarcode);
  199. var brandMysy = vm.brandGetOneFree.get(goodsDetails.brand);
  200. if(mysy){
  201. var buyNum = mysy.buyNum;
  202. if(type == "add"){
  203. // 证明是买一送一,并且达到买一送一的条件
  204. if(buyNum == 1 && vm.boughtNum.get(goodsDetails.prodBarcode)){
  205. // 设置赠品的单价
  206. goodsDetails.discountedPrice = goodsDetails.retailPrice;
  207. goodsDetails.actualPaymentAmount = 0;
  208. // goodsDetails.activity = "买1送1";
  209. // 清除该商品买一送一条件
  210. vm.boughtNum.delete(goodsDetails.prodBarcode);
  211. return ;
  212. }
  213. // 如果不是买一送一,而是买n送n,先获取购物车已有该类型商品数量
  214. var boughtNum = vm.boughtNum.get(goodsDetails.prodBarcode);
  215. // 如果没有,置为1
  216. if(!boughtNum){
  217. vm.boughtNum.set(goodsDetails.prodBarcode , 1);
  218. return ;
  219. }
  220. // 走到这里,证明购买过该类型商品,且数量不是买一送一的
  221. // 如果相等,证明达到送的条件
  222. if(buyNum === boughtNum){
  223. goodsDetails.discountedPrice = goodsDetails.retailPrice;
  224. goodsDetails.actualPaymentAmount = 0;
  225. // goodsDetails.activity = "买"+buyNum+"送1";
  226. // 清除该商品买一送一条件
  227. vm.boughtNum.delete(goodsDetails.prodBarcode);
  228. console.log(vm.boughtNum);
  229. }else{
  230. // 如果不相等,已经购买数量+1
  231. vm.boughtNum.set(goodsDetails.prodBarcode , boughtNum+1);
  232. }
  233. }else if (type == "minus"){
  234. // 获取该产品要买n送1 的n
  235. // 获取已经购买的数量
  236. var boughtNum = goodsDetails.sellVolume;
  237. // 减一后,不满足买一送一条件,重新计算金额
  238. // 如果不等于0,要减去价格
  239. var remainder = 0;
  240. if(boughtNum > buyNum+1){
  241. remainder = buyNum - (boughtNum % (buyNum+1)) ;
  242. }else{
  243. remainder = buyNum - ((buyNum+1) %boughtNum ) ;
  244. }
  245. if(boughtNum % (buyNum+1) != 0){
  246. // console.log("我要减去价格,也要减去数量,减去数量=" + goodsDetails.sellVolume);
  247. goodsDetails.actualPaymentAmount = goodsDetails.retailPrice;
  248. goodsDetails.discountedPrice = 0;
  249. // 如果等于0,只用减去数量跟优惠价,并恢复活动
  250. }else{
  251. // console.log("我不用减去价格,只要减去数量");
  252. goodsDetails.discountedPrice = goodsDetails.retailPrice;
  253. goodsDetails.actualPaymentAmount = 0;
  254. }
  255. goodsDetails.sellVolume = 1;
  256. vm.boughtNum.set(goodsDetails.prodBarcode,remainder);
  257. }
  258. }
  259. if(brandMysy){
  260. var buyNum = brandMysy.buyNum;
  261. if(type == "add"){
  262. // 如果不是买一送一,而是买n送n,先获取购物车已有该类型商品数量
  263. var boughtNum = vm.boughtNum.get(goodsDetails.brand);
  264. // 如果没有,置为1
  265. if(!boughtNum){
  266. vm.boughtNum.set(goodsDetails.brand , 1);
  267. return ;
  268. }
  269. // 走到这里,证明购买过该类型商品,且数量不是买一送一的
  270. // 如果相等,证明达到送的条件
  271. if(buyNum === boughtNum + 1){
  272. var mysyNum = vm.freeBardcode.get(brandMysy.giftBarcode);
  273. if(!mysyNum){
  274. mysyNum = 0;
  275. }
  276. vm.freeBardcode.set(brandMysy.giftBarcode,mysyNum + 1);
  277. vm.boughtNum.set(goodsDetails.brand,0);
  278. }else{
  279. // 如果不相等,已经购买数量+1
  280. vm.boughtNum.set(goodsDetails.brand , boughtNum+1);
  281. }
  282. }else if (type == "minus"){
  283. var mysyNum = vm.boughtNum.get(goodsDetails.brand);
  284. if(mysyNum == 0){
  285. if(vm.freeBardcode.get(brandMysy.giftBarcode) == 0){
  286. vm.freeBardcode.set(brandMysy.giftBarcode,-1);
  287. }else{
  288. vm.freeBardcode.set(brandMysy.giftBarcode,vm.freeBardcode.get(brandMysy.giftBarcode) - 1);
  289. }
  290. vm.boughtNum.set(goodsDetails.brand,buyNum - 1);
  291. }else{
  292. vm.boughtNum.set(goodsDetails.brand,mysyNum - 1);
  293. }
  294. // var freeNum = vm.freeBardcode.get(brandMysy.giftBarcode);
  295. // if(freeNum > 0){
  296. // vm.freeBardcode.set(brandMysy.giftBarcode,freeNum - 1);
  297. //
  298. // }
  299. }
  300. }
  301. // 判断当前商品是否为赠品
  302. // isSend(vm.mysy,goodsDetails,"买一送一");
  303. // 判断购物车里面是否有商品为赠品
  304. // shopCartContain(vm.mysy,goodsDetails,"买一送一");
  305. }
  306. // 判断当前商品是否为赠品
  307. function isSend(activity,goodsDetails,activityName){
  308. if(activity.indexOf(goodsDetails.prodBarcode) >= 0){
  309. // 如果符合条件,把赠送的条码给删除(一次性)
  310. var index = activity.indexOf(goodsDetails.prodBarcode);
  311. activity.splice(index,1);
  312. // 设置赠品的单价
  313. goodsDetails.discountedPrice = goodsDetails.retailPrice - 1;
  314. goodsDetails.actualPaymentAmount = 1;
  315. }
  316. }
  317. // 判断购物车里面是否有商品为赠品
  318. function shopCartContain(activity,goodsDetails,activityName){
  319. if(vm.goodsList && vm.goodsList.length > 0 ){
  320. for(var i = 0 ; i < vm.goodsList.length ; i ++){
  321. // 如果有商品为赠品,则把价格置位0并跳出循环
  322. if(activity.indexOf(vm.goodsList[i].prodBarcode) >= 0 && vm.goodsList[i].actualPaymentAmount != 0){
  323. // 如果符合条件,把赠送的条码给删除(一次性)
  324. var index = vm.mysy.indexOf(goodsDetails.prodBarcode);
  325. activity.splice(index,1);
  326. vm.goodsList[i].discountedPrice = vm.goodsList[i].retailPrice;
  327. vm.goodsList[i].actualPaymentAmount = 0;
  328. vm.goodsList[i].activity = activityName;
  329. vm.discountedPrice = vm.discountedPrice + vm.goodsList[i].retailPrice ;
  330. vm.actualPrice = vm.actualPrice - vm.goodsList[i].retailPrice ;
  331. break;
  332. }
  333. }
  334. }
  335. }
  336. // ======================= 组合价商品 ============================
  337. // 组合价商品
  338. function calculateGoodsByZhjsp(r){
  339. var barCode = r.goodsDetails.prodBarcode;
  340. if(r.map.zhjsp){
  341. // 将有组合的商品设置为1 ps:{"flag" => 0, "4005808550739" => 1, "4305615120454" => 0}
  342. vm.zhjsp.forEach(function(value,key,map){
  343. // 将组合价中组合的产品出现的次数+1
  344. value.forEach(function(v, k ,m){
  345. if(k === barCode)
  346. m.set(k,v+1);
  347. });
  348. var flag = 1;
  349. // 判断是否有商品成功组合
  350. value.forEach(function(v, k ,m){
  351. if(v === 0)
  352. flag = 0;
  353. });
  354. if(flag === 1){
  355. var combinationPrice = vm.combinationPrice.get(key);
  356. var barCodeArr = key.toString().split(":");
  357. // 扫码的商品条码 barCode
  358. for(var i = 0 ; i < barCodeArr.length ; i ++){
  359. var oldCode = barCodeArr[i];
  360. if(oldCode === barCode){
  361. continue;
  362. }
  363. if(vm.compareCombinationPrice.get(oldCode) && vm.compareCombinationPrice.get(oldCode) > combinationPrice){
  364. // 获取原组合关系
  365. var relationshipKey = vm.combinationRelationship.get(oldCode);
  366. // 将价格设置回原来的价格
  367. var keyArr = relationshipKey.toString().split(":");
  368. // 遍历原来的组合
  369. for(var j = 0 ; j < keyArr.length ; j ++){
  370. // 遍历购物车中原来的商品,替换价格
  371. for(var k = 0 ; k < vm.goodsList.length ; k ++){
  372. if(vm.goodsList[k].prodBarcode === keyArr[j] && vm.goodsList[k].activity == "组合价"){
  373. vm.discountedPrice = vm.discountedPrice - vm.goodsList[k].discountedPrice ;
  374. vm.actualPrice = vm.actualPrice + vm.goodsList[k].discountedPrice ;
  375. vm.goodsList[k].discountedPrice = 0 ; // 优惠价格
  376. vm.goodsList[k].actualPaymentAmount = vm.goodsList[k].retailPrice; // 实际支付价格
  377. vm.goodsList[k].isCombination = 0;
  378. vm.goodsList[k].activity = "";
  379. vm.compareCombinationPrice.delete(vm.goodsList[k].prodBarcode);
  380. vm.combinationRelationship.delete(vm.goodsList[k].prodBarcode);
  381. }
  382. }
  383. }
  384. }
  385. }
  386. for( var i = 0 ; i < barCodeArr.length ; i ++ ){
  387. // 如果是扫描的产品,直接退出,因为购物车中无该产品
  388. if(barCodeArr[i] == barCode){
  389. r.goodsDetails.isCombination = 1;
  390. r.goodsDetails.discountedPrice = r.goodsDetails.retailPrice - combinationPrice; // 优惠价格
  391. r.goodsDetails.actualPaymentAmount = combinationPrice; // 实际支付价格
  392. r.goodsDetails.activity = "组合价";
  393. vm.compareCombinationPrice.set(barCode,r.goodsDetails.actualPaymentAmount);
  394. vm.combinationRelationship.set(barCode,key);
  395. continue;
  396. }
  397. for(var j = 0 ; j < vm.goodsList.length ; j ++){
  398. if(vm.goodsList[j].prodBarcode === barCodeArr[i] && !vm.goodsList[j].isCombination){
  399. vm.goodsList[j].discountedPrice = vm.goodsList[j].retailPrice ; // 优惠价格
  400. vm.goodsList[j].actualPaymentAmount = 0; // 实际支付价格
  401. vm.goodsList[j].isCombination = 1;
  402. vm.goodsList[j].activity = "组合价";
  403. vm.discountedPrice = vm.discountedPrice + vm.goodsList[j].retailPrice ; // 总的优惠金额
  404. vm.actualPrice = vm.actualPrice - vm.goodsList[j].retailPrice ; // 总的实际支付金额
  405. vm.compareCombinationPrice.set(vm.goodsList[j].prodBarcode,vm.goodsList[j].actualPaymentAmount);
  406. vm.combinationRelationship.set(vm.goodsList[j].prodBarcode,barCode,key);
  407. break;
  408. }
  409. }
  410. }
  411. // 扣减
  412. var updateMap = map.get(key);
  413. updateMap.forEach(function(v, k ,m){
  414. m.set(k,v-1);
  415. });
  416. }
  417. });
  418. }
  419. console.log(vm.compareCombinationPrice);
  420. }
  421. const delay = (function () {
  422. let timer = 0;
  423. return function (callback, ms) {
  424. clearTimeout(timer);
  425. timer = setTimeout(callback.ms)
  426. }
  427. });
  428. let vm = new Vue({
  429. el: '#rrapp',
  430. data: {
  431. showList: true,
  432. goodsDetail:false,
  433. title: null,
  434. goods:{},
  435. orderSn:"",
  436. orderSn1:"",
  437. sysNotice: {},
  438. goodsList:[],
  439. orderInfo:[],
  440. userInfo:{},
  441. //user信息绑定集合
  442. userInfoBinding: {},
  443. sysUserInfo:{},
  444. storeName:null,
  445. prodBarcode:null,
  446. sessionId:null,
  447. pickUpCodeList:[],
  448. goodsDetailList:[],
  449. goodsSkuDetailList:[],
  450. orderEntity:{},
  451. orderProcessRecord:{},
  452. tax:0,
  453. currentOrderNo:null,
  454. pickUpCode:null,
  455. customname:'',
  456. customidcard:'',
  457. status:'',
  458. machineCode:'',
  459. storeId:null,
  460. index:0,
  461. max:0,
  462. totalPrice:0,
  463. discountedPrice:0,
  464. actualPrice:0,
  465. ruleValidate: {
  466. name: [
  467. {required: true, message: '名称不能为空', trigger: 'blur'}
  468. ]
  469. },
  470. q: {
  471. name: ''
  472. },
  473. firstPrint:false,
  474. // 第二件半价
  475. halfPrice:new Map(),
  476. // 买一送一
  477. mysy: [],
  478. freeBardcode : new Map(),
  479. modifyShopcart:false, // 是否需要修改购物车中商品信息
  480. brandGetOneFree : new Map(),
  481. barcodeGetOneFree: new Map(),
  482. boughtNum: new Map(),
  483. // 组合价
  484. zhjsp: new Map(),
  485. combinationPrice: new Map(), // 组合价商品的组合价
  486. compareCombinationPrice: new Map(), // 用于比较组合价
  487. combinationRelationship: new Map(), // 组合价格的组合关系
  488. // 满减
  489. mj: new Map(),
  490. accumulatedAmount: new Map(), // 累积金额(满减使用的)
  491. reduceMoney:0, // 满减金额
  492. showReduceMoney:0, // 用于展示的满减金额
  493. // 满赠
  494. useMz:false,
  495. mz: new Map(),
  496. accumulatedAmountForFullGift: new Map(), // 累积金额(满赠使用的)
  497. fullGiftCode:[],// 满赠商品条码
  498. // 优惠券
  499. coupons: new Map(),
  500. // 挂起订单集合
  501. pendingOrderMap: new Map(),
  502. // 挂起订单的key 在1~3循环
  503. pendingIndex:1,
  504. pendingOrderKeys:[],
  505. // 存储商品信息
  506. goodsMap:new Map(),
  507. response: "",
  508. // 支付码
  509. parCode : "",
  510. // 总件数
  511. totalCount:0,
  512. searchGoodsList: [],
  513. timer: null,
  514. searchGoods: [],
  515. // 卡回执标志
  516. delayResponse:false,
  517. canRefund:true,
  518. openSku:false,
  519. // 保存商品详情的list
  520. calGoodsList : [],
  521. // 会员码
  522. memberCode: '',
  523. // 会员手机
  524. memberPhone: '',
  525. // 订单抵扣积分
  526. deductionScore: '',
  527. // 积分抵扣金额
  528. scoreDeductionPrice: '',
  529. // 积分抵扣金额
  530. scoreLimit: 0,
  531. // 抵扣前积分
  532. beforeScore: 0,
  533. // 抵扣后积分
  534. afterScore: 0,
  535. // 会员openid
  536. openId: ''
  537. },
  538. watch: {
  539. prodBarcode (){
  540. if(vm.timer){
  541. clearTimeout(vm.timer);
  542. }
  543. if(!vm.prodBarcode){
  544. this.searchGoodsList = [];
  545. return ;
  546. }
  547. vm.timer = null;
  548. vm.timer = setTimeout(() => {
  549. vm.queryGoods();
  550. }, 1000*15);
  551. let result = [];
  552. for(let i=0; i<vm.searchGoods.length; i++){
  553. let goods = vm.searchGoods[i];
  554. if(goods != null && goods.name.indexOf(vm.prodBarcode) > -1){
  555. if(result.length <= 9){
  556. result.push(vm.searchGoods[i]);
  557. }else{
  558. break;
  559. }
  560. }
  561. }
  562. vm.searchGoodsList = result;
  563. }
  564. },
  565. methods: {
  566. // 支付完成,请求后端进行下单
  567. myDebounce:debounce(function(){
  568. toPayOrder();
  569. },2000),
  570. // 退款开始
  571. debounceRefund:debounce(function(){
  572. toRefund();
  573. },2000),
  574. queryGoods: function(){
  575. vm.storeId = sessionStorage.getItem("storeId");
  576. $.get("../goods/queryGoodsName?storeId="+vm.storeId+"&goodsName=", function (r) {
  577. if (r.code == 0) {
  578. vm.searchGoods = r.goodsList;
  579. } else {
  580. alert(r.msg);
  581. }
  582. });
  583. },
  584. searchQuery: function (prodBarcode){
  585. vm.prodBarcode = prodBarcode;
  586. vm.query();
  587. },
  588. queryOrderStatus:function(){
  589. $.get("../order/queryOrderStatus/"+vm.orderSn, function (r) {
  590. alert(r.msg);
  591. });
  592. },
  593. queryInveResponse:function(){
  594. $.get("../order/queryInveResponse/"+vm.orderSn1, function(r){
  595. console.log(r.resultMessage);
  596. let resultString = "";
  597. if(r.resultMessage != null && r.resultMessage.length > 0){
  598. for(let i = 0 ; i < r.resultMessage.length; i ++){
  599. resultString += i+':'+r.resultMessage[i] + '\r\n';
  600. }
  601. }
  602. alert(resultString);
  603. }) ;
  604. },
  605. query: function () {
  606. vm.storeId = sessionStorage.getItem("storeId");
  607. var thisGoods = {};
  608. var overflowLi = this.$refs.overflowLi;
  609. $.get("../goods/selectSkuDetails/"+vm.prodBarcode+"/"+vm.storeId, function (r) {
  610. if (r.code == 0) {
  611. if(r.goodsDetails.length>1) {
  612. r.goodsDetails.sellVolume = 1;
  613. vm.openSku = true;
  614. vm.goodsSkuDetailList = JSON.parse(JSON.stringify(r.goodsDetails));
  615. //此时必须异步执行滚动条滑动至底部
  616. setTimeout(()=>{
  617. overflowLi.scrollTop = overflowLi.scrollHeight;
  618. },0)
  619. }else{
  620. vm.saveOld();
  621. }
  622. } else {
  623. alert(r.msg);
  624. }
  625. });
  626. },
  627. //同条码多sku情况
  628. saveNew:function(value){
  629. vm.storeId = sessionStorage.getItem("storeId");
  630. var overflowLi = this.$refs.overflowLi;
  631. // confirm('确定吗?', function () {
  632. $.get("../goods/details/"+vm.prodBarcode+"/"+vm.storeId+"/"+value, function (r) {
  633. if (r.code == 0) {
  634. r.goodsDetails.sellVolume = 1;
  635. vm.goodsMap.set(r.goodsDetails.goodsSn,JSON.parse(JSON.stringify(r.goodsDetails)));
  636. vm.prodBarcode = '';
  637. calculateGoodsPrice(r);
  638. handle(r.goodsDetails,"add");
  639. vm.openSku = false;
  640. var data = Object.assign({}, JSON.parse(JSON.stringify(r.goodsDetails)));
  641. console.log("商品详情===>" + JSON.stringify(data));
  642. vm.calGoodsList.push(data);
  643. //此时必须异步执行滚动条滑动至底部
  644. setTimeout(()=>{
  645. overflowLi.scrollTop = overflowLi.scrollHeight;
  646. },0)
  647. } else {
  648. alert(r.msg);
  649. }
  650. });
  651. // })
  652. },
  653. //非同条码
  654. saveOld:function(){
  655. vm.storeId = sessionStorage.getItem("storeId");
  656. var overflowLi = this.$refs.overflowLi;
  657. $.get("../goods/detailsOld/"+vm.prodBarcode+"/"+vm.storeId, function (r) {
  658. if (r.code == 0) {
  659. r.goodsDetails.sellVolume = 1;
  660. vm.goodsMap.set(r.goodsDetails.goodsSn,JSON.parse(JSON.stringify(r.goodsDetails)));
  661. vm.prodBarcode = '';
  662. calculateGoodsPrice(r);
  663. handle(r.goodsDetails,"add");
  664. vm.openSku = false;
  665. var data = Object.assign({}, JSON.parse(JSON.stringify(r.goodsDetails)));
  666. console.log("商品详情=1=>" + JSON.stringify(data));
  667. vm.calGoodsList.push(data);
  668. //此时必须异步执行滚动条滑动至底部
  669. setTimeout(()=>{
  670. overflowLi.scrollTop = overflowLi.scrollHeight;
  671. },0)
  672. } else {
  673. alert(r.msg);
  674. }
  675. });
  676. },
  677. cancelNew: function(){
  678. vm.openSku=false;
  679. },
  680. add:function(value){
  681. // 增加数量
  682. for(var i = 0 ; i < this.goodsList.length ; i++){
  683. if(this.goodsList[i].id == value){
  684. // var goodsDetails = JSON.parse(JSON.stringify(vm.goodsMap.get(this.goodsList[i].goodsSn)));
  685. let goodsDetails = JSON.parse(JSON.stringify(vm.goodsList[i]));
  686. // console.log("加法 goods detail =====>" + JSON.stringify(goodsDetails));
  687. /*calculateGoodsByMj(goodsDetails,"add");
  688. calculateGoodsByMysy(goodsDetails,"add");
  689. calculateGoodsByHalfPrice(goodsDetails,"add");*/
  690. // calculateGoodsByMz(goodsDetails,"add");
  691. handleSellVolume(goodsDetails, "add");
  692. // handle(goodsDetails,"add");
  693. break;
  694. }
  695. }
  696. },
  697. minus:function(value){
  698. // 减少数量
  699. for(var i = 0 ; i < this.goodsList.length ; i++){
  700. if(this.goodsList[i].id == value){
  701. // 获取当前购物车的数量
  702. let goodsDetails = JSON.parse(JSON.stringify(vm.goodsList[i]));
  703. // console.log("减法 goods detail =====>" + JSON.stringify(goodsDetails));
  704. if(goodsDetails.sellVolume === 1){
  705. alert("数量至少为1个");
  706. return ;
  707. }
  708. // 如果不为空,证明减的是买A送B中的B,这时候要还原赠送资格跟B的扣减
  709. /*var freeMap = vm.freeBardcode.get(goodsDetails.prodBarcode);
  710. if((freeMap || freeMap == 0) && g.actualPaymentAmount == 0){
  711. vm.freeBardcode.set(goodsDetails.prodBarcode,freeMap + 1);
  712. goodsDetails.sellVolume = -1;
  713. goodsDetails.actualPaymentAmount = 0;
  714. goodsDetails.discountedPrice = -goodsDetails.retailPrice;
  715. goodsDetails.goodstaxes = - goodsDetails.goodstaxes;
  716. goodsDetails.retailPrice = - goodsDetails.retailPrice;
  717. }else{
  718. goodsDetails.sellVolume = g.sellVolume;
  719. calculateGoodsByMj(goodsDetails,"minus");
  720. calculateGoodsByMysy(goodsDetails,"minus");
  721. calculateGoodsByHalfPrice(goodsDetails,"minus");
  722. // calculateGoodsByMz(goodsDetails,"minus");
  723. goodsDetails.sellVolume = -1;
  724. goodsDetails.actualPaymentAmount = -goodsDetails.actualPaymentAmount;
  725. goodsDetails.discountedPrice = -goodsDetails.discountedPrice;
  726. goodsDetails.goodstaxes = - goodsDetails.goodstaxes;
  727. goodsDetails.retailPrice = - goodsDetails.retailPrice;
  728. }*/
  729. handleSellVolume(goodsDetails, "minus");
  730. // handle(goodsDetails,"minus");
  731. break;
  732. }
  733. }
  734. },
  735. selectItem:function(value) {
  736. console.log(value);
  737. },
  738. deleteItem:function(value){
  739. // 删除这条记录
  740. for(var i = 0 ; i < this.goodsList.length ; i++){
  741. if(this.goodsList[i].id == value){
  742. if(this.goodsList.length == 1){
  743. vm.goods = {};
  744. vm.goodsDetail = false;
  745. }
  746. if(vm.mz.get(this.goodsList[i].prodBarcode)){
  747. vm.mz.get(this.goodsList[i].prodBarcode).useMz = false ;
  748. }
  749. if(vm.brandGetOneFree.get(this.goodsList[i].brand)){
  750. var giftBarcode = vm.brandGetOneFree.get(this.goodsList[i].brand).giftBarcode;
  751. var muilty = vm.brandGetOneFree.get(this.goodsList[i].brand).buyNum;
  752. var sellNum = this.goodsList[i].sellVolume;
  753. vm.freeBardcode.set(giftBarcode,sellNum/muilty);
  754. for(var j = 0 ; j < vm.goodsList.length ; j++){
  755. var shopcartGoods = vm.goodsList[j];
  756. var shopcartFree = vm.freeBardcode.get(shopcartGoods.prodBarcode);
  757. if(shopcartFree /*&& shopcartGoods.actualPaymentAmount*/){
  758. shopcartGoods.actualPaymentAmount = shopcartGoods.actualPaymentAmount + (shopcartGoods.retailPrice * shopcartGoods.sellVolume);
  759. shopcartGoods.discountedPrice = shopcartGoods.discountedPrice - (shopcartGoods.retailPrice * shopcartGoods.sellVolume);
  760. vm.discountedPrice = vm.discountedPrice - (shopcartGoods.retailPrice * shopcartGoods.sellVolume);
  761. vm.actualPrice = vm.actualPrice + (shopcartGoods.retailPrice * shopcartGoods.sellVolume);
  762. vm.freeBardcode.set(shopcartGoods.prodBarcode, 0);// 重置回0
  763. }
  764. }
  765. }
  766. if(vm.halfPrice.get(this.goodsList[i].prodBarcode)){
  767. vm.halfPrice.set(this.goodsList[i].prodBarcode,1);
  768. }
  769. var goods = this.goodsList[i];
  770. // console.log(goods);
  771. // console.log(vm.totalPrice);
  772. $.get("../goods/number/del/" + sessionStorage.getItem("storeId") + "/" + goods.sku + "/" + goods.prodBarcode, function (res) {
  773. if (res.code === 0) {
  774. alert("删除成功!");
  775. } else if (res.code === 500) {
  776. alert(res.msg);
  777. } else {
  778. alert("未知异常!请联系管理员!");
  779. }
  780. });
  781. if(vm.freeBardcode.get(goods.prodBarcode) || vm.freeBardcode.get(goods.prodBarcode) == 0){
  782. var nnum = (((goods.retailPrice * goods.sellVolume) - goods.actualPaymentAmount)/goods.retailPrice);
  783. vm.freeBardcode.set(goods.prodBarcode, nnum);
  784. }
  785. vm.totalPrice = vm.totalPrice - (goods.retailPrice * goods.sellVolume);
  786. vm.totalCount = vm.totalCount - (goods.sellVolume);
  787. vm.discountedPrice = vm.discountedPrice - goods.discountedPrice;
  788. vm.actualPrice = vm.actualPrice - goods.actualPaymentAmount;
  789. vm.boughtNum.delete(goods.prodBarcode);
  790. vm.totalPrice = Math.round(vm.totalPrice * 100) / 100;
  791. vm.discountedPrice = Math.round(vm.discountedPrice * 100) / 100;
  792. vm.actualPrice = Math.round(vm.actualPrice * 100) / 100;
  793. vm.showReduceMoney = Math.round(vm.showReduceMoney * 100) / 100;
  794. this.goodsList.splice(i,1);
  795. break;
  796. }
  797. }
  798. this.index = value;
  799. },
  800. clearGoodsList:function(){
  801. confirm('确认清空吗?', function () {
  802. $.get("../goods/number/clear/" + sessionStorage.getItem("storeId"), function (res) {
  803. if (res.code === 0) {
  804. layer.confirm("清空成功", {
  805. skin: 'layui-layer-molv', btn: ['确定'], title: "提示"
  806. }, function () {
  807. location.reload();
  808. });
  809. } else if (res.code === 500) {
  810. alert(res.msg);
  811. } else {
  812. alert("未知异常!请联系管理员!");
  813. }
  814. })
  815. })
  816. },
  817. pendingOrder:function(){
  818. if(this.goodsList.length == 0){
  819. alert("购物车中没有商品");
  820. return;
  821. }
  822. console.log(vm.pendingOrderMap.size);
  823. if(vm.pendingOrderMap.size >= 3){
  824. alert("订单挂起最多支持3单");
  825. return;
  826. }
  827. var pendingObject = {
  828. 'goodsList':this.goodsList,
  829. 'totalPrice':vm.totalPrice,
  830. 'totalCount':vm.totalCount,
  831. 'discountedPrice':vm.discountedPrice,
  832. 'actualPrice':vm.actualPrice
  833. }
  834. vm.pendingOrderMap.set(vm.pendingIndex,pendingObject);
  835. vm.pendingOrderKeys.push(vm.pendingIndex);
  836. var newIndex = ++vm.pendingIndex;
  837. vm.pendingIndex = newIndex > 3?1: newIndex;
  838. vm.goodsList = [];
  839. vm.customClearData();
  840. },
  841. toResumePending:function(){
  842. if(vm.pendingOrderMap.size == 0){
  843. alert("当前没有挂起的订单");
  844. return ;
  845. }
  846. $('#pendignOrderModal').modal('show')
  847. },
  848. resumePending:function(key){
  849. if(vm.pendingOrderMap.size == 0){
  850. alert("当前没有挂起的订单");
  851. return ;
  852. }
  853. if(vm.goodsList.length > 0){
  854. alert("购物车中已有商品,不允许恢复!")
  855. return ;
  856. }
  857. var pendingObject = vm.pendingOrderMap.get(key);
  858. console.log(pendingObject);
  859. vm.goodsList = pendingObject.goodsList;
  860. vm.totalPrice = pendingObject.totalPrice;
  861. vm.totalCount = pendingObject.totalCount;
  862. vm.discountedPrice = pendingObject.discountedPrice;
  863. vm.actualPrice = pendingObject.actualPrice;
  864. // 清除恢复的数据
  865. vm.pendingOrderMap.delete(key);
  866. removeByValue(vm.pendingOrderKeys,key);
  867. $('#pendignOrderModal').modal('hide')
  868. },
  869. toOrderSubmit:function(){
  870. if(this.goodsList.length == 0){
  871. alert("请选择商品");
  872. return;
  873. }
  874. $('#myModal').modal('show')
  875. // 每次点击提交订单的时候清空姓名和身份证信息和手机号
  876. vm.$refs.customName.value = "";
  877. vm.$refs.customIDCard.value = "";
  878. vm.$refs.customPhone.value = "";
  879. vm.$refs.couponBarCode.value = "";
  880. if(vm.$refs.couponSn)
  881. vm.$refs.couponSn.value = "";
  882. this.userInfo.couponSn = "";
  883. },
  884. // 点击计算优惠价按钮,弹出输入框
  885. calculateOrderPrice : function () {
  886. if (this.calGoodsList.length == 0) {
  887. alert("请选择商品");
  888. return;
  889. }
  890. $("#calculateOrderPriceDialog").modal('show');
  891. },
  892. // 计算优惠价格,返回订单详情数据
  893. calculateOrderPriceSubmit : function () {
  894. // console.log("点击计算=====>" + JSON.stringify(vm.goodsList));
  895. var couponBarCode = vm.$refs.couponBarCode;
  896. if (couponBarCode === null || couponBarCode === '') {
  897. alert("无会员码,不能参加积分抵扣活动!\n计算中...");
  898. }
  899. calculateOrderPrice();
  900. },
  901. // 提交订单
  902. submitOrder:function(){
  903. vm.parCode = this.$refs.payCode.currentValue
  904. vm.myDebounce();
  905. },customClearData: function(){
  906. vm.totalPrice = 0;
  907. vm.totalCount = 0;
  908. vm.discountedPrice = 0;
  909. vm.actualPrice = 0;
  910. vm.goods={};
  911. vm.goodsDetail = false;
  912. // 第二件半价
  913. vm.halfPrice = new Map();
  914. // 买一送一
  915. vm.mysy = [];
  916. vm.freeBardcode = new Map();
  917. vm.brandGetOneFree = new Map();
  918. vm.barcodeGetOneFree = new Map();
  919. vm.brandGetOneFree = new Map();
  920. vm.boughtNum = new Map();
  921. // 组合价
  922. vm.zhjsp = new Map();
  923. vm.combinationPrice = new Map(); // 组合价商品的组合价
  924. // 满减
  925. vm.mj = new Map();
  926. vm.accumulatedAmount = new Map();// 累积金额(满减使用的)
  927. vm.reduceMoney = 0; // 满减金额
  928. vm.showReduceMoney = 0; // 用于展示的满减金额
  929. // 满赠
  930. vm.mz = new Map();
  931. vm.accumulatedAmountForFullGift = new Map(); // 累积金额(满赠使用的)
  932. vm.fullGiftCode = [];// 满赠商品条码
  933. // 优惠券
  934. vm.coupons = new Map();
  935. },
  936. queryIDCardInfo: function(){
  937. $.get("../order/queryIDCardInfo/"+vm.$refs.customPhone.value, function (r){
  938. if(r.code === 0){
  939. var data = r.userEntity;
  940. vm.$refs.customName.value = data.username;
  941. vm.$refs.customIDCard.value = data.idNo;
  942. }else{
  943. alert(r.msg);
  944. }
  945. });
  946. },
  947. sendDiva: function(){
  948. // document.getElementsByClassName('sendShow').style.display='none';
  949. $('.sendShow').hide();
  950. },
  951. sendDivb: function(){
  952. // document.getElementsByClassName('sendShow').style.display='block';
  953. $('.sendShow').show();
  954. },
  955. getIDCardInfo: function(){
  956. $.post("http://127.0.0.1:8000/idcard/read", function (r){
  957. if(r.code == "0"){
  958. vm.$refs.customName.value = r.rows[0].data.name;
  959. vm.$refs.customIDCard.value = r.rows[0].data.id_no;
  960. }else if(r.code=="-1"){
  961. alert(r.msg);
  962. return;
  963. }else{
  964. alert("请连接设备或设备有问题,请联系管理员!");
  965. }
  966. });
  967. },
  968. customPhoneBlur:function (){
  969. let customPhone = this.$refs.customPhone.value;
  970. if(customPhone){
  971. for(let key in this.userInfoBinding){
  972. if(customPhone == key){
  973. let userInfoBindingValue = this.userInfoBinding[key];
  974. this.$refs.customName.value = userInfoBindingValue.substring(0, userInfoBindingValue.length-18);
  975. this.$refs.customIDCard.value = userInfoBindingValue.substring(userInfoBindingValue.length-18);
  976. break;
  977. }
  978. }
  979. }
  980. },
  981. // 填写并验证顾客信息
  982. submitCustomInfo:function(){
  983. this.userInfo.customName = this.$refs.customName.value ;
  984. this.userInfo.customIDCard = this.$refs.customIDCard.value ;
  985. this.userInfo.customPhone = this.$refs.customPhone.value;
  986. this.userInfo.couponBarCode = this.$refs.couponBarCode.value;
  987. var status = $('input:radio:checked').val();
  988. var cmbCity = $('#cmbCity').val();
  989. var cmbProvince = $('#cmbProvince').val();
  990. var cmbArea = $('#cmbArea').val();
  991. var addrUser = $('#addrUser').val();
  992. // console.log('城市三级联动的值:'+cmbProvince+'|'+cmbCity+'|'+cmbArea+'|'+addrUser);
  993. if (status == 0) {
  994. if (cmbCity =="请选择"){
  995. alert("请选择省!");
  996. return ;
  997. }
  998. if (cmbProvince =="请选择"){
  999. alert("请选择市!");
  1000. return ;
  1001. }
  1002. if (cmbArea =="请选择"){
  1003. alert("请选择区!");
  1004. return ;
  1005. }
  1006. if (addrUser == "") {
  1007. alert("请填写详细地址!");
  1008. return ;
  1009. }
  1010. }
  1011. if(this.$refs.couponSn)
  1012. this.userInfo.couponSn = this.$refs.couponSn.value;
  1013. var idcardReg = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
  1014. if(!this.userInfo.customName){
  1015. alert("姓名不能为空!");
  1016. return ;
  1017. }
  1018. if(!idcardReg.test(this.userInfo.customIDCard)){
  1019. alert("请输入正确的身份证号");
  1020. return ;
  1021. }
  1022. if(!(/^1[3456789]\d{9}$/.test(this.userInfo.customPhone))){
  1023. alert("手机号码有误,请重填");
  1024. return ;
  1025. }
  1026. //将手机号与姓名身份证号进行绑定,下次填写手机号即可
  1027. let userInfoBindingKey = this.userInfo.customPhone;
  1028. let userInfoBindingValue = this.userInfo.customName+this.userInfo.customIDCard;
  1029. this.userInfoBinding[userInfoBindingKey] = userInfoBindingValue;
  1030. if(this.userInfo.couponSn && this.userInfo.couponSn != ""){
  1031. var coupon = vm.coupons.get(this.userInfo.couponSn);
  1032. if(coupon == null){
  1033. alert("请输入正确的优惠券码");
  1034. return ;
  1035. }
  1036. }
  1037. $("#Send").attr("data-dismiss","modal");
  1038. $('#payModal').modal('show');
  1039. $("#payCode").keydown(function(e){
  1040. if(e.keyCode==13){
  1041. $("#submitOrder").click();
  1042. event.preventDefault();
  1043. }
  1044. });
  1045. $('body').on('hidden.bs.modal', '.modal', function () {
  1046. $(this).removeData();
  1047. });
  1048. },
  1049. queryOrderDetail:function(orderSn,pickUpCode){
  1050. var storeId = sessionStorage.getItem("storeId");
  1051. $.get("../order/orderDetail/"+orderSn, function (r) {
  1052. if (r.code == 0) {
  1053. vm.orderProcessRecord = r.resultObj.orderProcessRecordEntity;
  1054. vm.orderEntity = r.resultObj.orderEntity;
  1055. vm.goodsDetailList = r.resultObj.goodsList;
  1056. vm.currentOrderNo = r.resultObj.orderEntity.id;
  1057. vm.pickUpCode = pickUpCode;
  1058. vm.tax = r.resultObj.tax;
  1059. vm.response = r.resultObj.response;
  1060. if(vm.orderProcessRecord.eleOrderStartTime){
  1061. vm.orderProcessRecord.eleOrderStartTime = parsedate(vm.orderProcessRecord.eleOrderStartTime);
  1062. }
  1063. if(vm.orderProcessRecord.paymentStartTime){
  1064. vm.orderProcessRecord.paymentStartTime = parsedate(vm.orderProcessRecord.paymentStartTime);
  1065. }
  1066. if(vm.orderProcessRecord.waybillStartTime){
  1067. vm.orderProcessRecord.waybillStartTime = parsedate(vm.orderProcessRecord.waybillStartTime);
  1068. }
  1069. if(vm.orderProcessRecord.customsSuccTime){
  1070. vm.orderProcessRecord.customsSuccTime = parsedate(vm.orderProcessRecord.customsSuccTime);
  1071. }
  1072. if(vm.orderProcessRecord.addOrderStartTime){
  1073. vm.orderProcessRecord.addOrderStartTime = parsedate(vm.orderProcessRecord.addOrderStartTime);
  1074. }
  1075. }
  1076. });
  1077. },
  1078. resendNotice:function(){
  1079. confirm('确认重发重置吗?', function () {
  1080. $.get("../order/resendOrderToCCNET/"+vm.orderEntity.orderSn+"/notice", function (r) {
  1081. alert(r.msg);
  1082. });
  1083. })
  1084. },
  1085. resendWaybill:function(){
  1086. confirm('确认重发运单吗?', function () {
  1087. $.get("../order/resendOrderToCCNET/"+vm.orderEntity.orderSn+"/waybill", function (r) {
  1088. alert(r.msg);
  1089. });
  1090. })
  1091. },
  1092. resendPayment:function(){
  1093. confirm('确认重发支付单吗?', function () {
  1094. $.get("../order/resendOrderToCCNET/"+vm.orderEntity.orderSn+"/payment", function (r) {
  1095. alert(r.msg);
  1096. });
  1097. })
  1098. },
  1099. forceSendToOms:function(){
  1100. confirm('确认强制推送清关吗?', function () {
  1101. $.get("../order/resendOrderToCCNET/"+vm.orderEntity.orderSn+"/forceSend", function (r) {
  1102. alert(r.msg);
  1103. });
  1104. })
  1105. },
  1106. resendorder:function(){
  1107. confirm('确认重发订单吗?', function () {
  1108. $.get("../order/resendOrderHkMall/"+vm.orderEntity.orderSn, function (r) {
  1109. if(r.code == "0"){
  1110. alert(r.msg);
  1111. } else {
  1112. alert(r.msg);
  1113. }
  1114. });
  1115. })
  1116. },
  1117. verification:function(){
  1118. if(vm.orderProcessRecord.isCustomsSend != 1){
  1119. alert("请等待清关完成");
  1120. return ;
  1121. }
  1122. confirm('确认核销吗?', function () {
  1123. $.ajax({
  1124. type: "POST",
  1125. url: "../order/printMsgAndChangeCode",
  1126. contentType: "application/json",
  1127. data: JSON.stringify({'id':vm.currentOrderNo,'sessionId':vm.sessionId}),
  1128. success: function (r) {
  1129. if (r.ticket != null) {
  1130. // printArea(r.ticket);
  1131. console.log("核销打印前,订单号: " + vm.currentOrderNo);
  1132. var content = getPrintContentOrder(r.ticket, printArea);
  1133. console.log("核销打印后,小票码: " + vm.pickUpCode + ",订单号: " + r.ticket.ticketHead.orderId);
  1134. }else{
  1135. alert("打印小票失败");
  1136. }
  1137. }
  1138. });
  1139. })
  1140. },
  1141. verEwbtion:function(){
  1142. confirm('确认打印快递单吗?', function () {
  1143. $.ajax({
  1144. type: "POST",
  1145. url: "../order/printMsgChangeEwb",
  1146. contentType: "application/json",
  1147. data: JSON.stringify({'id':vm.currentOrderNo,'sessionId':vm.sessionId}),
  1148. success: function (r) {
  1149. if (r.ticket != null) {
  1150. var content = getPrintContentOrder(r.ticket, printArea);
  1151. }else{
  1152. alert("打印快递单失败");
  1153. }
  1154. }
  1155. });
  1156. })
  1157. },
  1158. // 退款方法
  1159. refundOrder:function(){
  1160. vm.debounceRefund();
  1161. },
  1162. //确认提货
  1163. confirmDelivery: function(){
  1164. confirm('确认提货吗?', function () {
  1165. $.get("../pickupcode/confirmDelivery/"+vm.orderEntity.orderSn, function (r) {
  1166. alert(r.msg);
  1167. });
  1168. })
  1169. },
  1170. retrySendOrder:function(){
  1171. },
  1172. getInfo: function (id) {
  1173. $.get("../sys/notice/info/" + id, function (r) {
  1174. vm.sysNotice = r.sysNotice;
  1175. });
  1176. },
  1177. reload: function (event) {
  1178. vm.showList = false;
  1179. vm.showViewList = true;
  1180. vm.showSaveSupplierGoods = true;
  1181. var page = $("#jqGrid").jqGrid('getGridParam', 'page');
  1182. $("#jqGrid").jqGrid('setGridParam', {
  1183. postData: {
  1184. storeId: vm.q.storeId,
  1185. goodsName: vm.q.goodsName,
  1186. goodsSn: vm.q.goodsSn,
  1187. productSn: vm.q.productSn, category: vm.q.category, categoryTwo: vm.q.categoryTwo, goodsBizType:vm.q.goodsBizType,
  1188. thirdPartyMerchCode: vm.q.thirdPartyMerchCode
  1189. },
  1190. page: page
  1191. }).trigger("reloadGrid");
  1192. vm.handleReset('formValidate');
  1193. },
  1194. handleSubmit: function (name) {
  1195. handleSubmitValidate(this, name, function () {
  1196. vm.saveOrUpdate()
  1197. });
  1198. },
  1199. handleReset: function (name) {
  1200. handleResetForm(this, name);
  1201. },
  1202. logout: function () {
  1203. confirm('注:您确定要安全退出本次登录吗?', function () {
  1204. dialogLoading(true);
  1205. setTimeout(function () {
  1206. toUrl('../logout?_' + $.now());
  1207. }, 500);
  1208. });
  1209. }
  1210. }
  1211. });
  1212. function getPrintContent(ticket) {
  1213. var content = "<div style=\"width: 300px;font-family: 微软雅黑;font-size: 15px;\">";
  1214. // // 打印ogo
  1215. // content += "<div style=\"text-align: center;width: 100%;height: 50px;\">";
  1216. // // content += "<img src='./../../statics/img/cw_logo.png' />";
  1217. // // content += "2222222222";
  1218. // content += "<img src='/statics/img/cw_logo.png' style='width: 100%;height: 100%;' />";
  1219. // content += "</div>";
  1220. //小票头
  1221. content += "<div style=\"text-align: center;width: 100%;font-weight:bold;font-size: 15px;\">";
  1222. content += ticket.shopName
  1223. content += "</div>";
  1224. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  1225. content += "<div style=\"width: 100%;margin:5px 0px;\">";
  1226. /*content += "收银机号:" + ticket.salesNo;
  1227. content += "</div>";
  1228. content += "<div style=\"width: 100%;\">";*/
  1229. content += "收银员:" + ticket.userName;
  1230. content += "</div>";
  1231. content += "<div style=\"text-align: center;width: 100%;font-size: 30px;margin:15px 0 10px 5px;\">";
  1232. content += "小票码" ;
  1233. content += "</div>";
  1234. content += "<div style=\"text-align: center;width: 100%;font-size: 50px;margin:15px 0 10px 5px;\">";
  1235. content += ticket.code;
  1236. content += "</div>";
  1237. content += "<div style=\"width: 100%;margin:5px 0px;\">";
  1238. content += "订单编号:" + ticket.orderNo;
  1239. content += "</div>";
  1240. content += "<div style=\"width: 100%;margin:5px 0px;\">";
  1241. content += "手机号:" + ticket.phone;
  1242. content += "</div>";
  1243. content += "<div style=\"width: 100%;margin:5px 0px;\">";
  1244. content += "打印日期:" + ticket.time;
  1245. content += "</div>";
  1246. content += "<div style=\"width: 100%;margin:5px 0px;font-size: 13px;\">";
  1247. content += "该取货单号只有当天有效!"
  1248. content += "</div>";
  1249. content += "<div style=\"width: 100%;margin:5px 0px;font-size: 13px;\">";
  1250. content += "请妥善保管好小票,以免造成个人信息泄露!"
  1251. content += "</div>";
  1252. content += "</div>";
  1253. return content;
  1254. }
  1255. var printAreaCount = 0;
  1256. var printArea = function printArea(content) {
  1257. var idPrefix = "printArea_";
  1258. removePrintArea(idPrefix + printAreaCount);
  1259. ++printAreaCount;
  1260. var iframeId = idPrefix + printAreaCount;
  1261. var iframeStyle = 'width:0px;height:0px;left:0px;top:0px;';
  1262. iframe = document.createElement('IFRAME');
  1263. $(iframe).attr({
  1264. style: iframeStyle,
  1265. id: iframeId
  1266. });
  1267. document.body.appendChild(iframe);
  1268. var doc = iframe.contentWindow.document;
  1269. // doc.open();
  1270. doc.write('<div class="">' + content
  1271. + '</div>');
  1272. doc.close();
  1273. var frameWindow = iframe.contentWindow;
  1274. $(iframe).load(function(){
  1275. frameWindow.focus();
  1276. frameWindow.print();
  1277. alert('打印小票完成');
  1278. });
  1279. }
  1280. function printArea2(content) {
  1281. var idPrefix = "printArea_";
  1282. removePrintArea(idPrefix + printAreaCount);
  1283. printAreaCount++;
  1284. var iframeId = idPrefix + printAreaCount;
  1285. var iframeStyle = 'width:0px;height:0px;left:0px;top:0px;';
  1286. iframe = document.createElement('IFRAME');
  1287. $(iframe).attr({
  1288. style: iframeStyle,
  1289. id: iframeId
  1290. });
  1291. document.body.appendChild(iframe);
  1292. var doc = iframe.contentWindow.document;
  1293. doc.open();
  1294. doc.write('<div class="">' + content
  1295. + '</div>');
  1296. doc.close();
  1297. var frameWindow = iframe.contentWindow;
  1298. frameWindow.focus();
  1299. frameWindow.print();
  1300. frameWindow.print();
  1301. frameWindow.close();
  1302. }
  1303. var removePrintArea = function (id) {
  1304. $("iframe#" + id).remove();
  1305. };
  1306. var webSocket;
  1307. function openWebSocket() {
  1308. var storeId = sessionStorage.getItem("storeId");
  1309. if ("WebSocket" in window) {
  1310. console.log("当前浏览器支持WebSocket");
  1311. //实现化WebSocket对象
  1312. //指定要连接的服务器地址与端口建立连接
  1313. //注意ws、wss使用不同的端口。我使用自签名的证书测试,
  1314. //无法使用wss,浏览器打开WebSocket时报错
  1315. //ws对应http、wss对应https。
  1316. //kmall测试环境
  1317. //webSocket = new WebSocket("ws://183.62.225.124:8080/ws/server/"+storeId);
  1318. //kmall正式环境
  1319. //webSocket = new WebSocket("ws://8.135.102.238:8080/ws/server/"+storeId);
  1320. //kmall本地环境
  1321. webSocket = new WebSocket("ws://127.0.0.1:8089/ws/server/"+storeId);
  1322. // webSocket = new WebSocket("wss://cb.k1net.cn/ws/server/"+storeId);
  1323. if (webSocket.readyState === webSocket.CONNECTING) {
  1324. console.log('1.连接正在打开......');
  1325. }
  1326. // ---------- WebSocket 对象注册事件 ----------
  1327. //连接打开事件
  1328. webSocket.onopen = function () {
  1329. if (webSocket.readyState === webSocket.OPEN) {
  1330. console.log('2.连接已打开');
  1331. }
  1332. console.log('2.向服务端发送测试消息......');
  1333. // webSocket.send("2.client发测试消息:Client sent test msg。");
  1334. };
  1335. //收到消息事件
  1336. webSocket.onmessage = function (msg) {
  1337. var data = Object.assign({}, JSON.parse(msg.data));
  1338. console.log('3.接收到服务端信息......data:'+data);
  1339. vm.sessionId = data.sessionId;
  1340. vm.pickUpCodeList = [];
  1341. if(data.pickUpCodeList.length > 0){
  1342. for(var i = 0 ; i < data.pickUpCodeList.length ; i++){
  1343. // console.log(data.pickUpCodeList[i].storeId);
  1344. if(data.pickUpCodeList[i].storeId === storeId){
  1345. vm.pickUpCodeList.push(data.pickUpCodeList[i]);
  1346. }
  1347. }
  1348. }
  1349. vm.delayResponse = data.delayResponse;
  1350. };
  1351. //连接关闭事件
  1352. webSocket.onclose = function () {
  1353. if (!webSocket) {
  1354. console.log('4.Socket连接已关闭');
  1355. }
  1356. };
  1357. //发生了错误事件
  1358. webSocket.onerror = function () {
  1359. console.log("5.Socket发生了错误");
  1360. }
  1361. } else {
  1362. console.log("当前浏览器不支持WebSocket");
  1363. return false;
  1364. }
  1365. }
  1366. function sendMessage() {
  1367. if(webSocket && webSocket.readyState === webSocket.OPEN) {
  1368. webSocket.send("client manual send message.")
  1369. } else {
  1370. console.log('6.未创建WebSocket连接');
  1371. }
  1372. }
  1373. function closeWebSocket() {
  1374. if (webSocket != null) {
  1375. webSocket.close();
  1376. webSocket = null;
  1377. }
  1378. console.log("关闭WebSocket");
  1379. }
  1380. //窗口关闭时,关闭连接
  1381. window.unload = function () {
  1382. webSocket.close();
  1383. };
  1384. function parsedate(value){
  1385. var date = new Date(value);
  1386. var year = date.getFullYear();
  1387. var month = date.getMonth()+1; //月份+1
  1388. var day = date.getDate();
  1389. var hour = date.getHours();
  1390. var minutes = date.getMinutes();
  1391. var second = date.getSeconds();
  1392. return year+"-"+month+"-"+day+" "+hour+":"+minutes +":"+second;
  1393. }
  1394. function getPrintContentOrder(ticket, callback) {
  1395. var content = "<div style=\"width: 270px;font-family: 微软雅黑;font-size: 8px;\">";
  1396. // 打印ogo
  1397. content += "<div style=\"text-align: center;width: 100%;height: 260px;\">";
  1398. content += "<img src='/statics/img/cw_logo2.png' style='width: 100%;height: 100%;' />";
  1399. content += "</div>";
  1400. //小票头
  1401. content += "<div style=\"text-align: center;width: 100%;font-weight:bold;font-size: 13px;\">";
  1402. content += ticket.ticketHead.title;
  1403. content += "</div>";
  1404. /*content += "<div style=\"width: 100%;\">";
  1405. content += "会员:" + ticket.ticketHead.memberId;
  1406. content += "</div>";*/
  1407. content += "<div style=\"width: 100%;font-size: 25px;\">";
  1408. content += "小票码:" + vm.pickUpCode;
  1409. content += "</div>";
  1410. content += "<div style=\"width: 100%;\">";
  1411. content += "订单号:" + ticket.ticketHead.orderId;
  1412. content += "</div>";
  1413. content += "<div style=\"width: 100%;\">";
  1414. content += "交易时间:" + ticket.ticketHead.tradeTime;
  1415. content += "</div>";
  1416. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">-------------------------------------------------------</div>";
  1417. //商品信息
  1418. content += "<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  1419. content += "<tr>";
  1420. content += "<td style=\"width: 40%;text-align: left;font-size: 10px;font-weight: bold;\">商品名称</td>";
  1421. content += "<td style=\"width: 17%;text-align: right;font-size: 10px;font-weight: bold;\">单价</td>";
  1422. content += "<td style=\"width: 17%;text-align: right;font-size: 10px;font-weight: bold;\">优惠</td>";
  1423. // content += "<td style=\"width: 16%;text-align: right;font-size: 10px;font-weight: bold;\">税费</td>";
  1424. content += "<td style=\"width: 15%;text-align: right;font-size: 10px;font-weight: bold;\">数量</td>";
  1425. content += "<td style=\"width: 18%;text-align: right;font-size: 10px;font-weight: bold;\">小计</td>";
  1426. content += "</tr>";
  1427. content += "</table>";
  1428. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">-------------------------------------------------------</div>";
  1429. content += "<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  1430. for (var i=0;i< ticket.goods.length;i++){
  1431. content += "<tr>";
  1432. content += "<td style=\"width: 40%;text-align: left;font-size: 8px;padding-top: 8px;\">";
  1433. content += "<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  1434. content += "<tr>";
  1435. content += "<td style=\"text-align: left;font-size: 8px;vertical-align:top;\">#</td>";
  1436. content += "<td style=\"text-align: left;font-size: 8px;\">" + ticket.goods[i].gname + "</td>";
  1437. content += "</tr>";
  1438. content += "</table>";
  1439. content += "</td>";
  1440. content += "<td style=\"width: 17%;text-align: right;font-size: 8px;vertical-align:bottom;padding-top: 8px;\">" + ticket.goods[i].uprice + "</td>";
  1441. content += "<td style=\"width: 17%;text-align: right;font-size: 8px;vertical-align:bottom;padding-top: 8px;\">" + ticket.goods[i].discountPrice + "</td>";
  1442. // content += "<td style=\"width: 17%;text-align: right;font-size: 8px;vertical-align:bottom;padding-top: 8px;\">" + ticket.goods[i].taxation + "</td>";
  1443. content += "<td style=\"width: 15%;text-align: center;font-size: 8px;vertical-align:bottom;padding-top: 8px;\">" + ticket.goods[i].num + "</td>";
  1444. content += "<td style=\"width: 18%;text-align: right;font-size: 8px;vertical-align:bottom;padding-top: 8px;\">" + ticket.goods[i].subtotal + "</td>";
  1445. content += "</tr>";
  1446. }
  1447. content += "</table>";
  1448. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  1449. //收银信息
  1450. content += "<div style=\"width: 100%;\">";
  1451. content += "<span style=\"float: left;width: 50%;text-align: left;\">商品合计:</span>";
  1452. content += "<span style=\"float: left;width: 17%;text-align: left;\">" + ticket.cashInfo.goodsTotal + "件</span>";
  1453. content += "<span style=\"float: right;width: 33%;text-align: right;\">" + ticket.cashInfo.total + "元</span>";
  1454. content += "</div>";
  1455. content += "<div style=\"width: 100%;\">";
  1456. content += "<span style=\"float: left;width: 50%;text-align: left;\">税费合计:</span>";
  1457. content += "<span style=\"float: left;width: 17%;text-align: left;\">" + ticket.cashInfo.goodsTotal + "件</span>";
  1458. content += "<span style=\"float: right;width: 33%;text-align: right;\">" + ticket.cashInfo.taxTotal + "元</span>";
  1459. content += "</div>";
  1460. content += "<div style=\"width: 100%;\">";
  1461. content += "<span style=\"float: left;width: 50%;text-align: left;\">优惠合计:</span>";
  1462. content += "<span style=\"float: right;width: 50%;text-align: right;\">" + ticket.cashInfo.oddChange + "元</span>";
  1463. content += "</div>";
  1464. content += "<div style=\"width: 100%;\">";
  1465. content += "<span style=\"float: left;width: 50%;text-align: left;\">实收:</span>";
  1466. content += "<span style=\"float: right;width: 50%;text-align: right;\">" + ticket.cashInfo.receipts + "元</span>";
  1467. content += "</div>";
  1468. content += "<div style=\"width: 100%;\">";
  1469. content += "<span style=\"float: left;width: 50%;text-align: left;\">优惠券:</span>";
  1470. content += "<span style=\"float: right;width: 50%;text-align: right;\">" + ticket.cashInfo.coupon + "元</span>";
  1471. content += "</div>";
  1472. // content += "<div style=\"width: 100%;\">";
  1473. // content += "<span style=\"float: left;width: 50%;text-align: left;\">运费:</span>";
  1474. // content += "<span style=\"float: right;width: 50%;text-align: right;\">" + ticket.cashInfo.freight + "元</span>";
  1475. // content += "</div>";
  1476. content += "<div style=\"width: 100%;\">";
  1477. content += "<span style=\"float: left;width: 50%;text-align: left;\">支付渠道:</span>";
  1478. // 后期改成从系统中取
  1479. content += "<span style=\"float: right;width: 50%;text-align: right;\">" + ticket.cashInfo.paymentMode + "</span>";
  1480. content += "</div>";
  1481. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  1482. //海关清单信息
  1483. // content += "<div style=\"width: 100%;\">";
  1484. // content += "订单号:" + ticket.cusListing.orderId;
  1485. // content += "</div>";
  1486. // content += "<div style=\"width: 100%;\">";
  1487. // content += "运单编号:" + ticket.cusListing.waybillId;
  1488. // content += "</div>";
  1489. content += "<div style=\"width: 100%;\">";
  1490. content += "海关清单号:" + ticket.cusListing.invtNo;
  1491. content += "</div>";
  1492. // content += "<div style=\"width: 100%;\">";
  1493. // content += "收货人:" + ticket.cusListing.consignee;
  1494. // content += "</div>";
  1495. // content += "<div style=\"width: 100%;\">";
  1496. // content += "收货人电话:" + ticket.cusListing.consigneeTel;
  1497. // content += "</div>";
  1498. // content += "<div style=\"width: 100%;\">";
  1499. // content += "始发地: 仓库地址 : 广东省深圳市南山区前海保税港区W104" ;
  1500. // content += "</div>";
  1501. // content += "<div style=\"width: 100%;\">";
  1502. // content += "交货地:" + ticket.cusListing.deliveryAddress;
  1503. // content += "</div>";
  1504. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  1505. content += "<div style=\"width: 100%;text-align: center;\">";
  1506. content += "购买跨境商品须知:"
  1507. content += "</div>";
  1508. content += "<div style=\"width: 100%;\">";
  1509. content += "1、凡购买跨境商品均不提供发票;<br> 2、单笔限购5000元,年交易限额2.6万元; <br> 3、所有订单经海关放行后方可提货; <br> 4、凭小票领取您的订单商品; <br> 5、非产品质量问题,跨境商品不支持无理由退换货,请及时检查。 "
  1510. content += "</div>";
  1511. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  1512. content += "<div style=\"width: 100%;\">";
  1513. // content += ticket.ticketFoot.summary;
  1514. content += "</div>";
  1515. content += "<div style=\"width: 100%;\">";
  1516. // content += "客服电话:" + ticket.ticketFoot.serviceTel;
  1517. content += "</div>";
  1518. content += "<div style=\"width: 100%;\">";
  1519. // content += "网址:" + ticket.ticketFoot.url1;
  1520. content += "</div>";
  1521. content += "<div style=\"width: 100%;\">";
  1522. content += "欢迎再次惠顾 --服务电话:" + ticket.ticketMailInfo.shopTel;
  1523. content += "</div>";
  1524. content += "<div style=\"width: 100%;\">";
  1525. content += ticket.ticketHead.storeAddress;
  1526. content += "</div>";
  1527. content += "<div style=\"width: 100%;\">";
  1528. content += "请保管好收银小票。";
  1529. content += "</div>";
  1530. // 打印二维码
  1531. content += "<div style=\"text-align: center;width: 100%;height: 250px;\">";
  1532. content += `<img src='${ticket.ticketMailInfo.storeImgUrl}' style='width: 100%;height: 100%;' />`;
  1533. content += "</div>";
  1534. content += "<div style=\"width: 100%;text-align: center;\">";
  1535. content += "关注CW大药房客服号,获取更多优惠信息"
  1536. content += "</div>";
  1537. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  1538. content += "<div style=\"width: 100%;height: 50px;\"></div>";
  1539. // var strategies = {
  1540. // "best": function(data){
  1541. // return render_of_best(data);
  1542. // },
  1543. // "yto": function(data){
  1544. // return render_of_yto(data);
  1545. // }
  1546. // };
  1547. //
  1548. // var renderMailInfo = function(exprCode, data){
  1549. // return strategies[exprCode](data);
  1550. // };
  1551. //
  1552. // renderMailInfo('best', ticket);
  1553. // 面单打印
  1554. content += `
  1555. <div style="width: 100%; height: 82px; border: 1px solid black;">
  1556. <div style="width: 100%;height: 78px; overflow: hidden">
  1557. <img src='${ticket.ticketMailInfo.exprLogoUrl}' style='max-width:180px;' />
  1558. </div>
  1559. </div>
  1560. <!-- 面单条码 -->
  1561. <div style="width: 100%;height: 98px; border-width: 0 1px 1px 1px; border-style: solid; border-color: black;">
  1562. <div style="width: 200px; height: 88px;">
  1563. <img src='data:image/png;base64,${ticket.ticketMailInfo.exprNoBase64Img}' style='max-width:199px;' />
  1564. </div>
  1565. </div>
  1566. <div style="width: 100%; border-width: 0 1px 1px 1px; border-style: solid; border-color: black;">
  1567. <div style="padding: 5px 10px 5px 10px">
  1568. <div style="width: 65px; display: inline; font-weight: bolder;">
  1569. 收件人
  1570. </div>
  1571. <div style="width: 100px; display: inline;">
  1572. <span style="font-weight: bold">${ticket.cusListing.consignee}</span> <span style="font-weight: bold">${ticket.cusListing.consigneeTel}</span>
  1573. </div>
  1574. <div style="width: 100%">
  1575. ${ticket.ticketMailInfo.consigneeProvince} ${ticket.ticketMailInfo.consigneeCity} ${ticket.ticketMailInfo.consigneeDistrict} ${ticket.ticketMailInfo.consigneeAddress}
  1576. </div>
  1577. </div>
  1578. </div>
  1579. <div style="width: 100%; border-width: 0 1px 1px 1px; border-style: solid; border-color: black;">
  1580. <div style="padding: 5px 10px 5px 10px">
  1581. <div style="width: 65px; display: inline; font-weight: bolder">
  1582. 发件人
  1583. </div>
  1584. <div style="width: 100px; display: inline;">
  1585. <span style="font-weight: bold">${ticket.ticketMailInfo.senderName}</span> <span style="font-weight: bold">${ticket.ticketMailInfo.senderTel}</span>
  1586. </div>
  1587. <div style="width: 100%">
  1588. 仓库地址:${ticket.ticketMailInfo.senderProvince} ${ticket.ticketMailInfo.senderCity} ${ticket.ticketMailInfo.senderDistrict} ${ticket.ticketMailInfo.senderAddress}
  1589. </div>
  1590. </div>
  1591. </div>
  1592. `;
  1593. let box = "<div style='width: 100%; position: relative;'>";
  1594. for (let i = 0;i < ticket.goods.length; i++){
  1595. let topBorder = 0, bottomBorder = 0;
  1596. // if (i === 0) {
  1597. // topBorder = "1px";
  1598. // }
  1599. if (i === ticket.goods.length - 1) {
  1600. bottomBorder = "1px";
  1601. }
  1602. let paddingBottom = "5px";
  1603. if (i === ticket.goods.length - 1) {
  1604. paddingBottom = "35px";
  1605. }
  1606. box += `
  1607. <div
  1608. style="width: 100%; border-width: ${topBorder} 1px ${bottomBorder} 1px; border-style: solid; border-color: black; font-weight: bold;">
  1609. <div style="text-align: left;width: 70%; line-height: 1.5; padding: 5px 10px ${paddingBottom} 10px ">
  1610. ${ticket.goods[i].gname} *${ticket.goods[i].num}
  1611. </div>
  1612. </div>`;
  1613. }
  1614. let markBox = `<div style="position: absolute; bottom: 5px; right: 5px; font-weight: bold; font-size: 10pt; color: #9b9b9b">已验视</div>`;
  1615. box += markBox;
  1616. box += "</div>";
  1617. content += box;
  1618. if (typeof callback === "function") {
  1619. callback(content);
  1620. }
  1621. return content;
  1622. }
  1623. function queryAssistantInfo(){
  1624. $.get("../sys/user/info", function (r) {
  1625. if(r.code == 0){
  1626. vm.sysUserInfo = r.user;
  1627. $.get("../store/getStoresByMerch?merchSn="+r.user.merchSn+"&_=1590374349985",function(result){
  1628. if(result.code == 0){
  1629. for(var i = 0 ;i < result.list.length; i++){
  1630. if(result.list[i].id == r.user.storeId){
  1631. vm.storeName = result.list[i].storeName;
  1632. break;
  1633. }
  1634. }
  1635. }
  1636. });
  1637. }
  1638. });
  1639. }
  1640. function removeByValue(arr, val) {
  1641. var index = arr.indexOf(val);
  1642. if (index > -1) {
  1643. arr.splice(index, 1);
  1644. }
  1645. }
  1646. function handle(goodsDetails,operatorType){
  1647. vm.goodsDetail = true;
  1648. // goodsDetails.sellVolume = 1;
  1649. // console.log("goodsDetails=====>" + JSON.stringify(goodsDetails));
  1650. goodsDetails.id = vm.index;
  1651. // console.log("vm.index====>" + vm.index);
  1652. if(!vm.goodsList[vm.index]){
  1653. vm.index = vm.max;
  1654. }
  1655. // console.log("vm.goodsList[vm.index]=====>" + vm.goodsList[vm.index]);
  1656. vm.max++;
  1657. goodsDetails.goodsDesc = "";
  1658. // 判断当前商品是否是赠品
  1659. /*var freeMap = vm.freeBardcode.get(goodsDetails.prodBarcode);
  1660. if(freeMap && "minus" != operatorType){
  1661. goodsDetails.actualPaymentAmount = 0;
  1662. goodsDetails.discountedPrice = goodsDetails.retailPrice;
  1663. vm.freeBardcode.set(goodsDetails.prodBarcode,freeMap - 1);
  1664. }else{
  1665. if(!freeMap && freeMap != 0 ){
  1666. // 判断购物车中是否有赠品 这个操作只有是非赠品才能进来
  1667. for(var i = 0 ; i < vm.goodsList.length ; i++){
  1668. var shopcartGoods = vm.goodsList[i];
  1669. var shopcartFree = vm.freeBardcode.get(shopcartGoods.prodBarcode);
  1670. if(shopcartFree /!*&& shopcartGoods.actualPaymentAmount*!/){
  1671. // if("minus" != operatorType){
  1672. var shopcartSellNum = shopcartGoods.sellVolume;
  1673. if(shopcartFree > shopcartSellNum){
  1674. shopcartGoods.actualPaymentAmount = 0;
  1675. shopcartGoods.discountedPrice = shopcartGoods.retailPrice * shopcartFree;
  1676. vm.discountedPrice = vm.discountedPrice + shopcartGoods.discountedPrice ;
  1677. vm.actualPrice = vm.actualPrice + shopcartGoods.actualPaymentAmount ;
  1678. vm.freeBardcode.set(shopcartGoods.prodBarcode,shopcartFree - 1);//
  1679. }else if(shopcartFree == -1 ){
  1680. // g.actualPaymentAmount == 0){
  1681. shopcartGoods.actualPaymentAmount = shopcartGoods.retailPrice + shopcartGoods.actualPaymentAmount;
  1682. shopcartGoods.discountedPrice = shopcartGoods.discountedPrice - shopcartGoods.retailPrice;
  1683. vm.discountedPrice = vm.discountedPrice + shopcartGoods.discountedPrice ;
  1684. vm.actualPrice = vm.actualPrice + shopcartGoods.actualPaymentAmount ;
  1685. vm.freeBardcode.set(shopcartGoods.prodBarcode,0);// 重置回0
  1686. }else{
  1687. if(shopcartGoods.actualPaymentAmount > 0){
  1688. shopcartGoods.actualPaymentAmount = shopcartGoods.actualPaymentAmount - (shopcartGoods.retailPrice * shopcartFree);
  1689. shopcartGoods.discountedPrice = shopcartGoods.discountedPrice + (shopcartGoods.retailPrice * shopcartFree);
  1690. vm.actualPrice = vm.actualPrice - (shopcartGoods.retailPrice * shopcartFree) ;
  1691. vm.discountedPrice = vm.discountedPrice + (shopcartGoods.retailPrice * shopcartFree) ;
  1692. vm.freeBardcode.set(shopcartGoods.prodBarcode, shopcartFree - 1);// 重置回0
  1693. }
  1694. }
  1695. // }
  1696. }
  1697. }
  1698. }
  1699. }*/
  1700. goodsDetails.discountedPrice = Math.round(goodsDetails.discountedPrice * 100) / 100;
  1701. goodsDetails.actualPaymentAmount = Math.round(goodsDetails.actualPaymentAmount * 100) / 100;
  1702. var data = Object.assign({}, JSON.parse(JSON.stringify(goodsDetails)));
  1703. var isPush = true;
  1704. // 判断当前商品是否添加过
  1705. for(var i = 0 ; i < vm.goodsList.length ; i++){
  1706. if(vm.goodsList[i].goodsSn == data.goodsSn){
  1707. var goodsDetails = vm.goodsList[i];
  1708. if(data.actualPaymentAmount < 0 && goodsDetails.actualPaymentAmount == 0){
  1709. // goodsDetails.goodstaxes = Math.round((parseFloat(goodsDetails.goodstaxes) - parseFloat(data.goodstaxes)) * 100)/100;
  1710. // goodsDetails.discountedPrice = Math.round((parseFloat(goodsDetails.discountedPrice) - parseFloat(data.discountedPrice)) * 100)/100;
  1711. goodsDetails.actualPaymentAmount = 0;
  1712. }else{
  1713. // 税 goodstaxes,优惠金额 discountedPrice,实际支付 actualPaymentAmount,数量 sellVolume 45636917
  1714. goodsDetails.actualPaymentAmount = Math.round((parseFloat(goodsDetails.actualPaymentAmount) + parseFloat(data.actualPaymentAmount)) * 100)/100;
  1715. }
  1716. goodsDetails.discountedPrice = Math.round((parseFloat(goodsDetails.discountedPrice) + parseFloat(data.discountedPrice)) * 100)/100;
  1717. goodsDetails.goodstaxes = Math.round((parseFloat(goodsDetails.goodstaxes) + parseFloat(data.goodstaxes)) * 100)/100;
  1718. goodsDetails.sellVolume = Math.round((parseFloat(goodsDetails.sellVolume) + parseFloat(data.sellVolume)) * 100)/100;
  1719. goodsDetails.activity = data.activity;
  1720. isPush = false;
  1721. break;
  1722. }
  1723. }
  1724. // for(var i = 0 ; i < vm.goodsList.length ; i++){
  1725. // if(vm.goodsList[i].goodsSn == data.goodsSn){
  1726. // var goodsDetails = vm.goodsList[i];
  1727. // // 税 goodstaxes,优惠金额 discountedPrice,实际支付 actualPaymentAmount,数量 sellVolume 45636917
  1728. // goodsDetails.goodstaxes = Math.round((parseFloat(goodsDetails.goodstaxes) + parseFloat(data.goodstaxes)) * 100)/100;
  1729. // goodsDetails.discountedPrice = Math.round((parseFloat(goodsDetails.discountedPrice) + parseFloat(data.discountedPrice)) * 100)/100;
  1730. // goodsDetails.actualPaymentAmount = Math.round((parseFloat(goodsDetails.actualPaymentAmount) + parseFloat(data.actualPaymentAmount)) * 100)/100;
  1731. // goodsDetails.sellVolume = Math.round((parseFloat(goodsDetails.sellVolume) + parseFloat(data.sellVolume)) * 100)/100;
  1732. // goodsDetails.activity = data.activity;
  1733. // isPush = false;
  1734. // break;
  1735. // }
  1736. // }
  1737. if(isPush){
  1738. vm.goodsList.push(data);
  1739. vm.index = vm.index + 1;
  1740. }
  1741. vm.totalPrice = (vm.totalPrice + data.retailPrice);
  1742. if("minus" == operatorType){
  1743. vm.totalCount = vm.totalCount - 1;
  1744. }else{
  1745. vm.totalCount = vm.totalCount + 1;
  1746. }
  1747. if(vm.reduceMoney > 0){
  1748. vm.discountedPrice = vm.discountedPrice + data.discountedPrice + vm.reduceMoney;
  1749. vm.actualPrice = new BigNumber(vm.actualPrice).add(new BigNumber(data.actualPaymentAmount)).subtract(new BigNumber(vm.reduceMoney));
  1750. vm.showReduceMoney = vm.showReduceMoney + vm.reduceMoney;
  1751. vm.reduceMoney = 0;
  1752. }else{
  1753. vm.discountedPrice = vm.discountedPrice + data.discountedPrice ;
  1754. vm.actualPrice = new BigNumber(vm.actualPrice).add(new BigNumber(data.actualPaymentAmount));
  1755. }
  1756. if(data.sellVolume < 0){
  1757. data.sellVolume = - data.sellVolume;
  1758. data.retailPrice = - data.retailPrice;
  1759. data.goodstaxes = -data.goodstaxes;
  1760. }
  1761. vm.goods = data;
  1762. // 处理精度
  1763. vm.totalPrice = Math.round(vm.totalPrice * 100) / 100;
  1764. vm.discountedPrice = Math.round(vm.discountedPrice * 100) / 100;
  1765. vm.actualPrice = Math.round(vm.actualPrice * 100) / 100;
  1766. vm.showReduceMoney = Math.round(vm.showReduceMoney * 100) / 100;
  1767. // console.log("goodsDetails after=====>" + JSON.stringify(vm.goodsList));
  1768. }
  1769. // 下单处理
  1770. function toPayOrder(payCode){
  1771. $('#payCode').unbind('keydown').keydown(function(event){});
  1772. vm.machineCode = sessionStorage.getItem("machineCode");
  1773. var status = $('input:radio:checked').val();
  1774. var cmbCity = $('#cmbCity').val();
  1775. var cmbProvince = $('#cmbProvince').val();
  1776. var cmbArea = $('#cmbArea').val();
  1777. var addrUser = $('#addrUser').val();
  1778. addrUser = cmbProvince+cmbCity+cmbArea+addrUser;
  1779. // console.log('单选按钮值:'+status);
  1780. // console.log('城市三级联动的值:'+cmbProvince+'|'+cmbCity+'|'+cmbArea+'|'+addrUser);
  1781. console.log(vm.machineCode);
  1782. var param = {'userInfo':vm.userInfo,
  1783. 'payCode':vm.parCode,
  1784. 'goodsList':vm.goodsList,
  1785. 'sessionId':vm.sessionId,
  1786. 'machineCode':vm.machineCode,
  1787. 'memberCode': vm.memberCode,
  1788. 'memberPhone': vm.memberPhone,
  1789. 'deductionScore': new BigNumber(vm.deductionScore).toString(),
  1790. 'actualPrice': new BigNumber(vm.actualPrice).toString(),
  1791. 'scoreDeductionPrice': vm.scoreDeductionPrice,
  1792. 'scoreLimit': vm.scoreLimit,
  1793. 'beforeScore': vm.beforeScore,
  1794. 'afterScore': vm.afterScore,
  1795. 'openId': vm.openId,
  1796. 'cmbProvince':cmbProvince,
  1797. 'cmbCity':cmbCity,
  1798. 'cmbArea':cmbArea,
  1799. 'addrUser':addrUser,
  1800. 'status':status,
  1801. };
  1802. console.log(JSON.stringify(param));
  1803. vm.parCode = "";
  1804. $.ajax({
  1805. type: "POST",
  1806. url: "../order/orderConfirm",
  1807. contentType: "application/json",
  1808. data: JSON.stringify(param),
  1809. success: function (r) {
  1810. console.log(r);
  1811. if (r.code == 0) {
  1812. if (r.resultObj != null) {
  1813. $(".form-group input[type=text]").each(function(){
  1814. this.value = '';
  1815. })
  1816. // 打印小票码小票
  1817. var content = getPrintContent(r.resultObj);
  1818. console.log(content);
  1819. printArea2(content);
  1820. vm.goodsList = [];
  1821. vm.customname = '' ;
  1822. vm.customidcard = '';
  1823. vm.customClearData();
  1824. }else{
  1825. // alert("打印小票失败");
  1826. }
  1827. } else {
  1828. alert(r.msg);
  1829. }
  1830. }
  1831. });
  1832. }
  1833. // 调用后端接口进行退款
  1834. function toRefund(){
  1835. confirm('确认退款吗?', function () {
  1836. vm.canRefund = false;
  1837. $.ajax({
  1838. type: "POST",
  1839. url: "../order/orderHkRefund",
  1840. contentType: "application/json",
  1841. data: JSON.stringify({'orderId':vm.currentOrderNo,'sessionId':vm.sessionId}),
  1842. success: function (r) {
  1843. if (r.code == 0) {
  1844. vm.canRefund = true;
  1845. alert("退款成功")
  1846. } else if (r.code == 500) {
  1847. vm.canRefund = true;
  1848. alert(r.msg)
  1849. } else {
  1850. alert("退款失败,请联系管理员");
  1851. }
  1852. }
  1853. });
  1854. })
  1855. }
  1856. /**
  1857. * 计算当前购物栏商品优惠价格
  1858. */
  1859. calculateOrderPrice = function() {
  1860. let param = {
  1861. 'storeId': sessionStorage.getItem("storeId"),
  1862. 'memberCode': vm.$refs.couponBarCode.value,
  1863. 'goodsList' : vm.goodsList
  1864. };
  1865. // console.log("请求参数===>" + JSON.stringify(param));
  1866. $.ajax({
  1867. type: "POST",
  1868. url: "../order/calculateOrderDiscountPrice",
  1869. contentType: "application/json",
  1870. data: JSON.stringify(param),
  1871. success: function (r) {
  1872. if (r.code === 0) {
  1873. let calGoodsList = r.data.goodsDetailsDtos;
  1874. // 更新购物栏中数据
  1875. // console.log("返回====>" + JSON.stringify(r));
  1876. // console.log("计算前数据===>" + JSON.stringify(vm.goodsList));
  1877. vm.goodsList.clear();
  1878. calGoodsList.forEach(goods => vm.goodsList.push(goods));
  1879. vm.actualPrice = new BigNumber(r.data.orderTotalPrice).toString();
  1880. vm.memberCode = r.data.memberCode;
  1881. vm.memberPhone = r.data.memberPhone;
  1882. vm.openId = r.data.openId;
  1883. vm.deductionScore = r.data.deductionScore;
  1884. vm.scoreDeductionPrice = r.data.scoreDeductionPrice;
  1885. vm.scoreLimit = r.data.scoreLimit;
  1886. vm.beforeScore = r.data.beforeScore;
  1887. vm.afterScore = r.data.afterScore;
  1888. // console.log("计算后数据===>" + JSON.stringify(calGoodsList));
  1889. // console.log("替换后数据===>" + JSON.stringify(vm.goodsList));
  1890. $("#calculateOrderPriceDialog").modal('hide');
  1891. alert("计算完成");
  1892. } else if (r.code === 500) {
  1893. alert(r.msg);
  1894. } else {
  1895. alert("计算失败,请联系管理员");
  1896. }
  1897. }
  1898. });
  1899. }
  1900. /**
  1901. * 处理加减按钮操作
  1902. * @param currentGoodsDetail 当前操作的商品详情
  1903. * @param type 类型,add:加 minus:减
  1904. */
  1905. handleSellVolume = function (currentGoodsDetail, type) {
  1906. // console.log("处理前商品详情=====>" + JSON.stringify(currentGoodsDetail));
  1907. // 当前未被处理的商品数量
  1908. let number = currentGoodsDetail.sellVolume;
  1909. // 当前商品应支付金额
  1910. let currentActualPaymentAmount = new BigNumber(currentGoodsDetail.actualPaymentAmount);
  1911. // 当前商品税款
  1912. let currentGoodsTax = new BigNumber(currentGoodsDetail.goodstaxes);
  1913. // 当前商品零售价
  1914. let retailPrice = new BigNumber(currentGoodsDetail.retailPrice);
  1915. // 单个商品时的税款
  1916. let singleTax = currentGoodsTax.divide(number);
  1917. // 单个商品时的应支付金额
  1918. let singleActualPaymentAmount = currentActualPaymentAmount.divide(number);
  1919. // 当前总价
  1920. let currentTotalPrice = new BigNumber(vm.totalPrice);
  1921. // 当前实际支付价
  1922. let currentActualPrice = new BigNumber(vm.actualPrice);
  1923. let storeId = sessionStorage.getItem("storeId");
  1924. let sku = currentGoodsDetail.sku;
  1925. let prodBarcode = currentGoodsDetail.prodBarcode;
  1926. if ('add' === type) {
  1927. $.get("../goods/number/add/"+ storeId +"/" + sku + "/" + prodBarcode + "/" + number, function (res) {
  1928. if (res.code === 0) {
  1929. currentGoodsDetail.sellVolume += 1;
  1930. currentGoodsDetail.goodstaxes = currentGoodsTax.add(singleTax).toString();
  1931. currentGoodsDetail.actualPaymentAmount = currentActualPaymentAmount.add(singleActualPaymentAmount).toString();
  1932. vm.totalCount += 1;
  1933. vm.totalPrice = currentTotalPrice.add(retailPrice).toString();
  1934. vm.actualPrice = currentActualPrice.add(singleActualPaymentAmount).toString();
  1935. } else if (res.code === 500) {
  1936. alert(res.msg);
  1937. } else {
  1938. alert("未知异常!请联系管理员!");
  1939. }
  1940. });
  1941. } else {
  1942. $.get("../goods/number/minus/"+ storeId +"/" + sku + "/" + prodBarcode, function (res) {
  1943. if (res.code === 0) {
  1944. currentGoodsDetail.sellVolume -= 1;
  1945. currentGoodsDetail.goodstaxes = currentGoodsTax.subtract(singleTax).toString();
  1946. currentGoodsDetail.actualPaymentAmount = currentActualPaymentAmount.subtract(singleActualPaymentAmount).toString();
  1947. vm.totalCount -= 1;
  1948. vm.totalPrice = currentTotalPrice.subtract(retailPrice).toString();
  1949. vm.actualPrice = currentActualPrice.subtract(singleActualPaymentAmount).toString();
  1950. } else if (res.code === 500) {
  1951. alert(res.msg);
  1952. } else {
  1953. alert("未知异常!请联系管理员!");
  1954. }
  1955. });
  1956. }
  1957. for (let i = 0; i < vm.goodsList.length; i++) {
  1958. let goods = vm.goodsList[i];
  1959. if (currentGoodsDetail.prodBarcode === goods.prodBarcode && currentGoodsDetail.goodsSn === goods.goodsSn) {
  1960. let splice = vm.goodsList.splice(i, 1, currentGoodsDetail);
  1961. // console.log("被删除的元素====>" + JSON.stringify(splice));
  1962. }
  1963. }
  1964. // console.log("处理后商品详情=====>" + JSON.stringify(currentGoodsDetail));
  1965. }