feat:微信小程序短链

This commit is contained in:
dzc committed 2025-12-12 15:22:19 +08:00
1 parent 5f8be90582
commit 940b2fec2d
4 files changed
+35 -38

No files matched your search

+5 -2
View File
@@ -200,6 +200,9 @@ const handleOpenVip = () => {
uni.showToast({ title: `不支持${payMethodItem.title}支付`, icon: 'none' });
return
}
jumpToWechatPage()
return
messageBox
.confirm({
msg: '确认开通?',
@@ -238,8 +241,8 @@ const disposeWechatPay = async (openTypeId: any) => {
}
// 跳转到微信小程序
const jumpToWechatPage = () => {
jumpToWechatMiniProgram("openVip", {
const jumpToWechatPage = async () => {
await jumpToWechatMiniProgram("openVip", {
openTypeId: curOpenTypeId.value,
payMethod: payMethod.value
})
+10 -1
View File
@@ -12,7 +12,7 @@
<wd-cell title="手机号" :value="userInfo?.mobile" />
<wd-cell title="设置微信" :value="userInfo?.wechatNum" is-link ellipsis to="/pages/profile/set-wechat" />
<wd-cell title="黑名单" is-link ellipsis to="/pages/profile/black-list" />
<wd-cell title="客服邮箱" value="18917151569@163.com" is-link ellipsis />
<wd-cell title="客服邮箱" value="18917151569@163.com" is-link @tap="copyEmail('18917151569@163.com')" />
<wd-cell title="消息推送" value="消息推送" ellipsis>
<wd-switch v-model="params.isPush" inactive-color="#777" @change="settingChange" size="20" />
</wd-cell>
@@ -97,6 +97,15 @@ const beforeChange = ({ value, resolve }: any) => {
resolve(true);
};
const copyEmail = (email: string) => {
uni.setClipboardData({
data: email,
success: () => {
uni.showToast({ title: '复制成功', icon: 'none', });
},
});
}
// 退出登录
const handleLogout = () => {
message
+8
View File
@@ -71,6 +71,14 @@ const SocialApi = {
},
});
},
// 获取微信小程短链
getWxaQrcode: async (params) => {
return await request({
url: '/member/social-user/wxa-url-scheme',
method: 'GET',
params,
});
},
};
export default SocialApi;
+12 -35
View File
@@ -1,20 +1,10 @@
// @ts-nocheck
import { isEmpty } from 'lodash-es';
import SocialApi from '@/sheep/api/member/social';
const targetAppId = 'wx2b4e4d3feff8267f';
const paramsToQuery = (params: Record<string, any>) => {
if (isEmpty(params)) {
return '';
}
let query = [];
for (let key in params) {
query.push(key + '=' + params[key]);
}
return query.join('&');
}
export const jumpToWechatMiniProgram = (
export const jumpToWechatMiniProgram = async (
action: 'recharge' | 'openVip',
params: Record<string, any>,
) => {
@@ -24,28 +14,15 @@ export const jumpToWechatMiniProgram = (
}
if (action === 'openVip') {
path = 'pages/profile/apply-vip';
}
console.log("weixinShare:", path)
plus.share.getServices((data) => {
let sweixin = null;
data.forEach(item => {
if (item.id === "weixin") {
sweixin = item
}
})
console.log("sweixin:", sweixin)
if (!sweixin) {
uni.showToast({
title: "请安装微信",
icon: "none",
});
return
}
sweixin.launchMiniProgram({
id: targetAppId,
}
try {
// 获取小程序短链
const { code, data } = await SocialApi.getWxaQrcode({
path: path,
// 可取值:0-正式版; 1-测试版; 2-体验版。默认值为0。
type: 1,
});
})
json: JSON.stringify(params)
})
console.log("|获取小程序短链|成功code:", code, "data:", data);
} catch (error) {
console.log("|获取小程序短链|意外的错误error:", error);
}
}