Merge branch 'main' into property-only-app

# Conflicts:
#	app/pages/users/login/index.vue
property-only-app
wx-jincw 2 weeks ago
commit 2608bb1245

@ -262,3 +262,32 @@ export function bindingWx(data) {
export function unbindWx(data) {
return request.post('unbindWx', data, { useAdminUrl: true });
}
// ===== 访客登记模块 =====
// 访客登记 - 新增
export function api_addVisit(data) {
return request.post(
'autogencode/dcvisitbook/save',
data,
{ useAdminUrl: true }
);
}
// 访客登记 - 记录列表
export function api_visitRecordList(params) {
return request.get(
'autogencode/dcvisitbook/list',
params,
{ useAdminUrl: true }
);
}
// 访客登记 - 详情/凭证信息
export function api_visitInfo(id) {
return request.get(
'autogencode/dcvisitbook/info/' + id,
{},
{ useAdminUrl: true }
);
}

@ -90,6 +90,15 @@ export function getUserPhone(data){
return request.post('wechat/register/binding/phone',data,{noAuth : true});
}
/**
* 小程序微信绑定已有账号账号+密码
* 关闭强制获取手机号时使用将微信 openId 关联到已有账号
* @param {Object} data { account, password, key }
*/
export function bindRoutineAccount(data) {
return request.post('wechat/register/binding/account', data, { noAuth: true });
}
/**
* APP微信登录
* @param {Object} data

@ -38,5 +38,12 @@ module.exports = {
// 缓存时间 0 永久
EXPIRE:0,
//分页最多显示条数
LIMIT: 10
LIMIT: 10,
/**
* 小程序微信登录新用户是否强制获取手机号
* true=开启弹出微信手机号授权 register/binding/phone
* false=关闭跳转账号密码页 register/binding/account 绑定已有账号
* 可被后端 wechat/getLogo 返回的 routineLoginRequirePhone 覆盖
*/
MP_WECHAT_REQUIRE_PHONE: false
};

@ -8,6 +8,47 @@ import auth from './wechat';
import { LOGIN_STATUS, USER_INFO, EXPIRES_TIME, STATE_R_KEY, BACK_URL} from './../config/cache';
const LOGIN_PAGE_ROUTE = 'pages/users/login/index';
const WECHAT_LOGIN_PAGE_ROUTE = 'pages/users/wechat_login/index';
function normalizeRoute(route) {
return (route || '').replace(/^\//, '');
}
function getPrevPageRoute() {
const pages = getCurrentPages();
if (pages.length < 2) {
return '';
}
return normalizeRoute(pages[pages.length - 2].route);
}
/**
* 登录页 微信登录页切换上一页已是目标页则返回避免反复 navigateTo 堆栈
*/
export function switchLoginPage(url) {
const targetRoute = normalizeRoute((url || '').split('?')[0].replace(/^\//, ''));
const prevRoute = getPrevPageRoute();
if (prevRoute && prevRoute === targetRoute && url.indexOf('?') === -1) {
uni.navigateBack();
return;
}
uni.navigateTo({ url });
}
/**
* 微信授权后进入账号绑定页replace 当前页避免栈里叠多层登录相关页面
*/
export function openLoginBindPage(authKey) {
const url = `/pages/users/login/index?bindWechat=1&authKey=${encodeURIComponent(authKey)}`;
const prevRoute = getPrevPageRoute();
if (prevRoute === LOGIN_PAGE_ROUTE) {
uni.redirectTo({ url });
return;
}
uni.redirectTo({ url });
}
function prePage(){
let pages = getCurrentPages();
let prePage = pages[pages.length - 1];
@ -39,45 +80,35 @@ export function _toLogin(push, pathLogin) {
Cache.set('login_back_url',path);
}
// // #ifdef H5
// if (isWeixin()) {
// let urlData = location.pathname + location.search
// if (urlData.indexOf('?') !== -1) {
// urlData += '&go_longin=1';
// } else {
// urlData += '?go_longin=1';
// }
// if (!Cache.has('snsapiKey')) {
// auth.oAuth('snsapi_base', urlData);
// } else {
// if (['/pages/user/index'].indexOf(login_back_url) == -1) {
// uni.navigateTo({
// url: '/pages/users/wechat_login/index'
// })
// }
// }
// } else {
// if (['/pages/user/index'].indexOf(login_back_url) == -1) {
// uni.navigateTo({
// url: '/pages/users/login/index'
// })
// }
// }
// // #endif
// if (['pages/user/index','/pages/user/index'].indexOf(login_back_url) == -1) {
// // #ifdef MP
// uni.navigateTo({
// url: '/pages/users/wechat_login/index'
// })
// // #endif
// }
if (['pages/user/index','/pages/user/index'].indexOf(login_back_url) == -1) {
// #ifdef H5
if (isWeixin()) {
let urlData = location.pathname + location.search
if (urlData.indexOf('?') !== -1) {
urlData += '&go_longin=1';
} else {
urlData += '?go_longin=1';
}
if (!Cache.has('snsapiKey')) {
auth.oAuth('snsapi_base', urlData);
} else {
uni.navigateTo({
url: '/pages/users/wechat_login/index'
})
}
} else {
uni.navigateTo({
url: '/pages/users/login/index'
})
}
// #endif
// #ifdef MP
uni.navigateTo({
url: '/pages/users/wechat_login/index'
})
// #endif
}
}

@ -2,8 +2,8 @@
"name" : "八方物业",
"appid" : "__UNI__B905528",
"description" : "八方物业",
"versionName" : "1.0.2",
"versionCode" : 1002,
"versionName" : "1.0.3",
"versionCode" : 1003,
"transformPx" : false,
/* 5+App */
"app-plus" : {

@ -372,6 +372,34 @@
"navigationStyle": "custom"
// #endif
}
},
{
"path": "visitor_register/index",
"style": {
"navigationBarTitleText": "访客登记",
"navigationStyle": "custom"
}
},
{
"path": "visitor_records/index",
"style": {
"navigationBarTitleText": "访问记录",
"navigationStyle": "custom"
}
},
{
"path": "visitor_user/index",
"style": {
"navigationBarTitleText": "访客个人中心",
"navigationStyle": "custom"
}
},
{
"path": "visitor_credential/index",
"style": {
"navigationBarTitleText": "访问凭证",
"navigationStyle": "custom"
}
}
]
},

@ -0,0 +1,97 @@
<template>
<view>
<view class="cus-header" :style="{ marginTop: safeTop + 'px' }">
<text class="title">{{ title }}</text>
<view class="header-buttons">
<view class="back-btn" @click="handleBack" v-if="showBack">
<text class="back-icon"></text>
</view>
<slot name="right"></slot>
</view>
</view>
<view :style="{ marginTop: safeTop + 'px', height: '40px' }"></view>
</view>
</template>
<script>
export default {
props: {
title: {
type: String,
default: ''
},
showBack: {
type: Boolean,
default: true
}
},
data() {
return {
safeTop: 30
};
},
mounted() {
const info = uni.getWindowInfo();
this.safeTop = Math.max(info.safeAreaInsets.top, 30);
},
methods: {
handleBack() {
this.$emit('back');
}
}
};
</script>
<style lang="scss" scoped>
.cus-header {
position: fixed;
top: 0;
left: 0;
right: 0;
display: flex;
flex-direction: column;
align-items: center;
z-index: 10;
}
.cus-header .title {
font-size: 52rpx;
font-weight: bold;
color: #fff;
margin-bottom: 16rpx;
text-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.2);
}
.header-buttons {
position: absolute;
top: 0;
left: 20rpx;
display: flex;
align-items: center;
gap: 20rpx;
}
.back-btn {
width: 80rpx;
height: 80rpx;
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
backdrop-filter: blur(10rpx);
box-shadow: 0 4rpx 15rpx rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
}
.back-btn:active {
transform: scale(0.9);
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.15);
}
.back-icon {
font-size: 40rpx;
color: #fff;
font-weight: bold;
}
</style>

@ -0,0 +1,274 @@
<template>
<view class="container">
<!-- 顶部装饰条 -->
<view class="top-decoration"></view>
<CustomHeader title="访问凭证" @back="handleBack" />
<view class="credential-card">
<text class="card-title">访客二维码</text>
<text class="card-subtitle">请向工作人员出示此二维码</text>
<view class="qr-code-container">
<image :src="qrCodeUrl" class="qr-code" mode="aspectFit" @click="previewQrCode"></image>
<text class="qr-tip">凭此码可快速通行</text>
</view>
<view class="visitor-info">
<view class="info-item">
<text class="info-label">访客姓名</text>
<text class="info-value">{{ visitorName }}</text>
</view>
<view class="info-item">
<text class="info-label">联系电话</text>
<text class="info-value">{{ visitorPhone }}</text>
</view>
<view class="info-item">
<text class="info-label">车牌号</text>
<text class="info-value">{{ visitorPlate }}</text>
</view>
</view>
<view class="validity-info">
<text class="validity-label">有效期限</text>
<text class="validity-value">{{ validityTime }}</text>
</view>
<view class="status-badge">
<text class="status-text">{{ credentialStatus }}</text>
</view>
</view>
<view class="tips">
<text class="tips-title">使用提示</text>
<view class="tips-list">
<text class="tip-item"> 请妥善保管您的访问凭证</text>
<text class="tip-item"> 凭证仅限本人使用不得转借</text>
<text class="tip-item"> 凭证过期后需重新申请</text>
<text class="tip-item"> 如有疑问请联系工作人员</text>
</view>
</view>
<!-- 底部装饰 -->
<view class="bottom-decoration"></view>
</view>
</template>
<script>
import CustomHeader from '../components/CustomHeader.vue';
export default {
components: { CustomHeader },
data() {
return {
openid: '',
qrCodeUrl: '',
visitorName: '访客用户',
visitorPhone: '138****1234',
visitorPlate: '京A12345',
validityTime: '2026-01-03 00:00 - 2026-01-04 23:59',
credentialStatus: '有效'
};
},
onLoad(options) {
this.openid = options.openid || '';
this.qrCodeUrl = 'https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=visitor_openid_' + this.openid;
},
mounted() {
// 访
setTimeout(() => {
this.visitorName = '访客_' + this.openid.slice(-4);
}, 500);
},
methods: {
handleBack() {
uni.navigateBack();
},
previewQrCode() {
if (!this.qrCodeUrl) return;
uni.previewImage({
urls: [this.qrCodeUrl],
current: this.qrCodeUrl
});
},
refreshQrCode() {
this.qrCodeUrl = 'https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=visitor_openid_' + this.openid + '_' + Date.now();
uni.showToast({ title: '二维码已刷新', icon: 'success' });
}
}
};
</script>
<style lang="scss" scoped>
.container {
min-height: 100vh;
background: linear-gradient(135deg, #3a5da6 0%, #4a72c2 100%);
padding: 20rpx;
position: relative;
overflow: hidden;
}
.top-decoration {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 10rpx;
background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
}
.credential-card {
background: rgba(255, 255, 255, 0.95);
border-radius: 24rpx;
padding: 50rpx;
box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.15);
backdrop-filter: blur(10rpx);
position: relative;
z-index: 1;
margin-bottom: 40rpx;
margin-top: 12rpx;
}
.card-title {
font-size: 44rpx;
font-weight: bold;
color: #333;
text-align: center;
margin-bottom: 12rpx;
}
.card-subtitle {
font-size: 28rpx;
color: #666;
text-align: center;
display: block;
margin-bottom: 50rpx;
}
.qr-code-container {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 50rpx;
}
.qr-code {
width: 300rpx;
height: 300rpx;
background-color: #fff;
padding: 20rpx;
border-radius: 16rpx;
box-shadow: 0 12rpx 30rpx rgba(0, 0, 0, 0.1);
margin-bottom: 20rpx;
}
.qr-tip {
font-size: 28rpx;
color: #3a5da6;
font-weight: 500;
}
.visitor-info {
background: rgba(58, 93, 166, 0.05);
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 30rpx;
}
.info-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15rpx 0;
border-bottom: 1rpx solid rgba(58, 93, 166, 0.1);
}
.info-item:last-child {
border-bottom: none;
}
.info-label {
font-size: 32rpx;
color: #666;
}
.info-value {
font-size: 32rpx;
color: #333;
font-weight: 500;
}
.validity-info {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 0;
margin-bottom: 30rpx;
}
.validity-label {
font-size: 32rpx;
color: #666;
}
.validity-value {
font-size: 32rpx;
color: #ff6b6b;
font-weight: 500;
}
.status-badge {
background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
border-radius: 50rpx;
padding: 15rpx 40rpx;
text-align: center;
margin: 0 auto;
width: fit-content;
}
.status-text {
color: #fff;
font-size: 32rpx;
font-weight: bold;
}
.tips {
background: rgba(255, 255, 255, 0.95);
border-radius: 24rpx;
padding: 40rpx;
box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.15);
backdrop-filter: blur(10rpx);
position: relative;
z-index: 1;
}
.tips-title {
font-size: 36rpx;
font-weight: bold;
color: #333;
margin-bottom: 20rpx;
display: block;
}
.tips-list {
display: flex;
flex-direction: column;
gap: 15rpx;
}
.tip-item {
font-size: 28rpx;
color: #666;
line-height: 44rpx;
}
.bottom-decoration {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 200rpx;
background: linear-gradient(180deg, transparent, rgba(42, 82, 152, 0.2));
opacity: 0.6;
}
</style>

@ -0,0 +1,299 @@
<template>
<view class="container">
<z-paging ref="paging" v-model="list" @query="queryList">
<template #top>
<!-- 自定义导航栏 -->
<CustomHeader title="访问记录" @back="handleBack" />
<!-- 顶部装饰条 -->
<view class="top-decoration"></view>
<!-- 搜索框 -->
<view class="search-wrapper">
<view class="search-input-wrapper">
<text class="search-icon">🔍</text>
<input
v-model="searchKeyword"
class="search-input"
placeholder="搜索访问记录..."
@input="handleSearch"
/>
</view>
</view>
</template>
<!-- 访问记录列表 -->
<view class="records-list">
<view
v-for="record in list"
:key="record.id"
class="record-item"
>
<view class="record-header">
<text class="record-date">{{ record.date }}</text>
<view class="record-status" :class="record.status">
<text class="status-text">{{ record.statusText }}</text>
</view>
</view>
<view class="record-content">
<view class="record-info">
<text class="info-label">车牌号:</text>
<text class="info-value">{{ record.plateNumber }}</text>
</view>
<view class="record-info">
<text class="info-label">来访事由:</text>
<text class="info-value">{{ record.reason }}</text>
</view>
<view class="record-info">
<text class="info-label">拜访对象:</text>
<text class="info-value">{{ record.visitPerson }}</text>
</view>
<view class="record-info">
<text class="info-label">登记时间:</text>
<text class="info-value">{{ record.registerTime }}</text>
</view>
<view class="record-info" v-if="record.entryTime">
<text class="info-label">入场时间:</text>
<text class="info-value">{{ record.entryTime }}</text>
</view>
<view class="record-info" v-if="record.exitTime">
<text class="info-label">出场时间:</text>
<text class="info-value">{{ record.exitTime }}</text>
</view>
</view>
</view>
<!-- 无记录提示 -->
<view v-if="list.length === 0" class="no-records">
<text class="no-records-text">暂无访问记录</text>
</view>
</view>
</z-paging>
</view>
</template>
<script>
import CustomHeader from '../components/CustomHeader.vue';
export default {
components: { CustomHeader },
data() {
return {
openid: '',
searchKeyword: '',
list: [],
//
records: [
{
id: 1,
date: '2024-06-15',
plateNumber: '粤B12345',
reason: '商务洽谈',
visitPerson: '张三',
registerTime: '10:30',
entryTime: '10:35',
exitTime: '12:45',
status: 'completed',
statusText: '已完成'
},
{
id: 2,
date: '2024-06-14',
plateNumber: '粤B12345',
reason: '技术支持',
visitPerson: '李四',
registerTime: '14:20',
entryTime: '14:25',
exitTime: null,
status: 'in-progress',
statusText: '进行中'
},
{
id: 3,
date: '2024-06-13',
plateNumber: '粤B12345',
reason: '会议讨论',
visitPerson: '王五',
registerTime: '09:15',
entryTime: '09:20',
exitTime: '11:30',
status: 'completed',
statusText: '已完成'
}
]
};
},
onLoad(options) {
this.openid = options.openid || '';
if (this.openid) {
console.log('获取到的openid:', this.openid);
}
},
methods: {
queryList(pageNo, pageSize) {
//
this.$refs.paging.complete(this.records);
},
handleSearch() {
console.log('搜索关键词:', this.searchKeyword);
},
handleBack() {
uni.navigateBack();
}
}
};
</script>
<style lang="scss" scoped>
.container {
min-height: 100vh;
background: linear-gradient(135deg, #3a5da6 0%, #4a72c2 100%);
padding: 20rpx;
position: relative;
overflow: hidden;
}
.top-decoration {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 10rpx;
background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
}
.search-wrapper {
margin: 30rpx;
}
.search-input-wrapper {
display: flex;
align-items: center;
background: #f8f9fa;
border-radius: 16rpx;
border: 2rpx solid transparent;
transition: all 0.3s ease;
}
.search-input-wrapper:focus-within {
border-color: #2a5298;
background: #fff;
box-shadow: 0 0 0 6rpx rgba(42, 82, 152, 0.1);
}
.search-icon {
width: 80rpx;
height: 92rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 40rpx;
color: #2a5298;
}
.search-input {
flex: 1;
height: 92rpx;
border: none;
background: transparent;
padding: 0 24rpx;
font-size: 32rpx;
color: #333;
box-sizing: border-box;
}
.search-input::placeholder {
color: #999;
}
.records-list {
padding: 0 30rpx;
}
.record-item {
background: #f8f9fa;
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 15rpx rgba(0, 0, 0, 0.08);
transition: all 0.3s ease;
}
.record-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
}
.record-date {
font-size: 30rpx;
font-weight: 600;
color: #333;
}
.record-status {
padding: 8rpx 20rpx;
border-radius: 20rpx;
font-size: 24rpx;
font-weight: 600;
}
.record-status.in-progress {
background: rgba(42, 82, 152, 0.2);
color: #2a5298;
}
.record-status.completed {
background: rgba(76, 205, 196, 0.2);
color: #27ae60;
}
.status-text {
font-size: 26rpx;
}
.record-content {
border-top: 2rpx solid #e9ecef;
padding-top: 20rpx;
}
.record-info {
display: flex;
margin-bottom: 16rpx;
align-items: flex-start;
}
.info-label {
width: 120rpx;
font-size: 28rpx;
font-weight: 600;
color: #666;
margin-right: 20rpx;
}
.info-value {
flex: 1;
font-size: 28rpx;
color: #333;
word-break: break-all;
}
.no-records {
text-align: center;
padding: 100rpx 0;
color: #999;
}
.no-records-text {
font-size: 32rpx;
}
.bottom-decoration {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 200rpx;
background: linear-gradient(180deg, transparent, rgba(42, 82, 152, 0.2));
opacity: 0.6;
}
</style>

@ -0,0 +1,185 @@
<template>
<view class="input-component">
<view v-if="label" class="label-wrapper">
<text class="label">{{ label }}</text>
<text v-if="required" class="required">*</text>
</view>
<view class="input-wrapper" :class="{ 'textarea-wrapper': textarea }">
<view v-if="icon" class="input-icon" :class="{ 'textarea-icon': textarea }">{{ icon }}</view>
<input
v-if="!textarea"
v-model="inputValue"
class="input"
:type="type"
:placeholder="placeholder"
:placeholder-class="'placeholder'"
@input="handleInput"
@focus="handleFocus"
@blur="handleBlur"
/>
<textarea
v-else
v-model="inputValue"
class="textarea"
:placeholder="placeholder"
:placeholder-class="'placeholder'"
:rows="rows"
@input="handleInput"
@focus="handleFocus"
@blur="handleBlur"
></textarea>
</view>
</view>
</template>
<script>
export default {
props: {
value: {
type: String,
default: ''
},
label: {
type: String,
default: ''
},
required: {
type: Boolean,
default: false
},
icon: {
type: String,
default: ''
},
textarea: {
type: Boolean,
default: false
},
type: {
type: String,
default: 'text'
},
placeholder: {
type: String,
default: ''
},
rows: {
type: Number,
default: 3
}
},
data() {
return {
inputValue: this.value
};
},
watch: {
value(newVal) {
if (newVal !== this.inputValue) {
this.inputValue = newVal;
}
}
},
methods: {
handleInput(event) {
this.$emit('input', this.inputValue);
},
handleFocus(event) {
this.$emit('focus', event);
},
handleBlur(event) {
this.$emit('blur', event);
}
}
};
</script>
<style lang="scss" scoped>
.input-component {
margin-bottom: 50rpx;
position: relative;
}
.label-wrapper {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.label {
font-size: 34rpx;
font-weight: 600;
color: #333;
}
.required {
color: #ff6b6b;
margin-left: 8rpx;
font-size: 36rpx;
}
.input-wrapper {
display: flex;
align-items: center;
background: #f8f9fa;
border-radius: 16rpx;
border: 2rpx solid transparent;
transition: all 0.3s ease;
}
.input-wrapper.textarea-wrapper {
align-items: flex-start;
}
.input-wrapper:focus-within {
border-color: #2a5298;
background: #fff;
box-shadow: 0 0 0 6rpx rgba(42, 82, 152, 0.1);
}
.input-icon {
width: 80rpx;
min-height: 92rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 40rpx;
color: #2a5298;
}
.input-icon.textarea-icon {
align-items: flex-start;
padding-top: 24rpx;
}
.input {
flex: 1;
height: 92rpx;
border: none;
background: transparent;
padding: 0 24rpx;
font-size: 32rpx;
color: #333;
box-sizing: border-box;
}
.input::placeholder {
color: #999;
}
.textarea {
flex: 1;
border: none;
background: transparent;
padding: 24rpx;
font-size: 32rpx;
color: #333;
box-sizing: border-box;
resize: none;
line-height: 1.6;
}
.textarea::placeholder {
color: #999;
}
</style>

@ -0,0 +1,514 @@
<template>
<view class="container">
<!-- 顶部装饰条 -->
<view class="top-decoration"></view>
<view class="header">
<image src="/static/logo.png" class="logo" mode="aspectFit"></image>
<text class="title">访客登记</text>
<text class="subtitle">请填写以下信息进行登记</text>
<view class="header-buttons">
<view class="user-center-btn" @click="handleGoHome">
<text class="user-icon">🏠</text>
<text class="user-text">首页</text>
</view>
<view class="user-center-btn" @click="handleUserCenter">
<text class="user-icon">👤</text>
<text class="user-text">我的</text>
</view>
</view>
</view>
<view class="form-card">
<!-- 访客姓名 -->
<VisitorInput
v-model="form.visitorName"
label="姓名"
required
icon="👤"
placeholder="请输入您的姓名"
/>
<!-- 访客手机号 -->
<VisitorInput
v-model="form.visitorPhone"
label="手机号"
required
icon="📱"
type="number"
placeholder="请输入您的手机号"
/>
<!-- 车牌号码 -->
<VisitorInput
v-model="form.licensePlateNumber"
label="车牌号码"
required
icon="🚙"
placeholder="请输入车牌号"
/>
<!-- 受访人所在部门 -->
<VisitorInput
v-model="form.memberOrg"
label="受访人所在部门"
required
icon="🏢"
placeholder="请输入受访人所在部门"
/>
<!-- 受访人姓名 -->
<VisitorInput
v-model="form.memberName"
label="被访人姓名"
required
icon="👥"
placeholder="请输入受访人姓名"
/>
<!-- 受访人手机号 -->
<VisitorInput
v-model="form.memberPhone"
label="被访人手机号"
required
icon="📱"
type="number"
placeholder="请输入受访人手机号"
/>
<!-- 来访事由 -->
<VisitorInput
v-model="form.reason"
label="来访事由"
required
icon="📝"
textarea
rows="2"
placeholder="请输入来访事由"
/>
<!-- 预约日期 -->
<view class="form-item">
<text class="form-label required">预约日期</text>
<picker mode="date" :value="form.visitDate" :start="minDate" :end="maxDate" @change="handleDateChange">
<view class="date-picker-btn">
<text>{{ form.visitDate || '请选择预约日期' }}</text>
</view>
</picker>
</view>
<!-- 预约时间区间 -->
<view class="form-item">
<text class="form-label required">选择区间</text>
<view class="time-range">
<picker mode="time" :value="form.startTime" @change="handleStartTimeChange">
<view class="date-picker-btn time-btn">
<text>{{ form.startTime || '开始时间' }}</text>
</view>
</picker>
<text class="time-separator"></text>
<picker mode="time" :value="form.endTime" @change="handleEndTimeChange">
<view class="date-picker-btn time-btn">
<text>{{ form.endTime || '结束时间' }}</text>
</view>
</picker>
</view>
</view>
<button class="submit-btn" @click="handleSubmit" :disabled="!isFormValid">
<text class="btn-text">提交登记</text>
</button>
<!-- 查看访问记录按钮 -->
<button class="records-btn" @click="handleViewRecords">
<text class="btn-text">查看访问记录</text>
</button>
</view>
<!-- 底部装饰 -->
<view class="bottom-decoration"></view>
</view>
</template>
<script>
import { api_addVisit } from '@/api/property.js';
import VisitorInput from './components/VisitorInput.vue';
export default {
components: { VisitorInput },
data() {
const today = new Date();
const minDate = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
return {
minDate,
maxDate: '2050-12-31',
form: {
visitorName: '',
visitorPhone: '',
memberName: '',
memberPhone: '',
memberOrg: '',
reason: '',
visitDate: '',
startTime: '',
endTime: '',
visitStartTime: null,
visitEndTime: null,
licensePlateNumber: '',
openId: ''
}
};
},
computed: {
isFormValid() {
return this.form.visitorName &&
/^1[3-9]\d{9}$/.test(this.form.visitorPhone) &&
this.form.memberName &&
/^1[3-9]\d{9}$/.test(this.form.memberPhone) &&
this.form.memberOrg &&
this.form.reason &&
this.form.visitStartTime &&
this.form.visitEndTime &&
this.form.visitStartTime < this.form.visitEndTime &&
this.form.licensePlateNumber;
}
},
methods: {
handleDateChange(e) {
this.form.visitDate = e.detail.value;
this.updateVisitTime();
},
handleStartTimeChange(e) {
this.form.startTime = e.detail.value;
this.updateVisitTime();
},
handleEndTimeChange(e) {
this.form.endTime = e.detail.value;
this.updateVisitTime();
},
updateVisitTime() {
if (!this.form.visitDate || !this.form.startTime || !this.form.endTime) return;
this.form.visitStartTime = `${this.form.visitDate} ${this.form.startTime}:00`;
this.form.visitEndTime = `${this.form.visitDate} ${this.form.endTime}:59`;
},
async getWechatAuth() {
try {
uni.showLoading({ title: '正在获取授权...' });
const { code } = await uni.login();
// code openId
this.form.openId = 'mock_open_id_' + Date.now();
uni.hideLoading();
return true;
} catch (error) {
uni.hideLoading();
uni.showToast({ title: '获取授权失败,请重试', icon: 'none' });
console.error('微信授权失败:', error);
return false;
}
},
async handleSubmit() {
const authSuccess = await this.getWechatAuth();
if (!authSuccess) return;
try {
uni.showLoading({ title: '正在提交...' });
await api_addVisit({ ...this.form });
uni.hideLoading();
uni.showToast({ title: '登记成功', icon: 'success' });
//
const openId = this.form.openId;
this.form = {
visitorName: '',
visitorPhone: '',
memberName: '',
memberPhone: '',
memberOrg: '',
reason: '',
visitDate: '',
startTime: '',
endTime: '',
visitStartTime: null,
visitEndTime: null,
licensePlateNumber: '',
openId
};
} catch (error) {
uni.hideLoading();
uni.showToast({ title: '提交失败,请重试', icon: 'none' });
console.error('提交失败:', error);
}
},
handleViewRecords() {
uni.navigateTo({
url: `/pages/supply_chain/visitor_records/index?openid=${this.form.openId}`
});
},
handleUserCenter() {
uni.navigateTo({
url: `/pages/supply_chain/visitor_user/index?openid=${this.form.openId}`
});
},
handleGoHome() {
uni.reLaunch({
url: '/pages/index/index'
});
}
}
};
</script>
<style lang="scss">
.container {
min-height: 100vh;
background: linear-gradient(135deg, #3a5da6 0%, #4a72c2 100%);
padding: 20rpx;
position: relative;
overflow: hidden;
}
.top-decoration {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 10rpx;
background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
}
.header {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 60rpx;
margin-bottom: 60rpx;
position: relative;
z-index: 1;
}
.header-buttons {
position: absolute;
bottom: 18rpx;
left: 20rpx;
right: 20rpx;
display: flex;
justify-content: space-between;
}
.user-center-btn {
width: 98rpx;
height: 98rpx;
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
backdrop-filter: blur(10rpx);
box-shadow: 0 4rpx 15rpx rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
}
.user-center-btn:active {
transform: scale(0.9);
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.15);
}
.user-icon {
font-size: 40rpx;
}
.user-text {
font-size: 24rpx;
font-weight: 300;
color: rgba(255, 255, 255, 0.6);
line-height: 24rpx;
}
.logo {
width: 180rpx;
height: 180rpx;
margin-bottom: 30rpx;
border-radius: 50%;
box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.15);
background-color: rgba(255, 255, 255, 0.9);
padding: 20rpx;
}
.title {
font-size: 52rpx;
font-weight: bold;
color: #fff;
margin-bottom: 16rpx;
text-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.2);
}
.subtitle {
font-size: 28rpx;
color: rgba(255, 255, 255, 0.9);
font-weight: 300;
}
.form-card {
background: rgba(255, 255, 255, 0.95);
border-radius: 24rpx;
padding: 50rpx;
box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.15);
backdrop-filter: blur(10rpx);
position: relative;
z-index: 1;
}
.form-item {
margin-bottom: 40rpx;
display: flex;
flex-direction: column;
}
.form-label {
font-size: 32rpx;
color: #333;
margin-bottom: 16rpx;
font-weight: 500;
}
.form-label.required::after {
content: '*';
color: #ff6b6b;
margin-left: 8rpx;
}
.date-picker-btn {
width: 100%;
height: 96rpx;
background-color: #f5f5f5;
border-radius: 16rpx;
display: flex;
align-items: center;
padding: 0 32rpx;
box-sizing: border-box;
font-size: 32rpx;
color: #666;
border: 2rpx solid #e0e0e0;
transition: all 0.3s ease;
}
.date-picker-btn:active {
background-color: #e0e0e0;
border-color: #ccc;
}
.time-range {
display: flex;
align-items: center;
gap: 16rpx;
}
.time-btn {
flex: 1;
}
.time-separator {
font-size: 28rpx;
color: #999;
}
.submit-btn {
width: 100%;
height: 104rpx;
background: linear-gradient(135deg, #3a5da6 0%, #4a72c2 100%);
color: #fff;
font-size: 38rpx;
font-weight: 600;
border-radius: 52rpx;
margin-top: 30rpx;
border: none;
box-shadow: 0 12rpx 30rpx rgba(42, 82, 152, 0.4);
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.submit-btn:active {
transform: translateY(4rpx);
box-shadow: 0 8rpx 20rpx rgba(102, 126, 234, 0.3);
}
.submit-btn:disabled {
background: linear-gradient(135deg, #c0c4cc 0%, #a0a0a0 100%);
box-shadow: 0 8rpx 20rpx rgba(192, 196, 204, 0.3);
transform: none;
}
.records-btn {
width: 100%;
height: 104rpx;
background: linear-gradient(135deg, #3a5da6 0%, #4a72c2 100%);
color: #fff;
font-size: 38rpx;
font-weight: 600;
border-radius: 52rpx;
margin-top: 30rpx;
border: 2rpx solid #3a5da6;
box-shadow: 0 6rpx 20rpx rgba(58, 93, 166, 0.2);
transition: all 0.3s ease;
}
.records-btn:active {
transform: translateY(4rpx);
box-shadow: 0 4rpx 15rpx rgba(42, 82, 152, 0.3);
}
.btn-text {
position: relative;
display: flex;
align-items: center;
justify-content: center;
z-index: 1;
color: #fff;
height: 104rpx;
}
.bottom-decoration {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 200rpx;
background: linear-gradient(180deg, transparent, rgba(42, 82, 152, 0.2));
opacity: 0.6;
}
.container::before {
content: '';
position: absolute;
top: 20%;
right: 10%;
width: 200rpx;
height: 200rpx;
background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
border-radius: 50%;
animation: float 6s ease-in-out infinite;
}
.container::after {
content: '';
position: absolute;
bottom: 30%;
left: 5%;
width: 150rpx;
height: 150rpx;
background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
border-radius: 50%;
animation: float 8s ease-in-out infinite reverse;
}
@keyframes float {
0%, 100% {
transform: translateY(0rpx) scale(1);
}
50% {
transform: translateY(-30rpx) scale(1.1);
}
}
</style>

@ -0,0 +1,212 @@
<template>
<view class="container">
<!-- 顶部装饰条 -->
<view class="top-decoration"></view>
<CustomHeader title="个人中心" @back="handleBack" />
<view class="user-info-card">
<view class="user-avatar">
<text class="avatar-icon">👤</text>
</view>
<text class="user-name">{{ userName }}</text>
<text class="wechat-status">
<text class="status-icon">{{ isWechatBound ? '✓' : '!' }}</text>
{{ isWechatBound ? '微信已绑定' : '微信未绑定' }}
</text>
</view>
<view class="menu-list">
<view class="menu-item" @click="handleVisitRecords">
<text class="menu-icon">📋</text>
<text class="menu-text">访问记录</text>
<text class="menu-arrow"></text>
</view>
<view class="menu-item" @click="handleAccessCredential">
<text class="menu-icon">🎫</text>
<text class="menu-text">访问凭证</text>
<text class="menu-arrow"></text>
</view>
<view class="menu-item" @click="handleWechatBind">
<text class="menu-icon">🔗</text>
<text class="menu-text">微信绑定</text>
<text class="menu-arrow"></text>
</view>
</view>
<!-- 底部装饰 -->
<view class="bottom-decoration"></view>
</view>
</template>
<script>
import CustomHeader from '../components/CustomHeader.vue';
export default {
components: { CustomHeader },
data() {
return {
openid: '',
userName: '访客用户',
isWechatBound: true
};
},
onLoad(options) {
this.openid = options.openid || '';
},
mounted() {
//
setTimeout(() => {
this.userName = '访客_' + this.openid.slice(-4);
}, 500);
},
methods: {
handleBack() {
uni.navigateBack();
},
handleVisitRecords() {
uni.navigateTo({
url: `/pages/supply_chain/visitor_records/index?openid=${this.openid}`
});
},
handleAccessCredential() {
uni.navigateTo({
url: `/pages/supply_chain/visitor_credential/index?openid=${this.openid}`
});
},
handleWechatBind() {
if (this.isWechatBound) {
uni.showToast({ title: '微信已绑定', icon: 'success' });
} else {
uni.showToast({ title: '微信绑定功能开发中', icon: 'none' });
}
}
}
};
</script>
<style lang="scss" scoped>
.container {
min-height: 100vh;
background: linear-gradient(135deg, #3a5da6 0%, #4a72c2 100%);
padding: 20rpx;
position: relative;
overflow: hidden;
}
.top-decoration {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 10rpx;
background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
}
.user-info-card {
background: rgba(255, 255, 255, 0.95);
border-radius: 24rpx;
padding: 50rpx;
box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.15);
backdrop-filter: blur(10rpx);
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 40rpx;
margin-top: 12rpx;
}
.user-avatar {
width: 160rpx;
height: 160rpx;
background: linear-gradient(135deg, #3a5da6 0%, #4a72c2 100%);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 30rpx;
box-shadow: 0 12rpx 30rpx rgba(58, 93, 166, 0.4);
}
.avatar-icon {
font-size: 80rpx;
}
.user-name {
font-size: 44rpx;
font-weight: bold;
color: #333;
margin-bottom: 16rpx;
}
.wechat-status {
font-size: 32rpx;
color: #666;
display: flex;
align-items: center;
gap: 10rpx;
}
.status-icon {
font-size: 32rpx;
color: #4caf50;
font-weight: bold;
}
.menu-list {
background: rgba(255, 255, 255, 0.95);
border-radius: 24rpx;
padding: 20rpx;
box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.15);
backdrop-filter: blur(10rpx);
position: relative;
z-index: 1;
}
.menu-item {
display: flex;
align-items: center;
padding: 40rpx 30rpx;
border-bottom: 1rpx solid rgba(58, 93, 166, 0.1);
transition: all 0.3s ease;
}
.menu-item:last-child {
border-bottom: none;
}
.menu-item:active {
background: rgba(58, 93, 166, 0.05);
border-radius: 16rpx;
}
.menu-icon {
font-size: 44rpx;
margin-right: 30rpx;
}
.menu-text {
flex: 1;
font-size: 36rpx;
color: #333;
}
.menu-arrow {
font-size: 32rpx;
color: #999;
}
.bottom-decoration {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 200rpx;
background: linear-gradient(180deg, transparent, rgba(42, 82, 152, 0.2));
opacity: 0.6;
}
</style>

@ -47,9 +47,12 @@
</div>
</div>
<div class="logon" @click="loginMobile" v-if="current !== 0"></div>
<div class="logon" @click="submit" v-if="current === 0"></div>
<div class="logon" @click="submit" v-if="current === 0">{{ bindWechatMode ? '' : '' }}</div>
<!-- #ifdef MP-WEIXIN -->
<!-- <div class="logon logon-wechat" v-if="current === 0" @click="goWechatLogin"></div> -->
<div class="logon logon-wechat" v-if="current === 0 && !bindWechatMode" @click="goWechatLogin"></div>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<div class="bind-wechat-tip" v-if="bindWechatMode">使</div>
<!-- #endif -->
<div class="tips">
<!-- <div v-if="current==0" @click="current = 1"></div> -->
@ -80,11 +83,14 @@
validatorDefaultCatch
} from "@/utils/dialog";
import {
getLogo, appAuth, appleLogin
getLogo, appAuth, appleLogin, bindRoutineAccount
} from "@/api/public";
import {
VUE_APP_API_URL
} from "@/utils";
import {
switchLoginPage
} from '@/libs/login';
// #ifdef MP-WEIXIN
import {
wxGZHAuth
@ -116,7 +122,10 @@
appleLoginStatus: false, //
appleUserInfo: null,
appleShow: false, // ios13
pendingGzhCode: '' //
pendingGzhCode: '', //
// wechat_login register
bindWechatMode: false,
wechatBindAuthKey: ''
};
},
watch:{
@ -132,7 +141,13 @@
this.getCode();
this.getLogoImage();
},
onLoad() {
onLoad(options) {
// #ifdef MP-WEIXIN
if (options.bindWechat === '1' && options.authKey) {
this.bindWechatMode = true;
this.wechatBindAuthKey = decodeURIComponent(options.authKey);
}
// #endif
let self = this
uni.getSystemInfo({
success: function(res) {
@ -445,6 +460,43 @@
if (!that.password) return that.$util.Tips({
title: '请填写密码'
});
// openId
// #ifdef MP-WEIXIN
if (that.bindWechatMode) {
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) {
return that.$util.Tips({
title: '请输入正确的手机号码'
});
}
if (!that.wechatBindAuthKey) {
return that.$util.Tips({
title: '微信授权已失效,请返回重新授权'
});
}
uni.showLoading({ title: '绑定中' });
bindRoutineAccount({
account: that.account,
password: that.password,
key: that.wechatBindAuthKey
}).then(res => {
uni.hideLoading();
that.wechatBindAuthKey = '';
that.bindWechatMode = false;
that.$store.commit('LOGIN', {
token: res.data.token
});
that.getUserInfo(res.data);
}).catch(e => {
uni.hideLoading();
that.$util.Tips({
title: e
});
});
return;
}
// #endif
const loginPayload = {
account: that.account,
password: that.password,
@ -471,9 +523,7 @@
});
},
goWechatLogin() {
uni.navigateTo({
url: "/pages/users/wechat_login/index"
});
switchLoginPage('/pages/users/wechat_login/index');
},
getUserInfo(data){
this.$store.commit("SETUID", data.uid);
@ -687,6 +737,15 @@
background-color: #07c160;
}
.bind-wechat-tip {
margin-top: 24rpx;
padding: 0 20rpx;
text-align: center;
font-size: 24rpx;
color: #999;
line-height: 1.6;
}
.tips {
margin: 30rpx;
text-align: center;

@ -23,7 +23,11 @@
<!-- #ifdef MP -->
<button hover-class="none" @tap="getUserProfile" class="bg-green btn1">微信登录</button>
<!-- #endif -->
<!-- <button hover-class="none" @click="isUp = true" class="btn2">手机号登录</button> -->
<!-- 关闭强制手机号时引导已有账号用户去绑定 -->
<!-- #ifdef MP -->
<button hover-class="none" v-if="!requirePhone" @click="goBindAccountLogin" class="btn2"></button>
<!-- #endif -->
<button hover-class="none" @click="goAccountLogin" class="btn2">账号密码登录</button>
</view>
</view>
<block v-if="isUp">
@ -59,6 +63,10 @@
} from '@/api/user.js'
import Routine from '@/libs/routine';
import wechat from "@/libs/wechat";
import {
switchLoginPage,
openLoginBindPage
} from '@/libs/login';
export default {
data() {
return {
@ -72,7 +80,11 @@
authKey: '',
options: '',
userInfo: {},
codeNum: 0
codeNum: 0,
// true=false=
requirePhone: false,
// key使
pendingBindAuthKey: ''
}
},
components: {
@ -80,9 +92,11 @@
routinePhone
},
onLoad(options) {
// getLogo().then(res => {
// this.logoUrl = res.data.logoUrl
// })
// #ifdef MP
// getLogo requirePhone
this.requirePhone = this.parseRequirePhoneFlag(this.$config.MP_WECHAT_REQUIRE_PHONE);
this.loadMpLoginConfig();
// #endif
let that = this
// #ifdef H5
document.body.addEventListener("focusout", () => {
@ -131,6 +145,60 @@
},
methods: {
// #ifdef MP
/**
* 是否强制获取微信手机号 "1" / true 为开启其余均为关闭
*/
parseRequirePhoneFlag(value) {
return value === true || value === 1 || String(value) === '1';
},
/**
* 拉取小程序微信登录配置是否强制获取手机号
* 后端 system_config.routine_login_require_phone1=开启0=关闭默认
* 未配置时使用 app/config/app.js 中的 MP_WECHAT_REQUIRE_PHONE
*/
loadMpLoginConfig() {
const localDefault = this.parseRequirePhoneFlag(this.$config.MP_WECHAT_REQUIRE_PHONE);
return getLogo().then(res => {
const cfg = (res && res.data) ? res.data : {};
if (cfg.logoUrl) {
this.logoUrl = cfg.logoUrl;
}
// routineLoginRequirePhone
if (cfg.routineLoginRequirePhone !== undefined && cfg.routineLoginRequirePhone !== null && cfg.routineLoginRequirePhone !== '') {
this.requirePhone = this.parseRequirePhoneFlag(cfg.routineLoginRequirePhone);
} else {
this.requirePhone = localDefault;
}
return this.requirePhone;
}).catch(() => {
this.requirePhone = localDefault;
return this.requirePhone;
});
},
/**
* 关闭强制手机号时跳转账号密码页进行微信绑定
* 若尚未微信授权提示先点微信登录
*/
goBindAccountLogin() {
if (!this.pendingBindAuthKey) {
return this.$util.Tips({
title: '请先点击上方「微信登录」完成授权'
});
}
openLoginBindPage(this.pendingBindAuthKey);
},
/**
* 新微信用户且关闭强制手机号跳转绑定页
*/
goWechatBindLogin(authKey) {
this.pendingBindAuthKey = authKey;
openLoginBindPage(authKey);
},
// #endif
goAccountLogin() {
switchLoginPage('/pages/users/login/index');
},
back() {
uni.navigateBack();
},
@ -224,19 +292,22 @@
uni.showLoading({
title: '正在登录中'
});
// requirePhone
self.loadMpLoginConfig().finally(() => {
Routine.getUserProfile()
.then(res => {
Routine.getCode()
.then(code => {
self.getWxUser(code, res);
})
.catch(res => {
.catch(() => {
uni.hideLoading();
});
})
.catch(res => {
.catch(() => {
uni.hideLoading();
});
});
},
getWxUser(code, res) {
@ -254,17 +325,24 @@
userInfo.type = 'routine'
Routine.authUserInfo(userInfo.code, userInfo)
.then(res => {
self.authKey = res.data.key;
if (res.data.type === 'register') {
const payload = (res && res.data) ? res.data : (res || {});
self.authKey = payload.key;
if (payload.type === 'register') {
uni.hideLoading();
self.isPhoneBox = true
self.isPhoneBox = false;
//
if (self.requirePhone) {
self.isPhoneBox = true;
} else {
self.goWechatBindLogin(payload.key);
}
if (res.data.type === 'login') {
}
if (payload.type === 'login') {
uni.hideLoading();
self.$store.commit('LOGIN', {
token: res.data.token
token: payload.token
});
self.$store.commit("SETUID", res.data.uid);
self.$store.commit("SETUID", payload.uid);
self.getUserInfo();
self.$util.Tips({
title: res,

@ -162,6 +162,8 @@ public class Constants {
public static final String CONFIG_KEY_FRONT_API_URL = "front_api_url"; //移动商城接口地址
public static final String CONFIG_KEY_SITE_LOGO = "mobile_top_logo"; //logo地址
public static final String CONFIG_KEY_MOBILE_LOGIN_LOGO = "mobile_login_logo"; // 移动端登录 logo
/** 小程序微信登录是否强制获取手机号1=开启0=关闭(默认,走账号密码绑定微信) */
public static final String CONFIG_KEY_ROUTINE_LOGIN_REQUIRE_PHONE = "routine_login_require_phone";
public static final String CONFIG_KEY_SITE_NAME = "site_name"; //网站名称
public static final String CONFIG_SITE_TENG_XUN_MAP_KEY = "tengxun_map_key"; //腾讯地图key
public static final String CONFIG_BANK_LIST = "user_extract_bank"; //可提现银行

@ -0,0 +1,40 @@
package com.zbkj.common.request;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.zbkj.common.constants.RegularConstants;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
/**
*
* openId
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "WxBindingAccountRequest", description = "小程序微信绑定已有账号请求对象")
public class WxBindingAccountRequest implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "账号(手机号)", required = true)
@NotBlank(message = "账号不能为空")
@Pattern(regexp = RegularConstants.PHONE_TWO, message = "请输入正确的手机号")
@JsonProperty("account")
private String account;
@ApiModelProperty(value = "密码", required = true)
@NotBlank(message = "密码不能为空")
private String password;
@ApiModelProperty(value = "微信授权 register 阶段返回的 key", required = true)
@NotBlank(message = "key不能为空")
private String key;
}

@ -3,6 +3,7 @@ package com.zbkj.front.controller;
import com.zbkj.common.model.wechat.TemplateMessage;
import com.zbkj.common.request.RegisterAppWxRequest;
import com.zbkj.common.request.RegisterThirdUserRequest;
import com.zbkj.common.request.WxBindingAccountRequest;
import com.zbkj.common.request.WxBindingPhoneRequest;
import com.zbkj.common.response.CommonResult;
import com.zbkj.common.response.LoginResponse;
@ -87,6 +88,16 @@ public class WeChatController {
return CommonResult.success(userCenterService.registerBindingPhone(request));
}
/**
* +
* routine_login_require_phone
*/
@ApiOperation(value = "小程序微信绑定已有账号")
@RequestMapping(value = "/register/binding/account", method = RequestMethod.POST)
public CommonResult<LoginResponse> registerBindingAccount(@RequestBody @Validated WxBindingAccountRequest request){
return CommonResult.success(userCenterService.registerBindingAccount(request));
}
/**
* js
*/
@ -105,6 +116,8 @@ public class WeChatController {
public CommonResult<Map<String, String>> getLogo(){
Map<String, String> map = new HashMap<>();
map.put("logoUrl", userCenterService.getLogo());
// 1=微信登录新用户强制获取手机号0=跳转账号密码绑定微信(默认)
map.put("routineLoginRequirePhone", userCenterService.getRoutineLoginRequirePhone());
return CommonResult.success(map);
}

@ -173,6 +173,19 @@ public interface UserCenterService extends IService<User> {
*/
LoginResponse registerBindingPhone(WxBindingPhoneRequest request);
/**
* +
* @param request
* @return
*/
LoginResponse registerBindingAccount(WxBindingAccountRequest request);
/**
*
* @return 1=0=
*/
String getRoutineLoginRequirePhone();
/**
*
* @param pageParamRequest

@ -489,6 +489,16 @@ public class UserCenterServiceImpl extends ServiceImpl<UserDao, User> implements
return systemConfigService.getValueByKey(Constants.CONFIG_KEY_MOBILE_LOGIN_LOGO);
}
/**
*
* routine_login_require_phone1=0=
*/
@Override
public String getRoutineLoginRequirePhone() {
String value = systemConfigService.getValueByKey(Constants.CONFIG_KEY_ROUTINE_LOGIN_REQUIRE_PHONE);
return StrUtil.isBlank(value) ? "0" : value;
}
/**
*
* @param code String code
@ -854,6 +864,79 @@ public class UserCenterServiceImpl extends ServiceImpl<UserDao, User> implements
return loginResponse;
}
/**
* +
*
*/
@Override
public LoginResponse registerBindingAccount(WxBindingAccountRequest request) {
Object cache = redisUtil.get(request.getKey());
if (ObjectUtil.isNull(cache)) {
throw new CrmebException("微信授权已过期,请重新点击微信登录");
}
RegisterThirdUserRequest registerThirdUserRequest = JSONObject.parseObject(cache.toString(), RegisterThirdUserRequest.class);
if (!Constants.USER_LOGIN_TYPE_PROGRAM.equals(registerThirdUserRequest.getType())) {
throw new CrmebException("仅支持小程序微信绑定");
}
User user = userService.getByPhone(request.getAccount());
if (ObjectUtil.isNull(user)) {
throw new CrmebException("此账号未注册");
}
if (!user.getStatus()) {
throw new CrmebException("此账号被禁用");
}
String encryptedPassword = CrmebUtil.encryptPassword(request.getPassword(), request.getAccount());
if (!user.getPwd().equals(encryptedPassword)) {
throw new CrmebException("密码错误");
}
UserToken boundByUser = userTokenService.getTokenByUserId(user.getUid(), Constants.THIRD_LOGIN_TOKEN_TYPE_PROGRAM);
if (ObjectUtil.isNotNull(boundByUser)) {
throw new CrmebException("该账号已绑定微信小程序");
}
UserToken boundByOpenId = userTokenService.getByOpenidAndType(
registerThirdUserRequest.getOpenId(), Constants.THIRD_LOGIN_TOKEN_TYPE_PROGRAM);
if (ObjectUtil.isNotNull(boundByOpenId)) {
throw new CrmebException("该微信已绑定其他账号");
}
User finalUser = user;
Boolean execute = transactionTemplate.execute(e -> {
userTokenService.bind(
registerThirdUserRequest.getOpenId(),
Constants.THIRD_LOGIN_TOKEN_TYPE_PROGRAM,
finalUser.getUid());
return Boolean.TRUE;
});
if (!execute) {
throw new CrmebException("绑定微信失败,请稍后重试");
}
if (ObjectUtil.isNotNull(registerThirdUserRequest.getSpreadPid()) && registerThirdUserRequest.getSpreadPid() > 0) {
loginService.bindSpread(user, registerThirdUserRequest.getSpreadPid());
}
user.setLastLoginTime(DateUtil.nowDateTime());
userService.updateById(user);
redisUtil.delete(request.getKey());
LoginResponse loginResponse = new LoginResponse();
try {
loginResponse.setToken(tokenComponent.createToken(user));
} catch (Exception e) {
logger.error(StrUtil.format("绑定微信账号后生成token失败uid={}", user.getUid()));
e.printStackTrace();
}
loginResponse.setType("login");
loginResponse.setUid(user.getUid());
loginResponse.setNikeName(user.getNickname());
loginResponse.setPhone(user.getPhone());
return loginResponse;
}
/**
*
* @param pageParamRequest

Loading…
Cancel
Save