sale.js 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625
  1. $(function () {
  2. openWebSocket();
  3. queryAssistantInfo();
  4. });
  5. window.onbeforeunload = function(){
  6. closeWebSocket();
  7. }
  8. function debounce(fn,delay){
  9. console.log("进来了");
  10. var timer=null
  11. return function(){
  12. console.log(timer);
  13. if(timer){
  14. clearTimeout(timer)
  15. }
  16. timer = setTimeout(fn,delay)
  17. }
  18. }
  19. function calculateGoodsPrice(r){
  20. var rMap = r.map;
  21. var barCode = r.goodsDetails.prodBarcode;
  22. var brand = r.goodsDetails.brand;
  23. console.log(rMap);
  24. if(rMap.yhq){
  25. for(var i in rMap.yhq){
  26. vm.coupons.set(i,rMap.yhq[i]);
  27. }
  28. }
  29. // 是否有满减活动
  30. if(rMap.mj){
  31. if(rMap.mj[barCode] && !vm.mj.get(barCode)){
  32. // 该商品是否已经有过满减活动
  33. vm.mj.set(barCode,rMap.mj[barCode]);
  34. }else if(rMap.mj[brand] && !vm.mj.get(brand)){
  35. // 该品牌是否已经有过满减活动
  36. vm.mj.set(brand,rMap.mj[brand]);
  37. }
  38. }
  39. if(rMap.mysy){
  40. // 买的条码, 买的数量,送的条码,送的数量
  41. var mysy = {
  42. buyNum:rMap.mysy.buyNum,
  43. giftBarcode:rMap.mysy.giftBarcode,
  44. sendNum:rMap.mysy.sendNum
  45. };
  46. if(rMap.mysy.brand){
  47. vm.brandGetOneFree.set(rMap.mysy.productBrand,mysy);
  48. }else{
  49. vm.barcodeGetOneFree.set(rMap.mysy.barcode , mysy);
  50. }
  51. }
  52. if(rMap.mz){
  53. if(rMap.mz[barCode] && !vm.mz.get(barCode)){
  54. // 该商品是否已经有过满赠活动
  55. vm.mz.set(barCode,rMap.mz[barCode]);
  56. }else if(rMap.mz[brand] && !vm.mz.get(brand)){
  57. // 该品牌是否已经有过满赠活动
  58. vm.mz.set(brand,rMap.mz[brand]);
  59. }
  60. }
  61. if(rMap.drjbj){
  62. if(!vm.halfPrice.get(rMap.drjbj.barcode)){
  63. vm.halfPrice.set(rMap.drjbj.barcode,1);
  64. }
  65. }
  66. // if(rMap.zhjsp){
  67. // // 遍历该商品所有可能的组合价商品类型
  68. // for(var data in rMap.zhjsp){
  69. // if(!vm.zhjsp.get(data)){
  70. // // 分割组合价商品的条码,并以 条码:0 放入map中
  71. // var barCodeArray = data.toString().split(":");
  72. // var dataMap = new Map();
  73. // console.log(rMap.zhjsp[data]);
  74. // // dataMap.set();
  75. // for(var j = 0 ; j < barCodeArray.length ; j ++){
  76. // dataMap.set(barCodeArray[j],0);
  77. // }
  78. // vm.combinationPrice.set(data,rMap.zhjsp[data][0].combinedPrice)
  79. //
  80. // vm.zhjsp.set(data,dataMap);
  81. // }
  82. // }
  83. //
  84. // }
  85. // calculateGoodsByMj(r.goodsDetails,"add");
  86. calculateGoodsByMysy(r.goodsDetails,"add");
  87. calculateGoodsByMz(r.goodsDetails,"add");
  88. calculateGoodsByHalfPrice(r.goodsDetails,"add");
  89. // calculateGoodsByZhjsp(r);
  90. }
  91. // ==================== 满减==========================
  92. // 满减
  93. function calculateGoodsByMj(goodsDetails,type){
  94. if(vm.mj.get(goodsDetails.prodBarcode)){
  95. fullReduction(goodsDetails,goodsDetails.prodBarcode);
  96. }else if(vm.mj.get(goodsDetails.brand)){
  97. fullReduction(goodsDetails,goodsDetails.brand);
  98. }
  99. }
  100. // 满减的计算内容
  101. function fullReduction(goodsDetails,key){
  102. // 获取满减条件金额
  103. var qualifiedAmount = vm.mj.get(key).qualifiedAmount;
  104. // 获取已累积金额
  105. var money = vm.accumulatedAmount.get(key);
  106. if(isNaN(money)){
  107. money = goodsDetails.retailPrice;
  108. }else{
  109. money = money + goodsDetails.retailPrice;
  110. }
  111. if(money >= qualifiedAmount){
  112. vm.reduceMoney += vm.mj.get(key).deductionAmount; // 达到满减金额,获取扣减的额度
  113. vm.mj.delete(key); // 获取后删除该商品的满减
  114. vm.accumulatedAmount.delete(key); // 删除满减的金额
  115. }else{
  116. vm.accumulatedAmount.set(key,money);
  117. }
  118. }
  119. // ============================= 第二件半价==========================
  120. function calculateGoodsByHalfPrice(goodsDetails,type){
  121. var half = vm.halfPrice.get(goodsDetails.prodBarcode);
  122. if(half){
  123. var discountPrice = goodsDetails.retailPrice / 2;
  124. if(type == "add"){
  125. // 等于一的话,不满足条件
  126. if(half == 1){
  127. vm.halfPrice.set(goodsDetails.prodBarcode,2);
  128. }else if(half == 2){
  129. goodsDetails.actualPaymentAmount = discountPrice;
  130. goodsDetails.discountedPrice = discountPrice;
  131. vm.halfPrice.set(goodsDetails.prodBarcode,1);
  132. }
  133. }else if(type == "minus"){
  134. if(half == 2){
  135. goodsDetails.actualPaymentAmount = goodsDetails.actualPaymentAmount ;
  136. vm.halfPrice.set(goodsDetails.prodBarcode,1);
  137. }else if(half == 1){
  138. goodsDetails.actualPaymentAmount = goodsDetails.actualPaymentAmount - discountPrice;
  139. goodsDetails.discountedPrice = discountPrice;
  140. vm.halfPrice.set(goodsDetails.prodBarcode,2);
  141. }
  142. }
  143. }
  144. }
  145. // ============================= 满赠 ==============================
  146. // 满赠
  147. function calculateGoodsByMz(goodsDetails,type){
  148. // 判断当前支付金额是否满足满赠金额,若满足,直接修改金额为1
  149. var mzGoods = vm.mz.get(goodsDetails.prodBarcode);
  150. if(mzGoods){
  151. var mzPrice = mzGoods.qualifiedAmount;
  152. if(mzPrice < vm.actualPrice && !mzGoods.useMz){
  153. mzGoods.useMz = true;
  154. goodsDetails.actualPaymentAmount = 1;
  155. goodsDetails.discountedPrice = goodsDetails.retailPrice - 1;
  156. }
  157. }
  158. // // 1.满赠的商品是不是自己,遍历满赠商品数组
  159. // isSend(vm.fullGiftCode,goodsDetails,"满赠");
  160. //
  161. // if(vm.mz.get(goodsDetails.prodBarcode)){
  162. // fullGift(goodsDetails,goodsDetails.prodBarcode);
  163. // }else if(vm.mz.get(goodsDetails.brand)){
  164. // fullGift(goodsDetails,goodsDetails.brand);
  165. // }
  166. }
  167. function fullGift(goodsDetails,key){
  168. // 获取满赠条件金额
  169. var qualifiedAmount = vm.mz.get(key).qualifiedAmount;
  170. // 获取已累积金额
  171. var money = vm.accumulatedAmountForFullGift.get(key);
  172. if(isNaN(money)){
  173. money = goodsDetails.retailPrice;
  174. }else{
  175. money = money + goodsDetails.retailPrice;
  176. }
  177. // 达到满赠的要求
  178. if(money >= qualifiedAmount){
  179. // 将满赠的商品放入数组中,重置金额
  180. vm.fullGiftCode.push(vm.mz.get(key).giftBarcode);
  181. vm.mz.delete(key); // 获取后删除该商品的满减
  182. vm.accumulatedAmountForFullGift.delete(key); // 删除满减的金额
  183. // 2.购物车的商品里面是否有满赠的商品
  184. shopCartContain(vm.fullGiftCode,goodsDetails,"满赠");
  185. }else{
  186. vm.accumulatedAmountForFullGift.set(key,money);
  187. }
  188. }
  189. // 买一送一
  190. function calculateGoodsByMysy(goodsDetails,type){
  191. var mysy = vm.barcodeGetOneFree.get(goodsDetails.prodBarcode);
  192. var brandMysy = vm.brandGetOneFree.get(goodsDetails.brand);
  193. if(mysy){
  194. var buyNum = mysy.buyNum;
  195. if(type == "add"){
  196. // 证明是买一送一,并且达到买一送一的条件
  197. if(buyNum == 1 && vm.boughtNum.get(goodsDetails.prodBarcode)){
  198. // 设置赠品的单价
  199. goodsDetails.discountedPrice = goodsDetails.retailPrice;
  200. goodsDetails.actualPaymentAmount = 0;
  201. // goodsDetails.activity = "买1送1";
  202. // 清除该商品买一送一条件
  203. vm.boughtNum.delete(goodsDetails.prodBarcode);
  204. return ;
  205. }
  206. // 如果不是买一送一,而是买n送n,先获取购物车已有该类型商品数量
  207. var boughtNum = vm.boughtNum.get(goodsDetails.prodBarcode);
  208. // 如果没有,置为1
  209. if(!boughtNum){
  210. vm.boughtNum.set(goodsDetails.prodBarcode , 1);
  211. return ;
  212. }
  213. // 走到这里,证明购买过该类型商品,且数量不是买一送一的
  214. // 如果相等,证明达到送的条件
  215. if(buyNum === boughtNum){
  216. goodsDetails.discountedPrice = goodsDetails.retailPrice;
  217. goodsDetails.actualPaymentAmount = 0;
  218. // goodsDetails.activity = "买"+buyNum+"送1";
  219. // 清除该商品买一送一条件
  220. vm.boughtNum.delete(goodsDetails.prodBarcode);
  221. console.log(vm.boughtNum);
  222. }else{
  223. // 如果不相等,已经购买数量+1
  224. vm.boughtNum.set(goodsDetails.prodBarcode , boughtNum+1);
  225. }
  226. }else if (type == "minus"){
  227. // 获取该产品要买n送1 的n
  228. // 获取已经购买的数量
  229. var boughtNum = goodsDetails.sellVolume;
  230. // 减一后,不满足买一送一条件,重新计算金额
  231. // 如果不等于0,要减去价格
  232. var remainder = 0;
  233. if(boughtNum > buyNum+1){
  234. remainder = buyNum - (boughtNum % (buyNum+1)) ;
  235. }else{
  236. remainder = buyNum - ((buyNum+1) %boughtNum ) ;
  237. }
  238. if(boughtNum % (buyNum+1) != 0){
  239. // console.log("我要减去价格,也要减去数量,减去数量=" + goodsDetails.sellVolume);
  240. goodsDetails.actualPaymentAmount = goodsDetails.retailPrice;
  241. goodsDetails.discountedPrice = 0;
  242. // 如果等于0,只用减去数量跟优惠价,并恢复活动
  243. }else{
  244. // console.log("我不用减去价格,只要减去数量");
  245. goodsDetails.discountedPrice = goodsDetails.retailPrice;
  246. goodsDetails.actualPaymentAmount = 0;
  247. }
  248. goodsDetails.sellVolume = 1;
  249. vm.boughtNum.set(goodsDetails.prodBarcode,remainder);
  250. }
  251. }
  252. if(brandMysy){
  253. var buyNum = brandMysy.buyNum;
  254. if(type == "add"){
  255. // 如果不是买一送一,而是买n送n,先获取购物车已有该类型商品数量
  256. var boughtNum = vm.boughtNum.get(goodsDetails.brand);
  257. // 如果没有,置为1
  258. if(!boughtNum){
  259. vm.boughtNum.set(goodsDetails.brand , 1);
  260. return ;
  261. }
  262. // 走到这里,证明购买过该类型商品,且数量不是买一送一的
  263. // 如果相等,证明达到送的条件
  264. if(buyNum === boughtNum + 1){
  265. var mysyNum = vm.freeBardcode.get(brandMysy.giftBarcode);
  266. if(!mysyNum){
  267. mysyNum = 0;
  268. }
  269. vm.freeBardcode.set(brandMysy.giftBarcode,mysyNum + 1);
  270. vm.boughtNum.set(goodsDetails.brand,0);
  271. }else{
  272. // 如果不相等,已经购买数量+1
  273. vm.boughtNum.set(goodsDetails.brand , boughtNum+1);
  274. }
  275. }else if (type == "minus"){
  276. var mysyNum = vm.boughtNum.get(goodsDetails.brand);
  277. if(mysyNum == 0){
  278. if(vm.freeBardcode.get(brandMysy.giftBarcode) == 0){
  279. vm.freeBardcode.set(brandMysy.giftBarcode,-1);
  280. }else{
  281. vm.freeBardcode.set(brandMysy.giftBarcode,vm.freeBardcode.get(brandMysy.giftBarcode) - 1);
  282. }
  283. vm.boughtNum.set(goodsDetails.brand,buyNum - 1);
  284. }else{
  285. vm.boughtNum.set(goodsDetails.brand,mysyNum - 1);
  286. }
  287. // var freeNum = vm.freeBardcode.get(brandMysy.giftBarcode);
  288. // if(freeNum > 0){
  289. // vm.freeBardcode.set(brandMysy.giftBarcode,freeNum - 1);
  290. //
  291. // }
  292. }
  293. }
  294. // 判断当前商品是否为赠品
  295. // isSend(vm.mysy,goodsDetails,"买一送一");
  296. // 判断购物车里面是否有商品为赠品
  297. // shopCartContain(vm.mysy,goodsDetails,"买一送一");
  298. }
  299. // 判断当前商品是否为赠品
  300. function isSend(activity,goodsDetails,activityName){
  301. if(activity.indexOf(goodsDetails.prodBarcode) >= 0){
  302. // 如果符合条件,把赠送的条码给删除(一次性)
  303. var index = activity.indexOf(goodsDetails.prodBarcode);
  304. activity.splice(index,1);
  305. // 设置赠品的单价
  306. goodsDetails.discountedPrice = goodsDetails.retailPrice - 1;
  307. goodsDetails.actualPaymentAmount = 1;
  308. }
  309. }
  310. // 判断购物车里面是否有商品为赠品
  311. function shopCartContain(activity,goodsDetails,activityName){
  312. if(vm.goodsList && vm.goodsList.length > 0 ){
  313. for(var i = 0 ; i < vm.goodsList.length ; i ++){
  314. // 如果有商品为赠品,则把价格置位0并跳出循环
  315. if(activity.indexOf(vm.goodsList[i].prodBarcode) >= 0 && vm.goodsList[i].actualPaymentAmount != 0){
  316. // 如果符合条件,把赠送的条码给删除(一次性)
  317. var index = vm.mysy.indexOf(goodsDetails.prodBarcode);
  318. activity.splice(index,1);
  319. vm.goodsList[i].discountedPrice = vm.goodsList[i].retailPrice;
  320. vm.goodsList[i].actualPaymentAmount = 0;
  321. vm.goodsList[i].activity = activityName;
  322. vm.discountedPrice = vm.discountedPrice + vm.goodsList[i].retailPrice ;
  323. vm.actualPrice = vm.actualPrice - vm.goodsList[i].retailPrice ;
  324. break;
  325. }
  326. }
  327. }
  328. }
  329. // ======================= 组合价商品 ============================
  330. // 组合价商品
  331. function calculateGoodsByZhjsp(r){
  332. var barCode = r.goodsDetails.prodBarcode;
  333. if(r.map.zhjsp){
  334. // 将有组合的商品设置为1 ps:{"flag" => 0, "4005808550739" => 1, "4305615120454" => 0}
  335. vm.zhjsp.forEach(function(value,key,map){
  336. // 将组合价中组合的产品出现的次数+1
  337. value.forEach(function(v, k ,m){
  338. if(k === barCode)
  339. m.set(k,v+1);
  340. });
  341. var flag = 1;
  342. // 判断是否有商品成功组合
  343. value.forEach(function(v, k ,m){
  344. if(v === 0)
  345. flag = 0;
  346. });
  347. if(flag === 1){
  348. var combinationPrice = vm.combinationPrice.get(key);
  349. var barCodeArr = key.toString().split(":");
  350. // 扫码的商品条码 barCode
  351. for(var i = 0 ; i < barCodeArr.length ; i ++){
  352. var oldCode = barCodeArr[i];
  353. if(oldCode === barCode){
  354. continue;
  355. }
  356. if(vm.compareCombinationPrice.get(oldCode) && vm.compareCombinationPrice.get(oldCode) > combinationPrice){
  357. // 获取原组合关系
  358. var relationshipKey = vm.combinationRelationship.get(oldCode);
  359. // 将价格设置回原来的价格
  360. var keyArr = relationshipKey.toString().split(":");
  361. // 遍历原来的组合
  362. for(var j = 0 ; j < keyArr.length ; j ++){
  363. // 遍历购物车中原来的商品,替换价格
  364. for(var k = 0 ; k < vm.goodsList.length ; k ++){
  365. if(vm.goodsList[k].prodBarcode === keyArr[j] && vm.goodsList[k].activity == "组合价"){
  366. vm.discountedPrice = vm.discountedPrice - vm.goodsList[k].discountedPrice ;
  367. vm.actualPrice = vm.actualPrice + vm.goodsList[k].discountedPrice ;
  368. vm.goodsList[k].discountedPrice = 0 ; // 优惠价格
  369. vm.goodsList[k].actualPaymentAmount = vm.goodsList[k].retailPrice; // 实际支付价格
  370. vm.goodsList[k].isCombination = 0;
  371. vm.goodsList[k].activity = "";
  372. vm.compareCombinationPrice.delete(vm.goodsList[k].prodBarcode);
  373. vm.combinationRelationship.delete(vm.goodsList[k].prodBarcode);
  374. }
  375. }
  376. }
  377. }
  378. }
  379. for( var i = 0 ; i < barCodeArr.length ; i ++ ){
  380. // 如果是扫描的产品,直接退出,因为购物车中无该产品
  381. if(barCodeArr[i] == barCode){
  382. r.goodsDetails.isCombination = 1;
  383. r.goodsDetails.discountedPrice = r.goodsDetails.retailPrice - combinationPrice; // 优惠价格
  384. r.goodsDetails.actualPaymentAmount = combinationPrice; // 实际支付价格
  385. r.goodsDetails.activity = "组合价";
  386. vm.compareCombinationPrice.set(barCode,r.goodsDetails.actualPaymentAmount);
  387. vm.combinationRelationship.set(barCode,key);
  388. continue;
  389. }
  390. for(var j = 0 ; j < vm.goodsList.length ; j ++){
  391. if(vm.goodsList[j].prodBarcode === barCodeArr[i] && !vm.goodsList[j].isCombination){
  392. vm.goodsList[j].discountedPrice = vm.goodsList[j].retailPrice ; // 优惠价格
  393. vm.goodsList[j].actualPaymentAmount = 0; // 实际支付价格
  394. vm.goodsList[j].isCombination = 1;
  395. vm.goodsList[j].activity = "组合价";
  396. vm.discountedPrice = vm.discountedPrice + vm.goodsList[j].retailPrice ; // 总的优惠金额
  397. vm.actualPrice = vm.actualPrice - vm.goodsList[j].retailPrice ; // 总的实际支付金额
  398. vm.compareCombinationPrice.set(vm.goodsList[j].prodBarcode,vm.goodsList[j].actualPaymentAmount);
  399. vm.combinationRelationship.set(vm.goodsList[j].prodBarcode,barCode,key);
  400. break;
  401. }
  402. }
  403. }
  404. // 扣减
  405. var updateMap = map.get(key);
  406. updateMap.forEach(function(v, k ,m){
  407. m.set(k,v-1);
  408. });
  409. }
  410. });
  411. }
  412. console.log(vm.compareCombinationPrice);
  413. }
  414. let vm = new Vue({
  415. el: '#rrapp',
  416. data: {
  417. showList: true,
  418. goodsDetail:false,
  419. title: null,
  420. goods:{},
  421. sysNotice: {},
  422. goodsList:[],
  423. orderInfo:[],
  424. userInfo:{},
  425. //user信息绑定集合
  426. userInfoBinding: {},
  427. sysUserInfo:{},
  428. storeName:null,
  429. prodBarcode:null,
  430. sessionId:null,
  431. pickUpCodeList:[],
  432. goodsDetailList:[],
  433. orderEntity:{},
  434. orderProcessRecord:{},
  435. tax:0,
  436. currentOrderNo:null,
  437. pickUpCode:null,
  438. customname:'',
  439. customidcard:'',
  440. machineCode:'',
  441. storeId:null,
  442. index:0,
  443. max:0,
  444. totalPrice:0,
  445. discountedPrice:0,
  446. actualPrice:0,
  447. ruleValidate: {
  448. name: [
  449. {required: true, message: '名称不能为空', trigger: 'blur'}
  450. ]
  451. },
  452. q: {
  453. name: ''
  454. },
  455. firstPrint:false,
  456. // 第二件半价
  457. halfPrice:new Map(),
  458. // 买一送一
  459. mysy: [],
  460. freeBardcode : new Map(),
  461. modifyShopcart:false, // 是否需要修改购物车中商品信息
  462. brandGetOneFree : new Map(),
  463. barcodeGetOneFree: new Map(),
  464. boughtNum: new Map(),
  465. // 组合价
  466. zhjsp: new Map(),
  467. combinationPrice: new Map(), // 组合价商品的组合价
  468. compareCombinationPrice: new Map(), // 用于比较组合价
  469. combinationRelationship: new Map(), // 组合价格的组合关系
  470. // 满减
  471. mj: new Map(),
  472. accumulatedAmount: new Map(), // 累积金额(满减使用的)
  473. reduceMoney:0, // 满减金额
  474. showReduceMoney:0, // 用于展示的满减金额
  475. // 满赠
  476. useMz:false,
  477. mz: new Map(),
  478. accumulatedAmountForFullGift: new Map(), // 累积金额(满赠使用的)
  479. fullGiftCode:[],// 满赠商品条码
  480. // 优惠券
  481. coupons: new Map(),
  482. // 挂起订单集合
  483. pendingOrderMap: new Map(),
  484. // 挂起订单的key 在1~3循环
  485. pendingIndex:1,
  486. pendingOrderKeys:[],
  487. // 存储商品信息
  488. goodsMap:new Map(),
  489. response: "",
  490. // 支付码
  491. parCode : "",
  492. // 总件数
  493. totalCount:0
  494. },
  495. methods: {
  496. myDebounce:debounce(function(){
  497. toPayOrder();
  498. },2000),
  499. query: function () {
  500. vm.storeId = sessionStorage.getItem("storeId");;
  501. var thisGoods = {};
  502. $.get("../goods/details/"+vm.prodBarcode+"/"+vm.storeId, function (r) {
  503. if (r.code == 0) {
  504. r.goodsDetails.sellVolume = 1;
  505. vm.goodsMap.set(r.goodsDetails.goodsSn,JSON.parse(JSON.stringify(r.goodsDetails)));
  506. vm.prodBarcode = '';
  507. calculateGoodsPrice(r);
  508. handle(r.goodsDetails,"add");
  509. } else {
  510. alert(r.msg);
  511. }
  512. });
  513. },
  514. add:function(value){
  515. // 增加数量
  516. for(var i = 0 ; i < this.goodsList.length ; i++){
  517. if(this.goodsList[i].id == value){
  518. var goodsDetails = JSON.parse(JSON.stringify(vm.goodsMap.get(this.goodsList[i].goodsSn)));
  519. calculateGoodsByMj(goodsDetails,"add");
  520. calculateGoodsByMysy(goodsDetails,"add");
  521. calculateGoodsByHalfPrice(goodsDetails,"add");
  522. // calculateGoodsByMz(goodsDetails,"add");
  523. handle(goodsDetails,"add");
  524. break;
  525. }
  526. }
  527. },
  528. minus:function(value){
  529. // 减少数量
  530. for(var i = 0 ; i < this.goodsList.length ; i++){
  531. if(this.goodsList[i].id == value){
  532. // 获取当前购物车的数量
  533. var g = JSON.parse(JSON.stringify(this.goodsList[i]));
  534. console.log(g);
  535. var goodsDetails = JSON.parse(JSON.stringify(vm.goodsMap.get(this.goodsList[i].goodsSn)));
  536. if(g.sellVolume === 1){
  537. alert("数量至少为1个");
  538. return ;
  539. }
  540. // 如果不为空,证明减的是买A送B中的B,这时候要还原赠送资格跟B的扣减
  541. var freeMap = vm.freeBardcode.get(goodsDetails.prodBarcode);
  542. if((freeMap || freeMap == 0) && g.actualPaymentAmount == 0){
  543. vm.freeBardcode.set(goodsDetails.prodBarcode,freeMap + 1);
  544. goodsDetails.sellVolume = -1;
  545. goodsDetails.actualPaymentAmount = 0;
  546. goodsDetails.discountedPrice = -goodsDetails.retailPrice;
  547. goodsDetails.goodstaxes = - goodsDetails.goodstaxes;
  548. goodsDetails.retailPrice = - goodsDetails.retailPrice;
  549. }else{
  550. goodsDetails.sellVolume = g.sellVolume;
  551. calculateGoodsByMj(goodsDetails,"minus");
  552. calculateGoodsByMysy(goodsDetails,"minus");
  553. calculateGoodsByHalfPrice(goodsDetails,"minus");
  554. // calculateGoodsByMz(goodsDetails,"minus");
  555. goodsDetails.sellVolume = -1;
  556. goodsDetails.actualPaymentAmount = -goodsDetails.actualPaymentAmount;
  557. goodsDetails.discountedPrice = -goodsDetails.discountedPrice;
  558. goodsDetails.goodstaxes = - goodsDetails.goodstaxes;
  559. goodsDetails.retailPrice = - goodsDetails.retailPrice;
  560. }
  561. handle(goodsDetails,"minus");
  562. break;
  563. }
  564. }
  565. },
  566. deleteItem:function(value){
  567. console.log(value);
  568. // 删除这条记录
  569. for(var i = 0 ; i < this.goodsList.length ; i++){
  570. if(this.goodsList[i].id == value){
  571. if(this.goodsList.length == 1){
  572. vm.goods = {};
  573. vm.goodsDetail = false;
  574. }
  575. if(vm.mz.get(this.goodsList[i].prodBarcode)){
  576. vm.mz.get(this.goodsList[i].prodBarcode).useMz = false ;
  577. }
  578. if(vm.brandGetOneFree.get(this.goodsList[i].brand)){
  579. var giftBarcode = vm.brandGetOneFree.get(this.goodsList[i].brand).giftBarcode;
  580. var muilty = vm.brandGetOneFree.get(this.goodsList[i].brand).buyNum;
  581. var sellNum = this.goodsList[i].sellVolume;;
  582. vm.freeBardcode.set(giftBarcode,sellNum/muilty);
  583. for(var j = 0 ; j < vm.goodsList.length ; j++){
  584. var shopcartGoods = vm.goodsList[j];
  585. var shopcartFree = vm.freeBardcode.get(shopcartGoods.prodBarcode);
  586. if(shopcartFree /*&& shopcartGoods.actualPaymentAmount*/){
  587. shopcartGoods.actualPaymentAmount = shopcartGoods.actualPaymentAmount + (shopcartGoods.retailPrice * shopcartGoods.sellVolume);
  588. shopcartGoods.discountedPrice = shopcartGoods.discountedPrice - (shopcartGoods.retailPrice * shopcartGoods.sellVolume);
  589. vm.discountedPrice = vm.discountedPrice - (shopcartGoods.retailPrice * shopcartGoods.sellVolume);
  590. vm.actualPrice = vm.actualPrice + (shopcartGoods.retailPrice * shopcartGoods.sellVolume);
  591. vm.freeBardcode.set(shopcartGoods.prodBarcode, 0);// 重置回0
  592. }
  593. }
  594. }
  595. if(vm.halfPrice.get(this.goodsList[i].prodBarcode)){
  596. vm.halfPrice.set(this.goodsList[i].prodBarcode,1);
  597. }
  598. var goods = this.goodsList[i];
  599. console.log(goods);
  600. console.log(vm.totalPrice);
  601. if(vm.freeBardcode.get(goods.prodBarcode) || vm.freeBardcode.get(goods.prodBarcode) == 0){
  602. var nnum = (((goods.retailPrice * goods.sellVolume) - goods.actualPaymentAmount)/goods.retailPrice);
  603. vm.freeBardcode.set(goods.prodBarcode, nnum);
  604. }
  605. vm.totalPrice = vm.totalPrice - (goods.retailPrice * goods.sellVolume);
  606. vm.totalCount = vm.totalCount - (goods.sellVolume);
  607. vm.discountedPrice = vm.discountedPrice - goods.discountedPrice;
  608. vm.actualPrice = vm.actualPrice - goods.actualPaymentAmount;
  609. vm.boughtNum.delete(goods.prodBarcode);
  610. vm.totalPrice = Math.round(vm.totalPrice * 100) / 100;
  611. vm.discountedPrice = Math.round(vm.discountedPrice * 100) / 100;
  612. vm.actualPrice = Math.round(vm.actualPrice * 100) / 100;
  613. vm.showReduceMoney = Math.round(vm.showReduceMoney * 100) / 100;
  614. this.goodsList.splice(i,1);
  615. break;
  616. }
  617. }
  618. this.index = value;
  619. },
  620. clearGoodsList:function(){
  621. this.goodsList = [];
  622. vm.customClearData();
  623. },
  624. pendingOrder:function(){
  625. if(this.goodsList.length == 0){
  626. alert("购物车中没有商品");
  627. return;
  628. }
  629. console.log(vm.pendingOrderMap.size);
  630. if(vm.pendingOrderMap.size >= 3){
  631. alert("订单挂起最多支持3单");
  632. return;
  633. }
  634. vm.pendingOrderMap.set(vm.pendingIndex,this.goodsList);
  635. vm.pendingOrderKeys.push(vm.pendingIndex);
  636. var newIndex = ++vm.pendingIndex;
  637. vm.pendingIndex = newIndex > 3?1: newIndex;
  638. vm.clearGoodsList();
  639. },
  640. toResumePending:function(){
  641. if(vm.pendingOrderMap.size == 0){
  642. alert("当前没有挂起的订单");
  643. return ;
  644. }
  645. $('#pendignOrderModal').modal('show')
  646. },
  647. resumePending:function(key){
  648. if(vm.pendingOrderMap.size == 0){
  649. alert("当前没有挂起的订单");
  650. return ;
  651. }
  652. if(vm.goodsList.length > 0){
  653. alert("购物车中已有商品,不允许恢复!")
  654. return ;
  655. }
  656. vm.goodsList = vm.pendingOrderMap.get(key);
  657. // 清除恢复的数据
  658. vm.pendingOrderMap.delete(key);
  659. removeByValue(vm.pendingOrderKeys,key);
  660. $('#pendignOrderModal').modal('hide')
  661. },
  662. toOrderSubmit:function(){
  663. if(this.goodsList.length == 0){
  664. alert("请选择商品");
  665. return;
  666. }
  667. $('#myModal').modal('show')
  668. // 每次点击提交订单的时候清空姓名和身份证信息和手机号
  669. // vm.$refs.customName.value = "";
  670. // vm.$refs.customIDCard.value = "";
  671. // vm.$refs.customPhone.value = "";
  672. if(vm.$refs.couponSn)
  673. vm.$refs.couponSn.value = "";
  674. this.userInfo.couponSn = "";
  675. },
  676. submitOrder:function(){
  677. vm.parCode = this.$refs.payCode.currentValue
  678. vm.myDebounce();
  679. },customClearData: function(){
  680. vm.totalPrice = 0;
  681. vm.totalCount = 0;
  682. vm.discountedPrice = 0;
  683. vm.actualPrice = 0;
  684. vm.goods={};
  685. vm.goodsDetail = false;
  686. // 第二件半价
  687. vm.halfPrice = new Map();
  688. // 买一送一
  689. vm.mysy = [];
  690. vm.freeBardcode = new Map();
  691. vm.brandGetOneFree = new Map();
  692. vm.barcodeGetOneFree = new Map();
  693. vm.brandGetOneFree = new Map();
  694. vm.boughtNum = new Map();
  695. // 组合价
  696. vm.zhjsp = new Map();
  697. vm.combinationPrice = new Map(); // 组合价商品的组合价
  698. // 满减
  699. vm.mj = new Map();
  700. vm.accumulatedAmount = new Map();// 累积金额(满减使用的)
  701. vm.reduceMoney = 0; // 满减金额
  702. vm.showReduceMoney = 0; // 用于展示的满减金额
  703. // 满赠
  704. vm.mz = new Map();
  705. vm.accumulatedAmountForFullGift = new Map(); // 累积金额(满赠使用的)
  706. vm.fullGiftCode = [];// 满赠商品条码
  707. // 优惠券
  708. vm.coupons = new Map();
  709. },
  710. queryIDCardInfo: function(){
  711. $.get("../order/queryIDCardInfo/"+vm.$refs.customPhone.value, function (r){
  712. if(r.code === 0){
  713. var data = r.userEntity;
  714. vm.$refs.customName.value = data.username;
  715. vm.$refs.customIDCard.value = data.idNo;
  716. }else{
  717. alert(r.msg);
  718. }
  719. });
  720. },
  721. getIDCardInfo: function(){
  722. $.post("http://127.0.0.1:8000/idcard/read", function (r){
  723. // var dataR = JSON.parse(r);
  724. // console.log(dataR)
  725. if(r.code == "0"){
  726. // if(!r.info){
  727. // alert("请连接设备或设备有问题,请联系管理员!");
  728. // return ;
  729. // }
  730. // var data = JSON.parse(r.info);
  731. // if(data.code=="0"){
  732. vm.$refs.customName.value = r.rows[0].data.name;
  733. vm.$refs.customIDCard.value = r.rows[0].data.id_no;
  734. // }else{
  735. // alert(data.msg);
  736. // return ;
  737. // }
  738. }else if(r.code=="-1"){
  739. alert(r.msg);
  740. return;
  741. }else{
  742. alert("请连接设备或设备有问题,请联系管理员!");
  743. }
  744. });
  745. },
  746. customPhoneBlur:function (){
  747. let customPhone = this.$refs.customPhone.value;
  748. if(customPhone){
  749. for(let key in this.userInfoBinding){
  750. if(customPhone == key){
  751. let userInfoBindingValue = this.userInfoBinding[key];
  752. this.$refs.customName.value = userInfoBindingValue.substring(0, userInfoBindingValue.length-18);
  753. this.$refs.customIDCard.value = userInfoBindingValue.substring(userInfoBindingValue.length-18);
  754. break;
  755. }
  756. }
  757. }
  758. },
  759. submitCustomInfo:function(){
  760. this.userInfo.customName = this.$refs.customName.value ;
  761. this.userInfo.customIDCard = this.$refs.customIDCard.value ;
  762. this.userInfo.customPhone = this.$refs.customPhone.value;
  763. if(this.$refs.couponSn)
  764. this.userInfo.couponSn = this.$refs.couponSn.value;
  765. 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)$/;
  766. if(!this.userInfo.customName){
  767. alert("姓名不能为空!");
  768. return ;
  769. }
  770. if(!idcardReg.test(this.userInfo.customIDCard)){
  771. alert("请输入正确的身份证号");
  772. return ;
  773. }
  774. if(!(/^1[3456789]\d{9}$/.test(this.userInfo.customPhone))){
  775. alert("手机号码有误,请重填");
  776. return ;
  777. }
  778. //将手机号与姓名身份证号进行绑定,下次填写手机号即可
  779. let userInfoBindingKey = this.userInfo.customPhone;
  780. let userInfoBindingValue = this.userInfo.customName+this.userInfo.customIDCard;
  781. this.userInfoBinding[userInfoBindingKey] = userInfoBindingValue;
  782. if(this.userInfo.couponSn && this.userInfo.couponSn != ""){
  783. var coupon = vm.coupons.get(this.userInfo.couponSn);
  784. if(coupon == null){
  785. alert("请输入正确的优惠券码");
  786. return ;
  787. }
  788. }
  789. $("#Send").attr("data-dismiss","modal");
  790. $('#payModal').modal('show');
  791. $("#payCode").keydown(function(e){
  792. if(e.keyCode==13){
  793. $("#submitOrder").click();
  794. event.preventDefault();
  795. }
  796. });
  797. $('body').on('hidden.bs.modal', '.modal', function () {
  798. $(this).removeData();
  799. });
  800. },
  801. queryOrderDetail:function(orderSn,pickUpCode){
  802. var storeId = sessionStorage.getItem("storeId");
  803. $.get("../order/orderDetail/"+orderSn, function (r) {
  804. if (r.code == 0) {
  805. vm.orderProcessRecord = r.resultObj.orderProcessRecordEntity;
  806. vm.orderEntity = r.resultObj.orderEntity;
  807. vm.goodsDetailList = r.resultObj.goodsList;
  808. vm.currentOrderNo = r.resultObj.orderEntity.id;
  809. vm.pickUpCode = pickUpCode;
  810. vm.tax = r.resultObj.tax;
  811. vm.response = r.resultObj.response;
  812. if(vm.orderProcessRecord.eleOrderStartTime){
  813. vm.orderProcessRecord.eleOrderStartTime = parsedate(vm.orderProcessRecord.eleOrderStartTime);
  814. }
  815. if(vm.orderProcessRecord.paymentStartTime){
  816. vm.orderProcessRecord.paymentStartTime = parsedate(vm.orderProcessRecord.paymentStartTime);
  817. }
  818. if(vm.orderProcessRecord.waybillStartTime){
  819. vm.orderProcessRecord.waybillStartTime = parsedate(vm.orderProcessRecord.waybillStartTime);
  820. }
  821. if(vm.orderProcessRecord.customsSuccTime){
  822. vm.orderProcessRecord.customsSuccTime = parsedate(vm.orderProcessRecord.customsSuccTime);
  823. }
  824. if(vm.orderProcessRecord.addOrderStartTime){
  825. vm.orderProcessRecord.addOrderStartTime = parsedate(vm.orderProcessRecord.addOrderStartTime);
  826. }
  827. }
  828. });
  829. },
  830. resendNotice:function(){
  831. confirm('确认重发重置吗?', function () {
  832. $.get("../order/resendOrderToCCNET/"+vm.orderEntity.orderSn+"/notice", function (r) {
  833. alert(r);
  834. });
  835. })
  836. },
  837. resendWaybill:function(){
  838. confirm('确认重发运单吗?', function () {
  839. $.get("../order/resendOrderToCCNET/"+vm.orderEntity.orderSn+"/waybill", function (r) {
  840. alert(r);
  841. });
  842. })
  843. },
  844. resendPayment:function(){
  845. confirm('确认重发支付单吗?', function () {
  846. $.get("../order/resendOrderToCCNET/"+vm.orderEntity.orderSn+"/payment", function (r) {
  847. alert(r);
  848. });
  849. })
  850. },
  851. verification:function(){
  852. if(vm.orderProcessRecord.isCustomsSend != 1){
  853. alert("请等待清关完成");
  854. return ;
  855. }
  856. confirm('确认核销吗?', function () {
  857. $.ajax({
  858. type: "POST",
  859. url: "../order/printMsgAndChangeCode",
  860. contentType: "application/json",
  861. data: JSON.stringify({'id':vm.currentOrderNo,'sessionId':vm.sessionId}),
  862. success: function (r) {
  863. if (r.ticket != null) {
  864. // printArea(r.ticket);
  865. var content = getPrintContentOrder(r.ticket);
  866. printArea(content);
  867. }else{
  868. alert("打印小票失败");
  869. }
  870. }
  871. });
  872. })
  873. },
  874. refundOrder:function(){
  875. confirm('确认退款吗?', function () {
  876. $.ajax({
  877. type: "POST",
  878. url: "../order/orderRefund",
  879. contentType: "application/json",
  880. data: JSON.stringify({'orderId':vm.currentOrderNo,'sessionId':vm.sessionId}),
  881. success: function (r) {
  882. if (r.code == 0) {
  883. alert("退款成功")
  884. }else{
  885. alert("退款失败,请联系管理员");
  886. }
  887. }
  888. });
  889. })
  890. },
  891. retrySendOrder:function(){
  892. },
  893. getInfo: function (id) {
  894. $.get("../sys/notice/info/" + id, function (r) {
  895. vm.sysNotice = r.sysNotice;
  896. });
  897. },
  898. reload: function (event) {
  899. vm.showList = false;
  900. vm.showViewList = true;
  901. vm.showSaveSupplierGoods = true;
  902. var page = $("#jqGrid").jqGrid('getGridParam', 'page');
  903. $("#jqGrid").jqGrid('setGridParam', {
  904. postData: {
  905. storeId: vm.q.storeId,
  906. goodsName: vm.q.goodsName,
  907. goodsSn: vm.q.goodsSn,
  908. productSn: vm.q.productSn, category: vm.q.category, categoryTwo: vm.q.categoryTwo, goodsBizType:vm.q.goodsBizType,
  909. thirdPartyMerchCode: vm.q.thirdPartyMerchCode
  910. },
  911. page: page
  912. }).trigger("reloadGrid");
  913. vm.handleReset('formValidate');
  914. },
  915. handleSubmit: function (name) {
  916. handleSubmitValidate(this, name, function () {
  917. vm.saveOrUpdate()
  918. });
  919. },
  920. handleReset: function (name) {
  921. handleResetForm(this, name);
  922. },
  923. logout: function () {
  924. confirm('注:您确定要安全退出本次登录吗?', function () {
  925. dialogLoading(true);
  926. setTimeout(function () {
  927. toUrl('../logout?_' + $.now());
  928. }, 500);
  929. });
  930. }
  931. }
  932. });
  933. function getPrintContent(ticket) {
  934. var content = "<div style=\"width: 250px;font-family: 微软雅黑;font-size: 15px;\">";
  935. // // 打印ogo
  936. // content += "<div style=\"text-align: center;width: 100%;height: 50px;\">";
  937. // // content += "<img src='./../../statics/img/cw_logo.png' />";
  938. // // content += "2222222222";
  939. // content += "<img src='/statics/img/cw_logo.png' style='width: 100%;height: 100%;' />";
  940. // content += "</div>";
  941. //小票头
  942. content += "<div style=\"text-align: center;width: 100%;font-weight:bold;font-size: 15px;\">";
  943. content += ticket.shopName
  944. content += "</div>";
  945. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  946. content += "<div style=\"width: 100%;margin:5px 0px;\">";
  947. /*content += "收银机号:" + ticket.salesNo;
  948. content += "</div>";
  949. content += "<div style=\"width: 100%;\">";*/
  950. content += "收银员:" + ticket.userName;
  951. content += "</div>";
  952. content += "<div style=\"width: 100%;font-size: 30px;margin:15px 0 10px 5px;\">";
  953. content += "取货码:" + ticket.code;
  954. content += "</div>";
  955. content += "<div style=\"width: 100%;margin:5px 0px;\">";
  956. content += "订单编号:" + ticket.orderNo;
  957. content += "</div>";
  958. content += "<div style=\"width: 100%;margin:5px 0px;\">";
  959. content += "打印日期:" + ticket.time;
  960. content += "</div>";
  961. content += "<div style=\"width: 100%;margin:5px 0px;font-size: 13px;\">";
  962. content += "该取货单号只有当天有效"
  963. content += "</div>";
  964. content += "</div>";
  965. return content;
  966. }
  967. var printAreaCount = 0;
  968. function printArea(content) {
  969. var idPrefix = "printArea_";
  970. removePrintArea(idPrefix + printAreaCount);
  971. ++printAreaCount;
  972. var iframeId = idPrefix + printAreaCount;
  973. var iframeStyle = 'width:0px;height:0px;left:0px;top:0px;';
  974. iframe = document.createElement('IFRAME');
  975. $(iframe).attr({
  976. style: iframeStyle,
  977. id: iframeId
  978. });
  979. document.body.appendChild(iframe);
  980. var doc = iframe.contentWindow.document;
  981. // doc.open();
  982. doc.write('<div class="">' + content
  983. + '</div>');
  984. doc.close();
  985. var frameWindow = iframe.contentWindow;
  986. frameWindow.focus();
  987. frameWindow.print();
  988. frameWindow.print();
  989. alert('打印小票完成');
  990. /*if(!vm.firstPrint){
  991. setTimeout(function() {
  992. // frameWindow.close();
  993. frameWindow.focus();
  994. frameWindow.print();
  995. frameWindow.print();
  996. alert('打印小票完成');
  997. },250);
  998. vm.firstPrint = true;
  999. }else{
  1000. // frameWindow.close();
  1001. frameWindow.focus();
  1002. frameWindow.print();
  1003. frameWindow.print();
  1004. alert('打印小票完成');
  1005. }*/
  1006. }
  1007. function printArea2(content) {
  1008. var idPrefix = "printArea_";
  1009. removePrintArea(idPrefix + printAreaCount);
  1010. printAreaCount++;
  1011. var iframeId = idPrefix + printAreaCount;
  1012. var iframeStyle = 'width:0px;height:0px;left:0px;top:0px;';
  1013. iframe = document.createElement('IFRAME');
  1014. $(iframe).attr({
  1015. style: iframeStyle,
  1016. id: iframeId
  1017. });
  1018. document.body.appendChild(iframe);
  1019. var doc = iframe.contentWindow.document;
  1020. doc.open();
  1021. doc.write('<div class="">' + content
  1022. + '</div>');
  1023. doc.close();
  1024. var frameWindow = iframe.contentWindow;
  1025. frameWindow.focus();
  1026. frameWindow.print();
  1027. frameWindow.print();
  1028. frameWindow.close();
  1029. }
  1030. var removePrintArea = function (id) {
  1031. $("iframe#" + id).remove();
  1032. };
  1033. var webSocket;
  1034. function openWebSocket() {
  1035. var storeId = sessionStorage.getItem("storeId");
  1036. if ("WebSocket" in window) {
  1037. console.log("当前浏览器支持WebSocket");
  1038. //实现化WebSocket对象
  1039. //指定要连接的服务器地址与端口建立连接
  1040. //注意ws、wss使用不同的端口。我使用自签名的证书测试,
  1041. //无法使用wss,浏览器打开WebSocket时报错
  1042. //ws对应http、wss对应https。
  1043. // webSocket = new WebSocket("ws://183.62.225.124:8080/ws/server/"+storeId);
  1044. // webSocket = new WebSocket("ws://127.0.0.1:8080//ws/server/"+storeId);
  1045. webSocket = new WebSocket("wss://cb.k1net.cn/ws/server/"+storeId);
  1046. if (webSocket.readyState === webSocket.CONNECTING) {
  1047. console.log('1.连接正在打开......');
  1048. }
  1049. // ---------- WebSocket 对象注册事件 ----------
  1050. //连接打开事件
  1051. webSocket.onopen = function () {
  1052. if (webSocket.readyState === webSocket.OPEN) {
  1053. console.log('2.连接已打开');
  1054. }
  1055. console.log('2.向服务端发送测试消息......');
  1056. // webSocket.send("2.client发测试消息:Client sent test msg。");
  1057. };
  1058. //收到消息事件
  1059. webSocket.onmessage = function (msg) {
  1060. var data = Object.assign({}, JSON.parse(msg.data));
  1061. console.log('3.接收到服务端信息......data:'+data);
  1062. vm.sessionId = data.sessionId;
  1063. vm.pickUpCodeList = [];
  1064. if(data.pickUpCodeList.length > 0){
  1065. for(var i = 0 ; i < data.pickUpCodeList.length ; i++){
  1066. console.log(data.pickUpCodeList[i].storeId);
  1067. if(data.pickUpCodeList[i].storeId === storeId){
  1068. vm.pickUpCodeList.push(data.pickUpCodeList[i]);
  1069. }
  1070. }
  1071. }
  1072. // vm.pickUpCodeList = vm.pickUpCodeList.concat(data.pickUpCodeList);
  1073. // console.log(vm.pickUpCodeList);
  1074. // webSocket.send("2.client发测试消息:Client sent test msg。");
  1075. };
  1076. //连接关闭事件
  1077. webSocket.onclose = function () {
  1078. if (!webSocket) {
  1079. console.log('4.Socket连接已关闭');
  1080. }
  1081. };
  1082. //发生了错误事件
  1083. webSocket.onerror = function () {
  1084. console.log("5.Socket发生了错误");
  1085. }
  1086. } else {
  1087. console.log("当前浏览器不支持WebSocket");
  1088. return false;
  1089. }
  1090. }
  1091. function sendMessage() {
  1092. if(webSocket && webSocket.readyState === webSocket.OPEN) {
  1093. webSocket.send("client manual send message.")
  1094. } else {
  1095. console.log('6.未创建WebSocket连接');
  1096. }
  1097. }
  1098. function closeWebSocket() {
  1099. if (webSocket != null) {
  1100. webSocket.close();
  1101. webSocket = null;
  1102. }
  1103. console.log("关闭WebSocket");
  1104. }
  1105. //窗口关闭时,关闭连接
  1106. window.unload = function () {
  1107. webSocket.close();
  1108. };
  1109. function parsedate(value){
  1110. var date = new Date(value);
  1111. var year = date.getFullYear();
  1112. var month = date.getMonth()+1; //月份+1
  1113. var day = date.getDate();
  1114. var hour = date.getHours();
  1115. var minutes = date.getMinutes();
  1116. var second = date.getSeconds();
  1117. return year+"-"+month+"-"+day+" "+hour+":"+minutes +":"+second;
  1118. }
  1119. function getPrintContentOrder(ticket) {
  1120. var content = "<div style=\"width: 250px;font-family: 微软雅黑;font-size: 8px;\">";
  1121. // 打印ogo
  1122. content += "<div style=\"text-align: center;width: 100%;height: 260px;\">";
  1123. content += "<img src='/statics/img/cw_logo2.png' style='width: 100%;height: 100%;' />";
  1124. content += "</div>";
  1125. //小票头
  1126. content += "<div style=\"text-align: center;width: 100%;font-weight:bold;font-size: 13px;\">";
  1127. content += ticket.ticketHead.title;
  1128. content += "</div>";
  1129. /*content += "<div style=\"width: 100%;\">";
  1130. content += "会员:" + ticket.ticketHead.memberId;
  1131. content += "</div>";*/
  1132. content += "<div style=\"width: 100%;font-size: 25px;\">";
  1133. content += "取货码:" + vm.pickUpCode;
  1134. content += "</div>";
  1135. content += "<div style=\"width: 100%;\">";
  1136. content += "订单号:" + ticket.ticketHead.orderId;
  1137. content += "</div>";
  1138. content += "<div style=\"width: 100%;\">";
  1139. content += "交易时间:" + ticket.ticketHead.tradeTime;
  1140. content += "</div>";
  1141. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  1142. //商品信息
  1143. content += "<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  1144. content += "<tr>";
  1145. content += "<td style=\"width: 40%;text-align: left;font-size: 10px;font-weight: bold;\">商品名称</td>";
  1146. content += "<td style=\"width: 17%;text-align: right;font-size: 10px;font-weight: bold;\">单价</td>";
  1147. content += "<td style=\"width: 17%;text-align: right;font-size: 10px;font-weight: bold;\">优惠</td>";
  1148. // content += "<td style=\"width: 16%;text-align: right;font-size: 10px;font-weight: bold;\">税费</td>";
  1149. content += "<td style=\"width: 15%;text-align: right;font-size: 10px;font-weight: bold;\">数量</td>";
  1150. content += "<td style=\"width: 18%;text-align: right;font-size: 10px;font-weight: bold;\">小计</td>";
  1151. content += "</tr>";
  1152. content += "</table>";
  1153. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  1154. content += "<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  1155. for (var i=0;i< ticket.goods.length;i++){
  1156. content += "<tr>";
  1157. content += "<td style=\"width: 40%;text-align: left;font-size: 8px;padding-top: 8px;\">";
  1158. content += "<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  1159. content += "<tr>";
  1160. content += "<td style=\"text-align: left;font-size: 8px;vertical-align:top;\">#</td>";
  1161. content += "<td style=\"text-align: left;font-size: 8px;\">" + ticket.goods[i].gname + "</td>";
  1162. content += "</tr>";
  1163. content += "</table>";
  1164. content += "</td>";
  1165. content += "<td style=\"width: 17%;text-align: right;font-size: 8px;vertical-align:bottom;padding-top: 8px;\">" + ticket.goods[i].uprice + "</td>";
  1166. content += "<td style=\"width: 17%;text-align: right;font-size: 8px;vertical-align:bottom;padding-top: 8px;\">" + ticket.goods[i].discountPrice + "</td>";
  1167. // content += "<td style=\"width: 17%;text-align: right;font-size: 8px;vertical-align:bottom;padding-top: 8px;\">" + ticket.goods[i].taxation + "</td>";
  1168. content += "<td style=\"width: 15%;text-align: center;font-size: 8px;vertical-align:bottom;padding-top: 8px;\">" + ticket.goods[i].num + "</td>";
  1169. content += "<td style=\"width: 18%;text-align: right;font-size: 8px;vertical-align:bottom;padding-top: 8px;\">" + ticket.goods[i].subtotal + "</td>";
  1170. content += "</tr>";
  1171. }
  1172. content += "</table>";
  1173. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  1174. //收银信息
  1175. content += "<div style=\"width: 100%;\">";
  1176. content += "<span style=\"float: left;width: 50%;text-align: left;\">商品合计:</span>";
  1177. content += "<span style=\"float: left;width: 17%;text-align: left;\">" + ticket.cashInfo.goodsTotal + "件</span>";
  1178. content += "<span style=\"float: right;width: 33%;text-align: right;\">" + ticket.cashInfo.total + "元</span>";
  1179. content += "</div>";
  1180. content += "<div style=\"width: 100%;\">";
  1181. content += "<span style=\"float: left;width: 50%;text-align: left;\">税费合计:</span>";
  1182. content += "<span style=\"float: left;width: 17%;text-align: left;\">" + ticket.cashInfo.goodsTotal + "件</span>";
  1183. content += "<span style=\"float: right;width: 33%;text-align: right;\">" + ticket.cashInfo.taxTotal + "元</span>";
  1184. content += "</div>";
  1185. content += "<div style=\"width: 100%;\">";
  1186. content += "<span style=\"float: left;width: 50%;text-align: left;\">优惠合计:</span>";
  1187. content += "<span style=\"float: right;width: 50%;text-align: right;\">" + ticket.cashInfo.oddChange + "元</span>";
  1188. content += "</div>";
  1189. content += "<div style=\"width: 100%;\">";
  1190. content += "<span style=\"float: left;width: 50%;text-align: left;\">实收:</span>";
  1191. content += "<span style=\"float: right;width: 50%;text-align: right;\">" + ticket.cashInfo.receipts + "元</span>";
  1192. content += "</div>";
  1193. content += "<div style=\"width: 100%;\">";
  1194. content += "<span style=\"float: left;width: 50%;text-align: left;\">优惠券:</span>";
  1195. content += "<span style=\"float: right;width: 50%;text-align: right;\">" + ticket.cashInfo.coupon + "元</span>";
  1196. content += "</div>";
  1197. // content += "<div style=\"width: 100%;\">";
  1198. // content += "<span style=\"float: left;width: 50%;text-align: left;\">运费:</span>";
  1199. // content += "<span style=\"float: right;width: 50%;text-align: right;\">" + ticket.cashInfo.freight + "元</span>";
  1200. // content += "</div>";
  1201. content += "<div style=\"width: 100%;\">";
  1202. content += "<span style=\"float: left;width: 50%;text-align: left;\">支付渠道:</span>";
  1203. // 后期改成从系统中取
  1204. content += "<span style=\"float: right;width: 50%;text-align: right;\">" + "支付宝支付" + "</span>";
  1205. content += "</div>";
  1206. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  1207. //海关清单信息
  1208. content += "<div style=\"width: 100%;\">";
  1209. content += "订单号:" + ticket.cusListing.orderId;
  1210. content += "</div>";
  1211. content += "<div style=\"width: 100%;\">";
  1212. content += "运单编号:" + ticket.cusListing.waybillId;
  1213. content += "</div>";
  1214. content += "<div style=\"width: 100%;\">";
  1215. content += "海关清单号:" + ticket.cusListing.invtNo;
  1216. content += "</div>";
  1217. content += "<div style=\"width: 100%;\">";
  1218. content += "收货人:" + ticket.cusListing.consignee;
  1219. content += "</div>";
  1220. content += "<div style=\"width: 100%;\">";
  1221. content += "收货人电话:" + ticket.cusListing.consigneeTel;
  1222. content += "</div>";
  1223. content += "<div style=\"width: 100%;\">";
  1224. content += "始发地: 仓库地址 : 广东省深圳市南山区前海保税港区W104" ;
  1225. content += "</div>";
  1226. content += "<div style=\"width: 100%;\">";
  1227. content += "交货地:" + ticket.cusListing.deliveryAddress;
  1228. content += "</div>";
  1229. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  1230. content += "<div style=\"width: 100%;text-align: center;\">";
  1231. content += "购买跨境商品须知:"
  1232. content += "</div>";
  1233. content += "<div style=\"width: 100%;\">";
  1234. content += "1、凡购买跨境商品均不提供发票;<br> 2、单笔限购5000元,年交易限额2.6万元; <br> 3、所有订单经海关放行后方可提货; <br> 4、凭小票领取您的订单商品; <br> 5、非产品质量问题,跨境商品不支持无理由退换货,请及时检查。 "
  1235. content += "</div>";
  1236. content += "<div style=\"width: 100%;overflow:hidden;white-space: nowrap;\">--------------------------------------------------</div>";
  1237. content += "<div style=\"width: 100%;\">";
  1238. // content += ticket.ticketFoot.summary;
  1239. content += "</div>";
  1240. content += "<div style=\"width: 100%;\">";
  1241. // content += "客服电话:" + ticket.ticketFoot.serviceTel;
  1242. content += "</div>";
  1243. content += "<div style=\"width: 100%;\">";
  1244. // content += "网址:" + ticket.ticketFoot.url1;
  1245. content += "</div>";
  1246. content += "<div style=\"width: 100%;\">";
  1247. content += ticket.ticketFoot.welcome;
  1248. content += "</div>";
  1249. content += "<div style=\"width: 100%;\">";
  1250. content += "惠州市惠城区港惠购物中心负一层";
  1251. content += "</div>";
  1252. content += "<div style=\"width: 100%;\">";
  1253. content += "请保管好收银小票。";
  1254. content += "</div>";
  1255. // 打印二维码
  1256. content += "<div style=\"text-align: center;width: 100%;height: 250px;\">";
  1257. content += "<img src='/statics/img/cw_qrcode.png' style='width: 100%;height: 100%;' />";
  1258. content += "</div>";
  1259. content += "<div style=\"width: 100%;text-align: center;\">";
  1260. content += "关注CW大药房客服号,获取更多优惠信息"
  1261. content += "</div>";
  1262. return content;
  1263. }
  1264. function queryAssistantInfo(){
  1265. $.get("../sys/user/info", function (r) {
  1266. if(r.code == 0){
  1267. vm.sysUserInfo = r.user;
  1268. $.get("../store/getStoresByMerch?merchSn="+r.user.merchSn+"&_=1590374349985",function(result){
  1269. if(result.code == 0){
  1270. for(var i = 0 ;i < result.list.length; i++){
  1271. if(result.list[i].id == r.user.storeId){
  1272. vm.storeName = result.list[i].storeName;
  1273. break;
  1274. }
  1275. }
  1276. }
  1277. });
  1278. }
  1279. });
  1280. }
  1281. function removeByValue(arr, val) {
  1282. var index = arr.indexOf(val);
  1283. if (index > -1) {
  1284. arr.splice(index, 1);
  1285. }
  1286. }
  1287. function handle(goodsDetails,operatorType){
  1288. vm.goodsDetail = true;
  1289. // goodsDetails.sellVolume = 1;
  1290. goodsDetails.id = vm.index;
  1291. if(!vm.goodsList[vm.index]){
  1292. vm.index = vm.max;
  1293. }
  1294. vm.max++;
  1295. goodsDetails.goodsDesc = "";
  1296. // 判断当前商品是否是赠品
  1297. var freeMap = vm.freeBardcode.get(goodsDetails.prodBarcode);
  1298. if(freeMap && "minus" != operatorType){
  1299. goodsDetails.actualPaymentAmount = 0;
  1300. goodsDetails.discountedPrice = goodsDetails.retailPrice;
  1301. vm.freeBardcode.set(goodsDetails.prodBarcode,freeMap - 1);
  1302. }else{
  1303. if(!freeMap && freeMap != 0 ){
  1304. // 判断购物车中是否有赠品 这个操作只有是非赠品才能进来
  1305. for(var i = 0 ; i < vm.goodsList.length ; i++){
  1306. var shopcartGoods = vm.goodsList[i];
  1307. var shopcartFree = vm.freeBardcode.get(shopcartGoods.prodBarcode);
  1308. if(shopcartFree /*&& shopcartGoods.actualPaymentAmount*/){
  1309. // if("minus" != operatorType){
  1310. var shopcartSellNum = shopcartGoods.sellVolume;
  1311. if(shopcartFree > shopcartSellNum){
  1312. shopcartGoods.actualPaymentAmount = 0;
  1313. shopcartGoods.discountedPrice = shopcartGoods.retailPrice * shopcartFree;
  1314. vm.discountedPrice = vm.discountedPrice + shopcartGoods.discountedPrice ;
  1315. vm.actualPrice = vm.actualPrice + shopcartGoods.actualPaymentAmount ;
  1316. vm.freeBardcode.set(shopcartGoods.prodBarcode,shopcartFree - 1);//
  1317. }else if(shopcartFree == -1 ){
  1318. // g.actualPaymentAmount == 0){
  1319. shopcartGoods.actualPaymentAmount = shopcartGoods.retailPrice + shopcartGoods.actualPaymentAmount;
  1320. shopcartGoods.discountedPrice = shopcartGoods.discountedPrice - shopcartGoods.retailPrice;
  1321. vm.discountedPrice = vm.discountedPrice + shopcartGoods.discountedPrice ;
  1322. vm.actualPrice = vm.actualPrice + shopcartGoods.actualPaymentAmount ;
  1323. vm.freeBardcode.set(shopcartGoods.prodBarcode,0);// 重置回0
  1324. }else{
  1325. if(shopcartGoods.actualPaymentAmount > 0){
  1326. shopcartGoods.actualPaymentAmount = shopcartGoods.actualPaymentAmount - (shopcartGoods.retailPrice * shopcartFree);
  1327. shopcartGoods.discountedPrice = shopcartGoods.discountedPrice + (shopcartGoods.retailPrice * shopcartFree);
  1328. vm.actualPrice = vm.actualPrice - (shopcartGoods.retailPrice * shopcartFree) ;
  1329. vm.discountedPrice = vm.discountedPrice + (shopcartGoods.retailPrice * shopcartFree) ;
  1330. vm.freeBardcode.set(shopcartGoods.prodBarcode, shopcartFree - 1);// 重置回0
  1331. }
  1332. }
  1333. // }
  1334. }
  1335. }
  1336. }
  1337. }
  1338. goodsDetails.discountedPrice = Math.round(goodsDetails.discountedPrice * 100) / 100;
  1339. goodsDetails.actualPaymentAmount = Math.round(goodsDetails.actualPaymentAmount * 100) / 100;
  1340. var data = Object.assign({}, JSON.parse(JSON.stringify(goodsDetails)));
  1341. var isPush = true;
  1342. // 判断当前商品是否添加过
  1343. for(var i = 0 ; i < vm.goodsList.length ; i++){
  1344. if(vm.goodsList[i].goodsSn == data.goodsSn){
  1345. var goodsDetails = vm.goodsList[i];
  1346. if(data.actualPaymentAmount < 0 && goodsDetails.actualPaymentAmount == 0){
  1347. // goodsDetails.goodstaxes = Math.round((parseFloat(goodsDetails.goodstaxes) - parseFloat(data.goodstaxes)) * 100)/100;
  1348. // goodsDetails.discountedPrice = Math.round((parseFloat(goodsDetails.discountedPrice) - parseFloat(data.discountedPrice)) * 100)/100;
  1349. goodsDetails.actualPaymentAmount = 0;
  1350. }else{
  1351. // 税 goodstaxes,优惠金额 discountedPrice,实际支付 actualPaymentAmount,数量 sellVolume 45636917
  1352. goodsDetails.actualPaymentAmount = Math.round((parseFloat(goodsDetails.actualPaymentAmount) + parseFloat(data.actualPaymentAmount)) * 100)/100;
  1353. }
  1354. goodsDetails.discountedPrice = Math.round((parseFloat(goodsDetails.discountedPrice) + parseFloat(data.discountedPrice)) * 100)/100;
  1355. goodsDetails.goodstaxes = Math.round((parseFloat(goodsDetails.goodstaxes) + parseFloat(data.goodstaxes)) * 100)/100;
  1356. goodsDetails.sellVolume = Math.round((parseFloat(goodsDetails.sellVolume) + parseFloat(data.sellVolume)) * 100)/100;
  1357. goodsDetails.activity = data.activity;
  1358. isPush = false;
  1359. break;
  1360. }
  1361. }
  1362. // for(var i = 0 ; i < vm.goodsList.length ; i++){
  1363. // if(vm.goodsList[i].goodsSn == data.goodsSn){
  1364. // var goodsDetails = vm.goodsList[i];
  1365. // // 税 goodstaxes,优惠金额 discountedPrice,实际支付 actualPaymentAmount,数量 sellVolume 45636917
  1366. // goodsDetails.goodstaxes = Math.round((parseFloat(goodsDetails.goodstaxes) + parseFloat(data.goodstaxes)) * 100)/100;
  1367. // goodsDetails.discountedPrice = Math.round((parseFloat(goodsDetails.discountedPrice) + parseFloat(data.discountedPrice)) * 100)/100;
  1368. // goodsDetails.actualPaymentAmount = Math.round((parseFloat(goodsDetails.actualPaymentAmount) + parseFloat(data.actualPaymentAmount)) * 100)/100;
  1369. // goodsDetails.sellVolume = Math.round((parseFloat(goodsDetails.sellVolume) + parseFloat(data.sellVolume)) * 100)/100;
  1370. // goodsDetails.activity = data.activity;
  1371. // isPush = false;
  1372. // break;
  1373. // }
  1374. // }
  1375. if(isPush){
  1376. vm.goodsList.push(data);
  1377. vm.index = vm.index + 1;
  1378. }
  1379. vm.totalPrice = (vm.totalPrice + data.retailPrice);
  1380. if("minus" == operatorType){
  1381. vm.totalCount = vm.totalCount - 1;
  1382. }else{
  1383. vm.totalCount = vm.totalCount + 1;
  1384. }
  1385. if(vm.reduceMoney > 0){
  1386. vm.discountedPrice = vm.discountedPrice + data.discountedPrice + vm.reduceMoney;
  1387. vm.actualPrice = vm.actualPrice + data.actualPaymentAmount - vm.reduceMoney;
  1388. vm.showReduceMoney = vm.showReduceMoney + vm.reduceMoney;
  1389. vm.reduceMoney = 0;
  1390. }else{
  1391. vm.discountedPrice = vm.discountedPrice + data.discountedPrice ;
  1392. vm.actualPrice = vm.actualPrice + data.actualPaymentAmount ;
  1393. }
  1394. if(data.sellVolume < 0){
  1395. data.sellVolume = - data.sellVolume;
  1396. data.retailPrice = - data.retailPrice;
  1397. data.goodstaxes = -data.goodstaxes;
  1398. }
  1399. vm.goods = data;
  1400. // 处理精度
  1401. vm.totalPrice = Math.round(vm.totalPrice * 100) / 100;
  1402. vm.discountedPrice = Math.round(vm.discountedPrice * 100) / 100;
  1403. vm.actualPrice = Math.round(vm.actualPrice * 100) / 100;
  1404. vm.showReduceMoney = Math.round(vm.showReduceMoney * 100) / 100;
  1405. }
  1406. function toPayOrder(payCode){
  1407. $('#payCode').unbind('keydown').keydown(function(event){});
  1408. vm.machineCode = sessionStorage.getItem("machineCode");
  1409. console.log(vm.machineCode);
  1410. var param = {'userInfo':vm.userInfo,'payCode':vm.parCode,'goodsList':vm.goodsList,'sessionId':vm.sessionId,'machineCode':vm.machineCode};
  1411. console.log(JSON.stringify(param));
  1412. vm.parCode = "";
  1413. $.ajax({
  1414. type: "POST",
  1415. url: "../order/orderConfirm",
  1416. contentType: "application/json",
  1417. data: JSON.stringify(param),
  1418. success: function (r) {
  1419. console.log(r);
  1420. if (r.code == 0) {
  1421. if (r.resultObj != null) {
  1422. $(".form-group input[type=text]").each(function(){
  1423. this.value = '';
  1424. })
  1425. // 打印取货码小票
  1426. var content = getPrintContent(r.resultObj);
  1427. console.log(content);
  1428. printArea2(content);
  1429. vm.goodsList = [];
  1430. vm.customname = '' ;
  1431. vm.customidcard = '';
  1432. vm.customClearData();
  1433. }else{
  1434. // alert("打印小票失败");
  1435. }
  1436. } else {
  1437. alert(r.msg);
  1438. }
  1439. }
  1440. });
  1441. }