优化
This commit is contained in:
14
src/App.vue
14
src/App.vue
@@ -1,8 +1,20 @@
|
||||
<script setup lang='ts'>
|
||||
import { mpUpdate } from '@/utils';
|
||||
import { mpUpdate, setReferrerUserId, setRegisterStoreId } from '@/utils';
|
||||
|
||||
onLaunch((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
|
||||
mpUpdate();
|
||||
// #endif
|
||||
|
@@ -4,8 +4,10 @@
|
||||
<view class='c-flex-row' style='align-items: flex-start'>
|
||||
<image class='goods-image' :src='goodsDetailBean?.images||defaultImage' />
|
||||
<view class='c-flex-column' style='flex: 1'>
|
||||
<text class='goods-name'>{{ goodsDetailBean?.name }}</text>
|
||||
<text class='goods-price'>{{ flashPrice > 0 ? `${flashPrice}` : `${goodsDetailBean?.price}` || 0 }}</text>
|
||||
<text class='goods-name'>{{ goodsDetailBean?.name || '未知' }}</text>
|
||||
<text class='goods-price'>{{ flashPrice > 0 ? `${flashPrice}` : `${goodsDetailBean?.consumePrice || 0}` || 0
|
||||
}}
|
||||
</text>
|
||||
</view>
|
||||
<image class='close-image' :src='assetsUrl("ic_close.png")' @click.stop='close' />
|
||||
</view>
|
||||
@@ -58,6 +60,10 @@ import { assetsUrl, defaultImage } from '@/utils/assets';
|
||||
import { showToast } from '@/utils';
|
||||
import { getGoodsDetail } from '@/api/goods';
|
||||
import { GoodsBean, StockBean } from '@/api/goods/types';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { userInfo } = storeToRefs(userStore);
|
||||
|
||||
const props = defineProps({
|
||||
flashPrice: {
|
||||
@@ -78,7 +84,9 @@ const show = async (goodsId: string, fn: Function) => {
|
||||
callback = fn;
|
||||
|
||||
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('暂无库存');
|
||||
return;
|
||||
}
|
||||
@@ -103,7 +111,8 @@ const show = async (goodsId: string, fn: Function) => {
|
||||
}
|
||||
|
||||
if(skuSizeList) {
|
||||
// skuSizeList.value![2].existingNumber = 2;
|
||||
//skuSizeList.value![0].existingNumber = 2;
|
||||
//skuSizeList.value![2].existingNumber = 2;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -120,6 +120,7 @@ onLoad((e) => {
|
||||
|
||||
onShow(async () => {
|
||||
if(isLogin()) {
|
||||
// userStore.getProfile();
|
||||
if(userInfo.value.maOpenId) {
|
||||
if(getCompanyId() === '') {
|
||||
switchCompany();
|
||||
|
@@ -161,8 +161,9 @@ const addShoppingCart = () => {
|
||||
|
||||
const placeOrder = () => {
|
||||
showSkuDialog((e: GoodsBean) => {
|
||||
console.log(e);
|
||||
const orderBean = {
|
||||
totalPrice: e.price * e.checkedStock.count,
|
||||
totalPrice: (e.consumePrice * e.checkedStock.count).toFixed(2),
|
||||
orderGoods: [e]
|
||||
};
|
||||
goPath(`/pages/mall/subs/order/order-confirm?orderBean=${encodeURIComponent(JSON.stringify(orderBean))}`);
|
||||
|
@@ -124,7 +124,7 @@
|
||||
import { assetsUrl, defaultImage } from '@/utils/assets';
|
||||
import PaymentDialog from '@/components/payment-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 { getPaymentList, orderCreate, overPayment } from '@/api/order';
|
||||
import { CouponBean } from '@/api/user/types';
|
||||
@@ -198,6 +198,12 @@ const navigateTo = (e: any) => {
|
||||
};
|
||||
|
||||
const createOrder = async () => {
|
||||
|
||||
//邮寄
|
||||
if(tabIndex.value == 1 && !deliveryAddress.value.addrid) {
|
||||
showToast('请选择收货地址');
|
||||
return;
|
||||
}
|
||||
const params = {
|
||||
// 'discount': 0,
|
||||
// 'freePrice': 0,
|
||||
@@ -217,7 +223,7 @@ const createOrder = async () => {
|
||||
'stockId': item.checkedStock.stockId,
|
||||
'originPrice': item.price,
|
||||
// 'consumePrice': item.price * ((userInfo.value?.levelEntity?.discount || 0) / 100),
|
||||
'consumePrice': item.price,
|
||||
'consumePrice': item.consumePrice,
|
||||
'discount': userInfo.value?.levelEntity?.discount || 0
|
||||
// 'discountOriginPrice': 0,
|
||||
// 'produceIntegral': 0,
|
||||
|
@@ -85,7 +85,7 @@ watch(checkedAll, (newValue) => {
|
||||
});
|
||||
|
||||
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 = () => {
|
||||
|
@@ -10,7 +10,7 @@
|
||||
<view class='right-content accent-text-color' :class='{"right-content-disabled": item?.status==1}'>
|
||||
<text>{{ item?.name }}</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>
|
||||
</view>
|
||||
@@ -24,6 +24,7 @@ import { assetsUrl } from '@/utils/assets';
|
||||
import dayjs from 'dayjs';
|
||||
import { PropType } from 'vue';
|
||||
import { CouponBean } from '@/api/user/types';
|
||||
import { goPath } from '@/utils';
|
||||
|
||||
defineProps({
|
||||
item: Object as PropType<CouponBean>
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<image class='goods-image' :src='item?.orderGoods[0].images||defaultImage' />
|
||||
<view class='c-flex-column' style='flex: 1;'>
|
||||
<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 v-if='item?.payStatus == 2'>已支付</text>
|
||||
<text v-else-if='isPending(item)'>待支付</text>
|
||||
|
@@ -38,7 +38,7 @@
|
||||
<image class='goods-image' :src='item.stockStock.images||defaultImage' />
|
||||
<view class='c-flex-column' style='flex: 1;'>
|
||||
<view class='c-flex-row'>
|
||||
<text class='goods-name'>{{ item.goodsName }}</text>
|
||||
<text class='goods-name'>{{ item.goodsName || '未知' }}</text>
|
||||
</view>
|
||||
<text style='color: #999999;margin-top: 30rpx'>
|
||||
{{ item.goodsCode }}
|
||||
@@ -92,6 +92,12 @@
|
||||
<text style='color: #5B96FB;margin-left: 10rpx'>复制</text>
|
||||
</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 class='bottom-action-view c-flex-row' v-if='isPending(orderBean?.order)'>
|
||||
@@ -404,8 +410,8 @@ const payment = () => {
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
text:nth-of-type(1) {
|
||||
margin-bottom: 12rpx;
|
||||
text:nth-of-type(3) {
|
||||
margin-bottom: 0rpx;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import type { providerType, UserBean } from './types';
|
||||
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 { getCompanyInfo } from '@/api/company';
|
||||
|
||||
@@ -112,7 +112,8 @@ const useUserStore = defineStore('user', {
|
||||
const res = await login({
|
||||
code: result.code,
|
||||
userInfo: userInfo,
|
||||
referrerUserId: '1727303781559697409'
|
||||
// referrerUserId: '1727303781559697409'
|
||||
referrerUserId: getReferrerUserId()
|
||||
});
|
||||
|
||||
if(res.user == undefined || res.user.id === null) {
|
||||
@@ -126,7 +127,8 @@ const useUserStore = defineStore('user', {
|
||||
birthday: res.user.birthday,
|
||||
companyId: res.user.companyId,
|
||||
creatorId: res.user.creatorId,
|
||||
gender: res.user.gender
|
||||
gender: res.user.gender,
|
||||
storeId: getRegisterStoreId()
|
||||
};
|
||||
setToken(res.token);
|
||||
const registerResult = await this.userRegister(registerForm);
|
||||
|
@@ -1,5 +1,8 @@
|
||||
const TokenKey = 'accessToken';
|
||||
const CompanyIdKey = 'companyId';
|
||||
const ReferrerUserIdKey = 'referrerUserId';
|
||||
const RegisterStoreIdKey = 'storeId';
|
||||
|
||||
const TokenPrefix = 'Bearer ';
|
||||
|
||||
function isLogin() {
|
||||
@@ -22,9 +25,37 @@ function setCompanyId(companyId: string) {
|
||||
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() {
|
||||
uni.removeStorageSync(TokenKey);
|
||||
uni.removeStorageSync(CompanyIdKey);
|
||||
}
|
||||
|
||||
export { TokenPrefix, isLogin, getToken, setToken, getCompanyId, setCompanyId, clearToken };
|
||||
export {
|
||||
TokenPrefix,
|
||||
isLogin,
|
||||
getToken,
|
||||
setToken,
|
||||
getCompanyId,
|
||||
setCompanyId,
|
||||
getReferrerUserId,
|
||||
setReferrerUserId,
|
||||
getRegisterStoreId,
|
||||
setRegisterStoreId,
|
||||
clearToken
|
||||
};
|
||||
|
@@ -51,10 +51,17 @@ export function showToast(title: string, { icon, duration, complete }: ToastOpti
|
||||
}
|
||||
|
||||
export function goPath(path: string) {
|
||||
uni.navigateTo({
|
||||
url: path
|
||||
}).then(r => {
|
||||
});
|
||||
if(path.includes('home/index') || path.includes('mall/index') || path.includes('qrcode/index') || path.includes('mine/index')) {
|
||||
uni.switchTab({
|
||||
url: path
|
||||
}).then(r => {
|
||||
});
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: path
|
||||
}).then(r => {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function goLogin() {
|
||||
|
Reference in New Issue
Block a user