Guide friend eligibility and show membership package images

This commit is contained in:
Glore Zeng 2026-11-02 01:13:43 +08:00
parent 315a8365b6
commit 2135ca78e2
3 changed files with 80 additions and 13 deletions

View File

@ -378,6 +378,13 @@ page {
width: 184rpx; width: 184rpx;
height: 68rpx; height: 68rpx;
} }
.ui-add-friend-btn{
background: #D92554;
color: #ffffff;
border-radius: 34rpx;
font-size: 30rpx;
font-weight: 500;
}
.ui-operation-btn-v2{ .ui-operation-btn-v2{
width: 52rpx; width: 52rpx;
height: 52rpx; height: 52rpx;
@ -704,7 +711,7 @@ page {
<image class="ui-operation-btn-v2" src="https://image.fulllinkai.com/202409/25/104374082c9e2bd160ee963b4f29c98f.png" mode="widthFix" @tap="modalName = 'praise'"></image> <image class="ui-operation-btn-v2" src="https://image.fulllinkai.com/202409/25/104374082c9e2bd160ee963b4f29c98f.png" mode="widthFix" @tap="modalName = 'praise'"></image>
<image v-if="userInfo.base_profile.is_followed" class="ui-operation-btn-v2" src="https://image.fulllinkai.com/202407/30/48c1254fc413725432cc8d1c22be7440.png" mode="widthFix" @tap="attention"></image> <image v-if="userInfo.base_profile.is_followed" class="ui-operation-btn-v2" src="https://image.fulllinkai.com/202407/30/48c1254fc413725432cc8d1c22be7440.png" mode="widthFix" @tap="attention"></image>
<image v-else class="ui-operation-btn-v2" src="https://image.fulllinkai.com/202407/30/c7aa12666362515181a8f237a3ea48ff.png" mode="widthFix" @tap="attention"></image> <image v-else class="ui-operation-btn-v2" src="https://image.fulllinkai.com/202407/30/c7aa12666362515181a8f237a3ea48ff.png" mode="widthFix" @tap="attention"></image>
<image v-if="userInfo.other_info.is_friend == 0" class="ui-operation-btn" src="https://image.fulllinkai.com/202407/30/58d9ec020a61a2d5370f2adb77489c18.png" mode="widthFix" @tap="contactFriendFn"></image> <view v-if="userInfo.other_info.is_friend == 0" class="ui-operation-btn ui-add-friend-btn f-fcc" @tap="contactFriendFn">加好友</view>
<image v-else class="ui-operation-btn" src="https://image.fulllinkai.com/202407/30/0bfb0220f4b120dc0b0e9b4fb7a70a7b.png" mode="widthFix" @tap="jumpPath('chitchat')"></image> <image v-else class="ui-operation-btn" src="https://image.fulllinkai.com/202407/30/0bfb0220f4b120dc0b0e9b4fb7a70a7b.png" mode="widthFix" @tap="jumpPath('chitchat')"></image>
</view> </view>
</view> </view>
@ -751,7 +758,7 @@ page {
<image class="u_apply_img" mode="widthFix" src="https://images.ufutx.com/202105/31/37e0eda3fe1fcc0af2cb3ca2a51d2291.png"></image> <image class="u_apply_img" mode="widthFix" src="https://images.ufutx.com/202105/31/37e0eda3fe1fcc0af2cb3ca2a51d2291.png"></image>
<view class="font_34 color333 bold">打个招呼吧</view> <view class="font_34 color333 bold">打个招呼吧</view>
</view> </view>
<view class="font_28 color666 ui-pt-16" v-if="!userData.rank_id">非会员每天只有3次打招呼</view> <view class="font_28 color666 ui-pt-16" v-if="!friendEligibility.unlimited">完善资料并完成真人认证和学历认证后,每天可免费加好友3次</view>
</view> </view>
<view class="text-left ff ui-pt-30 ui-pl-36 ui-pr-36"> <view class="text-left ff ui-pt-30 ui-pl-36 ui-pr-36">
<textarea type="text" disabled show-confirm-bar="{{false}}" placeholder="输入打招呼内容" class="inputStyle" v-model="message" @input="typing" maxlength="60"/> <textarea type="text" disabled show-confirm-bar="{{false}}" placeholder="输入打招呼内容" class="inputStyle" v-model="message" @input="typing" maxlength="60"/>
@ -764,7 +771,7 @@ page {
<view class="u_apply_can f-fcc font_32 color999" @tap="modalName = ''">取消</view> <view class="u_apply_can f-fcc font_32 color999" @tap="modalName = ''">取消</view>
<view class="font_30 u_apply_btn white f-fcc" @tap="sendMsg">发送</view> <view class="font_30 u_apply_btn white f-fcc" @tap="sendMsg">发送</view>
</view> </view>
<view class="font_28 color999 text-center ui-pt-40" v-if="!userData.rank_id">还剩{{userInfo.other_info.surplus_num}}次,<text class="color-theme" @tap="jumpPath('vip')">成为会员</text>将不限制打招呼</view> <view class="font_28 color999 text-center ui-pt-40" v-if="!friendEligibility.unlimited">今日还剩{{friendEligibility.remaining}}次,<text class="color-theme" @tap="jumpPath('vip')">成为会员</text>将不限制打招呼</view>
</view> </view>
</view> </view>
</view> </view>
@ -820,6 +827,8 @@ wepy.page({
modalName: '', // 弹框 modalName: '', // 弹框
pairedScore: 0, pairedScore: 0,
userData: {}, // 自己的数据信息 userData: {}, // 自己的数据信息
friendEligibility: {unlimited: false, remaining: 0},
checkingFriendEligibility: false,
userInfo: {}, // 当前用户详情数据 userInfo: {}, // 当前用户详情数据
profile_courtship: {}, profile_courtship: {},
approveList: [ approveList: [
@ -1231,7 +1240,7 @@ wepy.page({
}) })
}, },
// 发送打招呼消息 // 发送打招呼消息
sendMsg() { async sendMsg() {
let vm = this let vm = this
let data = { let data = {
message: vm.message message: vm.message
@ -1242,16 +1251,17 @@ wepy.page({
} }
if (vm.throttle) { if (vm.throttle) {
vm.throttle = false vm.throttle = false
if (!await vm.ensureFriendEligibility()) { vm.throttle = true; return }
vm.$post({url: `${service.host}/other/user/${vm.id}/friend`, data}).then(({code, data}) => { vm.$post({url: `${service.host}/other/user/${vm.id}/friend`, data}).then(({code, data}) => {
if (code == 0) { if (code == 0) {
vm.modalName = '' vm.modalName = ''
vm.$showToast('消息已发送') vm.$showToast('消息已发送')
if (vm.userInfo.other_info.surplus_num) { // Refresh authoritative quota; the third successful request opens membership checkout.
vm.userInfo.other_info.surplus_num-- vm.ensureFriendEligibility()
}
} }
vm.throttle = true vm.throttle = true
}).catch(() => { }).catch(() => {
vm.ensureFriendEligibility()
vm.throttle = true vm.throttle = true
}).finally(() => { }).finally(() => {
vm.throttle = true vm.throttle = true
@ -1270,14 +1280,52 @@ wepy.page({
}) })
}, },
// 联系朋友 // 联系朋友
contactFriendFn() { async contactFriendFn() {
let vm = this let vm = this
// 校验是否完成注册资料 // 登录后由服务端依次检查完整资料、认证及剩余次数。
if (!vm.$signInVerify()) { if (!wx.getStorageSync('token')) {
vm.loginShow = true vm.loginShow = true
return return
} }
vm.getGreet(0) if (vm.checkingFriendEligibility) return
vm.checkingFriendEligibility = true
try { if (await vm.ensureFriendEligibility()) vm.getGreet(0) }
finally { vm.checkingFriendEligibility = false }
},
async ensureFriendEligibility() {
try {
const {code, data} = await this.$get({url: `${service.host}/friend/request/eligibility`})
if (code !== 0 || !data) return false
this.friendEligibility = data
if (data.action === 'profile') {
this.modalName = ''
wx.showModal({
title: '请先完善个人资料',
content: '完善个人资料后,再完成真人认证和学历认证,即可获得每天3次免费加好友机会。',
confirmText: '去完善',
success: res => { if (res.confirm) wx.navigateTo({url: '/pages/users/unmarriV2?progressShow=false'}) }
})
return false
}
if (data.action === 'purchase') {
this.modalName = ''
wx.navigateTo({url: '/pages/users/upgradeVIP'})
return false
}
if (data.action === 'verify') {
this.modalName = ''
const required = data.required || []
const real = required.indexOf('real') !== -1
wx.showModal({
title: '完成认证领取免费机会',
content: real ? (required.indexOf('education') !== -1 ? '完成真人认证和学历认证后,每天可免费加好友3次。请先完成真人认证。' : '完成真人认证后,每天可免费加好友3次。') : '完成学历认证后,每天可免费加好友3次。',
confirmText: real ? '真人认证' : '学历认证',
success: res => { if (res.confirm) wx.navigateTo({url: real ? '/pages/users/realName' : '/pages/users/degreeCertificate'}) }
})
return false
}
return data.allowed === true
} catch (e) { return false }
}, },
// 联系客服 // 联系客服
handleContact() { handleContact() {
@ -1308,7 +1356,7 @@ wepy.page({
wx.navigateTo({url: `/pages/home/personalDynamic?id=${vm.id}`}) wx.navigateTo({url: `/pages/home/personalDynamic?id=${vm.id}`})
} else if (type == 'chitchat') { } else if (type == 'chitchat') {
wx.navigateTo({url: `/pages/news/chitchat?id=${vm.id}&name=${encodeURIComponent(vm.userInfo.base_profile.nickname)}&pic=${vm.userInfo.base_profile.photo}&type=${vm.userInfo.base_profile.type}&real=${vm.userInfo.approve_profile.is_real_approved}`}) wx.navigateTo({url: `/pages/news/chitchat?id=${vm.id}&name=${encodeURIComponent(vm.userInfo.base_profile.nickname)}&pic=${vm.userInfo.base_profile.photo}&type=${vm.userInfo.base_profile.type}&real=${vm.userInfo.approve_profile.is_real_approved}`})
} else if (type == 'vip' && !vm.isIos) { } else if (type == 'vip') {
wx.navigateTo({url: `/pages/users/upgradeVIP`}) wx.navigateTo({url: `/pages/users/upgradeVIP`})
} }
vm.modalName = '' vm.modalName = ''

View File

@ -27,7 +27,7 @@
<swiper-item v-for="(item,index) in rankList" :key="index" class="{{cardCur==index?'cur':''}}" <swiper-item v-for="(item,index) in rankList" :key="index" class="{{cardCur==index?'cur':''}}"
@tap="showFn(index)"> @tap="showFn(index)">
<view class="swiper-item radius shadow " style="border-radius: 0"> <view class="swiper-item radius shadow " style="border-radius: 0">
<view style="padding:40rpx;background:#f7ead0;border-radius:24rpx;color:#333"><view>{{item.name}}</view><view>{{purchaseEnabled ? '购买前确认价格' : '会员购买暂不可用'}}</view></view> <image :src="item.pic" mode="aspectFit"></image>
</view> </view>
</swiper-item> </swiper-item>
</swiper> </swiper>

View File

@ -0,0 +1,19 @@
const fs=require('fs'),vm=require('vm'),assert=require('assert');
const source=fs.readFileSync('ufutx_love_mp/src/pages/home/information.wpy','utf8').match(/<script>([\s\S]*?)<\/script>/)[1].replace(/^import .*$/gm,'');
let options,modal,navigations=[];
const wx={getStorageSync:()=> 'synthetic-token',showModal:o=>{modal=o},navigateTo:o=>navigations.push(o.url)};
vm.runInNewContext(source,{wepy:{page:o=>{options=o}},https:{},base:{},service:{host:'https://synthetic.invalid'},wx,console});
const allow={allowed:true,action:'allow',remaining:1,unlimited:false};
function page(statuses){let gets=0,posts=0,greetings=0;return Object.assign({},options.methods,{id:123,message:'synthetic',throttle:true,modalName:'',checkingFriendEligibility:false,$signInVerify:()=>true,$showToast:()=>{},$get:async()=>({code:0,data:statuses[Math.min(gets++,statuses.length-1)]}),$post:async()=>{posts++;return {code:0}},getGreet:()=>{greetings++},counts:()=>({gets,posts,greetings})})}
(async()=>{
let incomplete=page([{action:'profile',required:['profile'],allowed:false,remaining:0}]);incomplete.$signInVerify=()=>false;await incomplete.contactFriendFn();assert.equal(incomplete.counts().greetings,0);assert.equal(modal.title,'请先完善个人资料');modal.success({confirm:true});assert.equal(navigations.pop(),'/pages/users/unmarriV2?progressShow=false');await incomplete.sendMsg();assert.equal(incomplete.counts().posts,0);
let p=page([{action:'verify',required:['real','education'],allowed:false}]);await p.contactFriendFn();assert.equal(p.counts().greetings,0);modal.success({confirm:true});assert.equal(navigations.pop(),'/pages/users/realName');
p=page([{action:'verify',required:['education'],allowed:false}]);await p.contactFriendFn();modal.success({confirm:true});assert.equal(navigations.pop(),'/pages/users/degreeCertificate');
p=page([{action:'purchase',remaining:0,allowed:false}]);await p.contactFriendFn();assert.equal(navigations.pop(),'/pages/users/upgradeVIP');assert.equal(p.counts().greetings,0);
p=page([allow]);await p.contactFriendFn();assert.equal(p.counts().greetings,1);
p=page([allow,{action:'purchase',remaining:0,allowed:false}]);await p.sendMsg();await new Promise(setImmediate);assert.equal(p.counts().posts,1);assert.equal(navigations.pop(),'/pages/users/upgradeVIP');
p=page([{action:'verify',required:['real'],allowed:false}]);await p.sendMsg();assert.equal(p.counts().posts,0);
p=page([{allowed:true,unlimited:true,remaining:-1,action:'allow'}]);await p.sendMsg();await new Promise(setImmediate);assert.equal(navigations.length,0);
p=page([]);p.$get=async()=>{throw Error('synthetic offline')};await p.sendMsg();assert.equal(p.counts().posts,0);assert(p.throttle);
console.log('PASS: real/education guidance, verified entry, exhausted redirect, third successful request redirect, direct-send gating, member unchanged, network failure closed; no real requests');
})().catch(e=>{console.error(e);process.exitCode=1});