From 1fb44496929548b4f07b37796d506dedc494d44a Mon Sep 17 00:00:00 2001 From: xuxueyang <xuxy@fengyuntec.com> Date: 星期二, 30 七月 2024 17:29:35 +0800 Subject: [PATCH] update 问题修复 --- store/index.js | 75 +++++++++++++++++++++++++++++-------- 1 files changed, 59 insertions(+), 16 deletions(-) diff --git a/store/index.js b/store/index.js index 9f5be1f..4f2f98b 100644 --- a/store/index.js +++ b/store/index.js @@ -29,7 +29,8 @@ 'flower': 0, 'shopping': 0, 'follow': 0, - 'delivery': 0 + 'delivery': 0, + 'order': 0 }, defaultaddress: {} }, @@ -368,8 +369,8 @@ state }, data) { { - const resp = await http.request('post', '/api/login/customer' + (data - .phoneNumber ? '/phone' : ''), { + const resp = await http.request('post', '/api/login/customer' + ((data.phoneNumber || data + .tel) ? '/phone' : ''), { data: { username: (data.phoneNumber || data.tel) ? (data.phoneNumber || data.tel) : data.username, @@ -399,22 +400,64 @@ }, submitShopping: async function({ commit, - dispatch + dispatch, + state }, data) { - const resp = await http.request('post', '/api/customer/flower/cart/change-num', { - data: { - id: data.id, - num: 1 - } - }) - if (resp && resp.code === 0) { - message.showToast('添加购物车成功') - dispatch('sign_add', 'shopping') - } else { - + if(!state.currentInfo.id){ + message.showToast('请先登录') + return } - return resp + //输入要添加多少个 + const res = await message.confirm('', { + editable: true, + title: '请输入购买数目' + }) + if (res.content && res.confirm) { + var t = res.content + if (!isNaN(parseInt(t)) && t > 0) { + message.showLoading() + const resp = await http.request('post', '/api/customer/flower/cart/change-num', { + data: { + id: data.id, + num: parseInt(t) + } + }) + message.hideLoading() + + if (resp && resp.code === 0) { + message.showToast('添加购物车成功') + dispatch('sign_add', 'shopping') + return resp + } else { + + } + return resp + } else { + message.showToast('输入数目需要大于0') + } + } + + return { + code: 1, + data: {} + } }, + countShopping: async function({ + commit, + dispatch, + state + }, data) { + if (state.currentInfo.id) { + const resp = await http.request('get', '/api/customer/flower/cart/flower/count', {}) + if (resp && resp.code === 0) { + return resp.data || 0 + } else { + return 0 + } + } + return 0 + }, + } }) -- Gitblit v1.9.3