切换公司逻辑完善

This commit is contained in:
2024-04-11 21:13:52 +08:00
parent 222bae69d9
commit 93e9c5227b
24 changed files with 451 additions and 146 deletions

View File

@@ -1,4 +1,4 @@
import { get } from '@/utils/request';
export const getCompanyList = (maOpenId: string) => get({ url: `/wc/wechat/company?maOpenId=${maOpenId}` });
export const getCompanyInfo = (companyId: string) => get({ url: `/ext/zconfig/company_find?companyId=${companyId}` });
export const getCompanyInfo = () => get({ url: `/ext/zconfig/company_find` });

View File

@@ -48,7 +48,7 @@ export interface OrderBean {
salePrice: number;
stockId: string;
stockStock: StockBean[];
payStatus: number;
payStatus: number;//状态 1.未支付 2.已支付
payTypeIds: string;
printed: string;
produceIntegralNumber: number;

View File

@@ -0,0 +1,92 @@
<template>
<sqb-pay style='width: 100%;' @bindnavigateTo='navigateTo'
:return_url='payParams.return_url'
:total_amount='payParams.total_amount'
:terminal_sn='payParams.terminal_sn'
:client_sn='payParams.client_sn'
:subject='payParams.subject'
:subject_img='payParams.subject_img '
:merchant_name='payParams.merchant_name'
:notify_url='payParams.notify_url'
:sign='payParams.sign'>
<slot name='button'></slot>
</sqb-pay>
</template>
<script lang='ts' setup>
import { PropType } from 'vue';
import { parseParameter, sortASCII } from '@/utils';
import { hexMD5 } from '@/utils/common/md5';
import { useUserStore } from '@/store';
const userState = useUserStore();
const { terminalInfo } = storeToRefs(userState);
export interface SqbPayParams {
return_url: string;
total_amount: number;
client_sn: string;
terminal_sn: string;
subject: string;
subject_img: string;
merchant_name: string;
notify_url: string;
sign: string;
}
const props = defineProps({
payParams: {
type: Object as PropType<SqbPayParams>,
default: () => {
return {
return_url: '',
total_amount: 0,
client_sn: '',
terminal_sn: '',
subject: '',
subject_img: '',
merchant_name: '',
notify_url: '',
sign: ''
};
}
}
});
watch(() => props.payParams, (newValue, prevValue) => {
if(newValue) {
let signParams = buildSignParams.value;
const signStr = parseParameter(signParams) + '&key=' + terminalInfo.value.terminalKey;
props.payParams.sign = hexMD5(signStr).toUpperCase();
}
});
const buildSignParams = computed(() => {
return sortASCII({
client_sn: props.payParams.client_sn || '',
return_url: props.payParams.return_url,
total_amount: (props.payParams.total_amount * 100).toString(),
terminal_sn: props.payParams.terminal_sn,
subject: props.payParams.subject,
subject_img: props.payParams.subject_img,
merchant_name: props.payParams.merchant_name,
notify_url: props.payParams.notify_url
}, true);
});
const navigateTo = (e: any) => {
console.log('--------------_>>>>>>navigateTo ', e);
uni.redirectTo({
url: e.detail.url,
fail(e) {
uni.showToast({
title: '支付失败'
});
}
});
};
</script>
<style lang='scss' scoped>
</style>

View File

@@ -76,6 +76,12 @@
{
"path": "webview/index",
"navigationBarTitleText": "网页"
},
{
"path": "payresult/index",
"style": {
"navigationBarTitleText": "支付结果"
}
}
]
},
@@ -140,7 +146,10 @@
{
"path": "recharge/index",
"style": {
"navigationBarTitleText": "会员充值"
"navigationBarTitleText": "会员充值",
"usingComponents": {
"sqb-pay": "plugin://sqb-pay/sqb-pay"
}
}
},
{
@@ -158,7 +167,10 @@
{
"path": "order/detail",
"style": {
"navigationBarTitleText": "订单详情"
"navigationBarTitleText": "订单详情",
"usingComponents": {
"sqb-pay": "plugin://sqb-pay/sqb-pay"
}
}
},
{

View File

@@ -6,7 +6,9 @@
</view>
<scroll-view class='scroll-view'>
<view class='c-flex-column' v-for='(item, index) in groupbuyList' :key='index'>
<!-- <u-list class='scroll-view' :border='false' @scrolltolower='loadMore'>-->
<!-- <u-list-item v-for='(item,index) in groupbuyList' :key='index'>-->
<view class='c-flex-column' v-for='(item,index) in groupbuyList' :key='index'>
<view class='item c-flex-row' @click.stop='goPath(`/pages/common/groupbuy/detail?id=${item.id}`)'>
<image class='goods-image' :src='JSON.parse(item.content)[0].images' />
<view class='c-flex-column' style='flex: 1'>
@@ -27,6 +29,8 @@
</view>
<view class='divider' style='margin: 0 30rpx' />
</view>
<!-- </u-list-item>-->
<!-- </u-list>-->
</scroll-view>
</view>
</template>
@@ -39,6 +43,7 @@ import { goPath } from '@/utils';
const tabIndex = ref(0);
const groupbuyList = ref([]);
const currentPageNum = ref(1);
onLoad((e) => {
fetchData();
@@ -48,9 +53,12 @@ watch(() => tabIndex.value, () => {
fetchData();
});
const fetchData = async () => {
const fetchData = async (refresh: boolean = true) => {
if(!refresh) {
currentPageNum.value += 1;
}
const { list } = await getGroupBuyList({
pageNum: 1,
pageNum: currentPageNum.value,
pageSize: 100,
obj: {
status: tabIndex.value
@@ -58,6 +66,10 @@ const fetchData = async () => {
});
groupbuyList.value = list;
};
const loadMore = () => {
fetchData(false);
};
</script>
<style lang='scss' scoped>

View File

@@ -27,15 +27,15 @@
<view class='bottom-view c-flex-row'>
<sqb-pay @bindnavigateTo='navigateTo'
:return_url='payParams.return_url'
:total_amount='payParams.total_amount'
:terminal_sn='payParams.terminal_sn'
:client_sn='payParams.client_sn'
:subject='payParams.subject'
:subject_img='payParams.subject_img '
:merchant_name='payParams.merchant_name'
:notify_url='payParams.notify_url'
:sign='payParams.sign'>
:return_url='buildSqbParams.return_url'
:total_amount='buildSqbParams.total_amount'
:terminal_sn='buildSqbParams.terminal_sn'
:client_sn='buildSqbParams.client_sn'
:subject='buildSqbParams.subject'
:subject_img='buildSqbParams.subject_img '
:merchant_name='buildSqbParams.merchant_name'
:notify_url='buildSqbParams.notify_url'
:sign='buildSqbParams.sign'>
<button class='confirm-button' @click='payment'>支付</button>
</sqb-pay>
</view>
@@ -54,34 +54,15 @@ const userState = useUserStore();
const { terminalInfo } = storeToRefs(userState);
const orderBean = ref<OrderBean>();
const payParams = ref({
return_url: '',
total_amount: '',
client_sn: '',
terminal_sn: '',
subject: '',
subject_img: '',
merchant_name: '',
notify_url: '',
sign: ''
});
onLoad((e: any) => {
orderBean.value = JSON.parse(decodeURIComponent(e?.orderBean));
let signParams = buildSignParams.value;
const signStr = parseParameter(signParams) + '&key=' + terminalInfo.value.terminalKey;
const sign = hexMD5(signStr).toUpperCase();
payParams.value = {
...signParams,
sign: sign
};
});
const buildSignParams = computed(() => {
return sortASCII({
const buildSqbParams = computed(() => {
const params = sortASCII({
client_sn: orderBean.value?.id || '',
return_url: '/pages/payResult/index',
return_url: '/pages/common/payresult/index',
total_amount: ((orderBean.value?.totalPrice || 0) * 100).toString(),
terminal_sn: terminalInfo.value.terminalSn,
subject: '商品团购券',
@@ -89,6 +70,11 @@ const buildSignParams = computed(() => {
merchant_name: terminalInfo.value.companyName,
notify_url: 'https://www.baidu.com'
}, true);
return {
...params,
sign: hexMD5(parseParameter(params) + '&key=' + terminalInfo.value.terminalKey).toUpperCase()
};
});
const navigateTo = (e: any) => {
@@ -105,7 +91,7 @@ const navigateTo = (e: any) => {
const payment = () => {
const params = {
'id': orderBean.value?.id,
'orderSn': buildSignParams.value.client_sn,
'orderSn': buildSqbParams.value.client_sn,
'terminal_key': terminalInfo.value.terminalKey,
'terminal_sn': terminalInfo.value.terminalSn
};

View File

@@ -0,0 +1,11 @@
<template>
<text>支付成功</text>
</template>
<script lang='ts' setup>
</script>
<style lang='scss' scoped>
</style>

View File

@@ -2,14 +2,14 @@
<view class='u-flex-column'>
<swiper class='swiper' :indicator-dots='true' :autoplay='true' :interval='3000' :duration='1000'
@change='swiperChange'>
<swiper-item v-for='(item, index) in bannerList' :key='index'>
<image :src='item' mode='aspectFill' />
<swiper-item v-for='(item, index) in companyConfigInfo?.bannerinx' :key='index'>
<image :src='item.src' mode='aspectFill' />
</swiper-item>
</swiper>
<view class='basic-view'>
<view class='indicator-view'>
<view v-for='(item,index) in bannerList' :key='item' class='normal'
<view v-for='(item,index) in companyConfigInfo?.bannerinx' :key='item' class='normal'
:class="{'active': index === currentBannerIndex}">
</view>
</view>
@@ -26,6 +26,10 @@
<text class='accent-text-color'>{{ userInfo?.balance || 0 }}</text>
<text>余额()</text>
</view>
<view class='divider' style='height: 83rpx' />
<view class='switch-view' @click.stop='switchCompany'>
<image :src='assetsUrl("ic_switch_company.png")' />
</view>
</view>
<view class='menu-view'>
@@ -53,8 +57,8 @@
<view class='bottom-banner-view'>
<swiper :indicator-dots='true' :autoplay='true' :interval='3000' :duration='1000'>
<swiper-item v-for='(item, index) in recommendBannerList' :key='index'>
<image :src='item' mode='aspectFill' />
<swiper-item v-for='(item, index) in companyConfigInfo.bannerhot' :key='index'>
<image :src='item.src' mode='aspectFill' />
</swiper-item>
</swiper>
</view>
@@ -63,17 +67,15 @@
</template>
<script setup lang='ts'>
import { getCompanyInfo, getCompanyList } from '@/api/company';
import { getCompanyList } from '@/api/company';
import { useUserStore } from '@/store';
import { assetsUrl, defaultAvatar } from '@/utils/assets';
import { getCompanyId, goPath, isLogin, setCompanyId } from '@/utils';
import { getCompanyId, goPath, isLogin } from '@/utils';
import { storeToRefs } from 'pinia';
const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore);
const bannerList = ref<string[]>([]);
const { userInfo, companyConfigInfo } = storeToRefs(userStore);
const currentBannerIndex = ref(0);
const recommendBannerList = ref<string[]>([]);
const submenuList = [
{
@@ -99,31 +101,31 @@ onLoad((e) => {
onShow(async () => {
if(isLogin()) {
const data = await getCompanyInfo(userInfo.value.companyId);
bannerList.value = data.bannerinx?.map((res: { src: string }) => res.src);
recommendBannerList.value = data.bannerhot?.map((res: { src: string }) => res.src);
if(userInfo.value.maOpenId) {
getCompanyList(userInfo.value.maOpenId).then(res => {
const companyList = res.map((res: { company: any }) => res.company);
const userList = res.map((res: { user: any }) => res.user);
// if(!getCompanyId()) {
uni.showActionSheet({
itemList: companyList.map((res: { companyName: string }) => res.companyName),
success: (res) => {
setCompanyId(companyList[res.tapIndex].id);
userStore.setUserInfo(userList[res.tapIndex]);
userStore.fetchTerminal();
}
});
// }
});
if(getCompanyId() === '') {
switchCompany();
}
} else {
await userStore.getProfile();
}
} else {
// setToken('42ae187265fb4688804fd294cbcf99f1')
}
});
const switchCompany = () => {
getCompanyList(userInfo.value.maOpenId).then(res => {
const companyList = res.map((res: { company: any }) => res.company);
const userList = res.map((res: { user: any }) => res.user);
uni.showActionSheet({
itemList: companyList.map((res: { companyName: string }) => res.companyName),
success: (res) => {
userStore.setUserInfo(userList[res.tapIndex]);
}
});
});
};
const swiperChange = (e: any) => {
currentBannerIndex.value = e.detail.current;
};
@@ -223,6 +225,13 @@ const swiperChange = (e: any) => {
font-weight: bold;
}
}
.switch-view {
image {
width: 50rpx;
height: 50rpx;
}
}
}
.divider {

View File

@@ -1,5 +1,5 @@
<template>
<view class='content'>
<view class='content' v-if='companyConfigInfo.mallopen==0'>
<view class='search-view'>
<view class='search-input' @click.stop='goPath("/pages/mall/subs/search/index")'>
<image :src=' assetsUrl("ic_search.png")'></image>
@@ -34,6 +34,9 @@
<text v-if='shoppingCartList.length>0'>{{ shoppingCartList?.length }}</text>
</view>
</view>
<view class='content' v-else style='align-items: center;justify-content:center;'>
<image :src='assetsUrl("bg_mall_close.png")' style='width: 200rpx; height: 200rpx;' />
</view>
<sku-dialog ref='skuDialogRef' />
</template>
@@ -44,7 +47,10 @@ import { goLogin, goPath, isLogin } from '@/utils';
import { getCategoryList, getGoodsList } from '@/api/goods';
import { CategoryBean, GoodsBean } from '@/api/goods/types';
import useShoppingCartStore from '@/store/modules/shoppingcart';
import { useUserStore } from '@/store';
const userStore = useUserStore();
const { userInfo, companyConfigInfo } = storeToRefs(userStore);
const shoppingCartStore = useShoppingCartStore();
const { shoppingCartList } = storeToRefs(shoppingCartStore);
@@ -59,6 +65,15 @@ onLoad(() => {
return;
}
userStore.$onAction(({ name, after }) => {
after(() => {
//更新用户信息
if(name === 'setUserInfo') {
fetchCategoryList();
}
});
});
fetchCategoryList();
});

View File

@@ -61,9 +61,9 @@
<text class='card-view-title'>商品总价</text>
<text class='card-view-value'>{{ orderBean?.totalPrice || 0 }}</text>
</view>
<view class='c-flex-row'>
<view class='c-flex-row' style='display: none'>
<text class='card-view-title'>运费</text>
<text class='card-view-value'>8</text>
<text class='card-view-value'>0</text>
</view>
<view class='c-flex-row' @click.stop='showCouponDialog'>
<text class='card-view-title'>优惠券
@@ -95,15 +95,15 @@
<text>合计</text>
<text>{{ orderBean?.totalPrice || 0 }}</text>
<sqb-pay @bindnavigateTo='navigateTo'
:return_url='payParams.return_url'
:total_amount='payParams.total_amount'
:terminal_sn='payParams.terminal_sn'
:client_sn='payParams.client_sn'
:subject='payParams.subject'
:subject_img='payParams.subject_img '
:merchant_name='payParams.merchant_name'
:notify_url='payParams.notify_url'
:sign='payParams.sign'>
:return_url='buildSqbParams.return_url'
:total_amount='buildSqbParams.total_amount'
:terminal_sn='buildSqbParams.terminal_sn'
:client_sn='buildSqbParams.client_sn'
:subject='buildSqbParams.subject'
:subject_img='buildSqbParams.subject_img '
:merchant_name='buildSqbParams.merchant_name'
:notify_url='buildSqbParams.notify_url'
:sign='buildSqbParams.sign'>
<button class='confirm-order' @click='payment'>确认订单</button>
</sqb-pay>
</view>
@@ -134,28 +134,16 @@ const tabIndex = ref(0);
const checkedCoupon = ref<CouponBean>();
const payParams = ref({
return_url: '',
total_amount: '',
client_sn: '',
terminal_sn: '',
subject: '',
subject_img: '',
merchant_name: '',
notify_url: '',
sign: ''
});
const orderBean = ref<OrderBean>();
onLoad((e) => {
orderBean.value = JSON.parse(decodeURIComponent(e?.orderBean));
});
const buildSignParams = computed(() => {
return sortASCII({
const buildSqbParams = computed(() => {
const params = sortASCII({
client_sn: orderBean.value?.id || '',
return_url: '/pages/payResult/index',
return_url: '/pages/common/payresult/index',
total_amount: ((orderBean.value?.totalPrice || 0) * 100).toString(),
terminal_sn: terminalInfo.value.terminalSn,
subject: orderBean?.value?.orderGoods[0].name,
@@ -163,6 +151,11 @@ const buildSignParams = computed(() => {
merchant_name: terminalInfo.value.companyName,
notify_url: 'https://www.baidu.com'
}, true);
return {
...params,
sign: hexMD5(parseParameter(params) + '&key=' + terminalInfo.value.terminalKey).toUpperCase()
};
});
const changePayment = () => {
@@ -216,17 +209,18 @@ const payment = async () => {
}
))
};
console.log('----------->>>>>params ', buildSqbParams.value);
const result = await orderCreate(params);
orderBean.value!.id = result.id;
let signParams = buildSignParams.value;
const signStr = parseParameter(signParams) + '&key=' + terminalInfo.value.terminalKey;
const sign = hexMD5(signStr).toUpperCase();
payParams.value = {
...signParams,
sign: sign
};
// let signParams = buildSignParams.value;
// const signStr = parseParameter(signParams) + '&key=' + terminalInfo.value.terminalKey;
// const sign = hexMD5(signStr).toUpperCase();
// payParams.value = {
// ...signParams,
// sign: sign
// };
uni.hideLoading();
};

View File

@@ -3,7 +3,7 @@
<view class='user-info-view'>
<image
class='image-bg'
:src=" assetsUrl('test_bg.png')"
:src='companyConfigInfo.userbgcover'
/>
<view class='top-row'>
@@ -18,15 +18,15 @@
<view class='bottom-row'>
<view @click.stop='gotoPath("/pages/mine/subs/integral/index")'>
<text>{{ userInfo?.integration||0 }}</text>
<text>{{ userInfo?.integration || 0 }}</text>
<text>积分</text>
</view>
<view @click.stop='gotoPath("/pages/mine/subs/recharge/index")'>
<text>{{ userInfo?.balance||0 }}</text>
<text>{{ userInfo?.balance || 0 }}</text>
<text>余额</text>
</view>
<view @click.stop='gotoPath("/pages/mine/subs/coupon/index")'>
<text>{{ userInfo?.couponsCount || 0}}</text>
<text>{{ userInfo?.couponsCount || 0 }}</text>
<text>优惠券</text>
</view>
</view>
@@ -122,7 +122,7 @@ const title = ref<string>();
title.value = import.meta.env.VITE_APP_TITLE;
const store = useUserStore();
const { userInfo } = storeToRefs(store);
const { userInfo, companyConfigInfo } = storeToRefs(store);
onLoad(() => {
if(!isLogin()) {

View File

@@ -10,7 +10,7 @@
<text class='secondary-text-color' style='flex: 1'>{{ item?.createtime }}</text>
<text style='color: #999999'>会员积分30.00</text>
</view>
<view class='divider' style='margin-top: 20rpx'/>
<!-- <view class='divider' style='margin-top: 20rpx'/>-->
<!-- </view>-->
</view>
</template>
@@ -28,7 +28,7 @@ defineProps({
display: flex;
flex-direction: column;
padding: 16rpx 23rpx 20rpx 30rpx;
margin: 20rpx 0;
margin: 10rpx 0;
}
.category-title {

View File

@@ -1,12 +1,14 @@
<template>
<view class='content'>
<view class='top-view c-flex-column'>
<text>{{ userInfo.integration }}</text>
<text>{{ userInfo?.integration }}</text>
<text>会员积分</text>
</view>
<text class='integral-detail-title'>积分明细</text>
<scroll-view style='margin: 10rpx 20rpx'>
<integral-item v-for='(item,index) in tradeList' :key='index' :item='item' />
<u-list @scrolltolower='loadMore'>
<integral-item v-for='(item,index) in tradeList' :key='index' :item='item' />
</u-list>
</scroll-view>
</view>
</template>
@@ -19,16 +21,26 @@ import { useUserStore } from '@/store';
const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore);
const tradeList = ref([]);
const currentPageNum = ref(1);
onLoad((e) => {
fetchData();
});
const fetchData = async () => {
const fetchData = async (refresh: boolean = true) => {
currentPageNum.value = refresh ? 1 : currentPageNum.value + 1;
const { rows } = await getIntegralList({
fbean: { 'pageNum': 1, 'pageSize': 10, 'bean': {} }
fbean: { 'pageNum': currentPageNum.value, 'pageSize': 20, 'bean': {} }
});
tradeList.value = rows;
if(refresh) {
tradeList.value = rows;
} else {
tradeList.value = tradeList.value.concat(rows);
}
};
const loadMore = () => {
fetchData(false);
};
</script>

View File

@@ -5,7 +5,9 @@
<view class='c-flex-column' style='flex: 1;'>
<view class='c-flex-row'>
<text class='goods-name'>{{ item?.orderGoods[0].goodsName }}</text>
<text class='status'>未支付</text>
<text class='status'>
{{ item?.payStatus == 2 ? '已支付' : '未支付' }}
</text>
</view>
<view class='bottom-view c-flex-row'>
<text>
@@ -19,30 +21,43 @@
</view>
</view>
<view class='action-view c-flex-row'>
<view class='countdown c-flex-row'>
<view class='countdown c-flex-row' v-if='item?.payStatus==1'>
<image :src='assetsUrl("ic_time.png")' />
<text class='primary-text-color'>支付剩余时间
<text class='accent-text-color'>05:23</text>
</text>
</view>
<view v-else style='flex: 1' />
<view class='c-flex-row'>
<text class='secondary-text-color'>加入购物车</text>
<text class='accent-text-color'>立即支付</text>
<text class='add-shoppingcart secondary-text-color' @click.stop='add(item?.orderGoods[0])'>加入购物车</text>
<text class='payment accent-text-color' v-if='item?.payStatus==1' @click.stop='pay(item?.id)'>立即支付
</text>
</view>
</view>
</view>
</template>
<script lang='ts' setup>
import { PropType } from 'vue';
import { assetsUrl } from '@/utils/assets';
import { goPath } from '@/utils';
import { PropType } from 'vue';
import { OrderBean } from '@/api/order/types';
import { GoodsBean } from '@/api/goods/types';
const emits = defineEmits(['addShoppingCart', 'payment']);
defineProps({
item: Object as PropType<OrderBean>
});
const add = (item: GoodsBean | undefined) => {
emits('addShoppingCart', item);
};
const pay = (orderId: string) => {
emits('payment', orderId);
};
</script>
<style lang='scss' scoped>
@@ -135,11 +150,12 @@ defineProps({
border-radius: 34rpx;
}
text:nth-of-type(1) {
.add-shoppingcart {
border: 1rpx solid #ACACAC;
}
text:nth-of-type(2) {
.payment {
border: 1rpx solid #F32B2B;
margin-left: 20rpx;
}

View File

@@ -1,7 +1,7 @@
<template>
<scroll-view scroll-y>
<view class='content'>
<view class='countdown c-flex-row'>
<view class='countdown c-flex-row' v-if='orderBean?.order.payStatus==1'>
<image :src='assetsUrl("ic_order.png")' />
<view class='c-flex-column'>
<text>
@@ -66,13 +66,13 @@
</view>
<view class='c-flex-row'>
<text class='card-view-title'>运费</text>
<text class='card-view-value'>8</text>
<text class='card-view-value'>0</text>
</view>
<view class='c-flex-row'>
<text class='card-view-title'>优惠券
<text style='font-size: 22rpx;color: #F32B2B;'>已选最大优惠</text>
</text>
<text class='card-view-value' style='color: #F32B2B;margin: 0'>-{{orderBean?.order?.reducePrice}}
<text class='card-view-value' style='color: #F32B2B;margin: 0'>-{{ orderBean?.order?.reducePrice }}
</text>
</view>
<view class='divider' />
@@ -93,9 +93,19 @@
<text>下单时间{{ orderBean?.order?.createTime }}</text>
</view>
<view class='bottom-action-view c-flex-row'>
<view class='bottom-action-view c-flex-row' v-if='orderBean?.order.payStatus==1'>
<text @click.stop='cancel'>取消订单</text>
<text @click.stop='payment'>立即支付</text>
<sqb-pay @bindnavigateTo='navigateTo'
:return_url='buildSqbParams.return_url'
:total_amount='buildSqbParams.total_amount'
:terminal_sn='buildSqbParams.terminal_sn'
:client_sn='buildSqbParams.client_sn'
:subject='buildSqbParams.subject'
:merchant_name='buildSqbParams.merchant_name'
:notify_url='buildSqbParams.notify_url'
:sign='buildSqbParams.sign'>
<button @click='payment'>立即支付</button>
</sqb-pay>
</view>
</view>
</scroll-view>
@@ -105,6 +115,12 @@
import { assetsUrl } from '@/utils/assets';
import { getOrderDetail } from '@/api/order';
import { OrderBean } from '@/api/order/types';
import { parseParameter, sortASCII } from '@/utils';
import { hexMD5 } from '@/utils/common/md5';
import { useUserStore } from '@/store';
const userState = useUserStore();
const { terminalInfo } = storeToRefs(userState);
const orderBean = ref<{
order: OrderBean,
@@ -113,13 +129,43 @@ const orderBean = ref<{
}>();
onLoad(async (e: any) => {
await uni.showLoading();
orderBean.value = await getOrderDetail(e.orderId);
uni.hideLoading();
});
const buildSqbParams = computed(() => {
const params = sortASCII({
client_sn: orderBean.value?.order?.id || '',
return_url: '/pages/common/payresult/index',
total_amount: ((orderBean.value?.order?.totalPrice || 0) * 100).toString(),
terminal_sn: terminalInfo.value.terminalSn,
subject: '商品支付',
merchant_name: terminalInfo.value.companyName,
notify_url: 'https://www.baidu.com'
}, true);
return {
...params,
sign: hexMD5(parseParameter(params) + '&key=' + terminalInfo.value.terminalKey).toUpperCase()
};
});
const navigateTo = (e: any) => {
console.log('--------------_>>>>>>navigateTo ', e);
uni.redirectTo({
url: e.detail.url,
fail(e) {
uni.showToast({
title: '支付失败'
});
}
});
};
const cancel = () => {
};
const payment = () => {
console.log(buildSqbParams.value);
};
</script>
@@ -334,6 +380,7 @@ const payment = () => {
.bottom-action-view {
background: #FFFFFF;
position: fixed;
height: 80rpx;
justify-content: flex-end;
bottom: 0;
left: 0;
@@ -350,11 +397,12 @@ const payment = () => {
margin-right: 20rpx;
}
text:nth-of-type(2) {
padding: 17rpx 45rpx;
sqb-pay button {
padding: 0 45rpx;
border-radius: 50rpx;
border: 1rpx solid #F32B2B;
font-weight: bold;
background: #FFFFFF;
font-size: 30rpx;
color: #F32B2B;
}

View File

@@ -2,18 +2,28 @@
<tabbar :titles="['全部', '进行中', '已结束']" @change='tabChange' />
<u-list :list='orderList' :border='false' @scrolltolower='loadMore'>
<u-list-item v-for='(item,index) in orderList' :key='index'>
<order-item :item='item' />
<order-item :item='item' @addShoppingCart='addShoppingCart' @pay='payment' />
</u-list-item>
<u-loadmore status='loading' />
</u-list>
<sku-dialog ref='skuDialogRef' :exists='temporaryStockBean' />
</template>
<script lang='ts' setup>
import { ref } from 'vue';
import { getOrderList } from '@/api/order';
import OrderItem from '@/pages/mine/subs/order/components/order-item.vue';
import { OrderBean } from '@/api/order/types';
import SkuDialog from '@/components/sku-dialog.vue';
import { GoodsBean, StockBean } from '@/api/goods/types';
import { showToast } from '@/utils';
import useShoppingCartStore from '@/store/modules/shoppingcart';
const shoppingCartStore = useShoppingCartStore();
const skuDialogRef = ref();
const temporaryStockBean = ref<StockBean>();
const orderList = ref<OrderBean[]>([]);
const currentPageNum = ref(1);
const payStatus = ref(0);
@@ -46,6 +56,17 @@ const fetchData = async (refresh: boolean = true) => {
const loadMore = () => {
fetchData(false);
};
const addShoppingCart = (item: GoodsBean) => {
skuDialogRef.value.show(item.goodsId, (e: GoodsBean) => {
shoppingCartStore.save(e);
showToast('加入购物车成功');
});
};
const payment = (orderId: string) => {
console.log(orderId);
};
</script>
<style lang='scss' scoped>

View File

@@ -1,7 +1,7 @@
<template>
<view class='content'>
<view class='top-card-view'>
<image class='bg-image' :src='assetsUrl("test_bg.png")' />
<image class='bg-image' :src='companyConfigInfo.userbgcover' />
<image class='avatar-image' :src='params.avatarUrl' />
<text>{{ userInfo.name }}</text>
<text>{{ userInfo.levelName }}</text>
@@ -61,7 +61,7 @@ import { useUserStore } from '@/store';
import { showToast } from '@/utils';
const store = useUserStore();
const { userInfo } = storeToRefs(store);
const { userInfo,companyConfigInfo } = storeToRefs(store);
const params = ref<{
avatarUrl: string;

View File

@@ -8,7 +8,7 @@
</view>
<view class='balance-content'>
<text>当前余额</text>
<text class='accent-text-color'>{{ userInfo.balance }}</text>
<text class='accent-text-color'>{{ userInfo?.balance }}</text>
</view>
</view>
@@ -27,7 +27,19 @@
</view>
<view class='bottom-button-view'>
<button class='primary-button' @click.stop='goRecharge'>充值</button>
<!-- <payment-button style='flex: 1' :payParams='buildSignParams'>-->
<sqb-pay style='width: 100%;' @bindnavigateTo='navigateTo'
:return_url='buildSqbParams.return_url'
:total_amount='buildSqbParams.total_amount'
:terminal_sn='buildSqbParams.terminal_sn'
:client_sn='buildSqbParams.client_sn'
:subject='buildSqbParams.subject'
:merchant_name='buildSqbParams.merchant_name'
:notify_url='buildSqbParams.notify_url'
:sign='buildSqbParams.sign'>
<button class='primary-button' @click='goRecharge'>充值</button>
</sqb-pay>
<!-- </payment-button>-->
</view>
</view>
</template>
@@ -36,9 +48,11 @@
import { assetsUrl } from '@/utils/assets';
import { useUserStore } from '@/store';
import { getRechargeList, recharge } from '@/api/user';
import { parseParameter, sortASCII } from '@/utils';
import { hexMD5 } from '@/utils/common/md5';
const store = useUserStore();
const { userInfo } = storeToRefs(store);
const userState = useUserStore();
const { userInfo, terminalInfo } = storeToRefs(userState);
const rechargeItems = ref<{
itemid: string
@@ -52,13 +66,44 @@ const currentIndex = ref<number>(0);
onLoad(async () => {
const { ruleitems } = await getRechargeList();
rechargeItems.value = ruleitems;
change(0);
});
const change = (index: number) => {
currentIndex.value = index;
};
const buildSqbParams = computed(() => {
const params = sortASCII({
// client_sn: rechargeItems.value[currentIndex.value]?.itemid || '',
client_sn: Date.now().toString(),
return_url: '/pages/common/payresult/index',
total_amount: ((rechargeItems.value[currentIndex.value]?.rechargeamount || 0) * 100).toString(),
terminal_sn: terminalInfo.value.terminalSn,
subject: '充值',
merchant_name: terminalInfo.value.companyName,
notify_url: 'https://www.baidu.com'
}, true);
return {
...params,
sign: hexMD5(parseParameter(params) + '&key=' + terminalInfo.value.terminalKey).toUpperCase()
};
});
const navigateTo = (e: any) => {
console.log('--------------_>>>>>>navigateTo ', e);
uni.redirectTo({
url: e.detail.url,
fail(e) {
uni.showToast({
title: '支付失败'
});
}
});
};
const goRecharge = () => {
console.log(buildSqbParams.value);
recharge({
itemid: rechargeItems.value[currentIndex.value].itemid
});

View File

@@ -1,5 +1,6 @@
<template>
<tabbar :titles='["全部","充值","消费"]' :item-active-color='"#D95554"' :indicator-color='"#D95554"' />
<tabbar :titles='["全部","充值","消费"]' @change='changeTab' :item-active-color='"#D95554"'
:indicator-color='"#D95554"' />
<view class='content'>
<view class='c-flex-row'>
<text>选择日期</text>
@@ -11,20 +12,33 @@
</picker>
</view>
<scroll-view :scroll-y='true'>
<u-list @scrolltolower='loadMore'>
<trade-item v-for='(item,index) in tradeList' :key='index' :item='item' />
</scroll-view>
</u-list>
</view>
</template>
<script lang='ts' setup>
import { assetsUrl } from '@/utils/assets';
import TradeItem from '@/pages/mine/subs/trade/components/trade-item.vue';
import TradeItem from './components/trade-item.vue';
const tradeList = ref([1, 2, 3, 4, 5]);
const currentPageNum = ref(1);
const changeDate = () => {
fetchData();
};
const changeTab = (index: number) => {
fetchData();
};
const fetchData = (refresh: boolean = true) => {
currentPageNum.value = refresh ? 1 : currentPageNum.value + 1;
};
const loadMore = () => {
fetchData(false);
};
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -61,7 +61,7 @@ page {
padding: 10rpx 30rpx 78rpx 30rpx;
button {
width: 100%;
width: 100% !important;
}
}

View File

@@ -3,11 +3,21 @@ 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 type { LoginResult, RegisterParams, TerminalBean } from '@/api/user/types';
import { getCompanyInfo } from '@/api/company';
const useUserStore = defineStore('user', {
state: () => ({
userInfo: {} as UserBean,
terminalInfo: {} as TerminalBean
terminalInfo: {} as TerminalBean,
companyConfigInfo: {
bannerhot: [] as any[],
bannerinx: [] as any[],
goodsdisable: 0,
goodsstockzero: 0,
mallopen: 0,
regqrcode: undefined,
userbgcover: undefined
}
}),
persist: {
@@ -33,9 +43,13 @@ const useUserStore = defineStore('user', {
actions: {
// 设置用户的信息
setUserInfo(partial: Partial<UserBean>) {
async setUserInfo(partial: Partial<UserBean>) {
this.userInfo = partial as UserBean;
setCompanyId(this.userInfo.companyId);
await this.fetchCompanyInfo();
await this.fetchTerminal();
},
// 重置用户信息
resetInfo() {
this.$reset();
@@ -43,8 +57,11 @@ const useUserStore = defineStore('user', {
// 获取用户信息
async getProfile() {
const result = await getUserProfile();
this.setUserInfo(result);
await this.fetchTerminal();
await this.setUserInfo(result);
},
async fetchCompanyInfo() {
this.companyConfigInfo = await getCompanyInfo();
},
userRegister(registerForm: RegisterParams) {
@@ -104,11 +121,11 @@ const useUserStore = defineStore('user', {
const registerResult = await this.userRegister(registerForm);
this.setUserInfo(registerResult as LoginResult);
setToken(res.token);
// setCompanyId(res.user.companyId);
setCompanyId(res.user.companyId);
} else {
this.setUserInfo(res.user);
setToken(res.token);
// setCompanyId(res.user.companyId);
setCompanyId(res.user.companyId);
}
resolve(res);
} else {