Merge branch 'vue3_tmp' of https://gitee.com/huizhizao/yudao-mall-uniapp into master-vue3

# Conflicts:
#	pages/index/index.vue
This commit is contained in:
YunaiV
2023-12-09 11:45:12 +08:00
25 changed files with 4404 additions and 4257 deletions
+38 -38
View File
@@ -2,41 +2,41 @@ import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default {
list: (data) =>
request2({
url: 'trade/cart/list',
method: 'GET',
custom: {
showLoading: false,
auth: true,
},
}),
append: (data) =>
request({
url: 'cart',
method: 'POST',
custom: {
showSuccess: true,
successMsg: '已添加到购物车~',
},
data: {
...data,
type: 'inc',
},
}),
// 删除购物车
delete: (ids) =>
request2({
url: 'trade/cart/delete?ids=' + ids,
method: 'DELETE',
}),
update: (data) =>
request2({
url: 'trade/cart/update-count',
method: 'PUT',
data: {
...data,
type: 'cover',
},
}),
};
list: (data) =>
request2({
url: 'trade/cart/list',
method: 'GET',
custom: {
showLoading: false,
auth: true,
},
}),
append: (data) =>
request({
url: 'cart',
method: 'POST',
custom: {
showSuccess: true,
successMsg: '已添加到购物车~',
},
data: {
...data,
type: 'inc',
},
}),
// 删除购物车
delete: (ids) =>
request2({
url: 'trade/cart/delete?ids=' + ids,
method: 'DELETE',
}),
update: (data) =>
request2({
url: 'trade/cart/update-count',
method: 'PUT',
data: {
...data,
type: 'cover',
},
}),
};
+42 -35
View File
@@ -1,38 +1,45 @@
import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default {
// 我的拼团
list: (params) =>
request({
url: 'coupon',
method: 'GET',
params,
custom: {
showLoading: false,
},
}),
userCoupon: (params) =>
request({
url: 'user/coupon',
method: 'GET',
params,
}),
detail: (id, user_coupon_id) =>
request({
url: 'coupon/' + id,
method: 'GET',
params: {
user_coupon_id,
},
}),
get: (id) =>
request({
url: 'coupon/get/' + id,
method: 'POST',
}),
listByGoods: (id) =>
request({
url: 'coupon/listByGoods/' + id,
method: 'GET',
}),
};
// 我的拼团
list: (params) =>
request({
url: 'coupon',
method: 'GET',
params,
custom: {
showLoading: false,
},
}),
userCoupon: (params) =>
request2({
url: 'promotion/coupon/page',
method: 'GET',
params,
}),
// userCoupon: (params) =>
// request({
// url: 'user/coupon',
// method: 'GET',
// params,
// }),
detail: (id, user_coupon_id) =>
request({
url: 'coupon/' + id,
method: 'GET',
params: {
user_coupon_id,
},
}),
get: (id) =>
request({
url: 'coupon/get/' + id,
method: 'POST',
}),
listByGoods: (id) =>
request({
url: 'coupon/listByGoods/' + id,
method: 'GET',
}),
};
+188 -145
View File
@@ -2,148 +2,191 @@ import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default {
// 订单详情
detail: (id,params) =>
request({
url: 'order/order/' + id,
method: 'GET',
params,
}),
// 发票详情
invoice: (id) =>
request({
url: 'order/invoice/' + id,
method: 'GET',
}),
// 获取支付结果
payResult: (id) =>
request({
url: 'order/order/' + id,
method: 'GET',
custom: {
showLoading: false,
},
}),
itemDetail: (id,itemId) =>
request({
url: 'order/order/itemDetail/'+ id + '/' + itemId,
method: 'GET',
custom: {
showLoading: false,
},
}),
// 订单列表
list: (params) =>
request2({
url: 'trade/order/page',
method: 'GET',
params,
custom: {
showLoading: false,
},
}),
// list: (params) =>
// request({
// url: 'order/order',
// method: 'GET',
// params,
// custom: {
// showLoading: false,
// },
// }),
// 计算订单信息
calc: (data) =>
request({
url: 'order/order/calc',
method: 'POST',
data,
}),
// 创建订单
create: (data) =>
request({
url: 'order/order/create',
method: 'POST',
data,
}),
//订单可用优惠券
coupons: (data) =>
request({
url: 'order/order/coupons',
method: 'POST',
data,
}),
// 确认收货
confirm: (id) =>
request({
url: 'order/order/confirm/' + id,
method: 'PUT',
}),
// 评价订单
comment: (id, data) =>
request({
url: 'order/order/comment/' + id,
method: 'POST',
data,
}),
// 申请退款
applyRefund: (id) =>
request({
url: 'order/order/applyRefund/' + id,
method: 'PUT',
}),
// 取消订单
cancel: (id) =>
request({
url: 'order/order/cancel/' + id,
method: 'PUT',
}),
// 删除订单
delete: (id) =>
request({
url: 'order/order/' + id,
method: 'DELETE',
}),
// 售后
aftersale: {
// 申请售后
apply: (data) =>
request({
url: 'order/aftersale',
method: 'POST',
data,
}),
list: (params) =>
request({
url: 'order/aftersale',
method: 'GET',
params,
custom: {
showLoading: false,
},
}),
//取消售后
cancel: (id) =>
request({
url: 'order/aftersale/cancel/' + id,
method: 'PUT',
}),
//删除售后单
delete: (id) =>
request({
url: 'order/aftersale/' + id,
method: 'DELETE',
}),
// 售后详情
detail: (id) =>
request({
url: 'order/aftersale/' + id,
method: 'GET',
}),
},
//订单包裹
express: (id, orderId) =>
request({
url: 'order/express/' + id + `${orderId ? '/' + orderId : ''}`,
method: 'GET',
}),
};
// 订单详情
detail: (id, params) =>
request2({
url: 'trade/order/get-detail?id=' + id,
method: 'GET',
params,
}),
// detail: (id, params) =>
// request({
// url: 'order/order/' + id,
// method: 'GET',
// params,
// }),
// 发票详情
invoice: (id) =>
request({
url: 'order/invoice/' + id,
method: 'GET',
}),
// 获取支付结果
payResult: (id) =>
request({
url: 'order/order/' + id,
method: 'GET',
custom: {
showLoading: false,
},
}),
itemDetail: (id, itemId) =>
request({
url: 'order/order/itemDetail/' + id + '/' + itemId,
method: 'GET',
custom: {
showLoading: false,
},
}),
// 订单列表
list: (params) =>
request2({
url: 'trade/order/page',
method: 'GET',
params,
custom: {
showLoading: false,
},
}),
// list: (params) =>
// request({
// url: 'order/order',
// method: 'GET',
// params,
// custom: {
// showLoading: false,
// },
// }),
// 计算订单信息
calc: (data) => {
const data2 = {
...data,
}
// 解决 SpringMVC 接受 List<Item> 参数的问题
delete data2.items
for (let i = 0; i < data.items.length; i++) {
// data2['items[' + i + '' + '].skuId'] = data.items[i].skuId + '';
// data2['items[' + i + '' + '].count'] = data.items[i].count + '';
// data2['items[' + i + '' + '].cartId'] = data.items[i].cartId + '';
data2['items' + `%5B${i}%5D` + '.skuId'] = data.items[i].skuId + '';
data2['items' + `%5B${i}%5D` + '.count'] = data.items[i].count + '';
data2['items' + `%5B${i}%5D` + '.cartId'] = data.items[i].cartId + '';
}
console.log(data2, '对比数据')
return request2({
url: 'trade/order/settlement',
method: 'GET',
// data,
params: data2
})
},
// calc: (data) =>
// request({
// url: 'order/order/calc',
// method: 'POST',
// data,
// }),
// 创建订单
create: (data) =>
request({
url: 'order/order/create',
method: 'POST',
data,
}),
//订单可用优惠券
coupons: (data) =>
request({
url: 'order/order/coupons',
method: 'POST',
data,
}),
// 确认收货
confirm: (id) =>
request({
url: 'order/order/confirm/' + id,
method: 'PUT',
}),
// 评价订单
comment: (data) =>
request2({
url: 'trade/order/item/create-comment',
method: 'POST',
data,
}),
// comment: (id, data) =>
// request({
// url: 'order/order/comment/' + id,
// method: 'POST',
// data,
// }),
// 申请退款
applyRefund: (id) =>
request({
url: 'order/order/applyRefund/' + id,
method: 'PUT',
}),
// 取消订单
cancel: (id) =>
request({
url: 'order/order/cancel/' + id,
method: 'PUT',
}),
// 删除订单
delete: (id) =>
request({
url: 'order/order/' + id,
method: 'DELETE',
}),
// 售后
aftersale: {
// 申请售后
apply: (data) =>
request({
url: 'order/aftersale',
method: 'POST',
data,
}),
list: (params) =>
request2({
url: 'trade/after-sale/page',
method: 'GET',
params,
custom: {
showLoading: false,
},
}),
// list: (params) =>
// request({
// url: 'order/aftersale',
// method: 'GET',
// params,
// custom: {
// showLoading: false,
// },
// }),
//取消售后
cancel: (id) =>
request({
url: 'order/aftersale/cancel/' + id,
method: 'PUT',
}),
//删除售后单
delete: (id) =>
request({
url: 'order/aftersale/' + id,
method: 'DELETE',
}),
// 售后详情
detail: (id) =>
request2({
url: 'trade/after-sale/get?id=' + id,
method: 'GET',
}),
},
//订单包裹
express: (id, orderId) =>
request({
url: 'order/express/' + id + `${orderId ? '/' + orderId : ''}`,
method: 'GET',
}),
};
+37 -11
View File
@@ -3,6 +3,15 @@ import request2 from '@/sheep/request2';
import $platform from '@/sheep/platform';
export default {
getUnused: () =>
request2({
url: 'promotion/coupon/get-unused-count',
method: 'GET',
custom: {
showLoading: false,
auth: true,
},
}),
profile: () =>
request2({
url: 'member/user/get',
@@ -187,9 +196,17 @@ export default {
}),
address: {
// default: () =>
// request({
// url: 'user/address/default',
// method: 'GET',
// custom: {
// showError: false,
// },
// }),
default: () =>
request({
url: 'user/address/default',
request2({
url: 'member/address/get-default',
method: 'GET',
custom: {
showError: false,
@@ -225,7 +242,7 @@ export default {
// showSuccess: true,
// },
// }),
update: ( data) =>
update: (data) =>
request2({
url: 'member/address/update',
method: 'PUT',
@@ -325,7 +342,7 @@ export default {
url: 'product/favorite/delete-list',
method: 'DELETE',
data: {
spuIds: id.split(',').map(item=>item*1),
spuIds: id.split(',').map(item => item * 1),
// spuIds: id.split(',').join(','),
},
custom: {
@@ -367,18 +384,27 @@ export default {
wallet: {
log: (params) =>
request2({
// url: 'member/point/record/page',
url: 'pay/wallet-transaction/page',
method: 'GET',
params,
custom: {},
}),
// log: (params) =>
// request({
// url: '/user/api/walletLog',
// method: 'GET',
// params,
// custom: {},
// }),
log2: (params) =>
request2({
url: 'member/point/record/page',
// url: 'pay/wallet-transaction/page',
method: 'GET',
params,
custom: {},
}),
// log: (params) =>
// request({
// url: '/user/api/walletLog',
// method: 'GET',
// params,
// custom: {},
// }),
},
account: {
info: (params) =>
@@ -1,80 +1,78 @@
<template>
<view class="ss-coupon-menu-wrap ss-flex ss-col-center">
<view
class="menu-item ss-flex-col ss-row-center ss-col-center"
v-for="item in props.list"
:key="item.title"
@tap="sheep.$router.go(item.path, { type: item.type })"
:class="item.type === 'all' ? 'menu-wallet' : 'ss-flex-1'"
>
<image class="item-icon" :src="sheep.$url.static(item.icon)" mode="aspectFit"></image>
<view class="menu-title ss-m-t-28">{{ item.title }}</view>
</view>
</view>
<view class="ss-coupon-menu-wrap ss-flex ss-col-center">
<view class="menu-item ss-flex-col ss-row-center ss-col-center" v-for="item in props.list" :key="item.title"
@tap="sheep.$router.go(item.path, { type: item.type })"
:class="item.type === 'all' ? 'menu-wallet' : 'ss-flex-1'">
<image class="item-icon" :src="sheep.$url.static(item.icon)" mode="aspectFit"></image>
<view class="menu-title ss-m-t-28">{{ item.title }}</view>
</view>
</view>
</template>
<script setup>
/**
* 装修组件 - 优惠券菜单
*/
import sheep from '@/sheep';
/**
* 装修组件 - 优惠券菜单
*/
import sheep from '@/sheep';
// 接收参数
const props = defineProps({
list: {
type: Array,
default() {
return [
{
title: '已领取',
value: '0',
icon: '/static/img/shop/order/nouse_coupon.png',
path: '/pages/coupon/list',
type: 'geted',
},
{
title: '已使用',
value: '0',
icon: '/static/img/shop/order/useend_coupon.png',
path: '/pages/coupon/list',
type: 'used',
},
{
title: '已失效',
value: '0',
icon: '/static/img/shop/order/out_coupon.png',
path: '/pages/coupon/list',
type: 'expired',
},
{
title: '领券中心',
value: '0',
icon: '/static/img/shop/order/all_coupon.png',
path: '/pages/coupon/list',
type: 'all',
},
];
},
},
});
// 接收参数
const props = defineProps({
list: {
type: Array,
default () {
return [{
title: '已领取',
value: '0',
icon: '/static/img/shop/order/nouse_coupon.png',
path: '/pages/coupon/list',
type: 'geted',
},
{
title: '已使用',
value: '0',
icon: '/static/img/shop/order/useend_coupon.png',
path: '/pages/coupon/list',
type: 'used',
},
{
title: '已失效',
value: '0',
icon: '/static/img/shop/order/out_coupon.png',
path: '/pages/coupon/list',
type: 'expired',
},
// {
// title: '领券中心',
// value: '0',
// icon: '/static/img/shop/order/all_coupon.png',
// path: '/pages/coupon/list',
// type: 'all',
// },
];
},
},
});
</script>
<style lang="scss" scoped>
.ss-coupon-menu-wrap {
.menu-item {
height: 160rpx;
.menu-title {
font-size: 24rpx;
line-height: 24rpx;
color: #333333;
}
.item-icon {
width: 44rpx;
height: 44rpx;
}
}
.menu-wallet {
width: 144rpx;
}
}
</style>
.ss-coupon-menu-wrap {
.menu-item {
height: 160rpx;
.menu-title {
font-size: 24rpx;
line-height: 24rpx;
color: #333333;
}
.item-icon {
width: 44rpx;
height: 44rpx;
}
}
.menu-wallet {
width: 144rpx;
}
}
</style>
+165 -162
View File
@@ -1,192 +1,195 @@
<template>
<view class="ss-m-20" :style="{ opacity: disabled ? '0.5' : '1' }">
<view class="content">
<view
<view class="ss-m-20" :style="{ opacity: disabled ? '0.5' : '1' }">
<view class="content">
<!-- <view
class="tag ss-flex ss-row-center"
:class="
data.status == 'expired' || data.status == 'used' ? 'disabled-bg-color' : 'info-bg-color'
"
>{{ data.type_text }}</view
>
<view class="title ss-m-x-30 ss-p-t-18">
<view class="ss-flex ss-row-between">
<view
class="value-text ss-flex-1 ss-m-r-10"
:class="
> -->
<view class="title ss-m-x-30 ss-p-t-18">
<view class="ss-flex ss-row-between">
<view class="value-text ss-flex-1 ss-m-r-10" :class="
data.status == 'expired' || data.status == 'used' ? 'disabled-color' : 'info-color'
"
>{{ data.name }}</view
>
<view>
<view
class="ss-flex ss-col-bottom"
:class="
">{{ data.name }}</view>
<view>
<view class="ss-flex ss-col-bottom" :class="
data.status != 'expired' && data.status != 'used' ? 'price-text' : 'disabled-color'
"
>
<view class="value-reduce ss-m-b-10" v-if="data.type === 'reduce'"></view>
<view class="value-price">{{ data.amount }}</view>
<view class="value-discount ss-m-b-10 ss-m-l-4" v-if="data.type === 'discount'"
></view
>
</view>
</view>
</view>
<view class="ss-flex ss-row-between ss-m-t-16">
<view
class="sellby-text"
:class="
">
<view class="value-reduce ss-m-b-10" v-if="data.type === 'reduce'"></view>
<view class="value-price">{{ data.amount }}</view>
<view class="value-discount ss-m-b-10 ss-m-l-4" v-if="data.type === 'discount'"></view>
</view>
</view>
</view>
<view class="ss-flex ss-row-between ss-m-t-16">
<view class="sellby-text" :class="
data.status == 'expired' || data.status == 'used'
? 'disabled-color'
: 'subtitle-color'
"
>
{{
">
{{'有效期:' + data.use_start_time.substring(0, 11) }}
{{ data.use_end_time.substring(0, 11) }}
<!-- {{
type === 'user'
? '有效期:' + data.use_start_time.substring(0, 11)
: '领取时间:' + data.get_start_time.substring(0, 11)
}}
{{
{{
type === 'user'
? data.use_end_time.substring(0, 11)
: data.get_end_time.substring(0, 11)
}}
</view>
<view
class="value-enough"
:class="
}} -->
</view>
<view class="value-enough" :class="
data.status == 'expired' || data.status == 'used'
? 'disabled-color'
: 'subtitle-color'
"
>{{ data.enough }}可用</view
>
</view>
</view>
</view>
">{{ data.enough }}可用</view>
</view>
</view>
</view>
<view class="desc ss-flex ss-row-between">
<view>
<view class="desc-title">
{{ data.description }}
</view>
<view>
<slot name="reason">
</slot>
</view>
</view>
<view>
<slot></slot>
</view>
</view>
</view>
<view class="desc ss-flex ss-row-between">
<view>
<view class="desc-title">
{{ data.description }}
</view>
<view>
<slot name="reason">
</slot>
</view>
</view>
<view>
<slot></slot>
</view>
</view>
</view>
</template>
<script setup>
import { reactive } from 'vue';
import sheep from '@/sheep';
const state = reactive({
stateMap: {
0: '立即领取',
1: '去使用',
},
});
// 接受参数
const props = defineProps({
data: {
type: Object,
default: {},
},
disabled: {
type: Boolean,
default: false,
},
type: {
type: String,
default: 'coupon',
},
});
import {
reactive
} from 'vue';
import sheep from '@/sheep';
const state = reactive({
stateMap: {
0: '立即领取',
1: '去使用',
},
});
// 接受参数
const props = defineProps({
data: {
type: Object,
default: {},
},
disabled: {
type: Boolean,
default: false,
},
type: {
type: String,
default: 'coupon',
},
});
</script>
<style lang="scss" scoped>
.info-bg-color {
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
}
.disabled-bg-color {
background: #999;
}
.info-color {
color: #333;
}
.subtitle-color {
color: #666;
}
.disabled-color {
color: #999;
}
.content {
width: 100%;
background: #fff;
border-radius: 20rpx 20rpx 0 0;
-webkit-mask: radial-gradient(circle at 12rpx 100%, #0000 12rpx, red 0) -12rpx;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.04);
.info-bg-color {
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
}
.tag {
width: 100rpx;
.disabled-bg-color {
background: #999;
}
color: #fff;
height: 40rpx;
font-size: 24rpx;
border-radius: 20rpx 0 20rpx 0;
}
.title {
padding-bottom: 22rpx;
border-bottom: 2rpx dashed #d3d3d3;
.value-text {
font-size: 32rpx;
font-weight: 600;
}
.sellby-text {
font-size: 24rpx;
font-weight: 400;
}
.value-price {
font-size: 64rpx;
font-weight: 500;
line-height: normal;
font-family: OPPOSANS;
}
.value-reduce {
line-height: normal;
font-size: 32rpx;
}
.value-discount {
line-height: normal;
font-size: 28rpx;
}
.value-enough {
font-size: 24rpx;
font-weight: 400;
font-family: OPPOSANS;
}
}
}
.desc {
width: 100%;
background: #fff;
-webkit-mask: radial-gradient(circle at 12rpx 0%, #0000 12rpx, red 0) -12rpx;
box-shadow: rgba(#000, 0.1);
box-sizing: border-box;
padding: 24rpx 30rpx;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.04);
border-radius: 0 0 20rpx 20rpx;
.desc-title {
font-size: 24rpx;
color: #999;
font-weight: 400;
}
}
.price-text {
color: #ff0000;
}
</style>
.info-color {
color: #333;
}
.subtitle-color {
color: #666;
}
.disabled-color {
color: #999;
}
.content {
width: 100%;
background: #fff;
border-radius: 20rpx 20rpx 0 0;
-webkit-mask: radial-gradient(circle at 12rpx 100%, #0000 12rpx, red 0) -12rpx;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.04);
.tag {
width: 100rpx;
color: #fff;
height: 40rpx;
font-size: 24rpx;
border-radius: 20rpx 0 20rpx 0;
}
.title {
padding-bottom: 22rpx;
border-bottom: 2rpx dashed #d3d3d3;
.value-text {
font-size: 32rpx;
font-weight: 600;
}
.sellby-text {
font-size: 24rpx;
font-weight: 400;
}
.value-price {
font-size: 64rpx;
font-weight: 500;
line-height: normal;
font-family: OPPOSANS;
}
.value-reduce {
line-height: normal;
font-size: 32rpx;
}
.value-discount {
line-height: normal;
font-size: 28rpx;
}
.value-enough {
font-size: 24rpx;
font-weight: 400;
font-family: OPPOSANS;
}
}
}
.desc {
width: 100%;
background: #fff;
-webkit-mask: radial-gradient(circle at 12rpx 0%, #0000 12rpx, red 0) -12rpx;
box-shadow: rgba(#000, 0.1);
box-sizing: border-box;
padding: 24rpx 30rpx;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.04);
border-radius: 0 0 20rpx 20rpx;
.desc-title {
font-size: 24rpx;
color: #999;
font-weight: 400;
}
}
.price-text {
color: #ff0000;
}
</style>
+396 -414
View File
@@ -1,476 +1,458 @@
<template>
<!-- 规格弹窗 -->
<su-popup :show="show" round="10" @close="emits('close')">
<view class="ss-modal-box bg-white ss-flex-col">
<view class="modal-header ss-flex ss-col-center">
<view class="header-left ss-m-r-30">
<image
class="sku-image"
:src="sheep.$url.cdn(state.selectedSkuPrice.image || goodsInfo.image)"
mode="aspectFill"
></image>
</view>
<view class="header-right ss-flex-col ss-row-between ss-flex-1">
<view class="goods-title ss-line-2">{{ goodsInfo.title }}</view>
<view class="header-right-bottom ss-flex ss-col-center ss-row-between">
<view class="ss-flex">
<view v-if="goodsPrice.price > 0" class="price-text">
{{ goodsPrice.price }}
</view>
<view class="ss-flex">
<view
v-if="goodsPrice.price > 0 && goodsPrice.score > 0"
class="score-text ss-m-l-4"
>+
</view>
<image
v-if="goodsPrice.score > 0"
:src="sheep.$url.static('/static/img/shop/goods/score1.svg')"
class="score-img"
>
</image>
<view v-if="goodsPrice.score > 0" class="score-text">
{{ goodsPrice.score }}
</view>
</view>
</view>
<!-- 规格弹窗 -->
<su-popup :show="show" round="10" @close="emits('close')">
<view class="ss-modal-box bg-white ss-flex-col">
<view class="modal-header ss-flex ss-col-center">
<view class="header-left ss-m-r-30">
<image class="sku-image" :src="sheep.$url.cdn(state.selectedSkuPrice.image || goodsInfo.image)"
mode="aspectFill"></image>
</view>
<view class="header-right ss-flex-col ss-row-between ss-flex-1">
<view class="goods-title ss-line-2">{{ goodsInfo.title }}</view>
<view class="header-right-bottom ss-flex ss-col-center ss-row-between">
<view class="ss-flex">
<view v-if="goodsPrice.price > 0" class="price-text">
{{ goodsPrice.price }}
</view>
<view class="ss-flex">
<view v-if="goodsPrice.price > 0 && goodsPrice.score > 0" class="score-text ss-m-l-4">+
</view>
<image v-if="goodsPrice.score > 0"
:src="sheep.$url.static('/static/img/shop/goods/score1.svg')" class="score-img">
</image>
<view v-if="goodsPrice.score > 0" class="score-text">
{{ goodsPrice.score }}
</view>
</view>
</view>
<view class="stock-text ss-m-l-20">
{{
<view class="stock-text ss-m-l-20">
{{
state.selectedSkuPrice.stock
? formatStock(goodsInfo.stock_show_type, state.selectedSkuPrice.stock)
: formatStock(goodsInfo.stock_show_type, goodsInfo.stock)
}}
</view>
</view>
</view>
</view>
<view class="modal-content ss-flex-1">
<scroll-view scroll-y="true" class="modal-content-scroll" @touchmove.stop>
<view class="sku-item ss-m-b-20" v-for="sku1 in goodsInfo.skus" :key="sku1.id">
<view class="label-text ss-m-b-20">{{ sku1.name }}</view>
<view class="ss-flex ss-col-center ss-flex-wrap">
<button
class="ss-reset-button spec-btn"
v-for="sku2 in sku1.children"
:class="[
</view>
</view>
</view>
</view>
<view class="modal-content ss-flex-1">
<scroll-view scroll-y="true" class="modal-content-scroll" @touchmove.stop>
<view class="sku-item ss-m-b-20" v-for="sku1 in goodsInfo.skus" :key="sku1.id">
<view class="label-text ss-m-b-20">{{ sku1.name }}</view>
<view class="ss-flex ss-col-center ss-flex-wrap">
<button class="ss-reset-button spec-btn" v-for="sku2 in sku1.children" :class="[
{
'ui-BG-Main-Gradient': state.currentSkuArray[sku2.parent_id] == sku2.id,
},
{
'disabled-btn': sku2.disabled == true,
},
]"
:key="sku2.id"
:disabled="sku2.disabled == true"
@tap="onSelectSku(sku2.parent_id, sku2.id)"
>
{{ sku2.name }}
</button>
</view>
</view>
<view class="buy-num-box ss-flex ss-col-center ss-row-between ss-m-b-40">
<view class="label-text">购买数量</view>
<su-number-box
:min="1"
:max="state.selectedSkuPrice.stock"
:step="1"
v-model="state.selectedSkuPrice.goods_num"
@change="onNumberChange($event)"
></su-number-box>
</view>
</scroll-view>
</view>
<view class="modal-footer border-top">
<view
class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center"
v-if="isScore"
>
<button class="ss-reset-button score-btn ui-Shadow-Main" @tap="onBuy">立即兑换</button>
</view>
<view class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center" v-else>
<button class="ss-reset-button add-btn ui-Shadow-Main" @tap="onAddCart"
>加入购物车</button
>
<button class="ss-reset-button buy-btn ui-Shadow-Main" @tap="onBuy">立即购买</button>
</view>
</view>
</view>
</su-popup>
]" :key="sku2.id" :disabled="sku2.disabled == true" @tap="onSelectSku(sku2.parent_id, sku2.id)">
{{ sku2.name }}
</button>
</view>
</view>
<view class="buy-num-box ss-flex ss-col-center ss-row-between ss-m-b-40">
<view class="label-text">购买数量</view>
<su-number-box :min="1" :max="state.selectedSkuPrice.stock" :step="1"
v-model="state.selectedSkuPrice.goods_num" @change="onNumberChange($event)"></su-number-box>
</view>
</scroll-view>
</view>
<view class="modal-footer border-top">
<view class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center" v-if="isScore">
<button class="ss-reset-button score-btn ui-Shadow-Main" @tap="onBuy">立即兑换</button>
</view>
<view class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center" v-else>
<button class="ss-reset-button add-btn ui-Shadow-Main" @tap="onAddCart">加入购物车</button>
<button class="ss-reset-button buy-btn ui-Shadow-Main" @tap="onBuy">立即购买</button>
</view>
</view>
</view>
</su-popup>
</template>
<script setup>
import { computed, reactive, watch } from 'vue';
import sheep from '@/sheep';
import { formatStock, formatPrice } from '@/sheep/hooks/useGoods';
import { isEmpty } from 'lodash';
import {
computed,
reactive,
watch
} from 'vue';
import sheep from '@/sheep';
import {
formatStock,
formatPrice
} from '@/sheep/hooks/useGoods';
import {
isEmpty
} from 'lodash';
const emits = defineEmits(['change', 'addCart', 'buy', 'close']);
const props = defineProps({
goodsInfo: {
type: Object,
default() {},
},
show: {
type: Boolean,
default: false,
},
isScore: {
type: Boolean,
default: false,
},
});
const emits = defineEmits(['change', 'addCart', 'buy', 'close']);
const props = defineProps({
goodsInfo: {
type: Object,
default () {},
},
show: {
type: Boolean,
default: false,
},
isScore: {
type: Boolean,
default: false,
},
});
const state = reactive({
selectedSkuPrice: {},
currentSkuArray: [],
});
//输入框改变数量
function onNumberChange(e) {
if (e === 0) return;
if (state.selectedSkuPrice.goods_num === e) return;
state.selectedSkuPrice.goods_num = e;
}
// 默认单规格
if (!props.goodsInfo.is_sku) {
state.selectedSkuPrice = props.goodsInfo.sku_prices[0];
}
const state = reactive({
selectedSkuPrice: {},
currentSkuArray: [],
});
//输入框改变数量
function onNumberChange(e) {
if (e === 0) return;
if (state.selectedSkuPrice.goods_num === e) return;
state.selectedSkuPrice.goods_num = e;
}
// 默认单规格
if (!props.goodsInfo.is_sku) {
state.selectedSkuPrice = props.goodsInfo.sku_prices[0];
}
const skuList = props.goodsInfo.skus;
const skuList = props.goodsInfo.skus;
// 可选规格
const skuPrices = computed(() => {
let skuPrices = props.goodsInfo.sku_prices;
if (props.goodsInfo.is_sku) {
skuPrices.forEach((item) => {
item.goods_sku_id_arr = item.goods_sku_ids.split(',');
});
}
return skuPrices;
});
// 可选规格
const skuPrices = computed(() => {
let skuPrices = props.goodsInfo.sku_prices;
if (props.goodsInfo.is_sku) {
skuPrices.forEach((item) => {
item.goods_sku_id_arr = item.goods_sku_ids.split(',');
});
}
return skuPrices;
});
watch(
() => state.selectedSkuPrice,
(newVal) => {
emits('change', newVal);
},
{
immediate: true, // 立即执行
deep: true, // 深度监听
},
);
watch(
() => state.selectedSkuPrice,
(newVal) => {
emits('change', newVal);
}, {
immediate: true, // 立即执行
deep: true, // 深度监听
},
);
const goodsPrice = computed(() => {
let price, score;
if (isEmpty(state.selectedSkuPrice)) {
price = props.goodsInfo.price[0];
score = props.goodsInfo.score || 0;
} else {
price = state.selectedSkuPrice.price;
score = state.selectedSkuPrice.score || 0;
}
return {
price,
score,
};
});
const goodsPrice = computed(() => {
let price, score;
if (isEmpty(state.selectedSkuPrice)) {
price = props.goodsInfo.price[0];
score = props.goodsInfo.score || 0;
} else {
price = state.selectedSkuPrice.price;
score = state.selectedSkuPrice.score || 0;
}
return {
price,
score,
};
});
function onAddCart() {
if (state.selectedSkuPrice.goods_id) {
if (state.selectedSkuPrice.stock <= 0) {
sheep.$helper.toast('库存不足');
} else {
emits('addCart', state.selectedSkuPrice);
}
} else {
sheep.$helper.toast('请选择规格');
}
}
function onAddCart() {
if (state.selectedSkuPrice.goods_id) {
if (state.selectedSkuPrice.stock <= 0) {
sheep.$helper.toast('库存不足');
} else {
emits('addCart', state.selectedSkuPrice);
}
} else {
sheep.$helper.toast('请选择规格');
}
}
function onBuy() {
if (state.selectedSkuPrice.goods_id) {
if (state.selectedSkuPrice.stock <= 0) {
sheep.$helper.toast('库存不足');
} else {
emits('buy', state.selectedSkuPrice);
}
} else {
sheep.$helper.toast('请选择规格');
}
}
// 改变禁用状态
function changeDisabled(isChecked = false, pid = 0, skuId = 0) {
let newPrice = []; // 所有可以选择的 skuPrice
function onBuy() {
if (state.selectedSkuPrice.goods_id) {
if (state.selectedSkuPrice.stock <= 0) {
sheep.$helper.toast('库存不足');
} else {
emits('buy', state.selectedSkuPrice);
}
} else {
sheep.$helper.toast('请选择规格');
}
}
// 改变禁用状态
function changeDisabled(isChecked = false, pid = 0, skuId = 0) {
let newPrice = []; // 所有可以选择的 skuPrice
if (isChecked) {
// 选中规格
// 当前点击选中规格下的 所有可用 skuPrice
for (let price of skuPrices.value) {
if (price.stock <= 0) {
// this.goodsNum 不判断是否大于当前选择数量,在 uni-number-box 判断,并且 取 stock 和 goods_num 的小值
continue;
}
if (price.goods_sku_id_arr.indexOf(skuId.toString()) >= 0) {
newPrice.push(price);
}
}
} else {
// 取消选中
// 当前所选规格下,所有可以选择的 skuPrice
newPrice = getCanUseSkuPrice();
}
if (isChecked) {
// 选中规格
// 当前点击选中规格下的 所有可用 skuPrice
for (let price of skuPrices.value) {
if (price.stock <= 0) {
// this.goodsNum 不判断是否大于当前选择数量,在 uni-number-box 判断,并且 取 stock 和 goods_num 的小值
continue;
}
if (price.goods_sku_id_arr.indexOf(skuId.toString()) >= 0) {
newPrice.push(price);
}
}
} else {
// 取消选中
// 当前所选规格下,所有可以选择的 skuPrice
newPrice = getCanUseSkuPrice();
}
// 所有存在并且有库存未选择的规格项 的 子项 id
let noChooseSkuIds = [];
for (let price of newPrice) {
noChooseSkuIds = noChooseSkuIds.concat(price.goods_sku_id_arr);
}
// 所有存在并且有库存未选择的规格项 的 子项 id
let noChooseSkuIds = [];
for (let price of newPrice) {
noChooseSkuIds = noChooseSkuIds.concat(price.goods_sku_id_arr);
}
// 去重
noChooseSkuIds = Array.from(new Set(noChooseSkuIds));
// 去重
noChooseSkuIds = Array.from(new Set(noChooseSkuIds));
if (isChecked) {
// 去除当前选中的规格项
let index = noChooseSkuIds.indexOf(skuId.toString());
noChooseSkuIds.splice(index, 1);
} else {
// 循环去除当前已选择的规格项
state.currentSkuArray.forEach((sku) => {
if (sku.toString() != '') {
// sku 为空是反选 填充的
let index = noChooseSkuIds.indexOf(sku.toString());
if (index >= 0) {
// sku 存在于 noChooseSkuIds
noChooseSkuIds.splice(index, 1);
}
}
});
}
if (isChecked) {
// 去除当前选中的规格项
let index = noChooseSkuIds.indexOf(skuId.toString());
noChooseSkuIds.splice(index, 1);
} else {
// 循环去除当前已选择的规格项
state.currentSkuArray.forEach((sku) => {
if (sku.toString() != '') {
// sku 为空是反选 填充的
let index = noChooseSkuIds.indexOf(sku.toString());
if (index >= 0) {
// sku 存在于 noChooseSkuIds
noChooseSkuIds.splice(index, 1);
}
}
});
}
// 当前已选择的规格大类
let chooseSkuKey = [];
if (!isChecked) {
// 当前已选择的规格大类
state.currentSkuArray.forEach((sku, key) => {
if (sku != '') {
// sku 为空是反选 填充的
chooseSkuKey.push(key);
}
});
} else {
// 当前点击选择的规格大类
chooseSkuKey = [pid];
}
// 当前已选择的规格大类
let chooseSkuKey = [];
if (!isChecked) {
// 当前已选择的规格大类
state.currentSkuArray.forEach((sku, key) => {
if (sku != '') {
// sku 为空是反选 填充的
chooseSkuKey.push(key);
}
});
} else {
// 当前点击选择的规格大类
chooseSkuKey = [pid];
}
for (let i in skuList) {
// 当前点击的规格,或者取消选择时候 已选中的规格 不进行处理
if (chooseSkuKey.indexOf(skuList[i]['id']) >= 0) {
continue;
}
for (let i in skuList) {
// 当前点击的规格,或者取消选择时候 已选中的规格 不进行处理
if (chooseSkuKey.indexOf(skuList[i]['id']) >= 0) {
continue;
}
for (let j in skuList[i]['children']) {
// 如果当前规格项 id 不存在于有库存的规格项中,则禁用
if (noChooseSkuIds.indexOf(skuList[i]['children'][j]['id'].toString()) >= 0) {
skuList[i]['children'][j]['disabled'] = false;
} else {
skuList[i]['children'][j]['disabled'] = true;
}
}
}
}
// 当前所选规格下,获取所有有库存的 skuPrice
function getCanUseSkuPrice() {
let newPrice = [];
for (let j in skuList[i]['children']) {
// 如果当前规格项 id 不存在于有库存的规格项中,则禁用
if (noChooseSkuIds.indexOf(skuList[i]['children'][j]['id'].toString()) >= 0) {
skuList[i]['children'][j]['disabled'] = false;
} else {
skuList[i]['children'][j]['disabled'] = true;
}
}
}
}
// 当前所选规格下,获取所有有库存的 skuPrice
function getCanUseSkuPrice() {
let newPrice = [];
for (let price of skuPrices.value) {
if (price.stock <= 0) {
// || price.stock < this.goodsNum 不判断是否大于当前选择数量,在 uni-number-box 判断,并且 取 stock 和 goods_num 的小值
continue;
}
var isOk = true;
for (let price of skuPrices.value) {
if (price.stock <= 0) {
// || price.stock < this.goodsNum 不判断是否大于当前选择数量,在 uni-number-box 判断,并且 取 stock 和 goods_num 的小值
continue;
}
var isOk = true;
state.currentSkuArray.forEach((sku) => {
// sku 不为空,并且,这个 条 skuPrice 没有被选中,则排除
if (sku.toString() != '' && price.goods_sku_id_arr.indexOf(sku.toString()) < 0) {
isOk = false;
}
});
state.currentSkuArray.forEach((sku) => {
// sku 不为空,并且,这个 条 skuPrice 没有被选中,则排除
if (sku.toString() != '' && price.goods_sku_id_arr.indexOf(sku.toString()) < 0) {
isOk = false;
}
});
if (isOk) {
newPrice.push(price);
}
}
if (isOk) {
newPrice.push(price);
}
}
return newPrice;
}
// 选择规格
function onSelectSku(pid, skuId) {
// 清空已选择
let isChecked = true; // 选中 or 取消选中
if (state.currentSkuArray[pid] != undefined && state.currentSkuArray[pid] == skuId) {
// 点击已被选中的,删除并填充 ''
isChecked = false;
state.currentSkuArray.splice(pid, 1, '');
} else {
// 选中
state.currentSkuArray[pid] = skuId;
}
return newPrice;
}
// 选择规格
function onSelectSku(pid, skuId) {
// 清空已选择
let isChecked = true; // 选中 or 取消选中
if (state.currentSkuArray[pid] != undefined && state.currentSkuArray[pid] == skuId) {
// 点击已被选中的,删除并填充 ''
isChecked = false;
state.currentSkuArray.splice(pid, 1, '');
} else {
// 选中
state.currentSkuArray[pid] = skuId;
}
let chooseSkuId = []; // 选中的规格大类
state.currentSkuArray.forEach((sku) => {
if (sku != '') {
// sku 为空是反选 填充的
chooseSkuId.push(sku);
}
});
let chooseSkuId = []; // 选中的规格大类
state.currentSkuArray.forEach((sku) => {
if (sku != '') {
// sku 为空是反选 填充的
chooseSkuId.push(sku);
}
});
// 当前所选规格下,所有可以选择的 skuPric
let newPrice = getCanUseSkuPrice();
// 当前所选规格下,所有可以选择的 skuPric
let newPrice = getCanUseSkuPrice();
// 判断所有规格大类是否选择完成
if (chooseSkuId.length == skuList.length && newPrice.length) {
newPrice[0].goods_num = state.selectedSkuPrice.goods_num || 1;
state.selectedSkuPrice = newPrice[0];
} else {
state.selectedSkuPrice = {};
}
// 判断所有规格大类是否选择完成
if (chooseSkuId.length == skuList.length && newPrice.length) {
newPrice[0].goods_num = state.selectedSkuPrice.goods_num || 1;
state.selectedSkuPrice = newPrice[0];
} else {
state.selectedSkuPrice = {};
}
// 改变规格项禁用状态
changeDisabled(isChecked, pid, skuId);
}
// 改变规格项禁用状态
changeDisabled(isChecked, pid, skuId);
}
changeDisabled(false);
changeDisabled(false);
</script>
<style lang="scss" scoped>
// 购买
.buy-box {
padding: 10rpx 0;
// 购买
.buy-box {
padding: 10rpx 0;
.add-btn {
width: 356rpx;
height: 80rpx;
border-radius: 40rpx 0 0 40rpx;
background-color: var(--ui-BG-Main-light);
color: var(--ui-BG-Main);
}
.add-btn {
width: 356rpx;
height: 80rpx;
border-radius: 40rpx 0 0 40rpx;
background-color: var(--ui-BG-Main-light);
color: var(--ui-BG-Main);
}
.buy-btn {
width: 356rpx;
height: 80rpx;
border-radius: 0 40rpx 40rpx 0;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: #fff;
}
.buy-btn {
width: 356rpx;
height: 80rpx;
border-radius: 0 40rpx 40rpx 0;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: #fff;
}
.score-btn {
width: 100%;
margin: 0 20rpx;
height: 80rpx;
border-radius: 40rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: #fff;
}
}
.score-btn {
width: 100%;
margin: 0 20rpx;
height: 80rpx;
border-radius: 40rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: #fff;
}
}
.ss-modal-box {
border-radius: 30rpx 30rpx 0 0;
max-height: 1000rpx;
.ss-modal-box {
border-radius: 30rpx 30rpx 0 0;
max-height: 1000rpx;
.modal-header {
position: relative;
padding: 80rpx 20rpx 40rpx;
.modal-header {
position: relative;
padding: 80rpx 20rpx 40rpx;
.sku-image {
width: 160rpx;
height: 160rpx;
border-radius: 10rpx;
}
.sku-image {
width: 160rpx;
height: 160rpx;
border-radius: 10rpx;
}
.header-right {
height: 160rpx;
}
.header-right {
height: 160rpx;
}
.close-icon {
position: absolute;
top: 10rpx;
right: 20rpx;
font-size: 46rpx;
opacity: 0.2;
}
.close-icon {
position: absolute;
top: 10rpx;
right: 20rpx;
font-size: 46rpx;
opacity: 0.2;
}
.goods-title {
font-size: 28rpx;
font-weight: 500;
line-height: 42rpx;
}
.goods-title {
font-size: 28rpx;
font-weight: 500;
line-height: 42rpx;
}
.score-img {
width: 36rpx;
height: 36rpx;
margin: 0 4rpx;
}
.score-img {
width: 36rpx;
height: 36rpx;
margin: 0 4rpx;
}
.score-text {
font-size: 30rpx;
font-weight: 500;
color: $red;
font-family: OPPOSANS;
}
.score-text {
font-size: 30rpx;
font-weight: 500;
color: $red;
font-family: OPPOSANS;
}
.price-text {
font-size: 30rpx;
font-weight: 500;
color: $red;
font-family: OPPOSANS;
.price-text {
font-size: 30rpx;
font-weight: 500;
color: $red;
font-family: OPPOSANS;
&::before {
content: '¥';
font-size: 30rpx;
font-weight: 500;
color: $red;
}
}
&::before {
content: '¥';
font-size: 30rpx;
font-weight: 500;
color: $red;
}
}
.stock-text {
font-size: 26rpx;
color: #999999;
}
}
.stock-text {
font-size: 26rpx;
color: #999999;
}
}
.modal-content {
padding: 0 20rpx;
.modal-content {
padding: 0 20rpx;
.modal-content-scroll {
max-height: 600rpx;
.modal-content-scroll {
max-height: 600rpx;
.label-text {
font-size: 26rpx;
font-weight: 500;
}
.label-text {
font-size: 26rpx;
font-weight: 500;
}
.buy-num-box {
height: 100rpx;
}
.buy-num-box {
height: 100rpx;
}
.spec-btn {
height: 60rpx;
min-width: 100rpx;
padding: 0 30rpx;
background: #f4f4f4;
border-radius: 30rpx;
color: #434343;
font-size: 26rpx;
margin-right: 10rpx;
margin-bottom: 10rpx;
}
.spec-btn {
height: 60rpx;
min-width: 100rpx;
padding: 0 30rpx;
background: #f4f4f4;
border-radius: 30rpx;
color: #434343;
font-size: 26rpx;
margin-right: 10rpx;
margin-bottom: 10rpx;
}
.disabled-btn {
font-weight: 400;
color: #c6c6c6;
background: #f8f8f8;
}
}
}
}
</style>
.disabled-btn {
font-weight: 400;
color: #c6c6c6;
background: #f8f8f8;
}
}
}
}
</style>
+136 -133
View File
@@ -1,34 +1,31 @@
<!-- 页面 -->
<template>
<view class="ss-user-info-wrap ss-p-t-50">
<view class="ss-flex ss-col-center ss-row-between ss-m-b-20">
<view class="left-box ss-flex ss-col-center ss-m-l-36">
<view class="avatar-box ss-m-r-24">
<image
class="avatar-img"
:src="
<view class="ss-user-info-wrap ss-p-t-50">
<view class="ss-flex ss-col-center ss-row-between ss-m-b-20">
<view class="left-box ss-flex ss-col-center ss-m-l-36">
<view class="avatar-box ss-m-r-24">
<image class="avatar-img" :src="
isLogin
? sheep.$url.cdn(userInfo.avatar)
: sheep.$url.static('/static/img/shop/default_avatar.png')
"
mode="aspectFill"
@tap="sheep.$router.go('/pages/user/info')"
></image>
</view>
<view>
<view class="nickname-box ss-flex ss-col-center">
<view class="nick-name ss-m-r-20">{{ userInfo?.nickname || nickname }}</view>
</view>
</view>
</view>
<view class="right-box ss-m-r-52">
<button class="ss-reset-button" @tap="showShareModal">
<text class="sicon-qrcode"></text>
</button>
</view>
</view>
" mode="aspectFill" @tap="sheep.$router.go('/pages/user/info')"></image>
</view>
<view>
<view class="nickname-box ss-flex ss-col-center">
<view class="nick-name ss-m-r-20">{{ userInfo?.nickname || nickname }}</view>
</view>
</view>
</view>
<view class="right-box ss-m-r-52">
<button class="ss-reset-button" @tap="showShareModal">
<text class="sicon-qrcode"></text>
</button>
</view>
</view>
<view
<!-- 提示绑定手机号 先隐藏 yudao 需要再修改 -->
<!-- <view
class="bind-mobile-box ss-flex ss-row-between ss-col-center"
v-if="isLogin && !userInfo.verification?.mobile"
>
@@ -37,129 +34,135 @@
<view class="mobile-title ss-m-l-20"> 点击绑定手机号确保账户安全 </view>
</view>
<button class="ss-reset-button bind-btn" @tap="onBind">去绑定</button>
</view>
</view>
</view> -->
</view>
</template>
<script setup>
/**
* 用户卡片
*
* @property {Number} leftSpace - 容器左间距
* @property {Number} rightSpace - 容器右间距
*
* @property {String} avatar - 头像
* @property {String} nickname - 昵称
* @property {String} vip - 等级
* @property {String} collectNum - 收藏数
* @property {String} likeNum - 点赞数
*
*
*/
import { computed, reactive } from 'vue';
import sheep from '@/sheep';
import { showShareModal, showAuthModal } from '@/sheep/hooks/useModal';
/**
* 用户卡片
*
* @property {Number} leftSpace - 容器左间距
* @property {Number} rightSpace - 容器右间距
*
* @property {String} avatar - 头像
* @property {String} nickname - 昵称
* @property {String} vip - 等级
* @property {String} collectNum - 收藏数
* @property {String} likeNum - 点赞数
*
*
*/
import {
computed,
reactive
} from 'vue';
import sheep from '@/sheep';
import {
showShareModal,
showAuthModal
} from '@/sheep/hooks/useModal';
// 用户信息
const userInfo = computed(() => sheep.$store('user').userInfo);
console.log('用户信息',userInfo)
// 用户信息
const userInfo = computed(() => sheep.$store('user').userInfo);
console.log('用户信息', userInfo)
// 是否登录
const isLogin = computed(() => sheep.$store('user').isLogin);
// 接收参数
const props = defineProps({
background: {
type: String,
default: '',
},
// 头像
avatar: {
type: String,
default: '',
},
nickname: {
type: String,
default: '请先登录',
},
vip: {
type: [String, Number],
default: '1',
},
collectNum: {
type: [String, Number],
default: '1',
},
likeNum: {
type: [String, Number],
default: '1',
},
});
// 是否登录
const isLogin = computed(() => sheep.$store('user').isLogin);
// 接收参数
const props = defineProps({
background: {
type: String,
default: '',
},
// 头像
avatar: {
type: String,
default: '',
},
nickname: {
type: String,
default: '请先登录',
},
vip: {
type: [String, Number],
default: '1',
},
collectNum: {
type: [String, Number],
default: '1',
},
likeNum: {
type: [String, Number],
default: '1',
},
});
function onBind() {
showAuthModal('changeMobile');
}
function onBind() {
showAuthModal('changeMobile');
}
</script>
<style lang="scss" scoped>
.ss-user-info-wrap {
box-sizing: border-box;
.ss-user-info-wrap {
box-sizing: border-box;
.avatar-box {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
overflow: hidden;
.avatar-box {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
overflow: hidden;
.avatar-img {
width: 100%;
height: 100%;
}
}
.avatar-img {
width: 100%;
height: 100%;
}
}
.nick-name {
font-size: 34rpx;
font-weight: 400;
color: #333333;
line-height: normal;
}
.nick-name {
font-size: 34rpx;
font-weight: 400;
color: #333333;
line-height: normal;
}
.vip-img {
width: 30rpx;
height: 30rpx;
}
.vip-img {
width: 30rpx;
height: 30rpx;
}
.sicon-qrcode {
font-size: 40rpx;
}
}
.sicon-qrcode {
font-size: 40rpx;
}
}
.bind-mobile-box {
width: 100%;
height: 84rpx;
padding: 0 34rpx 0 44rpx;
box-sizing: border-box;
background: #ffffff;
box-shadow: 0px -8rpx 9rpx 0px rgba(#e0e0e0, 0.3);
.bind-mobile-box {
width: 100%;
height: 84rpx;
padding: 0 34rpx 0 44rpx;
box-sizing: border-box;
background: #ffffff;
box-shadow: 0px -8rpx 9rpx 0px rgba(#e0e0e0, 0.3);
.cicon-mobile-o {
font-size: 30rpx;
color: #ff690d;
}
.cicon-mobile-o {
font-size: 30rpx;
color: #ff690d;
}
.mobile-title {
font-size: 24rpx;
font-weight: 500;
color: #ff690d;
}
.mobile-title {
font-size: 24rpx;
font-weight: 500;
color: #ff690d;
}
.bind-btn {
width: 100rpx;
height: 50rpx;
background: #ff6100;
border-radius: 25rpx;
font-size: 24rpx;
font-weight: 500;
color: #ffffff;
}
}
</style>
.bind-btn {
width: 100rpx;
height: 50rpx;
background: #ff6100;
border-radius: 25rpx;
font-size: 24rpx;
font-weight: 500;
color: #ffffff;
}
}
</style>
@@ -1,4 +1,16 @@
<template>
<<<<<<< HEAD
<view class="ss-wallet-menu-wrap ss-flex ss-col-center">
<view class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center"
@tap="sheep.$router.go('/pages/user/wallet/money')">
<view class="value-box ss-flex ss-col-bottom">
<view class="value-text ss-line-1">{{ userInfo.money }}</view>
<view class="unit-text ss-m-l-6"></view>
</view>
<view class="menu-title ss-m-t-28">账户余额</view>
</view>
<!-- <view class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center"
=======
<view class="ss-wallet-menu-wrap ss-flex ss-col-center">
<view
class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center"
@@ -11,6 +23,7 @@
<view class="menu-title ss-m-t-28">账户余额</view>
</view>
<!-- <view class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center"
>>>>>>> 6251ffa9944516e995002e7f11539aef3e1d50de
@tap="sheep.$router.go('/pages/user/wallet/commission')">
<view class="value-box ss-flex ss-col-bottom">
<view class="value-text">{{ userInfo?.commission || '0.00' }}</view>
@@ -18,6 +31,34 @@
</view>
<view class="menu-title ss-m-t-28">佣金</view>
</view> -->
<<<<<<< HEAD
<view class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center"
@tap="sheep.$router.go('/pages/user/wallet/score')">
<view class="value-box ss-flex ss-col-bottom">
<view class="value-text">{{ userInfo.point }}</view>
<view class="unit-text ss-m-l-6"></view>
</view>
<view class="menu-title ss-m-t-28">积分</view>
</view>
<view class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center" @tap="
sheep.$router.go('/pages/coupon/list', {
type: 'geted',
})
">
<view class="value-box ss-flex ss-col-bottom">
<view class="value-text">{{ numData.coupons_num }}</view>
<view class="unit-text ss-m-l-6"></view>
</view>
<view class="menu-title ss-m-t-28">优惠券</view>
</view>
<view class="menu-item ss-flex-col ss-row-center ss-col-center menu-wallet"
@tap="sheep.$router.go('/pages/user/wallet/money')">
<image class="item-icon" :src="sheep.$url.static('/static/img/shop/user/wallet_icon.png')" mode="aspectFit">
</image>
<view class="menu-title ss-m-t-30">我的钱包</view>
</view>
</view>
=======
<view
class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center"
@tap="sheep.$router.go('/pages/user/wallet/score')"
@@ -55,56 +96,61 @@
<view class="menu-title ss-m-t-30">我的钱包</view>
</view>
</view>
>>>>>>> 6251ffa9944516e995002e7f11539aef3e1d50de
</template>
<script setup>
/**
* 装修组件 - 订单菜单组
*/
import { computed, ref } from 'vue';
import sheep from '@/sheep';
/**
* 装修组件 - 订单菜单组
*/
import {
computed,
ref
} from 'vue';
import sheep from '@/sheep';
const userInfo = computed(() => sheep.$store('user').userInfo);
const numData = computed(() => sheep.$store('user').numData);
const userInfo = computed(() => sheep.$store('user').userInfo);
const numData = computed(() => sheep.$store('user').numData);
</script>
<style lang="scss" scoped>
.ss-wallet-menu-wrap {
.menu-wallet {
width: 144rpx;
}
.menu-item {
height: 160rpx;
.ss-wallet-menu-wrap {
.menu-wallet {
width: 144rpx;
}
.menu-title {
font-size: 24rpx;
line-height: 24rpx;
color: #333333;
}
.menu-item {
height: 160rpx;
.item-icon {
width: 44rpx;
height: 44rpx;
}
.menu-title {
font-size: 24rpx;
line-height: 24rpx;
color: #333333;
}
.value-box {
height: 50rpx;
text-align: center;
.item-icon {
width: 44rpx;
height: 44rpx;
}
.value-text {
font-size: 28rpx;
color: #000000;
line-height: 28rpx;
vertical-align: text-bottom;
font-family: OPPOSANS;
}
.value-box {
height: 50rpx;
text-align: center;
.unit-text {
font-size: 24rpx;
color: #343434;
line-height: 24rpx;
}
}
}
}
</style>
.value-text {
font-size: 28rpx;
color: #000000;
line-height: 28rpx;
vertical-align: text-bottom;
font-family: OPPOSANS;
}
.unit-text {
font-size: 24rpx;
color: #343434;
line-height: 24rpx;
}
}
}
}
</style>
+175 -170
View File
@@ -4,213 +4,218 @@
*/
import Request from 'luch-request';
import { baseUrl, apiPath } from '@/sheep/config';
import {
baseUrl,
apiPath
} from '@/sheep/config';
import $store from '@/sheep/store';
import $platform from '@/sheep/platform';
import { showAuthModal } from '@/sheep/hooks/useModal';
import {
showAuthModal
} from '@/sheep/hooks/useModal';
const options = {
// 显示操作成功消息 默认不显示
showSuccess: false,
// 成功提醒 默认使用后端返回值
successMsg: '',
// 显示失败消息 默认显示
showError: true,
// 失败提醒 默认使用后端返回信息
errorMsg: '',
// 显示请求时loading模态框 默认显示
showLoading: true,
// loading提醒文字
loadingMsg: '加载中',
// 需要授权才能请求 默认放开
auth: false,
// ...
// 显示操作成功消息 默认不显示
showSuccess: false,
// 成功提醒 默认使用后端返回值
successMsg: '',
// 显示失败消息 默认显示
showError: true,
// 失败提醒 默认使用后端返回信息
errorMsg: '',
// 显示请求时loading模态框 默认显示
showLoading: true,
// loading提醒文字
loadingMsg: '加载中',
// 需要授权才能请求 默认放开
auth: false,
// ...
};
// Loading全局实例
let LoadingInstance = {
target: null,
count: 0,
target: null,
count: 0,
};
/**
* 关闭loading
*/
function closeLoading() {
if (LoadingInstance.count > 0) LoadingInstance.count--;
if (LoadingInstance.count === 0) uni.hideLoading();
if (LoadingInstance.count > 0) LoadingInstance.count--;
if (LoadingInstance.count === 0) uni.hideLoading();
}
/**
* @description 请求基础配置 可直接使用访问自定义请求
*/
const http = new Request({
baseURL: baseUrl,
timeout: 8000,
method: 'GET',
header: {
Accept: 'text/json',
'Content-Type': 'application/json;charset=UTF-8',
platform: $platform.name,
},
// #ifdef APP-PLUS
sslVerify: false,
// #endif
// #ifdef H5
// 跨域请求时是否携带凭证(cookies)仅H5支持(HBuilderX 2.6.15+
withCredentials: false,
// #endif
custom: options,
baseURL: baseUrl,
timeout: 8000,
method: 'GET',
header: {
Accept: 'text/json',
'Content-Type': 'application/json;charset=UTF-8',
platform: $platform.name,
},
// #ifdef APP-PLUS
sslVerify: false,
// #endif
// #ifdef H5
// 跨域请求时是否携带凭证(cookies)仅H5支持(HBuilderX 2.6.15+
withCredentials: false,
// #endif
custom: options,
});
/**
* @description 请求拦截器
*/
http.interceptors.request.use(
(config) => {
if (config.custom.auth && !$store('user').isLogin) {
showAuthModal();
return Promise.reject();
}
if (config.custom.showLoading) {
LoadingInstance.count++;
LoadingInstance.count === 1 &&
uni.showLoading({
title: config.custom.loadingMsg,
mask: true,
fail: () => {
uni.hideLoading();
},
});
}
const token = uni.getStorageSync('token');
if (token) config.header['Authorization'] = token;
// TODO 芋艿:特殊处理
if (config.url.indexOf('/app-api/') !== -1) {
config.header['Accept'] = '*/*'
config.header['tenant-id'] = '1';
config.header['Authorization'] = 'Bearer test247';
}
return config;
},
(error) => {
return Promise.reject(error);
},
(config) => {
if (config.custom.auth && !$store('user').isLogin) {
showAuthModal();
return Promise.reject();
}
if (config.custom.showLoading) {
LoadingInstance.count++;
LoadingInstance.count === 1 &&
uni.showLoading({
title: config.custom.loadingMsg,
mask: true,
fail: () => {
uni.hideLoading();
},
});
}
const token = uni.getStorageSync('token');
if (token) config.header['Authorization'] = token;
// TODO 芋艿:特殊处理
if (config.url.indexOf('/app-api/') !== -1) {
config.header['Accept'] = '*/*'
config.header['tenant-id'] = '1';
config.header['Authorization'] = 'Bearer test247';
}
return config;
},
(error) => {
return Promise.reject(error);
},
);
/**
* @description 响应拦截器
*/
http.interceptors.response.use(
(response) => {
// 自动设置登陆令牌
if (response.header.authorization || response.header.Authorization) {
$store('user').setToken(response.header.authorization || response.header.Authorization);
}
(response) => {
// 自动设置登陆令牌
if (response.header.authorization || response.header.Authorization) {
$store('user').setToken(response.header.authorization || response.header.Authorization);
}
response.config.custom.showLoading && closeLoading();
if (response.data.error !== 0) {
if (response.config.custom.showError)
uni.showToast({
title: response.data.msg || '服务器开小差啦,请稍后再试~',
icon: 'none',
mask: true,
});
return Promise.resolve(response.data);
}
if (
response.data.error === 0 &&
response.data.msg !== '' &&
response.config.custom.showSuccess
) {
uni.showToast({
title: response.config.custom.successMsg || response.data.msg,
icon: 'none',
});
}
return Promise.resolve(response.data);
},
(error) => {
const userStore = $store('user');
const isLogin = userStore.isLogin;
let errorMessage = '网络请求出错';
if (error !== undefined) {
switch (error.statusCode) {
case 400:
errorMessage = '请求错误';
break;
case 401:
if (isLogin) {
errorMessage = '您的登陆已过期';
} else {
errorMessage = '请先登录';
}
userStore.logout(true);
showAuthModal();
break;
case 403:
errorMessage = '拒绝访问';
break;
case 404:
errorMessage = '请求出错';
break;
case 408:
errorMessage = '请求超时';
break;
case 429:
errorMessage = '请求频繁, 请稍后再访问';
break;
case 500:
errorMessage = '服务器开小差啦,请稍后再试~';
break;
case 501:
errorMessage = '服务未实现';
break;
case 502:
errorMessage = '网络错误';
break;
case 503:
errorMessage = '服务不可用';
break;
case 504:
errorMessage = '网络超时';
break;
case 505:
errorMessage = 'HTTP版本不受支持';
break;
}
if (error.errMsg.includes('timeout')) errorMessage = '请求超时';
// #ifdef H5
if (error.errMsg.includes('Network'))
errorMessage = window.navigator.onLine ? '服务器异常' : '请检查您的网络连接';
// #endif
}
response.config.custom.showLoading && closeLoading();
if (response.data.error !== 0) {
if (response.config.custom.showError)
uni.showToast({
title: response.data.msg || '服务器开小差啦,请稍后再试~',
icon: 'none',
mask: true,
});
return Promise.resolve(response.data);
}
if (
response.data.error === 0 &&
response.data.msg !== '' &&
response.config.custom.showSuccess
) {
uni.showToast({
title: response.config.custom.successMsg || response.data.msg,
icon: 'none',
});
}
return Promise.resolve(response.data);
},
(error) => {
const userStore = $store('user');
const isLogin = userStore.isLogin;
let errorMessage = '网络请求出错';
if (error !== undefined) {
switch (error.statusCode) {
case 400:
errorMessage = '请求错误';
break;
case 401:
if (isLogin) {
errorMessage = '您的登陆已过期';
} else {
errorMessage = '请先登录';
}
userStore.logout(true);
showAuthModal();
break;
case 403:
errorMessage = '拒绝访问';
break;
case 404:
errorMessage = '请求出错';
break;
case 408:
errorMessage = '请求超时';
break;
case 429:
errorMessage = '请求频繁, 请稍后再访问';
break;
case 500:
errorMessage = '服务器开小差啦,请稍后再试~';
break;
case 501:
errorMessage = '服务未实现';
break;
case 502:
errorMessage = '网络错误';
break;
case 503:
errorMessage = '服务不可用';
break;
case 504:
errorMessage = '网络超时';
break;
case 505:
errorMessage = 'HTTP版本不受支持';
break;
}
if (error.errMsg.includes('timeout')) errorMessage = '请求超时';
// #ifdef H5
if (error.errMsg.includes('Network'))
errorMessage = window.navigator.onLine ? '服务器异常' : '请检查您的网络连接';
// #endif
}
if (error && error.config) {
if (error.config.custom.showError === false) {
uni.showToast({
title: error.data?.msg || errorMessage,
icon: 'none',
mask: true,
});
}
error.config.custom.showLoading && closeLoading();
}
if (error && error.config) {
if (error.config.custom.showError === false) {
uni.showToast({
title: error.data?.msg || errorMessage,
icon: 'none',
mask: true,
});
}
error.config.custom.showLoading && closeLoading();
}
return false;
},
return false;
},
);
const request = (config) => {
if (config.url[0] !== '/') {
config.url = apiPath + config.url;
}
// TODO 芋艿:额外拼接
if (config.url.indexOf('/app-api/') >= 0) {
config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】
// config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】
}
return http.middleware(config);
if (config.url[0] !== '/') {
config.url = apiPath + config.url;
}
// TODO 芋艿:额外拼接
if (config.url.indexOf('/app-api/') >= 0) {
config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】
// config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】
}
return http.middleware(config);
};
export default request;
export default request;
+165 -139
View File
@@ -1,168 +1,194 @@
import { defineStore } from 'pinia';
import {
defineStore
} from 'pinia';
import userApi from '@/sheep/api/user';
import commissionApi from '@/sheep/api/commission';
import $share from '@/sheep/platform/share';
import { isEmpty, cloneDeep, clone } from 'lodash';
import {
isEmpty,
cloneDeep,
clone
} from 'lodash';
import cart from './cart';
import app from './app';
import { showAuthModal } from '@/sheep/hooks/useModal';
import {
showAuthModal
} from '@/sheep/hooks/useModal';
// 默认用户信息
const defaultUserInfo = {
avatar: '', // 头像
nickname: '', // 昵称
gender: 0, // 性别
mobile: '', // 手机号
money: '--', // 余额
commission: '--', // 佣金
score: '--', // 积分
verification: {}, // 认证字段
avatar: '', // 头像
nickname: '', // 昵称
gender: 0, // 性别
mobile: '', // 手机号
money: '--', // 余额
commission: '--', // 佣金
score: '--', // 积分
verification: {}, // 认证字段
};
// 默认订单、优惠券等其他资产信息
const defaultNumData = {
coupons_num: '--',
order_num: {
aftersale: 0,
nocomment: 0,
noget: 0,
nosend: 0,
unpaid: 0,
},
coupons_num: '--',
order_num: {
aftersale: 0,
nocomment: 0,
noget: 0,
nosend: 0,
unpaid: 0,
},
};
const user = defineStore({
id: 'user',
state: () => ({
userInfo: clone(defaultUserInfo), // 用户信息
isLogin: !!uni.getStorageSync('token'), // 登录状态
numData: cloneDeep(defaultNumData), // 用户其他数据
agentInfo: {}, // 分销商信息
lastUpdateTime: 0, // 上次更新时间
}),
id: 'user',
state: () => ({
userInfo: clone(defaultUserInfo), // 用户信息
isLogin: !!uni.getStorageSync('token'), // 登录状态
numData: cloneDeep(defaultNumData), // 用户其他数据
agentInfo: {}, // 分销商信息
lastUpdateTime: 0, // 上次更新时间
}),
actions: {
// 获取个人信息
async getInfo() {
const { code, data } = await userApi.profile();
// 为了兼容 获取用户余额 可能还会用到其他参数
const { code:code2, data:data2 } = await userApi.balance();
if (code !== 0||code2!=0) return;
data.money=data2.balance/100;
this.userInfo = data;
actions: {
// 获取个人信息
async getInfo() {
const {
code,
data
} = await userApi.profile();
return Promise.resolve(data);
},
// 为了兼容 获取用户余额 可能还会用到其他参数
// 优惠券数量,积分数量 应该在这里
const {
code: code2,
data: data2
} = await userApi.balance();
if (code !== 0 || code2 != 0) return;
data.money = data2.balance / 100;
this.userInfo = data;
console.log(data2, '信息')
return Promise.resolve(data);
},
// 获取分销商信息
async getAgentInfo() {
const res = await commissionApi.agent();
if (res.error === 0) {
this.agentInfo = res.data;
}
return Promise.resolve(res);
},
// 获取分销商信息
async getAgentInfo() {
const res = await commissionApi.agent();
if (res.error === 0) {
this.agentInfo = res.data;
}
return Promise.resolve(res);
},
// 获取订单、优惠券等其他资产信息
async getNumData() {
const { code, data } = await userApi.data();
const data2 = await userApi.data2();
if (code === 0&&data2.code===0) {
console.log('订单数据',data);
this.numData = {order_num:{
noget:data.deliveredCount,
unpaid:data.unpaidCount,
nocomment:data.uncommentedCount,
aftersale:data2.data
}};
}
},
// 获取订单、优惠券等其他资产信息
async getNumData() {
const {
code,
data
} = await userApi.data();
const data2 = await userApi.data2();
let data3 = await userApi.getUnused();
console.log(data3.data, '优惠券')
if (code === 0 && data2.code === 0) {
console.log('订单数据', data);
this.numData = {
coupons_num: data3.data,
order_num: {
noget: data.deliveredCount,
unpaid: data.unpaidCount,
nocomment: data.uncommentedCount,
aftersale: data2.data
}
};
}
},
// 添加分享记录
async addShareLog(params) {
const { error } = await userApi.addShareLog(params);
if (error === 0) uni.removeStorageSync('shareLog');
},
// 添加分享记录
async addShareLog(params) {
const {
error
} = await userApi.addShareLog(params);
if (error === 0) uni.removeStorageSync('shareLog');
},
// 设置token
setToken(token = '') {
if (token === '') {
this.isLogin = false;
uni.removeStorageSync('token');
} else {
this.isLogin = true;
uni.setStorageSync('token', token);
this.loginAfter();
}
return this.isLogin;
},
// 设置token
setToken(token = '') {
if (token === '') {
this.isLogin = false;
uni.removeStorageSync('token');
} else {
this.isLogin = true;
uni.setStorageSync('token', token);
this.loginAfter();
}
return this.isLogin;
},
// 更新用户相关信息 (手动限流 5秒之内不刷新)
async updateUserData() {
if (!this.isLogin) {
this.resetUserData();
return;
}
const nowTime = new Date().getTime();
if (this.lastUpdateTime + 5000 > nowTime) return;
await this.getInfo();
this.getNumData();
this.lastUpdateTime = nowTime;
return this.userInfo;
},
// 更新用户相关信息 (手动限流 5秒之内不刷新)
async updateUserData() {
if (!this.isLogin) {
this.resetUserData();
return;
}
const nowTime = new Date().getTime();
if (this.lastUpdateTime + 5000 > nowTime) return;
await this.getInfo();
this.getNumData();
this.lastUpdateTime = nowTime;
return this.userInfo;
},
// 重置用户默认数据
resetUserData() {
this.setToken();
this.userInfo = clone(defaultUserInfo);
this.numData = cloneDeep(defaultNumData);
this.agentInfo = {};
cart().emptyList();
},
// 重置用户默认数据
resetUserData() {
this.setToken();
this.userInfo = clone(defaultUserInfo);
this.numData = cloneDeep(defaultNumData);
this.agentInfo = {};
cart().emptyList();
},
// 登录后
async loginAfter() {
await this.updateUserData();
cart().getList();
// 登录后设置全局分享参数
$share.getShareInfo();
// 提醒绑定手机号
if (app().platform.bind_mobile && !this.userInfo.verification?.mobile) {
showAuthModal('changeMobile');
}
// 登录后
async loginAfter() {
await this.updateUserData();
cart().getList();
// 登录后设置全局分享参数
$share.getShareInfo();
// 提醒绑定手机号
// if (app().platform.bind_mobile && !this.userInfo.verification?.mobile) {
// showAuthModal('changeMobile');
// }
// 添加分享记录
const shareLog = uni.getStorageSync('shareLog');
if (!isEmpty(shareLog)) {
this.addShareLog({
...shareLog,
});
}
},
// 添加分享记录
const shareLog = uni.getStorageSync('shareLog');
if (!isEmpty(shareLog)) {
this.addShareLog({
...shareLog,
});
}
},
// 登出
async logout(force = false) {
if (!force) {
const { error } = await userApi.logout();
if (error === 0) {
this.resetUserData();
}
}
if (force) {
this.resetUserData();
}
// 登出
async logout(force = false) {
if (!force) {
const {
error
} = await userApi.logout();
if (error === 0) {
this.resetUserData();
}
}
if (force) {
this.resetUserData();
}
return !this.isLogin;
},
},
persist: {
enabled: true,
strategies: [
{
key: 'user-store',
},
],
},
return !this.isLogin;
},
},
persist: {
enabled: true,
strategies: [{
key: 'user-store',
}, ],
},
});
export default user;
export default user;