diff --git a/src/pages/home/information.wpy b/src/pages/home/information.wpy
index ad9cc52..029e8c4 100644
--- a/src/pages/home/information.wpy
+++ b/src/pages/home/information.wpy
@@ -378,6 +378,13 @@ page {
width: 184rpx;
height: 68rpx;
}
+ .ui-add-friend-btn{
+ background: #D92554;
+ color: #ffffff;
+ border-radius: 34rpx;
+ font-size: 30rpx;
+ font-weight: 500;
+ }
.ui-operation-btn-v2{
width: 52rpx;
height: 52rpx;
@@ -704,7 +711,7 @@ page {
-
+ 加好友
@@ -751,7 +758,7 @@ page {
打个招呼吧
- 非会员每天只有3次打招呼
+ 完善资料并完成真人认证和学历认证后,每天可免费加好友3次
@@ -764,7 +771,7 @@ page {
取消
发送
- 还剩{{userInfo.other_info.surplus_num}}次,成为会员将不限制打招呼
+ 今日还剩{{friendEligibility.remaining}}次,成为会员将不限制打招呼
@@ -820,6 +827,8 @@ wepy.page({
modalName: '', // 弹框
pairedScore: 0,
userData: {}, // 自己的数据信息
+ friendEligibility: {unlimited: false, remaining: 0},
+ checkingFriendEligibility: false,
userInfo: {}, // 当前用户详情数据
profile_courtship: {},
approveList: [
@@ -1231,7 +1240,7 @@ wepy.page({
})
},
// 发送打招呼消息
- sendMsg() {
+ async sendMsg() {
let vm = this
let data = {
message: vm.message
@@ -1242,16 +1251,17 @@ wepy.page({
}
if (vm.throttle) {
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}) => {
if (code == 0) {
vm.modalName = ''
vm.$showToast('消息已发送')
- if (vm.userInfo.other_info.surplus_num) {
- vm.userInfo.other_info.surplus_num--
- }
+ // Refresh authoritative quota; the third successful request opens membership checkout.
+ vm.ensureFriendEligibility()
}
vm.throttle = true
}).catch(() => {
+ vm.ensureFriendEligibility()
vm.throttle = true
}).finally(() => {
vm.throttle = true
@@ -1270,14 +1280,52 @@ wepy.page({
})
},
// 联系朋友
- contactFriendFn() {
+ async contactFriendFn() {
let vm = this
- // 校验是否完成注册资料
- if (!vm.$signInVerify()) {
+ // 登录后由服务端依次检查完整资料、认证及剩余次数。
+ if (!wx.getStorageSync('token')) {
vm.loginShow = true
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() {
@@ -1308,7 +1356,7 @@ wepy.page({
wx.navigateTo({url: `/pages/home/personalDynamic?id=${vm.id}`})
} 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}`})
- } else if (type == 'vip' && !vm.isIos) {
+ } else if (type == 'vip') {
wx.navigateTo({url: `/pages/users/upgradeVIP`})
}
vm.modalName = ''
diff --git a/src/pages/users/upgradeVIP.wpy b/src/pages/users/upgradeVIP.wpy
index 6817d54..fc9f617 100644
--- a/src/pages/users/upgradeVIP.wpy
+++ b/src/pages/users/upgradeVIP.wpy
@@ -27,7 +27,7 @@
- {{item.name}}{{purchaseEnabled ? '购买前确认价格' : '会员购买暂不可用'}}
+
diff --git a/tools/local-acceptance/friend-eligibility.test.cjs b/tools/local-acceptance/friend-eligibility.test.cjs
new file mode 100644
index 0000000..8b37acb
--- /dev/null
+++ b/tools/local-acceptance/friend-eligibility.test.cjs
@@ -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(/