feat:解锁微信信息;vip判断

This commit is contained in:
ctw committed 2025-12-08 14:05:24 +08:00
1 parent 603f72008c
commit 338f5b524f
9 files changed
+114 -281

No files matched your search

+50 -4
View File
@@ -76,11 +76,14 @@
<view class="m-4">
<view class="my-2 text-size-base">查看微信</view>
<view class="bg-color-theme rounded-1 flex justify-between items-center p-2">
<view
v-if="!userWechatInfo.wechatNum"
class="bg-color-theme rounded-1 flex justify-between items-center p-2"
>
<view class="flex-col">
<view class="flex items-center">
<image class="size-44rpx mr-2" src="@/static/weixin-black.png" mode="aspectFill" />
<text class="text-black">qdadafafafadawd</text>
<text class="text-black">*************</text>
</view>
<view class="text-xs c-black tracking-0.2">
<text>成为</text>
@@ -88,7 +91,18 @@
<text>免费解锁</text>
</view>
</view>
<view class="rounded-1 px-4 py-1 bg-#333 active:bg-#222">解锁</view>
<view class="rounded-1 px-4 py-1 bg-#333 active:bg-#222" @click="unlockWeChat">
解锁
</view>
</view>
<view v-else class="bg-color-theme rounded-1 flex justify-between items-center p-2">
<view class="flex items-center">
<image class="size-44rpx mr-2" src="@/static/weixin-black.png" mode="aspectFill" />
<text class="text-black">{{ userWechatInfo.wechatNum }}</text>
</view>
<view class="rounded-1 px-4 py-1 bg-#333 active:bg-#222" @click="copyWechatNum">
复制
</view>
</view>
</view>
@@ -198,10 +212,12 @@
import { formatDate } from '@/sheep/helper/utils';
const userCity = computed(() => sheep.$store('user').userCity);
const userInfo = computed(() => sheep.$store('user').userInfo);
const scrollTop = ref(0);
const userDetail = ref<any>({});
const userDetail = ref<any>({}); // 用户详情
const actionShow = ref(false);
// 朋友圈列表参数
const params = reactive({
scene: 'DYNAMIC_RECOMMEND',
province: '',
@@ -215,12 +231,18 @@
scoreSk: 0, // 爽快评分
scoreYq: 0, // 有趣评分
});
// 浏览记录参数
const viewRecord = reactive({
bizType: '',
bizId: '',
viewStartTime: new Date().getTime(),
viewEndTime: '',
});
// 用户微信信息
const userWechatInfo = reactive({
wechatNum: '',
wechatQrCode: '',
});
const photoListUrls = computed(
() =>
@@ -281,6 +303,30 @@
scrollTop.value = e.detail.scrollTop;
}
// 解锁微信
const unlockWeChat = async () => {
const vip = userInfo.value?.memberVip.vip;
if (!vip) return uni.showToast({ title: '请先开通vip会员', icon: 'none' });
if (!params.memberId) return uni.showToast({ title: '用户id不存在', icon: 'none' });
const { code, data } = await RecentApi.unlockWeChat({ memberId: params.memberId });
if (code === 0) {
uni.showToast({ title: '解锁成功', icon: 'none' });
Object.assign(userWechatInfo, data);
}
};
// 复制微信号
const copyWechatNum = () => {
uni.setClipboardData({
data: userWechatInfo.wechatNum,
showToast: false,
success: () => {
uni.showToast({ title: '微信号已复制', icon: 'success' });
},
});
};
// 相册预览
const previewPhoto = (current: number) => {
uni.previewImage({
+9 -6
View File
@@ -15,7 +15,7 @@
v-for="(item, index) in reportTypeList"
:key="index"
>
<wd-radio :value="item" class="flex items-center justify-between mt-0! w-full">
<wd-radio :value="index" class="flex items-center justify-between mt-0! w-full">
<view class="text-size-base mr-auto">{{ item }}</view>
</wd-radio>
</view>
@@ -64,7 +64,7 @@
const reportTypeList = ref([]);
const form = reactive({
memberId: '',
reportType: '',
reportType: -1,
reportDescription: '',
});
const reportImages = ref([]);
@@ -79,24 +79,27 @@
const { data = null } = await RecentApi.reportType();
if (data?.reportTypeList && data.reportTypeList.length > 0) {
reportTypeList.value = data.reportTypeList;
form.reportType = data.reportTypeList[0];
form.reportType = 0;
return;
}
reportTypeList.value = [];
});
const submitReport = async () => {
if (!form.memberId || !form.reportType)
return uni.showToast({ title: '用户id不存在', icon: 'none' });
console.log(form);
if (!form.memberId) return uni.showToast({ title: '用户id不存在', icon: 'none' });
if (!form.reportDescription) return uni.showToast({ title: '请填写问题描述', icon: 'none' });
const { code } = await RecentApi.recentOperate({
action: 'MEMBER_REPORT',
...form,
reportType: form.reportType.toString(),
reportPic: reportPic.value,
});
if (code === 0) {
uni.showToast({ title: '举报成功', icon: 'none' });
setTimeout(() => {
back();
}, 500);
}
};
+23 -21
View File
@@ -984,28 +984,10 @@
this.isSending = true;
const reqData = this.reqQueue.shift();
// RecentApi.sendPrivateMsg(reqData.msgInfo)
// .then((res) => {
// if (res.code === 0) {
// reqData.resolve(res);
// }
// })
// .catch((e) => {
// reqData.reject(e);
// })
// .finally(() => {
// this.isSending = false;
// // 发送下一条请求
// this.processReqQueue();
// });
this.$http({
url: this.messageAction,
method: 'post',
data: reqData.msgInfo,
})
// 私聊 有会员次数限制
RecentApi.sendPrivateMsg(reqData.msgInfo)
.then((res) => {
reqData.resolve(res);
reqData.resolve(res.data);
})
.catch((e) => {
reqData.reject(e);
@@ -1015,6 +997,26 @@
// 发送下一条请求
this.processReqQueue();
});
// 私聊 无限制
// this.$http({
// url: this.messageAction,
// method: 'post',
// data: reqData.msgInfo,
// })
// .then((res) => {
// console.log(res);
// reqData.resolve(res);
// })
// .catch((e) => {
// reqData.reject(e);
// })
// .finally(() => {
// this.isSending = false;
// // 发送下一条请求
// this.processReqQueue();
// });
}
},
reCalChatMainHeight() {
-141
View File
@@ -1,141 +0,0 @@
<template>
<web-view
class="page chat-group-video"
id="chat-video-wv"
@message="onMessage"
:src="url"
></web-view>
</template>
<script>
import CHAT_ENV from '@/chat-env.js';
export default {
data() {
return {
url: '',
wv: '',
isHost: false,
groupId: null,
inviterId: null,
userInfos: [],
};
},
methods: {
onMessage(e) {
this.onWebviewMessage(e.detail.data[0]);
},
onInsertMessage(msgInfo) {},
onWebviewMessage(event) {
console.log('来自webview的消息:' + JSON.stringify(event));
switch (event.key) {
case 'WV_READY':
this.initWebView();
break;
case 'WV_CLOSE':
uni.navigateBack();
break;
case 'INSERT_MESSAGE':
this.onInsertMessage(event.data);
break;
}
},
sendMessageToWebView(key, message) {
// 如果webview还没初始化好,则延迟100ms再推送
if (!this.wv) {
setTimeout(() => this.sendMessageToWebView(key, message), 100);
return;
}
let event = {
key: key,
data: message,
};
// #ifdef APP-PLUS
this.wv.evalJS(`onEvent('${encodeURIComponent(JSON.stringify(event))}')`);
// #endif
// #ifdef H5
this.wv.postMessage(event, '*');
// #endif
},
initWebView() {
// #ifdef APP-PLUS
// APP的webview
this.wv = this.$scope.$getAppWebview().children()[0];
// #endif
// #ifdef H5
// H5的webview就是iframe
this.wv = document.getElementById('chat-video-wv').contentWindow;
// #endif
},
initUrl() {
this.url = '/hybrid/html/rtc-group/index.html?';
this.url += 'baseUrl=' + CHAT_ENV.BASE_URL;
this.url += '&groupId=' + this.groupId;
this.url += '&userId=' + this.userStore.userInfo.id;
this.url += '&inviterId=' + this.inviterId;
this.url += '&isHost=' + this.isHost;
this.url += '&loginInfo=' + JSON.stringify(uni.getStorageSync('loginInfo'));
this.url += '&userInfos=' + JSON.stringify(this.userInfos);
this.url += '&config=' + JSON.stringify(this.configStore.webrtc);
},
},
onBackPress() {
this.sendMessageToWebView('NAV_BACK', {});
},
onLoad(options) {
uni.$on('WS_RTC_GROUP', (msg) => {
// 推送给web-view处理
this.sendMessageToWebView('RTC_MESSAGE', msg);
});
// #ifdef H5
window.onmessage = (e) => {
this.onWebviewMessage(e.data.data.arg);
};
// #endif
// 是否发起人
this.isHost = JSON.parse(options.isHost);
// 发起者的用户
this.inviterId = options.inviterId;
// 解析页面跳转时带过来的好友信息
this.groupId = options.groupId;
// 邀请的用户信息
this.userInfos = JSON.parse(decodeURIComponent(options.userInfos));
// 构建url
this.initUrl();
},
onUnload() {
uni.$off('WS_RTC_GROUP');
},
};
</script>
<style lang="scss" scoped>
.chat-group-video {
.header {
display: flex;
justify-content: center;
align-items: center;
height: 60rpx;
padding: 5px;
background-color: white;
line-height: 50px;
font-size: 40rpx;
font-weight: 600;
.btn-side {
position: absolute;
line-height: 60rpx;
font-size: 28rpx;
cursor: pointer;
&.left {
left: 30rpx;
}
&.right {
right: 30rpx;
}
}
}
}
</style>
-106
View File
@@ -1,106 +0,0 @@
<template>
<web-view
class="page chat-private-video"
id="chat-video-wv"
@message="onMessage"
:src="url"
></web-view>
</template>
<script>
import CHAT_ENV from '@/chat-env.js';
export default {
data() {
return {
url: '',
wv: '',
mode: 'video',
isHost: true,
friend: {},
};
},
methods: {
onMessage(e) {
this.onWebviewMessage(e.detail.data[0]);
},
onWebviewMessage(event) {
console.log('来自webview的消息:' + JSON.stringify(event));
switch (event.key) {
case 'WV_READY':
this.initWebView();
break;
case 'WV_CLOSE':
uni.navigateBack();
break;
}
},
sendMessageToWebView(key, message) {
// 如果webview还没初始化好,则延迟100ms再推送
if (!this.wv) {
setTimeout(() => this.sendMessageToWebView(key, message), 100);
return;
}
let event = {
key: key,
data: message,
};
// #ifdef APP-PLUS
this.wv.evalJS(`onEvent('${encodeURIComponent(JSON.stringify(event))}')`);
// #endif
// #ifdef H5
this.wv.postMessage(event, '*');
// #endif
},
initWebView() {
// #ifdef APP-PLUS
// APP的webview
this.wv = this.$scope.$getAppWebview().children()[0];
// #endif
// #ifdef H5
// H5的webview就是iframe
this.wv = document.getElementById('chat-video-wv').contentWindow;
// #endif
},
initUrl() {
this.url = '/hybrid/html/rtc-private/index.html';
this.url += '?mode=' + this.mode;
this.url += '&isHost=' + this.isHost;
this.url += '&baseUrl=' + CHAT_ENV.BASE_URL;
this.url += '&loginInfo=' + JSON.stringify(uni.getStorageSync('loginInfo'));
this.url += '&userInfo=' + JSON.stringify(this.userStore.userInfo);
this.url += '&friend=' + JSON.stringify(this.friend);
this.url += '&config=' + JSON.stringify(this.configStore.webrtc);
},
},
onBackPress() {
this.sendMessageToWebView('NAV_BACK', {});
},
onLoad(options) {
uni.$on('WS_RTC_PRIVATE', (msg) => {
// 推送给web-view处理
this.sendMessageToWebView('RTC_MESSAGE', msg);
});
// #ifdef H5
window.onmessage = (e) => {
this.onWebviewMessage(e.data.data.arg);
};
// #endif
// 模式:视频呼叫/语音呼叫
this.mode = options.mode;
// 是否呼叫方
this.isHost = JSON.parse(options.isHost);
// 解析页面跳转时带过来的好友信息
this.friend = JSON.parse(decodeURIComponent(options.friend));
// 构建url
this.initUrl();
},
onUnload() {
uni.$off('WS_RTC_PRIVATE');
},
};
</script>
<style lang="scss" scoped>
.chat-web-view {
}
</style>
+6
View File
@@ -119,6 +119,8 @@
import { onLoad } from '@dcloudio/uni-app';
import RecentApi from '@/sheep/api/member/recent';
import { useMessage } from '@/uni_modules/wot-design-uni';
// @ts-ignore
import $store from '@/sheep/store';
const messageBox = useMessage();
@@ -170,6 +172,10 @@
const { code } = await RecentApi.memberOpenTypePay({ openTypeId: curOpenTypeId.value });
if (code !== 0) return uni.showToast({ title: '开通失败', icon: 'fail' });
uni.showToast({ title: '开通成功', icon: 'success' });
$store('user').getInfo();
setTimeout(() => {
uni.navigateBack();
}, 500);
})
.catch(() => {});
};
+1 -1
View File
@@ -54,7 +54,7 @@
<capsule-cell title="职业" :value="userinfo.occ" />
</wd-picker>
<textarea
class="h-280rpx mx-8 my-4 rounded-10rpx bg-color-light p-10rpx text-32rpx text-color-theme"
class="h-280rpx w-84% mx-auto my-4 rounded-10rpx bg-color-light p-10rpx text-32rpx text-color-theme"
v-model="userinfo.description"
:maxlength="100"
placeholder="个人简介(100字以内)"
+13 -2
View File
@@ -21,10 +21,17 @@
mode="aspectFill"
/>
<view class="flex-1">
<view class="mb-1 text-base">{{ userInfo.nickname }}</view>
<view class="mb-1 text-base">
<text>{{ userInfo.nickname }}</text>
<image class="size-26rpx ml-2" :src="userGenderImageSrc" mode="scaleToFill" />
</view>
<view class="mb-2 text-xs text-#ffffff80 flex items-center">
<text>ID: {{ userInfo.id }}</text>
<image class="size-24rpx ml-4" :src="userGenderImageSrc" mode="scaleToFill" />
<text
class="font-bold font-italic text-xs ml-2 text-color-dark bg-color-theme-dark px-1 rounded-1"
>
VIP
</text>
</view>
<text
v-if="userCity?.t"
@@ -73,6 +80,7 @@
<view class="flex items-center">
<text class="text-xs">尊享vip免费特权</text>
<navigator
v-if="!userInfo.memberVip.vip"
url="/pages/profile/apply-vip"
open-type="navigate"
hover-class="navigator-hover"
@@ -81,6 +89,9 @@
立即开通
</text>
</navigator>
<text v-else class="ml-4 px-2 py-1 rounded-1 text-24rpx bg-color-theme text-black">
VIP 开通成功
</text>
</view>
</view>
+12
View File
@@ -389,6 +389,18 @@ const RecentApi = {
},
});
},
// 解锁微信信息
unlockWeChat: (data: any) => {
return request({
url: '/member/recent/look-wechat',
method: 'GET',
data,
custom: {
showLoading: true,
loadingMsg: '加载中',
},
});
},
// 获取礼物列表
getGiftList: () => {
return request({