信息缺失提示

master
lion 2 months ago
parent b14669f79e
commit 574f70be75

@ -236,6 +236,27 @@
required: true,
message: '请选择出生日期',
trigger: ['blur', 'change'],
}, {
validator: (rule, value, callback) => {
if (this.base.isNull(value)) return true;
const s = String(value).trim();
//
if (/^\d{4}-\d{1,2}$/.test(s)) return false;
if (!/^\d{4}-\d{1,2}-\d{1,2}$/.test(s)) return false;
const parts = s.split('-');
const y = parseInt(parts[0], 10);
const mo = parseInt(parts[1], 10);
const da = parseInt(parts[2], 10);
if (mo < 1 || mo > 12 || da < 1 || da > 31) return false;
const dt = new Date(y, mo - 1, da);
return (
dt.getFullYear() === y &&
dt.getMonth() === mo - 1 &&
dt.getDate() === da
);
},
message: '出生日期须为完整年月日(例如 1993-01-15',
trigger: ['blur', 'change'],
}]
}
}
@ -269,9 +290,12 @@
url:'/packages/avatarUpload/index'
})
},
//
// yyyy-MM-dd
dateConfirm(e) {
this.form.birthday = e.year + '-' + e.month + '-' + e.day
const y = e.year;
const m = String(e.month).padStart(2, '0');
const d = String(e.day).padStart(2, '0');
this.form.birthday = `${y}-${m}-${d}`;
},
addMobile() {
this.myMobile = this.form.mobile

@ -185,6 +185,23 @@
required: true,
message: '请选择出生日期',
trigger: ['blur', 'change'],
}, {
validator: (rule, value, callback) => {
if (this.base.isNull(value)) return true;
const s = String(value).trim();
// ( 1993-01)
if (/^\d{4}-\d{1,2}$/.test(s)) return false;
if (!/^\d{4}-\d{1,2}-\d{1,2}$/.test(s)) return false;
const parts = s.split('-');
const y = parseInt(parts[0], 10);
const mo = parseInt(parts[1], 10);
const da = parseInt(parts[2], 10);
if (mo < 1 || mo > 12 || da < 1 || da > 31) return false;
const dt = new Date(y, mo - 1, da);
return dt.getFullYear() === y && dt.getMonth() === mo - 1 && dt.getDate() === da;
},
message: '出生日期须为完整年月日(例如 1993-01-15',
trigger: ['blur', 'change'],
}]
}
}
@ -209,7 +226,39 @@
}
},
methods: {
isBirthdayMonthOnly(birthday) {
if (this.base.isNull(birthday)) return false;
return /^\d{4}-\d{1,2}$/.test(String(birthday).trim());
},
isBirthdayYmd(birthday) {
if (this.base.isNull(birthday)) return false;
const s = String(birthday).trim();
if (!/^\d{4}-\d{1,2}-\d{1,2}$/.test(s)) return false;
const parts = s.split('-');
const y = parseInt(parts[0], 10);
const mo = parseInt(parts[1], 10);
const da = parseInt(parts[2], 10);
if (mo < 1 || mo > 12 || da < 1 || da > 31) return false;
const dt = new Date(y, mo - 1, da);
return dt.getFullYear() === y && dt.getMonth() === mo - 1 && dt.getDate() === da;
},
isBasicInfoIncomplete() {
const f = this.form || {};
if (this.base.isNull(f.username)) return true;
if (this.base.isNull(f.sex)) return true;
if (this.base.isNull(f.email)) return true;
if (this.base.isNull(f.company_name)) return true;
if (this.base.isNull(f.company_position)) return true;
if (this.base.isNull(f.birthday)) return true;
if (this.isBirthdayMonthOnly(f.birthday)) return true;
if (!this.isBirthdayYmd(f.birthday)) return true;
return false;
},
addMobile() {
if (this.isBasicInfoIncomplete()) {
this.base.toast('请先完善基础信息后再绑定');
return;
}
// this.myMobile = this.form.mobile
this.showMobile = true
},
@ -271,7 +320,10 @@
},
//
dateConfirm(e) {
this.form.birthday = e.year + '-' + e.month + '-' + e.day
const y = e.year;
const m = String(e.month).padStart(2, '0');
const d = String(e.day).padStart(2, '0');
this.form.birthday = `${y}-${m}-${d}`;
},
//
handleCompanyConfirm(company) {

@ -40,6 +40,27 @@
</view> -->
</view>
</view>
<!-- 无手机号绑定或注册 pages/me/index 一致 -->
<view class="modal">
<u-popup v-model="showRegister" mode="bottom">
<view>
<view class="modal-tip-wrap">
<view class="modal-tip">提示</view>
<view class="modal-close" @click="showRegister = false">关闭</view>
</view>
<view class="modal-content">
<view>如您已是我方校友请先绑定账号</view>
<view @click="goBind" class="modal-bind">
去绑定
</view>
<view>如您还不是我方校友请先注册</view>
<view @click="toRegister" class="modal-register">
去注册
</view>
</view>
</view>
</u-popup>
</view>
<tabbar :currentPage="2"></tabbar>
</view>
</template>
@ -53,7 +74,9 @@
data() {
return {
user: {},
enter_schoolmate: 0
enter_schoolmate: 0,
showRegister: false,
hasMobile: false
}
},
onShareAppMessage() {
@ -69,16 +92,41 @@
}
},
onShow() {
this.showRegister = false
this.getUser()
},
onLoad() {
},
methods: {
ensureMobileOrPrompt() {
if (!this.hasMobile) {
this.base.toast("请先绑定或注册")
this.showRegister = true
return false
}
return true
},
goBind() {
uni.navigateTo({
url: '/packages/register/login'
})
},
toRegister() {
uni.navigateTo({
url: '/packages/register/index'
})
},
getUser() {
this.$u.api.user().then(res => {
console.log("res", res)
this.enter_schoolmate = res.enter_schoolmate
this.$u.vuex('vuex_user', res.user)
if (this.base.isNull(res.user.mobile)) {
this.hasMobile = false
} else {
this.showRegister = false
this.hasMobile = true
}
})
},
goToProfile() {
@ -87,6 +135,9 @@
});
},
handleButtonClick(type) {
if (!this.ensureMobileOrPrompt()) {
return
}
switch (type) {
case 'alumni':
if (this.enter_schoolmate) {
@ -227,5 +278,58 @@
font-weight: bold;
color: #8f6e4d;
}
.modal {
::v-deep .u-drawer-bottom {
border-radius: 40rpx;
}
.modal-tip-wrap {
display: flex;
align-items: center;
justify-content: space-between;
padding: 30rpx;
}
.modal-tip {
font-size: 32rpx;
}
.modal-close {
color: #409eff;
font-size: 28rpx;
}
.modal-content {
height: 450rpx;
padding: 0 30rpx;
font-size: 32rpx;
text-align: center;
&>view {
margin: 30rpx auto;
}
}
.modal-bind {
width: 45%;
text-align: center;
margin: 0 auto;
color: #fff;
border-radius: 30rpx;
padding: 20rpx;
background: linear-gradient(to right, #e4cdb4, #c69c6d);
}
.modal-register {
width: 45%;
text-align: center;
margin: 0 auto;
color: #fff;
border-radius: 30rpx;
padding: 20rpx;
background: linear-gradient(to right, #5e5fbc, #0d0398);
}
}
}
</style>

@ -108,6 +108,32 @@
<view class="birthday-button" @click="closeBirthdayPopup"></view>
</view>
</view>
<!-- 个人信息缺失提示 -->
<view class="profile-incomplete-popup" v-if="showProfileIncomplete">
<view class="profile-incomplete-mask" @click="closeProfileIncomplete"></view>
<view class="profile-incomplete-dialog">
<view class="profile-incomplete-text">您的个人信息有缺失请尽快补充</view>
<view class="profile-incomplete-btn" @click="goCompleteProfile"></view>
</view>
</view>
<!-- 无手机号绑定或注册与个人中心一致 -->
<view class="modal">
<u-popup v-model="showRegister" mode="bottom">
<view>
<view class="modal-tip-wrap">
<view class="modal-tip">提示</view>
<view class="modal-close" @click="showRegister = false">关闭</view>
</view>
<view class="modal-content">
<view>如您已是我方校友请先绑定账号</view>
<view @click="goBind" class="modal-bind">去绑定</view>
<view>如您还不是我方校友请先注册</view>
<view @click="toRegister" class="modal-register">去注册</view>
</view>
</view>
</u-popup>
</view>
</view>
</template>
@ -118,6 +144,11 @@ import topBanner from "@/components/topBanner.vue";
import PrivacyPopup from "@/components/privacy-popup/privacy-popup.vue";
import CalendarWidget from "@/components/calendar-widget/calendar-widget.vue";
/** 点遮罩关闭资料缺失提示时写入,值为当天 yyyy-MM-dd当天内不再弹出 */
const PROFILE_INCOMPLETE_DISMISSED_KEY = "stbc1_profileIncompleteDismissedDate";
/** 手机号缺失提醒:当天首次进入首页仅弹出一次(展示过即记) */
const MOBILE_MISSING_PROMPT_DATE_KEY = "stbc1_mobileMissingPromptDate";
export default {
components: {
tabbar,
@ -137,6 +168,11 @@ export default {
can_appointment: false,
is_birthday: false,
hasShowBirthday: false,
showProfileIncomplete: false,
showRegister: false,
pendingProfileIncomplete: false,
pendingMobileMissing: false,
isFirstShow: true,
};
},
onShareAppMessage() {
@ -170,6 +206,25 @@ export default {
this.getNoticesList();
this.getBannerList();
},
onShow() {
if (this.isFirstShow) {
this.isFirstShow = false;
return;
}
this.showRegister = false;
let token = uni.getStorageSync("stbc1_lifeData")
? uni.getStorageSync("stbc1_lifeData").vuex_token
: "";
if (this.base.isNull(token)) return;
this.$u.api.user().then((res) => {
this.$u.vuex("vuex_user", res.user);
if (!this.isProfileIncomplete(res.user)) {
this.showProfileIncomplete = false;
this.pendingProfileIncomplete = false;
this.pendingMobileMissing = false;
}
});
},
methods: {
onAgreePrivacy() {
//
@ -183,6 +238,108 @@ export default {
// wx.exitMiniProgram();
console.log("User rejected the privacy policy");
},
/** 出生日期仅有年月、无具体日期(如 1993-01视为未完善 */
isBirthdayMonthOnly(birthday) {
if (this.base.isNull(birthday)) return false;
const s = String(birthday).trim();
return /^\d{4}-\d{1,2}$/.test(s);
},
isEmptyProfileField(v) {
if (this.base.isNull(v)) return true;
if (typeof v === "string" && v.trim() === "") return true;
return false;
},
getTodayYmd() {
const d = new Date();
const y = d.getFullYear();
const m = String(d.getMonth() + 1).padStart(2, "0");
const day = String(d.getDate()).padStart(2, "0");
return `${y}-${m}-${day}`;
},
/** 当天是否已通过点遮罩关闭过资料缺失提示 */
isProfileIncompleteDismissedToday() {
return uni.getStorageSync(PROFILE_INCOMPLETE_DISMISSED_KEY) === this.getTodayYmd();
},
isMobileMissing(user) {
return !user || this.isEmptyProfileField(user.mobile);
},
isMobileMissingPromptShownToday() {
return uni.getStorageSync(MOBILE_MISSING_PROMPT_DATE_KEY) === this.getTodayYmd();
},
markMobileMissingPromptShownToday() {
uni.setStorageSync(MOBILE_MISSING_PROMPT_DATE_KEY, this.getTodayYmd());
},
/** 已绑定手机的前提下,资料是否不完整 */
isProfileIncomplete(user) {
if (!user || this.isEmptyProfileField(user.mobile)) return false;
if (this.isEmptyProfileField(user.company_name)) return true;
if (this.isEmptyProfileField(user.company_position)) return true;
if (this.isEmptyProfileField(user.email)) return true;
if (this.isEmptyProfileField(user.sex)) return true;
if (this.isEmptyProfileField(user.birthday)) return true;
if (this.isBirthdayMonthOnly(user.birthday)) return true;
return false;
},
maybeShowProfileIncomplete(user, isBirthdayFlag) {
if (!user || !this.isProfileIncomplete(user)) {
this.pendingProfileIncomplete = false;
return;
}
if (this.isProfileIncompleteDismissedToday()) {
this.pendingProfileIncomplete = false;
return;
}
const showBirthdayLayer =
isBirthdayFlag && !this.hasShowBirthday;
if (showBirthdayLayer) {
this.pendingProfileIncomplete = true;
} else {
this.showProfileIncomplete = true;
this.pendingProfileIncomplete = false;
}
},
maybeShowHomeReminder(user, isBirthdayFlag) {
if (this.isMobileMissing(user) && !this.isMobileMissingPromptShownToday()) {
const showBirthdayLayer = isBirthdayFlag && !this.hasShowBirthday;
if (showBirthdayLayer) {
this.pendingMobileMissing = true;
} else {
this.base.toast("请先绑定或注册");
this.showRegister = true;
this.markMobileMissingPromptShownToday();
}
this.pendingProfileIncomplete = false;
return;
}
this.maybeShowProfileIncomplete(user, isBirthdayFlag);
},
/** 点遮罩或点「去完善」后,当天冷启动不再弹出资料缺失提示 */
markProfileIncompleteDismissedToday() {
uni.setStorageSync(PROFILE_INCOMPLETE_DISMISSED_KEY, this.getTodayYmd());
},
goCompleteProfile() {
this.showProfileIncomplete = false;
this.markProfileIncompleteDismissedToday();
uni.navigateTo({
url: "/packages/my/index",
});
},
closeProfileIncomplete() {
this.showProfileIncomplete = false;
this.markProfileIncompleteDismissedToday();
},
goBind() {
this.showRegister = false;
uni.navigateTo({
url: "/packages/register/login",
});
},
toRegister() {
this.showRegister = false;
uni.navigateTo({
url: "/packages/register/index",
});
},
changeCurrent(e) {
this.show_current_swiper = e.detail.current + 1;
},
@ -233,11 +390,17 @@ export default {
vuex_token: tokenResult,
vuex_user: result1.data.user,
});
this.$u.vuex("vuex_token", tokenResult);
this.$u.vuex("vuex_user", result1.data.user);
//
if (result1.data.is_birthday && !this.hasShowBirthday) {
this.is_birthday = true;
}
this.maybeShowHomeReminder(
result1.data.user,
result1.data.is_birthday
);
},
fail(err) {
console.log("uesr-error", err);
@ -253,11 +416,12 @@ export default {
// }
// this.door_appointments = res.door_appointments ? true : false
this.$u.vuex("vuex_user", res.user);
// 使is_birthday
if (res.is_birthday && !this.hasShowBirthday) {
this.is_birthday = true;
}
this.maybeShowHomeReminder(res.user, res.is_birthday);
});
},
@ -267,6 +431,27 @@ export default {
//
uni.setStorageSync("hasShowBirthday", true);
this.hasShowBirthday = true;
if (this.pendingProfileIncomplete) {
const life = uni.getStorageSync("stbc1_lifeData") || {};
const u = life.vuex_user || this.vuex_user || {};
if (
!this.isProfileIncompleteDismissedToday() &&
this.isProfileIncomplete(u)
) {
this.showProfileIncomplete = true;
}
this.pendingProfileIncomplete = false;
}
if (this.pendingMobileMissing) {
const life = uni.getStorageSync("stbc1_lifeData") || {};
const u = life.vuex_user || this.vuex_user || {};
if (this.isMobileMissing(u) && !this.isMobileMissingPromptShownToday()) {
this.base.toast("请先绑定或注册");
this.showRegister = true;
this.markMobileMissingPromptShownToday();
}
this.pendingMobileMissing = false;
}
},
async getBannerList() {
@ -575,4 +760,106 @@ export default {
transition: all 0.3s ease;
}
}
.profile-incomplete-popup {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 9998;
display: flex;
align-items: center;
justify-content: center;
}
.profile-incomplete-mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.45);
}
.profile-incomplete-dialog {
position: relative;
width: 620rpx;
padding: 56rpx 44rpx 46rpx;
background: #fff;
border-radius: 30rpx;
box-shadow: 0 8rpx 40rpx rgba(0, 0, 0, 0.12);
}
.profile-incomplete-text {
font-size: 32rpx;
color: #333;
line-height: 1.6;
text-align: center;
margin-bottom: 46rpx;
}
.profile-incomplete-btn {
width: 70%;
margin: 0 auto;
color: #fff;
text-align: center;
padding: 20rpx 0;
border-radius: 30rpx;
font-size: 30rpx;
background: linear-gradient(to right, #5e5fbc, #0d0398);
}
.modal {
::v-deep .u-drawer-bottom {
border-radius: 40rpx;
}
&-tip-wrap {
display: flex;
align-items: center;
justify-content: space-between;
padding: 30rpx;
}
&-tip {
font-size: 32rpx;
}
&-close {
color: #409eff;
font-size: 28rpx;
}
&-content {
height: 450rpx;
padding: 0 30rpx;
font-size: 32rpx;
text-align: center;
& > view {
margin: 30rpx auto;
}
}
&-bind {
width: 45%;
text-align: center;
margin: 0 auto;
color: #fff;
border-radius: 30rpx;
padding: 20rpx;
background: linear-gradient(to right, #e4cdb4, #c69c6d);
}
&-register {
width: 45%;
text-align: center;
margin: 0 auto;
color: #fff;
border-radius: 30rpx;
padding: 20rpx;
background: linear-gradient(to right, #5e5fbc, #0d0398);
}
}
</style>
Loading…
Cancel
Save