Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
wangxiaolu-promotion-wechat
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
sfa
wangxiaolu-promotion-wechat
Commits
837cbfed
提交
837cbfed
authored
12月 05, 2024
作者:
lidongxu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
信息提交页面搭建完毕
上级
ee74a7a3
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
72 行增加
和
100 行删除
+72
-100
login.js
api/login.js
+5
-53
config.js
config.js
+10
-10
main.js
main.js
+3
-3
pages.json
pages.json
+9
-8
login.vue
pages/login.vue
+39
-22
register.vue
pages/register.vue
+0
-0
start.vue
pages/start.vue
+4
-2
getters.js
store/getters.js
+0
-1
constant.js
utils/constant.js
+1
-0
storage.js
utils/storage.js
+1
-1
没有找到文件。
api/login.js
浏览文件 @
837cbfed
import
request
from
'@/utils/request'
import
request
from
'@/utils/request'
// 登录方法
// 提交用户注册信息
export
function
login
(
username
,
password
,
code
,
uuid
)
{
export
function
submitUserInfo
(
data
)
{
const
data
=
{
username
,
password
,
code
,
uuid
}
return
request
({
return
request
({
'url'
:
'/auth/login'
,
'url'
:
'/user/wechat/core/temporary/enroll'
,
headers
:
{
isToken
:
false
},
'method'
:
'post'
,
'method'
:
'post'
,
'data'
:
data
'data'
:
data
})
})
}
}
\ No newline at end of file
// 注册方法
export
function
register
(
data
)
{
return
request
({
url
:
'/auth/register'
,
headers
:
{
isToken
:
false
},
method
:
'post'
,
data
:
data
})
}
// 获取用户详细信息
export
function
getInfo
()
{
return
request
({
'url'
:
'/system/user/getInfo'
,
'method'
:
'get'
})
}
// 退出方法
export
function
logout
()
{
return
request
({
'url'
:
'/auth/logout'
,
'method'
:
'DELETE'
})
}
// 获取验证码
export
function
getCodeImg
()
{
return
request
({
'url'
:
'/auth/captchaImage'
,
headers
:
{
isToken
:
false
},
method
:
'get'
,
timeout
:
20000
})
}
config.js
浏览文件 @
837cbfed
...
@@ -5,9 +5,9 @@ module.exports = {
...
@@ -5,9 +5,9 @@ module.exports = {
mapKey
:
'mryaav7xyp0Z3ItwUT3oMssYAmG8sTSU'
,
mapKey
:
'mryaav7xyp0Z3ItwUT3oMssYAmG8sTSU'
,
coordtype
:
'gcj02'
,
// 坐标类型(小程序获取和百度地图 API 使用类型要对应上)
coordtype
:
'gcj02'
,
// 坐标类型(小程序获取和百度地图 API 使用类型要对应上)
// baseUrl: 'http://localhost:8080',
// baseUrl: 'http://localhost:8080',
baseUrl
:
'http://
192.168.140.189:8080'
,
// 局域网请求
baseUrl
:
'http://
promotion.wxl66.cn:8010'
,
// 云 API 域名
// baseUrl: 'http://sfa.test.wxl66.cn:85/api', // 上线测试
wxAppId
:
'wx5d89065bb4725557'
,
// baseUrl: 'http://111.198.15.68:85/api
',
wxSecret
:
'7395e91baf6b49ca9b84b1301989f77e
'
,
// 应用信息
// 应用信息
appInfo
:
{
appInfo
:
{
// 应用名称
// 应用名称
...
@@ -20,13 +20,13 @@ module.exports = {
...
@@ -20,13 +20,13 @@ module.exports = {
site_url
:
"http://ruoyi.vip"
,
site_url
:
"http://ruoyi.vip"
,
// 政策协议
// 政策协议
agreements
:
[{
agreements
:
[{
title
:
"隐私政策"
,
title
:
"隐私政策"
,
url
:
"https://ruoyi.vip/protocol.html"
url
:
"https://ruoyi.vip/protocol.html"
},
},
{
{
title
:
"用户服务协议"
,
title
:
"用户服务协议"
,
url
:
"https://ruoyi.vip/protocol.html"
url
:
"https://ruoyi.vip/protocol.html"
}
}
]
]
}
}
}
}
main.js
浏览文件 @
837cbfed
...
@@ -4,14 +4,14 @@ import store from './store' // store
...
@@ -4,14 +4,14 @@ import store from './store' // store
import
plugins
from
'./plugins'
// plugins
import
plugins
from
'./plugins'
// plugins
import
'./permission'
// permission
import
'./permission'
// permission
import
*
as
auth
from
'./utils/auth.js'
import
*
as
auth
from
'./utils/auth.js'
import
config
from
'./config.js'
Vue
.
use
(
plugins
)
Vue
.
use
(
plugins
)
// 获取 access_token
// 获取 access_token
const
appid
=
'wx5d89065bb4725557'
const
secret
=
'7395e91baf6b49ca9b84b1301989f77e'
// 发起请求
// 发起请求
uni
.
request
({
uni
.
request
({
url
:
`https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=
${
appid
}
&secret=
${
s
ecret
}
`
,
url
:
`https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=
${
config
.
wxAppId
}
&secret=
${
config
.
wxS
ecret
}
`
,
success
:
function
(
res
)
{
success
:
function
(
res
)
{
auth
.
setAccessToken
(
res
.
data
.
access_token
)
auth
.
setAccessToken
(
res
.
data
.
access_token
)
},
},
...
...
pages.json
浏览文件 @
837cbfed
{
{
"pages"
:
[
"pages"
:
[
{
"path"
:
"pages/start"
,
"style"
:
{
"navigationBarTitleText"
:
"欢迎使用-小卤促销员平台"
}
},
{
{
"path"
:
"pages/login"
,
"path"
:
"pages/login"
,
"style"
:
{
"style"
:
{
...
@@ -7,9 +13,9 @@
...
@@ -7,9 +13,9 @@
}
}
},
},
{
{
"path"
:
"pages/
start
"
,
"path"
:
"pages/
register
"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"
欢迎使用-小卤促销员平台
"
"navigationBarTitleText"
:
"
促销员提交
"
}
}
},
},
{
{
...
@@ -30,12 +36,7 @@
...
@@ -30,12 +36,7 @@
"navigationBarTitleText"
:
"工作台"
"navigationBarTitleText"
:
"工作台"
}
}
},
},
{
"path"
:
"pages/register"
,
"style"
:
{
"navigationBarTitleText"
:
"注册"
}
},
{
{
"path"
:
"pages/mine/index"
,
"path"
:
"pages/mine/index"
,
"style"
:
{
"style"
:
{
...
...
pages/login.vue
浏览文件 @
837cbfed
...
@@ -48,38 +48,55 @@ export default {
...
@@ -48,38 +48,55 @@ export default {
},
},
methods
:
{
methods
:
{
// 手机号登录
// 手机号登录
getPhoneNumber
(
e
)
{
async
getPhoneNumber
(
e
)
{
this
.
$modal
.
loading
(
"登录中,请耐心等待..."
)
this
.
$modal
.
loading
(
"登录中,请耐心等待..."
)
// 通过微信小程序 API 获取手机号
// 通过微信小程序 API 获取手机号
uni
.
request
({
const
[,
phoneRes
]
=
await
uni
.
request
({
url
:
`https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=
${
getAccessToken
()}
`
,
url
:
`https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=
${
getAccessToken
()}
`
,
method
:
'POST'
,
method
:
'POST'
,
data
:
{
data
:
{
code
:
e
.
detail
.
code
code
:
e
.
detail
.
code
},
success
:
(
res
)
=>
{
console
.
log
(
'后端解密手机号成功,手机号为:'
,
res
);
storage
.
set
(
constant
.
loginPhone
,
res
.
data
.
phone_info
.
phoneNumber
)
this
.
$modal
.
closeLoading
()
this
.
$tab
.
reLaunch
(
'/pages/index'
)
},
fail
:
function
()
{
console
.
log
(
'后端解密手机号失败'
);
}
}
})
// 调用微信登录接口,获取 code
const
[,
loginRes
]
=
await
uni
.
login
({
provider
:
'weixin'
})
// 通过 code 获取 openid
const
[,
openRes
]
=
await
uni
.
request
({
url
:
`https://api.weixin.qq.com/sns/jscode2session?appid=
${
this
.
globalConfig
.
wxAppId
}
&secret=
${
this
.
globalConfig
.
wxSecret
}
&js_code=
${
loginRes
.
code
}
&grant_type=authorization_code`
});
});
// 获取用户信息-头像等
const
[,
userRes
]
=
await
uni
.
getUserInfo
({
provider
:
'weixin'
,
withCredentials
:
false
})
storage
.
set
(
constant
.
loginPhone
,
phoneRes
.
data
.
phone_info
.
phoneNumber
)
storage
.
set
(
constant
.
loginOpenId
,
openRes
.
data
.
openid
)
this
.
$store
.
commit
(
'SET_USER'
,
userRes
.
userInfo
)
this
.
$modal
.
closeLoading
()
this
.
$tab
.
reLaunch
(
'/pages/register'
)
},
},
// // 登录成功后,处理函数
fail
:
function
()
{
// async loginSuccess(result) {
console
.
log
(
'后端解密手机号失败'
);
// // 设置用户信息
// await this.$store.dispatch('GetInfo')
// await this.getAuth()
// this.$tab.reLaunch('/pages/index')
// },
// 登录成功后,开始获取各种权限
async
getAuth
()
{
// 获取地址位置
return
this
.
$store
.
dispatch
(
'GetLocation'
)
}
}
},
// // 登录成功后,处理函数
// async loginSuccess(result) {
// // 设置用户信息
// await this.$store.dispatch('GetInfo')
// await this.getAuth()
// this.$tab.reLaunch('/pages/index')
// },
// 登录成功后,开始获取各种权限
async
getAuth
()
{
// 获取地址位置
return
this
.
$store
.
dispatch
(
'GetLocation'
)
}
}
}
}
</
script
>
</
script
>
...
...
pages/register.vue
浏览文件 @
837cbfed
差异被折叠。
点击展开。
pages/start.vue
浏览文件 @
837cbfed
...
@@ -10,9 +10,11 @@ export default {
...
@@ -10,9 +10,11 @@ export default {
setTimeout
(()
=>
{
setTimeout
(()
=>
{
// this.$tab.redirectTo('/page_subject/pages/login')
// this.$tab.redirectTo('/page_subject/pages/login')
console
.
log
(
storage
.
get
(
constant
.
loginPhone
))
console
.
log
(
storage
.
get
(
constant
.
loginPhone
))
// TODO:下面重写:有手机号,判断注册信息填过没有,有就去首页,没有就去注册页
if
(
storage
.
get
(
constant
.
loginPhone
))
{
if
(
storage
.
get
(
constant
.
loginPhone
))
{
// 有存储过之前的登录手机号
// 有存储过之前的登录手机号+openId 也不对,需要注册成功,再去首页
this
.
$tab
.
switchTab
(
'/pages/index'
)
// this.$tab.switchTab('/pages/index')
this
.
$tab
.
redirectTo
(
'/pages/register'
)
}
else
{
}
else
{
this
.
$tab
.
redirectTo
(
'/pages/login'
)
this
.
$tab
.
redirectTo
(
'/pages/login'
)
}
}
...
...
store/getters.js
浏览文件 @
837cbfed
import
store
from
'@/store'
const
getters
=
{
const
getters
=
{
token
:
state
=>
state
.
user
.
token
,
token
:
state
=>
state
.
user
.
token
,
avatar
:
state
=>
state
.
user
.
avatar
,
avatar
:
state
=>
state
.
user
.
avatar
,
...
...
utils/constant.js
浏览文件 @
837cbfed
...
@@ -8,6 +8,7 @@ const constant = {
...
@@ -8,6 +8,7 @@ const constant = {
location
:
'vuex_location'
,
location
:
'vuex_location'
,
// 登录使用手机号
// 登录使用手机号
loginPhone
:
'vuex_login_phone'
,
loginPhone
:
'vuex_login_phone'
,
loginOpenId
:
'vuex_login_openid'
,
}
}
export
default
constant
export
default
constant
utils/storage.js
浏览文件 @
837cbfed
...
@@ -4,7 +4,7 @@ import constant from './constant'
...
@@ -4,7 +4,7 @@ import constant from './constant'
let
storageKey
=
'storage_data'
let
storageKey
=
'storage_data'
// 存储节点变量名
// 存储节点变量名
let
storageNodeKeys
=
[
constant
.
avatar
,
constant
.
name
,
constant
.
roles
,
constant
.
permissions
,
constant
.
user
,
constant
.
location
,
constant
.
loginPhone
]
let
storageNodeKeys
=
[
constant
.
avatar
,
constant
.
name
,
constant
.
roles
,
constant
.
permissions
,
constant
.
user
,
constant
.
location
,
constant
.
loginPhone
,
constant
.
loginOpenId
]
const
storage
=
{
const
storage
=
{
set
:
function
(
key
,
value
)
{
set
:
function
(
key
,
value
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论