Commit 07dd3f1c by xinla

短链

1 parent d5d57322
...@@ -186,9 +186,9 @@ export default { ...@@ -186,9 +186,9 @@ export default {
<el-form-item prop="secret" label="小程序Secret"> <el-form-item prop="secret" label="小程序Secret">
<el-input clearable v-model="form.secret" placeholder="请输入" maxlength="30" show-word-limit></el-input> <el-input clearable v-model="form.secret" placeholder="请输入" maxlength="30" show-word-limit></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="" label="小程序原始ID"> <!-- <el-form-item prop="" label="小程序原始ID">
<el-input clearable v-model="form.name" placeholder="请输入" maxlength="30" show-word-limit></el-input> <el-input clearable v-model="form.name" placeholder="请输入" maxlength="30" show-word-limit></el-input>
</el-form-item> </el-form-item> -->
<el-form-item prop="longLink" label="小程序页面路径"> <el-form-item prop="longLink" label="小程序页面路径">
<el-input clearable v-model="form.longLink" placeholder="请输入" maxlength="30" show-word-limit></el-input> <el-input clearable v-model="form.longLink" placeholder="请输入" maxlength="30" show-word-limit></el-input>
</el-form-item> </el-form-item>
......
...@@ -33,15 +33,15 @@ export default { ...@@ -33,15 +33,15 @@ export default {
<div class="cc ac g-card g-pad20" style="width: 70%">公众号文章示例</div> <div class="cc ac g-card g-pad20" style="width: 70%">公众号文章示例</div>
</div> </div>
</template> </template>
<template v-else-if="[7, 9, 10].includes(+data.type)"> <template v-else-if="[7, 9].includes(+data.type)">
<div class="g-card g-pad20 cc ac" style="width: 70%; padding-bottom: 50px"> <div class="g-card g-pad20 cc ac" style="width: 70%; padding-bottom: 50px">
<div class="mt10">小程序</div> <div class="mt10">{{ data.name || '小程序' }}</div>
<div class="mt20 mb20"> <div class="mt20 mb20">
<el-image style="width: 120px; height: 120px" :src="data.avatar"> <el-image style="width: 120px; height: 120px" :src="data.avatar">
<!-- <div slot="placeholder">请设置</div> --> <!-- <div slot="placeholder">请设置</div> -->
</el-image> </el-image>
</div> </div>
<el-button type="primary">点击打开小程序</el-button> <el-button type="primary">点击打开{{ data.name || '小程序' }}</el-button>
</div> </div>
</template> </template>
<template v-else> <template v-else>
...@@ -53,7 +53,7 @@ export default { ...@@ -53,7 +53,7 @@ export default {
:src="data.avatar" :src="data.avatar"
error="头像" error="头像"
fit="fit"></el-image> fit="fit"></el-image>
<div class="toe">{{ data.shortLinkName || '名称' }}</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>
<el-image style="width: 120px; height: 120px; margin: 20px 0" :src="data.qrCode" fit="fit"></el-image> <el-image style="width: 120px; height: 120px; margin: 20px 0" :src="data.qrCode" fit="fit"></el-image>
......
...@@ -2,23 +2,23 @@ ...@@ -2,23 +2,23 @@
<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">
<div class="cc ac g-card g-pad20" style="width: 70%">公众号文章示例</div> <web-view :webview-styles="webviewStyles" :src="data.longLink"></web-view>
</div> </div>
</template> </template>
<template v-else-if="[7, 9, 10].includes(+data.type)"> <template v-else-if="[7, 9].includes(+data.type)">
<div class="g-card g-pad20 cc ac" style="width: 70%"> <div class="g-card g-pad20 cc ac" style="width: 70%">
<div class="mt10">小程序</div> <div class="mt10">{{ data.name || '小程序' }}</div>
<div class="mt20 mb20"> <div class="mt20 mb20">
<image style="width: 120px; height: 120px" :src="data.avatar" error="头像" fit="fit"></image> <image style="width: 120px; height: 120px" :src="data.avatar" error="头像" fit="fit"></image>
</div> </div>
<button type="primary" @tap="open()">点击打开小程序</button> <button type="primary" @tap="open()">点击打开{{ data.name || '小程序' }}</button>
</div> </div>
</template> </template>
<template v-else> <template v-else>
<div class="g-card g-pad20 cc ac" style="width: 70%"> <div class="g-card g-pad20 cc ac" style="width: 70%">
<div class="al bfc-o"> <div class="al bfc-o">
<image class="fl mr10" style="width: 50px; height: 50px" :src="data.avatar" error="头像" fit="fit"></image> <image class="fl mr10" style="width: 50px; height: 50px" :src="data.avatar" error="头像" fit="fit"></image>
<div class="toe">{{ data.name || '无aa。名称' }}</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: 120px; height: 120px; margin: 20px 0" :src="data.qrCode" fit="fit"></image> <image style="width: 120px; height: 120px; margin: 20px 0" :src="data.qrCode" fit="fit"></image>
...@@ -45,9 +45,8 @@ ...@@ -45,9 +45,8 @@
} }
}, },
onLoad(options) { onLoad(options) {
const query = options.query; // 这个就是你的参数,是个json对象
console.log('onLoad options', options); // 场景值为 1065 console.log('onLoad options', options); // 场景值为 1065
this.getDetail(query.route) this.getDetail(options.id)
}, },
created() { created() {
// let id = this.$route.query.id // let id = this.$route.query.id
...@@ -57,14 +56,17 @@ ...@@ -57,14 +56,17 @@
}, },
methods: { methods: {
getDetail(path) { getDetail(path) {
console.log('path', path)
this.loading = true this.loading = true
getDetail(path) getDetail(path)
.then(({ .then(({
data data
}) => { }) => {
this.data = data this.data = data
console.log('data', data)
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: touchTypeDict[data.type].previewMobileTitle, // title: touchTypeDict[data.type].previewMobileTitle,
title: data.shortLinkName
}) })
}) })
.catch(() => {}) .catch(() => {})
...@@ -74,8 +76,8 @@ ...@@ -74,8 +76,8 @@
}, },
open() { open() {
wx.navigateToMiniProgram({ wx.navigateToMiniProgram({
appId: '', appId: this.data.appId,
path: 'page/index/index?id=123', path: this.data.longLink,
extraData: { extraData: {
foo: 'bar', foo: 'bar',
}, },
......
...@@ -14,6 +14,8 @@ http.interceptors.request.use( ...@@ -14,6 +14,8 @@ http.interceptors.request.use(
// if (config.custom.auth) { // if (config.custom.auth) {
// config.header.token = 'token' // config.header.token = 'token'
// } // }
config.header['Authorization'] =
'eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX3R5cGUiOiIwMCIsInVzZXJfaWQiOjEsImxvZ2luX3R5cGUiOiJMaW5rV2VDaGF0QVBJIiwidXNlcl9uYW1lIjoiYWRtaW4iLCJ1c2VyX2tleSI6IjYyZjRiYWZmLWY2NzYtNGNlOS1iNDNhLTZhMjhlM2QwYTEwNiIsImNvcnBfbmFtZSI6IuS7n-W-ruenkeaKgCIsImNvcnBfaWQiOiJ3dzYyMmZjODUyZjc5YzNmMTMifQ.CvkoSw7K1eT-AjmfFYX5e2MlxKFNjfqzPpIwPlEuNDRL3ZASTW7t6UlGUl5CbYGI-F-3EPcVvFm9PcEk_YKtlQ'
// if (config.custom.loading) { // if (config.custom.loading) {
// uni.showLoading() // uni.showLoading()
// } // }
...@@ -35,14 +37,14 @@ http.interceptors.response.use( ...@@ -35,14 +37,14 @@ http.interceptors.response.use(
(response) => { (response) => {
/* 对响应成功做点什么 可使用async await 做异步操作*/ /* 对响应成功做点什么 可使用async await 做异步操作*/
let data = response.data let data = response.data
if (data.code == 200 || (data.code != 0 && data.code != 500)) { if (data.code == 200) {
return data.result || data.record || data.data return data
} }
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: data.msg, title: data.msg,
duration: 2000, duration: 3000,
}) })
return Promise.reject(response) // return Promise.reject 可使promise状态进入catch return Promise.reject(response) // return Promise.reject 可使promise状态进入catch
}, },
...@@ -67,7 +69,7 @@ export async function get(url, params) { ...@@ -67,7 +69,7 @@ export async function get(url, params) {
}) })
} }
export default function (config = {}) { export default function(config = {}) {
config.baseURL = cfg.BASE_API config.baseURL = cfg.BASE_API
// 兼容get方法使用data传参 // 兼容get方法使用data传参
if ((config.method || 'get').toLowerCase() === 'get' && !config.params) { if ((config.method || 'get').toLowerCase() === 'get' && !config.params) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!