clearing.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
  6. <meta name="apple-mobile-web-app-capable" content="yes">
  7. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  8. <title>结算</title>
  9. <link rel="stylesheet" type="text/css" href="css/mui.min.css" />
  10. <link rel="stylesheet" type="text/css" href="css/iconfont.css" />
  11. <link rel="stylesheet" type="text/css" href="css/main.css" />
  12. <style>
  13. input[type="checkbox"] {
  14. /*pointer-events: none;*/
  15. }
  16. .mui-switch {
  17. background: #bbb;
  18. height: 20px;
  19. border: 1px solid #bbb;
  20. padding: 0 5px;
  21. }
  22. .mui-switch:before {
  23. content: '';
  24. }
  25. .mui-switch.mui-active:before {
  26. content: '';
  27. }
  28. .mui-switch .mui-switch-handle {
  29. top: -6px;
  30. width: 30px;
  31. height: 30px;
  32. margin-left: 2px;
  33. }
  34. .clearing-box .mui-table-view-cell.mui-active,
  35. .mui-navigate-right.mui-active {
  36. background: #fff !important;
  37. }
  38. .mui-switch.mui-active {
  39. background: #79b3f3;
  40. border-color: #79b3f3;
  41. }
  42. .clearing-box .mui-table-view-cell {
  43. border-bottom: 8px solid #f2f2f2;
  44. }
  45. .clearing-box .mui-table-view-cell:after,
  46. .my-view-no-top:after {
  47. left: 0;
  48. display: none;
  49. }
  50. .shopping-cart-list {
  51. border-bottom: 8px solid #f2f2f2;
  52. }
  53. .clearing-box {
  54. margin: 0;
  55. padding-bottom: 0;
  56. }
  57. .icon-dingwei {
  58. font-size: 22px;
  59. color: #e06974;
  60. }
  61. .my-view-no-top .mui-navigate-right:after{
  62. right: 7px;
  63. }
  64. </style>
  65. <script type="text/javascript">
  66. // 屏蔽分享
  67. window.hiddenAllWechatMenu = true;
  68. </script>
  69. </head>
  70. <body style="background: #f2f2f2;">
  71. <div class="loading-bg">
  72. <div class="mui-loading">
  73. <div class="mui-spinner">
  74. </div>
  75. &nbsp;&nbsp;加载中...
  76. </div>
  77. </div>
  78. <div class="mui-content">
  79. <div style="padding:0 14px 0 14px;background-color: #fff;text-align: center;border-bottom:8px solid #f2f2f2;">
  80. <ul class="mui-table-view mui-table-view-striped my-grid-view-no mui-table-view-condensed">
  81. <li class="mui-table-view-cell" style="background-color: #fff;border-radius: 5px;padding: 11px 8px;">
  82. <div class="mui-table" id="user-address-div" style="height: 80px;">
  83. <div class="mui-table-cell mui-col-xs-12 table-middle" style="display: table-cell;">
  84. <div class="btn-add-address"><span class="iconfont icon-jia"></span>添加收货地址</div>
  85. </div>
  86. <!--<div class="mui-table-cell mui-col-xs-1 mui-text-left table-middle">
  87. <p><span class="iconfont icon-dingwei"></span></p>
  88. </div>
  89. <div class="mui-table-cell mui-col-xs-10 mui-text-left table-middle">
  90. <div>收货人:林笑笑 <span class="mui-pull-right">16899996678</span></div>
  91. <p>收货地址:广东省深圳市福田区莲花街道深圳特区 报业大厦12b</p>
  92. </div>
  93. <div class="mui-table-cell mui-col-xs-1 mui-text-right table-middle">
  94. <p><span class="mui-icon mui-icon-arrowright"></span></p>
  95. </div>-->
  96. </div>
  97. </li>
  98. </ul>
  99. </div>
  100. <ul class="mui-table-view mui-table-view-striped my-grid-view-no mui-table-view-condensed shopping-cart-list">
  101. </ul>
  102. <div class="clearing-box">
  103. <ul class="mui-table-view my-view-no-top">
  104. <li class="mui-table-view-cell" id="ul-youhuiquan" style="display: none;">
  105. <a class="mui-navigate-right btn-youhuiquan">
  106. 优惠券<span class="mui-pull-right cl-red" style="margin-right: 10px;display: none;">-¥0.0</span>
  107. </a>
  108. </li>
  109. <li class="mui-table-view-cell show_integral">
  110. 可用积分 <span style="margin-left: 10px;" class="integral_num">0</span>,抵扣¥<span class="integral_money">0</span>
  111. <!-- 开关打开状态,多了一个.mui-active类 -->
  112. <div class="mui-switch mui-switch-mini mui-active" id="mySwitch">
  113. <div class="mui-switch-handle"></div>
  114. </div>
  115. </li>
  116. <li class="mui-table-view-cell">
  117. <div class="mui-input-row">
  118. <label style="width:20%;padding:13px 0;">订单备注</label>
  119. <input style="width: 79%;font-size: 12px;" maxlength="140" id="textarea" type="text" placeholder="您对订单有特殊要求,可以在此备注" />
  120. </div>
  121. <!--<textarea id="textarea" maxlength="140" rows="1" placeholder="您对订单有特殊要求,可以在此备注" style="background-color: #f9f9f9;border: 0;margin:14px 0 0 0;padding: 15px;font-size: 14px;"></textarea>-->
  122. <p id="tips" style="text-align: right"></p>
  123. </li>
  124. </ul>
  125. <div style="padding:14px 14px 50px 14px;font-size: 12px;color: #999;background: #f2f2f2;">由于购买人数较多,下单后,订单将会按下单顺序依次发货,敬请谅解</div>
  126. </div>
  127. <div class="buy-footer1">
  128. <table class="tb-clearing">
  129. <tr>
  130. <td class="quanxuan">
  131. 共<span class="cl-red"><span id="pro-count">0</span>件</span>商品
  132. </td>
  133. <td class="mui-text-center">合计:<span class="count_price_box">¥<span class="count_price">0.00</span></span>元</td>
  134. <td>
  135. <a id="go-pay" class="mui-btn mui-pull-right add_gwc">立即支付</a>
  136. </td>
  137. </tr>
  138. </table>
  139. </div>
  140. </div>
  141. <script src="js/mui.min.js"></script>
  142. <script src="js/jquery-2.1.1.min.js"></script>
  143. <script src="js/main.js"></script>
  144. <script src="js/wechat-utils-1.0.js"></script>
  145. <script>
  146. var userIntegral = 0; // 用户可用积分
  147. var meonyProportion = 0; // 兑换比例:1个积分=?分钱
  148. var payTotal = 0.0; // 支付总金额
  149. var userInputIntegral = 0; // 抵扣积分
  150. var isPay = true; // 是否在请求支付,false表示正在请求,true可以请求
  151. var cartIdStr = ""; // 购物车ID
  152. var usePayMoney = 0;
  153. var ipt_balance = 0;
  154. var yhq_val = 0;
  155. var used_balance = 0;
  156. var yhq_type = 1;
  157. var yhq_id = '';
  158. var userIntegralUsed = 1; // 是否使用积分 1:使用 2:不使用
  159. mui.ready(function() {
  160. var parameter = {}; //ajax参数json集合
  161. var cartidList = '';
  162. if(!window.sessionStorage) {
  163. mui.alert("您的浏览器不支持sessionStorage");
  164. } else {
  165. //读取上一个页面带过来的sessionStorage
  166. pay_data = JSON.parse(sessionStorage.getItem('pay_data'));
  167. if(pay_data != null) {
  168. cartidList = pay_data.text[0]; //购物项id集合
  169. parameter["cartIds"] = cartidList;
  170. $.ajax(base_path + '/wechat/order/payBefore', {
  171. data: parameter,
  172. dataType: 'json',
  173. type: 'POST',
  174. xhrFields: {
  175. withCredentials: true
  176. },
  177. crossDomain: true,
  178. timeout: 15000,
  179. success: function(dt) {
  180. if(dt.isRedirect) {
  181. location.href = dt.redirectURL;
  182. } else {
  183. console.log(dt);
  184. if(dt.status == true) {
  185. // 购物项遍历
  186. console.log(dt)
  187. var liNote = "";
  188. var yhq_str = "";
  189. payTotal = dt.data.payTotal; // 支付金额,单位分
  190. if(dt.data.couponItems.length > 0) {
  191. $("#ul-youhuiquan").show();
  192. //console.log("有优惠券" + dt.data.couponItems.length + "张")
  193. var str = '';
  194. mui.each(dt.data.couponItems, function(index) {
  195. var opacity = 1,
  196. checked = 'checked',
  197. disabled = '';
  198. if(index > 0) {
  199. opacity = 0.5;
  200. checked = '';
  201. }
  202. if(payTotal < this.couponConsumeEnough) {
  203. opacity = 0.5;
  204. checked = '';
  205. disabled = 'disabled="disabled"';
  206. }
  207. str += '<li class="my-table-view-cell" style="opacity:' + opacity + '"><div class="mui-table"><div class="mui-table-cell table-middle mui-col-xs-11">优惠券:¥' + ((this.couponReduce) / 100).toFixed(2) + '<h6>有效期至:' + this.couponUseEndDate + '</h6></div><div class="mui-table-cell table-middle mui-col-xs-1"><input name="checkbox" val="' + (this.couponReduce / 100).toFixed(2) + '" type="checkbox" ' + checked + ' ' + disabled + ' class="mui-pull-left" id="' + this.couponItemId + '"/></div></div></li>';
  208. });
  209. $("body").append('<div class="my-picker"><ul class="mui-table-view mui-table-view-striped mui-table-view-condensed my-grid-view-no" style="padding: 20px 0 30px 0;overflow: scroll;max-height: 400px;">' + str + '</ul><button class="mui-btn my-btn-block my-btn-buy-know">确认使用</button></div>');
  210. }
  211. mui.each(dt.data.cartItems, function(index) {
  212. var num = this.cartNum;
  213. var total = (num * this.productDiscount / 100).toFixed(2); //购物车小计,单位分,保留两位小数
  214. var productId = this.cartProductId;
  215. var zeng = '';
  216. if(typeof(this.salesUserGiftList) != "undefined") {
  217. $.each(this.salesUserGiftList, function() {
  218. zeng += this.giftName + '*' + (num * this.userGiftCount) + '件 '
  219. });
  220. }
  221. if(zeng != '') {
  222. zeng = '<p style="font-size:12px;">(赠品:' + zeng + ')</p>';
  223. }
  224. liNote += '<li class="mui-table-view-cell"><div class="mui-table"><div class="mui-table-cell mui-col-xs-4"><img class="mui-media-object wh-100" src="' + this.productIntroduceImg + '"></div><div class="mui-table-cell table-middle mui-col-xs-8" style="line-height:2.5">' + this.productName + '<h6><span class="center" style="line-height: 15px;">颜色:' + this.productColor + '</span></br><span class="center" style="line-height: 15px;">数量:' + num + '</span></h6><div>单价 ¥' + (this.productDiscount / 100).toFixed(2) + '</div></div></div><div>' + zeng + '</div></li>';
  225. });
  226. var $productListUl = $(".shopping-cart-list");
  227. $productListUl.empty();
  228. $productListUl.append(liNote);
  229. // 保存数据
  230. cartIdStr = dt.data.cartId; // 购物车ID
  231. userIntegral = dt.data.userIntegral; // 用户可用积分
  232. //计算积分能换算的钱
  233. var myUserIntegral = 0;
  234. if(dt.data.userIsVip == 2 && dt.data.userIntegral > 0){
  235. $('.show_integral').show();
  236. //积分赋值
  237. $('.integral_num').text(dt.data.userIntegral);
  238. var myUserIntegral = dt.data.userIntegral;
  239. myUserIntegral = parseInt(accDiv(myUserIntegral, 10));
  240. userIntegralUsedNumber = myUserIntegral
  241. $('.integral_money').text(myUserIntegral)
  242. }else{
  243. $('.show_integral').hide();
  244. userIntegralUsed = 2;
  245. }
  246. //默认自己拉出地址
  247. if(dt.data.addressInfo != undefined && dt.data.addressInfo != null) {
  248. $(".btn-add-address").parent().hide();
  249. $("#user-address-div").append('<div class="mui-table-cell mui-col-xs-1 mui-text-left table-middle addr"><p><span class="iconfont icon-dingwei"></span></p></div><div class="mui-table-cell mui-col-xs-10 mui-text-left table-middle addr"><div>收货人:' + dt.data.addressInfo.salesAddressName + ' <span class="" style="padding-left: 10px;" >' + dt.data.addressInfo.salesAddressTel + '</span></div><p>收货地址:' + dt.data.addressInfo.salesAddressInfo + '</p></div><div class="mui-table-cell mui-col-xs-1 mui-text-right table-middle addr"><p><span class="mui-icon mui-icon-arrowright"></span></p></div>');
  250. //给微信参数赋值
  251. wechatAddr.status = true;
  252. wechatAddr.detailInfo = dt.data.addressInfo.salesAddressInfo;
  253. wechatAddr.userName = dt.data.addressInfo.salesAddressName;
  254. wechatAddr.userTel = dt.data.addressInfo.salesAddressTel;
  255. wechatAddr.postalCode = dt.data.addressInfo.salesAddressPostnum;
  256. }
  257. $("#pro-count").text(dt.data.cartItems.length);
  258. if(dt.data.couponItems.length) {
  259. yhq_id = $("input[name=checkbox]:checked").attr('id');
  260. var cout = 0;
  261. console.log(yhq_id)
  262. if(typeof(yhq_id) != "undefined") {
  263. $(".btn-youhuiquan>span").text("-¥" + $("input[name=checkbox]:checked").attr("val")).show();
  264. cout = $("input[name=checkbox]:checked").attr("val");
  265. }
  266. var count_price = payTotal - cout * 100;
  267. if(count_price <= 0) {
  268. count_price = 0.0; //判断商品价格减去现金券价格若<0 则显示0
  269. }
  270. $(".count_price").text((count_price / 100).toFixed(2));
  271. } else {
  272. $(".count_price").text((dt.data.payTotal / 100).toFixed(2));
  273. }
  274. } else {
  275. mui.alert(dt.message, function() {
  276. location.href = "shopping-cart.html?dates=" + new Date().getTime(); // 前往购物车
  277. });
  278. }
  279. }
  280. },
  281. error: function(xhr, type, errorThrown) {
  282. console.log(xhr);
  283. mui.alert("获取数据失败,网络错误!")
  284. }
  285. });
  286. } else {
  287. mui.alert("sessionStorage异常!", function() {
  288. location.href = "index.html";
  289. })
  290. }
  291. }
  292. document.querySelector('.loading-bg').style.display = 'none';
  293. });
  294. //callback为用户点击蒙版时自动执行的回调;
  295. var mask = mui.createMask(function() {
  296. $(".my-picker").removeClass("active");
  297. });
  298. //点击弹出优惠券列表
  299. $(document).on('tap', '.btn-youhuiquan', function() {
  300. mask.show();
  301. $(".my-picker").addClass("active");
  302. });
  303. //选择优惠券
  304. $(document).on('click', '.my-picker input[name=checkbox]', function() {
  305. var th = $(this);
  306. if(th.prop("checked")) {
  307. th.parent().parent().parent().siblings().css("opacity", .5).find("input").prop("checked", false);
  308. th.parent().parent().parent().css("opacity", 1);
  309. $('.my-btn-buy-know').removeAttr("disabled");
  310. } else {
  311. th.parent().parent().parent().css("opacity", .5);
  312. $('.my-btn-buy-know').attr("disabled", "disabled");
  313. }
  314. });
  315. //确认使用优惠券
  316. $(document).on('tap', '.my-btn-buy-know', function() {
  317. console.log("确认使用");
  318. yhq_id = $("input[name=checkbox]:checked").attr('id');
  319. var cout = 0;
  320. if(typeof(yhq_id) != "undefined") {
  321. $(".btn-youhuiquan>span").text("-¥" + $("input[name=checkbox]:checked").attr("val")).show();
  322. cout = $("input[name=checkbox]:checked").attr("val");
  323. }
  324. $(".my-picker").removeClass("active");
  325. $(".mui-backdrop").css("opacity", 0).remove();
  326. var count_price = payTotal - cout * 100;
  327. if(count_price <= 0) {
  328. count_price = 0.0; //判断商品价格减去现金券价格若<0 则显示0
  329. }
  330. $(".count_price").text((count_price / 100).toFixed(2));
  331. });
  332. // 获取微信共享地址
  333. $(document).on('tap', '#user-address-div', function() {
  334. editAddrV1(
  335. function(res) {
  336. // 用户成功拉出地址
  337. var address = res.provinceName + "-" + res.cityName + "-" + res.countryName + "-" + res.detailInfo;
  338. wechatAddr.status = true;
  339. wechatAddr.detailInfo = address;
  340. wechatAddr.postalCode = res.postalCode;
  341. wechatAddr.userName = res.userName;
  342. wechatAddr.userTel = res.telNumber;
  343. wechatAddr.nationalCode = res.nationalCode;
  344. $("#user-address-div .addr").remove();
  345. $(".btn-add-address").parent().hide();
  346. $("#user-address-div").append('<div class="mui-table-cell mui-col-xs-1 mui-text-left table-middle addr"><p><span class="iconfont icon-dingwei"></span></p></div><div class="mui-table-cell mui-col-xs-10 mui-text-left table-middle addr"><div>收货人:' + wechatAddr.userName + ' <span class="" style="padding-left: 10px;">' + wechatAddr.userTel + '</span></div><p>收货地址:' + wechatAddr.detailInfo + '</p></div><div class="mui-table-cell mui-col-xs-1 mui-text-right table-middle addr"><p><span class="mui-icon mui-icon-arrowright"></span></p></div>');
  347. },
  348. function() {
  349. if($('#user-address-div .addr').html() != null && $('#user-address-div .addr').html() != '') {
  350. wechatAddr.status = true;
  351. } else {
  352. wechatAddr.status = false;
  353. // 用户取消拉出地址
  354. mui.alert("您没有选择收货地址!");
  355. }
  356. }
  357. );
  358. });
  359. // 去支付
  360. $(document).on('tap', '#go-pay', function() {
  361. var remark = $("#textarea").val();
  362. var ch_en_num = /^[A-Za-z0-9 _\[\]\【\】\{\}\{\}\(\)\(\)\《\》\<\>\,\,\.\。\、\!\!\~\·\@\#\¥\$\%\^\…\&\—\:\:\;\;\‘\’\'\'\"\"\“\”\?\?\-\=\|\*\+\-\u4e00-\u9fa5]{0,100}$/;
  363. if(ch_en_num.test(remark)) {
  364. console.log("备注验证通过")
  365. } else {
  366. mui.alert("备注格式错误!仅支持中/英文,数字,普通符号");
  367. return false;
  368. }
  369. if(wechatAddr.status) {
  370. if(isPay) {
  371. isPay = false; // 锁定请求按钮
  372. /* 组装数据 */
  373. var dataArgs = {
  374. "orderAddressInfo": wechatAddr.detailInfo,
  375. "orderAddressPostNum": wechatAddr.postalCode,
  376. "orderAddressMoblie": wechatAddr.userTel,
  377. "orderAddressName": wechatAddr.userName,
  378. "cartIdStr": cartIdStr,
  379. "orderIntegralNum": 0,
  380. "orderUserRemark": remark,
  381. "couponId": yhq_id,
  382. "balancePayAmount": 0
  383. };
  384. $.ajax(base_path + '/wechat/order/pay', { // 提交订单,准备支付
  385. data: dataArgs,
  386. dataType: 'json',
  387. type: 'POST',
  388. xhrFields: {
  389. withCredentials: true
  390. },
  391. crossDomain: true,
  392. timeout: 15000,
  393. success: function(dt) {
  394. // layer.closeAll();
  395. //mui.alert(dt.resultCode=="500");
  396. if(dt.resultCode == "500") {
  397. mui.alert(dt.message);
  398. isPay = true;
  399. return;
  400. };
  401. if(dt.data.info == "isOK") {
  402. location.href = 'pay-win.html?orderId=' + dt.data.orderId + "&dates=" + new Date().getTime();
  403. return;
  404. };
  405. var orderId = dt.data.orderId;
  406. if(dt.status) {
  407. var str = dt.data.info;
  408. var obj = JSON.parse("{" + str + "}");
  409. WeixinJSBridge.invoke('getBrandWCPayRequest', obj, function(res) {
  410. //console.log(res)
  411. if(res.err_msg == 'get_brand_wcpay_request:ok') {
  412. $.ajax(base_path + '/wechat/order/checkOrderPaySuccess?dates=' + new Date().getTime(), {
  413. data: {
  414. "orderId": orderId
  415. },
  416. dataType: 'json',
  417. xhrFields: {
  418. withCredentials: true
  419. },
  420. crossDomain: true,
  421. type: 'get',
  422. timeout: 15000,
  423. success: function(dataobj) {
  424. if(dataobj.isRedirect) {
  425. location.href = dataobj.redirectURL;
  426. } else {
  427. if(dataobj.status == true) { // 支付成功
  428. location.href = "pay-win.html?orderId=" + orderId + "&dates=" + new Date().getTime();
  429. } else {
  430. location.href = "order-details.html?orderId=" + orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  431. }
  432. }
  433. },
  434. error: function(xhr, type, errorThrown) {
  435. console.log(xhr);
  436. isPay = true;
  437. mui.alert("支付失败!网络错误");
  438. }
  439. });
  440. // var orderIds = {
  441. // "orderId": dt.data.orderId
  442. // };
  443. // var url =base_path+"/wechat/order/checkOrderPaySuccess";
  444. // $.getJSON(url, {
  445. // "s": new Date().getTime(),
  446. // "orderId": dt.data.orderId
  447. // }, function(data) {
  448. // if(data.status == true) { // 支付成功
  449. // location.href = "pay-win.html?orderId=" + orderIds.orderId + "&dates=" + new Date().getTime();
  450. // } else {
  451. // setTimeout("checkOrderStatus('" + dt.data.orderId + "')", 1000);
  452. // }
  453. // });
  454. } else {
  455. isPay = true;
  456. mui.alert("支付失败!请稍后重试!", function() {
  457. location.href = "order-details.html?orderId=" + orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  458. });
  459. }
  460. });
  461. } else {
  462. isPay = true;
  463. mui.alert(dt.message);
  464. location.href = "order-details.html?orderId=" + orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  465. }
  466. },
  467. error: function(xhr, type, errorThrown) {
  468. isPay = true;
  469. // layer.closeAll();
  470. mui.alert("您的网络异常,请刷新重试!");
  471. return;
  472. }
  473. });
  474. } else {
  475. mui.alert("正在请求支付中~~请稍后!");
  476. return;
  477. }
  478. } else {
  479. mui.alert("请选择收货地址!");
  480. return;
  481. }
  482. });
  483. //实时监听文本框字数
  484. document.getElementById("textarea").addEventListener("input", function() {
  485. if(this.value.length > 140) {
  486. $("#tips").text("超出长度" + (this.value.length - 140) + "字");
  487. } else {
  488. $("#tips").text("还可输入" + (140 - this.value.length) + "字");
  489. }
  490. });
  491. // 积分开关事件
  492. document.getElementById("mySwitch").addEventListener("toggle", function(e) {
  493. if(e.detail.isActive) {
  494. console.log("你启动了开关");
  495. } else {
  496. console.log("你关闭了开关");
  497. }
  498. })
  499. </script>
  500. </body>
  501. </html>