orderCar_body.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
  6. <meta name="apple-mobile-web-app-capable" content="yes" />
  7. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  8. <meta name="format-detection" content="telephone=no" />
  9. <title>购物车</title>
  10. <link rel="stylesheet" type="text/css" href="../../css/shopcar.css">
  11. <link rel="stylesheet" type="text/css" href="../../css/html.css">
  12. <script type="text/javascript" src="../../script/auto-size.js"></script>
  13. <style>
  14. body, html {
  15. padding-bottom: 1rem;
  16. }
  17. .lb {
  18. display: flex;
  19. display: -webkit-flex;
  20. }
  21. .down {
  22. background-color: #007f86 !important;
  23. }
  24. .lb .mid {
  25. width: 70%;
  26. }
  27. .aui-choose {
  28. width: 40px;
  29. height: 40px;
  30. }
  31. .delete, .cancel {
  32. width: 49.68% !important;
  33. margin-left: 1px;
  34. }
  35. .delete {
  36. background-color: #009944 !important;
  37. }
  38. .cancel {
  39. background-color: #b5b6b6 !important;
  40. }
  41. .aui-checkbox-div {
  42. text-align: center;
  43. margin-right: 0px;
  44. margin-top: 0px;
  45. }
  46. .zmq-padding-doneBtn {
  47. margin-top: 8px;
  48. }
  49. .fix_bottom .zjq {
  50. margin-top: 10px;
  51. }
  52. [v-cloak] {
  53. display: none;
  54. }
  55. .zmq-img-nodata {
  56. margin-top: 2rem;
  57. }
  58. .aui-radio, .aui-checkbox {
  59. width: 0.8rem !important;
  60. height: 0.8rem !important;
  61. }
  62. </style>
  63. </head>
  64. <body><!-- v-on:click="lookInfo(item.id)" -->
  65. <div id="app" v-cloak>
  66. <img v-show="shopCarList.length == 0" src="../../image/nodata.png" class="zmq-img-nodata"/>
  67. <div class="lb zmq-width-90 zmq-radius-5 zmq-padding-left-10" v-for="(item,index) in shopCarList">
  68. <img v-lazy ="item.materialDto.simpleImgPath" class="spt" />
  69. <div class="mid">
  70. <p class="name">
  71. {{item.materialDto.materialName}}
  72. </p>
  73. <p class="color zmq-text-msg">
  74. {{item.materialDto.brand}}
  75. </p>
  76. <div class="jj">
  77. <span class="jia" v-on:click.stop="changeNum('-',index,item.amount)">-</span>
  78. <input class="num" v-bind:value="item.amount">
  79. <span class="jian" v-on:click.stop="changeNum('+',index,item.amount)">+</span>
  80. </div>
  81. </div>
  82. <div v-show="edit == true" class="aui-checkbox-div zmq-position-absolute" v-on:click="chooseThis(item.checked,index)">
  83. <span class="aui-checkbox" v-bind:class="item.checked == true ? 'check' : ''" class="check">
  84. <input type="checkbox" class="input_check" checked="checked"/>
  85. <label for="check1"></label>
  86. </span>
  87. </div>
  88. </div>
  89. <div class="fix_bottom" v-if="edit == false">
  90. <div class="zjq zmq-flex zmq-width-70 zmq-flex-end">
  91. <p class="p1 zmq-flex-1 zmq-line-1">
  92. 合计: {{shopCarList.length}} 条记录
  93. </p>
  94. <!--<p class="zmq-flex-1 zmq-line-1">
  95. 总共: <em class="zmq-text-msg">{{totalNum}}</em> 件商品
  96. </p>-->
  97. </div>
  98. <a v-on:click="downOrder"> <em class="zmq-bg-noraml zmq-text-white zmq-float-right zmq-padding-doneBtn zmq-margin-right-10 zmq-radius-5 zmq-position-absolute">生成订单</em> </a>
  99. </div>
  100. <div class="fix_bottom" v-else>
  101. <a id="js" class="delete" v-on:click="deleteCar">删除所选</a>
  102. <a id="js" class="cancel" v-on:click="cancel">取消</a>
  103. </div>
  104. </div>
  105. <script src="../../script/api.js" type="text/javascript"></script>
  106. <script type="text/javascript" src="../../script/vue.js"></script>
  107. <script type="text/javascript" src="../../script/httpRequest.js"></script>
  108. <script type="text/javascript" src="../../script/vue_plugins.js"></script>
  109. <script type="text/javascript" src="../../script/vue-lazyload.js"></script>
  110. <script type="text/javascript">
  111. apiready = function() {
  112. new Vue({
  113. el : '#app',
  114. data : {
  115. // 获取列表
  116. getShopCarUrl : 'shopCarListUrl',
  117. // 购物车列表
  118. shopCarList : [],
  119. retariler_id : '',
  120. // 下单
  121. downOrderUrl : 'downOrderUrl',
  122. // 总件数
  123. totalNum : 10,
  124. // 删除购物车
  125. deleteUrl : 'deleteCars',
  126. // 是否编辑购物和
  127. edit : false,
  128. // 获取购物车类型 1普通订单 0活动订单
  129. tabIndex : 1,
  130. },
  131. methods : {
  132. init : function() {
  133. var _this = this;
  134. this.retariler_id = $api.getStorage("retailerid");
  135. // 点击编辑购物车
  136. this.addEvent("editCar", function(ret) {
  137. _this.edit = !_this.edit;
  138. })
  139. this.getCarM();
  140. this.configHeaderRefush(function() {
  141. _this.getCarM();
  142. })
  143. this.addEvent("refushCar12",function(ret){
  144. _this.tabIndex = ret.value.index;
  145. _this.getCarM();
  146. })
  147. },
  148. // 获取购物车
  149. getCarM : function() {
  150. var _this = this;
  151. var data = "?retailer_id="+ this.retariler_id + '&cart_type=' + this.tabIndex;
  152. this.$getadd(this.getShopCarUrl,data, function(ret) {
  153. if (ret.list.length > 0) {
  154. _this.shopCarList = ret.list;
  155. _this.agentId = ret.list[0].agentId;
  156. var totalNum = 0;
  157. // 循环取出件数
  158. ret.list.map(function(item, index) {
  159. totalNum += item.amount;
  160. })
  161. _this.totalNum = totalNum;
  162. }else{
  163. _this.shopCarList = ret.list;
  164. }
  165. });
  166. },
  167. // 查看详情
  168. lookInfo : function(id) {
  169. if (this.edit == true) {
  170. return;
  171. }
  172. var param = {
  173. id : id
  174. }
  175. this.goWin('storeInfo_win', '../store/storeInfo_win.html', param);
  176. },
  177. // 改变数目
  178. changeNum : function(type, index, amout) {
  179. if (type == '+') {
  180. this.$set(this.shopCarList[index], "amount", amout + 1);
  181. this.totalNum = this.totalNum + 1;
  182. } else {
  183. if (amout > 1) {
  184. this.$set(this.shopCarList[index], "amount", amout - 1);
  185. this.totalNum = this.totalNum - 1;
  186. }
  187. }
  188. },
  189. // 开始下单 {"retailerId":"212","amounr":100,"bizCartDtoList":[{"id":121...},{"id":12..}] 这里把购物车的列表给我}
  190. downOrder : function() {
  191. if(this.shopCarList.length == 0){
  192. api.toast({
  193. msg:'暂无商品'
  194. });
  195. return;
  196. }
  197. var data = {
  198. retailerId : this.retariler_id,
  199. amount : this.totalNum,
  200. bizCartDtoList : this.shopCarList,
  201. // agentId : this.agentId,
  202. orderType : (this.tabIndex == "1" ? 0 : 1),
  203. url : 'json',
  204. type : 'body',
  205. }, url = this.downOrderUrl, _this = this;
  206. this.$post(url, data, function(ret) {
  207. if (ret.code == 0) {
  208. _this.showToast("下单成功");
  209. _this.sendEvent("refushCar");
  210. setTimeout(function() {
  211. _this.totalNum = 0;
  212. _this.getCarM();
  213. }, 200);
  214. }
  215. });
  216. },
  217. // 编辑选择这个商品
  218. chooseThis : function(check, index) {
  219. var checked = check == true ? false : true;
  220. this.$set(this.shopCarList[index], "checked", checked);
  221. },
  222. // 删除购物车记录
  223. deleteCar : function() {
  224. var chooseid = new Array();
  225. this.shopCarList.map(function(item, index) {
  226. if (item.checked == true) {
  227. chooseid.push(item.id);
  228. }
  229. });
  230. if (chooseid.length == 0) {
  231. return;
  232. }
  233. var data = {
  234. id : chooseid,
  235. url : 'json',
  236. type : 'body',
  237. yy : 'keng'
  238. }, url = this.deleteUrl, _this = this;
  239. this.$post(url, data, function(ret) {
  240. if (ret.code == 0) {
  241. _this.showToast("删除购物车记录成功");
  242. _this.sendEvent("refushCar");
  243. setTimeout(function() {
  244. _this.getCarM();
  245. }, 200);
  246. }
  247. });
  248. },
  249. // 取消雄安但
  250. cancel : function() {
  251. this.edit = false;
  252. }
  253. },
  254. mounted : function() {
  255. Vue.use(VueLazyload,{
  256. preLoad: 1.3,
  257. error: '../../image/noimg.png',
  258. loading: '../../image/load.gif',
  259. attempt: 1,
  260. });
  261. this.init();
  262. }
  263. })
  264. }
  265. </script>
  266. </body>
  267. </html>