Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wx-boss
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姜雷
wx-boss
Commits
ec2f9691
Commit
ec2f9691
authored
Dec 31, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into test
parents
8296f540
5ed10c4b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
79 deletions
+97
-79
index.js
miniprogram/pages/index/index.js
+0
-0
index.ts
miniprogram/pages/index/index.ts
+97
-79
No files found.
miniprogram/pages/index/index.js
View file @
ec2f9691
This diff is collapsed.
Click to expand it.
miniprogram/pages/index/index.ts
View file @
ec2f9691
...
...
@@ -107,92 +107,110 @@ Page({
if
(
this
.
validateLoginData
())
{
const
{
account
,
pwd
}
=
this
.
data
;
console
.
log
(
account
,
pwd
);
wx
.
requestSubscribeMessage
({
tmplIds
:
[
'WU2yMHKM_yNPLGHRsstggnnGIgcRgDEIaJQiWWNJ9ss'
],
success
(
res
)
{
console
.
log
(
'in success'
,
res
);
},
fail
(
res
)
{
console
.
log
(
'in fail'
,
res
);
},
complete
(
res
)
{
console
.
log
(
'in complete'
,
res
);
wx
.
login
({
success
:
res
=>
{
if
(
res
.
code
)
{
const
code
=
res
.
code
;
wx
.
showLoading
({
title
:
''
});
systemFetch
({
url
:
'/login/verifyCode'
,
})
.
then
((
res
:
wx
.
RequestSuccessCallbackResult
)
=>
{
console
.
log
(
res
);
return
{
verifyCode
:
res
.
data
.
verifyCode
,
cookie
:
res
.
header
[
'Set-Cookie'
],
};
})
.
then
(
({
verifyCode
,
cookie
,
}:
{
verifyCode
:
string
;
cookie
:
string
;
})
=>
{
let
mixpwd
=
md5
(
pwd
);
return
systemFetch
({
url
:
'/boss/login'
,
method
:
'POST'
,
header
:
{
cookie
:
cookie
,
},
data
:
{
code
,
account
,
pwd
:
mixpwd
,
varifyCode
:
verifyCode
,
systemFetch
({
url
:
'/boss/login/init/data'
,
method
:
'GET'
,
})
.
then
(
res
=>
{
console
.
log
(
res
);
return
res
.
templates
;
})
.
catch
(
err
=>
{
return
;
})
.
then
(
ids
=>
{
let
tmplIds
=
ids
&&
ids
.
length
?
ids
.
map
(
item
=>
item
.
templateId
)
:
[];
wx
.
requestSubscribeMessage
({
tmplIds
:
tmplIds
,
success
(
res
)
{
console
.
log
(
'in success'
,
res
);
},
fail
(
res
)
{
console
.
log
(
'in fail'
,
res
);
},
complete
(
res
)
{
console
.
log
(
'in complete'
,
res
);
wx
.
login
({
success
:
res
=>
{
if
(
res
.
code
)
{
const
code
=
res
.
code
;
wx
.
showLoading
({
title
:
''
});
systemFetch
({
url
:
'/login/verifyCode'
,
})
.
then
((
res
:
wx
.
RequestSuccessCallbackResult
)
=>
{
console
.
log
(
res
);
return
{
verifyCode
:
res
.
data
.
verifyCode
,
cookie
:
res
.
header
[
'Set-Cookie'
],
};
})
.
then
(
({
verifyCode
,
cookie
,
}:
{
verifyCode
:
string
;
cookie
:
string
;
})
=>
{
let
mixpwd
=
md5
(
pwd
);
return
systemFetch
({
url
:
'/boss/login'
,
method
:
'POST'
,
header
:
{
cookie
:
cookie
,
},
data
:
{
code
,
account
,
pwd
:
mixpwd
,
varifyCode
:
verifyCode
,
},
});
},
)
.
then
(
res
=>
{
console
.
log
(
res
);
const
{
token
,
data
:
{
userInfo
,
userRoles
},
}
=
res
;
app
.
globalData
.
token
=
token
;
app
.
globalData
.
userInfo
=
userInfo
;
app
.
globalData
.
userRoles
=
userRoles
.
length
?
userRoles
[
0
].
childs
:
[];
try
{
wx
.
setStorageSync
(
'token'
,
token
);
}
catch
(
error
)
{}
wx
.
hideLoading
();
wx
.
redirectTo
({
url
:
'/pages/homeAndReport/homeAndReport'
,
});
})
.
catch
(
err
=>
{
console
.
log
(
err
);
wx
.
hideLoading
();
wx
.
showToast
({
title
:
err
.
errMsg
,
icon
:
'none'
,
});
});
},
)
.
then
(
res
=>
{
console
.
log
(
res
);
const
{
token
,
data
:
{
userInfo
,
userRoles
},
}
=
res
;
app
.
globalData
.
token
=
token
;
app
.
globalData
.
userInfo
=
userInfo
;
app
.
globalData
.
userRoles
=
userRoles
.
length
?
userRoles
[
0
].
childs
:
[];
try
{
wx
.
setStorageSync
(
'token'
,
token
);
}
catch
(
error
)
{}
wx
.
hideLoading
();
wx
.
redirectTo
({
url
:
'/pages/homeAndReport/homeAndReport'
,
});
})
.
catch
(
err
=>
{
console
.
log
(
err
);
wx
.
hideLoading
();
}
else
{
wx
.
showToast
({
title
:
err
.
errMsg
,
title
:
'登录获取code失败'
,
icon
:
'none'
,
});
});
}
else
{
wx
.
showToast
({
title
:
'登录获取code失败'
,
icon
:
'none'
,
});
}
}
},
});
},
});
},
});
})
.
catch
(
err
=>
{
console
.
log
(
err
);
});
}
// fetch()
// wx.redirectTo({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment