8 changed files with 2060 additions and 2254 deletions
File diff suppressed because it is too large
@ -0,0 +1,375 @@ |
|||||
|
<template> |
||||
|
<view class="assemble"> |
||||
|
<view style="height: 20rpx;"></view> |
||||
|
<!-- 市场人员展示--> |
||||
|
<view class="div-style"> |
||||
|
<view style="height: 38vh;"> |
||||
|
<view style="display: flex;align-items: center;padding: 20rpx 0 0 20rpx;"> |
||||
|
<view> |
||||
|
<image :src="$util.img('/uniapp_src/static/images/index/danlan.png')" class="drop-image"> |
||||
|
</image> |
||||
|
</view> |
||||
|
<view class="title">本月业绩</view> |
||||
|
</view> |
||||
|
<view class="coach-message"> |
||||
|
<view class="left1"> |
||||
|
<view style="padding: 20rpx 0;"> |
||||
|
<view style="display: flex;align-items: center;"> |
||||
|
<view style="padding: 12rpx;"> |
||||
|
<image :src="$util.img('/uniapp_src/static/images/index/huang.png')" |
||||
|
class="drop-image-x"></image> |
||||
|
</view> |
||||
|
<view class="title-x">资源总数</view> |
||||
|
</view> |
||||
|
<view class="title-x1">{{infoData.month.new_total}}人</view> |
||||
|
</view> |
||||
|
|
||||
|
<view> |
||||
|
<view style="display: flex;align-items: center;"> |
||||
|
<view style="padding: 12rpx;"> |
||||
|
<image :src="$util.img('/uniapp_src/static/images/index/lvs.png')" |
||||
|
class="drop-image-x"></image> |
||||
|
</view> |
||||
|
<view class="title-x">已分配</view> |
||||
|
</view> |
||||
|
<view class="title-x1">{{infoData.month.new_total}}人</view> |
||||
|
</view> |
||||
|
|
||||
|
<view> |
||||
|
<view style="display: flex;align-items: center;"> |
||||
|
<view style="padding: 12rpx;"> |
||||
|
<image :src="$util.img('/uniapp_src/static/images/index/shenlan.png')" |
||||
|
class="drop-image-x"></image> |
||||
|
</view> |
||||
|
<view class="title-x">昨日新增</view> |
||||
|
</view> |
||||
|
<view class="title-x1">{{infoData.month.yesterday_new}}人</view> |
||||
|
</view> |
||||
|
|
||||
|
<view> |
||||
|
<view style="display: flex;align-items: center;"> |
||||
|
<view style="padding: 12rpx;"> |
||||
|
<image :src="$util.img('/uniapp_src/static/images/index/lan.png')" |
||||
|
class="drop-image-x"></image> |
||||
|
</view> |
||||
|
<view class="title-x">今日新增</view> |
||||
|
</view> |
||||
|
<view class="title-x1">{{infoData.month.today_new}}人</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<!-- 统计图--> |
||||
|
<view class="right1"> |
||||
|
<view style="text-align: center;">{{infoData.date_range}}</view> |
||||
|
<view class="statistics_box"> |
||||
|
|
||||
|
<view class="item"> |
||||
|
<view class="box"> |
||||
|
<view class="progress-bar" |
||||
|
:style="{ height: `${infoData.month.yesterday_new_rate}%`, background: '#f59a23' }"> |
||||
|
</view> |
||||
|
<view class="ratio" |
||||
|
:style="{ color: infoData.month.yesterday_new_rate <= 0 ? '#333333' : '#000' }"> |
||||
|
{{ infoData.month.yesterday_new_rate }}% |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="title">昨日</view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="item"> |
||||
|
<view class="box"> |
||||
|
<view class="progress-bar" |
||||
|
:style="{ height: `${infoData.month.assigned_sales_rate}%`, background: '#039f64' }"> |
||||
|
</view> |
||||
|
<view class="ratio" |
||||
|
:style="{ color: infoData.month.assigned_sales_rate <= 0 ? '#333333' : '#000' }"> |
||||
|
{{ infoData.month.assigned_sales_rate }}% |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="title">分配</view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="item"> |
||||
|
<view class="box"> |
||||
|
<view class="progress-bar" |
||||
|
:style="{ height: `${infoData.month.today_new_rate}%`, background: '#4066f2' }"> |
||||
|
</view> |
||||
|
<view class="ratio" |
||||
|
:style="{ color: infoData.month.today_new_rate <= 0 ? '#333333' : '#000' }"> |
||||
|
{{ infoData.month.today_new_rate }}% |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="title">今日</view> |
||||
|
</view> |
||||
|
|
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<view style="width: 90%;background: #EFF3F8;height: 4rpx;margin: auto;"></view> |
||||
|
|
||||
|
<view style="height: 38vh;"> |
||||
|
<view style="display: flex;align-items: center;padding: 20rpx 0 0 20rpx;"> |
||||
|
<view> |
||||
|
<image :src="$util.img('/uniapp_src/static/images/index/danlv.png')" class="drop-image"></image> |
||||
|
</view> |
||||
|
<view class="title">个人业绩</view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="coach-message"> |
||||
|
<view class="this_month"> |
||||
|
<view style="padding: 20rpx 0;display: flex;justify-content: space-between;"> |
||||
|
<view style="width: 48%;"> |
||||
|
<view style="display: flex;align-items: center;"> |
||||
|
<view style="padding: 12rpx;"> |
||||
|
<image :src="$util.img('/uniapp_src/static/images/index/danlv.png')" |
||||
|
class="drop-image-x"></image> |
||||
|
</view> |
||||
|
<view class="title-x">今日新增资源</view> |
||||
|
</view> |
||||
|
<view class="title-x1">{{infoData.last_month.xzzy}}人</view> |
||||
|
</view> |
||||
|
|
||||
|
<view style="width: 48%;"> |
||||
|
<view style="display: flex;align-items: center;"> |
||||
|
<view style="padding: 12rpx;"> |
||||
|
<image :src="$util.img('/uniapp_src/static/images/index/danlv.png')" |
||||
|
class="drop-image-x"></image> |
||||
|
</view> |
||||
|
<view class="title-x">今日业绩收入</view> |
||||
|
</view> |
||||
|
<view class="title-x1">{{infoData.last_month.yjsr}}人</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<view style="padding: 20rpx 0;display: flex;justify-content: space-between;"> |
||||
|
<view style="width: 48%;"> |
||||
|
<view style="display: flex;align-items: center;"> |
||||
|
<view style="padding: 12rpx;"> |
||||
|
<image :src="$util.img('/uniapp_src/static/images/index/danlv.png')" |
||||
|
class="drop-image-x"></image> |
||||
|
</view> |
||||
|
<view class="title-x">历史关单数量</view> |
||||
|
</view> |
||||
|
<view class="title-x1">{{infoData.last_month.gdsl}}人</view> |
||||
|
</view> |
||||
|
|
||||
|
<view style="width: 48%;"> |
||||
|
<view style="display: flex;align-items: center;"> |
||||
|
<view style="padding: 12rpx;"> |
||||
|
<image :src="$util.img('/uniapp_src/static/images/index/danlv.png')" |
||||
|
class="drop-image-x"></image> |
||||
|
</view> |
||||
|
<view class="title-x">资源未分配数量</view> |
||||
|
</view> |
||||
|
<view class="title-x1">{{infoData.last_month.wfpsl}}人</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<AQTabber /> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import apiRoute from '@/api/apiRoute.js'; |
||||
|
|
||||
|
import AQTabber from "@/components/AQ/AQTabber.vue" |
||||
|
|
||||
|
export default { |
||||
|
components: { |
||||
|
AQTabber, |
||||
|
}, |
||||
|
data() { |
||||
|
return { |
||||
|
infoData: {}, //详情 |
||||
|
|
||||
|
userInfo: {}, //当前登录的用户信息 |
||||
|
} |
||||
|
}, |
||||
|
onShow() { |
||||
|
this.init() |
||||
|
}, |
||||
|
methods: { |
||||
|
async init() { |
||||
|
await this.getUserInfo() |
||||
|
await this.getXsIndex() |
||||
|
}, |
||||
|
|
||||
|
//获取用户信息 |
||||
|
async getUserInfo() { |
||||
|
let res = await apiRoute.getPersonnelInfo({}) |
||||
|
if (res.code != 1) { |
||||
|
uni.showToast({ |
||||
|
title: res.msg, |
||||
|
icon: 'none' |
||||
|
}) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
this.userInfo = res.data |
||||
|
}, |
||||
|
|
||||
|
//获取销售首页详情 |
||||
|
async getXsIndex() { |
||||
|
let role_key_arr = this.userInfo.role_key_arr.join(',') |
||||
|
let params = { |
||||
|
personnel_id: this.userInfo.id, //员工表id |
||||
|
role_key_arr: role_key_arr, // 角色key 转换数组为字符串,若为空则赋予空字符串 |
||||
|
} |
||||
|
let res = await apiRoute.xs_statisticsMarketHome(params) |
||||
|
if (res.code != 1) { |
||||
|
uni.showToast({ |
||||
|
title: res.msg, |
||||
|
icon: 'none' |
||||
|
}) |
||||
|
return |
||||
|
} |
||||
|
this.infoData = res.data |
||||
|
console.log('统计', this.infoData) |
||||
|
}, |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="less" scoped> |
||||
|
//自定义导航栏 |
||||
|
.navbar_section { |
||||
|
border: 1px solid #fff; |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
background: #fff; |
||||
|
|
||||
|
.title { |
||||
|
padding: 40rpx 0rpx; |
||||
|
|
||||
|
/* 小程序端样式 */ |
||||
|
// #ifdef MP-WEIXIN |
||||
|
padding: 80rpx 0rpx; |
||||
|
// #endif |
||||
|
|
||||
|
font-size: 30rpx; |
||||
|
color: #858585; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.assemble { |
||||
|
width: 100%; |
||||
|
height: 100vh; |
||||
|
background: #292929; |
||||
|
} |
||||
|
|
||||
|
.div-style { |
||||
|
width: 92%; |
||||
|
height: 85vh; |
||||
|
background: #fff; |
||||
|
border-radius: 16rpx; |
||||
|
margin: auto; |
||||
|
} |
||||
|
|
||||
|
.coach-message { |
||||
|
width: 92%; |
||||
|
margin: 10rpx auto; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
padding-top: 20rpx; |
||||
|
} |
||||
|
|
||||
|
.drop-image { |
||||
|
width: 50rpx; |
||||
|
height: 50rpx; |
||||
|
} |
||||
|
|
||||
|
.title { |
||||
|
font-size: 30rpx; |
||||
|
color: #7F7F7F; |
||||
|
padding-left: 20rpx; |
||||
|
} |
||||
|
|
||||
|
.left1 { |
||||
|
width: 48%; |
||||
|
height: 95%; |
||||
|
margin: auto; |
||||
|
} |
||||
|
|
||||
|
.right1 { |
||||
|
width: 48%; |
||||
|
height: 95%; |
||||
|
margin: auto; |
||||
|
|
||||
|
.statistics_box { |
||||
|
margin: auto; |
||||
|
margin-top: 10rpx; |
||||
|
display: flex; |
||||
|
justify-content: space-between; |
||||
|
|
||||
|
.item { |
||||
|
width: 90rpx; |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
align-items: center; |
||||
|
|
||||
|
.box { |
||||
|
width: 100%; |
||||
|
height: 328rpx; |
||||
|
border: 1px solid #ddd; |
||||
|
border-radius: 6rpx; |
||||
|
background: #f5f5f5; |
||||
|
position: relative; |
||||
|
|
||||
|
.progress-bar { |
||||
|
width: 100%; |
||||
|
height: 0; |
||||
|
transition: height 0.3s ease; |
||||
|
position: absolute; |
||||
|
bottom: 0; |
||||
|
} |
||||
|
|
||||
|
.ratio { |
||||
|
width: 100%; |
||||
|
position: absolute; |
||||
|
bottom: -0rpx; |
||||
|
font-size: 26rpx; |
||||
|
text-align: center; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.title { |
||||
|
margin-top: 5rpx; |
||||
|
padding: 0; |
||||
|
font-size: 26rpx; |
||||
|
color: #999999; |
||||
|
; |
||||
|
text-align: center; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.this_month { |
||||
|
width: 100%; |
||||
|
height: 95%; |
||||
|
margin: auto; |
||||
|
} |
||||
|
|
||||
|
.drop-image-x { |
||||
|
width: 20rpx; |
||||
|
height: 20rpx; |
||||
|
} |
||||
|
|
||||
|
.title-x { |
||||
|
font-size: 28rpx; |
||||
|
color: #7F7F7F; |
||||
|
padding-left: 20rpx; |
||||
|
} |
||||
|
|
||||
|
.title-x1 { |
||||
|
font-size: 28rpx; |
||||
|
color: #333333; |
||||
|
padding-left: 60rpx; |
||||
|
} |
||||
|
</style> |
||||
@ -1,360 +1,327 @@ |
|||||
<template> |
<template> |
||||
<view> |
<view> |
||||
<view style="height: 500rpx;background-color:#fff;"> |
<view style="height: 500rpx;background-color:#fff;"> |
||||
<view style="height: 150rpx;"></view> |
<view style="height: 150rpx;"></view> |
||||
<view class="image-container;"> |
<view class="image-container;"> |
||||
<image :src="$util.img('/uniapp_src/static/images/login/login1.png')" class="base-image"></image> |
<image :src="$util.img('/uniapp_src/static/images/login/login1.png')" class="base-image"></image> |
||||
<image :src="$util.img('/uniapp_src/static/images/login/login2.png')" class="overlay-image"></image> |
<image :src="$util.img('/uniapp_src/static/images/login/login2.png')" class="overlay-image"></image> |
||||
</view> |
</view> |
||||
<view style="width: 100%;font-size: 60rpx;color: #ccc;text-align: center;margin-top: 60rpx;"> |
<view style="width: 100%;font-size: 60rpx;color: #ccc;text-align: center;margin-top: 60rpx;"> |
||||
运动课堂 |
运动识堂 |
||||
</view> |
</view> |
||||
</view> |
</view> |
||||
<view :style="{'background-color':'#fff','width':'100%','height':'100vh' }"> |
<view :style="{'background-color':'#fff','width':'100%','height':'100vh' }"> |
||||
<view style="width: 95%;height: 30rpx;"></view> |
<view style="width: 95%;height: 30rpx;"></view> |
||||
<view style="width: 95%;margin:30rpx auto;"> |
<view style="width: 95%;margin:30rpx auto;"> |
||||
<fui-input borderTop placeholder="登录账号" v-model="user" @input="input" |
<fui-input borderTop placeholder="登录账号" v-model="user" |
||||
backgroundColor="#f2f2f2"></fui-input> |
backgroundColor="#f2f2f2"></fui-input> |
||||
</view> |
</view> |
||||
|
|
||||
<view style="width: 95%;margin: auto;"> |
<view style="width: 95%;margin: auto;"> |
||||
<fui-input borderTop :padding="['20rpx','32rpx']" v-model="password1" placeholder="登录密码" |
<fui-input borderTop :padding="['20rpx','32rpx']" v-model="password1" placeholder="登录密码" |
||||
:password="password" @input="input" backgroundColor="#f2f2f2"> |
:password="password" backgroundColor="#f2f2f2"> |
||||
<fui-icon :name="password?'invisible':'visible'" color="#B2B2B2" :size="50" |
<fui-icon :name="password?'invisible':'visible'" color="#B2B2B2" :size="50" |
||||
@click="change"></fui-icon> |
@click="change"></fui-icon> |
||||
</fui-input> |
</fui-input> |
||||
</view> |
</view> |
||||
|
|
||||
<view style="width: 95%;margin:30rpx auto;"> |
<view style="width: 95%;margin:30rpx auto;"> |
||||
<fui-input |
<fui-input @click="picker_show_loginType=true" v-model="loginType_str" placeholder="请选择登录类型" |
||||
@click="picker_show_loginType=true" |
backgroundColor="#f2f2f2"> |
||||
v-model="loginType_str" |
<fui-icon name="arrowdown" color="#B2B2B2" :size="50" @click="change"></fui-icon> |
||||
placeholder="请选择登录类型" |
</fui-input> |
||||
backgroundColor="#f2f2f2" |
<fui-picker layer="1" :linkage="true" :options="loginType_Arr" :show="picker_show_loginType" |
||||
> |
@change="changePicker_loginType" @cancel="picker_show_loginType=false"></fui-picker> |
||||
<fui-icon name="arrowdown" color="#B2B2B2" :size="50" |
</view> |
||||
@click="change"></fui-icon> |
|
||||
</fui-input> |
<view style="width: 95%;margin:60rpx auto;"> |
||||
<fui-picker |
<fui-button background="#00be8c" radius="5rpx" @click="login">登录</fui-button> |
||||
layer="1" |
</view> |
||||
:linkage="true" |
|
||||
:options="loginType_Arr" |
<view style="width: 95%;margin:60rpx auto;"> |
||||
:show="picker_show_loginType" |
<fui-button background="#fff" radius="5rpx" @click="forgot" color="#00be8c">忘记登录密码</fui-button> |
||||
@change="changePicker_loginType" |
</view> |
||||
@cancel="picker_show_loginType=false" |
|
||||
></fui-picker> |
</view> |
||||
</view> |
</view> |
||||
|
|
||||
<view style="width: 95%;margin:60rpx auto;"> |
|
||||
<fui-button background="#00be8c" radius="5rpx" @click="login">登录</fui-button> |
|
||||
</view> |
|
||||
|
|
||||
<view style="width: 95%;margin:60rpx auto;"> |
|
||||
<fui-button background="#fff" radius="5rpx" @click="forgot" color="#00be8c">忘记登录密码</fui-button> |
|
||||
</view> |
|
||||
|
|
||||
</view> |
|
||||
</view> |
|
||||
</template> |
</template> |
||||
|
|
||||
<script> |
<script> |
||||
import apiRoute from '@/api/apiRoute.js'; |
import apiRoute from '@/api/apiRoute.js'; |
||||
|
|
||||
export default { |
export default { |
||||
data() { |
data() { |
||||
return { |
return { |
||||
inited: false, // 添加标记位控制 init 只执行一次 |
inited: false, // 添加标记位控制 init 只执行一次 |
||||
|
|
||||
password: true, |
password: true, |
||||
user: '', //账户 |
user: '', //账户 |
||||
password1: '', //密码 |
password1: '', //密码 |
||||
mini_wx_openid:'',//微信小程序openid |
mini_wx_openid: '', //微信小程序openid |
||||
|
|
||||
loginType:'',//登陆类型|1=教练,2=销售,3=学员 |
loginType: '', //登陆类型|1=教练,2=销售,3=学员 |
||||
loginType_str:'',//登陆类型中文名字 |
loginType_str: '', //登陆类型中文名字 |
||||
loginType_Arr:[ |
loginType_Arr: [{ |
||||
{ |
value: '1', |
||||
value: '1', |
text: '市场登陆' |
||||
text: '教师登陆' |
}, |
||||
}, |
{ |
||||
{ |
value: '2', |
||||
value: '2', |
text: '教师登陆' |
||||
text: '销售登陆' |
}, |
||||
}, |
{ |
||||
{ |
value: '3', |
||||
value: '3', |
text: '销售登陆' |
||||
text: '学员登陆' |
}, |
||||
} |
{ |
||||
], |
value: '4', |
||||
picker_show_loginType:false,//是否显示下拉窗组件 |
text: '学员登陆' |
||||
|
} |
||||
|
], |
||||
path_arr:{ |
picker_show_loginType: false, //是否显示下拉窗组件 |
||||
'1':'/pages/coach/home/index',//教练 |
|
||||
'2':'/pages/market/index/index',//销售 |
|
||||
'3':'/pages/student/index/index',//学员 |
path_arr: { |
||||
}, |
'1': '/pages/market/home/index', //市场 |
||||
} |
'2': '/pages/coach/home/index', //教练 |
||||
}, |
'3': '/pages/market/index/index', //销售 |
||||
onLoad(options) { |
'4': '/pages/student/index/index', //学员 |
||||
this.loginType = options.loginType ?? '2'//登陆类型|1=教练,2=销售,3=学员 |
}, |
||||
const selectedItem = this.loginType_Arr.find(item => item.value === String(this.loginType)); |
} |
||||
this.loginType_str = selectedItem ? selectedItem.text : '未知类型'; |
}, |
||||
// uni.hideHomeButton() |
onLoad(options) { |
||||
// console.log(uni.getStorageSync('um_id')) |
this.loginType = options.loginType ?? '1' //登陆类型|1=市场,2=教练,3=销售4=学员 |
||||
// 防止 onShow 触发后重复 init |
const selectedItem = this.loginType_Arr.find(item => item.value === String(this.loginType)); |
||||
|
this.loginType_str = selectedItem ? selectedItem.text : '未知类型'; |
||||
let res_codes = options.res_codes || ''//这个是axios.js传错来的接口请求返回的code,如果是401时则说明登陆报错,此时不应进入下方初始化方法 |
|
||||
if (!this.inited && !res_codes) { |
let res_codes = options.res_codes || '' //这个是axios.js传错来的接口请求返回的code,如果是401时则说明登陆报错,此时不应进入下方初始化方法 |
||||
this.openViewHome() |
if (!this.inited && !res_codes) { |
||||
this.inited = true |
this.openViewHome() |
||||
} |
this.inited = true |
||||
}, |
} |
||||
methods: { |
}, |
||||
async init(){ |
methods: { |
||||
//条件编译 微信小程序 |
async init() { |
||||
//#ifdef MP-WEIXIN |
//条件编译 微信小程序 |
||||
await this.getMiNiWxOpenId() |
//#ifdef MP-WEIXIN |
||||
//#endif |
await this.getMiNiWxOpenId() |
||||
}, |
//#endif |
||||
input(e) { |
}, |
||||
//console.log(e) |
change() { |
||||
}, |
this.password = !this.password |
||||
change() { |
}, |
||||
this.password = !this.password |
forgot() { |
||||
}, |
this.$navigateTo({ |
||||
forgot() { |
url: '/pages/student/login/forgot' |
||||
this.$navigateTo({ |
}) |
||||
url: '/pages/student/login/forgot' |
}, |
||||
}) |
//登陆 |
||||
}, |
async login() { |
||||
//登陆 |
try { |
||||
async login() { |
// 参数验证 |
||||
|
if (!this.user) { |
||||
if (!this.user) { |
uni.showToast({ |
||||
uni.showToast({ |
title: '请输入手机号', |
||||
title: '请输入用户名', |
icon: 'none' |
||||
icon: 'none' |
}); |
||||
}) |
return; |
||||
return |
} |
||||
} |
if (!this.password1) { |
||||
if (!this.password1) { |
uni.showToast({ |
||||
uni.showToast({ |
title: '请输入密码', |
||||
title: '请输入密码', |
icon: 'none' |
||||
icon: 'none' |
}); |
||||
}) |
return; |
||||
return |
} |
||||
} |
if (!this.loginType) { |
||||
|
uni.showToast({ |
||||
if (!this.loginType) { |
title: '请选择登录类型', |
||||
uni.showToast({ |
icon: 'none' |
||||
title: '请选择登陆类型', |
}); |
||||
icon: 'none' |
return; |
||||
}) |
} |
||||
return |
|
||||
} |
const params = { |
||||
|
phone: this.user, |
||||
let item = {}; |
password: this.password1, |
||||
item['username'] = this.user |
login_type: this.loginType, |
||||
item['password'] = this.password1 |
mini_wx_openid: this.mini_wx_openid //微信小程序openid |
||||
|
}; |
||||
let res |
|
||||
//判断登陆类型|1=教练,2=销售,3=学员 |
console.log('登录参数:', params); |
||||
if(this.loginType == 1){ |
let res; |
||||
//销售 |
if (this.loginType != 4) { |
||||
let params = { |
//员工登录 |
||||
'phone': this.user, |
res = await apiRoute.personnelLogin(params); |
||||
'password': this.password1, |
} else { |
||||
'login_type': 1, |
//学生 |
||||
'mini_wx_openid':this.mini_wx_openid,//微信小程序openid |
res = await apiRoute.xy_login(params); |
||||
} |
} |
||||
res = await apiRoute.personnelLogin(params) |
console.log('登录响应:', res); |
||||
}else if(this.loginType == 2){ |
|
||||
|
if (res && res.code === 1) { // 成功状态码为1 |
||||
//销售 |
// 登录成功 |
||||
let params = { |
if (res.data && res.data.token) { |
||||
'phone': this.user, |
uni.setStorageSync("token", res.data.token); |
||||
'password': this.password1, |
// 保存用户类型 |
||||
'login_type': 2, |
if (res.data.user_type) { |
||||
'mini_wx_openid':this.mini_wx_openid,//微信小程序openid |
uni.setStorageSync("userType", res.data.user_type); |
||||
} |
} |
||||
res = await apiRoute.personnelLogin(params) |
// 保存过期时间 |
||||
console.log(123123,res) |
if (res.data.expires_time) { |
||||
|
uni.setStorageSync("expires_time", res.data.expires_time); |
||||
}else if (this.loginType == 3){ |
} |
||||
//学生 |
} |
||||
let params = { |
|
||||
'phone': this.user, |
uni.showToast({ |
||||
'password': this.password1, |
title:'登录成功', |
||||
'login_type': 2, |
icon: 'success' |
||||
'mini_wx_openid':this.mini_wx_openid,//微信小程序openid |
}); |
||||
} |
|
||||
res = await apiRoute.xy_login(params) |
} else { |
||||
} |
uni.showToast({ |
||||
|
title: res || '登录失败', |
||||
if(!res.code){ |
icon: 'none' |
||||
uni.showToast({ |
}); |
||||
title: res.msg, |
} |
||||
icon: 'none' |
} catch (error) { |
||||
}) |
console.error('登录失败:', error); |
||||
return |
uni.showToast({ |
||||
} |
title: error || '登录失败,请重试', |
||||
uni.setStorageSync('expires_time', res.data.expires_time);//token过期时间 |
icon: 'none' |
||||
uni.setStorageSync('token', res.data.token); |
}); |
||||
let userType = res.data.user_type |
} |
||||
console.log('用户类型', userType) |
}, |
||||
uni.setStorageSync('userType', userType); |
|
||||
uni.setStorageSync('tabBerIndex', 0); |
//获取微信小程序openid |
||||
|
// 获取微信登录 code 并请求 openid |
||||
let url_path = '' |
async getMiNiWxOpenId() { |
||||
switch (String(userType)) { |
uni.login({ |
||||
case '1': //教练 |
provider: 'weixin', |
||||
url_path = '/pages/coach/home/index' |
success: (res) => { |
||||
break; |
const code = res.code; |
||||
case '2': //销售 |
this.fetchOpenId(code); // 调用单独方法 |
||||
url_path = '/pages/market/index/index' |
}, |
||||
break; |
fail: () => { |
||||
case '3': //学员 |
uni.showToast({ |
||||
url_path = '/pages/student/index/index' |
title: '微信登录失败', |
||||
break; |
icon: 'none' |
||||
default: |
}); |
||||
uni.showToast({ |
} |
||||
title: '用户类型错误', |
}); |
||||
icon: 'none' |
}, |
||||
}) |
// 获取微信登录 code 并请求 openid |
||||
return; |
async fetchOpenId(code) { |
||||
} |
let params = { |
||||
this.$navigateTo({ |
code: code, |
||||
url: url_path |
} |
||||
}) |
let res = await apiRoute.common_getMiniWxOpenId(params) |
||||
}, |
if (res.code != 1) { |
||||
|
uni.showToast({ |
||||
//获取微信小程序openid |
title: res.msg, |
||||
// 获取微信登录 code 并请求 openid |
icon: 'none' |
||||
async getMiNiWxOpenId() { |
}) |
||||
uni.login({ |
return |
||||
provider: 'weixin', |
} |
||||
success: (res) => { |
this.mini_wx_openid = res.data.openid |
||||
const code = res.code; |
}, |
||||
this.fetchOpenId(code); // 调用单独方法 |
|
||||
}, |
//登录类型选择相关 |
||||
fail: () => { |
changePicker_loginType(e) { |
||||
uni.showToast({ title: '微信登录失败', icon: 'none' }); |
console.log('监听选择', e) |
||||
} |
this.loginType = e.value |
||||
}); |
this.loginType_str = e.text |
||||
}, |
this.picker_show_loginType = false |
||||
// 获取微信登录 code 并请求 openid |
|
||||
async fetchOpenId(code){ |
//@todo 上线时请删除这个判断 |
||||
let params = { |
if (this.loginType == 1) { |
||||
code: code, |
//教师端 |
||||
} |
this.user = '15374889135' //账户 |
||||
let res = await apiRoute.common_getMiniWxOpenId(params) |
this.password1 = '15374889135' //密码 |
||||
if (res.code != 1){ |
} else if (this.loginType == 2) { |
||||
uni.showToast({ |
//销售端 |
||||
title: res.msg, |
this.user = '15148228108' //账户 |
||||
icon: 'none' |
this.password1 = '123123' //密码 |
||||
}) |
} else { |
||||
return |
//学生端 |
||||
} |
this.user = '13042409890' //账户 |
||||
this.mini_wx_openid = res.data.openid |
this.password1 = '13042409890' //密码 |
||||
}, |
} |
||||
|
|
||||
//登录类型选择相关 |
}, |
||||
changePicker_loginType(e){ |
|
||||
console.log('监听选择', e) |
//检测首页是否正确跳转-不正确则进行重定向 |
||||
this.loginType = e.value |
async openViewHome() { |
||||
this.loginType_str = e.text |
const userType = String(uni.getStorageSync('userType') || ''); |
||||
this.picker_show_loginType = false |
const token = uni.getStorageSync('token') || '' |
||||
|
|
||||
//@todo 上线时请删除这个判断 |
if (!userType || !token) { |
||||
if(this.loginType == 1){ |
return |
||||
//教师端 |
} |
||||
this.user= '15374889135' //账户 |
|
||||
this.password1= '15374889135' //密码 |
const pages = getCurrentPages(); |
||||
}else if(this.loginType == 2){ |
const currentPage = pages[pages.length - 1]; |
||||
//销售端 |
const thisPath = '/' + currentPage.route; |
||||
this.user= '15148228108' //账户 |
|
||||
this.password1= '123123' //密码 |
|
||||
}else{ |
const openPath = this.path_arr[userType]; |
||||
//学生端 |
|
||||
this.user= '13042409890' //账户 |
console.log('当前路径:', thisPath); |
||||
this.password1= '13042409890' //密码 |
console.log('用户类型:', userType); |
||||
} |
console.log('应跳转路径:', openPath); |
||||
|
|
||||
}, |
if (thisPath !== openPath) { |
||||
|
// 如果不是正确的首页路径,则跳转到对应角色首页 |
||||
//检测首页是否正确跳转-不正确则进行重定向 |
uni.setStorageSync('tabBerIndex', 0) |
||||
async openViewHome() { |
|
||||
const userType = String(uni.getStorageSync('userType') || ''); |
// 使用 redirectTo 替代 navigateTo,避免页面栈堆积 |
||||
const token = uni.getStorageSync('token') || '' |
uni.redirectTo({ |
||||
|
url: openPath, |
||||
if(!userType || !token){ |
complete(e) { |
||||
return |
console.log(e) |
||||
} |
} |
||||
|
}); |
||||
const pages = getCurrentPages(); |
return |
||||
const currentPage = pages[pages.length - 1]; |
} |
||||
const thisPath = '/' + currentPage.route; |
// 如果是正确的路径,交给 onShow 控制初始化 |
||||
|
}, |
||||
|
} |
||||
const openPath = this.path_arr[userType]; |
} |
||||
|
|
||||
console.log('当前路径:', thisPath); |
|
||||
console.log('用户类型:', userType); |
|
||||
console.log('应跳转路径:', openPath); |
|
||||
|
|
||||
if (thisPath !== openPath) { |
|
||||
// 如果不是正确的首页路径,则跳转到对应角色首页 |
|
||||
uni.setStorageSync('tabBerIndex', 0) |
|
||||
|
|
||||
// 使用 redirectTo 替代 navigateTo,避免页面栈堆积 |
|
||||
uni.redirectTo({ |
|
||||
url: openPath, |
|
||||
complete(e) { |
|
||||
console.log(e) |
|
||||
} |
|
||||
}); |
|
||||
return |
|
||||
} |
|
||||
// 如果是正确的路径,交给 onShow 控制初始化 |
|
||||
}, |
|
||||
} |
|
||||
} |
|
||||
</script> |
</script> |
||||
|
|
||||
<style lang="less" scoped> |
<style lang="less" scoped> |
||||
page { |
page { |
||||
font-weight: normal; |
font-weight: normal; |
||||
} |
} |
||||
|
|
||||
.fui-section__title { |
.fui-section__title { |
||||
margin-left: 32rpx; |
margin-left: 32rpx; |
||||
} |
} |
||||
|
|
||||
.fui-left__icon { |
.fui-left__icon { |
||||
padding-right: 24rpx; |
padding-right: 24rpx; |
||||
} |
} |
||||
|
|
||||
.image-container { |
.image-container { |
||||
margin: auto; |
margin: auto; |
||||
position: relative; |
position: relative; |
||||
width: 150rpx; |
width: 150rpx; |
||||
/* 设置与第一张图片相同的宽度 */ |
/* 设置与第一张图片相同的宽度 */ |
||||
height: 150rpx; |
height: 150rpx; |
||||
/* 设置与第一张图片相同的高度 */ |
/* 设置与第一张图片相同的高度 */ |
||||
} |
} |
||||
|
|
||||
.base-image { |
.base-image { |
||||
width: 100%; |
width: 100%; |
||||
height: 100%; |
height: 100%; |
||||
} |
} |
||||
|
|
||||
.overlay-image { |
.overlay-image { |
||||
position: absolute; |
position: absolute; |
||||
top: 50%; |
top: 50%; |
||||
left: 50%; |
left: 50%; |
||||
transform: translate(-50%, -50%); |
transform: translate(-50%, -50%); |
||||
width: 100rpx; |
width: 100rpx; |
||||
height: 100rpx; |
height: 100rpx; |
||||
} |
} |
||||
</style> |
</style> |
||||
Loading…
Reference in new issue