Merge remote-tracking branch 'origin/master'

This commit is contained in:
cun-nan 2023-11-30 11:57:53 +08:00
commit 41cabe23d1
18 changed files with 521 additions and 160 deletions
fuintAdmin/src/views/EventMarketing/activeRecommend
fuintBackend
configure/dev
fuint-application/src/main/java/com/fuint
common/service/impl
module/clientApi/controller
gasStation-uni
.hbuilderx
pages.json
pagesHome
Activity
PointsMing
activeIn
pagesLogin/login
store
unpackage/dist/dev/.sourcemap/mp-weixin/pagesMy

View File

@ -709,6 +709,7 @@ export default {
this.pddhidlist.push(row.id)
console.log(row)
let data ={
giftUserType:0,//
activeGift: 2, // 01 2. 3 4.
goodsIds: "", //id
goodsName:"" , //
@ -908,6 +909,7 @@ export default {
console.log(this.ruleForm.activeRecommendChildList)
console.log(this.ruleForm)
this.ruleForm.id = 1
this.$refs["ruleForm"].validate(valid => {
if (valid) {
if (this.ruleForm.id != null) {

View File

@ -87,8 +87,8 @@ weixin.official.appId=wxf4327ef05c27a0
weixin.official.appSecret=1f55e8749332234d9a074873d8e6a3
# 小程序配置
wxpay.appId = wxb6af3741234162bc
wxpay.appSecret = 76a538bfa5b55a4564d5f2be5540
wxpay.appId = wxba517a9bac38fe92
wxpay.appSecret = 8bfcce86abc4e2a461ecc781a09249a5
wxpay.mchId=1636980812
wxpay.apiV2=34354320201030y323e432342343
wxpay.certPath=/usr/local/fuint/cert/apiclient_cert.p12

View File

@ -13,8 +13,10 @@ import com.fuint.business.userManager.entity.MtInvitation;
import com.fuint.business.userManager.entity.UserBalance;
import com.fuint.business.userManager.mapper.MtInvitationMapper;
import com.fuint.business.userManager.mapper.UserBalanceMapper;
import com.fuint.business.userManager.service.LJUserService;
import com.fuint.business.userManager.service.MtInvitationService;
import com.fuint.business.userManager.service.UserBalanceService;
import com.fuint.business.userManager.vo.LJUserVo;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.dto.MemberTopDto;
import com.fuint.common.dto.UserDto;
@ -725,14 +727,15 @@ public class MemberServiceImpl extends ServiceImpl<MtUserMapper, MtUser> impleme
@Resource
private UserBalanceService userBalanceService;
@Autowired
@Resource
private ILJStoreService iljStoreService;
@Resource
LJUserService ljUserService;
@Override
public MtUser queryMemberByOpenId2(String openId, JSONObject userInfo) throws BusinessCheckException {
// merchantId 可以不需要
MtUser user = mtUserMapper.queryMemberByOpenId2(openId);
// MtUser user = mtUserMapper.queryMemberByOpenId2(openId);
String avatar = Optional.ofNullable(userInfo.getString("avatarUrl")).orElse("");
String gender = StringUtil.isNotEmpty(userInfo.getString("gender")) ? userInfo.getString("gender") : GenderEnum.MAN.getKey().toString();
@ -747,130 +750,249 @@ public class MemberServiceImpl extends ServiceImpl<MtUserMapper, MtUser> impleme
String source = StringUtil.isNotEmpty(userInfo.getString("source")) ? userInfo.getString("source") : MemberSourceEnum.WECHAT_LOGIN.getKey();
// openid没有时使用手机号
if (user == null) {
// 根绝手机号查询是否有该用户 没有则新建 有就更新
if (ObjectUtil.isNotEmpty(mobile) || "".equals(mobile)) {
MtUser mtUserMobile = queryMemberByMobile2(mobile);
MtUser mtUser = new MtUser();
if (StringUtil.isNotEmpty(mobile)) {
MtUser mtUserMobile = queryMemberByMobile2(mobile);
if (mtUserMobile != null) {
mtUser = mtUserMobile;
if (ObjectUtil.isEmpty(mtUserMobile)) {
// 新增
// LJUserVo userVo = new LJUserVo();
mtUser.setOpenId(openId);
mtUser.setMobile(mobile);
mtUser.setCreateTime(new Date());
mtUser.setUpdateTime(new Date());
mtUser.setDescription("微信登录自动注册");
mtUser.setStatus("qy");
mtUser.setSex(Integer.parseInt(gender));
mtUser.setUserNo(editUserNo());
// 微信用户 12 0未知
if (gender.equals(GenderEnum.FEMALE.getKey().toString())) {
gender = GenderEnum.UNKNOWN.getKey().toString();
} else if (gender.equals(GenderEnum.UNKNOWN.getKey().toString())) {
gender = GenderEnum.FEMALE.getKey().toString();
}
}
// 昵称为空用手机号
if (StringUtil.isEmpty(nickName) && StringUtil.isNotEmpty(mobile)) {
nickName = mobile.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2");
}
String userNo = CommonUtil.createUserNo();
mobile = CommonUtil.replaceXSS(mobile);
avatar = CommonUtil.replaceXSS(avatar);
nickName = CommonUtil.replaceXSS(nickName);
mtUser.setUserNo(userNo);
mtUser.setMobile(mobile);
mtUser.setAvatar(avatar);
mtUser.setName(nickName);
mtUser.setOpenId(openId);
// MtUserGrade grade = userGradeService.getInitUserGrade(merchantId);
// if (grade != null) {
// mtUser.setGradeId(grade.getId() + "");
// }
Date time = new Date();
mtUser.setCreateTime(time);
mtUser.setUpdateTime(time);
mtUser.setBalance(new BigDecimal(0));
mtUser.setPoint(0);
mtUser.setDescription("微信登录自动注册");
mtUser.setIdcard("");
mtUser.setStatus("qy");
mtUser.setAddress(country + province + city);
// 微信用户 12 0未知
if (gender.equals(GenderEnum.FEMALE.getKey().toString())) {
gender = GenderEnum.UNKNOWN.getKey().toString();
} else if (gender.equals(GenderEnum.UNKNOWN.getKey().toString())) {
gender = GenderEnum.FEMALE.getKey().toString();
}
mtUser.setSex(Integer.parseInt(gender));
if (StringUtil.isNotEmpty(storeId)) {
mtUser.setStoreId(Integer.parseInt(storeId));
} else {
mtUser.setStoreId(0);
}
mtUser.setSource(source);
mtUser.setCreateTime(new Date());
mtUser.setUpdateTime(new Date());
if (mtUser.getId() == null || mtUser.getId() <= 0) {
save(mtUser);
} else {
updateById(mtUser);
}
user = mtUserMapper.queryMemberByOpenId2(openId);
// 新增余额信息
if (ObjectUtil.isNotEmpty(storeId) && storeId !="") {
// 根据userid和stortId查询是否存在对应的余额信息
UserBalance userBalance = userBalanceService.selectUserBalance(mtUserMobile.getId(), Integer.parseInt(storeId));
if (ObjectUtil.isEmpty(userBalance)) {
// 新增余额信息
UserBalance userBalanceAdd = new UserBalance();
userBalanceAdd.setMtUserId(mtUserMobile.getId());
userBalanceAdd.setStoreId(Integer.parseInt(storeId));
userBalanceAdd.setCardBalance(0.0);
userBalanceAdd.setPoints(0);
userBalanceAdd.setGrowthValue(0);
userBalanceAdd.setConsumeNum(0);
// 新增余额信息
if (ObjectUtil.isNotEmpty(storeId) && storeId !="") {
// 根据userid和stortId查询是否存在对应的余额信息
UserBalance userBalance = userBalanceService.selectUserBalance(user.getId(), Integer.parseInt(storeId));
if (ObjectUtil.isEmpty(userBalance)) {
// 新增余额信息
UserBalance userBalanceAdd = new UserBalance();
userBalanceAdd.setMtUserId(user.getId());
userBalanceAdd.setStoreId(Integer.parseInt(storeId));
userBalanceAdd.setCardBalance(0.0);
userBalanceAdd.setPoints(0);
userBalanceAdd.setGrowthValue(0);
userBalanceAdd.setConsumeNum(0);
MtUserGrade lowGrade = userGradeService.getLowGrade(Integer.parseInt(storeId));
if (ObjectUtil.isNotEmpty(lowGrade) && ObjectUtil.isNotEmpty(lowGrade.getId())) {
userBalanceAdd.setGradeId(lowGrade.getId());
MtUserGrade lowGrade = userGradeService.getLowGrade(Integer.parseInt(storeId));
if (ObjectUtil.isNotEmpty(lowGrade) && ObjectUtil.isNotEmpty(lowGrade.getId())) {
userBalanceAdd.setGradeId(lowGrade.getId());
}
// 新增会员余额信息
userBalanceService.insertUserBalance(userBalanceAdd);
}
LJStore store = iljStoreService.selectStoreByStoreId(Integer.parseInt(storeId));
// 查询关联表里面是否有信息
MtInvitation mtInvitation1 = mtInvitationMapper.queryByStoreId(Integer.parseInt(storeId), mtUserMobile.getId());
if (ObjectUtil.isEmpty(mtInvitation1)) {
MtInvitation mtInvitation = new MtInvitation();
mtInvitation.setUserId(mtUserMobile.getId());
mtInvitation.setStoreId(Integer.parseInt(storeId));
if (ObjectUtil.isNotEmpty(staffId) && staffId !="") {
mtInvitation.setStaffId(Integer.parseInt(staffId));
}
if (ObjectUtil.isNotEmpty(inviterId) && inviterId !="") {
mtInvitation.setInviterId(Integer.parseInt(inviterId));
}
if (!ObjectUtil.isEmpty(store)){
mtInvitation.setChainStoreId(store.getChainStoreId());
}
mtInvitationMapper.insert(mtInvitation);
}
// 新增会员余额信息
userBalanceService.insertUserBalance(userBalanceAdd);
}
LJStore store = iljStoreService.selectStoreByStoreId(Integer.parseInt(storeId));
// 查询关联表里面是否有信息
MtInvitation mtInvitation1 = mtInvitationMapper.queryByStoreId(Integer.parseInt(storeId), user.getId());
if (ObjectUtil.isEmpty(mtInvitation1)) {
MtInvitation mtInvitation = new MtInvitation();
mtInvitation.setUserId(user.getId());
mtInvitation.setStoreId(Integer.parseInt(storeId));
mtInvitation.setStaffId(Integer.parseInt(staffId));
mtInvitation.setInviterId(Integer.parseInt(inviterId));
if (!ObjectUtil.isEmpty(store)){
mtInvitation.setChainStoreId(store.getChainStoreId());
return mtUser;
}else {
// 已被禁用
if (!"qy".equals(mtUserMobile.getStatus())) {
return null;
}
// 修改
mtUserMobile.setOpenId(openId);
updateById(mtUserMobile);
if (ObjectUtil.isNotEmpty(storeId) && storeId !="") {
MtInvitation mtInvitation1 = mtInvitationMapper.queryByStoreId(Integer.parseInt(storeId), mtUserMobile.getId());
if (ObjectUtil.isEmpty(mtInvitation1)) {
MtInvitation mtInvitation = new MtInvitation();
mtInvitation.setUserId(mtUserMobile.getId());
mtInvitation.setStoreId(Integer.parseInt(storeId));
if (ObjectUtil.isNotEmpty(staffId) && staffId !="") {
mtInvitation.setStaffId(Integer.parseInt(staffId));
}
if (ObjectUtil.isNotEmpty(inviterId) && inviterId !="") {
mtInvitation.setInviterId(Integer.parseInt(inviterId));
}
mtInvitationMapper.insert(mtInvitation);
}
mtInvitationMapper.insert(mtInvitation);
}
}
return mtUserMobile;
} else {
// 已被禁用
if (user.getStatus().equals(StatusEnum.DISABLE.getKey())) {
return null;
}
// 补充手机号
if (StringUtil.isNotEmpty(mobile)) {
user.setMobile(mobile);
updateById(user);
}
if (ObjectUtil.isNotEmpty(storeId) && storeId !="") {
MtInvitation mtInvitation1 = mtInvitationMapper.queryByStoreId(Integer.parseInt(storeId), user.getId());
if (ObjectUtil.isEmpty(mtInvitation1)) {
MtInvitation mtInvitation = new MtInvitation();
mtInvitation.setUserId(user.getId());
mtInvitation.setStoreId(Integer.parseInt(storeId));
mtInvitation.setStaffId(Integer.parseInt(staffId));
mtInvitation.setInviterId(Integer.parseInt(inviterId));
mtInvitationMapper.insert(mtInvitation);
}
}
// 使用openId查询
return null;
}
return user;
// // openid没有时使用手机号
// if (user == null) {
// MtUser mtUser = new MtUser();
// if (StringUtil.isNotEmpty(mobile)) {
// MtUser mtUserMobile = queryMemberByMobile2(mobile);
// if (mtUserMobile != null) {
// mtUser = mtUserMobile;
// }
// }
// // 昵称为空用手机号
// if (StringUtil.isEmpty(nickName) && StringUtil.isNotEmpty(mobile)) {
// nickName = mobile.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2");
// }
// String userNo = CommonUtil.createUserNo();
// mobile = CommonUtil.replaceXSS(mobile);
// avatar = CommonUtil.replaceXSS(avatar);
// nickName = CommonUtil.replaceXSS(nickName);
// mtUser.setUserNo(userNo);
// mtUser.setMobile(mobile);
// mtUser.setAvatar(avatar);
// mtUser.setName(nickName);
// mtUser.setOpenId(openId);
//
// Date time = new Date();
// mtUser.setCreateTime(time);
// mtUser.setUpdateTime(time);
// mtUser.setBalance(new BigDecimal(0));
// mtUser.setPoint(0);
// mtUser.setDescription("微信登录自动注册");
// mtUser.setIdcard("");
// mtUser.setStatus("qy");
// // 微信用户 12 0未知
// if (gender.equals(GenderEnum.FEMALE.getKey().toString())) {
// gender = GenderEnum.UNKNOWN.getKey().toString();
// } else if (gender.equals(GenderEnum.UNKNOWN.getKey().toString())) {
// gender = GenderEnum.FEMALE.getKey().toString();
// }
// mtUser.setSex(Integer.parseInt(gender));
//
// mtUser.setSource(source);
// if (mtUser.getId() == null || mtUser.getId() <= 0) {
// save(mtUser);
// } else {
// updateById(mtUser);
// }
//
// user = mtUserMapper.queryMemberByOpenId2(openId);
//
// // 新增余额信息
// if (ObjectUtil.isNotEmpty(storeId) && storeId !="") {
// // 根据userid和stortId查询是否存在对应的余额信息
// UserBalance userBalance = userBalanceService.selectUserBalance(user.getId(), Integer.parseInt(storeId));
// if (ObjectUtil.isEmpty(userBalance)) {
// // 新增余额信息
// UserBalance userBalanceAdd = new UserBalance();
// userBalanceAdd.setMtUserId(user.getId());
// userBalanceAdd.setStoreId(Integer.parseInt(storeId));
// userBalanceAdd.setCardBalance(0.0);
// userBalanceAdd.setPoints(0);
// userBalanceAdd.setGrowthValue(0);
// userBalanceAdd.setConsumeNum(0);
//
// MtUserGrade lowGrade = userGradeService.getLowGrade(Integer.parseInt(storeId));
// if (ObjectUtil.isNotEmpty(lowGrade) && ObjectUtil.isNotEmpty(lowGrade.getId())) {
// userBalanceAdd.setGradeId(lowGrade.getId());
// }
// // 新增会员余额信息
// userBalanceService.insertUserBalance(userBalanceAdd);
// }
// LJStore store = iljStoreService.selectStoreByStoreId(Integer.parseInt(storeId));
// // 查询关联表里面是否有信息
// MtInvitation mtInvitation1 = mtInvitationMapper.queryByStoreId(Integer.parseInt(storeId), user.getId());
// if (ObjectUtil.isEmpty(mtInvitation1)) {
// MtInvitation mtInvitation = new MtInvitation();
// mtInvitation.setUserId(user.getId());
// mtInvitation.setStoreId(Integer.parseInt(storeId));
// mtInvitation.setStaffId(Integer.parseInt(staffId));
// mtInvitation.setInviterId(Integer.parseInt(inviterId));
// if (!ObjectUtil.isEmpty(store)){
// mtInvitation.setChainStoreId(store.getChainStoreId());
// }
// mtInvitationMapper.insert(mtInvitation);
// }
// }
// } else {
// // 已被禁用
// if (user.getStatus().equals(StatusEnum.DISABLE.getKey())) {
// return null;
// }
// // 补充手机号
// if (StringUtil.isNotEmpty(mobile)) {
// user.setMobile(mobile);
// updateById(user);
// }
//
// if (ObjectUtil.isNotEmpty(storeId) && storeId !="") {
// MtInvitation mtInvitation1 = mtInvitationMapper.queryByStoreId(Integer.parseInt(storeId), user.getId());
// if (ObjectUtil.isEmpty(mtInvitation1)) {
// MtInvitation mtInvitation = new MtInvitation();
// mtInvitation.setUserId(user.getId());
// mtInvitation.setStoreId(Integer.parseInt(storeId));
// mtInvitation.setStaffId(Integer.parseInt(staffId));
// mtInvitation.setInviterId(Integer.parseInt(inviterId));
// mtInvitationMapper.insert(mtInvitation);
// }
// }
// }
//
// return user;
}
//生成用户编号
private String editUserNo() {
Random random = new Random();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 7; i++) {
sb.append(random.nextInt(10));
}
String digits = sb.toString();
int sum = 0;
for (int i = 0; i < digits.length(); i++) {
int digit = Integer.parseInt(String.valueOf(digits.charAt(i)));
if (i % 2 == 0) {
sum += digit;
} else {
sum += digit * 3;
}
}
int checksum = (10 - (sum % 10)) % 10;
String number = digits + checksum;
return number;
}

View File

@ -106,66 +106,32 @@ public class ClientSignController extends BaseController {
logger.info("微信授权登录参数:{}", param);
JSONObject userInfo = paramsObj.getJSONObject("userInfo");
String storeId = ObjectUtil.isEmpty(userInfo.get("storeId"))? "" : userInfo.get("storeId").toString();
String staffId = ObjectUtil.isEmpty(userInfo.get("staffId"))? "" : userInfo.get("staffId").toString();
String inviterId = ObjectUtil.isEmpty(userInfo.get("inviterId"))? "" : userInfo.get("inviterId").toString();
// String staffId = ObjectUtil.isEmpty(userInfo.get("staffId"))? "" : userInfo.get("staffId").toString();
// String inviterId = ObjectUtil.isEmpty(userInfo.get("inviterId"))? "" : userInfo.get("inviterId").toString();
JSONObject loginInfo = weixinService.getWxProfile2(param.get("code").toString()); // 发起的登录请求 merchantId用来获取商户的appid 目前用不到
if (loginInfo == null) {
return getFailureResult(0, "微信登录失败");
}
// 获取用户信息
// String type = userInfo.getString("type");
// type.equals("phone") &&
// String encryptedData = userInfo.getString("encryptedData");
// userInfo.put("phone", "");
// userInfo.put("source", MemberSourceEnum.WECHAT_LOGIN.getKey());
// if (StringUtil.isNotEmpty(encryptedData)) {
// String phone = weixinService.getPhoneNumber(userInfo.get("encryptedData").toString(), loginInfo.get("session_key").toString(), userInfo.get("iv").toString());
// userInfo.put("phone", phone);
// }
// 默认店铺主页 ()
// if (storeId == null || StringUtil.isEmpty(storeId)) {
// MtStore mtStore = storeService.getDefaultStore(merchantNo);
// if (mtStore != null) {
// storeId = mtStore.getId().toString();
// }
// }
MtUser mtUser = memberService.queryMemberByOpenId2(loginInfo.get("openid").toString(), userInfo);
if (mtUser == null) {
return getFailureResult(0, "用户状态异常");
}
String userAgent = request.getHeader("user-agent");
// String token = TokenUtil.generateToken(userAgent, mtUser.getId());
// UserInfo userLoginInfo = new UserInfo();
// userLoginInfo.setId(mtUser.getId());
// userLoginInfo.setStoreId(storeId);
//
// userLoginInfo.setToken(token);
// TokenUtil.saveToken(userLoginInfo);
//
// Map<String, Object> result = new HashMap<>();
// result.put("token", token);
// result.put("userId", mtUser.getId());
// result.put("userName", mtUser.getName());
// result.put("openId", mtUser.getOpenId());
AccountInfo accountInfo = new AccountInfo();
accountInfo.setId(mtUser.getId());
accountInfo.setDeptId(-1L);
if (ObjectUtil.isNotEmpty(storeId) && storeId!= "") {
accountInfo.setStoreId(Integer.parseInt(storeId));
}
String token1 = TokenUtil.generateToken(userAgent, mtUser.getId());
accountInfo.setToken(token1);
String token = TokenUtil.generateToken(userAgent, mtUser.getId());
accountInfo.setToken(token);
TokenUtil.saveAccountToken(accountInfo);
LoginResponse response = new LoginResponse();
response.setLogin(true);
response.setToken(token1);
response.setToken(token);
response.setTokenCreatedTime(new Date());
// return getSuccessResult(response);
return getSuccessResult("登录成功", response);
}

View File

@ -0,0 +1,16 @@
{ // launch.json configurations app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
// launchtypelocalremote, localremote
"version": "0.0",
"configurations": [{
"default" :
{
"launchtype" : "local"
},
"mp-weixin" :
{
"launchtype" : "local"
},
"type" : "uniCloud"
}
]
}

View File

@ -34,6 +34,13 @@
"navigationStyle": "custom"
}
},
{
"path": "activeIn/index",
"style": {
"navigationBarTitleText": "你建的",
"navigationStyle": "custom"
}
},
{
"path": "Address/Address",
"style": {

View File

@ -7,7 +7,8 @@
<view class="my-icons"></view>
</view>
<view class="mub">
<view class="mub-box" v-for="(item,index) in activityList" :key="index" @click="getactvity(item.path)">
<!-- <view class="mub-box" v-for="(item,index) in activityList" :key="index" @click="getactvity(item.path)"> -->
<view class="mub-box" v-for="(item,index) in activityList" :key="index" @click="intoOtherPage()">
<view class="box-img">
<image src="../../static/imgs/xp.jpg" mode=""></image>
</view>
@ -29,6 +30,7 @@
</template>
<script>
import request from '../../utils/request'
export default {
data() {
return {
@ -58,11 +60,38 @@
}
},
datas() {
return {
datas: [{
"activeDescribe": ""
}]
}
},
components: {
},
methods: {
intoOtherPage() {
uni.navigateTo({
url: '/pagesHome/activeIn/index'
})
},
getData() {
// request({
// url: '/business/marketingActivity/activeConsumption/AppletList',
// method: 'get',
// success: function(res) {
// this.datas = res.data
// }
// })
request({
url: '/business/marketingActivity/activeConsumption/AppletList',
method: 'get',
}).then(res => {
console.log(res);
this.datas = res.data
})
},
getactvity(url) {
if (url) {
console.log('跳转中');

View File

@ -81,6 +81,4 @@
position: fixed;
top: 0px;
}
</style>

View File

@ -0,0 +1,82 @@
<template>
<view class="content">
<view class="container">
<view class="my-header">
<view class="my-icons" @click="goback"> <uni-icons type="left" size="16"></uni-icons> </view>
<view class="my-text">样版页</view>
<view class="my-icons"></view>
</view>
<!-- 顶部区域 -->
<view class="" v-for="(item,index) in datas" :key="index">
<text>{{item.activeDescribe || ""}}</text>
</view>
</view>
</view>
</template>
<script>
import request from '../../utils/request'
export default {
data() {
return {
title: '',
datas: [],
}
},
components: {
},
onLoad() {
this.getData();
},
methods: {
getData() {
request({
url: '/business/marketingActivity/activeConsumption/appletList',
method: 'get',
}).then(res => {
this.datas = res.data
})
},
goback() {
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
.content {
background: #f4f5f6;
}
.container {
width: 100%;
height: 100vh;
box-sizing: border-box;
padding-top: 88px;
}
.my-header {
width: 100%;
height: 88px;
background: #ffffff;
display: flex;
align-items: center;
justify-content: space-between;
color: #000;
box-sizing: border-box;
padding: 0px 15px;
padding-top: 40px;
.my-icons {
width: 20px;
}
position: fixed;
top: 0px;
}
</style>

View File

@ -75,6 +75,7 @@
userInfo: {
storeId: 0,
staffId: "",
phone:'17753808121'
},
type: 'phone',

View File

@ -0,0 +1,8 @@
const getters = {
token: state => state.user.token,
avatar: state => state.user.avatar,
name: state => state.user.name,
roles: state => state.user.roles,
permissions: state => state.user.permissions
}
export default getters

View File

@ -0,0 +1,15 @@
import Vue from 'vue'
import Vuex from 'vuex'
import user from '@/store/modules/user'
import getters from './getters'
Vue.use(Vuex)
const store = new Vuex.Store({
modules: {
user
},
getters
})
export default store

View File

@ -0,0 +1,115 @@
import config from '@/config'
import storage from '@/utils/storage'
import constant from '@/utils/constant'
import {
login,
logout,
getInfo
} from '@/api/login'
import {
getToken,
setToken,
removeToken
} from '@/utils/auth'
const baseUrl = config.baseUrl
const user = {
state: {
token: getToken(),
name: storage.get(constant.name),
avatar: storage.get(constant.avatar),
roles: storage.get(constant.roles),
permissions: storage.get(constant.permissions)
},
mutations: {
SET_TOKEN: (state, token) => {
state.token = token
},
SET_NAME: (state, name) => {
state.name = name
storage.set(constant.name, name)
},
SET_AVATAR: (state, avatar) => {
state.avatar = avatar
storage.set(constant.avatar, avatar)
},
SET_ROLES: (state, roles) => {
state.roles = roles
storage.set(constant.roles, roles)
},
SET_PERMISSIONS: (state, permissions) => {
state.permissions = permissions
storage.set(constant.permissions, permissions)
}
},
actions: {
// 登录
Login({
commit
}, userInfo) {
const username = userInfo.username.trim()
const password = userInfo.password
const code = userInfo.code
const uuid = userInfo.uuid
return new Promise((resolve, reject) => {
login(username, password, code, uuid).then(res => {
setToken(res.token)
commit('SET_TOKEN', res.token)
resolve()
}).catch(error => {
reject(error)
})
})
},
// 获取用户信息
GetInfo({
commit,
state
}) {
return new Promise((resolve, reject) => {
getInfo().then(res => {
const user = res.user
const avatar = baseUrl + user.avatar
const username = (user == null || user.userName == "" || user.userName ==
null) ? "" : user.userName
if (res.roles && res.roles.length > 0) {
commit('SET_ROLES', res.roles)
commit('SET_PERMISSIONS', res.permissions)
} else {
commit('SET_ROLES', ['ROLE_DEFAULT'])
}
commit('SET_NAME', username)
commit('SET_AVATAR', avatar)
resolve(res)
}).catch(error => {
reject(error)
})
})
},
// 退出系统
LogOut({
commit,
state
}) {
return new Promise((resolve, reject) => {
logout(state.token).then(() => {
commit('SET_TOKEN', '')
commit('SET_ROLES', [])
commit('SET_PERMISSIONS', [])
removeToken()
storage.clean()
resolve()
}).catch(error => {
reject(error)
})
})
}
}
}
export default user

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long