注册,物流
This commit is contained in:
parent
7eebc286e4
commit
9224c8a09a
|
|
@ -104,6 +104,13 @@ namespace CoreCms.Net.IServices
|
|||
Task<WebApiCallBack> SmsLogin(FMWxAccountCreate entity,
|
||||
int loginType = (int) GlobalEnumVars.LoginType.WeChatPhoneNumber, int platform = 1);
|
||||
|
||||
/// <summary>
|
||||
/// 手机号密码登录
|
||||
/// </summary>
|
||||
/// <param name="entity">登录实体</param>
|
||||
/// <returns></returns>
|
||||
Task<WebApiCallBack> PasswordLogin(FMPasswordLogin entity);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询分页数据
|
||||
|
|
|
|||
|
|
@ -30,4 +30,20 @@ namespace CoreCms.Net.Model.FromBody
|
|||
public string password { get; set; }
|
||||
public string repassword { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手机号密码登录实体
|
||||
/// </summary>
|
||||
public class FMPasswordLogin
|
||||
{
|
||||
/// <summary>
|
||||
/// 手机号码
|
||||
/// </summary>
|
||||
public string mobile { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
public string password { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
|
|
@ -21,8 +22,11 @@ using CoreCms.Net.Model.Entities;
|
|||
using CoreCms.Net.Model.ViewModels.Api;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
|
||||
using Flurl.Http;
|
||||
|
||||
using Qiniu.Util;
|
||||
|
||||
|
||||
namespace CoreCms.Net.Services
|
||||
{
|
||||
|
|
@ -173,17 +177,23 @@ namespace CoreCms.Net.Services
|
|||
|
||||
|
||||
var allConfigs = await _settingServices.GetConfigDictionaries();
|
||||
var showApiAppid = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ShowApiAppid);
|
||||
var showApiSecret = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ShowApiSecret);
|
||||
|
||||
var showApiTimesTamp = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
var url = $"https://route.showapi.com/64-19?appKey={showApiSecret}";
|
||||
if (phone.Length > 4)
|
||||
{
|
||||
phone = phone.Substring(phone.Length - 4, 4);
|
||||
}
|
||||
// 构建POST请求参数
|
||||
var postData = new
|
||||
{
|
||||
com = "auto", // 固定值
|
||||
nu = number, // 订单号
|
||||
phone = phone // 手机尾号
|
||||
};
|
||||
|
||||
var signStr = "com" + com + "nu" + number + "phone" + phone + "showapi_appid" + showApiAppid + "showapi_timestamp" + showApiTimesTamp + showApiSecret;
|
||||
var md5Sign = CommonHelper.Md5For32(signStr).ToLower();
|
||||
var result = await url.PostUrlEncodedAsync(postData).ReceiveJson<ShowApiGetExpressPollResult>();
|
||||
|
||||
var url = "https://route.showapi.com/64-19?com=" + com + "&nu=" + number + "&phone=" + phone + "&showapi_appid=" + showApiAppid +
|
||||
"&showapi_timestamp=" + showApiTimesTamp + "&showapi_sign=" + md5Sign;
|
||||
var result = await url.GetJsonAsync<ShowApiGetExpressPollResult>();
|
||||
|
||||
if (result.showapi_res_code != 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -641,6 +641,90 @@ namespace CoreCms.Net.Services
|
|||
|
||||
#endregion
|
||||
|
||||
#region 手机号密码登录
|
||||
/// <summary>
|
||||
/// 手机号密码登录
|
||||
/// </summary>
|
||||
/// <param name="entity">登录实体</param>
|
||||
/// <returns></returns>
|
||||
public async Task<WebApiCallBack> PasswordLogin(FMPasswordLogin entity)
|
||||
{
|
||||
var jm = new WebApiCallBack();
|
||||
|
||||
if (string.IsNullOrEmpty(entity.mobile))
|
||||
{
|
||||
jm.msg = "请输入手机号码";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(entity.password))
|
||||
{
|
||||
jm.msg = "请输入密码";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (!CommonHelper.IsMobile(entity.mobile))
|
||||
{
|
||||
jm.msg = "请输入合法的手机号码";
|
||||
return jm;
|
||||
}
|
||||
|
||||
// 查询用户是否存在
|
||||
var userInfo = await _dal.QueryByClauseAsync(p => p.mobile == entity.mobile);
|
||||
if (userInfo == null)
|
||||
{
|
||||
jm.msg = "用户不存在";
|
||||
return jm;
|
||||
}
|
||||
|
||||
// 检查用户状态
|
||||
if (userInfo.status != (int)GlobalEnumVars.UserStatus.正常)
|
||||
{
|
||||
jm.msg = "用户账户已被禁用";
|
||||
return jm;
|
||||
}
|
||||
|
||||
// 检查用户是否设置了密码
|
||||
if (string.IsNullOrEmpty(userInfo.passWord))
|
||||
{
|
||||
jm.msg = "该账户未设置密码,请使用其他方式登录";
|
||||
return jm;
|
||||
}
|
||||
|
||||
// 验证密码
|
||||
var encryptedPassword = CommonHelper.EnPassword(entity.password, userInfo.createTime);
|
||||
if (userInfo.passWord != encryptedPassword)
|
||||
{
|
||||
jm.msg = "密码错误";
|
||||
return jm;
|
||||
}
|
||||
|
||||
// 登录成功,生成JWT Token
|
||||
var claims = new List<Claim> {
|
||||
new Claim(ClaimTypes.Name, userInfo.nickName),
|
||||
new Claim(JwtRegisteredClaimNames.Jti, userInfo.id.ToString()),
|
||||
new Claim(ClaimTypes.Expiration, DateTime.Now.AddSeconds(_permissionRequirement.Expiration.TotalSeconds).ToString()) };
|
||||
|
||||
//用户标识
|
||||
var identity = new ClaimsIdentity(JwtBearerDefaults.AuthenticationScheme);
|
||||
identity.AddClaims(claims);
|
||||
jm.status = true;
|
||||
jm.msg = "登录成功";
|
||||
jm.data = JwtToken.BuildJwtToken(claims.ToArray(), _permissionRequirement);
|
||||
|
||||
//录入登录日志
|
||||
var log = new CoreCmsUserLog();
|
||||
log.userId = userInfo.id;
|
||||
log.state = (int)GlobalEnumVars.UserLogTypes.登录;
|
||||
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ?
|
||||
_httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
|
||||
log.createTime = DateTime.Now;
|
||||
log.parameters = GlobalEnumVars.UserLogTypes.登录.ToString();
|
||||
await _userLogServices.InsertAsync(log);
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询分页数据
|
||||
|
|
|
|||
|
|
@ -222,6 +222,9 @@ const install = (Vue, vm) => {
|
|||
let syncWeChatInfo = (params = {}) => vm.$u.post('/Api/User/SyncWeChatInfo', params, { method: 'user.SyncWeChatInfo', needToken: true });
|
||||
//小程序手机授权(拉取手机号码)
|
||||
let loginByGetPhoneNumber = (params = {}) => vm.$u.post('/Api/User/DecryptPhoneNumber', params, { method: 'user.wxapploginByGetPhoneNumber', needToken: false });
|
||||
//账号密码登录
|
||||
let loginByPassword = (params = {}) => vm.$u.post('/Api/User/PasswordLogin', params, { method: 'user.wxapploginByPassword', needToken: false });
|
||||
|
||||
//取下级地址列表
|
||||
let getAreaList = (params = {}) => vm.$u.post('/Api/Common/GetAreas', params, { method: 'user.getarealist', needToken: false });
|
||||
//取搜索页推荐关键字
|
||||
|
|
@ -490,6 +493,7 @@ const install = (Vue, vm) => {
|
|||
loginByDecodeEncryptedData,
|
||||
syncWeChatInfo,
|
||||
loginByGetPhoneNumber,
|
||||
loginByPassword,
|
||||
getAreaList,
|
||||
getRecommendKeys,
|
||||
myInvite,
|
||||
|
|
|
|||
|
|
@ -10,20 +10,27 @@
|
|||
<u-image width="48rpx" height="48rpx" :src="shopLogo"></u-image>
|
||||
</view>
|
||||
<text class="shopName">
|
||||
{{shopName||'登录授权'}}
|
||||
</text>
|
||||
<text class="get">
|
||||
申请
|
||||
{{ shopName || '用户登录' }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="title3">获取以下权限为您提供服务</view>
|
||||
<view class="desc">
|
||||
1、获取你的手机号提供更好的账户安全,物流,订单状态提醒等服务(在接下来微信授权手机号的弹窗中选择“允许”)<br />
|
||||
2、使用我们的相关服务,需要将您的手机号授权给我们。
|
||||
<view class="title3">请输入您的账号密码</view>
|
||||
|
||||
<!-- 登录表单 -->
|
||||
<view class="login-form">
|
||||
<view class="form-item">
|
||||
<u-input v-model="loginForm.mobile" placeholder="请输入手机号" type="number" maxlength="11"
|
||||
:clearable="true" @input="onInputChange" />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<u-input v-model="loginForm.password" placeholder="请输入密码" type="password"
|
||||
:clearable="true" @input="onInputChange" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!--服务协议-->
|
||||
<view class="u-margin-top-30 u-margin-bottom-30 agreement-checked-view">
|
||||
<u-checkbox v-model="agreement" @change="checkboxChange" size="30" active-color="#19be6b"></u-checkbox>
|
||||
<u-checkbox v-model="agreement" @change="checkboxChange" size="30"
|
||||
active-color="#19be6b"></u-checkbox>
|
||||
<view class="coreshop-text-black-view">
|
||||
<text class="coreshop-text-black">同意</text>
|
||||
<text class="text-blue" @tap="goUserAgreementPage">《服务协议》</text>
|
||||
|
|
@ -33,9 +40,10 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-padding-left-30 u-padding-right-30">
|
||||
<u-button @click="closeAuth">暂不授权</u-button>
|
||||
<u-button type="success" :disabled="isDisabled" v-if="isDisabled">确定授权</u-button>
|
||||
<u-button type="success" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" v-else>确定授权</u-button>
|
||||
<u-button @click="closeAuth">取消</u-button>
|
||||
<u-button type="success" :disabled="isDisabled" @click="handleLogin"
|
||||
v-if="isDisabled">登录</u-button>
|
||||
<u-button type="success" @click="handleLogin" v-else>登录</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -44,239 +52,318 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* 登录提示页
|
||||
* @property {Boolean} value=showLoginTip - 由v-model控制显示隐藏。
|
||||
* @property {Boolean} forceOauth - 小程序端特制的全屏登录提示。
|
||||
*/
|
||||
import { mapMutations, mapActions, mapState } from 'vuex';
|
||||
import { goods, articles, commonUse, tools } from '@/common/mixins/mixinsHelper.js'
|
||||
export default {
|
||||
mixins: [goods, articles, commonUse, tools],
|
||||
name: 'coreshopLoginModal',
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
agreement: false,
|
||||
isDisabled: true,
|
||||
};
|
||||
/**
|
||||
* 登录提示页
|
||||
* @property {Boolean} value=showLoginTip - 由v-model控制显示隐藏。
|
||||
* @property {Boolean} forceOauth - 小程序端特制的全屏登录提示。
|
||||
*/
|
||||
import { mapMutations, mapActions, mapState } from 'vuex';
|
||||
import { goods, articles, commonUse, tools } from '@/common/mixins/mixinsHelper.js'
|
||||
export default {
|
||||
mixins: [goods, articles, commonUse, tools],
|
||||
name: 'coreshopLoginModal',
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
agreement: false,
|
||||
isDisabled: true,
|
||||
loginForm: {
|
||||
mobile: '',
|
||||
password: ''
|
||||
}
|
||||
};
|
||||
},
|
||||
props: {
|
||||
value: {},
|
||||
modalType: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
showLoginTip: state => state.showLoginTip,
|
||||
sessionAuthId: state => state.sessionAuthId,
|
||||
hasLogin: state => state.hasLogin,
|
||||
}),
|
||||
shopLogo() {
|
||||
return this.$store.state.config.shopLogo
|
||||
},
|
||||
props: {
|
||||
value: {},
|
||||
modalType: {
|
||||
type: String,
|
||||
default: ''
|
||||
shopName() {
|
||||
return this.$store.state.config.shopName;
|
||||
},
|
||||
showLogin: {
|
||||
get() {
|
||||
return this.showLoginTip;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit('showLoginTip', val);
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
showLoginTip: state => state.showLoginTip,
|
||||
sessionAuthId: state => state.sessionAuthId,
|
||||
hasLogin: state => state.hasLogin,
|
||||
}),
|
||||
shopLogo() {
|
||||
return this.$store.state.config.shopLogo
|
||||
sessionAuthIdTool: {
|
||||
get() {
|
||||
return this.sessionAuthId;
|
||||
},
|
||||
shopName() {
|
||||
return this.$store.state.config.shopName;
|
||||
},
|
||||
showLogin: {
|
||||
get() {
|
||||
return this.showLoginTip;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit('showLoginTip', val);
|
||||
}
|
||||
},
|
||||
sessionAuthIdTool: {
|
||||
get() {
|
||||
return this.sessionAuthId;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit('sessionAuthId', val);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
const _this = this
|
||||
// #ifdef MP-WEIXIN
|
||||
var userInfo = this.$store.state.userInfo;
|
||||
//var token = this.$db.get('userToken');
|
||||
if (Object.keys(userInfo).length != 0) {
|
||||
console.log("获取到store.state用户数据");
|
||||
} else {
|
||||
_this.doToken();
|
||||
}
|
||||
// #endif
|
||||
},
|
||||
//watch: {
|
||||
// 'hasLogin': {
|
||||
// handler(newVal) {
|
||||
// console.log(newVal);
|
||||
// if (newVal == false) {
|
||||
// console.log("watch监听");
|
||||
// this.doToken();
|
||||
// }
|
||||
// },
|
||||
// deep: true,
|
||||
// immediate: true,
|
||||
// }
|
||||
//},
|
||||
methods: {
|
||||
doToken() {
|
||||
const _this = this
|
||||
console.log("重新获取用户数据");
|
||||
_this.getCode(function (code) {
|
||||
var data = {
|
||||
code: code
|
||||
}
|
||||
_this.$u.api.onLogin(data).then(res => {
|
||||
if (res.status) {
|
||||
if (res.data.auth) {
|
||||
_this.$db.set('userToken', res.data.auth.token)
|
||||
_this.$store.commit('hasLogin', true);
|
||||
}
|
||||
if (res.data.user) {
|
||||
_this.$store.commit('userInfo', res.data.user);
|
||||
}
|
||||
_this.sessionAuthIdTool = res.otherData;
|
||||
console.log("成功后获取sessionAuthIdTool:" + _this.sessionAuthIdTool);
|
||||
} else {
|
||||
_this.sessionAuthIdTool = res.otherData;
|
||||
console.log("失败后获取sessionAuthIdTool:" + _this.sessionAuthIdTool);
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
// 勾选版权协议
|
||||
checkboxChange(e) {
|
||||
this.agreement = e.value;
|
||||
if (e.value == true) {
|
||||
this.isDisabled = false;
|
||||
} else {
|
||||
this.isDisabled = true;
|
||||
}
|
||||
console.log(this.agreement);
|
||||
},
|
||||
// 隐藏登录弹窗
|
||||
hideModal() {
|
||||
this.showLogin = false;
|
||||
},
|
||||
// 小程序,取消登录
|
||||
closeAuth() {
|
||||
this.showLogin = false;
|
||||
this.$u.toast('您已取消授权')
|
||||
},
|
||||
getCode: function (callback) {
|
||||
let _this = this
|
||||
uni.login({
|
||||
// #ifdef MP-ALIPAY
|
||||
scopes: 'auth_user',
|
||||
// #endif
|
||||
success: function (res) {
|
||||
console.log(res);
|
||||
if (res.code) {
|
||||
return callback(res.code)
|
||||
} else {
|
||||
//login成功,但是没有取到code
|
||||
_this.$refs.uToast.show({ title: '未取得code,请重试', type: 'error', })
|
||||
}
|
||||
},
|
||||
fail: function (res) {
|
||||
console.log(res);
|
||||
_this.$refs.uToast.show({ title: '用户授权失败wx.login,请重试', type: 'error', })
|
||||
}
|
||||
})
|
||||
},
|
||||
toLogin: function (data) {
|
||||
let _this = this
|
||||
_this.$u.api.loginByDecodeEncryptedData(data).then(res => {
|
||||
if (res.status) {
|
||||
//判断是否返回了token,如果没有,就说明没有绑定账号,跳转到绑定页面
|
||||
if (res.data.token) {
|
||||
//登陆成功,设置token,并返回上一页
|
||||
_this.$db.set('userToken', res.data.token)
|
||||
_this.$store.commit('hasLogin', true);
|
||||
_this.$refs.uToast.show({ title: '登录成功', type: 'success', })
|
||||
return false
|
||||
} else {
|
||||
_this.sessionAuthIdTool = res.data.sessionAuthId;
|
||||
}
|
||||
} else {
|
||||
_this.$refs.uToast.show({ title: '登录失败,请重试', type: 'error', })
|
||||
}
|
||||
})
|
||||
},
|
||||
async getPhoneNumber(e) {
|
||||
let _this = this;
|
||||
if (e.mp.detail.errMsg == 'getPhoneNumber:ok') {
|
||||
var data = {
|
||||
sessionAuthId: _this.sessionAuthIdTool,
|
||||
iv: e.mp.detail.iv,
|
||||
encryptedData: e.mp.detail.encryptedData,
|
||||
}
|
||||
//有推荐码的话,带上
|
||||
var invitecode = _this.$db.get('invitecode')
|
||||
if (invitecode) {
|
||||
data.invitecode = invitecode
|
||||
}
|
||||
_this.toGetPhoneNumber(data);
|
||||
}
|
||||
else if (e.mp.detail.errMsg == 'getPhoneNumber:fail user deny') {
|
||||
_this.$u.toast('您已经取消了授权,将无法进行关键业务功能。');
|
||||
}
|
||||
else {
|
||||
_this.$u.toast('如未授权,您可尝试使用手机号+短信验证码登录');
|
||||
}
|
||||
_this.agreement = false;
|
||||
_this.isDisabled = true;
|
||||
_this.showLogin = false;
|
||||
},
|
||||
//实际的去登陆
|
||||
toGetPhoneNumber: function (data) {
|
||||
let _this = this
|
||||
_this.$u.api.loginByGetPhoneNumber(data).then(res => {
|
||||
console.log(res);
|
||||
if (res.status) {
|
||||
//判断是否返回了token,如果没有,就说明没有绑定账号,跳转到绑定页面
|
||||
if (res.data.token) {
|
||||
//console.log("登陆成功,设置token,并返回上一页");
|
||||
//登陆成功,设置token,并返回上一页
|
||||
_this.$db.set('userToken', res.data.token)
|
||||
_this.$store.commit('hasLogin', true);
|
||||
_this.showLogin = false;
|
||||
_this.$refs.uToast.show({ title: '登录成功', type: 'success', })
|
||||
return false
|
||||
}
|
||||
} else if (res.status == false && res.code == 500) {
|
||||
console.log("sessionId不正确,重载");
|
||||
_this.$u.route({ type: 'switchTab', url: '/pages/index/default/default' });
|
||||
} else {
|
||||
_this.$u.toast('登录失败,请重试')
|
||||
}
|
||||
})
|
||||
set(val) {
|
||||
this.$store.commit('sessionAuthId', val);
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
// 初始化时清空表单
|
||||
this.loginForm = {
|
||||
mobile: '',
|
||||
password: ''
|
||||
};
|
||||
},
|
||||
//watch: {
|
||||
// 'hasLogin': {
|
||||
// handler(newVal) {
|
||||
// console.log(newVal);
|
||||
// if (newVal == false) {
|
||||
// console.log("watch监听");
|
||||
// this.doToken();
|
||||
// }
|
||||
// },
|
||||
// deep: true,
|
||||
// immediate: true,
|
||||
// }
|
||||
//},
|
||||
methods: {
|
||||
doToken() {
|
||||
const _this = this
|
||||
console.log("重新获取用户数据");
|
||||
_this.getCode(function (code) {
|
||||
var data = {
|
||||
code: code
|
||||
}
|
||||
_this.$u.api.onLogin(data).then(res => {
|
||||
if (res.status) {
|
||||
if (res.data.auth) {
|
||||
_this.$db.set('userToken', res.data.auth.token)
|
||||
_this.$store.commit('hasLogin', true);
|
||||
}
|
||||
if (res.data.user) {
|
||||
_this.$store.commit('userInfo', res.data.user);
|
||||
}
|
||||
_this.sessionAuthIdTool = res.otherData;
|
||||
console.log("成功后获取sessionAuthIdTool:" + _this.sessionAuthIdTool);
|
||||
} else {
|
||||
_this.sessionAuthIdTool = res.otherData;
|
||||
console.log("失败后获取sessionAuthIdTool:" + _this.sessionAuthIdTool);
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
// 勾选版权协议
|
||||
checkboxChange(e) {
|
||||
this.agreement = e.value;
|
||||
this.checkFormValid();
|
||||
},
|
||||
|
||||
// 输入框内容变化时触发
|
||||
onInputChange() {
|
||||
this.checkFormValid();
|
||||
},
|
||||
|
||||
// 检查表单是否有效
|
||||
checkFormValid() {
|
||||
const isValid = this.agreement &&
|
||||
this.loginForm.mobile.length === 11 &&
|
||||
this.loginForm.password.length >= 6;
|
||||
this.isDisabled = !isValid;
|
||||
return isValid;
|
||||
},
|
||||
// 隐藏登录弹窗
|
||||
hideModal() {
|
||||
this.showLogin = false;
|
||||
},
|
||||
// 取消登录
|
||||
closeAuth() {
|
||||
this.showLogin = false;
|
||||
this.resetForm();
|
||||
},
|
||||
|
||||
// 重置表单
|
||||
resetForm() {
|
||||
this.loginForm = {
|
||||
mobile: '',
|
||||
password: ''
|
||||
};
|
||||
this.agreement = false;
|
||||
this.isDisabled = true;
|
||||
},
|
||||
|
||||
// 处理登录
|
||||
handleLogin() {
|
||||
if (!this.checkFormValid()) {
|
||||
this.$u.toast('请完善登录信息');
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证手机号格式
|
||||
const mobileReg = /^1[3-9]\d{9}$/;
|
||||
if (!mobileReg.test(this.loginForm.mobile)) {
|
||||
this.$u.toast('请输入正确的手机号');
|
||||
return;
|
||||
}
|
||||
|
||||
this.doPasswordLogin();
|
||||
},
|
||||
// 密码登录
|
||||
doPasswordLogin() {
|
||||
const _this = this;
|
||||
const data = {
|
||||
mobile: this.loginForm.mobile,
|
||||
password: this.loginForm.password
|
||||
};
|
||||
|
||||
// // 显示加载状态
|
||||
// this.$u.loading.show({
|
||||
// title: '登录中...'
|
||||
// });
|
||||
|
||||
this.$u.api.loginByPassword(data).then(res => {
|
||||
// this.$u.loading.hide();
|
||||
console.log('登录结果:', res);
|
||||
|
||||
if (res.status) {
|
||||
if (res.data && res.data.token) {
|
||||
// 登录成功,保存token和用户信息
|
||||
_this.$db.set('userToken', res.data.token);
|
||||
_this.$store.commit('hasLogin', true);
|
||||
|
||||
if (res.data.user) {
|
||||
_this.$store.commit('userInfo', res.data.user);
|
||||
}
|
||||
|
||||
_this.showLogin = false;
|
||||
_this.resetForm();
|
||||
_this.$refs.uToast.show({
|
||||
title: '登录成功',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
_this.$u.toast('登录失败,请检查账号密码');
|
||||
}
|
||||
} else {
|
||||
_this.$u.toast(res.msg || '登录失败,请重试');
|
||||
}
|
||||
}).catch(err => {
|
||||
this.$u.loading.hide();
|
||||
console.error('登录错误:', err);
|
||||
_this.$u.toast('网络错误,请重试');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.modal-box { width: 610rpx; border-radius: 20rpx; background: #fff; position: relative; left: 50%; transform: translateX(-50%); padding: 30rpx; z-index: 11111;
|
||||
.head-bg { width: 100%; height: 210rpx; }
|
||||
.detail { width: 100%; text-align: center;
|
||||
.title1 { color: #46351b; font-size: 35rpx; font-weight: bold; }
|
||||
.title2 { font-size: 28rpx; color: #999; padding-top: 20rpx; }
|
||||
.title3 { color: #46351b; font-size: 35rpx; font-weight: bold; text-align: left; line-height: 35rpx; padding: 30rpx 0 30rpx 30rpx; }
|
||||
.desc { font-size: 24rpx; line-height: 40rpx; color: #333; background: #f7f8fa; text-align: left; padding: 20rpx; }
|
||||
.user-avatar { width: 160rpx; height: 160rpx; overflow: hidden; margin: 0 auto; margin-bottom: 40rpx; }
|
||||
.user-name { font-size: 35rpx; font-family: PingFang SC; font-weight: bold; color: #845708; margin-bottom: 30rpx; }
|
||||
.modal-box {
|
||||
width: 610rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #fff;
|
||||
position: relative;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
padding: 30rpx;
|
||||
z-index: 11111;
|
||||
|
||||
.head-bg {
|
||||
width: 100%;
|
||||
height: 210rpx;
|
||||
}
|
||||
|
||||
.detail {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
|
||||
.title1 {
|
||||
color: #46351b;
|
||||
font-size: 35rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.title2 {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.title3 {
|
||||
color: #46351b;
|
||||
font-size: 35rpx;
|
||||
font-weight: bold;
|
||||
text-align: left;
|
||||
line-height: 35rpx;
|
||||
padding: 30rpx 0 30rpx 30rpx;
|
||||
}
|
||||
|
||||
.desc {
|
||||
font-size: 24rpx;
|
||||
line-height: 40rpx;
|
||||
color: #333;
|
||||
background: #f7f8fa;
|
||||
text-align: left;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.user-avatar {
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
overflow: hidden;
|
||||
margin: 0 auto;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.user-name {
|
||||
font-size: 35rpx;
|
||||
font-family: PingFang SC;
|
||||
font-weight: bold;
|
||||
color: #845708;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
}
|
||||
.shopDesc { padding: 30rpx 0rpx 0rpx 0rpx; text-align: left;
|
||||
.shopName { margin-left: 20rpx; line-height: 40rpx; }
|
||||
.get { margin-left: 20rpx; line-height: 40rpx; }
|
||||
}
|
||||
|
||||
.shopDesc {
|
||||
padding: 30rpx 0rpx 0rpx 0rpx;
|
||||
text-align: left;
|
||||
|
||||
.shopName {
|
||||
margin-left: 20rpx;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
.agreement-checked-view { position: relative; padding: 18.18rpx 0rpx 18.18rpx 30rpx; display: flex; align-items: center; margin: 10rpx 0; font-size: 24rpx;
|
||||
.coreshop-checked { transform: scale(0.7); }
|
||||
|
||||
.get {
|
||||
margin-left: 20rpx;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.agreement-checked-view {
|
||||
position: relative;
|
||||
padding: 18.18rpx 0rpx 18.18rpx 30rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin: 10rpx 0;
|
||||
font-size: 24rpx;
|
||||
|
||||
.coreshop-checked {
|
||||
transform: scale(0.7);
|
||||
}
|
||||
}
|
||||
|
||||
.login-form {
|
||||
padding: 20rpx 30rpx;
|
||||
|
||||
.form-item {
|
||||
margin-bottom: 30rpx;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using NPOI.HSSF.UserModel;
|
||||
using SqlSugar;
|
||||
|
||||
using static SKIT.FlurlHttpClient.Wechat.Api.Models.WeDataQueryBindListResponse.Types;
|
||||
|
||||
namespace CoreCms.Net.Web.Admin.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -410,7 +412,8 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
|||
|
||||
//事物处理过程开始
|
||||
|
||||
if (!string.IsNullOrEmpty(entity.passWord)) oldModel.passWord = CommonHelper.Md5For32(entity.passWord);
|
||||
if (!string.IsNullOrEmpty(entity.passWord)) oldModel.passWord = CommonHelper.EnPassword(entity.passWord, oldModel.createTime);
|
||||
//CommonHelper.Md5For32(entity.passWord);
|
||||
oldModel.mobile = entity.mobile;
|
||||
oldModel.sex = entity.sex;
|
||||
oldModel.birthday = entity.birthday;
|
||||
|
|
@ -423,7 +426,6 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
|||
var bl = await _coreCmsUserServices.UpdateAsync(oldModel);
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
dbProvider="Microsoft.Data.SqlClient.SqlConnection, Microsoft.Data.SqlClient"
|
||||
connectionString="Server=127.0.0.1;Database=BaseMIS;User ID=sa;Password=123456"
|
||||
-->
|
||||
<target name="log_database" xsi:type="Database" dbProvider="Microsoft.Data.SqlClient.SqlConnection, Microsoft.Data.SqlClient" connectionString="Server=192.168.195.8;uid=sa;pwd=Dbt@com@123;Database=CoreShop;MultipleActiveResultSets=true;pooling=true;min pool size=5;max pool size=32767;connect timeout=20;Encrypt=True;TrustServerCertificate=True;">
|
||||
<target name="log_database" xsi:type="Database" dbProvider="Microsoft.Data.SqlClient.SqlConnection, Microsoft.Data.SqlClient" connectionString="Server=192.168.195.8;uid=sa;pwd=Dbt@com@123;Database=Shop;MultipleActiveResultSets=true;pooling=true;min pool size=5;max pool size=32767;connect timeout=20;Encrypt=True;TrustServerCertificate=True;">
|
||||
<commandText>
|
||||
INSERT INTO SysNLogRecords
|
||||
(LogDate,LogLevel,LogType,LogTitle,Logger,Message,MachineName,MachineIp,NetRequestMethod
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"ConnectionStrings": {
|
||||
"DbType": "SqlServer", //数据库将支持两种模式【SqlServer,MySql】
|
||||
"SqlConnection": "Server=192.168.195.8;uid=sa;pwd=Dbt@com@123;Database=CoreShop;MultipleActiveResultSets=true;pooling=true;min pool size=5;max pool size=32767;connect timeout=20;Encrypt=True;TrustServerCertificate=True;"
|
||||
"SqlConnection": "Server=192.168.195.8;uid=sa;pwd=Dbt@com@123;Database=Shop;MultipleActiveResultSets=true;pooling=true;min pool size=5;max pool size=32767;connect timeout=20;Encrypt=True;TrustServerCertificate=True;"
|
||||
//SqlServer数据库连接字符串,需要开启数据库连接复用【MultipleActiveResultSets=true】
|
||||
|
||||
// 如果采用容器化部署Service 要写成mysql的服务名,否则写地址
|
||||
|
|
|
|||
|
|
@ -431,6 +431,40 @@ namespace CoreCms.Net.Web.WebApi.Controllers
|
|||
|
||||
#endregion
|
||||
|
||||
#region 手机号密码登录===================================================================
|
||||
/// <summary>
|
||||
/// 手机号密码登录
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<WebApiCallBack> PasswordLogin([FromBody] FMPasswordLogin entity)
|
||||
{
|
||||
var jm = new WebApiCallBack();
|
||||
|
||||
if (string.IsNullOrEmpty(entity.mobile))
|
||||
{
|
||||
jm.msg = "请输入手机号码";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(entity.password))
|
||||
{
|
||||
jm.msg = "请输入密码";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (!CommonHelper.IsMobile(entity.mobile))
|
||||
{
|
||||
jm.msg = "请输入合法的手机号码";
|
||||
return jm;
|
||||
}
|
||||
|
||||
jm = await _userServices.PasswordLogin(entity);
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 用户短信注册并返回jwt token(弃用)======================================================
|
||||
/// <summary>
|
||||
/// 用户短信注册并返回jwt token(弃用)
|
||||
|
|
|
|||
|
|
@ -897,6 +897,13 @@
|
|||
<param name="entity"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:CoreCms.Net.Web.WebApi.Controllers.UserController.PasswordLogin(CoreCms.Net.Model.FromBody.FMPasswordLogin)">
|
||||
<summary>
|
||||
手机号密码登录
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:CoreCms.Net.Web.WebApi.Controllers.UserController.SmsLogin2(CoreCms.Net.Model.FromBody.FMWxAccountCreate)">
|
||||
<summary>
|
||||
用户短信注册并返回jwt token(弃用)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user