This commit is contained in:
2024-04-14 20:18:44 +08:00
parent 13fd77f13b
commit 877469ab43
12 changed files with 98 additions and 22 deletions

View File

@@ -1,8 +1,20 @@
<script setup lang='ts'> <script setup lang='ts'>
import { mpUpdate } from '@/utils'; import { mpUpdate, setReferrerUserId, setRegisterStoreId } from '@/utils';
onLaunch((options) => { onLaunch((options) => {
console.log('App Launch options ', options); console.log('App Launch options ', options);
if(options?.query) {
//保存登录邀请员工id
if(options.query.referrerUserId) {
setReferrerUserId(options.query.referrerUserId);
}
//保存注册门店id
if(options.query.storeId) {
setRegisterStoreId(options.query.storeId);
}
}
// #ifdef MP // #ifdef MP
mpUpdate(); mpUpdate();
// #endif // #endif

View File

@@ -4,8 +4,10 @@
<view class='c-flex-row' style='align-items: flex-start'> <view class='c-flex-row' style='align-items: flex-start'>
<image class='goods-image' :src='goodsDetailBean?.images||defaultImage' /> <image class='goods-image' :src='goodsDetailBean?.images||defaultImage' />
<view class='c-flex-column' style='flex: 1'> <view class='c-flex-column' style='flex: 1'>
<text class='goods-name'>{{ goodsDetailBean?.name }}</text> <text class='goods-name'>{{ goodsDetailBean?.name || '未知' }}</text>
<text class='goods-price'>{{ flashPrice > 0 ? `${flashPrice}` : `${goodsDetailBean?.price}` || 0 }}</text> <text class='goods-price'>{{ flashPrice > 0 ? `${flashPrice}` : `${goodsDetailBean?.consumePrice || 0}` || 0
}}
</text>
</view> </view>
<image class='close-image' :src='assetsUrl("ic_close.png")' @click.stop='close' /> <image class='close-image' :src='assetsUrl("ic_close.png")' @click.stop='close' />
</view> </view>
@@ -58,6 +60,10 @@ import { assetsUrl, defaultImage } from '@/utils/assets';
import { showToast } from '@/utils'; import { showToast } from '@/utils';
import { getGoodsDetail } from '@/api/goods'; import { getGoodsDetail } from '@/api/goods';
import { GoodsBean, StockBean } from '@/api/goods/types'; import { GoodsBean, StockBean } from '@/api/goods/types';
import { useUserStore } from '@/store';
const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore);
const props = defineProps({ const props = defineProps({
flashPrice: { flashPrice: {
@@ -78,7 +84,9 @@ const show = async (goodsId: string, fn: Function) => {
callback = fn; callback = fn;
goodsDetailBean.value = await getGoodsDetail(goodsId); goodsDetailBean.value = await getGoodsDetail(goodsId);
if(goodsDetailBean.value?.stocks?.length == 0) { goodsDetailBean.value.consumePrice = Number((goodsDetailBean.value?.price * ((userInfo?.value?.levelEntity?.discount || 100) / 100)).toFixed(2));
if((goodsDetailBean.value?.stocks?.length || 0) <= 0) {
showToast('暂无库存'); showToast('暂无库存');
return; return;
} }
@@ -103,7 +111,8 @@ const show = async (goodsId: string, fn: Function) => {
} }
if(skuSizeList) { if(skuSizeList) {
// skuSizeList.value![2].existingNumber = 2; //skuSizeList.value![0].existingNumber = 2;
//skuSizeList.value![2].existingNumber = 2;
} }
}; };

View File

@@ -120,6 +120,7 @@ onLoad((e) => {
onShow(async () => { onShow(async () => {
if(isLogin()) { if(isLogin()) {
// userStore.getProfile();
if(userInfo.value.maOpenId) { if(userInfo.value.maOpenId) {
if(getCompanyId() === '') { if(getCompanyId() === '') {
switchCompany(); switchCompany();

View File

@@ -161,8 +161,9 @@ const addShoppingCart = () => {
const placeOrder = () => { const placeOrder = () => {
showSkuDialog((e: GoodsBean) => { showSkuDialog((e: GoodsBean) => {
console.log(e);
const orderBean = { const orderBean = {
totalPrice: e.price * e.checkedStock.count, totalPrice: (e.consumePrice * e.checkedStock.count).toFixed(2),
orderGoods: [e] orderGoods: [e]
}; };
goPath(`/pages/mall/subs/order/order-confirm?orderBean=${encodeURIComponent(JSON.stringify(orderBean))}`); goPath(`/pages/mall/subs/order/order-confirm?orderBean=${encodeURIComponent(JSON.stringify(orderBean))}`);

View File

@@ -124,7 +124,7 @@
import { assetsUrl, defaultImage } from '@/utils/assets'; import { assetsUrl, defaultImage } from '@/utils/assets';
import PaymentDialog from '@/components/payment-dialog.vue'; import PaymentDialog from '@/components/payment-dialog.vue';
import CouponDialog from '@/pages/mall/subs/components/coupon-dialog.vue'; import CouponDialog from '@/pages/mall/subs/components/coupon-dialog.vue';
import { goPath, parseParameter, sortASCII } from '@/utils'; import { goPath, parseParameter, showToast, sortASCII } from '@/utils';
import { hexMD5 } from '@/utils/common/md5'; import { hexMD5 } from '@/utils/common/md5';
import { getPaymentList, orderCreate, overPayment } from '@/api/order'; import { getPaymentList, orderCreate, overPayment } from '@/api/order';
import { CouponBean } from '@/api/user/types'; import { CouponBean } from '@/api/user/types';
@@ -198,6 +198,12 @@ const navigateTo = (e: any) => {
}; };
const createOrder = async () => { const createOrder = async () => {
//邮寄
if(tabIndex.value == 1 && !deliveryAddress.value.addrid) {
showToast('请选择收货地址');
return;
}
const params = { const params = {
// 'discount': 0, // 'discount': 0,
// 'freePrice': 0, // 'freePrice': 0,
@@ -217,7 +223,7 @@ const createOrder = async () => {
'stockId': item.checkedStock.stockId, 'stockId': item.checkedStock.stockId,
'originPrice': item.price, 'originPrice': item.price,
// 'consumePrice': item.price * ((userInfo.value?.levelEntity?.discount || 0) / 100), // 'consumePrice': item.price * ((userInfo.value?.levelEntity?.discount || 0) / 100),
'consumePrice': item.price, 'consumePrice': item.consumePrice,
'discount': userInfo.value?.levelEntity?.discount || 0 'discount': userInfo.value?.levelEntity?.discount || 0
// 'discountOriginPrice': 0, // 'discountOriginPrice': 0,
// 'produceIntegral': 0, // 'produceIntegral': 0,

View File

@@ -85,7 +85,7 @@ watch(checkedAll, (newValue) => {
}); });
const totalPayPrice = computed(() => { const totalPayPrice = computed(() => {
return shoppingCartList.value.filter(res => res.checked).reduce((a, b) => a + b.price * b.checkedStock.count, 0); return shoppingCartList.value.filter(res => res.checked).reduce((a, b) => a + b.consumePrice * b.checkedStock.count, 0);
}); });
const deleteShoppingCart = () => { const deleteShoppingCart = () => {

View File

@@ -10,7 +10,7 @@
<view class='right-content accent-text-color' :class='{"right-content-disabled": item?.status==1}'> <view class='right-content accent-text-color' :class='{"right-content-disabled": item?.status==1}'>
<text>{{ item?.name }}</text> <text>{{ item?.name }}</text>
<text>有效期至{{ dayjs(item?.startTime).format('YYYY-MM-DD') }}</text> <text>有效期至{{ dayjs(item?.startTime).format('YYYY-MM-DD') }}</text>
<text class='btn-text' :class='{"btn-text-disabled": item?.status==1}'> <text class='btn-text' :class='{"btn-text-disabled": item?.status==1}' @click.stop='goPath("/pages/mall/index")'>
立即使用 立即使用
</text> </text>
</view> </view>
@@ -24,6 +24,7 @@ import { assetsUrl } from '@/utils/assets';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { PropType } from 'vue'; import { PropType } from 'vue';
import { CouponBean } from '@/api/user/types'; import { CouponBean } from '@/api/user/types';
import { goPath } from '@/utils';
defineProps({ defineProps({
item: Object as PropType<CouponBean> item: Object as PropType<CouponBean>

View File

@@ -4,7 +4,7 @@
<image class='goods-image' :src='item?.orderGoods[0].images||defaultImage' /> <image class='goods-image' :src='item?.orderGoods[0].images||defaultImage' />
<view class='c-flex-column' style='flex: 1;'> <view class='c-flex-column' style='flex: 1;'>
<view class='c-flex-row'> <view class='c-flex-row'>
<text class='goods-name'>{{ item?.orderGoods[0].goodsName }}</text> <text class='goods-name'>{{ item?.orderGoods[0].goodsName||'未知' }}</text>
<text class='status'> <text class='status'>
<text v-if='item?.payStatus == 2'>已支付</text> <text v-if='item?.payStatus == 2'>已支付</text>
<text v-else-if='isPending(item)'>待支付</text> <text v-else-if='isPending(item)'>待支付</text>

View File

@@ -38,7 +38,7 @@
<image class='goods-image' :src='item.stockStock.images||defaultImage' /> <image class='goods-image' :src='item.stockStock.images||defaultImage' />
<view class='c-flex-column' style='flex: 1;'> <view class='c-flex-column' style='flex: 1;'>
<view class='c-flex-row'> <view class='c-flex-row'>
<text class='goods-name'>{{ item.goodsName }}</text> <text class='goods-name'>{{ item.goodsName || '未知' }}</text>
</view> </view>
<text style='color: #999999;margin-top: 30rpx'> <text style='color: #999999;margin-top: 30rpx'>
{{ item.goodsCode }} {{ item.goodsCode }}
@@ -92,6 +92,12 @@
<text style='color: #5B96FB;margin-left: 10rpx'>复制</text> <text style='color: #5B96FB;margin-left: 10rpx'>复制</text>
</text> </text>
<text>下单时间{{ orderBean?.order?.createTime }}</text> <text>下单时间{{ orderBean?.order?.createTime }}</text>
<text>
支付状态
<text v-if='orderBean?.order?.payStatus == 2' style='color: #F32B2B'>已支付</text>
<text v-else-if='isPending(orderBean?.order)' style='color: #F32B2B'>待支付</text>
<text v-else style='color: #999999'>已过期</text>
</text>
</view> </view>
<view class='bottom-action-view c-flex-row' v-if='isPending(orderBean?.order)'> <view class='bottom-action-view c-flex-row' v-if='isPending(orderBean?.order)'>
@@ -404,8 +410,8 @@ const payment = () => {
color: #333333; color: #333333;
} }
text:nth-of-type(1) { text:nth-of-type(3) {
margin-bottom: 12rpx; margin-bottom: 0rpx;
} }
} }

View File

@@ -1,7 +1,7 @@
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import type { providerType, UserBean } from './types'; import type { providerType, UserBean } from './types';
import { getTerminal, getUserProfile, login, logout as userLogout, register } from '@/api/user/index'; import { getTerminal, getUserProfile, login, logout as userLogout, register } from '@/api/user/index';
import { clearToken, setCompanyId, setToken } from '@/utils/auth'; import { clearToken, getReferrerUserId, getRegisterStoreId, setCompanyId, setToken } from '@/utils/auth';
import type { LoginResult, RegisterParams, TerminalBean } from '@/api/user/types'; import type { LoginResult, RegisterParams, TerminalBean } from '@/api/user/types';
import { getCompanyInfo } from '@/api/company'; import { getCompanyInfo } from '@/api/company';
@@ -112,7 +112,8 @@ const useUserStore = defineStore('user', {
const res = await login({ const res = await login({
code: result.code, code: result.code,
userInfo: userInfo, userInfo: userInfo,
referrerUserId: '1727303781559697409' // referrerUserId: '1727303781559697409'
referrerUserId: getReferrerUserId()
}); });
if(res.user == undefined || res.user.id === null) { if(res.user == undefined || res.user.id === null) {
@@ -126,7 +127,8 @@ const useUserStore = defineStore('user', {
birthday: res.user.birthday, birthday: res.user.birthday,
companyId: res.user.companyId, companyId: res.user.companyId,
creatorId: res.user.creatorId, creatorId: res.user.creatorId,
gender: res.user.gender gender: res.user.gender,
storeId: getRegisterStoreId()
}; };
setToken(res.token); setToken(res.token);
const registerResult = await this.userRegister(registerForm); const registerResult = await this.userRegister(registerForm);

View File

@@ -1,5 +1,8 @@
const TokenKey = 'accessToken'; const TokenKey = 'accessToken';
const CompanyIdKey = 'companyId'; const CompanyIdKey = 'companyId';
const ReferrerUserIdKey = 'referrerUserId';
const RegisterStoreIdKey = 'storeId';
const TokenPrefix = 'Bearer '; const TokenPrefix = 'Bearer ';
function isLogin() { function isLogin() {
@@ -22,9 +25,37 @@ function setCompanyId(companyId: string) {
uni.setStorageSync(CompanyIdKey, companyId); uni.setStorageSync(CompanyIdKey, companyId);
} }
function getReferrerUserId() {
return uni.getStorageSync(ReferrerUserIdKey);
}
function setReferrerUserId(referrerUserId: string) {
uni.setStorageSync(ReferrerUserIdKey, referrerUserId);
}
function setRegisterStoreId(storeId: string) {
uni.setStorageSync(RegisterStoreIdKey, storeId);
}
function getRegisterStoreId() {
return uni.getStorageSync(RegisterStoreIdKey);
}
function clearToken() { function clearToken() {
uni.removeStorageSync(TokenKey); uni.removeStorageSync(TokenKey);
uni.removeStorageSync(CompanyIdKey); uni.removeStorageSync(CompanyIdKey);
} }
export { TokenPrefix, isLogin, getToken, setToken, getCompanyId, setCompanyId, clearToken }; export {
TokenPrefix,
isLogin,
getToken,
setToken,
getCompanyId,
setCompanyId,
getReferrerUserId,
setReferrerUserId,
getRegisterStoreId,
setRegisterStoreId,
clearToken
};

View File

@@ -51,10 +51,17 @@ export function showToast(title: string, { icon, duration, complete }: ToastOpti
} }
export function goPath(path: string) { export function goPath(path: string) {
uni.navigateTo({ if(path.includes('home/index') || path.includes('mall/index') || path.includes('qrcode/index') || path.includes('mine/index')) {
url: path uni.switchTab({
}).then(r => { url: path
}); }).then(r => {
});
} else {
uni.navigateTo({
url: path
}).then(r => {
});
}
} }
export function goLogin() { export function goLogin() {