接入jcfw的分享配置
This commit is contained in:
parent
db6cb7f7bd
commit
d735ce9b7c
@ -49,7 +49,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue, Watch } from 'vue-property-decorator'
|
import { Component, Vue, Watch } from 'vue-property-decorator'
|
||||||
import { IGameInfo } from '@/modules/gameinfo'
|
import { IGameInfo } from '@/modules/gameinfo'
|
||||||
import {uniIcons, uniCard, uniTag} from '@dcloudio/uni-ui'
|
|
||||||
|
|
||||||
declare module 'vue/types/vue' {
|
declare module 'vue/types/vue' {
|
||||||
interface Vue {
|
interface Vue {
|
||||||
@ -61,9 +60,6 @@ declare module 'vue/types/vue' {
|
|||||||
name: 'BegImgCell',
|
name: 'BegImgCell',
|
||||||
props: ['gData'],
|
props: ['gData'],
|
||||||
components:{
|
components:{
|
||||||
uniIcons,
|
|
||||||
uniCard,
|
|
||||||
uniTag
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
export default class extends Vue{
|
export default class extends Vue{
|
||||||
|
@ -32,6 +32,8 @@ declare module 'vue/types/vue' {
|
|||||||
@Component({
|
@Component({
|
||||||
name: 'PriceCell',
|
name: 'PriceCell',
|
||||||
props: ['data'],
|
props: ['data'],
|
||||||
|
components:{
|
||||||
|
}
|
||||||
})
|
})
|
||||||
export default class extends Vue{
|
export default class extends Vue{
|
||||||
|
|
||||||
|
@ -146,12 +146,9 @@ let SDKManage = function() {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let cbs = function(res) {
|
let cbs = function(res) {
|
||||||
if (res.length > 0) {
|
if (res.length > 0) {
|
||||||
let shareArr = [];
|
let shareArr = {};
|
||||||
for (let obj of res) {
|
for (let obj of res) {
|
||||||
shareArr.push({
|
shareArr[obj.type] = {image: obj.image, str: obj.str}
|
||||||
image: obj.image,
|
|
||||||
str: obj.str
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
wx.setStorageSync('share_cfg', shareArr);
|
wx.setStorageSync('share_cfg', shareArr);
|
||||||
}
|
}
|
||||||
|
@ -44,21 +44,40 @@ export default class extends Vue{
|
|||||||
await this.$onLaunched;
|
await this.$onLaunched;
|
||||||
await this.fetchGames()
|
await this.fetchGames()
|
||||||
await this.fetchCollectInfo()
|
await this.fetchCollectInfo()
|
||||||
|
//#ifdef MP-WEIXIN
|
||||||
|
wx.showShareMenu({
|
||||||
|
menus: ['shareAppMessage', 'shareTimeline']
|
||||||
|
})
|
||||||
|
// #endif
|
||||||
}
|
}
|
||||||
onShareAppMessage(res: any) {
|
onShareAppMessage(res: any) {
|
||||||
if (res.from === 'button') {// 来自页面内分享按钮
|
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 {
|
return {
|
||||||
title: '自定义分享标题',
|
title: shareData?.str || '',
|
||||||
path: '/pages/test/test?id=123'
|
path: '/pages/index/index?s=1',
|
||||||
|
imageUrl: shareData?.image || ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onShareTimeline() {
|
onShareTimeline() {
|
||||||
|
let shareDataAll = uni.getStorageSync('share_cfg')
|
||||||
|
let shareData = shareDataAll['systemshare']
|
||||||
return {
|
return {
|
||||||
title: '自定义分享标题',
|
title: shareData?.str || '',
|
||||||
query: '/pages/test/test?id=123',
|
query: '/pages/index/index?s=1',
|
||||||
imageUrl: ''
|
imageUrl: shareData?.image || ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onClick(e: any) {
|
onClick(e: any) {
|
||||||
|
@ -17,6 +17,21 @@
|
|||||||
{{desc}}
|
{{desc}}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</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>
|
||||||
<view class="price-list" v-if="priceList.length > 0">
|
<view class="price-list" v-if="priceList.length > 0">
|
||||||
<view class="price-title">低价排名</view>
|
<view class="price-title">低价排名</view>
|
||||||
@ -47,6 +62,10 @@ import ImageSwiper from '@/components/ImageSwiper/index.vue'
|
|||||||
import PriceCell from '@/components/PriceCell/index.vue'
|
import PriceCell from '@/components/PriceCell/index.vue'
|
||||||
import DlcCell from '@/components/DlcCell/index.vue'
|
import DlcCell from '@/components/DlcCell/index.vue'
|
||||||
import { getGameInfo, getGamePrice } from '@/api/game_data'
|
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({
|
@Component({
|
||||||
name: 'GameInfo',
|
name: 'GameInfo',
|
||||||
@ -54,6 +73,8 @@ import { getGameInfo, getGamePrice } from '@/api/game_data'
|
|||||||
ImageSwiper,
|
ImageSwiper,
|
||||||
PriceCell,
|
PriceCell,
|
||||||
DlcCell,
|
DlcCell,
|
||||||
|
uniIcons,
|
||||||
|
uniTag
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
export default class extends Vue{
|
export default class extends Vue{
|
||||||
@ -68,19 +89,35 @@ export default class extends Vue{
|
|||||||
private desc: string = ''
|
private desc: string = ''
|
||||||
private params: any = {}
|
private params: any = {}
|
||||||
private bgImg = ''
|
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.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0
|
||||||
this.gameId = options.gameId
|
this.gameId = options.gameId
|
||||||
|
let needLogin = !!options.s
|
||||||
if (this.gameId) {
|
if (this.gameId) {
|
||||||
this.fetchGameInfo()
|
if (needLogin) {
|
||||||
this.fetchGamePrice()
|
await this.$onLaunched;
|
||||||
|
await this.fetchCollectInfo()
|
||||||
|
}
|
||||||
|
await this.fetchGameInfo()
|
||||||
|
await this.fetchGamePrice()
|
||||||
|
await this.fetchZanInfo()
|
||||||
}
|
}
|
||||||
this.params = {
|
this.params = {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
blur:"m"
|
blur:"m"
|
||||||
}
|
}
|
||||||
|
//#ifdef MP-WEIXIN
|
||||||
|
wx.showShareMenu({
|
||||||
|
menus: ['shareAppMessage', 'shareTimeline']
|
||||||
|
})
|
||||||
|
// #endif
|
||||||
|
this.collect = UserModule.collectSet.has(this.gameId)
|
||||||
}
|
}
|
||||||
async created() {
|
async created() {
|
||||||
uni.setNavigationBarTitle({
|
uni.setNavigationBarTitle({
|
||||||
@ -108,6 +145,7 @@ export default class extends Vue{
|
|||||||
}
|
}
|
||||||
this.bgImg = this.imgSwiperData[0]
|
this.bgImg = this.imgSwiperData[0]
|
||||||
}
|
}
|
||||||
|
this.shareIcon = data.jumpGame?.icon || ''
|
||||||
this.desc = data.jumpGameExt?.longDesc || ''
|
this.desc = data.jumpGameExt?.longDesc || ''
|
||||||
if (data.dlcList) {
|
if (data.dlcList) {
|
||||||
for (let obj of data.dlcList) {
|
for (let obj of data.dlcList) {
|
||||||
@ -131,6 +169,61 @@ export default class extends Vue{
|
|||||||
this.priceList.push(obj)
|
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>
|
</script>
|
||||||
|
|
||||||
@ -138,6 +231,23 @@ export default class extends Vue{
|
|||||||
.game-info{
|
.game-info{
|
||||||
padding: 5px 8px;
|
padding: 5px 8px;
|
||||||
z-index: 2;
|
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 {
|
.tab-list .uni-tag {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
@ -209,5 +319,18 @@ dlc-cell {
|
|||||||
.bottom-area{
|
.bottom-area{
|
||||||
height: 24px;
|
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>
|
</style>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user