Commit 7806c26d authored by spc's avatar spc

sywebview

parent 21273336
import requestModule from './request.js'
const {api} = requestModule
export const fetchSyWebviewJSON = () => api.get('/c/front/content', {type: 'sywebview'})
...@@ -39,6 +39,7 @@ Webview页面使用说明: ...@@ -39,6 +39,7 @@ Webview页面使用说明:
<script> <script>
import { useUserStore } from '@/stores/user.js'; import { useUserStore } from '@/stores/user.js';
import { useGlobalStore } from '../../stores/global'; import { useGlobalStore } from '../../stores/global';
import { fetchSyWebviewJSON } from '../../api/sywebview';
export default { export default {
data() { data() {
return { return {
...@@ -57,13 +58,23 @@ export default { ...@@ -57,13 +58,23 @@ export default {
// 确保登录以获取 cuk(异步回调,可能未立即生效) // 确保登录以获取 cuk(异步回调,可能未立即生效)
await this.wxAutoLogin(); await this.wxAutoLogin();
const res = await fetchSyWebviewJSON()
console.log('res', res)
// if (!res.data.url) {
// uni.redirectTo({
// url: '/pages/index/index'
// })
// return
// }
// 固定写死的 URL(不从 options 读取 baseUrl) // 固定写死的 URL(不从 options 读取 baseUrl)
const baseUrl = 'https://25niansuyuan.feihe.com/projects/Firmus/dev/index'; const baseUrl = res.data.url || 'https://25niansuyuan.feihe.com/projects/Firmus/dev/index';
const store = useGlobalStore(); const store = useGlobalStore();
const cuk = store.cuk; const cuk = store.cuk;
const openId = store.openId; const openId = store.openId;
const unionId = store.unionId; const unionId = store.unionId;
// 将 options 的所有参数原样作为查询参数传给 H5,并补齐 cuk // 将 options 的所有参数原样作为查询参数传给 H5,并补齐 cuk
const params = { ...(options || {}) }; const params = { ...(options || {}) };
if (cuk && !params.cuk) params.cuk = cuk; if (cuk && !params.cuk) params.cuk = cuk;
...@@ -97,15 +108,15 @@ export default { ...@@ -97,15 +108,15 @@ export default {
onShareAppMessage(options) { onShareAppMessage(options) {
// 分享功能 // 分享功能
const { share } = this; const { share } = this;
console.warn(share?.link, "share.link--------", JSON.stringify(options)); console.warn(share?.shareUrl, "share.link--------", JSON.stringify(options));
if (share) { if (share) {
const shareurl = share.link; const shareurl = share.shareUrl;
return { return {
title: share.title, title: share.shareTitle,
path: shareurl, path: shareurl,
imageUrl: share.imgUrl || '', imageUrl: share.shareImageUrl || '',
success: function (res) { success: function (res) {
console.log(res, '分享成功'); console.log(res, '分享成功');
// uni.showToast({ // uni.showToast({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment