我的全部订单,待发货-待评价-评价晒单 优惠券列表
This commit is contained in:
+42
-35
@@ -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',
|
||||
}),
|
||||
};
|
||||
+9
-3
@@ -107,12 +107,18 @@ export default {
|
||||
method: 'PUT',
|
||||
}),
|
||||
// 评价订单
|
||||
comment: (id, data) =>
|
||||
request({
|
||||
url: 'order/order/comment/' + id,
|
||||
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({
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
+162
-140
@@ -1,168 +1,190 @@
|
||||
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();
|
||||
// 为了兼容 获取用户余额 可能还会用到其他参数
|
||||
// 优惠券数量,积分数量 应该在这里
|
||||
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);
|
||||
},
|
||||
|
||||
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();
|
||||
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 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;
|
||||
Reference in New Issue
Block a user