integral_shop.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  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/api.css" />
  12. <link rel="stylesheet" type="text/css" href="../css/aui-win.css" />
  13. <link rel="stylesheet" type="text/css" href="css/vant-ui.css" />
  14. <link rel="stylesheet" type="text/css" href="css/iconfont.css">
  15. <link rel="stylesheet" type="text/css" href="css/main.css" />
  16. <script type="text/javascript" src="../script/aui-tab.js"></script>
  17. <script src="js/vue.js"></script>
  18. <script src="js/vant-ui.js"></script>
  19. <script src="js/main.js"></script>
  20. <title></title>
  21. </head>
  22. <style>
  23. .box-main {
  24. position: relative;
  25. top: -4rem;
  26. padding-top: .5rem;
  27. }
  28. .card {
  29. display: flex;
  30. justify-content: center;
  31. margin-bottom: 2rem;
  32. }
  33. .card-list {
  34. width: 7rem;
  35. background-color: #fff;
  36. border-radius: .3rem;
  37. display: flex;
  38. flex-direction: column;
  39. }
  40. .card-box {
  41. display: flex;
  42. flex-direction: row;
  43. justify-content: space-between;
  44. border-bottom: 1px solid #F1F1F1;
  45. margin: 0 .2rem;
  46. padding: .2rem 0;
  47. }
  48. .card-box:last-child {
  49. border-bottom: 0px solid #F1F1F1;
  50. }
  51. .card-list-left {
  52. display: flex;
  53. flex-direction: row;
  54. }
  55. .card-check {
  56. display: flex;
  57. align-items: center;
  58. margin: 0 .2rem;
  59. }
  60. .card-img {
  61. margin: .2rem .2rem .2rem .4rem;
  62. }
  63. .card-text {
  64. display: flex;
  65. flex-direction: column;
  66. justify-content: space-between;
  67. margin: .2rem 0;
  68. }
  69. .card-title {
  70. width: 2.5rem;
  71. }
  72. .card-title-p {
  73. font-size: .3rem;
  74. display: -webkit-box;
  75. -webkit-box-orient: vertical;
  76. -webkit-line-clamp: 2;
  77. overflow: hidden;
  78. }
  79. .shop-add-left {
  80. display: flex;
  81. font-size: .28rem;
  82. }
  83. .shop-add-left input {
  84. width: .6rem;
  85. border: 1px solid rgba(229, 229, 229, 1);
  86. text-align: center;
  87. }
  88. .but-sub {
  89. border-top: 1px solid rgba(229, 229, 229, 1);
  90. border-left: 1px solid rgba(229, 229, 229, 1);
  91. border-bottom: 1px solid rgba(229, 229, 229, 1);
  92. width: .45rem;
  93. text-align: center;
  94. border-top-left-radius: .05rem;
  95. border-bottom-left-radius: .05rem;
  96. }
  97. .but-add {
  98. border-top: 1px solid rgba(229, 229, 229, 1);
  99. border-right: 1px solid rgba(229, 229, 229, 1);
  100. border-bottom: 1px solid rgba(229, 229, 229, 1);
  101. width: .45rem;
  102. text-align: center;
  103. border-top-right-radius: .05rem;
  104. border-bottom-right-radius: .05rem;
  105. }
  106. .card-del {
  107. margin: .3rem;
  108. width: .3rem;
  109. height: .3rem;
  110. }
  111. .card-del img {
  112. width: .3rem;
  113. height: .3rem;
  114. }
  115. .settle {
  116. position: absolute;
  117. bottom: 0;
  118. background-color: #fff;
  119. width: 100%
  120. }
  121. .settle-main {
  122. display: flex;
  123. justify-content: space-between;
  124. margin: .15rem 0;
  125. }
  126. .settle-left {
  127. margin: 0 .2rem;
  128. display: flex;
  129. flex-direction: row;
  130. }
  131. .settle-right {
  132. display: flex;
  133. flex-direction: row;
  134. }
  135. .settle-compute {
  136. color: rgba(0, 159, 233, 1);
  137. display: flex;
  138. align-items: center;
  139. margin: 0 .2rem;
  140. }
  141. .settle-button {
  142. display: flex;
  143. justify-content: center;
  144. align-items: center;
  145. background-color: rgba(0, 158, 232, 1);
  146. border-radius: .5rem;
  147. height: .6rem;
  148. width: 2rem;
  149. color: #fff;
  150. margin: 0 .2rem;
  151. }
  152. .color-c2c2c2 {
  153. background-color: #C2C2C2;
  154. }
  155. .settle-check {
  156. display: flex;
  157. align-items: center;
  158. }
  159. .check-text {
  160. margin-left: .2rem;
  161. display: flex;
  162. align-items: center;
  163. color: rgba(102, 102, 102, 1);
  164. }
  165. .buttom-buy {
  166. background-color: #E01212;
  167. color: #ffffff;
  168. display: flex;
  169. justify-content: center;
  170. align-items: center;
  171. border-radius: 1rem;
  172. width: 70%;
  173. height: .7rem;
  174. }
  175. .upwarp-nodata{
  176. display: none !important;
  177. }
  178. .mescroll{
  179. position: relative;
  180. height: 85%;
  181. }
  182. </style>
  183. <body>
  184. <div id="app" style="background-color:#F5F5F5">
  185. <header class="aui-bar aui-bar-nav aui-bar-info" id="aui-header">
  186. <div>
  187. <a class="aui-btn aui-btn-info aui-pull-left" tapmode onclick="closeWin()"> <span class="aui-iconfont aui-icon-left"></span> </a>
  188. <div class="aui-title" id="aui-title">
  189. 购物车
  190. </div>
  191. <div style="display:flex;justify-content:flex-end;font-size:.3rem;align-items:center;margin-right:.2rem;">
  192. <div v-on:click="setEdit" v-show="inEdit">
  193. 编辑
  194. </div>
  195. <div v-on:click="getEdit" v-show="outEdit">
  196. 完成
  197. </div>
  198. </div>
  199. <!-- <div v-on:click="getEdit" v-show="outEdit" style="display:flex;justify-content:flex-end;font-size:.3rem;align-item:center;margin-right:.2rem;">
  200. 完成
  201. </div> -->
  202. </div>
  203. </header>
  204. <div class="banner">
  205. </div>
  206. <div class="box-main mescroll-touch-y mescroll" id="mescroll">
  207. <div class="card-main" >
  208. <div class="card">
  209. <div class="card-list">
  210. <div class="card-box" v-for="(item,index) in Shopcarts" :key="index">
  211. <div class="card-list-left">
  212. <div class="card-check">
  213. <span>
  214. <van-checkbox v-model="item.checked" v-on:change="numCheck(item)"></van-checkbox>
  215. </span>
  216. </div>
  217. <div class="card-img">
  218. <img v-if="item.productImage==null" src="img/nothing.png" style="width:1.8rem;height:1.8rem">
  219. <img v-else :src="item.productImage" style="width:1.8rem;height:1.8rem">
  220. </div>
  221. <div class="card-text">
  222. <div class="card-title">
  223. <p class="card-title-p">{{item.productIntroduction}}</p>
  224. </div>
  225. <div class="shop-add-left">
  226. <van-stepper v-model="item.cartQty" input-width=".6rem" button-size=".4rem" integer min="1" max="999" v-on:change="inputNum(item)" />
  227. <!-- <div class="but-sub" v-on:click="subQuantity(item)">-</div>
  228. <input type="number" v-model="item.cartQty" v-on:input="inputNum(item)" v-on:Blur='outBlur(item)'>
  229. <div class="but-add" v-on:click="addQuantity(item)">+</div> -->
  230. </div>
  231. </div>
  232. </div>
  233. <div class="card-del" v-on:click="delCart(item)">
  234. <img src="./img/images/slices.png" alt="">
  235. </div>
  236. </div>
  237. </div>
  238. </div>
  239. </div>
  240. </div>
  241. <div class="settle">
  242. <div class="settle-main">
  243. <div class="settle-left">
  244. <div class="settle-check">
  245. <van-checkbox v-model="allCheck" v-on:click="changeAllCheck"></van-checkbox>
  246. </div>
  247. <div class="check-text">
  248. 全选
  249. </div>
  250. </div>
  251. <div class="settle-right">
  252. <div class="settle-compute" ref="updateTotal">
  253. 总计: {{totalSumAll}}积分
  254. </div>
  255. <div class="settle-button" v-show="inEdit" v-on:click="showPopup">
  256. 结算
  257. </div>
  258. <div class="settle-button color-c2c2c2" v-show="outEdit" v-on:click="allDelCart()">
  259. 删除
  260. </div>
  261. </div>
  262. </div>
  263. </div>
  264. <van-popup v-model="show" closeable position="bottom" :style="{ height: '40%' }">
  265. <div v-if="addresslist.length!=0" style="margin-top:1rem;height:65%" class="mescroll-touch-y mescroll">
  266. <van-radio-group v-model="radio" v-for="(ab,index) in addresslist" :key="index" style="padding:.2rem .4rem">
  267. <van-radio :name="ab.mainId">
  268. <div>
  269. <div>
  270. {{ab.contactsName}}
  271. </div>
  272. <div style="font-size:.25rem">
  273. {{ab.province}}{{ab.city}}{{ab.county}}{{ab.address}}
  274. </div>
  275. </div>
  276. </van-radio>
  277. </van-radio-group>
  278. </div>
  279. <div v-else>
  280. <div style="display:flex;justify-content:center;margin-top:.8rem;color:#ccc">
  281. 暂无收货地址
  282. </div>
  283. <div style="display:flex;justify-content:center;margin-top:.8rem;color:#00a0ea" v-on:click="goaddress">
  284. 点击去添加
  285. </div>
  286. </div>
  287. <div style="position: fixed;bottom: .2rem;width:100%;display:flex;justify-content:center">
  288. <div class="buttom-buy" v-on:click="addOrder">
  289. 立即下单
  290. </div>
  291. </div>
  292. </van-popup>
  293. </div>
  294. </body>
  295. <link rel="stylesheet" href="./mescroll/mescroll.min.css">
  296. <script type="text/javascript" src="./js/qrcode.min.js"></script>
  297. <script type="text/javascript" src="../script/aui-scroll.js"></script>
  298. <script type="text/javascript" src="./mescroll/mescroll.min.js"></script>
  299. <script type="text/javascript" src="../script/api.js"></script>
  300. <script type="text/javascript" src="../script/httpRequest.js"></script>
  301. <script type="text/javascript" src="../script/vue_plugins.js"></script>
  302. <script type="text/javascript">
  303. function closeWin() {
  304. api.closeWin({});
  305. }
  306. apiready = function() {
  307. api.parseTapmode();
  308. var header = $api.byId('aui-header');
  309. $api.fixStatusBar(header);
  310. new Vue({
  311. el: '#app',
  312. data: {
  313. checkBox: [],
  314. inEdit: true,
  315. outEdit: false,
  316. Shopcarts: [],
  317. total: '',
  318. allCheck: false,
  319. current: 1,
  320. size: 10, // 订单状态 0,新创建,1已接单,2,驳回,3完成 经销商审核 0 待审核 1 同意 2 拒绝
  321. frist: 1,
  322. totalPages: 1,
  323. hasOther : false,
  324. mescroll :'',
  325. show: false,
  326. addresslist: [],
  327. radio: '',
  328. },
  329. methods: {
  330. init: function() {
  331. this.storeId = $api.getStorage('userid');
  332. this.loginId = $api.getStorage('loginid');
  333. this.status = $api.getStorage('status');
  334. this.getShopCart();
  335. var _this = this;
  336. this.addEvent("refreshshop", function() {
  337. _this.getShopCart();
  338. _this.show = false;
  339. });
  340. // this.configDownAndPull("mescroll", function(mescroll) {
  341. // _this.getShopCart(mescroll);
  342. // }, function() {
  343. //
  344. // }, false);
  345. },
  346. configs: function() {
  347. var _this = this;
  348. this.frist = 2;
  349. this.configDownAndPull("mescroll", function(mescroll) {
  350. _this.mescroll = mescroll;
  351. _this.current = 1;
  352. _this.getShopCart(mescroll);
  353. }, function(mescroll) {
  354. if (_this.current < _this.totalPages) {
  355. _this.current = _this.current + 1;
  356. _this.getShopCart(mescroll, 1);
  357. } else {
  358. mescroll.endSuccess(_this.size, false);
  359. }
  360. })
  361. },
  362. addMore: function() {
  363. var _this = this;
  364. if (_this.current < _this.totalPages) {
  365. _this.current = _this.current + 1;
  366. _this.getCouponList(_this.mescroll, 1);
  367. } else {
  368. _this.hasOther = true;
  369. }
  370. },
  371. inputNum: function(item) {
  372. if (item.cartQty > 999) {
  373. this.showToast("最多购买999件")
  374. item.cartQty = "999";
  375. } else if (item.cartQty < 0) {
  376. this.showToast("最少购买1件")
  377. item.cartQty = "1";
  378. }
  379. if (item.cartQty != '') {
  380. var data = {
  381. "url": "json",
  382. "type": "body",
  383. "mainId": item.mainId,
  384. "cartQty": Number(item.cartQty)
  385. }
  386. _this = this,
  387. url = "fixCartNum";
  388. this.$post(url, data, function(ret) {})
  389. }
  390. },
  391. setEdit: function() {
  392. if (this.inEdit) {
  393. this.inEdit = false;
  394. this.outEdit = true;
  395. } else {
  396. this.inEdit = true;
  397. this.outEdit = false;
  398. }
  399. },
  400. getEdit: function() {
  401. if (this.outEdit) {
  402. this.outEdit = false;
  403. this.inEdit = true;
  404. } else {
  405. this.inEdit = false;
  406. this.outEdit = true;
  407. }
  408. },
  409. getShopCart: function(mescroll) {
  410. var data = {
  411. "url": "json",
  412. "type": "body",
  413. "storeId": this.storeId,
  414. "size": this.size,
  415. "current": this.current
  416. },
  417. _this = this,
  418. url = "getShopCart";
  419. setTimeout(function() {
  420. if (mescroll) {
  421. mescroll.endSuccess();
  422. }
  423. }, 1000);
  424. this.$post(url, data, function(ret) {
  425. if (ret.code == 0 || ret.code == '0') {
  426. ret.data.records.map(function(store, index) {
  427. store.checked = false;
  428. })
  429. _this.Shopcarts = _this.current == 1 ? ret.data.records : _this.Shopcarts.concat(ret.data.records);
  430. _this.totalPages = ret.data.pages;
  431. if (mescroll) {
  432. mescroll.endSuccess(_this.size, true)
  433. }
  434. if (_this.frist == 1) {
  435. _this.$nextTick(function() {
  436. _this.configs();
  437. })
  438. }
  439. }
  440. })
  441. },
  442. changeAllCheck: function() {
  443. if (this.allCheck == false) {
  444. this.Shopcarts.map(function(cart, index) {
  445. cart.checked = false;
  446. })
  447. } else {
  448. this.Shopcarts.map(function(cart, index) {
  449. cart.checked = true;
  450. })
  451. }
  452. },
  453. numCheck: function(item) {
  454. var i = 0;
  455. this.Shopcarts.forEach(function(item) {
  456. if (item.checked === true) i++
  457. })
  458. if (i != this.Shopcarts.length) {
  459. this.allCheck = false
  460. } else {
  461. this.allCheck = true
  462. }
  463. },
  464. delCart: function(item) {
  465. var arr = [];
  466. var add = item.mainId;
  467. arr.push(add);
  468. var data = {
  469. "url": "json",
  470. "type": "body",
  471. "ids": arr,
  472. },
  473. _this = this,
  474. url = "delCart";
  475. _this.showModal('温馨提示', '是否确认删除?', ["取消", "确认"], function(res) {
  476. if (res == 2) {
  477. _this.$post(url, data, function(ret) {
  478. if (ret.code == 0 || ret.code == '0') {
  479. _this.showToast("已成功删除")
  480. } else {
  481. _this.showToast("删除失败")
  482. }
  483. setTimeout(function() {
  484. _this.getShopCart();
  485. }, 200)
  486. })
  487. }
  488. })
  489. },
  490. showPopup: function() {
  491. var arr = [];
  492. this.Shopcarts.map(function(cart, index) {
  493. if (cart.checked == true) {
  494. arr.push(cart.mainId);
  495. }
  496. })
  497. if (arr.length == 0) {
  498. this.showToast('至少选择一件商品');
  499. return;
  500. }
  501. if(this.status==3){
  502. api.alert({
  503. title: '系统提示',
  504. msg: '门店已冻结,请找相关业务经理解冻!'
  505. });
  506. return;
  507. }
  508. this.show = true;
  509. var data = {
  510. "url": "json",
  511. "type": "body",
  512. "storeId": this.storeId,
  513. "addressType": "1",
  514. "isDel":0
  515. },
  516. _this = this,
  517. url = "getReceiptAddress";
  518. this.$post(url, data, function(ret) {
  519. if (ret.code == 0 || ret.code == '0') {
  520. _this.addresslist = ret.list;
  521. for (var i = 0; i < _this.addresslist.length; i++) {
  522. if(_this.addresslist[i].beDefault==1){
  523. _this.radio=_this.addresslist[i].mainId
  524. }else{
  525. _this.radio = _this.addresslist[0].mainId
  526. }
  527. }
  528. }
  529. })
  530. },
  531. addOrder: function() {
  532. var hasChoose = [];
  533. this.Shopcarts.map(function(cart, index) {
  534. if (cart.checked == true) {
  535. hasChoose.push({              
  536. "mainId":  cart.mainId,
  537. "productId": cart.productId,
  538. "storeId":  cart.storeId,
  539. "cartQty":  cart.cartQty,
  540. "cartType":  cart.cartType,
  541. "status":  cart.status,
  542. "productIntroduction": cart.productIntroduction,
  543. "brand":  cart.brand,
  544. "spec":  cart.spec,
  545. "pattern":  cart.pattern,
  546. "createTime":  cart.createTime,
  547. "productPrice": cart.productPrice,
  548. "isDelete":  cart.isDelete,
  549. "productImage":  cart.productImage,
  550. "size":  null,
  551. "current":  null       
  552. });
  553. }
  554. })
  555. if (this.radio == "") {
  556. this.showToast('请选择收货地址');
  557. return;
  558. }
  559. var data = {
  560. "url": "json",
  561. "type": "body",
  562. "bizIntegralCartDtoList": hasChoose,
  563. "shopId": this.storeId,
  564. "receiptAddressId": this.radio
  565. },
  566. _this = this,
  567. url = "addOrder";
  568. _this.showModal('温馨提示', '是否确认下单?', ["取消", "确认"], function(res) {
  569. if (res == 2) {
  570. _this.$post(url, data, function(ret) {
  571. if (ret.code == 0 || ret.code == '0') {
  572. _this.showToast("成功下单")
  573. _this.allCheck = false;
  574. _this.show = false;
  575. setTimeout(function() {
  576. _this.goWin('annal', 'annal_win.html');
  577. }, 1000);
  578. } else {
  579. _this.showToast("下单失败")
  580. }
  581. setTimeout(function() {
  582. _this.getShopCart();
  583. }, 200)
  584. })
  585. }else{
  586. _this.show = false;
  587. }
  588. })
  589. },
  590. allDelCart: function() {
  591. var arr = [];
  592. this.Shopcarts.map(function(cart, index) {
  593. if (cart.checked == true) {
  594. arr.push(cart.mainId);
  595. }
  596. })
  597. if (arr.length == 0) {
  598. this.showToast('至少选择一件商品');
  599. return;
  600. }
  601. var data = {
  602. "url": "json",
  603. "type": "body",
  604. "ids": arr,
  605. },
  606. _this = this,
  607. url = "delCart";
  608. _this.showModal('温馨提示', '是否确认删除?', ["取消", "确认"], function(res) {
  609. if (res == 2) {
  610. _this.$post(url, data, function(ret) {
  611. if (ret.code == 0 || ret.code == '0') {
  612. _this.showToast("已成功删除")
  613. _this.allCheck = false
  614. } else {
  615. _this.showToast("删除失败")
  616. }
  617. setTimeout(function() {
  618. _this.getShopCart();
  619. _this.current = 1;
  620. }, 200)
  621. })
  622. }
  623. })
  624. },
  625. goaddress:function(){
  626. this.goWin('address','address_win.html');
  627. this.show=false
  628. }
  629. },
  630. watch: {
  631. },
  632. computed: {
  633. totalSumAll: function() {
  634. var totalSumAll = 0;
  635. this.Shopcarts.map(function(cart, index) {
  636. if (cart.checked == true) {
  637. totalSumAll +=cart.productPrice*Number(cart.cartQty)
  638. }
  639. })
  640. return totalSumAll
  641. },
  642. },
  643. mounted: function() {
  644. this.init();
  645. }
  646. })
  647. }
  648. </script>
  649. </html>