Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jd-vx-app
Project
Project
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
Administrator
jd-vx-app
Commits
7c363b63
Commit
7c363b63
authored
Apr 20, 2022
by
肖健
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小程序登录调整
parent
6fd1a18f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
240 additions
and
70 deletions
+240
-70
.gitignore
.gitignore
+1
-1
api.js
common/api/api.js
+78
-0
main.js
main.js
+3
-0
manifest.json
manifest.json
+35
-35
index.vue
pages/binding/index.vue
+123
-34
No files found.
.gitignore
View file @
7c363b63
unpackage
\ No newline at end of file
unpackage/
\ No newline at end of file
common/api/api.js
0 → 100644
View file @
7c363b63
const
baseUrl
=
'http://mpcw6f.natappfree.cc'
;
const
httpRequest
=
(
opts
,
data
)
=>
{
let
httpDefaultOpts
=
{
url
:
baseUrl
+
opts
.
url
,
data
:
data
,
method
:
opts
.
method
,
header
:
opts
.
method
==
'get'
?
{
'X-Requested-With'
:
'XMLHttpRequest'
,
"Accept"
:
"application/json"
,
"Content-Type"
:
"application/json; charset=UTF-8"
}
:
{
'X-Requested-With'
:
'XMLHttpRequest'
,
"Content-Type"
:
"application/json; charset=UTF-8"
// 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
},
dataType
:
'json'
,
}
let
promise
=
new
Promise
(
function
(
resolve
,
reject
)
{
uni
.
request
(
httpDefaultOpts
).
then
(
(
res
)
=>
{
resolve
(
res
[
1
])
}
).
catch
(
(
response
)
=>
{
reject
(
response
)
}
)
})
return
promise
};
//带Token请求
const
httpTokenRequest
=
(
opts
,
data
)
=>
{
let
token
=
uni
.
getStorageSync
(
'userToken'
);
uni
.
getStorage
({
key
:
'token'
,
success
:
function
(
ress
)
{
token
=
ress
.
data
}
});
//此token是登录成功后后台返回保存在storage中的
let
httpDefaultOpts
=
{
url
:
baseUrl
+
opts
.
url
,
data
:
data
,
method
:
opts
.
method
,
header
:
opts
.
method
==
'get'
?
{
'Authorization'
:
'Bearer '
+
token
,
'X-Requested-With'
:
'XMLHttpRequest'
,
"Accept"
:
"application/json"
,
"Content-Type"
:
"application/json; charset=UTF-8"
// "Content-Type": "application/json; charset=UTF-8"
}
:
{
'Authorization'
:
'Bearer '
+
token
,
'X-Requested-With'
:
'XMLHttpRequest'
,
"Content-Type"
:
"application/json; charset=UTF-8"
// 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
},
dataType
:
'json'
,
}
let
promise
=
new
Promise
(
function
(
resolve
,
reject
)
{
uni
.
request
(
httpDefaultOpts
).
then
(
(
res
)
=>
{
// console.log(3333333333333333333,res)
resolve
(
res
[
1
])
}
).
catch
(
(
response
)
=>
{
reject
(
response
)
}
)
})
return
promise
};
export
default
{
baseUrl
,
httpRequest
,
httpTokenRequest
}
\ No newline at end of file
main.js
View file @
7c363b63
...
...
@@ -2,9 +2,12 @@ import Vue from 'vue'
import
App
from
'./App'
import
uView
from
'@/common/uview-ui/index'
;
import
http
from
"./common/api/api.js"
Vue
.
config
.
productionTip
=
false
import
ActiveForm
from
"@/common/active-form/active-form"
;
Vue
.
use
(
uView
);
Vue
.
prototype
.
http
=
http
App
.
mpType
=
'app'
Vue
.
component
(
'ActiveForm'
,
ActiveForm
)
const
app
=
new
Vue
({
...
...
manifest.json
View file @
7c363b63
{
"name"
:
"挪车"
,
"appid"
:
"__UNI__F54AE0B"
,
"description"
:
""
,
"versionName"
:
"1.0.0"
,
"versionCode"
:
"100"
,
"transformPx"
:
false
,
"name"
:
"挪车"
,
"appid"
:
"__UNI__F54AE0B"
,
"description"
:
""
,
"versionName"
:
"1.0.0"
,
"versionCode"
:
"100"
,
"transformPx"
:
false
,
/*
5
+App特有相关
*/
"app-plus"
:
{
"optimization"
:
{
"subPackages"
:
true
"app-plus"
:
{
"optimization"
:
{
"subPackages"
:
true
},
"runmode"
:
"liberate"
,
//
开启分包优化后,必须配置资源释放模式
"usingComponents"
:
true
,
"splashscreen"
:
{
"alwaysShowBeforeRender"
:
true
,
"waiting"
:
true
,
"autoclose"
:
true
,
"delay"
:
0
"runmode"
:
"liberate"
,
//
开启分包优化后,必须配置资源释放模式
"usingComponents"
:
true
,
"splashscreen"
:
{
"alwaysShowBeforeRender"
:
true
,
"waiting"
:
true
,
"autoclose"
:
true
,
"delay"
:
0
},
/*
模块配置
*/
"modules"
:
{},
"modules"
:
{},
/*
应用发布信息
*/
"distribute"
:
{
"distribute"
:
{
/*
android打包配置
*/
"android"
:
{
"permissions"
:
[
"android"
:
{
"permissions"
:
[
"<uses-permission android:name=
\"
android.permission.CHANGE_NETWORK_STATE
\"
/>"
,
"<uses-permission android:name=
\"
android.permission.MOUNT_UNMOUNT_FILESYSTEMS
\"
/>"
,
"<uses-permission android:name=
\"
android.permission.READ_CONTACTS
\"
/>"
,
...
...
@@ -50,28 +50,28 @@
]
},
/*
ios打包配置
*/
"ios"
:
{},
"ios"
:
{},
/*
SDK配置
*/
"sdkConfigs"
:
{}
"sdkConfigs"
:
{}
}
},
/*
快应用特有相关
*/
"quickapp"
:
{},
"quickapp"
:
{},
/*
小程序特有相关
*/
"mp-weixin"
:
{
"appid"
:
"
"
,
"setting"
:
{
"urlCheck"
:
false
"mp-weixin"
:
{
"appid"
:
"wx8fd4dc1c4b9f6f41
"
,
"setting"
:
{
"urlCheck"
:
false
},
"usingComponents"
:
true
"usingComponents"
:
true
},
"mp-alipay"
:
{
"usingComponents"
:
true
"mp-alipay"
:
{
"usingComponents"
:
true
},
"mp-baidu"
:
{
"usingComponents"
:
true
"mp-baidu"
:
{
"usingComponents"
:
true
},
"mp-toutiao"
:
{
"usingComponents"
:
true
"mp-toutiao"
:
{
"usingComponents"
:
true
}
}
\ No newline at end of file
}
pages/binding/index.vue
View file @
7c363b63
<!--
* @Author: euzhi
* @Description: 登录
-->
<
template
>
<view
class=
"appCotent"
>
<div
class=
"binding"
>
<div
class=
"login__logo"
>
<image
src=
"@/static/binding/logo.png"
>
</div>
<div
class=
"login__btn"
@
click=
"login"
>
微信一键登录
</div>
<div
class=
"login__read"
>
<u-checkbox-group
v-model=
"checked"
placement=
"row"
>
<u-checkbox
activeColor=
"ok"
></u-checkbox>
</u-checkbox-group>
已阅读并同意
<span>
《京东用户注册协议》
</span>
、
<span>
《京东隐私政策》
</span>
。若您的手机号未注册,将为您直接注册京东账号
</div>
</div>
</view>
<view
class=
"appCotent"
>
<div
class=
"binding"
>
<div
class=
"login__logo"
>
<image
src=
"@/static/binding/logo.png"
>
</div>
<!-- #ifdef MP-WEIXIN -->
<!--
<view
v-if=
"isCanUse"
>
<view>
<button
class=
"login__btn"
hover-class=
"none"
type=
'primary'
@
click=
"getUserProfile"
>
微信一键登录
</button>
</view>
</view>
-->
<view
v-if=
"isCanUse2"
>
<view>
<button
class=
"login__btn"
hover-class=
"none"
type=
'primary'
open-type=
"getPhoneNumber"
@
getphonenumber=
"getPhoneNumber"
>
微信一键登录
</button>
</view>
</view>
<!-- #endif -->
<div
class=
"login__read"
>
<u-checkbox-group
v-model=
"nc_protocol"
placement=
"row"
>
<u-checkbox
activeColor=
"green"
></u-checkbox>
</u-checkbox-group>
已阅读并同意
<span>
《京东用户注册协议》
</span>
、
<span>
《京东隐私政策》
</span>
。若您的手机号未注册,将为您直接注册京东账号
</div>
</div>
</view>
</
template
>
<
script
>
export
default
{
data
()
{
return
{
checked
:
[],
};
},
methods
:
{
login
()
{
//跳转到绑定页面
uni
.
navigateTo
({
url
:
'/pages/binding/binding'
});
}
},
data
()
{
return
{
code
:
""
,
isCanUse
:
false
,
//默认为true
isCanUse2
:
false
,
//默认为true
openid
:
''
,
nc_protocol
:
false
,
}
},
methods
:
{
//登录
login
()
{
let
_this
=
this
;
uni
.
showLoading
({
title
:
'登录中...'
})
},
//解析手机号
getPhoneNumber
(
e
)
{
let
that
=
this
if
(
e
.
detail
.
errMsg
==
"getPhoneNumber:ok"
)
{
that
.
decodePhoneLogin
(
e
.
detail
)
}
else
{
console
.
log
(
"用户点击了拒绝"
)
}
},
//解密手机号码
async
decodePhoneLogin
(
detail
)
{
let
encryptedData
=
detail
.
encryptedData
let
iv
=
detail
.
iv
let
that
=
this
let
param
=
{
code
:
detail
.
code
,
}
let
opts
=
{
url
:
'/xcx/login'
,
method
:
'post'
}
await
that
.
http
.
httpRequest
(
opts
,
param
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
)
{
uni
.
showToast
({
title
:
'授权成功'
,
duration
:
1500
})
uni
.
setStorageSync
(
"userToken"
,
res
.
data
.
data
.
token
)
//跳转到绑定页面
this
.
gotoIndex
()
}
else
{
uni
.
showToast
({
title
:
'授权失败'
,
icon
:
'none'
,
})
}
})
},
gotoIndex
()
{
//跳转到绑定页面
uni
.
reLaunch
({
//信息更新成功后跳转到小程序首页
url
:
'/pages/binding/binding'
})
// uni.navigateTo({
// url: '/pages/binding/binding'
// });
}
},
onLoad
()
{
//默认加载
let
userToken
=
uni
.
getStorageSync
(
'userToken'
)
if
(
userToken
)
{
let
that
=
this
let
opts
=
{
url
:
'/app/user/info'
,
method
:
'get'
}
that
.
http
.
httpTokenRequest
(
opts
,
{}).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
)
{
this
.
gotoIndex
()
}
else
{
uni
.
showToast
({
title
:
'授权失败'
,
icon
:
'none'
,
})
this
.
isCanUse2
=
true
}
})
}
else
{
this
.
isCanUse2
=
true
}
}
}
</
script
>
...
...
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