From e8b854f5e6ef2245b6f1778ca009cbf721939579 Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Sun, 28 Feb 2021 23:48:13 +0800 Subject: [PATCH 01/13] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=A7=84=E6=A0=BC=E9=80=89=E6=8B=A9=E5=AE=9E=E6=97=B6=E4=BB=8E?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E8=8E=B7=E5=8F=96=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/pms/inventory.js | 13 +++++++++++++ api/pms/product.js | 1 + pages/product/product.vue | 19 ++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 api/pms/inventory.js diff --git a/api/pms/inventory.js b/api/pms/inventory.js new file mode 100644 index 0000000..226d1e8 --- /dev/null +++ b/api/pms/inventory.js @@ -0,0 +1,13 @@ +import request from '@/utils/request' + + +/** + * 获取商品库存 + */ +export function getInventory(skuId) { + return request({ + url: '/mall-pms/api.app/v1/inventories/' + skuId + '/inventory', + method: 'get' + }) + +} diff --git a/api/pms/product.js b/api/pms/product.js index c7507f1..fb8b175 100644 --- a/api/pms/product.js +++ b/api/pms/product.js @@ -15,3 +15,4 @@ export function detail(id) { method: 'get' }) } + diff --git a/pages/product/product.vue b/pages/product/product.vue index 20b8f58..76566a2 100644 --- a/pages/product/product.vue +++ b/pages/product/product.vue @@ -157,6 +157,11 @@ import { detail } from '@/api/pms/product.js'; + + import { + getInventory + } from '@/api/pms/inventory.js'; + import { save as saveCart, confirm as orderConfirm @@ -271,7 +276,19 @@ const selectedSpecValueIds = this.selectedSpec.map(item => item.id).sort().join(',') // 根据规格排序字符串找到匹配的sku信息 - this.selectedSku = this.skuList.filter(sku => sku.specValueIds == selectedSpecValueIds)[0] + const {id,picUrl,price} = this.skuList.filter(sku => sku.specValueIds == selectedSpecValueIds)[0] + + + // 实时获取商品库存信息 + getInventory(id).then(response=>{ + const stock=response.data + this.selectedSku={ + id:id, + picUrl:picUrl, + price:price, + stock:stock + } + }) }, //分享 share() { -- Gitee From ad1f41c4bce0360015c10bc4b303abdee966aad1 Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Mon, 15 Mar 2021 01:10:45 +0800 Subject: [PATCH 02/13] =?UTF-8?q?feat:=E8=AE=A2=E5=8D=95=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/oms/cart.js | 61 ++- api/oms/order.js | 4 +- api/pms/inventory.js | 2 +- pages/cart/cart.vue | 841 +++++++++++++++++------------------- pages/category/category.vue | 2 +- pages/order/createOrder.vue | 17 +- pages/product/list.vue | 12 +- pages/product/product.vue | 63 ++- store/modules/user.js | 6 +- utils/request.js | 44 +- 10 files changed, 508 insertions(+), 544 deletions(-) diff --git a/api/oms/cart.js b/api/oms/cart.js index ba0c649..ae7c360 100644 --- a/api/oms/cart.js +++ b/api/oms/cart.js @@ -21,71 +21,60 @@ export function save(skuId) { skuId: skuId }, headers: { - 'auth': true // 需要认证 + 'auth': true } }) } -// 修改购物车商品数量 -export function update(data) { +/** + * 局部更新购物车商品 + * @param {Object} params + */ +export function updateCartItem(skuId, params) { return request({ - url: '/mall-oms/api.app/v1/carts', + url: '/mall-oms/api.app/v1/carts/skuId/' + skuId, method: 'put', - data: data, + params: params, headers: { - 'auth': true // 需要认证 + 'auth': true } }) } -// 是否选择购物车中商品 -export function checkItem(data){ - return request({ - url: '/mall-oms/api.app/v1/carts/check', - method: 'put', - data: data, - headers: { - 'auth': true // 需要认证 - } - }) -} -// 是否选择购物车中商品 -export function checkAll(check){ +/** + * 批量局部更新购物车商品 + * @param {Object} params + */ +export function batchUpdateCartItem(params) { return request({ - url: '/mall-oms/api.app/v1/carts/checkAll', + url: '/mall-oms/api.app/v1/carts/batch', method: 'put', - params: { - check: check - }, + params: params, headers: { - 'auth': true // 需要认证 + 'auth': true } }) } -// 删除购物车中选中商品 -export function deleteCart(skuIds) { +// 批量删除购物车商品 +export function deleteCartItem(skuId) { return request({ - url: '/mall-oms/api.app/v1/carts', + url: '/mall-oms/api.app/v1/carts/skuId/' + skuId, method: 'delete', - params: { - skuIds: skuIds - }, headers: { - 'auth': true // 需要认证 + 'auth': true } }) } // 删除购物车中选中商品 -export function clear(skuIds) { +export function deleteCart() { return request({ - url: '/mall-oms/api.app/v1/carts/clear', - method: 'get', + url: '/mall-oms/api.app/v1/carts', + method: 'delete', headers: { - 'auth': true // 需要认证 + 'auth': true } }) } - diff --git a/api/oms/order.js b/api/oms/order.js index 0fd5287..30b7df8 100644 --- a/api/oms/order.js +++ b/api/oms/order.js @@ -4,7 +4,7 @@ import request from '@/utils/request' // 确认订单 export function confirm(skuId,number) { return request({ - url: '/mall-oms/api.app/v1/orders/confirm', + url: '/mall-oms/api.app/v1/orders/_confirm', method: 'post', params: { skuId: skuId, @@ -19,7 +19,7 @@ export function confirm(skuId,number) { // 提交订单 export function submit(data) { return request({ - url: '/mall-oms/api.app/v1/orders/submit', + url: '/mall-oms/api.app/v1/orders/_submit', method: 'post', data: data, headers: { diff --git a/api/pms/inventory.js b/api/pms/inventory.js index 226d1e8..77dd61d 100644 --- a/api/pms/inventory.js +++ b/api/pms/inventory.js @@ -6,7 +6,7 @@ import request from '@/utils/request' */ export function getInventory(skuId) { return request({ - url: '/mall-pms/api.app/v1/inventories/' + skuId + '/inventory', + url: '/mall-pms/api.app/v1/skus/' + skuId + '/inventory', method: 'get' }) diff --git a/pages/cart/cart.vue b/pages/cart/cart.vue index 7c8818d..a8d9666 100644 --- a/pages/cart/cart.vue +++ b/pages/cart/cart.vue @@ -1,445 +1,412 @@ diff --git a/pages/category/category.vue b/pages/category/category.vue index 35b576d..ef1265f 100644 --- a/pages/category/category.vue +++ b/pages/category/category.vue @@ -8,7 +8,7 @@ {{ item.name }} - + {{ titem.name }} diff --git a/pages/order/createOrder.vue b/pages/order/createOrder.vue index 8ba9dfc..56bad99 100644 --- a/pages/order/createOrder.vue +++ b/pages/order/createOrder.vue @@ -137,7 +137,7 @@ freightAmount: 0, payAmount: 0, skuId: 0, - skuNumber: 0, + skuNum: 0, couponList: [ { id: 1, @@ -186,11 +186,8 @@ } }, onLoad(option){ - //商品数据 - //let data = JSON.parse(option.data); - console.log(option); this.skuId = option.skuId; - this.skuNumber = option.skuNumber; + this.skuNum = option.skuNum; this.loadData(); this.defaultAddress(); }, @@ -207,8 +204,8 @@ async loadData() { // 调用后端接口,查询订单确认页列表 const skuId = this.skuId === 0? null:this.skuId; - const skuNumber = this.skuNumber === 0? null:this.skuNumber; - confirm(skuId,skuNumber).then(response =>{ + const skuNum = this.skuNum === 0? null:this.skuNum; + confirm(skuId,skuNum).then(response =>{ const data = response.data; this.orderConfirmInfo = data; this.orderItems = data.items; @@ -234,7 +231,7 @@ this.payAmount = totalPrice - couponAmount -freightAmount; }, numberChange(data) { - this.number = data.number; + this.num = data.num; }, changePayType(type){ this.payType = type; @@ -251,7 +248,7 @@ submitVO.addressId = this.addressData.id; if (this.skuId != 0){ submitVO.skuId = this.skuId; - submitVO.skuNumber = this.skuNumber; + submitVO.skuNum = this.skuNum; } if (this.couponId != 0){ submitVO.couponId = this.couponId; @@ -397,7 +394,7 @@ .price { margin-bottom: 4upx; } - .number{ + .num{ font-size: 26upx; color: $font-color-base; margin-left: 20upx; diff --git a/pages/product/list.vue b/pages/product/list.vue index e1d9d02..46da05d 100644 --- a/pages/product/list.vue +++ b/pages/product/list.vue @@ -15,7 +15,7 @@ - + {{ item.name }} @@ -81,9 +81,9 @@ // #ifdef H5 this.headerTop = document.getElementsByTagName('uni-page-head')[0].offsetHeight + 'px'; // #endif + this.cateId = options.tid; this.loadCateList(options.fid, options.sid); - this.loadData(); }, onPageScroll(e) { //兼容iOS端下拉时顶部漂移 @@ -103,13 +103,14 @@ }, methods: { //加载分类 - async loadCateList(fid, sid) { + loadCateList(fid, sid) { getCategoryList(fid).then(response => { this.cateList = response.data; + this.loadData(); }); }, //加载商品 ,带下拉刷新和上滑加载 - async loadData(type = 'add', loading) { + loadData(type = 'add', loading) { //没有更多直接返回 if (type === 'add') { // 上滑加载 if (this.loadingType === 'nomore') { @@ -128,8 +129,6 @@ this.queryParams.categoryId = this.cateId getGoodsList(this.queryParams).then(response => { - console.log('获取分类下的商品列表', response.data); - const { data, total @@ -162,7 +161,6 @@ }); } - }, //筛选点击 tabClick(index) { diff --git a/pages/product/product.vue b/pages/product/product.vue index 76566a2..817b791 100644 --- a/pages/product/product.vue +++ b/pages/product/product.vue @@ -3,7 +3,7 @@ - + @@ -21,7 +21,7 @@ 销量: {{spu.sales}} - 库存: {{selectedSku.stock}} + 库存: {{selectedSku.inventory}} 浏览量: 768 @@ -44,7 +44,7 @@ 购买类型 - {{ sItem.value }} + {{ sItem.value }} @@ -124,13 +124,13 @@ - + ¥{{selectedSku.price|moneyFormatter}} - 库存:{{selectedSku.stock}}件 + 库存:{{selectedSku.inventory}}件 已选: - {{ sItem.value }} + {{ sItem.value }} @@ -179,18 +179,18 @@ brandId: undefined, originPrice: undefined, price: undefined, - picUrls: [], + pics: [], unit: undefined, description: undefined, detail: undefined }, attrs: [], specs: [], - skuList: [], + skus: [], specClass: 'none', selectedSku: {}, - selectedSpec: [], + selectedSpecValueIdArr: [], favorite: true, shareList: [], desc: ` @@ -212,34 +212,33 @@ spu, attrs, specs, - skuList + skus } = response.data; this.spu = spu; this.attrs = attrs; this.specs = specs; - this.skuList = skuList; + this.skus = skus; // 默认选择第一条规格 - this.selectedSpec = [] + this.selectedSpecValueIdArr = [] this.specs.forEach(spec => { if(spec.values.length > 0){ spec.values[0].selected = true // 添加规格是否选中属性 - this.selectedSpec.push(spec.values[0]) + this.selectedSpecValueIdArr.push(spec.values[0]) } }) // 默认选择的规格id排序拼接字符串 例如: 1,2,3 - const defaltSpecValueIds = this.selectedSpec.map(item => item.id).sort().join(',') + const defaultSpecValueIds = this.selectedSpecValueIdArr.map(item => item.id).sort().join(',') // 根据规格排序字符串找到匹配的sku信息 - this.selectedSku = this.skuList.filter(sku => sku.specValueIds == defaltSpecValueIds)[0] + this.selectedSku = this.skus.filter(sku => sku.specValueIds == defaultSpecValueIds)[0] }); //接收传值,id里面放的是标题,因为测试数据并没写id - let id = options.id; - if (id) { - this.$api.msg(`点击了${id}`); + if (spuId) { + this.$api.msg(`点击了${spuId}`); } this.shareList = await this.$api.json('shareList'); @@ -266,47 +265,47 @@ } }) - this.selectedSpec = [] + this.selectedSpecValueIdArr = [] this.specs.forEach(spec => { const selectedSpecValue = spec.values.filter(value => value.selected == true)[0] - this.selectedSpec.push(selectedSpecValue) - + this.selectedSpecValueIdArr.push(selectedSpecValue) }) - const selectedSpecValueIds = this.selectedSpec.map(item => item.id).sort().join(',') + const selectedSpecValueIds = this.selectedSpecValueIdArr.map(item => item.id).sort().join(',') // 根据规格排序字符串找到匹配的sku信息 - const {id,picUrl,price} = this.skuList.filter(sku => sku.specValueIds == selectedSpecValueIds)[0] + const {id,pic,price} = this.skus.filter(sku => sku.specValueIds == selectedSpecValueIds)[0] // 实时获取商品库存信息 getInventory(id).then(response=>{ - const stock=response.data + const inventory=response.data this.selectedSku={ id:id, - picUrl:picUrl, + pic:pic, price:price, - stock:stock + inventory:inventory } }) }, - //分享 + // 分享 share() { this.$refs.share.toggleMask(); }, - //收藏 + // 收藏 toFavorite() { this.favorite = !this.favorite; }, + // 立即购买 buy() { const skuId = this.selectedSku.id; - const skuNumber = 1; + const skuNum = 1; uni.navigateTo({ - url: `/pages/order/createOrder?skuId=`+skuId+`&skuNumber=`+skuNumber, + url: `/pages/order/createOrder?skuId=`+skuId+`&skuNum=`+skuNum, }); }, + // 添加至购物车 addToCart() { - console.info("已选择商品",this.selectedSku) const skuId = this.selectedSku.id saveCart(skuId).then(response => { // 1、添加商品到购物车 @@ -321,8 +320,6 @@ }, }); }) - - }, stopPrevent() {} } diff --git a/store/modules/user.js b/store/modules/user.js index 0e712e8..61d00db 100644 --- a/store/modules/user.js +++ b/store/modules/user.js @@ -60,6 +60,7 @@ const actions = { // user logout logout({commit, state,}) { + console.log('logout') return new Promise((resolve, reject) => { logout().then(() => { uni.removeStorage({ @@ -76,7 +77,10 @@ const actions = { reject(error) }) }) - } + }, + + + } export default { diff --git a/utils/request.js b/utils/request.js index f2d1065..47556af 100644 --- a/utils/request.js +++ b/utils/request.js @@ -1,6 +1,5 @@ import axios from 'axios' - - +import store from '@/store' axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' // create an axios instance @@ -18,7 +17,7 @@ service.interceptors.request.use( if (config.headers.auth === true) { // 判断请求是否需要认证 const token = uni.getStorageSync('token') if (token) { - config.headers['Authorization'] =token; + config.headers['Authorization'] = token; } } return config @@ -59,20 +58,33 @@ service.defaults.adapter = function(config) { // response interceptor -service.interceptors.response.use( - /** - * If you want to get http information such as headers or status - * Please return response => response - */ +service.interceptors.response.use(({ + config, + data + }) => { + + console.log('响应数据', data) + const { + code, + msg + } = data + + if (code && code != '00000') { + if (code == 'A0230') { // token过期 + console.log('token过期') + uni.showToast({ + title: '会话已过期,请重新登录', + success() { + uni.navigateTo({ + url: `/pages/public/login`, + }); + } + }) + } + } else { + return data + } - /** - * Determine the request status by custom code - * Here is just an example - * You can also judge the status by HTTP Status Code - */ - response => { - const res = response.data - return res }, error => { console.log('err' + error) // for debug -- Gitee From 9425ad59a9d1da76f7ffa4977645507727cc901b Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Tue, 16 Mar 2021 01:02:57 +0800 Subject: [PATCH 03/13] =?UTF-8?q?feat:=E8=AE=A2=E5=8D=95=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/order/createOrder.vue | 236 ++++++++++++++++++++---------------- 1 file changed, 131 insertions(+), 105 deletions(-) diff --git a/pages/order/createOrder.vue b/pages/order/createOrder.vue index 56bad99..0a76b0a 100644 --- a/pages/order/createOrder.vue +++ b/pages/order/createOrder.vue @@ -6,14 +6,13 @@ - {{addressData.name}} - {{addressData.mobile}} + {{selectedAddress.name}} + {{selectedAddress.mobile}} - {{addressData.address}} {{addressData.area}} + {{selectedAddress.address}} {{selectedAddress.area}} - @@ -27,10 +26,10 @@ {{item.skuName}} - {{item.skuSpec}} + ¥{{item.price|moneyFormatter}} - x {{item.number}} + x {{item.num}} @@ -79,7 +78,7 @@ - + @@ -89,7 +88,7 @@ 提交订单 - + @@ -104,7 +103,7 @@ {{item.price}} 满30可用 - + @@ -118,7 +117,8 @@ - diff --git a/pages/order/createOrder.vue b/pages/order/createOrder.vue index 0a76b0a..0564556 100644 --- a/pages/order/createOrder.vue +++ b/pages/order/createOrder.vue @@ -6,30 +6,33 @@ - {{selectedAddress.name}} - {{selectedAddress.mobile}} + {{ selectedAddress.name }} + {{ selectedAddress.mobile }} - {{selectedAddress.address}} {{selectedAddress.area}} + {{ selectedAddress.address }} {{ selectedAddress.area }} - + - - 西城小店铺 + + 有来小店 - {{item.skuName}} + {{ item.skuName }} - ¥{{item.price|moneyFormatter}} - x {{item.num}} + ¥{{ item.price | moneyFormatter }} + x {{ item.num }} @@ -38,22 +41,14 @@ - - 券 - + 优惠券 - - 选择优惠券 - - - {{couponTitle}} - + 选择优惠券 + {{ couponTitle }} - - 减 - + 商家促销 暂无可用优惠 @@ -62,20 +57,20 @@ 商品金额 - ¥{{orderConfirmInfo.totalPrice|moneyFormatter}} + ¥{{ orderConfirmInfo.totalPrice | moneyFormatter }} 优惠金额 - -¥{{couponAmount|moneyFormatter}} + -¥{{ couponAmount | moneyFormatter }} 运费 免运费 - -¥{{freightAmount|moneyFormatter}} + -¥{{ freightAmount | moneyFormatter }} 备注 - + @@ -84,23 +79,23 @@ 实付款 - {{payAmount|moneyFormatter}} + {{ payAmount | moneyFormatter }} 提交订单 - + - + - {{item.title}} + {{ item.title }} 有效期至2019-06-30 - {{item.price}} + {{ item.price }} 满30可用 @@ -111,600 +106,551 @@ - diff --git a/static/logo.png b/static/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..449670ed97c5fca6713458da3d7d0f502c27054d GIT binary patch literal 10074 zcmeI2X;f0}`|n9JD^s({Qc)|1${Z@o)Evr8!PJ~0GoZ~sxN>Kr4R20wd`JZ#vf1P#Kd3|2|Ua%JH-h1tR?`vQ8eO=$rcfYu1 zVEdKp%-v*2{GgvP{AY~Bb@@H24V zR$}IpC(kRwMxviM+W8+Rb!#t0GQ#bxRu7ZAM|`}!dWy-6ydK68Eu?u(_X#IQXxPpy zd-Ly-GKtoHhm}eh&+y)r<8_FUq?pCEebc-S=X<1&`TZ_mZ+TPs8+XUq%E529kM4Kx3J4ciCyHbgTqX8WG1R zj6H!4ugO@yl*`g#e_SBewW|(>o!^cEy>Jn{EcHxZWR%d~ks6n(>N*MvQS0XP;|`>A z@Gn$f6JBc^C>GuTW2Fo#pS5d zLRHNQD~xy011-JBDD)}am%g)mYV&7 zqOCs-M8NJ>n}RGQcu9YldpH53?8#G>l#ng5&F?!8cZB`OB;HtSNTWxUTTDQgu1@J) zTAM4eKgmL?nlg4zK5L>Xp{mHp(~j{(ldeCysO1R|e(fEn=#S zgHL%(h2*wFXc}9-JT(c?4_K ze5BZ;-`=y!$&=Zr>C{jBndaLT1#v}I4)m3I2bI*1&tE=s7Fq_~ta35nxB;^{{Zi2& zHi}Vmy!G9&!rS?E>`xl`hnG$wOa!*q7lP=8DTjh0 zowpk7cAaJ=aFw(Rk;7Uyr%mh)JhD(f4|VRyuIF1x+cv#km?mi7&N}qA-id3v?{99d zI>4+}#psZDqC++mj9o1%C>pKN4xBm8JO#}=wgk8Sbk=GI>aBUEsGUQV-P-7RboeU! z4Do$@R*ix?E1o3bMxo^Ahrsr-`dw)npwmEFW{nk25G~ZL%zjuAj5PO?=izoE(d%WU z!DQVDC@b+hzcc^eGXo|~_c=O2+nFe0E!!ef$Gj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?ZTuF7GQS1RV0|a3#M4)YsiUXGC`c*5bqdRZ^)>cq!0o)Hm4A zsR4z-qt_<)F2T`h_<+grhgtv@C9_YGIVZ^M6M<8lw#ah!hyV^Ut^F_6W%Pd-X8&Dq u{cjiTKZE~?(tnZxu#^A4S_r>4K~MLp6P089hk)K)} literal 0 HcmV?d00001 diff --git a/utils/request.js b/utils/request.js index 47556af..eebf049 100644 --- a/utils/request.js +++ b/utils/request.js @@ -62,8 +62,6 @@ service.interceptors.response.use(({ config, data }) => { - - console.log('响应数据', data) const { code, msg -- Gitee From 6d51cfaae2cf95f4c7a8bce8a9e9e2fcc32d24ab Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Thu, 18 Mar 2021 20:23:58 +0800 Subject: [PATCH 05/13] =?UTF-8?q?feat:=E8=B4=AD=E7=89=A9=E8=BD=A6=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/oms/cart.js | 2 +- api/oms/order.js | 2 +- api/pms/inventory.js | 13 - api/pms/product.js | 10 + api/user.js | 2 +- pages/cart/cart.vue | 639 ++++++++++++++++++------------------ pages/order/createOrder.vue | 5 +- pages/product/list.vue | 2 + pages/product/product.vue | 24 +- store/modules/user.js | 7 +- utils/request.js | 2 +- 11 files changed, 350 insertions(+), 358 deletions(-) delete mode 100644 api/pms/inventory.js diff --git a/api/oms/cart.js b/api/oms/cart.js index ae7c360..759ae64 100644 --- a/api/oms/cart.js +++ b/api/oms/cart.js @@ -13,7 +13,7 @@ export function detail() { } // 添加购物车 -export function save(skuId) { +export function addCartItem(skuId) { return request({ url: '/mall-oms/api.app/v1/carts', method: 'post', diff --git a/api/oms/order.js b/api/oms/order.js index 30b7df8..c2661b5 100644 --- a/api/oms/order.js +++ b/api/oms/order.js @@ -6,7 +6,7 @@ export function confirm(skuId,number) { return request({ url: '/mall-oms/api.app/v1/orders/_confirm', method: 'post', - params: { + data: { skuId: skuId, number: number }, diff --git a/api/pms/inventory.js b/api/pms/inventory.js deleted file mode 100644 index 77dd61d..0000000 --- a/api/pms/inventory.js +++ /dev/null @@ -1,13 +0,0 @@ -import request from '@/utils/request' - - -/** - * 获取商品库存 - */ -export function getInventory(skuId) { - return request({ - url: '/mall-pms/api.app/v1/skus/' + skuId + '/inventory', - method: 'get' - }) - -} diff --git a/api/pms/product.js b/api/pms/product.js index fb8b175..87d6c99 100644 --- a/api/pms/product.js +++ b/api/pms/product.js @@ -16,3 +16,13 @@ export function detail(id) { }) } + +/** + * 获取商品库存 + */ +export function getSkuStock(skuId) { + return request({ + url: '/mall-pms/api.app/v1/skus/' + skuId + '/stock', + method: 'get' + }) +} diff --git a/api/user.js b/api/user.js index a323e37..ef002f3 100644 --- a/api/user.js +++ b/api/user.js @@ -26,7 +26,7 @@ export function logout() { export function getUserInfo() { return request({ - url: '/mall-ums/api.app/v1/users/me', + url: '/mall-ums/api.app/v1/members/me', method: 'get', headers:{ 'auth':true diff --git a/pages/cart/cart.vue b/pages/cart/cart.vue index c57ddf5..4c96b36 100644 --- a/pages/cart/cart.vue +++ b/pages/cart/cart.vue @@ -15,18 +15,32 @@ - + - + {{ item.skuName }} ¥{{ item.price | moneyFormatter }} - + @@ -36,378 +50,367 @@ - - 清空 - + 清空 - ¥{{ cart.totalPrice | moneyFormatter }} + ¥{{ totalPrice | moneyFormatter }} 已优惠 - {{ cart.totalCoupon | moneyFormatter }} + {{ coupon | moneyFormatter }} - + diff --git a/pages/order/createOrder.vue b/pages/order/createOrder.vue index 0564556..09064be 100644 --- a/pages/order/createOrder.vue +++ b/pages/order/createOrder.vue @@ -57,7 +57,7 @@ 商品金额 - ¥{{ orderConfirmInfo.totalPrice | moneyFormatter }} + ¥{{ totalPrice | moneyFormatter }} 优惠金额 @@ -130,12 +130,11 @@ export default { couponList: [], totalPrice: 0, selectedAddress: {}, - orderConfirmInfo: {}, orderItems: [] }; }, onLoad(option) { - console.log('========>> 进入订单详情页面, 路径:', this.$mp.page.route, '参数', option); + console.log('========>> 进入订单确认页面, 路径:', this.$mp.page.route, '参数', option); this.skuId = option.skuId; this.skuNum = option.skuNum; this.loadData(); diff --git a/pages/product/list.vue b/pages/product/list.vue index 46da05d..38170ad 100644 --- a/pages/product/list.vue +++ b/pages/product/list.vue @@ -78,6 +78,8 @@ }, onLoad(options) { + console.log('========>> 进入订单列表页面, 路径:', this.$mp.page.route, '参数', options); + // #ifdef H5 this.headerTop = document.getElementsByTagName('uni-page-head')[0].offsetHeight + 'px'; // #endif diff --git a/pages/product/product.vue b/pages/product/product.vue index 817b791..7131cbb 100644 --- a/pages/product/product.vue +++ b/pages/product/product.vue @@ -21,7 +21,7 @@ 销量: {{spu.sales}} - 库存: {{selectedSku.inventory}} + 库存: {{selectedSku.stock}} 浏览量: 768 @@ -127,7 +127,7 @@ ¥{{selectedSku.price|moneyFormatter}} - 库存:{{selectedSku.inventory}}件 + 库存:{{selectedSku.stock}}件 已选: {{ sItem.value }} @@ -155,15 +155,11 @@ import share from '@/components/share'; import { - detail + detail,getSkuStock } from '@/api/pms/product.js'; import { - getInventory - } from '@/api/pms/inventory.js'; - - import { - save as saveCart, + addCartItem , confirm as orderConfirm } from '@/api/oms/cart.js' export default { @@ -206,6 +202,7 @@ }; }, async onLoad(options) { + console.log('========>> 进入商品详情页面, 路径:', this.$mp.page.route, '参数', options); const spuId = options.id detail(spuId).then(response => { const { @@ -276,15 +273,14 @@ // 根据规格排序字符串找到匹配的sku信息 const {id,pic,price} = this.skus.filter(sku => sku.specValueIds == selectedSpecValueIds)[0] - // 实时获取商品库存信息 - getInventory(id).then(response=>{ - const inventory=response.data + getSkuStock(id).then(response=>{ + const stock=response.data this.selectedSku={ id:id, pic:pic, price:price, - inventory:inventory + stock:stock } }) }, @@ -307,9 +303,7 @@ // 添加至购物车 addToCart() { const skuId = this.selectedSku.id - saveCart(skuId).then(response => { - // 1、添加商品到购物车 - // 2、跳转到购物车页面 + addCartItem(skuId).then(response => { uni.switchTab({ url: `/pages/cart/cart`, success: (res) => { diff --git a/store/modules/user.js b/store/modules/user.js index 61d00db..549bb4c 100644 --- a/store/modules/user.js +++ b/store/modules/user.js @@ -60,7 +60,7 @@ const actions = { // user logout logout({commit, state,}) { - console.log('logout') + console.log('logout') return new Promise((resolve, reject) => { logout().then(() => { uni.removeStorage({ @@ -77,10 +77,7 @@ const actions = { reject(error) }) }) - }, - - - + } } export default { diff --git a/utils/request.js b/utils/request.js index eebf049..9a6ea05 100644 --- a/utils/request.js +++ b/utils/request.js @@ -69,7 +69,7 @@ service.interceptors.response.use(({ if (code && code != '00000') { if (code == 'A0230') { // token过期 - console.log('token过期') + uni.showToast({ title: '会话已过期,请重新登录', success() { -- Gitee From cd8ccdfd002dacac25df384095d5c83b848f03c5 Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Fri, 19 Mar 2021 01:11:21 +0800 Subject: [PATCH 06/13] =?UTF-8?q?feat:=E8=B4=AD=E7=89=A9=E8=BD=A6=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E8=B0=83=E6=95=B4=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/oms/cart.js | 59 ++--- api/oms/pay.js | 6 +- pages/cart/cart.vue | 633 ++++++++++++++++++++++---------------------- pages/money/pay.vue | 4 +- 4 files changed, 352 insertions(+), 350 deletions(-) diff --git a/api/oms/cart.js b/api/oms/cart.js index 759ae64..32cdf1f 100644 --- a/api/oms/cart.js +++ b/api/oms/cart.js @@ -2,7 +2,7 @@ import request from '@/utils/request' // 查询购物车 -export function detail() { +export function getCart() { return request({ url: '/mall-oms/api.app/v1/carts', method: 'get', @@ -12,29 +12,27 @@ export function detail() { }) } -// 添加购物车 -export function addCartItem(skuId) { +/** + * 全选/全不选 + * @param {Object} params + */ +export function check(params) { return request({ - url: '/mall-oms/api.app/v1/carts', - method: 'post', - params: { - skuId: skuId - }, + url: '/mall-oms/api.app/v1/carts/_check', + method: 'put', + params: params, headers: { 'auth': true } }) } -/** - * 局部更新购物车商品 - * @param {Object} params - */ -export function updateCartItem(skuId, params) { + +// 清空购物车 +export function deleteCart() { return request({ - url: '/mall-oms/api.app/v1/carts/skuId/' + skuId, - method: 'put', - params: params, + url: '/mall-oms/api.app/v1/carts', + method: 'delete', headers: { 'auth': true } @@ -42,36 +40,37 @@ export function updateCartItem(skuId, params) { } -/** - * 批量局部更新购物车商品 - * @param {Object} params - */ -export function batchUpdateCartItem(params) { +// 添加购物车 +export function addCartItem(skuId) { return request({ - url: '/mall-oms/api.app/v1/carts/batch', - method: 'put', - params: params, + url: '/mall-oms/api.app/v1/carts', + method: 'post', + params: { + skuId: skuId + }, headers: { 'auth': true } }) } -// 批量删除购物车商品 -export function deleteCartItem(skuId) { +// 更新购物车商品 +export function updateCartItem(skuId, data) { return request({ url: '/mall-oms/api.app/v1/carts/skuId/' + skuId, - method: 'delete', + method: 'put', + data:data, headers: { 'auth': true } }) } -// 删除购物车中选中商品 -export function deleteCart() { + +// 批量删除购物车商品 +export function removeCartItem(skuId) { return request({ - url: '/mall-oms/api.app/v1/carts', + url: '/mall-oms/api.app/v1/carts/skuId/' + skuId, method: 'delete', headers: { 'auth': true diff --git a/api/oms/pay.js b/api/oms/pay.js index 2bba2fd..38fcff7 100644 --- a/api/oms/pay.js +++ b/api/oms/pay.js @@ -2,9 +2,9 @@ import request from '@/utils/request' // 查询购物车 -export function getPayInfo(orderId) { +export function getPayment(orderId) { return request({ - url: '/mall-oms/api.app/v1/order_pays/orderId/' + orderId, + url: '/mall-oms/api.app/v1/payments/orderId/' + orderId, method: 'get', headers: { 'auth': true // 需要认证 @@ -15,7 +15,7 @@ export function getPayInfo(orderId) { // 支付 export function pay(orderId, payType) { return request({ - url: '/mall-oms/api.app/v1/order_pays', + url: '/mall-oms/api.app/v1/payments', method: 'post', params: { orderId: orderId, diff --git a/pages/cart/cart.vue b/pages/cart/cart.vue index 4c96b36..a932de0 100644 --- a/pages/cart/cart.vue +++ b/pages/cart/cart.vue @@ -18,29 +18,15 @@ - + {{ item.skuName }} ¥{{ item.price | moneyFormatter }} - + @@ -67,350 +53,367 @@ diff --git a/pages/money/pay.vue b/pages/money/pay.vue index 0b2aee2..1b601cc 100644 --- a/pages/money/pay.vue +++ b/pages/money/pay.vue @@ -39,7 +39,7 @@ - - diff --git a/pages/money/pay.vue b/pages/money/pay.vue index 1b601cc..90a7a99 100644 --- a/pages/money/pay.vue +++ b/pages/money/pay.vue @@ -39,12 +39,13 @@ diff --git a/pages/index/index.vue b/pages/index/index.vue index 7eba7f2..c9b2315 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -232,7 +232,7 @@ }; }, - onLoad() { + onShow() { this.loadData(); }, methods: { diff --git a/pages/money/pay.vue b/pages/money/pay.vue index 90a7a99..58af00e 100644 --- a/pages/money/pay.vue +++ b/pages/money/pay.vue @@ -65,8 +65,9 @@ export default { this.payType = type; }, pay() { - console.info('========确认支付========'); + console.info('========付款开始========'); pay(this.orderId, this.payType).then(response => { + console.log('订单付款结果',response) uni.showToast({ title: '订单支付成功', icon: 'success', diff --git a/pages/money/paySuccess.vue b/pages/money/paySuccess.vue index 06ef07e..df9225f 100644 --- a/pages/money/paySuccess.vue +++ b/pages/money/paySuccess.vue @@ -4,7 +4,7 @@ 支付成功 - 查看订单 + 查看订单 返回首页 diff --git a/pages/order/order.vue b/pages/order/order.vue index 775130e..f9936db 100644 --- a/pages/order/order.vue +++ b/pages/order/order.vue @@ -1,612 +1,578 @@ diff --git a/pages/product/list.vue b/pages/product/list.vue index 38170ad..0d26416 100644 --- a/pages/product/list.vue +++ b/pages/product/list.vue @@ -76,9 +76,8 @@ } }; }, - onLoad(options) { - console.log('========>> 进入订单列表页面, 路径:', this.$mp.page.route, '参数', options); + console.log('========>> 进入商品列表页面, 路径:', this.$mp.page.route, '参数', options); // #ifdef H5 this.headerTop = document.getElementsByTagName('uni-page-head')[0].offsetHeight + 'px'; diff --git a/pages/product/product.vue b/pages/product/product.vue index 7131cbb..0cb4fcd 100644 --- a/pages/product/product.vue +++ b/pages/product/product.vue @@ -295,9 +295,8 @@ // 立即购买 buy() { const skuId = this.selectedSku.id; - const skuNum = 1; uni.navigateTo({ - url: `/pages/order/createOrder?skuId=`+skuId+`&skuNum=`+skuNum, + url: `/pages/order/createOrder?skuId=`+skuId+`&count=1`, }); }, // 添加至购物车 diff --git a/pages/user/user.vue b/pages/user/user.vue index 5728663..3f9dc18 100644 --- a/pages/user/user.vue +++ b/pages/user/user.vue @@ -38,7 +38,7 @@ - 128.8 + {{balance|moneyFormatter}} 余额 @@ -46,27 +46,27 @@ 优惠券 - 20 + 0 积分 - + 全部订单 - + 待付款 - + - 待收货 + 待发货 - + - 退款/售后 + 已完成 @@ -156,7 +156,7 @@ export default { }, // #endif computed: { - ...mapGetters(['hasLogin', 'nickname', 'avatar']) + ...mapGetters(['hasLogin', 'nickname', 'avatar','balance']) }, methods: { /** diff --git a/store/getters.js b/store/getters.js index 2ac4837..a009814 100644 --- a/store/getters.js +++ b/store/getters.js @@ -1,6 +1,7 @@ const getters = { hasLogin: state => state.user.hasLogin, nickname: state => state.user.nickname, - avatar: state => state.user.avatar + avatar: state => state.user.avatar, + balance: state => state.user.balance } export default getters diff --git a/store/modules/user.js b/store/modules/user.js index 549bb4c..86638ce 100644 --- a/store/modules/user.js +++ b/store/modules/user.js @@ -3,7 +3,8 @@ import { login , getUserInfo , logout } from '@/api/user' const state = { hasLogin:false, nickname: '', - avatar: '' + avatar: '', + balance:0 } const mutations = { @@ -15,7 +16,10 @@ const mutations = { }, SET_AVATAR: (state, avatar) => { state.avatar = avatar - } + }, + SET_BALANCE: (state, balance) => { + state.balance = balance + }, } const actions = { @@ -48,9 +52,10 @@ const actions = { if (!data) { reject('Verification failed, please Login again.') } - const {nickname, avatar} = data + const {nickname, avatar,balance} = data commit('SET_NICKNAME', nickname) commit('SET_AVATAR', avatar) + commit('SET_BALANCE', balance) resolve(data) }).catch(error => { reject(error) diff --git a/utils/request.js b/utils/request.js index 9a6ea05..8b090b3 100644 --- a/utils/request.js +++ b/utils/request.js @@ -66,10 +66,8 @@ service.interceptors.response.use(({ code, msg } = data - if (code && code != '00000') { if (code == 'A0230') { // token过期 - uni.showToast({ title: '会话已过期,请重新登录', success() { @@ -78,11 +76,15 @@ service.interceptors.response.use(({ }); } }) + } else { + uni.showToast({ + title: msg + }); + return Promise.reject(new Error(msg || 'Error')) } } else { return data } - }, error => { console.log('err' + error) // for debug -- Gitee From 77c25b2c50b640f5195909dbd6e9a6cd37bf5dce Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Sun, 21 Mar 2021 21:24:33 +0800 Subject: [PATCH 09/13] =?UTF-8?q?feat:=E8=AE=A2=E5=8D=95=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/ums/address.js | 11 +++++++---- pages/address/address.vue | 20 ++++++++++++-------- pages/money/pay.vue | 7 ++++++- pages/product/list.vue | 1 - store/getters.js | 3 ++- store/modules/user.js | 11 +++++++++-- 6 files changed, 36 insertions(+), 17 deletions(-) diff --git a/api/ums/address.js b/api/ums/address.js index d253a26..cbe9898 100644 --- a/api/ums/address.js +++ b/api/ums/address.js @@ -1,9 +1,12 @@ import request from '@/utils/request' -export function list() { +export function list(memberId) { return request({ url: '/mall-ums/api.app/v1/addresses', method: 'get', + params: { + memberId: memberId + }, headers: { 'auth': true // 需要认证 } @@ -23,13 +26,13 @@ export function add(data) { } -export function update(id,data) { +export function update(id, data) { return request({ - url: '/mall-ums/api.app/v1/addresses/'+id, + url: '/mall-ums/api.app/v1/addresses/' + id, method: 'put', data: data, headers: { 'auth': true // 需要认证 } }) -} \ No newline at end of file +} diff --git a/pages/address/address.vue b/pages/address/address.vue index d1c61e3..aebf4fe 100644 --- a/pages/address/address.vue +++ b/pages/address/address.vue @@ -13,9 +13,6 @@ - - 重要:添加和修改地址回调仅增加了一条数据做演示,实际开发中将回调改为请求后端接口刷新一下列表即可 - @@ -25,6 +22,9 @@ import { list } from '@/api/ums/address.js'; + import { + mapGetters + } from 'vuex'; export default { data() { @@ -33,15 +33,19 @@ addressList: [] }; }, - onLoad(option) { - console.log(option.source); - this.source = option.source; + onLoad(options) { + console.log('========>> 进入会员地址页面, 路径:', this.$mp.page.route, '参数:', options); + this.source = options.source; this.getAddressList() }, + computed: { + ...mapGetters(['memberId']) + }, methods: { getAddressList() { - list().then(response => { - console.log('地址列表', response.data) + console.log('会员ID',this.memberId) + list(this.memberId).then(response => { + console.log('获取地址数据', response.data) this.addressList = response.data; }); }, diff --git a/pages/money/pay.vue b/pages/money/pay.vue index 58af00e..d0866f2 100644 --- a/pages/money/pay.vue +++ b/pages/money/pay.vue @@ -40,6 +40,9 @@