Commit f17cf76f by xinla

短链

1 parent 8c2c85b9
<template> <template>
<view class="content"> <view class="content">
<template v-if="data.type == 0"> <!-- <template v-if="data.type == 0">
<div class="mask" style="position: absolute"> <div class="mask" style="position: absolute">
<web-view :webview-styles="webviewStyles" :src="data.longLink"></web-view> <web-view :src="data.longLink"></web-view>
</div> </div>
</template> </template> -->
<div v-else class="g-card g-pad20 cc ac" style="width: 70%"> <div class="g-card g-pad20 cc ac">
<!-- 个人小程序,企业小程序 --> <!-- 个人小程序,企业小程序 -->
<template v-if="[7, 9].includes(+data.type)"> <template v-if="[7, 9].includes(+data.type)">
<div class="">{{ data.name || '小程序' }}</div> <div class="">{{ data.name || '小程序' }}</div>
<image style="width: 200px; height: 200px; display: block; margin: 20px auto 30px;" :src="data.avatar" <image
show-menu-by-longpress fit="fit"></image> style="width: 200px; height: 200px; display: block; margin: 20px auto 30px"
:src="data.avatar"
show-menu-by-longpress
fit="fit"></image>
<button class="" type="primary" @tap="open()">点击打开{{ data.name || '小程序' }}</button> <button class="" type="primary" @tap="open()">点击打开{{ data.name || '小程序' }}</button>
</template> </template>
<template v-else> <template v-else>
<!-- 员工活码,客群活码 门店导购活码 门店群活码 --> <!-- 员工活码,客群活码 门店导购活码 门店群活码 -->
<div v-if="[4, 5, 6, 8].includes(+data.type)" class="mt10">{{ data.name || touchTypeDict[data.type].name }} <div v-if="[4, 5, 6, 8].includes(+data.type)" class="mt10">
{{ data.name || touchTypeDict[data.type].name }}
</div> </div>
<div v-else class="al bfc-o"> <div v-else class="al bfc-o">
<image class="fl mr10" style="width: 50px; height: 50px" :src="data.avatar" show-menu-by-longpress> <image class="fl mr10" style="width: 50px; height: 50px" :src="data.avatar" show-menu-by-longpress></image>
</image>
<div class="toe">{{ data.name || '名称' }}</div> <div class="toe">{{ data.name || '名称' }}</div>
<div class="tips mt20 toe">{{ data.describe || '描述' }}</div> <div class="tips mt20 toe">{{ data.describe || '描述' }}</div>
</div> </div>
<image style="width: 200px; height: 200px; margin: 20px 0 30px" :src="data.qrCode" show-menu-by-longpress> <image
</image> style="width: 200px; height: 200px; margin: 20px 0 30px"
<div class="">长按二维码{{ touchTypeDict[data.type].previewMobileTitle }}</div> :src="data.qrCode"
show-menu-by-longpress></image>
<div v-if="[5, 6].includes(+data.type)" class="mt10">长按二维码保存后,使用微信扫一扫打开</div>
<div v-else class="">长按二维码{{ touchTypeDict[data.type].previewMobileTitle }}</div>
</template> </template>
</div> </div>
<!-- <canvas canvas-id="mycanvas" id="mycanvas" type="2d" style="width: 500px; height: 500px; display: none"></canvas> -->
</view> </view>
</template> </template>
<script> <script>
import { // const jsQR = require('jsqr')
getDetail import { getDetail } from '@/api/intelligentShortLink'
} from '@/api/intelligentShortLink' import { touchTypeDict } from './mixin'
import {
touchTypeDict
} from './mixin'
export default { export default {
data() { data() {
return { return {
loading: false, loading: false,
data: {}, data: {},
touchTypeDict, touchTypeDict,
id: '',
qrCodeUrl: '',
} }
}, },
onLoad(options) { onLoad(options) {
console.log('onLoad options', options); console.log('onLoad options', options)
this.getDetail(options.id) this.id = options.id
},
onReady() {
this.getDetail(this.id)
}, },
created() { created() {
// let id = this.$route.query.id // let id = this.$route.query.id
...@@ -60,14 +70,68 @@ ...@@ -60,14 +70,68 @@
// var page = pages[pages.length - 1] // var page = pages[pages.length - 1]
// console.log('当前页面路由地址数据信息', page) // console.log('当前页面路由地址数据信息', page)
}, },
mounted() {},
methods: { methods: {
getDetail(path) { getDetail(path) {
console.log('path', path) console.log('path', path)
this.loading = true this.loading = true
getDetail(path) getDetail(path)
.then(({ .then(({ data }) => {
data // if ([5, 6].includes(+data.type)) {
}) => { // var query = uni.createSelectorQuery().in(this)
// query
// .select('#mycanvas')
// .fields({ node: true, size: true })
// .exec((res) => {
// var canvas = res[0].node
// // var ctx = uni.createCanvasContext('mycanvas', this)
// var ctx = canvas.getContext('2d')
// // Canvas 画布的实际绘制宽高
// const width = res[0].width
// const height = res[0].height
// // 初始化画布大小
// const dpr = wx.getWindowInfo().pixelRatio
// debugger
// canvas.width = width * dpr
// canvas.height = height * dpr
// // ctx.scale(1, 1)
// var img = canvas.createImage()
// img.onload = function () {
// ctx.drawImage(img, 0, 0)
// // canvas.toDataURL()
// var imageData = ctx.getImageData(0, 0, img.width, img.height)
// var code = jsQR(imageData.data, imageData.width, imageData.height, {})
// if (code) {
// console.log('code', code.data)
// this.qrCodeUrl = code.data
// } else {
// console.log('识别错误')
// }
// // uni.canvasGetImageData({
// // mycanvas: 'mycanvas',
// // x: 0,
// // y: 0,
// // width: img.width,
// // height: img.height,
// // success(imageData) {
// // var code = jsQR(imageData.data, imageData.width, imageData.height, {
// // inversionAttempts: 'dontInvert',
// // })
// // if (code) {
// // console.log('code', code.data)
// // } else {
// // console.log('识别错误')
// // }
// // },
// // })
// }
// img.src = data.qrCode
// })
// }
this.data = data this.data = data
console.log('data', data) console.log('data', data)
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
...@@ -84,17 +148,25 @@ ...@@ -84,17 +148,25 @@
wx.navigateToMiniProgram({ wx.navigateToMiniProgram({
appId: this.data.appId, appId: this.data.appId,
path: this.data.longLink, path: this.data.longLink,
extraData: { // extraData: {
foo: 'bar', // foo: 'bar',
}, // },
envVersion: 'develop', // envVersion: 'develop',
success(res) { success(res) {
// 打开成功 // 打开成功
}, },
}) })
}, },
// copy() {
// uni.setClipboardData({
// data: this.data.longLink,
// success: function () {
// console.log('success')
// },
// })
// },
}, },
} }
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!