增加小游戏码的预览
This commit is contained in:
parent
5658137053
commit
faa9394f87
BIN
public/img/icons/preview.png
Normal file
BIN
public/img/icons/preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
public/img/icons/wqr.png
Normal file
BIN
public/img/icons/wqr.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
@ -5,8 +5,10 @@ export interface IGameVersion {
|
|||||||
name: string
|
name: string
|
||||||
url?: string
|
url?: string
|
||||||
appid?: string
|
appid?: string
|
||||||
|
appsecret?: string
|
||||||
image?: string
|
image?: string
|
||||||
selected?: boolean
|
selected?: boolean
|
||||||
|
qr?: string
|
||||||
}
|
}
|
||||||
export interface IGameData {
|
export interface IGameData {
|
||||||
_id?: string
|
_id?: string
|
||||||
|
@ -55,6 +55,13 @@ export const getShopGameInfo = (data: any) =>
|
|||||||
data
|
data
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const getShopGameQr = (data: any) =>
|
||||||
|
request({
|
||||||
|
url: '/shop/gameqr',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
|
||||||
export const updateShopQtypes = (data: any) =>
|
export const updateShopQtypes = (data: any) =>
|
||||||
request({
|
request({
|
||||||
url: '/shop/save_qtype',
|
url: '/shop/save_qtype',
|
||||||
|
@ -80,6 +80,19 @@
|
|||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
label="AppSecret"
|
||||||
|
:prop="'versions.'+index+'.appsecret'"
|
||||||
|
v-if="vdata.type === 1"
|
||||||
|
:rules="{
|
||||||
|
required: true, message: 'AppSecret不能为空', trigger: 'blur'
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
v-model="vdata.appsecret"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button
|
<el-button
|
||||||
type="warning"
|
type="warning"
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
v-model="game.selected"
|
v-model="game.selected"
|
||||||
:active-text="game.name"
|
:active-text="game.name"
|
||||||
@change="gameSelectedChange(game._id)"
|
@change="gameSelectedChange(game._id)"
|
||||||
|
:disabled = "noShop"
|
||||||
inactive-text="">
|
inactive-text="">
|
||||||
</el-switch>
|
</el-switch>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -51,11 +52,29 @@
|
|||||||
<div style="padding: 14px;">
|
<div style="padding: 14px;">
|
||||||
<span>{{vdata.name}}</span>
|
<span>{{vdata.name}}</span>
|
||||||
<div class="bottom">
|
<div class="bottom">
|
||||||
<span>{{ vdata.type | parseGameType}}</span>
|
<el-image
|
||||||
|
v-if="!noShop"
|
||||||
|
style="width: 40px; height: 40px"
|
||||||
|
:src="vdata.type === 1 ? 'img/icons/wqr.png' : 'img/icons/preview.png'"
|
||||||
|
@click="showPreview(vdata)"
|
||||||
|
>
|
||||||
|
</el-image>
|
||||||
|
<span
|
||||||
|
v-if="vdata.type === 1 && !noShop"
|
||||||
|
@click="showPreview(vdata)"
|
||||||
|
>
|
||||||
|
查看小程序码
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
v-if="vdata.type === 0 && !noShop"
|
||||||
|
>
|
||||||
|
<a :href="vdata.url" target="_blank">预览游戏 </a>
|
||||||
|
</span>
|
||||||
<el-switch
|
<el-switch
|
||||||
v-model="vdata.selected"
|
v-model="vdata.selected"
|
||||||
active-text=""
|
active-text=""
|
||||||
@change="versionSelectedChange(game._id, vdata._id)"
|
@change="versionSelectedChange(game._id, vdata._id)"
|
||||||
|
:disabled = "noShop"
|
||||||
inactive-text="">
|
inactive-text="">
|
||||||
</el-switch>
|
</el-switch>
|
||||||
</div>
|
</div>
|
||||||
@ -64,24 +83,36 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
|
<el-image-viewer
|
||||||
|
v-if="showViewer"
|
||||||
|
:on-close="closeViewer"
|
||||||
|
:url-list="[qrUrl]" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue, Watch } from 'vue-property-decorator'
|
import { Component, Vue, Watch } from 'vue-property-decorator'
|
||||||
import { getGames, IGameData } from '@/api/game'
|
import { getGames, IGameData, IGameVersion } from '@/api/game'
|
||||||
import Sticky from '@/components/Sticky/index.vue'
|
import Sticky from '@/components/Sticky/index.vue'
|
||||||
import { getShopGameInfo, getShops, saveShopGameInfo } from '@/api/shop'
|
import ElImageViewer from 'element-ui/packages/image/src/image-viewer'
|
||||||
|
|
||||||
|
import {
|
||||||
|
getShopGameInfo,
|
||||||
|
getShopGameQr,
|
||||||
|
getShops,
|
||||||
|
saveShopGameInfo
|
||||||
|
} from '@/api/shop'
|
||||||
import { UserModule } from '@/store/modules/user'
|
import { UserModule } from '@/store/modules/user'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'GameSetting',
|
name: 'GameSetting',
|
||||||
components: {
|
components: {
|
||||||
Sticky
|
Sticky,
|
||||||
|
ElImageViewer
|
||||||
},
|
},
|
||||||
filters: {
|
filters: {
|
||||||
parseGameType: (type: number) => {
|
parseGameType: (type: number) => {
|
||||||
return type === 0 ? '微信小游戏' : '网页版'
|
return type === 1 ? '微信小游戏' : '网页版'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -93,6 +124,8 @@ export default class extends Vue {
|
|||||||
private allDepts = []
|
private allDepts = []
|
||||||
private gameid = ''
|
private gameid = ''
|
||||||
private versionid = ''
|
private versionid = ''
|
||||||
|
private qrUrl = ''
|
||||||
|
private showViewer = false
|
||||||
private listQuery = {
|
private listQuery = {
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 20,
|
limit: 20,
|
||||||
@ -104,6 +137,10 @@ export default class extends Vue {
|
|||||||
return UserModule.level
|
return UserModule.level
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get noShop() {
|
||||||
|
return !this.shop
|
||||||
|
}
|
||||||
|
|
||||||
async created() {
|
async created() {
|
||||||
await this.getList()
|
await this.getList()
|
||||||
if (UserModule.level === 1) {
|
if (UserModule.level === 1) {
|
||||||
@ -134,9 +171,25 @@ export default class extends Vue {
|
|||||||
this.gameid = data.gameid
|
this.gameid = data.gameid
|
||||||
this.versionid = data.versionid
|
this.versionid = data.versionid
|
||||||
this.updateGameSelected()
|
this.updateGameSelected()
|
||||||
|
for (let i = 0; i < this.list.length; i++) {
|
||||||
|
const game = this.list[i]
|
||||||
|
for (const v of game.versions) {
|
||||||
|
if (v.type === 1) {
|
||||||
|
const url = await this.getGameQr(this.shop, this.gameid, this.versionid)
|
||||||
|
v.qr = [url]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Vue.set(this.list, i, game)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateGameSelected() {
|
private async getGameQr(shop: string, gameId: string, version: string) {
|
||||||
|
const params = { shop, gameId, version }
|
||||||
|
const { data } = await getShopGameQr(params)
|
||||||
|
return data.url
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updateGameSelected() {
|
||||||
if (this.list.length === 0) {
|
if (this.list.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -222,6 +275,20 @@ export default class extends Vue {
|
|||||||
console.log('save shop gamesetting error')
|
console.log('save shop gamesetting error')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private showPreview(data: IGameVersion) {
|
||||||
|
if (data.type === 1) {
|
||||||
|
this.qrUrl = data.qr
|
||||||
|
this.showViewer = true
|
||||||
|
} else if (data.url) {
|
||||||
|
window.open(data.url, '_blank')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private closeViewer() {
|
||||||
|
this.qrUrl = ''
|
||||||
|
this.showViewer = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user