Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
杨炀
/
ztx_wx_admin
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
023f830b
authored
2023-10-08 19:27:13 +0800
by
华明祺
1
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
登录
1 parent
79cf495e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
138 additions
and
245 deletions
App.vue
common/login.js
common/request.js
config.js
pages/index/login.vue
pages/index/order.vue
App.vue
View file @
023f830
<
script
>
import
*
as
loginServer
from
'@/common/login.js'
;
import
*
as
api
from
'@/common/api.js'
;
import
config
from
'@/config.js'
;
import
{
h5Login
}
from
'@/common/login.js'
;
import
*
as
api
from
'@/common/api.js'
;
import
config
from
'@/config.js'
;
let
loginUrl
=
[
'pages/index/login'
,
'pages/index/register'
]
let
firstload
=
false
export
default
{
onLaunch
:
function
(
options
)
{
console
.
log
(
'App Launch'
,
options
);
firstload
=
true
let
firstload
=
false
export
default
{
onLaunch
:
function
()
{
console
.
log
(
'App Launch'
);
firstload
=
true
this
.
globalData
.
baseUrl
=
config
.
baseUrl
;
this
.
globalData
.
baseUrl_api
=
config
.
baseUrl_api
;
this
.
globalData
.
fileUrl
=
config
.
fileUrl
;
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
checkSession
({
success
:
res
=>
{
loginServer
.
getCurrUser
(
true
)
.
catch
(()
=>
{
return
loginServer
.
pcLogin
();
})
.
then
(
user
=>
{
resolve
(
user
);
});
},
fail
:
res
=>
{
loginServer
.
wxLogin
()
.
then
(
loginRes
=>
{
return
loginServer
.
pcLogin
(
loginRes
.
code
);
})
.
then
(
user
=>
{
resolve
(
user
);
});
}
});
})
.
then
(()
=>
{
return
loginServer
.
getNowOpenId
()
})
.
then
(()
=>
{
return
loginServer
.
initData
()
// console.log(22222222)
// const currUser = uni.getStorageSync('currUser');
// // console.log(currUser)
// return Promise.all([api.getVenue(), api.getOwnMemberInfo()]).then(res => {
// let ven = res[0].data;
// let men = res[1]?.data;
// if (ven.venuePic) {
// ven.venuePicArr = ven.venuePic.split(',');
// }
// if (ven.businessPeriod) {
// ven.startBus = ven.businessPeriod.split(',')[0];
// ven.endBus = ven.businessPeriod.split(',')[1];
// }
// ven.latitude = ven.lal.split(',')[0];
// ven.longitude = ven.lal.split(',')[1];
// this.globalData.venue = ven;
// this.globalData.isVip = men?.isVip;
// // this.globalData.relateProjectId = men.info.relateProjectId;
// this.globalData.relateProjectIdList = men?.info?.relateProjectIdList;
// this.globalData.relateVenueProjectIdList = men?.info?.relateVenueProjectIdList;
// this.globalData.venueConfig = {
// normalOverDay: ven.resSiteConfig?.normalOrderNum,
// normalPeriodStart: ven.resSiteConfig?.normalOrderPeriod.split(',')[0],
// normalPeriodEnd: ven.resSiteConfig?.normalOrderPeriod.split(',')[1]
// };
// if (men?.isVip) {
// this.globalData.venueConfig.memberOverDay = ven.resSiteConfig?.memberOrderNum;
// this.globalData.venueConfig.memberPeriodStart = ven.resSiteConfig?.memberOrderPeriod.split(',')[0];
// this.globalData.venueConfig.memberPeriodEnd = ven.resSiteConfig?.memberOrderPeriod.split(',')[1];
// }
// });
})
.
then
(()
=>
{
this
.
globalData
.
isLogin
=
true
;
let
firstLoadCallback
=
getApp
().
firstLoadCallback
;
if
(
firstLoadCallback
)
{
firstLoadCallback
();
}
});
},
onShow
:
function
()
{
console
.
log
(
'App Show'
);
// loginServer.getNowOpenId()
if
(
!
firstload
)
{
loginServer
.
getCurrUser
(
true
)
.
catch
(()
=>
{
return
loginServer
.
pcLogin
().
then
(()
=>
{
uni
.
redirectTo
({
url
:
getCurrentPages
()[
getCurrentPages
().
length
-
1
].
$page
.
fullPath
})
});
})
}
},
onHide
:
function
()
{
console
.
log
(
'App Hide'
);
}
};
this
.
globalData
.
baseUrl_api
=
config
.
baseUrl_api
;
if
(
loginUrl
.
indexOf
(
options
.
path
)
==-
1
){
let
userName
=
uni
.
getStorageSync
(
'userName'
)
if
(
userName
)
{
h5Login
(
userName
)
.
then
(()
=>
{
this
.
globalData
.
isLogin
=
true
;
let
firstLoadCallback
=
getApp
().
firstLoadCallback
;
if
(
firstLoadCallback
)
{
firstLoadCallback
();
}
})
.
catch
(()
=>
{
uni
.
redirectTo
({
url
:
'/pages/index/login'
})
})
}
else
{
this
.
globalData
.
isLogin
=
false
;
uni
.
redirectTo
({
url
:
'/pages/index/login'
})
}
}
},
onShow
:
function
()
{
console
.
log
(
'App Show'
);
},
onHide
:
function
()
{
console
.
log
(
'App Hide'
);
}
};
</
script
>
<
style
lang=
"scss"
>
...
...
common/login.js
View file @
023f830
This diff is collapsed.
Click to expand it.
common/request.js
View file @
023f830
import
config
from
'@/config.js'
import
{
pcLogin
,
getNowOpenId
,
initData
h5LoginAuto
}
from
'./login'
const
excludeUrls
=
[
'
/system/wx/getUserInfo
'
]
const
excludeUrls
=
[
'
pages/index/login'
,
'pages/index/register
'
]
// 获取Token
function
getToken
()
{
try
{
const
token
=
uni
.
getStorageSync
(
'token'
);
if
(
token
)
{
return
token
}
else
{
return
''
}
}
catch
(
e
)
{
console
.
log
(
e
)
}
try
{
const
token
=
uni
.
getStorageSync
(
'token'
)
if
(
token
)
{
return
token
}
else
{
return
''
}
}
catch
(
e
)
{
console
.
log
(
e
)
}
}
// 获取请求头
function
getHeaders
()
{
le
t
token
=
getToken
()
le
t
header
=
{
"Authorization"
:
token
,
"Content-Type"
:
"application/json"
,
//
根据自己的数据类型
// "Content-Type":"application/x-www-form-urlencoded",
}
return
header
cons
t
token
=
getToken
()
cons
t
header
=
{
'Authorization'
:
token
,
'Content-Type'
:
'application/json'
//
根据自己的数据类型
// "Content-Type":"application/x-www-form-urlencoded",
}
return
header
}
le
t
request
=
function
(
req
)
{
req
.
method
=
req
.
method
.
toUpperCase
()
if
(
!
[
'GET'
,
'POST'
,
'PUT'
,
'DELETE'
].
includes
(
req
.
method
))
{
uni
.
showToast
({
title
:
`暂不支持的请求方式:
${
req
.
method
}
`
,
icon
:
'none'
});
return
}
cons
t
request
=
function
(
req
)
{
req
.
method
=
req
.
method
.
toUpperCase
()
if
(
!
[
'GET'
,
'POST'
,
'PUT'
,
'DELETE'
].
includes
(
req
.
method
))
{
uni
.
showToast
({
title
:
`暂不支持的请求方式:
${
req
.
method
}
`
,
icon
:
'none'
})
return
}
// if (req.method == 'POST' && !req.hideLoding) {
// uni.showLoading({
// title: '提交中...'
// })
// }
// if (req.method == 'POST' && !req.hideLoding) {
// uni.showLoading({
// title: '提交中...'
// })
// }
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
request
({
url
:
config
.
baseUrl_api
+
req
.
url
,
method
:
req
.
method
,
data
:
req
.
params
,
header
:
getHeaders
(),
}).
then
(
res
=>
{
switch
(
res
.
statusCode
)
{
case
200
:
const
data
=
res
.
data
||
{};
if
(
data
.
code
==
200
)
{
resolve
(
data
)
}
else
{
//登录超时
if
(
data
.
code
==
60002
||
data
.
code
==
60001
)
{
if
(
req
.
url
!=
'/system/wx/getUserInfo'
)
{
reLogin
();
}
}
else
if
(
data
.
code
==
401
&&
req
.
url
!=
'/system/wx/getUserInfo'
)
{
pcLogin
()
.
then
(()
=>
{
return
getNowOpenId
()
})
.
then
(()
=>
{
return
initData
()
})
.
then
(()
=>
{
uni
.
hideLoading
();
uni
.
redirectTo
({
url
:
getCurrentPages
()[
getCurrentPages
().
length
-
1
].
$page
.
fullPath
})
})
}
else
{
if
(
!
excludeUrls
.
includes
(
req
.
url
))
{
uni
.
showToast
({
title
:
data
.
msg
,
icon
:
'none'
,
duration
:
3000
})
}
}
reject
(
res
)
}
break
default
:
reject
(
res
)
}
}).
catch
(
res
=>
{
reject
(
res
)
}).
finally
(()
=>
{
// if (req.method == 'POST' && !req.hideLoding) {
// uni.hideLoading()
// }
})
})
}
function
reLogin
()
{
const
currUser
=
uni
.
getStorageSync
(
'currUser'
)
||
{}
if
(
currUser
.
openId
)
{
const
accountInfo
=
uni
.
getAccountInfoSync
()
pcLoginByOpenId
(
accountInfo
.
miniProgram
.
appId
,
currUser
.
openId
)
.
then
((
res
)
=>
{
let
user
=
res
.
data
;
uni
.
setStorageSync
(
'token'
,
'Bearer '
+
user
.
token
);
uni
.
setStorageSync
(
'currUser'
,
user
);
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
request
({
url
:
config
.
baseUrl_api
+
req
.
url
,
method
:
req
.
method
,
data
:
req
.
params
,
header
:
getHeaders
()
}).
then
(
res
=>
{
switch
(
res
.
statusCode
)
{
case
200
:
const
data
=
res
.
data
||
{}
if
(
data
.
code
===
200
)
{
resolve
(
data
)
}
else
{
if
(
!
excludeUrls
.
includes
(
req
.
url
))
{
uni
.
showToast
({
title
:
data
.
msg
,
icon
:
'none'
,
duration
:
3000
})
}
uni
.
showToast
({
title
:
'一走神把您的操作遗漏了,请重试'
,
icon
:
'none'
})
}).
catch
(()
=>
{
uni
.
showToast
({
title
:
'服务异常,请稍后重试'
,
icon
:
'none'
})
})
}
// 登录超时
if
(
data
.
code
===
60002
||
data
.
code
===
60001
)
{
uni
.
redirectTo
({
url
:
'/pages/index/login'
})
}
else
if
(
data
.
code
===
401
)
{
h5LoginAuto
()
.
then
(()
=>
{
uni
.
hideLoading
()
uni
.
redirectTo
({
url
:
getCurrentPages
()[
getCurrentPages
()
.
length
-
1
].
$page
.
fullPath
})
})
.
catch
(()
=>
{
uni
.
showToast
({
title
:
'服务异常,请稍后重试'
,
icon
:
'none'
})
})
}
reject
(
res
)
}
break
default
:
reject
(
res
)
}
}).
catch
(
res
=>
{
reject
(
res
)
}).
finally
(()
=>
{
// if (req.method == 'POST' && !req.hideLoding) {
// uni.hideLoading()
// }
})
})
}
function
pcLoginByOpenId
(
appId
,
openId
)
{
return
request
({
url
:
"/system/wx/loginByOpenId"
,
method
:
"POST"
,
params
:
{
appId
:
appId
,
openId
:
openId
}
})
}
export
default
request
;
export
default
request
...
...
config.js
View file @
023f830
// prod
// const baseUrl = 'https://research.wtwuxicenter.com/';
// const baseUrl_api=`${baseUrl}/prod-api`;
// const baseUrl_api = 'https://research.wtwuxicenter.com/';
// uat
// const baseUrl = 'https://jxt.itechtop.cn';
const
baseUrl
=
'https://jxt.wtwuxicenter.com'
;
const
baseUrl_api
=
`
${
baseUrl
}
/prod-api`
;
// staging
// const baseUrl = 'https://5q5re1d432g2.ngrok2.xiaomiqiu123.top';
// const baseUrl = "http://192.168.1.118:8081";
// const baseUrl_api = `${baseUrl}`;
const
fileUrl
=
"http://r.itechtop.cn"
;
const
baseUrl_api
=
"http://192.168.1.96:8787"
;
export
default
{
baseUrl
:
baseUrl
,
fileUrl
:
fileUrl
,
baseUrl_api
:
baseUrl_api
,
baseUrl_api
};
\ No newline at end of file
...
...
pages/index/login.vue
View file @
023f830
This diff is collapsed.
Click to expand it.
pages/index/order.vue
View file @
023f830
...
...
@@ -85,7 +85,7 @@
const
app
=
getApp
();
const
projectList
=
ref
([]);
const
priceTable
=
ref
([]);
const
priceTable
=
ref
([]);
const
czList
=
ref
([]);
const
isActive
=
ref
(
0
);
const
popup
=
ref
(
null
);
...
...
杨炀
@yangyang
mentioned in commit
c49a1142
2023-10-08 11:28:23 UTC
mentioned in commit
c49a1142
Toggle commit list
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment