You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

765 lines
19 KiB

<template>
<view class="index-container">
<view class="ic-content">
<view class="ic-header">
<view class="ih-address" v-if="loginStatus" @click="toStoreList">
<view>{{indexData.brand_name || '-'}}(共{{indexData.stadium_num || '0'}}家)</view>
<image src="/static/images/icon/arrow_ff.png" mode="aspectFit"></image>
</view>
<view v-else class="ih-btn" hover-class="hover-active" @click="showAuthor">点击登陆</view>
<block v-if="isPermissionShowTab({ serverKey: 1001 })">
<view class="ih-tip">今日总收入</view>
<view class="ih-price"><text>{{loginStatus?'¥':''}}</text>{{loginStatus?(indexData.amount || '0'):'***'}}</view>
<view class="ih-amount">
<view>
<view>收款笔数</view>
<view>{{loginStatus?(indexData.in_count || '0'):'**'}}</view>
</view>
<view>
<view>退款笔数</view>
<view>{{loginStatus?(indexData.out_count || '0'):'**'}}</view>
</view>
</view>
</block>
<image class="ih-bg-icon" style="left: 0;" mode="aspectFit" src="/static/images/icon/index/header_bg_a.png"></image>
<image class="ih-bg-icon" mode="aspectFit" src="/static/images/icon/index/header_bg_b.png"></image>
</view>
<view class="ic-notice" @click="toNoticeList">
<view class="in-left">
<image src="/static/images/icon/index/notice.png" mode="aspectFit"></image>
<text>消息中心</text>
</view>
<view class="in-right">
<view v-if="indexData.message_count>0">{{indexData.message_count || '0'}}</view>
<image src="/static/images/icon/arrow_b2.png" mode="aspectFit"></image>
</view>
</view>
</view>
<view class="ic-tabs" v-if="indexData&&indexData.permission">
<block v-for="(e, i) in tabList" :key="i">
<view class="it-item" @click="toPageInfo(e)" v-if="isPermissionShowTab(e)">
<view>
<image mode="aspectFit" :src="'/static/images/icon/index/tab_'+ e.id + '.png'"></image>
<view>{{e.name}}</view>
</view>
</view>
</block>
<!-- <view class="hold-place-blank">
<navigator url="/subpackage/party/pages/index/index">party/pages/index/index</navigator>
<navigator url="/subpackage/party/pages/login/login">party/pages/login/login</navigator>
</view> -->
</view>
<view class="ox-dark-mask" v-if="isShowAuthorModal">
<view class="ic-author-modal">
<view class="iam-title">微信授权</view>
<view class="iam-tip">您的信息和数据将受到保护</view>
<image class="iam-pic" mode="aspectFit" src="/static/images/icon/author_modal.png"></image>
<view class="iam-btns">
<button plain hover-class="hover-active" @click="cancelAuthor">取消</button>
<button
v-if="isProfile"
plain
hover-class="hover-active"
@click="profileConfirm"
>授权并登录</button>
<button
v-else
plain
hover-class="hover-active"
open-type="getUserInfo"
lang="zh_CN"
@getuserinfo="confirmAuthor"
>授权并登录</button>
</view>
</view>
</view>
<view class="fly_btn" @click="toPageInfo(tabList[4])" v-if="loginStatus">
<image class="f_bg" src="/static/images/icon/index/green_bg_circle.png" mode="scaleToFill"/>
<image class="f_icon" src="/static/images/icon/index/scan_icon_white.png" mode="scaleToFill"/>
<text>核销</text>
</view>
</view>
</template>
<script>
import util from '../../utils/util';
import { servers } from '../../js/server';
import { API } from '../../js/api';
const tabList = [
{
id: 0,
name: '收入统计',
path: '/pages/turnover/turnover',
serverKey: 1001 // 后端对应权限编号
},
{
id: 1,
name: '收款记录',
path: '/subpackage/income/pages/details_record/details_record',
serverKey: 1002 // 后端对应权限编号
},
{
id: 2,
name: '订单管理',
path: '/subpackage/order/pages/order_manage/order_manage',
serverKey: 1012 // 后端对应权限编号
},
{
id: 3,
name: '员工管理',
path: '/pages/employee/manage/manage',
serverKey: 1007 // 后端对应权限编号
},
{
id: 4,
name: '核销查询',
path: '/pages/write_off/menu/menu',
serverKey: 1008 // 后端对应权限编号
},
{
id: 5,
name: '场地看板',
// path: '/pages/site/order_list/order_list', // 20210804 不要占用列表
path: '/pages/site/manage/manage',
serverKey: 1009 // 后端对应权限编号
},
{
id: 6,
name: '设备管理',
path: '/subpackage/device/pages/index/index',
serverKey: 1010 // 后端对应权限编号
},
{
id: 7,
name: '商品零售',
path: '/subpackage/retail/pages/index/index',
serverKey: 1011 // 后端对应权限编号
},
// {
// id: 8,
// name: '课程管理',
// path: '/subpackage/course/pages/index/index',
// serverKey: 1013 // 后端对应权限编号 1013
// },
{
id: 9,
name: '储值卡管理',
path: '/pages/order_list/order_list?order_type=18',
serverKey: 1014 // 后端对应权限编号 1014
},
{
id: 10,
name: '进场人数异常',
path: '/subpackage/blacklist/pages/abnormal_list/abnormal_list',
serverKey: 1015 // 后端对应权限编号 1015
},
{
id: 11,
name: '钱包提现',
path: '/subpackage/wallet/pages/index/index',
serverKey: 1017 // 后端对应权限编号 1017
},
{//需求要求更改ICON位置
id: 12,
name: '系统工具',
path: '/subpackage/party/pages/index/index',
serverKey: 1016 // 后端对应权限编号 1016
},
];
const app = getApp();
// #ifndef H5
const uniGetSetting = util.promisify(uni.getSetting);
const uniLogin = util.promisify(uni.login);
const uniGetUserInfo= util.promisify(uni.getUserInfo);
const APPID = uni.getAccountInfoSync().miniProgram.appId;
// #endif
// #ifdef H5
const APPID = "wx7106e84614cf0060" //TODO
// #endif
export default {
computed: {
isProfile: _=>util.isProfile(),
// loginStatus(){
// return app.isLogin();
// }
},
data() {
return {
tabList,
isShowAuthorModal: false,
indexData: {},
loginStatus: false,
}
},
async onLoad(options) {
try{
util.showLoad();
// 20230829 新增平台账户不绑定,不检验,每次进来走重新登陆绑定流程
if(options.role !== 'ADMIN-PLATFORM')await this.checkUserAuthor();
util.hideLoad();
this.loginStatus = app.isLogin();
if(!!app.isLogin())this.getIndexInfo();
}catch(err){
util.hideLoad();
uni.removeStorageSync('token');
// util.showNone(err.message || '身份校验失败!');
console.log('onLoad err',err);
this.loginStatus = app.isLogin();
}
},
onShow(){
let { indexData } = this;
if(JSON.stringify(indexData)!='{}'&&!!app.isLogin())this.getIndexInfo();
},
methods: {
// 账号有开启了权限的才显示菜单,否则不显示【ID1000840】
isPermissionShowTab(e){
let { indexData } = this;
if(indexData&&Object.prototype.toString.call(indexData.permission) === '[object Object]'){
return indexData.permission[e.serverKey]
}
return false;
},
toNoticeList(){
if(!app.isLogin())return this.showAuthor();
util.routeTo(`/pages/message/list/list`,'nT');
},
toPageInfo(tabInfo){
let { indexData } = this;
let _permission = indexData.permission || {};
if(!app.isLogin())return this.showAuthor();
if(!tabInfo.path)return util.showNone('暂未开放!');
//if(tabInfo.id == 2)return util.routeTo(tabInfo.path,'nT'); //测试
if(!_permission[tabInfo.serverKey])return util.showNone('暂无权限,请联系管理员开启!')
if(tabInfo.id === 1){
util.$_emit('turnoverToDetailsRecord', {
stadiumInfo: null,
brandInfo: indexData&&indexData.brand ? indexData.brand : null,
});
}
if(tabInfo.id === 10 || tabInfo.id === 11)return util.routeTo(tabInfo.path + `?brand_id=${indexData.brand.id}`,'nT');
if(tabInfo.id === 12){
// if(!indexData.brand.mini_wechat_appid)return util.showNone('暂无appid!')
let url = tabInfo.path + `?appid=${indexData.brand.mini_wechat_appid}`
console.log(222,url)
return util.routeTo(url,'nT');
}
util.routeTo(tabInfo.path,'nT');
},
getIndexInfo(){
servers.get({
url: API.calc,
data: {},
failMsg: '加载数据失败!'
})
.then(res=>{
this.indexData = res;
this.$store.commit('setBrandInfo',res);
})
},
// 看是否授权,清除token
async checkUserAuthor(){
try{
let loginRes =""
// #ifndef H5
loginRes = await uniLogin();
// #endif
// #ifdef H5
loginRes = {errMsg: "login:ok", code: "0c3xEi0w3kr1t23zcU3w3ZQR3w3xEi0h"} //TODO 设置H5测试数据
// #endif
console.log(loginRes)
return servers.get({
url: API.wechatMiniAppLoginAndSync,
data: {
code: loginRes.code,
appid: APPID,
// #ifdef H5
token:"3d2b0092-e761-11ee-8a66-5254005df464", //TODO
// #endif
},
isDefaultGet: false,
})
.then(res=>{
util.hideLoad();
let _data = res.data;
if(_data.code == 0){
// let _data = res.data.data;
if(_data.data == ''){
uni.removeStorageSync('token');
this.loginStatus = app.isLogin();
// 20240325 新增openid绑定账号检测
this.webBrandUserCheck();
// return util.routeTo(`/pages/login/login`,'rL');
}
uni.setStorageSync('token',_data.data);
return _data;
}else{
util.showNone(_data.message || '校验身份失败!');
throw res.data || {};
}
})
.catch(err=>{
throw err;
})
}catch(err){
throw err;
}
},
showAuthor(){
this.isShowAuthorModal = true
},
closeAuthor(){
this.isShowAuthorModal = false
},
cancelAuthor(){
this.closeAuthor();
},
getLoginQuery({
userInfo,
loginRes
}){
return {
appid: APPID,
code: loginRes.code,
encryptedData: userInfo.encryptedData,
// is_details: 1,
// 后端解密错误,直接传用户信息
user_info: userInfo.userInfo,
user_raw_data: userInfo.rawData,
...userInfo.userInfo,
}
},
// 新获取用户信息
profileConfirm(){
uni.getUserProfile({
lang: 'zh_CN', desc: '授权登陆',
success: res => {
this.confirmAuthor({detail: {...res}});
},
fail: function(err) {
util.showNone('获取用户信息失败!请重试');
console.warn('getUserProfile Err', err)
}
})
},
async confirmAuthor(userRes){
if(!userRes.detail.userInfo){
this.closeAuthor();
return util.showNone('获取用户信息失败!请稍后重试');
}
let loginRes = await uniLogin();
if(!loginRes.code){
this.closeAuthor();
return util.showNone('获取登陆凭证失败!稍后重试');
}
servers.post({
url: API.wechatMiniAppLoginAndSync,
data: this.getLoginQuery({
userInfo: userRes.detail,
loginRes
}),
isDefaultGet: false,
})
.then(res=>{
util.hideLoad();
let _data = res.data || {};
if(_data.code == 0){
if(_data.data == '')return util.routeTo(`/pages/login/login`,'rL');
util.showNone(_data.message || '登陆成功!');
// let _data = res.data.data;
// if(_data.user.role == '')return util.routeTo(`/pages/merchant_login/merchant_login`,'rL');
uni.setStorageSync('token',_data.data);
setTimeout(_=>{
this.getIndexInfo();
this.closeAuthor();
this.loginStatus = app.isLogin();
}, 1200);
}else{
util.showNone(_data.message || '后台登陆失败!');
setTimeout(_=>this.closeAuthor(), 1200);
}
}).catch(util.hideLoad)
},
webBrandUserCheck(){
// return this.webUserGet();
console.warn('webBrandUserCheck')
let token = uni.getStorageSync('token');
let token_web = uni.getStorageSync('token_web');
let _data = {
token: token||"",
token_web: token_web||"",
}
return servers.get({
url: API['party'].webBrandUser,
data: _data,
failMsg: '加载数据失败!'
})
.then(res=>{
console.log('webBrandUserCheck',res)
// if(!res.had_binding){
// console.warn('webBrandUser 验证绑定账号失败!');
// return util.routeTo(`/pages/login/login`,'rL');
// }else{
//status: 1创建品牌 2实名认证 3审核成功 4审核失败 5完成 6修改审核中???待定
console.warn(res,'webBrandUserCheck success',res.status);
if(res.status==0&&token_web){
return util.routeTo(`/subpackage/party/pages/login/regist`,'rL');
}else if(res.status==1){
return util.routeTo(`/subpackage/party/pages/login/reviewing`,'rL');
}else if(res.status==2){
return util.routeTo(`/subpackage/party/pages/login/reviewing`,'rL');
}else if(res.status==5){
//完成 小程序端执行绑定
this.bindUserOpenid();
}
// return res;
// }
}).catch(err=>{
console.warn('webBrandUserCheck err',err)
util.routeTo(`/pages/login/login`,'rL');
})
},
toStoreList(){
if(!app.isLogin())return this.showAuthor();
let { indexData } = this;
util.routeTo(`/pages/store_list/store_list?brand_id=${indexData.brand.id}`,'nT');
},
bindUserOpenid(){
let token_web = uni.getStorageSync('token_web');
let _data = {
token_web: token_web||"",
}
return servers.post({
url: API['party'].bindingOpenId,
data: _data,
failMsg: '绑定失败!'
})
.then(res=>{
console.log('小程序端绑定bindUserOpenid',res)
if(res.msg=="success"){
util.showNone('绑定成功!');
util.routeTo(`/pages/index/index`,'rL');
}else{
util.showNone(res.message || '绑定失败!');
}
}).catch(err=>{
console.warn('bindUserOpenid err',err)
util.showNone(err.message || '绑定失败!');
// util.routeTo(`/subpackage/party/pages/login/reviewing`,'rL');
util.routeTo(`/pages/login/login`,'rL');
})
},
webUserGet(){
let token_web = uni.getStorageSync('token_web');
let _data = {
token_web: token_web||"",
}
return servers.post({
url: API['party'].webUserGet,
data: _data,
failMsg: '获取信息失败!'
})
.then(res=>{
console.log('webUserGet:',res)
if(res.code==0){
}else{
util.showNone(res.message || '失败!');
}
}).catch(err=>{
console.warn('bindUserOpenid err',err)
util.showNone(err.message || '获取信息失败!');
})
},
}
}
</script>
<style lang="scss" scoped>
@import "~style/public.scss";
.index-container{
position: relative;
}
.ic-content{
padding: 24upx;
}
.ic-header{
position: relative;
height: auto;
margin-bottom: 24upx;
padding: 38upx 24upx 30upx;
border-radius: 14upx;
background-color: $themeColor;
overflow: hidden;
.ih-address{
margin-bottom: 26upx;
@include centerFlex(center);
>view{
max-width: 90%;
line-height: 50upx;
text-align: center;
font-size: 36upx;
color: #fff;
@include textHide(1);
}
>image{
flex-shrink: 0;
margin-left: 20upx;
width: 28upx;
height: 28upx;
}
}
.ih-btn{
margin: 0 auto 28upx;
width: 160upx;
height: 48upx;
text-align: center;
line-height: 48upx;
font-size: 28upx;
color: $themeColor;
background-color: #fff;
border-radius: 24upx;
}
.ih-tip{
margin-bottom: 8upx;
line-height: 40upx;
text-align: center;
font-size: 28upx;
color: rgba($color: #fff, $alpha: .7);
}
.ih-price{
margin-bottom: 50upx;
line-height: 96upx;
text-align: center;
font-size: 84upx;
font-weight: 500;
color: #fff;
@include textHide(1);
>text{
line-height: 74upx;
font-size: 64upx;
}
}
.ih-amount{
@include centerFlex(space-around);
>view{
>view{
&:first-child{
margin-bottom: 16upx;
line-height: 40upx;
text-align: center;
font-size: 28upx;
color: rgba($color: #fff, $alpha: .7);
}
&+view{
line-height: 56upx;
text-align: center;
font-size: 40upx;
font-weight: 500;
color: #fff;
}
}
}
}
.ih-bg-icon{
position: absolute;
top: 0;
width: 120upx;
height: 142upx;
&+.ih-bg-icon{
right: 0;
top: 38upx;
width: 240upx;
height: 400upx;
}
}
}
.ic-notice{
padding: 0 24upx;
height: 108upx;
border-radius: 10upx;
background-color: #fff;
@include centerFlex(space-between);
.in-left{
>image{
vertical-align: middle;
margin-right: 10upx;
width: 52upx;
height: 50upx;
}
>text{
font-size: 28upx;
line-height: 40upx;
color: #1a1a1a;
}
}
.in-right{
@include centerFlex(flex-end);
>view{
margin-right: 14upx;
line-height: 50upx;
text-align: center;
width: 50upx;
height: 50upx;
line-height: 50upx;
font-size: 24upx;
border-radius: 50%;
color: #fff;
background-color: #ea5061;
@include textHide(1);
}
>image{
width: 28upx;
height: 28upx;
}
}
}
.ic-tabs{
display: flex;
flex-wrap: wrap;
padding: 0upx 14upx 12upx;
margin-top: -12upx;
.it-item{
flex-shrink: 0;
width: 33.33%;
padding: 12upx;
>view{
padding: 40upx 10upx 0;
height: 218upx;
border-radius: 10upx;
background-color: #fff;
>image{
display: block;
margin: 0 auto 20upx;
width: 52upx;
height: 52upx;
}
>view{
text-align: center;
line-height: 40upx;
font-size: 28upx;
color: #1a1a1a;
@include textHide(1);
}
}
}
}
.ic-author-modal{
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
padding-top: 60upx;
width: 662upx;
height: 884upx;
border-radius: 10upx;
background-color: #fff;
.iam-title{
margin-bottom: 22upx;
text-align: center;
line-height: 60upx;
font-size: 44upx;
font-weight: 500;
color: #1a1a1a;
}
.iam-tip{
margin-bottom: 52upx;
line-height: 40upx;
text-align: center;
font-size: 28upx;
color: #9c9c9f;
}
.iam-pic{
margin: 0 auto 62upx;
display: block;
width: 488upx;
height: 416upx;
}
.iam-btns{
@include centerFlex(center);
>button{
margin: 0 20upx;
width: 240upx;
height: 92upx;
line-height: 88upx;
text-align: center;
border-radius: 46upx;
border: 2upx solid $themeColor;
font-size: 32upx;
color: $themeColor;
&+button{
background-color: $themeColor;
color: #fff;
}
}
}
}
// fly_btn
.fly_btn{
position: fixed;
bottom: 100rpx;
right: 80rpx;
@include centerFlex(center);
flex-direction: column;
.f_bg{
position: absolute;
width: 148upx;
height: 148upx;
}
.f_icon{
z-index: 3;
width: 40rpx;
height: 40rpx;
}
>text{
z-index: 3;
font-size: 20rpx;
color: #fff;
}
}
.hold-place-blank{
height:250rpx;
width: 1rpx;
}
</style>