update uni-app

This commit is contained in:
全栈小学生 2023-08-12 16:13:35 +08:00
parent 72bd5a1ba3
commit ffa8719298
18 changed files with 750 additions and 83 deletions

View File

@ -32,14 +32,18 @@ export function logout() {
*
*/
export function usernameRegister(data : AnyObject) {
return request.post('register', data, { showErrorMessage: true })
let url = 'register'
data.pid && (url += `?pid=${data.pid}`)
return request.post(url, data, { showErrorMessage: true })
}
/**
*
*/
export function mobileRegister(data : AnyObject) {
return request.post('register/mobile', data, { showErrorMessage: true })
let url = 'register/mobile'
data.pid && (url += `?pid=${data.pid}`)
return request.post(url, data, { showErrorMessage: true })
}
/**
@ -60,7 +64,9 @@ export function weappLogin(data : AnyObject) {
*
*/
export function bind(data : AnyObject) {
return request.post('bind', data, { showErrorMessage: true })
let url = 'bind'
data.pid && (url += `?pid=${data.pid}`)
return request.post(url, data, { showErrorMessage: true })
}
/**

View File

@ -10,6 +10,6 @@ export function pay(data : AnyObject) {
/**
*
*/
export function getPayInfo(outTradeNo : string) {
return request.get(`pay/info/${outTradeNo}`, {}, { showErrorMessage: true })
export function getPayInfo(tradeType : string, tradeId : number) {
return request.get(`pay/info/${tradeType}/${tradeId}`, {}, { showErrorMessage: true })
}

View File

@ -6,8 +6,6 @@
:class="{ selected: diyStore.currentIndex == index,decorate : diyStore.mode == 'decorate' }"
:style="component.pageStyle">
<fixed-group :component="component" :index="index" :pullDownRefresh="props.pullDownRefresh"></fixed-group>
<template v-if="component.componentName == 'Article'">
<diy-article :component="component" :index="index"
:pullDownRefresh="props.pullDownRefresh"></diy-article>
@ -31,6 +29,12 @@
<template v-if="component.componentName == 'Text'">
<diy-text :component="component" :index="index" :pullDownRefresh="props.pullDownRefresh"></diy-text>
</template>
<template v-if="component.componentName == 'RubikCube'">
<diy-rubik-cube :component="component" :index="index" :pullDownRefresh="props.pullDownRefresh"></diy-rubik-cube>
</template>
<template v-if="component.componentName == 'HotArea'">
<diy-hot-area :component="component" :index="index" :pullDownRefresh="props.pullDownRefresh"></diy-hot-area>
</template>
</view>
<template v-if="diyStore.mode != 'decorate' && data.global.bottomTabBarSwitch">
<view class="pt-[20rpx]"></view>

View File

@ -0,0 +1,83 @@
<template>
<view :style="warpCss">
<view class="simple-graph-wrap overflow-hidden relative leading-0">
<image :style="{ height: diyComponent.imgHeight }" :src="img(diyComponent.imageUrl)" mode="widthFix"
:show-menu-by-longpress="true" class="w-full"></image>
<template v-if="diyStore.mode != 'decorate'">
<!-- 热区功能 -->
<app-link :data="mapItem.link" class="absolute" v-for="(mapItem, mapIndex) in diyComponent.heatMapData"
:key="mapIndex" :style="{
width: mapItem.width + '%',
height: mapItem.height + '%',
left: mapItem.left + '%',
top: mapItem.top + '%'
}"></app-link>
</template>
</view>
</view>
</template>
<script setup lang="ts">
//
import { computed, watch, onMounted } from 'vue';
import useDiyStore from '@/stores/diy';
import { img } from '@/utils/common';
const props = defineProps(['component', 'index', 'pullDownRefresh']);
const diyStore = useDiyStore();
const diyComponent = computed(() => {
if (diyStore.mode == 'decorate') {
return diyStore.value[props.index];
} else {
return props.component;
}
})
const warpCss = computed(() => {
var style = '';
if (diyComponent.value.componentBgColor) style += 'background-color:' + diyComponent.value.componentBgColor + ';';
if (diyComponent.value.topRounded) style += 'border-top-left-radius:' + diyComponent.value.topRounded * 2 + 'rpx;';
if (diyComponent.value.topRounded) style += 'border-top-right-radius:' + diyComponent.value.topRounded * 2 + 'rpx;';
if (diyComponent.value.bottomRounded) style += 'border-bottom-left-radius:' + diyComponent.value.bottomRounded * 2 + 'rpx;';
if (diyComponent.value.bottomRounded) style += 'border-bottom-right-radius:' + diyComponent.value.bottomRounded * 2 + 'rpx;';
return style;
})
onMounted(() => {
refresh();
//
watch(
() => diyComponent.value,
(newValue, oldValue) => {
if (newValue && newValue.componentName == 'HotArea') {
refresh();
}
}
)
});
const refresh = () => {
if (diyStore.mode == 'decorate') {
//
if (diyComponent.value.imageUrl == '') {
diyComponent.value.imageUrl = 'static/resource/images/diy/figure.png';
diyComponent.value.imgWidth = 690;
diyComponent.value.imgHeight = 330;
}
}
}
watch(
() => props.pullDownRefresh,
(newValue, oldValue) => {
//
}
)
</script>
<style lang="scss">
</style>

View File

@ -2,7 +2,7 @@
<view class="image-ads" :style="warpCss">
<view v-if="diyComponent.list.length == 1" class="leading-0 overflow-hidden" :style="swiperWarpCss">
<app-link :data="diyComponent.list[0].link">
<image :src="img(diyComponent.list[0].imageUrl)" :style="{height: imgHeight}" mode="scaleToFill"
<image :src="img(diyComponent.list[0].imageUrl)" :style="{height: imgHeight}" mode="heightFix"
class="w-full" :show-menu-by-longpress="true"></image>
</app-link>
</view>
@ -71,9 +71,6 @@
swiperIndex.value = e.detail.current;
};
const handleData = () => {
};
onMounted(() => {
refresh();
//
@ -100,7 +97,6 @@
}
});
}
handleData()
}
</script>

View File

@ -0,0 +1,549 @@
<template>
<view :class="['rubik-cube', diyStore.mode]" :style="warpCss">
<!-- 1左2右 -->
<template v-if="diyComponent.mode == 'row1-lt-of2-rt'">
<view class="template-left">
<app-link :data="diyComponent.list[0].link" :class="['item', diyComponent.mode]"
:style="{ marginRight: diyComponent.imageGap * 2 + 'rpx', width: diyComponent.list[0].imgWidth, height: diyComponent.list[0].imgHeight + 'px' }">
<image :src="img(diyComponent.list[0].imageUrl)" mode="scaleToFill"
:style="diyComponent.list[0].pageItemStyle" :show-menu-by-longpress="true"></image>
</app-link>
</view>
<view class="template-right">
<template v-for="(item, index) in diyComponent.list" :key="index">
<template v-if="index > 0">
<app-link :data="item.link" :class="['item', diyComponent.mode]"
:style="{ marginBottom: diyComponent.imageGap * 2 + 'rpx', width: item.imgWidth, height: item.imgHeight + 'px' }">
<image :src="img(item.imageUrl)" mode="scaleToFill" :style="item.pageItemStyle"
:show-menu-by-longpress="true"></image>
</app-link>
</template>
</template>
</view>
</template>
<!-- 1左3右 -->
<template v-else-if="diyComponent.mode == 'row1-lt-of1-tp-of2-bm'">
<view class="template-left">
<app-link :data="diyComponent.list[0].link" :class="['item', diyComponent.mode]"
:style="{ marginRight: diyComponent.imageGap * 2 + 'rpx', width: diyComponent.list[0].imgWidth, height: diyComponent.list[0].imgHeight + 'px' }">
<image :src="img(diyComponent.list[0].imageUrl)" mode="scaleToFill"
:style="diyComponent.list[0].pageItemStyle" :show-menu-by-longpress="true"></image>
</app-link>
</view>
<view class="template-right">
<app-link :data="diyComponent.list[1].link" :class="['item', diyComponent.mode]"
:style="{ marginBottom: diyComponent.imageGap * 2 + 'rpx', width: diyComponent.list[1].imgWidth, height: diyComponent.list[1].imgHeight + 'px' }">
<image :src="img(diyComponent.list[1].imageUrl)" mode="scaleToFill"
:style="diyComponent.list[1].pageItemStyle" :show-menu-by-longpress="true"></image>
</app-link>
<view class="template-bottom">
<template v-for="(item, index) in diyComponent.list" :key="index">
<template v-if="index > 1">
<app-link :data="item.link" :class="['item', diyComponent.mode]" :style="{
marginRight: diyComponent.imageGap * 2 + 'rpx',
width: item.imgWidth,
height: item.imgHeight + 'px'
}">
<image :src="img(item.imageUrl)" mode="scaleToFill" :style="item.pageItemStyle"
:show-menu-by-longpress="true"></image>
</app-link>
</template>
</template>
</view>
</view>
</template>
<template v-else>
<app-link :class="['item', diyComponent.mode]" v-for="(item, index) in diyComponent.list" :key="index"
:data="item.link"
:style="{ marginRight: diyComponent.imageGap * 2 + 'rpx', marginBottom: diyComponent.imageGap * 2 + 'rpx', width: item.widthStyle, height: item.imgHeight + 'px' }">
<image :src="img(item.imageUrl)" :mode="'scaleToFill'" :style="item.pageItemStyle"
:show-menu-by-longpress="true"></image>
</app-link>
</template>
</view>
</template>
<script setup lang="ts">
//
import { onMounted, computed, watch } from 'vue';
import useDiyStore from '@/stores/diy';
import { img } from '@/utils/common';
const props = defineProps(['component', 'index', 'pullDownRefresh']);
const diyStore = useDiyStore();
const diyComponent = computed(() => {
if (diyStore.mode == 'decorate') {
return diyStore.value[props.index];
} else {
return props.component;
}
})
const warpCss = computed(() => {
var style = '';
if (diyComponent.value.componentBgColor) style += 'background-color:' + diyComponent.value.componentBgColor + ';';
if (diyComponent.value.topRounded) style += 'border-top-left-radius:' + diyComponent.value.topRounded * 2 + 'rpx;';
if (diyComponent.value.topRounded) style += 'border-top-right-radius:' + diyComponent.value.topRounded * 2 + 'rpx;';
if (diyComponent.value.bottomRounded) style += 'border-bottom-left-radius:' + diyComponent.value.bottomRounded * 2 + 'rpx;';
if (diyComponent.value.bottomRounded) style += 'border-bottom-right-radius:' + diyComponent.value.bottomRounded * 2 + 'rpx;';
return style;
})
const countBorderRadius = (type, index) => {
var obj = '';
if (diyComponent.value.elementAngle == 'right') {
return obj;
}
var defaultData = {
'row1-lt-of2-rt': [
['border-top-right-radius', 'border-bottom-right-radius'],
['border-top-left-radius', 'border-bottom-left-radius', 'border-bottom-right-radius'],
['border-top-left-radius', 'border-bottom-left-radius', 'border-top-right-radius']
],
'row1-lt-of1-tp-of2-bm': [
['border-top-right-radius', 'border-bottom-right-radius'],
['border-top-left-radius', 'border-bottom-left-radius', 'border-bottom-right-radius'],
['border-radius'],
['border-top-left-radius', 'border-bottom-left-radius', 'border-top-right-radius']
],
'row1-tp-of2-bm': [
['border-bottom-left-radius', 'border-bottom-right-radius'],
['border-top-left-radius', 'border-bottom-right-radius', 'border-top-right-radius'],
['border-top-left-radius', 'border-bottom-left-radius', 'border-top-right-radius']
],
'row2-lt-of2-rt': [
['border-top-right-radius', 'border-bottom-left-radius', 'border-bottom-right-radius'],
['border-top-left-radius', 'border-bottom-right-radius', 'border-bottom-left-radius'],
['border-top-left-radius', 'border-bottom-right-radius', 'border-top-right-radius'],
['border-top-left-radius', 'border-bottom-left-radius', 'border-top-right-radius']
],
'row1-of4': [
['border-top-right-radius', 'border-bottom-right-radius'],
['border-radius'],
['border-radius'],
['border-top-left-radius', 'border-bottom-left-radius']
],
'row1-of3': [
['border-top-right-radius', 'border-bottom-right-radius'],
['border-radius'],
['border-top-left-radius', 'border-bottom-left-radius']
],
'row1-of2': [
['border-top-right-radius', 'border-bottom-right-radius'],
['border-top-left-radius', 'border-bottom-left-radius']
]
};
defaultData[type][index].forEach((item, index) => {
obj += 'border-top-left-radius:' + diyComponent.value.topElementRounded * 2 + 'rpx;';
obj += 'border-top-right-radius:' + diyComponent.value.topElementRounded * 2 + 'rpx;';
obj += 'border-bottom-left-radius:' + diyComponent.value.bottomElementRounded * 2 + 'rpx;';
obj += 'border-bottom-right-radius:' + diyComponent.value.bottomElementRounded * 2 + 'rpx;';
});
return obj;
}
watch(
() => props.pullDownRefresh,
(newValue, oldValue) => {
//
}
)
onMounted(() => {
refresh();
//
watch(
() => diyComponent.value,
(newValue, oldValue) => {
if (newValue && newValue.componentName == 'RubikCube') {
refresh();
}
}
)
});
const refresh = () => {
if (diyStore.mode == 'decorate') {
diyComponent.value.list.forEach((item : any, index) => {
//
if (item.imageUrl == '') {
item.imageUrl = 'static/resource/images/diy/figure.png';
item.imgWidth = 690;
item.imgHeight = 330;
}
});
}
handleData()
}
const handleData = () => {
var singleRow = {
'row1-of2': {
ratio: 2,
width: 'calc((100% - ' + uni.upx2px(diyComponent.value.imageGap * 2) + 'px) / 2)'
},
'row1-of3': {
ratio: 3,
width: 'calc((100% - ' + uni.upx2px(diyComponent.value.imageGap * 4) + 'px) / 3)'
},
'row1-of4': {
ratio: 4,
width: 'calc((100% - ' + uni.upx2px(diyComponent.value.imageGap * 6) + 'px) / 4)'
}
};
diyComponent.value.list.forEach((item, index) => {
item.pageItemStyle = countBorderRadius(diyComponent.value.mode, index);
});
if (singleRow[diyComponent.value.mode]) {
calcSingleRow(singleRow[diyComponent.value.mode]);
} else if (diyComponent.value.mode == 'row2-lt-of2-rt') {
calcFourSquare();
} else if (diyComponent.value.mode == 'row1-lt-of2-rt') {
calcRowOneLeftOfTwoRight();
} else if (diyComponent.value.mode == 'row1-tp-of2-bm') {
calcRowOneTopOfTwoBottom();
} else if (diyComponent.value.mode == 'row1-lt-of1-tp-of2-bm') {
calcRowOneLeftOfOneTopOfTwoBottom();
}
};
/**
* 魔方单行多个平分宽度
* 公式
* 宽度屏幕宽度/2示例375/2=187.5
* 比例原图高/原图宽示例322/690=0.46
* 高度宽度*比例示例187.5*0.46=86.25
*/
const calcSingleRow = (params) => {
uni.getSystemInfo({
success: res => {
let maxHeight = 0;
diyComponent.value.list.forEach((item, index) => {
var ratio = item.imgHeight / item.imgWidth;
let width = res.windowWidth - uni.upx2px(diyComponent.value.margin.both *
2); //
if (diyComponent.value.imageGap > 0) {
width -= uni.upx2px(params.ratio * diyComponent.value.imageGap * 2); //
}
item.imgWidth = width / params.ratio;
item.imgHeight = item.imgWidth * ratio;
if (maxHeight == 0 || maxHeight < item.imgHeight) maxHeight = item
.imgHeight;
})
diyComponent.value.list.forEach((item, index) => {
item.widthStyle = params.width;
item.imgHeight = maxHeight;
});
}
})
};
/**
* 魔方四方型各占50%
*/
const calcFourSquare = () => {
uni.getSystemInfo({
success: res => {
let maxHeightFirst = 0;
let maxHeightTwo = 0;
diyComponent.value.list.forEach((item, index) => {
var ratio = item.imgHeight / item.imgWidth;
item.imgWidth = res.windowWidth;
item.imgWidth -= uni.upx2px(diyComponent.value.margin.both * 4);
if (diyComponent.value.imageGap > 0) {
item.imgWidth -= uni.upx2px(diyComponent.value.imageGap * 2);
}
item.imgWidth = item.imgWidth / 2;
item.imgHeight = item.imgWidth * ratio;
//
if (index <= 1) {
if (maxHeightFirst == 0 || maxHeightFirst < item.imgHeight) {
maxHeightFirst = item.imgHeight;
}
} else if (index > 1) {
if (maxHeightTwo == 0 || maxHeightTwo < item.imgHeight) {
maxHeightTwo = item.imgHeight;
}
}
});
diyComponent.value.list.forEach((item, index) => {
item.imgWidth = 'calc((100% - ' + uni.upx2px(diyComponent.value.imageGap * 2) +
'px) / 2)';
item.widthStyle = item.imgWidth;
if (index <= 1) {
item.imgHeight = maxHeightFirst;
} else if (index > 1) {
item.imgHeight = maxHeightTwo;
}
});
}
});
}
/**
* 魔方1左2右
*/
const calcRowOneLeftOfTwoRight = () => {
let rightHeight = 0; //
let divide = 'left'; // leftright
if (diyComponent.value.list[1].imgWidth === diyComponent.value.list[2].imgWidth) divide = 'right';
uni.getSystemInfo({
success: res => {
diyComponent.value.list.forEach((item, index) => {
if (index == 0) {
var ratio = item.imgHeight / item.imgWidth; //
item.imgWidth = res.windowWidth - uni.upx2px(diyComponent.value.margin
.both * 4) - uni.upx2px(diyComponent.value.imageGap * 2);
item.imgWidth = item.imgWidth / 2;
item.imgHeight = item.imgWidth * ratio;
rightHeight = (item.imgHeight - uni.upx2px(diyComponent.value.imageGap *
2)) / 2;
item.imgWidth += 'px';
} else {
item.imgWidth = diyComponent.value.list[0].imgWidth;
item.imgHeight = rightHeight;
}
});
}
});
}
/**
* 魔方1上2下
*/
const calcRowOneTopOfTwoBottom = () => {
var maxHeight = 0;
uni.getSystemInfo({
success: res => {
diyComponent.value.list.forEach((item, index) => {
var ratio = item.imgHeight / item.imgWidth; //
if (index == 0) {
item.imgWidth = res.windowWidth - uni.upx2px(diyComponent.value.margin
.both * 4);
} else if (index > 0) {
item.imgWidth = res.windowWidth - uni.upx2px(diyComponent.value.margin
.both * 4) - uni.upx2px(diyComponent.value.imageGap * 2);
item.imgWidth = item.imgWidth / 2;
}
item.imgHeight = item.imgWidth * ratio;
//
if (index > 0 && (maxHeight == 0 || maxHeight < item.imgHeight))
maxHeight = item.imgHeight;
});
diyComponent.value.list.forEach((item, index) => {
item.imgWidth += 'px';
item.widthStyle = item.imgWidth;
if (index > 0) item.imgHeight = maxHeight;
});
}
});
}
/**
* 魔方1左3右
*/
const calcRowOneLeftOfOneTopOfTwoBottom = () => {
uni.getSystemInfo({
success: res => {
diyComponent.value.list.forEach((item, index) => {
//
if (index == 0) {
var ratio = item.imgHeight / item.imgWidth; //
item.imgWidth = res.windowWidth - uni.upx2px(diyComponent.value.margin
.both * 4) - uni.upx2px(diyComponent.value.imageGap * 2);
item.imgWidth = item.imgWidth / 2;
item.imgHeight = item.imgWidth * ratio;
} else if (index == 1) {
item.imgWidth = diyComponent.value.list[0].imgWidth;
item.imgHeight = (diyComponent.value.list[0].imgHeight - uni.upx2px(diyComponent.value
.imageGap * 2)) / 2;
} else if (index > 1) {
item.imgWidth = (diyComponent.value.list[0].imgWidth - uni.upx2px(diyComponent.value
.imageGap * 2)) / 2;
item.imgHeight = diyComponent.value.list[1].imgHeight;
}
});
diyComponent.value.list.forEach((item, index) => {
item.imgWidth += 'px';
item.imgHeight;
});
}
});
}
</script>
<style lang="scss">
.rubik-cube {
overflow: hidden;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.item {
text-align: center;
line-height: 0;
overflow: hidden;
image {
width: 100%;
max-width: 100%;
height: 100%;
}
}
}
//
.rubik-cube .item.row1-of2 {
box-sizing: border-box;
margin-top: 0 !important;
margin-bottom: 0 !important;
}
.rubik-cube .item.row1-of2:nth-child(1) {
margin-left: 0 !important;
}
.rubik-cube .item.row1-of2:nth-child(2) {
margin-right: 0 !important;
}
//
.rubik-cube .item.row1-of3 {
box-sizing: border-box;
margin-top: 0 !important;
margin-bottom: 0 !important;
}
.rubik-cube .item.row1-of3:nth-child(1) {
margin-left: 0 !important;
}
.rubik-cube .item.row1-of3:nth-child(3) {
margin-right: 0 !important;
}
//
.rubik-cube .item.row1-of4 {
box-sizing: border-box;
margin-top: 0 !important;
margin-bottom: 0 !important;
}
.rubik-cube .item.row1-of4:nth-child(1) {
margin-left: 0 !important;
}
.rubik-cube .item.row1-of4:nth-child(4) {
margin-right: 0 !important;
}
//
.rubik-cube .item.row2-lt-of2-rt {
// width: 50%;
display: inline-block;
box-sizing: border-box;
}
.rubik-cube .item.row2-lt-of2-rt:nth-child(1) {
margin-left: 0 !important;
margin-top: 0 !important;
}
.rubik-cube .item.row2-lt-of2-rt:nth-child(2) {
margin-right: 0 !important;
margin-top: 0 !important;
}
.rubik-cube .item.row2-lt-of2-rt:nth-child(3) {
margin-left: 0 !important;
margin-bottom: 0 !important;
}
.rubik-cube .item.row2-lt-of2-rt:nth-child(4) {
margin-right: 0 !important;
margin-bottom: 0 !important;
}
//
.rubik-cube .template-left,
.rubik-cube .template-right {
// width: 50%;
box-sizing: border-box;
}
.rubik-cube .template-left .item.row1-lt-of2-rt:nth-child(1) {
margin-bottom: 0;
}
.rubik-cube .template-right .item.row1-lt-of2-rt:nth-child(2) {
margin-bottom: 0 !important;
}
.rubik-cube.row1-lt-of2-rt .template-right {
display: flex;
flex-direction: column;
justify-content: space-between;
}
//
.rubik-cube .item.row1-tp-of2-bm:nth-child(1) {
width: 100%;
box-sizing: border-box;
margin-top: 0 !important;
margin-left: 0 !important;
margin-right: 0 !important;
}
.rubik-cube .item.row1-tp-of2-bm:nth-child(2) {
// width: 50%;
box-sizing: border-box;
margin-left: 0 !important;
margin-bottom: 0 !important;
}
.rubik-cube .item.row1-tp-of2-bm:nth-child(3) {
// width: 50%;
box-sizing: border-box;
margin-right: 0 !important;
margin-bottom: 0 !important;
}
//
.rubik-cube .template-left .item.row1-lt-of1-tp-of2-bm {
width: 100%;
box-sizing: border-box;
}
.rubik-cube .template-bottom {
display: flex;
align-items: center;
justify-content: space-between;
}
.rubik-cube .template-bottom .item:nth-child(2) {
margin-right: 0 !important;
}
</style>

View File

@ -1,39 +1,14 @@
<template>
<view :style="warpCss">
<view>
固定模板示例我也可以装修
我定义的数据源{{ diyComponent.componentName }}
<!-- 自定义模板渲染 -->
<diy-group :data="props.data" :pullDownRefresh="props.pullDownRefresh"></diy-group>
</view>
</template>
<script setup lang="ts">
import { computed, watch } from 'vue';
import useDiyStore from '@/stores/diy';
const props = defineProps(['component', 'index', 'pullDownRefresh']);
const diyStore = useDiyStore();
const diyComponent = computed(() => {
if (diyStore.mode == 'decorate') {
return diyStore.value[props.index];
} else {
return props.component;
}
})
const warpCss = computed(() => {
var style = '';
style += 'height:' + diyComponent.value.height * 2 + 'rpx;';
if (diyComponent.value.componentBgColor) style += 'background-color:' + diyComponent.value.componentBgColor + ';';
return style;
})
watch(
() => props.pullDownRefresh,
(newValue, oldValue) => {
//
}
)
const props = defineProps(['data', 'pullDownRefresh']);
</script>
<style></style>

View File

@ -1,14 +1,12 @@
<template>
<view class="fixed-group">
<template v-if="props.component.componentName == 'DemoIndex'">
<fixed-demo-index :component="props.component" :index="props.index"
:pullDownRefresh="props.pullDownRefresh"></fixed-demo-index>
<template v-if="props.data.global.component == 'demo-index'">
<fixed-demo-index :data="props.data" :pullDownRefresh="props.pullDownRefresh"></fixed-demo-index>
</template>
</view>
</template>
<script lang="ts" setup>
import { computed, watch } from 'vue';
const props = defineProps(['component', 'index', 'pullDownRefresh']);
const props = defineProps(['data', 'pullDownRefresh']);
</script>
<style lang="scss" scoped>
@import './index.scss';

View File

@ -1,5 +1,5 @@
<template>
<u-popup :show="show" :round="10" @close="handleClose" :closeable="true" bgColor="#fff"
<u-popup :show="show" :round="10" @close="handleClose" :closeable="true" bgColor="#fff" zIndex="10081"
:closeOnClickOverlay="false">
<view class="flex flex-col h-[75vh]" v-if="payInfo">
<view class="head">
@ -63,7 +63,8 @@
loading.value = true
pay({
out_trade_no: payInfo.value?.out_trade_no,
trade_type: payInfo.value?.trade_type,
trade_id: payInfo.value?.trade_id,
type: type.value
}).then(res => {
switch (type.value) {
@ -73,7 +74,7 @@
provider: 'wxpay',
...res.data,
success: (res) => {
redirect({ url: '/pages/pay/result', param: { code: payInfo.value?.out_trade_no }, mode: 'redirectTo' })
toPayResult()
},
fail: (res) => {
loading.value = false
@ -87,32 +88,30 @@
wechat.pay({
...res.data,
success: () => {
redirect({ url: '/pages/pay/result', param: { code: payInfo.value?.out_trade_no }, mode: 'redirectTo' })
toPayResult()
},
cancel: () => {
loading.value = false
}
})
} else {
uni.setStorageSync('paymenting', payInfo.value?.out_trade_no)
uni.setStorageSync('paymenting', { trade_type: payInfo.value?.trade_type, trade_id: payInfo.value?.trade_id })
location.href = res.data.h5_url
addListenerPayBack()
}
// #endif
break;
case 'alipay':
// #ifdef H5
if (isWeixinBrowser()) {
redirect({ url: '/pages/pay/browser', param: { code: payInfo.value?.out_trade_no, alipay: encodeURIComponent(res.data.url) }, mode: 'redirectTo' })
redirect({ url: '/pages/pay/browser', param: { trade_type: payInfo.value?.trade_type, trade_id: payInfo.value?.trade_id, alipay: encodeURIComponent(res.data.url) }, mode: 'redirectTo' })
} else {
uni.setStorageSync('paymenting', payInfo.value?.out_trade_no)
uni.setStorageSync('paymenting', { trade_type: payInfo.value?.trade_type, trade_id: payInfo.value?.trade_id })
location.href = res.data.url
addListenerPayBack()
}
// #endif
break;
default:
redirect({ url: '/pages/pay/result', param: { code: payInfo.value?.out_trade_no }, mode: 'redirectTo' })
toPayResult()
}
}).catch(() => {
loading.value = false
@ -123,10 +122,14 @@
* 检测是否是支付后返回
*/
uni.$on('checkIsReturnAfterPayment', () => {
const data = uni.getStorageSync('paymenting')
if (uni.getStorageSync('paymenting')) {
redirect({
url: '/pages/pay/result',
param: { code: uni.getStorageSync('paymenting') },
param: {
trade_type: data.trade_type,
trade_id: data.trade_id
},
mode: 'redirectTo',
success() {
uni.removeStorageSync('paymenting')
@ -135,28 +138,36 @@
}
})
const open = (outTradeNo : string) => {
getPayInfo(outTradeNo)
const open = (tradeType : string, tradeId : number, payReturn: string = '') => {
//
uni.setStorageSync('payReturn', encodeURIComponent(payReturn))
getPayInfo(tradeType, tradeId)
.then((res : any) => {
let { data } = res
payInfo.value = data
if (uni.$u.test.isEmpty(data)) {
uni.showToast({ title: t('pay.notObtainedInfo'), icon: 'none' })
return
}
if (data.money == 0) {
redirect({ url: '/pages/pay/result', param: { code: outTradeNo }, mode: 'redirectTo' })
toPayResult()
return
}
if (data.status != 0) {
uni.showToast({ title: t('pay.paymentDocuments') + data.status_name, icon: 'none' })
return
}
payInfo.value = data
type.value = data.pay_type_list[0] ? data.pay_type_list[0].key : ''
show.value = true
})
.catch(() => { })
}
const toPayResult = ()=> {
redirect({ url: '/pages/pay/result', param: { trade_type: payInfo.value?.trade_type, trade_id: payInfo.value?.trade_id }, mode: 'redirectTo' })
}
const emits = defineEmits(['close'])

View File

@ -1,5 +1,5 @@
<template>
<u-tabbar :value="value" @change="tabbarChange" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true"
<u-tabbar :value="value" @change="tabbarChange" zIndex="9999" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true"
:inactive-color="tabbar.textColor" :active-color="tabbar.textHoverColor" v-if="tabbar">
<block v-for="item in tabbar.list">
<u-tabbar-item :style="{'background-color': tabbar.backgroundColor}" :text="item.text"

View File

@ -4,13 +4,21 @@
<view v-show="!loading">
<view class="diy-template-wrap bg-index"
<!-- 自定义模板渲染 -->
<view class="diy-template-wrap bg-index" v-if="data.pageMode != 'fixed'"
:style="{ backgroundColor: data.global.pageBgColor,minHeight: 'calc(100vh - 50px)',backgroundImage : data.global.bgUrl ? 'url(' + img(data.global.bgUrl) + ')' : '' }">
<diy-group :data="data" :pullDownRefresh="pullDownRefresh"></diy-group>
</view>
<!-- 固定模板渲染 -->
<view class="fixed-template-wrap" v-if="data.pageMode == 'fixed'">
<fixed-group :data="data" :pullDownRefresh="pullDownRefresh"></fixed-group>
</view>
</view>
</view>
</template>
@ -32,6 +40,8 @@
const pullDownRefresh = ref(0)
const diyData = reactive({
pageMode: 'diy',
title: '',
global: {},
value: []
})
@ -76,9 +86,10 @@
}).then((res : any) => {
if (res.data.value) {
let data = res.data;
diyData.mode = data.mode;
diyData.pageMode = data.mode;
diyData.title = data.title;
let sources = JSON.parse(res.data.value);
let sources = JSON.parse(data.value);
diyData.global = sources.global;
diyData.value = sources.value;
diyData.value.forEach((item, index) => {
@ -92,7 +103,7 @@
}
});
uni.setNavigationBarTitle({
title: diyData.global.title
title: diyData.title
})
}

View File

@ -4,13 +4,21 @@
<view v-show="!loading">
<view class="diy-template-wrap bg-index"
<!-- 自定义模板渲染 -->
<view class="diy-template-wrap bg-index" v-if="data.pageMode != 'fixed'"
:style="{ backgroundColor: data.global.pageBgColor,minHeight: 'calc(100vh - 50px)',backgroundImage : data.global.bgUrl ? 'url(' + img(data.global.bgUrl) + ')' : '' }">
<diy-group :data="data" :pullDownRefresh="pullDownRefresh"></diy-group>
</view>
<!-- 固定模板渲染 -->
<view class="fixed-template-wrap" v-if="data.pageMode == 'fixed'">
<fixed-group :data="data" :pullDownRefresh="pullDownRefresh"></fixed-group>
</view>
</view>
</view>
</template>
@ -34,6 +42,8 @@
//
const diyData = reactive({
pageMode: 'diy',
title: '',
global: {},
value: []
})
@ -72,9 +82,10 @@
}).then((res : any) => {
if (res.data.value) {
let data = res.data;
diyData.mode = data.mode;
diyData.pageMode = data.mode;
diyData.title = data.title;
let sources = JSON.parse(data.value);
diyData.title = sources.title;
diyData.global = sources.global;
diyData.value = sources.value;
diyData.value.forEach((item, index) => {
@ -88,7 +99,7 @@
}
});
uni.setNavigationBarTitle({
title: diyData.global.title
title: diyData.title
})
}

View File

@ -138,7 +138,7 @@
rechargeLoading.value = true
createRecharge({ recharge_money: rechargeAmount.value }).then(res => {
payRef.value?.open(res.data.out_trade_no)
payRef.value?.open(res.data.trade_type, res.data.trade_id)
}).catch(() => {
rechargeLoading.value = false
})

View File

@ -4,13 +4,21 @@
<view v-show="!loading">
<view class="diy-template-wrap bg-index"
<!-- 自定义模板渲染 -->
<view class="diy-template-wrap bg-index" v-if="data.pageMode != 'fixed'"
:style="{ backgroundColor: data.global.pageBgColor,minHeight: 'calc(100vh - 50px)',backgroundImage : data.global.bgUrl ? 'url(' + img(data.global.bgUrl) + ')' : '' }">
<diy-group :data="data" :pullDownRefresh="pullDownRefresh"></diy-group>
</view>
<!-- 固定模板渲染 -->
<view class="fixed-template-wrap" v-if="data.pageMode == 'fixed'">
<fixed-group :data="data" :pullDownRefresh="pullDownRefresh"></fixed-group>
</view>
</view>
</view>
</template>
@ -28,6 +36,8 @@
const pullDownRefresh = ref(0)
const diyData = reactive({
pageMode: 'diy',
title: '',
global: {},
value: []
})
@ -66,8 +76,10 @@
}).then((res : any) => {
if (res.data.value) {
let data = res.data;
diyData.mode = data.mode;
let sources = JSON.parse(res.data.value);
diyData.pageMode = data.mode;
diyData.title = data.title;
let sources = JSON.parse(data.value);
diyData.global = sources.global;
diyData.value = sources.value;
diyData.value.forEach((item, index) => {
@ -81,7 +93,7 @@
}
});
uni.setNavigationBarTitle({
title: diyData.global.title
title: diyData.title
})
}
loading.value = false;

View File

@ -12,7 +12,7 @@
onLoad((data : AnyObject) => {
if (!isWeixinBrowser() && data.alipay) {
uni.setStorageSync('paymenting', data.code)
uni.setStorageSync('paymenting', { trade_type: data.trade_type, trade_id: data.trade_id })
location.href = decodeURIComponent(data.alipay)
}
})

View File

@ -32,11 +32,13 @@
const payInfo = ref<AnyObject | null>(null)
const loading = ref(false)
let outTradeNo = ''
let tradeType = ''
let tradeId = 0
let requestNum = 0
onLoad((data : any) => {
outTradeNo = data.code
tradeType = data.trade_type
tradeId = data.trade_id
getPayInfo()
})
@ -44,7 +46,7 @@
* 获取支付信息
*/
const getPayInfo = () => {
getPayInfoApi(outTradeNo)
getPayInfoApi(tradeType, tradeId)
.then((res : responseResult) => {
if (!uni.$u.test.isEmpty(res.data)) {
if (res.data.status == 1 && requestNum < 5) {

View File

@ -3,6 +3,7 @@ import { toRaw } from 'vue'
interface Diy {
mode : string, // 模式decorate 装修,为空表示正常
pageMode : string, // 页面展示模式diy自定义fixed固定
currentIndex : number,
global : {
title : string,
@ -17,6 +18,7 @@ const useDiyStore = defineStore('diy', {
state: () : Diy => {
return {
mode: '',
pageMode: 'diy',
currentIndex: -99,
global: {
title: "",
@ -46,6 +48,7 @@ const useDiyStore = defineStore('diy', {
try {
let data = JSON.parse(event.data);
this.currentIndex = data.currentIndex;
this.pageMode = data.pageMode;
if (data.global) this.global = data.global;
if (data.value) this.value = data.value;

View File

@ -95,8 +95,11 @@ class Request {
this.config.showSuccessMessage && uni.showToast({ title: data.msg, icon: 'none' })
resolve(data)
} else {
this.handleAuthError(data.code)
this.config.showErrorMessage && uni.showToast({ title: data.msg, icon: 'none' })
if (data.code == 0) {
uni.showToast({ title: data.msg, icon: 'none' })
} else {
this.handleAuthError(data.code)
}
reject(data)
}
},
@ -128,8 +131,11 @@ class Request {
this.config.showSuccessMessage && uni.showToast({ title: data.msg, icon: 'none' })
resolve(data)
} else {
this.handleAuthError(data.code)
this.config.showErrorMessage && uni.showToast({ title: data.msg, icon: 'none' })
if (data.code == 0) {
uni.showToast({ title: data.msg, icon: 'none' })
} else {
this.handleAuthError(data.code)
}
reject(data)
}
},