cartList_body.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <!DOCTYPE html>
  2. <html class="">
  3. <!--STATUS OK-->
  4. <head>
  5. <meta name="referrer" content="always" />
  6. <meta charset='utf-8' />
  7. <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  8. <meta http-equiv="x-dns-prefetch-control" content="on">
  9. <meta name="description" content="">
  10. <meta name="format-detection" content="telephone=no" />
  11. <link rel="stylesheet" type="text/css" href="css/vant-ui.css" />
  12. <link rel="stylesheet" type="text/css" href="css/iconfont.css">
  13. <link rel="stylesheet" type="text/css" href="css/main.css" />
  14. <script src="js/vue.js"></script>
  15. <script src="js/vant-ui.js"></script>
  16. <script src="js/main.js"></script>
  17. <title></title>
  18. </head>
  19. <style>
  20. .zmq-flex {
  21. display: flex;
  22. position: fixed;
  23. width: 100%;
  24. height: 1rem;
  25. background-color: #fff;
  26. left: 0;
  27. bottom: 0;
  28. z-index: 2222;
  29. justify-content: space-between;
  30. padding-left: .2rem;
  31. }
  32. .allcheck {
  33. font-size: .3rem;
  34. line-height: 1rem;
  35. margin-left: -2.8rem;
  36. }
  37. .zmq-price {
  38. }
  39. .zmq-downOrder {
  40. width: 2rem;
  41. height: 1rem;
  42. background-color: #005AA9;
  43. color: #fff;
  44. float: right;
  45. line-height: 1rem;
  46. text-align: center;
  47. font-size: .3rem;
  48. }
  49. </style>
  50. <body>
  51. <div id="app" v-cloak>
  52. <div class="pageView gouwuche">
  53. <div class="gouwucheBackground" style="padding-bottom:.5rem">
  54. <div class="cardGouwuche" v-show="list.length > 0">
  55. <div class="item flex jlr a-center" v-for="(item,index) in list">
  56. <van-checkbox v-model="item.checked" style="z-index : 2222" v-on:change="getTotalMoney"></van-checkbox>
  57. <div class="flex jlr a-center" style="flex: 1; padding-left: 0.3rem;">
  58. <div class="image"><img src="img/tire.png">
  59. </div>
  60. <div class="infos flex col jlr">
  61. <div class="flex a-center jlr">
  62. <h2>{{ item.maktx }}</h2>
  63. <van-icon name="delete" size="0.3rem" v-on:click="delCarMatax(item.id)"></van-icon>
  64. </div>
  65. <div class="setp flex jlr">
  66. <div class="left flex a-center j-center" v-on:click="minusSign(index,0)">
  67. -
  68. </div>
  69. <div class="value flex a-center j-center">
  70. {{item.purchaseNumber ? item.purchaseNumber : 0}}
  71. </div>
  72. <div class="right flex a-center j-center" v-on:click="minusSign(index,1)">
  73. +
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. <!-- <div class="cardFooter flex a-center jlr">
  80. <h4>优惠劵</h4>
  81. <div class="flex a-center gouwuquan">
  82. 20元优惠卷 <i class="iconfont icon-right"></i>
  83. </div>
  84. </div>-->
  85. </div>
  86. <div v-show="list.length == 0" style="text-align:center">
  87. <img src="./image/noData.png" style="margin:2rem auto" />
  88. </div>
  89. </div>
  90. </div>
  91. <!-- 购物车 价格全选 -->
  92. <div class="zmq-flex">
  93. <van-checkbox v-model="allCheck" v-on:click="changeAllCheck"></van-checkbox>
  94. <p class="allcheck">
  95. 全选
  96. </p>
  97. <div style="display: flex;line-height: 1rem;padding-left: .1rem">
  98. <div class="zmq-downOrder" v-on:click="downOrder">
  99. 立即下单
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </body>
  105. <script type="text/javascript" src="../script/api.js"></script>
  106. <script type="text/javascript" src="../script/httpRequest.js"></script>
  107. <script type="text/javascript" src="../script/vue_plugins.js"></script>
  108. <script type="text/javascript">
  109. apiready = function() {
  110. new Vue({
  111. el : '#app',
  112. data : {
  113. list : [],
  114. startTimeShow : false,
  115. startCurrentDate : new Date(),
  116. cartList : [], // 购物车详情
  117. allCheck : false, // 全选
  118. totalCount : 0, // 总价
  119. checked : false,
  120. },
  121. watch : {
  122. // "allCheck" : function(nw, ow) {
  123. // if (nw == false) {
  124. // this.list.map(function(cart, index) {
  125. // cart.checked = false;
  126. // })
  127. // this.totalCount = 0;
  128. // } else {
  129. // this.list.map(function(cart, index) {
  130. // cart.checked = true;
  131. // })
  132. // }
  133. // },
  134. },
  135. methods : {
  136. init : function() {
  137. this.userId = $api.getStorage('userid');
  138. this.status = $api.getStorage('status');
  139. this.getCarList();
  140. },
  141. // 获取购物车列表
  142. getCarList : function() {
  143. var url = "getCarListU", _this = this, data = {
  144. "storeId" : this.userId,
  145. "url" : "json",
  146. "type" : "body"
  147. };
  148. this.$post(url, data, function(ret) {
  149. if (ret.code == 0 || ret.code == '0') {
  150. ret.data.map(function(store,index){
  151. store.checked = false;
  152. })
  153. _this.list = ret.data;
  154. }
  155. })
  156. },
  157. // 控制数量
  158. minusSign : function(index, type) {
  159. var number = this.list[index].purchaseNumber ? this.list[index].purchaseNumber : 0;
  160. if (type == 0) {
  161. // -
  162. if (number > 1) {
  163. this.$set(this.list[index], "purchaseNumber", (parseInt(number) - 1));
  164. }else{
  165. this.list[index].purchaseNumber=1;
  166. this.showToast("最少购买1件")
  167. }
  168. } else {
  169. this.$set(this.list[index], "purchaseNumber", (parseInt(number) + 1));
  170. }
  171. this.getTotalMoney();
  172. var data = {
  173. "url": "json",
  174. "type": "body",
  175. "id": this.list[index].id,
  176. "purchaseNumber": this.list[index].purchaseNumber
  177. }
  178. _this = this,
  179. url = "updateCarNum";
  180. this.$post(url, data, function(ret) {})
  181. },
  182. // 下单
  183. downOrder : function() {
  184. var count = 0, price = 0, hasChoose = new Array();
  185. this.list.map(function(cart, index) {
  186. if(cart.checked == true){
  187. price = price + (parseInt(cart.purchaseNumber) ? parseInt(cart.purchaseNumber) : 0) * 1;
  188. count = count + (parseInt(cart.purchaseNumber) ? parseInt(cart.purchaseNumber) : 0);
  189. hasChoose.push({
  190. "id" : cart.id,
  191. "storeId" : cart.storeId,
  192. "purchaseNumber" : cart.purchaseNumber,
  193. "cartType" : cart.cartType,
  194. "kunnr" : cart.kunnr,
  195. "matnr" : cart.matnr,
  196. "maktx" : cart.maktx,
  197. "brand" : cart.brand,
  198. "spec" : cart.spec,
  199. "pattern" : cart.pattern
  200. });
  201. }
  202. })
  203. if(hasChoose.length == 0){
  204. api.toast({msg : '至少选择一件商品'});
  205. return;
  206. }
  207. if(this.status==3){
  208. api.alert({
  209. title: '系统提示',
  210. msg: '门店已冻结,请找相关业务经理解冻!',
  211. }, function (ret, err) {
  212. });
  213. return;
  214. }
  215. var data = {
  216. "retailerId" : this.userId,
  217. "amount" : count,
  218. "orderType" : "0",
  219. "bizCartDtoList" : hasChoose,
  220. "type" : "body",
  221. "url" : "json"
  222. }, _this = this, url = "downOrderU";
  223. this.$post(url, data, function(ret) {
  224. if (ret.code == 0 || ret.code == '0') {
  225. api.toast({
  226. msg : '下单成功'
  227. });
  228. api.sendEvent({
  229. name: 'refushCarList',
  230. });
  231. var msg = {
  232. id : ret.msg
  233. }
  234. _this.getCarList();
  235. setTimeout(function() {
  236. _this.goWin("orderInfo", "orderInfo_win.html", msg);
  237. }, 200);
  238. }
  239. })
  240. },
  241. // 控制购物车对应商品数量
  242. openTimer : function() {
  243. this.startTimeShow = true
  244. },
  245. startConfirm : function(e) {
  246. this.startTimeShow = false
  247. },
  248. /**
  249. * 控制算出购物车的总金额
  250. */
  251. getTotalMoney : function(){
  252. var totalCount = 0;
  253. var isok = true;
  254. this.list.map(function(cart, index) {
  255. if(cart.checked == true){
  256. totalCount = totalCount + (parseInt(cart.purchaseNumber) ? parseInt(cart.purchaseNumber) : 0) * 1;
  257. }else{
  258. isok = false;
  259. }
  260. })
  261. if (isok == true) {
  262. this.allCheck = true;
  263. } else {
  264. this.allCheck = false;
  265. }
  266. this.totalCount = totalCount;
  267. },
  268. /**
  269. * 全选改变
  270. */
  271. changeAllCheck : function(){
  272. if (this.allCheck == false) {
  273. this.list.map(function(cart, index) {
  274. cart.checked = false;
  275. })
  276. this.totalCount = 0;
  277. } else {
  278. this.list.map(function(cart, index) {
  279. cart.checked = true;
  280. })
  281. }
  282. },
  283. /**
  284. * 删除购物车中的物料
  285. */
  286. delCarMatax : function(id){
  287. var url = "delCarMataxU",_this = this;
  288. var data = {
  289. "id":id,
  290. "url" : "json",
  291. "type" : "body"
  292. }
  293. this.$post(url,data,function(ret){
  294. if(ret.code == 0 || ret.code == '0'){
  295. api.toast({
  296. msg: '删除成功',
  297. });
  298. api.sendEvent({
  299. name: 'refushCarList',
  300. });
  301. setTimeout(function(){
  302. _this.getCarList();
  303. },500)
  304. }
  305. })
  306. }
  307. },
  308. filters : {
  309. timer : function(v) {
  310. if (v) {
  311. var y = v.getFullYear()
  312. var m = v.getMonth() + 1
  313. var d = v.getDate()
  314. return y + '-' + m + '-' + d
  315. } else {
  316. return '请选择'
  317. }
  318. }
  319. },
  320. mounted : function() {
  321. this.init();
  322. }
  323. })
  324. }
  325. </script>
  326. </html>