接入jcfw的分享配置
This commit is contained in:
parent
db6cb7f7bd
commit
d735ce9b7c
@ -49,7 +49,6 @@
|
||||
<script lang="ts">
|
||||
import { Component, Vue, Watch } from 'vue-property-decorator'
|
||||
import { IGameInfo } from '@/modules/gameinfo'
|
||||
import {uniIcons, uniCard, uniTag} from '@dcloudio/uni-ui'
|
||||
|
||||
declare module 'vue/types/vue' {
|
||||
interface Vue {
|
||||
@ -61,9 +60,6 @@ declare module 'vue/types/vue' {
|
||||
name: 'BegImgCell',
|
||||
props: ['gData'],
|
||||
components:{
|
||||
uniIcons,
|
||||
uniCard,
|
||||
uniTag
|
||||
}
|
||||
})
|
||||
export default class extends Vue{
|
||||
|
@ -32,6 +32,8 @@ declare module 'vue/types/vue' {
|
||||
@Component({
|
||||
name: 'PriceCell',
|
||||
props: ['data'],
|
||||
components:{
|
||||
}
|
||||
})
|
||||
export default class extends Vue{
|
||||
|
||||
|
@ -146,12 +146,9 @@ let SDKManage = function() {
|
||||
return new Promise((resolve, reject) => {
|
||||
let cbs = function(res) {
|
||||
if (res.length > 0) {
|
||||
let shareArr = [];
|
||||
let shareArr = {};
|
||||
for (let obj of res) {
|
||||
shareArr.push({
|
||||
image: obj.image,
|
||||
str: obj.str
|
||||
});
|
||||
shareArr[obj.type] = {image: obj.image, str: obj.str}
|
||||
}
|
||||
wx.setStorageSync('share_cfg', shareArr);
|
||||
}
|
||||
|
@ -44,21 +44,40 @@ export default class extends Vue{
|
||||
await this.$onLaunched;
|
||||
await this.fetchGames()
|
||||
await this.fetchCollectInfo()
|
||||
//#ifdef MP-WEIXIN
|
||||
wx.showShareMenu({
|
||||
menus: ['shareAppMessage', 'shareTimeline']
|
||||
})
|
||||
// #endif
|
||||
}
|
||||
onShareAppMessage(res: any) {
|
||||
if (res.from === 'button') {// 来自页面内分享按钮
|
||||
console.log(res.target)
|
||||
if (res.target?.id) {
|
||||
let game = this.games.find(o => o.gameId === res.target.id)
|
||||
if (game) {
|
||||
return {
|
||||
title: game.name,
|
||||
path: '/pages/info/index?s=1&gameId=' + game.gameId,
|
||||
imageUrl: game.icon
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let shareDataAll = uni.getStorageSync('share_cfg')
|
||||
let shareData = shareDataAll['systemshare']
|
||||
return {
|
||||
title: '自定义分享标题',
|
||||
path: '/pages/test/test?id=123'
|
||||
title: shareData?.str || '',
|
||||
path: '/pages/index/index?s=1',
|
||||
imageUrl: shareData?.image || ''
|
||||
}
|
||||
}
|
||||
onShareTimeline() {
|
||||
let shareDataAll = uni.getStorageSync('share_cfg')
|
||||
let shareData = shareDataAll['systemshare']
|
||||
return {
|
||||
title: '自定义分享标题',
|
||||
query: '/pages/test/test?id=123',
|
||||
imageUrl: ''
|
||||
title: shareData?.str || '',
|
||||
query: '/pages/index/index?s=1',
|
||||
imageUrl: shareData?.image || ''
|
||||
}
|
||||
}
|
||||
onClick(e: any) {
|
||||
|
@ -17,6 +17,21 @@
|
||||
{{desc}}
|
||||
</text>
|
||||
</view>
|
||||
<view class="icon-view">
|
||||
<view class="icon-cell">
|
||||
<button class="card-actions-item share-btn" :id="gameId" open-type="share">
|
||||
<uni-icons type="pyq" size="18" color="#999"></uni-icons>
|
||||
</button>
|
||||
</view>
|
||||
<view class="icon-cell" @click="onZanGame">
|
||||
<uni-icons v-if="!zan" type="hand-up" size="24" color="#999"></uni-icons>
|
||||
<uni-icons v-if="zan" type="hand-up-filled" size="24" color="#18bc37"></uni-icons>
|
||||
</view>
|
||||
<view class="icon-cell" @click="onCollectGame">
|
||||
<uni-icons v-if="!collect" type="heart" size="24" color="#999"></uni-icons>
|
||||
<uni-icons v-if="collect" type="heart-filled" size="24" color="#18bc37"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="price-list" v-if="priceList.length > 0">
|
||||
<view class="price-title">低价排名</view>
|
||||
@ -47,6 +62,10 @@ import ImageSwiper from '@/components/ImageSwiper/index.vue'
|
||||
import PriceCell from '@/components/PriceCell/index.vue'
|
||||
import DlcCell from '@/components/DlcCell/index.vue'
|
||||
import { getGameInfo, getGamePrice } from '@/api/game_data'
|
||||
import { IGameInfo } from '@/modules/gameinfo'
|
||||
import {uniIcons, uniTag} from '@dcloudio/uni-ui'
|
||||
import { getCollectList, getZanList, updateCollectInfo, updateZanInfo } from '@/api/game'
|
||||
import { UserModule } from '@/store/modules/user'
|
||||
|
||||
@Component({
|
||||
name: 'GameInfo',
|
||||
@ -54,6 +73,8 @@ import { getGameInfo, getGamePrice } from '@/api/game_data'
|
||||
ImageSwiper,
|
||||
PriceCell,
|
||||
DlcCell,
|
||||
uniIcons,
|
||||
uniTag
|
||||
}
|
||||
})
|
||||
export default class extends Vue{
|
||||
@ -68,19 +89,35 @@ export default class extends Vue{
|
||||
private desc: string = ''
|
||||
private params: any = {}
|
||||
private bgImg = ''
|
||||
private collect = false
|
||||
private zan = false
|
||||
private shareIcon = ''
|
||||
$onLaunched: any
|
||||
|
||||
onLoad(options: any) {
|
||||
async onLoad(options: any) {
|
||||
this.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0
|
||||
this.gameId = options.gameId
|
||||
let needLogin = !!options.s
|
||||
if (this.gameId) {
|
||||
this.fetchGameInfo()
|
||||
this.fetchGamePrice()
|
||||
if (needLogin) {
|
||||
await this.$onLaunched;
|
||||
await this.fetchCollectInfo()
|
||||
}
|
||||
await this.fetchGameInfo()
|
||||
await this.fetchGamePrice()
|
||||
await this.fetchZanInfo()
|
||||
}
|
||||
this.params = {
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
blur:"m"
|
||||
}
|
||||
//#ifdef MP-WEIXIN
|
||||
wx.showShareMenu({
|
||||
menus: ['shareAppMessage', 'shareTimeline']
|
||||
})
|
||||
// #endif
|
||||
this.collect = UserModule.collectSet.has(this.gameId)
|
||||
}
|
||||
async created() {
|
||||
uni.setNavigationBarTitle({
|
||||
@ -108,6 +145,7 @@ export default class extends Vue{
|
||||
}
|
||||
this.bgImg = this.imgSwiperData[0]
|
||||
}
|
||||
this.shareIcon = data.jumpGame?.icon || ''
|
||||
this.desc = data.jumpGameExt?.longDesc || ''
|
||||
if (data.dlcList) {
|
||||
for (let obj of data.dlcList) {
|
||||
@ -131,6 +169,61 @@ export default class extends Vue{
|
||||
this.priceList.push(obj)
|
||||
}
|
||||
}
|
||||
async onZanGame() {
|
||||
const act = this.zan ? 0 : 1
|
||||
try {
|
||||
const res = await updateZanInfo(this.gameId, act)
|
||||
this.zan = !this.zan
|
||||
console.log('update zan stat success: ', this.zan)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
private async fetchZanInfo() {
|
||||
const games = [this.gameId]
|
||||
let data: any = await getZanList(games)
|
||||
if (data[this.gameId]) {
|
||||
this.zan = !!data[this.gameId]?.did
|
||||
}
|
||||
|
||||
this.$forceUpdate()
|
||||
}
|
||||
async onCollectGame() {
|
||||
const act = this.collect ? 0 : 1
|
||||
try {
|
||||
const res = await updateCollectInfo(this.gameId, act)
|
||||
this.collect = !this.collect
|
||||
if (this.collect) {
|
||||
UserModule.add_collect(this.gameId)
|
||||
} else {
|
||||
UserModule.remove_collect(this.gameId)
|
||||
}
|
||||
console.log('update collect stat success: ', this.collect)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
private async fetchCollectInfo() {
|
||||
const datas: any = await getCollectList()
|
||||
UserModule.update_collect(datas)
|
||||
}
|
||||
onShareAppMessage(res: any) {
|
||||
if (res.from === 'button') {// 来自页面内分享按钮
|
||||
console.log(res.target)
|
||||
}
|
||||
return {
|
||||
title: this.name,
|
||||
path: '/pages/info/index?s=1&gameId=' + this.gameId,
|
||||
imageUrl: this.shareIcon
|
||||
}
|
||||
}
|
||||
onShareTimeline() {
|
||||
return {
|
||||
title: this.name,
|
||||
query: '/pages/info/index?s=1&gameId=' + this.gameId,
|
||||
imageUrl: this.shareIcon
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -138,6 +231,23 @@ export default class extends Vue{
|
||||
.game-info{
|
||||
padding: 5px 8px;
|
||||
z-index: 2;
|
||||
position: relative;
|
||||
}
|
||||
.icon-view{
|
||||
position: absolute;
|
||||
width: 124px;
|
||||
height: 30px;
|
||||
top: 12px;
|
||||
right: 10px;
|
||||
display: flex;
|
||||
/*border: 1px solid #eaecef;*/
|
||||
border-radius: 3px;
|
||||
}
|
||||
.icon-cell{
|
||||
width: 33%;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
}
|
||||
.tab-list .uni-tag {
|
||||
margin-right: 5px;
|
||||
@ -209,5 +319,18 @@ dlc-cell {
|
||||
.bottom-area{
|
||||
height: 24px;
|
||||
}
|
||||
.share-btn {
|
||||
box-sizing: unset;
|
||||
text-align: left;
|
||||
border-radius: 0;
|
||||
background-color: white!important;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.share-btn::after{
|
||||
border: none;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
Loading…
x
Reference in New Issue
Block a user