From 9f916f98c6cc6827c84da18fbc9a5e2cacbefc0a Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期二, 02 四月 2024 16:20:08 +0800 Subject: [PATCH] Merge refs/remotes/origin/master into refs/heads/master --- pages/cart/index.js | 92 +++++++++++++++++++++++++++++++++------------- 1 files changed, 66 insertions(+), 26 deletions(-) diff --git a/pages/cart/index.js b/pages/cart/index.js index 546e1c1..d00cc4c 100644 --- a/pages/cart/index.js +++ b/pages/cart/index.js @@ -1,9 +1,14 @@ const app = getApp(); // import { getPublicImage } from '@/assets/js/middleGround/tool.js' -import { getPublicImage } from '../../assets/js/middleGround/tool'; +import { + loginInfo +} from '../../assets/js/login'; +import { + getPublicImage +} from '../../assets/js/middleGround/tool'; import Toast from 'tdesign-miniprogram/toast/index'; -import { loginInfo } from '../../assets/js/login'; + Page({ data: { onDisabled: false, @@ -35,7 +40,11 @@ }) } this.shoppingCartGet(); - this.setData({ totalPrice: 0.00, selectedCount: 0, checkAll: false, }) + this.setData({ + totalPrice: 0.00, + selectedCount: 0, + checkAll: false, + }) }, @@ -45,8 +54,21 @@ ids: [item.id] }).then(res => { this.shoppingCartGet(); - wx.showToast({ title: '鍒犻櫎鍥句功鎴愬姛', icon: 'none' }); + wx.showToast({ + title: '鍒犻櫎鍥句功鎴愬姛', + icon: 'none' + }); + this.setData({ + totalPrice: 0.00, + selectedCount: 0, + checkAll: false, + }) + + }); + + + }, shoppingCartGet() { @@ -63,12 +85,13 @@ }) res.datas.forEach(item => { - // console.log(item, 'item456'); item.imgUrl = getPublicImage(item.productMonWithLinkDto.product.icon, '', '160'); - - this.setData({ - type: item.saleMethod.type == 'createProductItemSaleMethod' ? 'item' : 'product' - }) + // this.setData({ + // type: item.saleMethod.type == 'createProductItemSaleMethod' ? 'item' : 'product' + // }) + const type = item.saleMethod.type == 'createProductItemSaleMethod' ? 'item' : 'product'; + item.type = type; // 灏唗ype璁剧疆涓篿tem瀵硅薄鐨勫睘鎬э紝鑰屼笉鏄娇鐢╯etData + // debugger }); @@ -78,7 +101,6 @@ if (this.data.shoppingCartData.length === 0) { - console.log(11111); this.setData({ onDisabled: true }) @@ -108,7 +130,9 @@ }, HandelItemChange(e) { - const { item } = e.target.dataset; + const { + item + } = e.target.dataset; const items = this.data.shoppingCartData items.map(eitem => { if (eitem.id == item.id) { @@ -147,7 +171,6 @@ goPaymentPage() { - // 棣栭〉娴嬭瘯鐧诲綍鍔熻兘锛屽悗缁敞閲� // 妫�鏌ョ櫥褰曠姸鎬� const token = wx.getStorageSync(app.config.tokenKey) @@ -155,8 +178,6 @@ loginInfo(app, (data) => { // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� if (data) { - - const selectedItems = this.data.shoppingCartData.filter(item => item.checked); // console.log(selectedItems, 789); const selectedIds = selectedItems.map(item => item.id); @@ -166,9 +187,6 @@ linkIds: selectedIds } app.MG.store.shoppingCartCreateOrder(data).then(res => { - // console.log(res, 456); - - const url = '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber wx.navigateTo({ url @@ -188,11 +206,30 @@ } }) } else { - // 濡傛灉鏄涓�娆$櫥褰曪紝浼氳烦杞嚦缁戝畾鐢ㄦ埛淇℃伅椤甸潰锛屽~鍐欏畬鐢ㄦ埛淇℃伅鍚庤繘琛岀櫥褰曞苟鍌ㄥ瓨token鍜岀敤鎴蜂俊鎭紝缁撴潫鍚庤烦杞洖褰撳墠椤甸潰锛堟惡甯﹂〉闈㈠弬鏁帮級 + const selectedItems = this.data.shoppingCartData.filter(item => item.checked); + // console.log(selectedItems, 789); + const selectedIds = selectedItems.map(item => item.id); + console.log('閫変腑鐨勫晢鍝� id:', selectedIds); + if (selectedIds.length) { + let data = { + linkIds: selectedIds + } + app.MG.store.shoppingCartCreateOrder(data).then(res => { + const url = '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber + wx.navigateTo({ + url + }); + }) + } else { + Toast({ + context: this, + selector: '#t-toast', + message: '璇烽�夋嫨鍟嗗搧', + theme: 'warning', + direction: 'column', + }); + } } - - - @@ -202,8 +239,9 @@ url: '/pages/testLogin/index' }); }, - //瑙﹀簳鍑芥暟 - onReachBottom() { + + + onScrollToLower() { if (this.data.shoppingCartData.length < this.data.totalSize) { this.setData({ isMore: true, @@ -220,17 +258,19 @@ }) console.log('300'); }, 300) - } }, // 涓嬫媺鍑芥暟 onPullDownRefresh() { this.setData({ - start: 1 + start: 1, + checkAll: false, + selectedCount: 0, + totalPrice: 0.00, }) console.log(978); this.shoppingCartGet() }, -}); +}); \ No newline at end of file -- Gitblit v1.9.1