Commit e94b8d2a authored by hewenhao's avatar hewenhao

feat: pk历史数据展示

parent 5abb7931
......@@ -41,7 +41,8 @@ declare namespace JSX {
>,
'pk-record': React.DetailedHTMLProps<
React.HTMLAttributes<HTMLElement> & {
list: any[]
list: any[];
config: any;
},
HTMLElement
>,
......
......@@ -3,6 +3,7 @@
import { rankTranslate, getImageForRank } from '@/pages/battles/utils'
import assets from '@/assets/oss/assets-pk'
import assets2 from '@/assets/oss/assets-prepare'
import { getStorage, StorageKeys } from '@/utils/storage'
import styles from './index.module.scss'
const PageSize = 10
......@@ -13,9 +14,13 @@ Component({
type: Array,
value: [],
},
config: {
type: Object,
value: {}
}
},
observers: {
'list' (val) {
'list' () {
this.reset()
}
},
......@@ -31,6 +36,7 @@ Component({
this._loading = false
this._currentPage = 0
this.loadMore()
this._userInfo = getStorage(StorageKeys.userInfo)
},
methods: {
reset () {
......@@ -60,10 +66,19 @@ Component({
hasNextPage = false
}
const userInfo = this._userInfo
const isWin = item => {
if (item.initiator === userInfo?.userId) {
return item.result === 'WIN'
}
return item.result === 'LOSE'
}
const start = currentPage * PageSize
const newList = list.slice(start, max).map((item) => ({
...item,
wined: item.result === 'WIN',
wined: isWin(item),
initiatorLevel: rankTranslate(item.initiatorLevel),
recipientLevel: rankTranslate(item.recipientLevel),
initiatorBadge: getImageForRank(item.initiatorLevel),
......
......@@ -41,7 +41,7 @@
<text class="{{styles.value}}">{{item.initiatorResultTime}}s</text>
<view class="{{styles.value}}">
<image class="{{styles.diamond}}" src="{{assets2['diamond.png'].u}}" />
<text>+10</text>
<text>+{{ item.result === 'WIN' ? config.personalPkWinPoint : config.personalPkLosePoint }}</text>
</view>
</view>
<!-- stats -->
......@@ -56,7 +56,7 @@
<text class="{{styles.value}}">{{item.recipientResultTime}}s</text>
<view class="{{styles.value}}">
<image class="{{styles.diamond}}" src="{{assets2['diamond.png'].u}}" />
<text>+15</text>
<text>+{{ item.result === 'WIN' ? config.personalPkLosePoint : config.personalPkWinPoint }}</text>
</view>
</view>
</view>
......@@ -64,7 +64,7 @@
</view>
</template>
<block wx:for="{{ realList }}" wx:key="userId">
<template is="pkItem" data="{{ styles, item, assets, assets2, rankTranslate }}" />
<template is="pkItem" data="{{ styles, item, assets, assets2, rankTranslate, config }}" />
</block>
<view class="{{styles.spinWrap}}" wx:if="{{loading}}">
<view class="{{styles.spin}}">
......
......@@ -18,6 +18,8 @@ const Battles = () => {
const nav = useMemo(getMenuButtonBoundingClientRect, [])
const summary = useStoreState((state) => state.battlesModel.summary)
const addPkGuideTimes = useStoreActions((state) => state.guideModel.addPkGuideTimes)
const getSetting = useStoreActions((state) => state.userModel.getSetting)
const setting = useStoreState((state) => state.userModel.setting)
const fetchUserSummary = useStoreActions(
(actions) => actions.battlesModel.fetchUserSummary
......@@ -30,6 +32,7 @@ const Battles = () => {
useDidShow(() => {
fetchUserSummary({})
getSetting()
})
const page = useMemo(() => getCurrentInstance()?.page, [])
......@@ -68,7 +71,7 @@ const Battles = () => {
</View>
<View className={styles.gameResult}>
<pk-record list={summary?.records || []} ref={pkRecords} />
<pk-record list={summary?.records || []} config={setting} ref={pkRecords} />
</View>
</View>
<View className={styles.bottom}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment