From 860b5221a942029f50fec60dcd2cea9220af74ad Mon Sep 17 00:00:00 2001 From: Ankkaya Date: Thu, 29 Aug 2024 18:06:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=95=86=E5=93=81):=20=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20feat(=E6=88=91=E7=9A=84):=20=E6=8F=90?= =?UTF-8?q?=E7=8E=B0=EF=BC=8C=E9=92=B1=E5=8C=85=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/my.vue | 10 +- pages/product/components/item.vue | 203 ++++---- pages/product/components/propertyDetail.vue | 4 +- pages/product/components/propertyList.vue | 14 +- pages/product/js/config.js | 56 +-- pages/product/js/sku.js | 66 ++- pages/product/manageGoods.vue | 20 +- pages/user/wallet/money.vue | 476 ++++++++++-------- pages/user/wallet/withdraw.vue | 106 +++- peach/api/pay/wallet.js | 47 +- peach/api/trade/goods.js | 6 +- .../p-goods-column/p-goods-column.vue | 398 +++++++-------- peach/store/trade.js | 44 +- 13 files changed, 839 insertions(+), 611 deletions(-) diff --git a/pages/index/my.vue b/pages/index/my.vue index 58ad3df..a7d2124 100644 --- a/pages/index/my.vue +++ b/pages/index/my.vue @@ -20,13 +20,14 @@ - {{ remain }} + {{ fen2yuan(remain) }} 总获取积分 {{ userInfo.point }} + 冻结金额¥ {{ fen2yuan(freezePrice || 0) }} @@ -47,6 +48,7 @@ diff --git a/pages/product/components/propertyDetail.vue b/pages/product/components/propertyDetail.vue index fd65683..601578f 100644 --- a/pages/product/components/propertyDetail.vue +++ b/pages/product/components/propertyDetail.vue @@ -6,9 +6,9 @@ 规格名 {{ item.name }} - + 规格值 - + {{ item.name }} - + @@ -127,6 +131,7 @@ const inputFormdata = ref({ function addPropertyClick() { propertyTitle.value = '新增' inputFormdata.value.name = '' + inputFormdata.value.id = '' inputDialogRef.value.open() } @@ -160,12 +165,11 @@ defineExpose({ .popup-content { height: 500rpx; padding: 40rpx; - display: flex; - flex-wrap: wrap; - gap: 20rpx; - justify-content: flex-start; .property-item { + display: inline-block; + margin-right: 10px; + margin-bottom: 10px; text-align: center; line-height: 60rpx; height: 60rpx; diff --git a/pages/product/js/config.js b/pages/product/js/config.js index f9b7475..104ab12 100644 --- a/pages/product/js/config.js +++ b/pages/product/js/config.js @@ -1,34 +1,34 @@ export const SPEC_TYPE = [ - { - label: '单规格', - value: false, - }, - { - label: '多规格', - value: true, - }, + { + label: '单规格', + value: false, + }, + { + label: '多规格', + value: true, + }, ] // sku 相关属性校验 export const SKU_RULE_CONFIG = [ - { - name: 'stock', - rule: (arg) => arg >= 0, - message: '商品库存必须大于等于 1 !!!', - }, - { - name: 'price', - rule: (arg) => arg >= 0.01, - message: '商品销售价格必须大于等于 0.01 元!!!', - }, - { - name: 'marketPrice', - rule: (arg) => arg >= 0.01, - message: '商品市场价格必须大于等于 0.01 元!!!', - }, - { - name: 'costPrice', - rule: (arg) => arg >= 0.01, - message: '商品成本价格必须大于等于 0.00 元!!!', - }, + { + name: 'stock', + rule: (arg) => arg >= 0, + message: '商品库存必须大于等于 1 !!!', + }, + { + name: 'price', + rule: (arg) => arg >= 0.01, + message: '商品销售价格必须大于等于 0.01 元!!!', + }, + { + name: 'marketPrice', + rule: (arg) => arg >= 0.01, + message: '商品市场价格必须大于等于 0.01 元!!!', + }, + { + name: 'costPrice', + rule: (arg) => arg >= 0.01, + message: '商品成本价格必须大于等于 0.01 元!!!', + }, ] diff --git a/pages/product/js/sku.js b/pages/product/js/sku.js index 87d0e07..b65f441 100644 --- a/pages/product/js/sku.js +++ b/pages/product/js/sku.js @@ -29,11 +29,16 @@ async function showPropertyList() { } function onRDPickerConfirm(e) { - formData.value.specType = SPEC_TYPE[e.value[0]].value - formData.value.specText = SPEC_TYPE[e.value[0]].label + if (formData.value.specType !== SPEC_TYPE[e.value[0]].value) { + peach.$store('trade').specType = SPEC_TYPE[e.value[0]].value + peach.$store('trade').selectedProperty = [] - // 如果商品规格不一致,则需要重新初始化 sku 列表 - initSku() + formData.value.specType = SPEC_TYPE[e.value[0]].value + formData.value.specText = SPEC_TYPE[e.value[0]].label + + // 如果商品规格不一致,则需要重新初始化 sku 列表 + initSku() + } } function pickerProperty() { @@ -46,6 +51,7 @@ function pickerProperty() { async function onPropertyConfirm(e) { await getGoodsProperty() + changeSubProperty() } function onConfirm() { @@ -59,30 +65,32 @@ async function getGoodsProperty() { // 把 propertyList 中 id 相同的属性合并,并去重 propertyList.value = peach.$store('trade').selectedProperty || [] + let tempSkus = peach.$store('trade').skus || [] + // 根据已经选择数据,设置默认选中 + data.forEach((item) => { // 判断属性是否已经选中 let propertyParent = propertyList.value.find((sitem) => sitem?.id === item.id) item.checked = propertyParent ? true : false - // 如果属性已经选中,查询子类中是否有选中 - if (item.checked) { - item.propertyValues.forEach((child) => { - let childResult = propertyParent?.children.some((schild) => schild === child.id) - child.checked = childResult ? true : false + tempSkus.forEach((sitem) => { + sitem.properties.forEach((titem) => { + item.propertyValues.forEach((child) => { + if (!child.checked) { + child.checked = titem.valueId === child.id ? true : false + } + }) }) - } + }) }) goodsPropertyList.value = data - - console.log(goodsPropertyList.value) } function changeSubProperty() { // 修改子属性状态,需要同步更新 skus 的显示 - console.log(goodsPropertyList.value) // 过滤父属性 checked 选项,深拷贝避免后面循环改变元数据内容 let temp = JSON.parse(JSON.stringify(goodsPropertyList.value.filter((item) => item.checked))) temp.forEach((item) => { @@ -115,7 +123,32 @@ function changeSubProperty() { tempSkus.push(obj) } + tempSkus.forEach((item) => { + skus.value.forEach((sitem) => { + if (sitem.properties.length === item.properties.length && item.properties.length > 0) { + let sitemIds = sitem.properties.map((child) => child.valueId) + let itemIds = item.properties.map((tchild) => tchild.valueId) + let isExist = sitemIds.every((schild) => itemIds.includes(schild)) + + if (isExist) { + item.picUrl = sitem.picUrl + item.barCode = sitem.barCode + item.price = sitem.price + item.marketPrice = sitem.marketPrice + item.costPrice = sitem.costPrice + item.stock = sitem.stock + item.weight = sitem.weight + item.volume = sitem.volume + } + } + }) + }) + skus.value = tempSkus + + peach.$store('trade').$patch({ + skus: skus.value, + }) } /** @@ -168,6 +201,7 @@ function submitProperty() { peach.$store('trade').$patch({ skus: skus.value, specType: formData.value.specType, + isSave: true, }) peach.$router.back() } catch (e) { @@ -278,10 +312,10 @@ const inputPropertyValueFormdata = ref({ remark: '', }) function addPropertyValueClick(item) { - console.log(item) propertyValueTitle.value = '新增' inputPropertyValueFormdata.value.name = '' inputPropertyValueFormdata.value.propertyId = item.id + inputPropertyValueFormdata.value.id = '' inputPropertyValueDialogRef.value.open() } @@ -296,11 +330,12 @@ async function dialogInputPropertyValueConfirm(value) { await GoodsApi.createPropertyValue(inputPropertyValueFormdata.value) } await getGoodsProperty() + changeSubProperty() + inputPropertyValueDialogRef.value.close() } function longPropertyValuePress(item) { - console.log(item) if (canEdit.value) { // 震动提示 uni.vibrateShort() @@ -317,6 +352,7 @@ function longPropertyValuePress(item) { if (res.tapIndex === 1) { await GoodsApi.delPropertyValue({ id: item.id }) await getGoodsProperty() + changeSubProperty() } }, }) diff --git a/pages/product/manageGoods.vue b/pages/product/manageGoods.vue index dda72f8..037ed6c 100644 --- a/pages/product/manageGoods.vue +++ b/pages/product/manageGoods.vue @@ -153,7 +153,7 @@ diff --git a/pages/user/wallet/withdraw.vue b/pages/user/wallet/withdraw.vue index 096ac5a..48032ec 100644 --- a/pages/user/wallet/withdraw.vue +++ b/pages/user/wallet/withdraw.vue @@ -1,53 +1,97 @@ @@ -63,14 +107,14 @@ const state = ref({ font-size: 26rpx; .note { - color: #b5b5b5 + color: #b5b5b5; } } } } .detail { - background-color: rgba(236, 236, 236, .3); + background-color: rgba(236, 236, 236, 0.3); border-radius: 20rpx; .label { @@ -79,7 +123,6 @@ const state = ref({ } .account { - :deep(.uni-easyinput__content-input) { font-size: 28px; } @@ -95,7 +138,7 @@ const state = ref({ .account::before { content: '¥'; font-size: 48rpx; - color: #333 + color: #333; } .note { @@ -103,7 +146,16 @@ const state = ref({ font-size: 26rpx; } + .last { + color: #a3a3a3; + font-size: 26rpx; + margin-top: 5px; + } + .can-use { + color: #333; + font-size: 26rpx; + } } .footer-box { @@ -120,4 +172,4 @@ const state = ref({ } } } - \ No newline at end of file + diff --git a/peach/api/pay/wallet.js b/peach/api/pay/wallet.js index 92843c0..1e37d45 100644 --- a/peach/api/pay/wallet.js +++ b/peach/api/pay/wallet.js @@ -1,7 +1,46 @@ -import request from "@/peach/request"; +import request from '@/peach/request' const PayWalletApi = { - getWalletTransactionPage: () => {}, -}; + // 提现余额 + withdraw: (data) => { + return request({ + url: '/pay/wallet/withdraw', + method: 'post', + data, + custom: { + showSuccess: true, + successMsg: '提现成功', + }, + }) + }, -export default PayWalletApi; + // 提现配置信息 + withdrawConfig: () => { + return request({ + url: '/shop/particulars-config/get', + method: 'get', + }) + }, + + // 钱包流水记录 + flowList: (params) => { + const queryString = Object.keys(params) + .map((key) => encodeURIComponent(key) + '=' + params[key]) + .join('&') + return request({ + url: `/pay/wallet-transaction/page?${queryString}`, + method: 'get', + }) + }, + + // 钱包统计 + statistics: (params) => { + const queryString = `createTime=${params.createTime[0]}&createTime=${params.createTime[1]}` + return request({ + url: `/pay/wallet-transaction/get-summary?${queryString}`, + method: 'get', + }) + }, +} + +export default PayWalletApi diff --git a/peach/api/trade/goods.js b/peach/api/trade/goods.js index f94f11e..6ce6fde 100644 --- a/peach/api/trade/goods.js +++ b/peach/api/trade/goods.js @@ -107,7 +107,7 @@ const GoodsApi = { // 创建商品属性值 createPropertyValue: (data) => { return request({ - url: '/property/value/create', + url: '/product/property/value/create', method: 'POST', data, custom: { @@ -118,7 +118,7 @@ const GoodsApi = { // 删除商品属性值 delPropertyValue: (data) => { return request({ - url: '/property/value/delete', + url: '/product/property/value/delete', method: 'DELETE', params: data, custom: { @@ -129,7 +129,7 @@ const GoodsApi = { // 修改商品属性值 editPropertyValue: (data) => { return request({ - url: '/property/value/update', + url: '/product/property/value/update', method: 'PUT', data, custom: { diff --git a/peach/components/p-goods-column/p-goods-column.vue b/peach/components/p-goods-column/p-goods-column.vue index 8aa0af0..722a64a 100644 --- a/peach/components/p-goods-column/p-goods-column.vue +++ b/peach/components/p-goods-column/p-goods-column.vue @@ -1,58 +1,58 @@ diff --git a/peach/store/trade.js b/peach/store/trade.js index 5993c3a..7bc090c 100644 --- a/peach/store/trade.js +++ b/peach/store/trade.js @@ -2,32 +2,36 @@ import { ref, computed } from 'vue' import { defineStore } from 'pinia' const useTradeStore = defineStore('trade', () => { - // 已选择规格类型 - const selectedProperty = ref(null) + // 已选择规格类型 + const selectedProperty = ref(null) - // 商品信息 - const goodsInfo = ref(null) + // 商品信息 + const goodsInfo = ref(null) - // 详情标记 - const detailTag = ref('edit') + // 详情标记 + const detailTag = ref('edit') - // 规格类型,默认单规格 - const specType = ref(false) + // 是否触发保存操作 + const isSave = ref(false) - // 商品属性 - const skus = ref(null) + // 规格类型,默认单规格 + const specType = ref(false) - // 商品是否可编辑 - const canEdit = computed(() => (detailTag.value === 'detail' ? false : true)) + // 商品属性 + const skus = ref(null) - return { - selectedProperty, - goodsInfo, - skus, - canEdit, - detailTag, - specType, - } + // 商品是否可编辑 + const canEdit = computed(() => (detailTag.value === 'detail' ? false : true)) + + return { + selectedProperty, + goodsInfo, + skus, + canEdit, + detailTag, + specType, + isSave, + } }) export default useTradeStore