diff --git a/src/components/author_modal/author_modal.vue b/src/components/author_modal/author_modal.vue
new file mode 100644
index 0000000..4fc281a
--- /dev/null
+++ b/src/components/author_modal/author_modal.vue
@@ -0,0 +1,184 @@
+
+
+
+ 微信授权
+ 您的信息和数据将受到保护
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/pages.json b/src/pages.json
index 72a67ad..762916e 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -4,6 +4,15 @@
{
"path": "pages/index/index",
"style": {
+ "mp-weixin": {
+ "navigationStyle": "custom"
+ }
+ }
+ },
+ {
+ "path": "pages/login_and_bind/login_and_bind",
+ "style": {
+ "navigationBarTitleText": "登录"
}
},
{
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 1d05548..790d392 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -1,5 +1,8 @@
+
+
+
-
-
- 微信授权
- 您的信息和数据将受到保护
-
-
-
+ 授权并登录
-
-
-
-
-
+ >
+
轻触头像切换账号
@@ -98,87 +83,29 @@
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: '/pages/collection/record/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/search_result/search_result',
- 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
- }
- ];
-
+ import author_modal from '../../components/author_modal/author_modal.vue'
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
export default {
+ components: {
+ 'author-modal': author_modal
+ },
computed: {
isProfile: _=>util.isProfile(),
- // loginStatus(){
- // return app.isLogin();
- // }
+ customBarStyle(){
+ let { customBarInfo } = this;
+ return `height: ${customBarInfo.height}px;`
+ }
},
data() {
return {
- tabList,
+ tabList: tabList(),
isShowAuthorModal: false,
indexData: {},
loginStatus: false,
+ customBarInfo: {},
}
},
async onLoad() {
@@ -199,12 +126,44 @@
// #endif
},
onShow(){
+ this.initCustomBarInfo();
// #ifndef H5
let { indexData } = this;
if(JSON.stringify(indexData)!='{}'&&!!app.isLogin())this.getIndexInfo();
// #endif
},
methods: {
+ // 初始化状态栏信息
+ initCustomBarInfo(){
+ let _timer = null; // 防止小程序api未初始化完成
+ const sysInfo = uni.getSystemInfoSync();
+ const capsuleInfo = uni.getMenuButtonBoundingClientRect();
+ // const capsuleInfo = null;
+ let _data = {
+ statusBarHeight: sysInfo.statusBarHeight,
+ capsuleInfo,
+ }
+ clearTimeout(_timer);
+ _timer = null;
+ if(capsuleInfo&&capsuleInfo.top&&capsuleInfo.bottom){
+ _data[ 'height' ] = capsuleInfo.bottom + capsuleInfo.top - sysInfo.statusBarHeight + 4;
+ }else{
+ _timer = setTimeout(_=>this.initCustomBarInfo(),700); // 防止小程序api未初始化完成
+ _data[ 'height' ] = sysInfo.statusBarHeight + 50;
+ }
+ this.customBarInfo = _data;
+ },
+ authorCancel(){
+ this.closeAuthor();
+ },
+ authorFail(){
+ this.closeAuthor();
+ },
+ authorSuccess(){
+ this.getIndexInfo();
+ this.closeAuthor();
+ this.loginStatus = app.isLogin();
+ },
toNoticeList(){
if(!app.isLogin())return this.showAuthor();
util.routeTo(`/pages/message/list/list`,'nT');
@@ -218,7 +177,6 @@
if(!_permission[tabInfo.serverKey])return util.showNone('暂无权限,请联系管理员开启!')
util.routeTo(tabInfo.path,'nT');
},
-
getIndexInfo(){
servers.get({
url: API.calc,
@@ -248,12 +206,13 @@
let _data = res.data;
if(_data.code == 0){
// let _data = res.data.data;
+
if(_data.data == ''){
uni.removeStorageSync('token');
this.loginStatus = app.isLogin();
return util.routeTo(`/pages/login/login`,'rL');
}
- uni.setStorageSync('token',_data.data);
+ uni.setStorageSync('token', _data.data);
return _data;
}else{
util.showNone(_data.message || '校验身份失败!');
@@ -274,81 +233,6 @@
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)
-
- },
toStoreList(){
if(!app.isLogin())return this.showAuthor();
@@ -357,10 +241,75 @@
},
}
}
+
+ function tabList(){
+ return [
+ {
+ id: 0,
+ name: '营业额',
+ path: '/pages/turnover/turnover',
+ serverKey: 1001 // 后端对应权限编号
+ },
+ {
+ id: 1,
+ name: '收款记录',
+ path: '/pages/collection/record/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/search_result/search_result',
+ 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
+ }
+ ];
+ }
\ No newline at end of file