Commit e94b8d2a authored by hewenhao's avatar hewenhao

feat: pk历史数据展示

parent 5abb7931
...@@ -41,7 +41,8 @@ declare namespace JSX { ...@@ -41,7 +41,8 @@ declare namespace JSX {
>, >,
'pk-record': React.DetailedHTMLProps< 'pk-record': React.DetailedHTMLProps<
React.HTMLAttributes<HTMLElement> & { React.HTMLAttributes<HTMLElement> & {
list: any[] list: any[];
config: any;
}, },
HTMLElement HTMLElement
>, >,
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import { rankTranslate, getImageForRank } from '@/pages/battles/utils' import { rankTranslate, getImageForRank } from '@/pages/battles/utils'
import assets from '@/assets/oss/assets-pk' import assets from '@/assets/oss/assets-pk'
import assets2 from '@/assets/oss/assets-prepare' import assets2 from '@/assets/oss/assets-prepare'
import { getStorage, StorageKeys } from '@/utils/storage'
import styles from './index.module.scss' import styles from './index.module.scss'
const PageSize = 10 const PageSize = 10
...@@ -13,9 +14,13 @@ Component({ ...@@ -13,9 +14,13 @@ Component({
type: Array, type: Array,
value: [], value: [],
}, },
config: {
type: Object,
value: {}
}
}, },
observers: { observers: {
'list' (val) { 'list' () {
this.reset() this.reset()
} }
}, },
...@@ -31,6 +36,7 @@ Component({ ...@@ -31,6 +36,7 @@ Component({
this._loading = false this._loading = false
this._currentPage = 0 this._currentPage = 0
this.loadMore() this.loadMore()
this._userInfo = getStorage(StorageKeys.userInfo)
}, },
methods: { methods: {
reset () { reset () {
...@@ -60,10 +66,19 @@ Component({ ...@@ -60,10 +66,19 @@ Component({
hasNextPage = false 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 start = currentPage * PageSize
const newList = list.slice(start, max).map((item) => ({ const newList = list.slice(start, max).map((item) => ({
...item, ...item,
wined: item.result === 'WIN', wined: isWin(item),
initiatorLevel: rankTranslate(item.initiatorLevel), initiatorLevel: rankTranslate(item.initiatorLevel),
recipientLevel: rankTranslate(item.recipientLevel), recipientLevel: rankTranslate(item.recipientLevel),
initiatorBadge: getImageForRank(item.initiatorLevel), initiatorBadge: getImageForRank(item.initiatorLevel),
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<text class="{{styles.value}}">{{item.initiatorResultTime}}s</text> <text class="{{styles.value}}">{{item.initiatorResultTime}}s</text>
<view class="{{styles.value}}"> <view class="{{styles.value}}">
<image class="{{styles.diamond}}" src="{{assets2['diamond.png'].u}}" /> <image class="{{styles.diamond}}" src="{{assets2['diamond.png'].u}}" />
<text>+10</text> <text>+{{ item.result === 'WIN' ? config.personalPkWinPoint : config.personalPkLosePoint }}</text>
</view> </view>
</view> </view>
<!-- stats --> <!-- stats -->
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<text class="{{styles.value}}">{{item.recipientResultTime}}s</text> <text class="{{styles.value}}">{{item.recipientResultTime}}s</text>
<view class="{{styles.value}}"> <view class="{{styles.value}}">
<image class="{{styles.diamond}}" src="{{assets2['diamond.png'].u}}" /> <image class="{{styles.diamond}}" src="{{assets2['diamond.png'].u}}" />
<text>+15</text> <text>+{{ item.result === 'WIN' ? config.personalPkLosePoint : config.personalPkWinPoint }}</text>
</view> </view>
</view> </view>
</view> </view>
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
</view> </view>
</template> </template>
<block wx:for="{{ realList }}" wx:key="userId"> <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> </block>
<view class="{{styles.spinWrap}}" wx:if="{{loading}}"> <view class="{{styles.spinWrap}}" wx:if="{{loading}}">
<view class="{{styles.spin}}"> <view class="{{styles.spin}}">
...@@ -72,4 +72,4 @@ ...@@ -72,4 +72,4 @@
<View class="{{styles.spinText}}">加载中</View> <View class="{{styles.spinText}}">加载中</View>
</view> </view>
</view> </view>
<view class="{{styles.emptyText}}" wx:if="{{list.length < 1}}">暂无数据</view> <view class="{{styles.emptyText}}" wx:if="{{list.length < 1}}">暂无数据</view>
\ No newline at end of file
...@@ -18,6 +18,8 @@ const Battles = () => { ...@@ -18,6 +18,8 @@ const Battles = () => {
const nav = useMemo(getMenuButtonBoundingClientRect, []) const nav = useMemo(getMenuButtonBoundingClientRect, [])
const summary = useStoreState((state) => state.battlesModel.summary) const summary = useStoreState((state) => state.battlesModel.summary)
const addPkGuideTimes = useStoreActions((state) => state.guideModel.addPkGuideTimes) const addPkGuideTimes = useStoreActions((state) => state.guideModel.addPkGuideTimes)
const getSetting = useStoreActions((state) => state.userModel.getSetting)
const setting = useStoreState((state) => state.userModel.setting)
const fetchUserSummary = useStoreActions( const fetchUserSummary = useStoreActions(
(actions) => actions.battlesModel.fetchUserSummary (actions) => actions.battlesModel.fetchUserSummary
...@@ -30,6 +32,7 @@ const Battles = () => { ...@@ -30,6 +32,7 @@ const Battles = () => {
useDidShow(() => { useDidShow(() => {
fetchUserSummary({}) fetchUserSummary({})
getSetting()
}) })
const page = useMemo(() => getCurrentInstance()?.page, []) const page = useMemo(() => getCurrentInstance()?.page, [])
...@@ -68,7 +71,7 @@ const Battles = () => { ...@@ -68,7 +71,7 @@ const Battles = () => {
</View> </View>
<View className={styles.gameResult}> <View className={styles.gameResult}>
<pk-record list={summary?.records || []} ref={pkRecords} /> <pk-record list={summary?.records || []} config={setting} ref={pkRecords} />
</View> </View>
</View> </View>
<View className={styles.bottom}> <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