integral_shop.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  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
  188. class="aui-iconfont aui-icon-left"></span> </a>
  189. <div class="aui-title" id="aui-title">
  190. 购物车
  191. </div>
  192. <div
  193. style="display:flex;justify-content:flex-end;font-size:.3rem;align-items:center;margin-right:.2rem;">
  194. <div v-on:click="setEdit" v-show="inEdit">
  195. 编辑
  196. </div>
  197. <div v-on:click="getEdit" v-show="outEdit">
  198. 完成
  199. </div>
  200. </div>
  201. <!-- <div v-on:click="getEdit" v-show="outEdit" style="display:flex;justify-content:flex-end;font-size:.3rem;align-item:center;margin-right:.2rem;">
  202. 完成
  203. </div> -->
  204. </div>
  205. </header>
  206. <div class="banner">
  207. </div>
  208. <div class="box-main mescroll-touch-y mescroll" id="mescroll">
  209. <div class="card-main">
  210. <div class="card">
  211. <div class="card-list">
  212. <div class="card-box" v-for="(item,index) in Shopcarts" :key="index">
  213. <div class="card-list-left">
  214. <div class="card-check">
  215. <span>
  216. <van-checkbox v-model="item.checked" v-on:change="numCheck(item)">
  217. </van-checkbox>
  218. </span>
  219. </div>
  220. <div class="card-img">
  221. <img v-if="item.productImage==null" src="img/nothing.png"
  222. style="width:1.8rem;height:1.8rem">
  223. <img v-else :src="item.productImage" style="width:1.8rem;height:1.8rem">
  224. </div>
  225. <div class="card-text">
  226. <div class="card-title">
  227. <p class="card-title-p">{{item.productIntroduction}}</p>
  228. </div>
  229. <div class="shop-add-left">
  230. <van-stepper v-model="item.cartQty" input-width=".6rem" button-size=".4rem"
  231. integer min="1" max="999" v-on:change="inputNum(item)" />
  232. <!-- <div class="but-sub" v-on:click="subQuantity(item)">-</div>
  233. <input type="number" v-model="item.cartQty" v-on:input="inputNum(item)" v-on:Blur='outBlur(item)'>
  234. <div class="but-add" v-on:click="addQuantity(item)">+</div> -->
  235. </div>
  236. </div>
  237. </div>
  238. <div class="card-del" v-on:click="delCart(item)">
  239. <img src="./img/images/slices.png" alt="">
  240. </div>
  241. </div>
  242. </div>
  243. </div>
  244. </div>
  245. </div>
  246. <div class="settle">
  247. <div class="settle-main">
  248. <div class="settle-left">
  249. <div class="settle-check">
  250. <van-checkbox v-model="allCheck" v-on:click="changeAllCheck"></van-checkbox>
  251. </div>
  252. <div class="check-text">
  253. 全选
  254. </div>
  255. </div>
  256. <div class="settle-right">
  257. <div class="settle-compute" ref="updateTotal">
  258. 总计: {{totalSumAll}}积分
  259. </div>
  260. <div class="settle-button" v-show="inEdit" v-on:click="showPopup">
  261. 结算
  262. </div>
  263. <div class="settle-button color-c2c2c2" v-show="outEdit" v-on:click="allDelCart()">
  264. 删除
  265. </div>
  266. </div>
  267. </div>
  268. </div>
  269. <van-popup v-model="show" closeable position="bottom" :style="{ height: '40%' }">
  270. <div v-if="addresslist.length!=0" style="margin-top:1rem;height:65%" class="mescroll-touch-y mescroll">
  271. <van-radio-group v-model="radio" v-for="(ab,index) in addresslist" :key="index"
  272. style="padding:.2rem .4rem">
  273. <van-radio :name="ab.mainId">
  274. <div>
  275. <div>
  276. {{ab.contactsName}}
  277. </div>
  278. <div style="font-size:.25rem">
  279. {{ab.province}}{{ab.city}}{{ab.county}}{{ab.address}}
  280. </div>
  281. </div>
  282. </van-radio>
  283. </van-radio-group>
  284. </div>
  285. <div v-else>
  286. <div style="display:flex;justify-content:center;margin-top:.8rem;color:#ccc">
  287. 暂无收货地址
  288. </div>
  289. <div style="display:flex;justify-content:center;margin-top:.8rem;color:#00a0ea" v-on:click="goaddress">
  290. 点击去添加
  291. </div>
  292. </div>
  293. <div style="position: fixed;bottom: .2rem;width:100%;display:flex;justify-content:center">
  294. <div class="buttom-buy" v-on:click="addOrder">
  295. 立即下单
  296. </div>
  297. </div>
  298. </van-popup>
  299. </div>
  300. </body>
  301. <link rel="stylesheet" href="./mescroll/mescroll.min.css">
  302. <script type="text/javascript" src="./js/qrcode.min.js"></script>
  303. <script type="text/javascript" src="../script/aui-scroll.js"></script>
  304. <script type="text/javascript" src="./mescroll/mescroll.min.js"></script>
  305. <script type="text/javascript" src="../script/api.js"></script>
  306. <script type="text/javascript" src="../script/httpRequest.js"></script>
  307. <script type="text/javascript" src="../script/vue_plugins.js"></script>
  308. <script type="text/javascript">
  309. function closeWin() {
  310. api.closeWin({});
  311. }
  312. apiready = function () {
  313. api.parseTapmode();
  314. var header = $api.byId('aui-header');
  315. $api.fixStatusBar(header);
  316. new Vue({
  317. el: '#app',
  318. data: {
  319. checkBox: [],
  320. inEdit: true,
  321. outEdit: false,
  322. Shopcarts: [],
  323. total: '',
  324. allCheck: false,
  325. current: 1,
  326. size: 10, // 订单状态 0,新创建,1已接单,2,驳回,3完成 经销商审核 0 待审核 1 同意 2 拒绝
  327. frist: 1,
  328. totalPages: 1,
  329. hasOther: false,
  330. mescroll: '',
  331. show: false,
  332. addresslist: [],
  333. radio: '',
  334. },
  335. methods: {
  336. init: function () {
  337. this.storeId = $api.getStorage('userid');
  338. this.loginId = $api.getStorage('loginid');
  339. this.status = $api.getStorage('status');
  340. this.getShopCart();
  341. var _this = this;
  342. this.addEvent("refreshshop", function () {
  343. _this.getShopCart();
  344. _this.show = false;
  345. });
  346. // this.configDownAndPull("mescroll", function(mescroll) {
  347. // _this.getShopCart(mescroll);
  348. // }, function() {
  349. //
  350. // }, false);
  351. },
  352. configs: function () {
  353. var _this = this;
  354. this.frist = 2;
  355. this.configDownAndPull("mescroll", function (mescroll) {
  356. _this.mescroll = mescroll;
  357. _this.current = 1;
  358. _this.getShopCart(mescroll);
  359. }, function (mescroll) {
  360. if (_this.current < _this.totalPages) {
  361. _this.current = _this.current + 1;
  362. _this.getShopCart(mescroll, 1);
  363. } else {
  364. mescroll.endSuccess(_this.size, false);
  365. }
  366. })
  367. },
  368. addMore: function () {
  369. var _this = this;
  370. if (_this.current < _this.totalPages) {
  371. _this.current = _this.current + 1;
  372. _this.getCouponList(_this.mescroll, 1);
  373. } else {
  374. _this.hasOther = true;
  375. }
  376. },
  377. inputNum: function (item) {
  378. if (item.cartQty > 999) {
  379. this.showToast("最多购买999件")
  380. item.cartQty = "999";
  381. } else if (item.cartQty < 0) {
  382. this.showToast("最少购买1件")
  383. item.cartQty = "1";
  384. }
  385. if (item.cartQty != '') {
  386. var data = {
  387. "url": "json",
  388. "type": "body",
  389. "mainId": item.mainId,
  390. "cartQty": Number(item.cartQty)
  391. }
  392. _this = this,
  393. url = "fixCartNum";
  394. this.$post(url, data, function (ret) { })
  395. }
  396. },
  397. setEdit: function () {
  398. if (this.inEdit) {
  399. this.inEdit = false;
  400. this.outEdit = true;
  401. } else {
  402. this.inEdit = true;
  403. this.outEdit = false;
  404. }
  405. },
  406. getEdit: function () {
  407. if (this.outEdit) {
  408. this.outEdit = false;
  409. this.inEdit = true;
  410. } else {
  411. this.inEdit = false;
  412. this.outEdit = true;
  413. }
  414. },
  415. getShopCart: function (mescroll) {
  416. var data = {
  417. "url": "json",
  418. "type": "body",
  419. "storeId": this.storeId,
  420. "size": this.size,
  421. "current": this.current
  422. },
  423. _this = this,
  424. url = "getShopCart";
  425. setTimeout(function () {
  426. if (mescroll) {
  427. mescroll.endSuccess();
  428. }
  429. }, 1000);
  430. this.$post(url, data, function (ret) {
  431. if (ret.code == 0 || ret.code == '0') {
  432. ret.data.records.map(function (store, index) {
  433. store.checked = false;
  434. })
  435. _this.Shopcarts = _this.current == 1 ? ret.data.records : _this.Shopcarts.concat(ret.data.records);
  436. _this.totalPages = ret.data.pages;
  437. if (mescroll) {
  438. mescroll.endSuccess(_this.size, true)
  439. }
  440. if (_this.frist == 1) {
  441. _this.$nextTick(function () {
  442. _this.configs();
  443. })
  444. }
  445. }
  446. })
  447. },
  448. changeAllCheck: function () {
  449. if (this.allCheck == false) {
  450. this.Shopcarts.map(function (cart, index) {
  451. cart.checked = false;
  452. })
  453. } else {
  454. this.Shopcarts.map(function (cart, index) {
  455. cart.checked = true;
  456. })
  457. }
  458. },
  459. numCheck: function (item) {
  460. var i = 0;
  461. this.Shopcarts.forEach(function (item) {
  462. if (item.checked === true) i++
  463. })
  464. if (i != this.Shopcarts.length) {
  465. this.allCheck = false
  466. } else {
  467. this.allCheck = true
  468. }
  469. },
  470. delCart: function (item) {
  471. var arr = [];
  472. var add = item.mainId;
  473. arr.push(add);
  474. var data = {
  475. "url": "json",
  476. "type": "body",
  477. "ids": arr,
  478. },
  479. _this = this,
  480. url = "delCart";
  481. _this.showModal('温馨提示', '是否确认删除?', ["取消", "确认"], function (res) {
  482. if (res == 2) {
  483. _this.$post(url, data, function (ret) {
  484. if (ret.code == 0 || ret.code == '0') {
  485. _this.showToast("已成功删除")
  486. } else {
  487. _this.showToast("删除失败")
  488. }
  489. setTimeout(function () {
  490. _this.getShopCart();
  491. }, 200)
  492. })
  493. }
  494. })
  495. },
  496. showPopup: function () {
  497. var arr = [];
  498. this.Shopcarts.map(function (cart, index) {
  499. if (cart.checked == true) {
  500. arr.push(cart.mainId);
  501. }
  502. })
  503. if (arr.length == 0) {
  504. this.showToast('至少选择一件商品');
  505. return;
  506. }
  507. if (this.status == 3) {
  508. api.alert({
  509. title: '系统提示',
  510. msg: '门店已冻结,请找相关业务经理解冻!'
  511. });
  512. return;
  513. }
  514. this.show = true;
  515. var data = {
  516. "url": "json",
  517. "type": "body",
  518. "storeId": this.storeId,
  519. "addressType": "1",
  520. "isDel": 0
  521. },
  522. _this = this,
  523. url = "getReceiptAddress";
  524. this.$post(url, data, function (ret) {
  525. if (ret.code == 0 || ret.code == '0') {
  526. _this.addresslist = ret.list;
  527. for (var i = 0; i < _this.addresslist.length; i++) {
  528. if (_this.addresslist[i].beDefault == 1) {
  529. _this.radio = _this.addresslist[i].mainId
  530. } else {
  531. _this.radio = _this.addresslist[0].mainId
  532. }
  533. }
  534. }
  535. })
  536. },
  537. addOrder: function () {
  538. var hasChoose = [];
  539. this.Shopcarts.map(function (cart, index) {
  540. if (cart.checked == true) {
  541. hasChoose.push({
  542. "mainId": cart.mainId,
  543. "productId": cart.productId,
  544. "storeId": cart.storeId,
  545. "cartQty": cart.cartQty,
  546. "cartType": cart.cartType,
  547. "status": cart.status,
  548. "productIntroduction": cart.productIntroduction,
  549. "brand": cart.brand,
  550. "spec": cart.spec,
  551. "pattern": cart.pattern,
  552. "createTime": cart.createTime,
  553. "productPrice": cart.productPrice,
  554. "isDelete": cart.isDelete,
  555. "productImage": cart.productImage,
  556. "size": null,
  557. "current": null
  558. });
  559. }
  560. })
  561. if (this.radio == "") {
  562. this.showToast('请选择收货地址');
  563. return;
  564. }
  565. var data = {
  566. "url": "json",
  567. "type": "body",
  568. "bizIntegralCartDtoList": hasChoose,
  569. "shopId": this.storeId,
  570. "receiptAddressId": this.radio
  571. },
  572. _this = this,
  573. url = "addOrder";
  574. _this.showModal('温馨提示', '是否确认下单?', ["取消", "确认"], function (res) {
  575. if (res == 2) {
  576. _this.$post(url, data, function (ret) {
  577. if (ret.code == 0 || ret.code == '0') {
  578. if (!ret.message) {
  579. _this.showToast("成功下单")
  580. _this.allCheck = false;
  581. _this.show = false;
  582. setTimeout(function () {
  583. _this.goWin('annal', 'annal_win.html');
  584. }, 1000);
  585. } else {
  586. api.toast({
  587. msg: ret.message
  588. });
  589. _this.allCheck = false;
  590. _this.show = false;
  591. return
  592. }
  593. } else {
  594. _this.showToast("下单失败")
  595. }
  596. setTimeout(function () {
  597. _this.getShopCart();
  598. }, 200)
  599. })
  600. } else {
  601. _this.show = false;
  602. }
  603. })
  604. },
  605. allDelCart: function () {
  606. var arr = [];
  607. this.Shopcarts.map(function (cart, index) {
  608. if (cart.checked == true) {
  609. arr.push(cart.mainId);
  610. }
  611. })
  612. if (arr.length == 0) {
  613. this.showToast('至少选择一件商品');
  614. return;
  615. }
  616. var data = {
  617. "url": "json",
  618. "type": "body",
  619. "ids": arr,
  620. },
  621. _this = this,
  622. url = "delCart";
  623. _this.showModal('温馨提示', '是否确认删除?', ["取消", "确认"], function (res) {
  624. if (res == 2) {
  625. _this.$post(url, data, function (ret) {
  626. if (ret.code == 0 || ret.code == '0') {
  627. _this.showToast("已成功删除")
  628. _this.allCheck = false
  629. } else {
  630. _this.showToast("删除失败")
  631. }
  632. setTimeout(function () {
  633. _this.getShopCart();
  634. _this.current = 1;
  635. }, 200)
  636. })
  637. }
  638. })
  639. },
  640. goaddress: function () {
  641. this.goWin('address', 'address_win.html');
  642. this.show = false
  643. }
  644. },
  645. watch: {
  646. },
  647. computed: {
  648. totalSumAll: function () {
  649. var totalSumAll = 0;
  650. this.Shopcarts.map(function (cart, index) {
  651. if (cart.checked == true) {
  652. totalSumAll += cart.productPrice * Number(cart.cartQty)
  653. }
  654. })
  655. return totalSumAll
  656. },
  657. },
  658. mounted: function () {
  659. this.init();
  660. }
  661. })
  662. }
  663. </script>
  664. </html>