Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cust-app
Project
Project
Details
Activity
Releases
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
李伟
cust-app
Commits
62068d95
Commit
62068d95
authored
Dec 25, 2024
by
liwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了登录
parent
10b3f25b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
409 deletions
+109
-409
App.vue
App.vue
+3
-13
my.vue
pages/tab/my.vue
+80
-179
index.vue
pageslogin/index/index.vue
+26
-217
No files found.
App.vue
View file @
62068d95
...
...
@@ -2,19 +2,9 @@
export
default
{
onLaunch
:
function
(
option
)
{
console
.
log
(
"进入App.vue页面 "
+
option
.
path
)
if
(
uni
.
getStorageSync
(
'itemobj'
))
{
uni
.
switchTab
({
url
:
'/pages/tab/index'
});
}
else
{
if
(
option
.
path
!=
"pageslike/like/userInfo"
)
{
console
.
log
(
"分享用户标识失败,跳转登录页"
)
console
.
log
(
uni
.
getStorageSync
(
'usershare'
))
uni
.
reLaunch
({
url
:
'/pageslogin/index/index'
});
}
}
},
onShow
:
function
()
{
...
...
pages/tab/my.vue
View file @
62068d95
<
template
>
<view
class=
""
style=
"background: #F4F5F9;"
>
<!-- 没登录-->
<view
class=
"home-page-container"
style=
"min-height: 100vh;"
@
touchmove
.
stop
.
prevent=
"() =>
{}" v-if="nologin==true">
<image
class=
"bgc-imga"
src=
"../../static/images/bg-c.png"
mode=
"aspectFill"
></image>
<u-navbar
leftText=
" "
title=
" "
:bgColor=
"bgColor"
:fixed=
"false"
:safeAreaInsetTop=
"true"
...
...
@@ -17,15 +18,19 @@
</image>
</view>
<view
class=
"text"
>
登录后才能查看我的哦
</view>
<view
class=
"nobutton"
@
click=
"
getUserInfo
"
>
点此登录
</view>
<view
class=
"nobutton"
@
click=
"
login
"
>
点此登录
</view>
</view>
<view
class=
""
v-if=
"nologin == false && flag == true"
>
<!-- 已登录-->
<view
class=
""
v-if=
"nologin == false"
>
<!-- 顶部 背景-->
<image
class=
"bgc-imga"
src=
"../../static/images/my2.png"
mode=
"aspectFill"
></image>
<view
class=
"logion"
>
<!-- 顶部 第一部分-->
<view
class=
"logion"
>
<image
class=
"bgc-imgas"
src=
"../../static/images/my22.png"
mode=
"aspectFill"
></image>
<view
class=
"sss"
>
<view
class=
"logo"
>
<image
:src=
"info.headPortrait"
style=
"width: 100%;height: 100%;border-radius: 50%;"
mode=
"aspectFill"
>
...
...
@@ -53,12 +58,13 @@
</view>
<view
class=
"diving"
style=
"margin: 0 136rpx;"
@
click=
"gotolike(2)"
>
<view
class=
"divtast"
v-if=
"info.likeMe==0"
>
<!--
<view
class=
"divtast"
v-if=
"info.likeMe==0"
>
-->
<view
class=
"divtast"
>
<text
v-if=
"info.likeMe"
>
{{
info
.
likeMe
}}
</text><text
v-else
>
0
</text>
</view>
<view
class=
"vimg"
v-else
>
<image
:src=
"info.likeMeheadPortrait"
class=
"simg"
mode=
"aspectFill"
></image
>
</view
>
<!--
<view
class=
"vimg"
v-else
>
--
>
<!--
<image
:src=
"info.likeMeheadPortrait"
class=
"simg"
mode=
"aspectFill"
></image>
--
>
<!--
</view>
--
>
<view
class=
"divingname"
>
喜欢我的
...
...
@@ -77,8 +83,8 @@
</view>
</view>
<view
class=
"box"
v-if=
"dataflag"
>
<!-- 认证 第二部分-->
<view
class=
"box"
>
<view
class=
"boxsing"
style=
"height: 52rpx;"
>
<view
class=
"boxsname"
style=
"margin-left: 42rpx;"
>
双重认证
...
...
@@ -107,6 +113,8 @@
<view
class=
""
style=
"height: 52rpx;"
>
</view>
</view>
<!-- 动态 第三部分-->
<view
class=
"box"
@
click=
"goCommunity"
v-if=
"(info.userArticleViewResponse.articleImg!==null&&info.userArticleViewResponse.articleImg.length)||info.userArticleViewResponse.articleContent!==null"
>
<view
class=
"boxsing"
>
<image
src=
"../../static/images/106.svg"
style=
"width: 42rpx;height: 42rpx;margin-left: 42rpx;;"
...
...
@@ -124,7 +132,7 @@
</view>
</view>
<!-- 操作项 第四部分-->
<view
class=
"box"
style=
""
>
<view
class=
"box-bottom"
v-for=
"(item,index) in button"
:key=
"index"
@
click=
"whether(index)"
>
<view
class=
"box-bottom-left"
>
...
...
@@ -156,30 +164,40 @@
</view>
</view>
</view>
<ELM
ref=
"elm"
:msg=
"tipMsg"
></ELM>
</view>
<u-popup
u-popup
:show=
"tipsShow"
mode=
"center"
round=
"12"
:safeAreaInsetBottom=
"false"
>
<view
class=
"popup-container"
>
<image
class=
"pop-bgc"
:src=
"img + '/img/home-pop-bg.png'"
></image>
<view
class=
"div-popo"
>
<view
class=
"pop-title"
>
温馨提示
</view>
<view
class=
"tips-content"
>
请您仔细阅读并充分理解相关条款, 点击同意即代表您已阅读并同意
<view
class=
"agreement-btn"
>
《用户协议》
</view>
、
<view
class=
"agreement-btn"
>
《隐私政策》
</view>
</view>
<view
class=
"btn-c"
>
<view
class=
"pop-btn agree"
@
click=
"handAgree"
>
同意
</view>
<view
class=
"pop-btn"
@
click=
"handleNoAgree"
>
不同意
</view>
</view>
</view>
</view>
</u-popup>
</view>
</
template
>
<
script
>
import
{
WS
}
from
'@/util/wsConfig.js'
import
ELM
from
'../../components/elm-toast/index.vue'
;
export
default
{
components
:
{
ELM
},
data
()
{
return
{
flag
:
true
,
dataflag
:
true
,
tipsShow
:
false
,
nologin
:
''
,
img
:
this
.
$BASE_URL
,
bgColor
:
"rgba(255, 255, 255, 0)"
,
button
:
[{
name
:
"欧几币"
,
button
:
[
{
name
:
"金币"
,
num
:
0
,
la
:
"立即充值"
,
img
:
"../../static/images/mymoney.png"
,
...
...
@@ -191,7 +209,7 @@
},
{
name
:
"推荐给好友"
,
num
:
''
,
la
:
"
免费获得欧几币
"
,
la
:
""
,
img
:
"../../static/images/myshare.png"
,
},
{
name
:
"设置"
,
...
...
@@ -201,6 +219,7 @@
}],
info
:
{
nickName
:
'11111'
,
goldBalance
:
0
,
userArticleViewResponse
:{
articleImg
:
null
,
articleContent
:
null
...
...
@@ -215,13 +234,10 @@
},
onShow
()
{
if
(
uni
.
getStorageSync
(
'token'
))
{
console
.
log
(
'1111111'
)
this
.
ownerId
=
uni
.
getStorageSync
(
'info'
)
!=
null
?
uni
.
getStorageSync
(
'info'
).
id
:
null
;
}
if
(
uni
.
getStorageSync
(
'userInfo'
))
{
console
.
log
(
'22222'
)
this
.
nologin
=
false
// this.personalCenter()
}
else
{
this
.
nologin
=
true
}
...
...
@@ -230,27 +246,46 @@
},
methods
:
{
//获取用户信息
getUserInfo
()
{
try
{
wx
.
getUserProfile
({
desc
:
'用于完善会员资料'
,
success
:
res
=>
{
console
.
log
(
'userInfo========:'
,
res
)
},
fail
:
errinfo
=>
{
console
.
log
(
'errinfo1=========='
,
errinfo
)
}
});
}
catch
{
wx
.
getUserInfo
({
success
:
resinfo
=>
{
},
fail
:
errinfo
=>
{
console
.
log
(
'errinfo2=========='
,
errinfo
)
}
});
}
},
//不同意授权
handleNoAgree
()
{
this
.
tipsShow
=
false
;
},
//同意授权
handAgree
()
{
this
.
getUserInfo
()
this
.
tipsShow
=
false
;
},
gotomation
()
{
uni
.
navigateTo
({
url
:
"/pagesme/me/doubleauth"
})
},
async
getUnRead
()
{
const
res
=
await
this
.
$myRequest
({
url
:
`/message/un/read`
,
withToken
:
true
,
method
:
'GET'
});
uni
.
setTabBarBadge
({
//显示数字
index
:
1
,
//tabbar下标
text
:
`
${
res
.
data
.
data
}
`
//数字
})
},
gotolike
(
type
)
{
//喜欢三个列表页面
console
.
log
(
"进来了"
)
this
.
tipMsg
=
"开源版暂未开放,敬请期待!如需旗舰版,可联系作者微信(MMRWXM)咨询"
;
this
.
$refs
.
elm
.
showDialog
();
},
whether
(
i
)
{
if
(
i
==
0
)
{
...
...
@@ -267,47 +302,10 @@
}
},
//登录
getUserInfo
()
{
// #ifdef MP-WEIXIN
try
{
wx
.
getUserProfile
({
desc
:
'用于完善会员资料'
,
success
:
(
resinfo
)
=>
{
wx
.
login
({
success
:
(
res
)
=>
{
if
(
res
.
code
)
{
console
.
log
(
res
.
code
,
resinfo
);
this
.
setCode
(
res
.
code
,
resinfo
);
}
else
{}
},
fail
:
(
err
)
=>
{}
})
},
fail
:
(
errinfo
)
=>
{
this
.
setCode
(
this
.
generateRandomString
(
10
),
'null'
);
}
})
}
catch
{
wx
.
getUserInfo
({
success
:
(
resinfo
)
=>
{
wx
.
login
({
success
:
(
res
)
=>
{
if
(
res
.
code
)
{
console
.
log
(
res
.
code
,
resinfo
);
this
.
setCode
(
res
.
code
,
resinfo
);
}
else
{}
},
fail
:
(
err
)
=>
{}
})
},
fail
:
(
errinfo
)
=>
{}
login
()
{
uni
.
navigateTo
({
url
:
"/pageslogin/index/index"
})
}
// #endif
// #ifndef MP-WEIXIN
this
.
setCode
(
"ip"
,
'null'
);
// #endif
},
//完善信息
updateInformation
()
{
...
...
@@ -315,108 +313,11 @@
url
:
"/pagesme/me/updateInformation"
})
},
async
setCode
(
code
,
resinfo
)
{
console
.
log
(
code
)
const
res
=
await
this
.
$myRequest
({
url
:
'/token/wxAppletLogin'
,
data
:
{
code
:
code
},
method
:
'POST'
,
});
var
obj
=
{
code
:
code
,
state
:
res
.
data
.
code
,
nickName
:
resinfo
!=
'null'
?
resinfo
.
userInfo
.
nickName
:
"匿名用户"
}
uni
.
setStorageSync
(
'verification'
,
obj
);
if
(
res
.
data
.
code
==
200
)
{
this
.
tipMsg
=
"登录成功"
;
this
.
$refs
.
elm
.
showDialog
();
var
info
=
{
birthday
:
res
.
data
.
data
.
info
.
birthday
,
city
:
res
.
data
.
data
.
info
.
city
,
gender
:
res
.
data
.
data
.
info
.
gender
,
headPortrait
:
res
.
data
.
data
.
info
.
headPortrait
,
id
:
res
.
data
.
data
.
info
.
id
,
nickName
:
res
.
data
.
data
.
info
.
nickName
,
}
uni
.
setStorageSync
(
'userInfo'
,
info
);
uni
.
setStorageSync
(
'token'
,
res
.
data
.
data
.
token
);
this
.
personalCenter
()
this
.
getUnRead
()
this
.
ownerId
=
res
.
data
.
data
.
info
.
id
;
this
.
connectSocketInit
();
}
else
if
(
res
.
data
.
code
==
11002
)
{
uni
.
reLaunch
({
url
:
"/pagesintroduction/selfIntroduction?code="
+
code
})
}
else
{
this
.
tipMsg
=
res
.
data
.
msg
;
this
.
$refs
.
elm
.
showDialog
();
}
},
async
personalCenter
()
{
const
res
=
await
this
.
$myRequest
({
url
:
'/nostalgia/fruser/personalCenter'
,
withToken
:
true
,
method
:
'GET'
,
});
if
(
res
.
data
.
code
==
200
)
{
this
.
info
=
res
.
data
.
data
if
(
this
.
info
.
userArticleViewResponse
.
articleImg
.
length
>
3
){
this
.
info
.
userArticleViewResponse
.
articleImg
=
this
.
info
.
userArticleViewResponse
.
articleImg
.
splice
(
0
,
3
)
}
this
.
flag
=
true
var
num
=
this
.
info
.
educationAuth
==
null
||
this
.
info
.
educationAuth
==
'EXAMINE'
||
this
.
info
.
educationAuth
==
'REFUSE'
?
0
:
1
var
nums
=
this
.
info
.
identityAuth
==
null
||
this
.
info
.
identityAuth
==
'EXAMINE'
||
this
.
info
.
identityAuth
==
'REFUSE'
?
0
:
1
this
.
numtwo
=
num
+
nums
console
.
log
(
num
+
nums
)
if
(
this
.
numtwo
==
2
&&
this
.
info
.
completionRatio
>=
80
)
{
this
.
dataflag
=
false
}
else
{
this
.
dataflag
=
true
}
this
.
nologin
=
false
}
else
{
this
.
tipMsg
=
res
.
data
.
msg
;
this
.
$refs
.
elm
.
showDialog
();
}
},
goCommunity
(){
this
.
tipMsg
=
"开源版暂未开放,敬请期待!如需旗舰版,可联系作者微信(MMRWXM)咨询"
;
this
.
$refs
.
elm
.
showDialog
();
},
generateRandomString
(
length
)
{
let
result
=
uni
.
getStorageSync
(
'touristopenid'
);
if
(
result
!=
null
&&
result
!=
""
)
{
return
result
;
}
else
{
result
=
''
;
}
const
characters
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
;
// 包含大小写字母和数字的所有字符集合
for
(
let
i
=
0
;
i
<
length
;
i
++
)
{
const
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
characters
.
length
);
result
+=
characters
[
randomIndex
];
}
var
now
=
new
Date
();
var
year
=
now
.
getFullYear
();
// 年份
var
month
=
(
now
.
getMonth
()
+
1
).
toString
().
padStart
(
2
,
'0'
);
// 月份(注意要加上1)
var
day
=
now
.
getDate
().
toString
().
padStart
(
2
,
'0'
);
// 天数
var
hours
=
now
.
getHours
().
toString
().
padStart
(
2
,
'0'
);
// 小时
var
minutes
=
now
.
getMinutes
().
toString
().
padStart
(
2
,
'0'
);
// 分钟
var
seconds
=
now
.
getSeconds
().
toString
().
padStart
(
2
,
'0'
);
// 秒数
result
=
"touristopenid"
+
result
+
(
+
year
+
month
+
day
+
hours
+
minutes
+
seconds
);
uni
.
setStorageSync
(
'touristopenid'
,
result
);
return
result
;
}
}
}
</
script
>
...
...
pageslogin/index/index.vue
View file @
62068d95
...
...
@@ -4,43 +4,16 @@
<image
class=
"bgc-imga"
src=
"../../static/images/bg-c.png"
mode=
"widthFix"
></image>
<image
class=
"bgc-img"
src=
"../static/images/home-bgc.png"
mode=
"aspectFit"
></image>
<!--
<image
class=
"logo-img"
src=
"../static/images/logo.png"
></image>
-->
<!--
<view
class=
"start-btn"
@
click=
"handleShowTips"
>
-->
<!--
<view>
开始邂逅
</view>
-->
<!--
</view>
-->
<view
class=
"start-btn"
>
<button
open-type=
"getPhoneNumber"
@
getphonenumber=
"getPhoneNumber($event)"
>
开始邂逅
</button>
</view>
<!--
<u-popup
u-popup
:show=
"tipsShow"
mode=
"center"
round=
"12"
:safeAreaInsetBottom=
"false"
>
-->
<!--
<view
class=
"popup-container"
>
-->
<!--
<image
class=
"pop-bgc"
:src=
"img + '/img/home-pop-bg.png'"
></image>
-->
<!--
<view
class=
"div-popo"
>
-->
<!--
<view
class=
"pop-title"
>
温馨提示
</view>
-->
<!--
<view
class=
"tips-content"
>
-->
<!-- 请您仔细阅读并充分理解相关条款, 点击同意即代表您已阅读并同意-->
<!--
<view
class=
"agreement-btn"
>
《用户协议》
</view>
-->
<!-- 、-->
<!--
<view
class=
"agreement-btn"
>
《隐私政策》
</view>
-->
<!--
</view>
-->
<!--
<view
class=
"btn-c"
>
-->
<!--
<view
class=
"pop-btn agree"
@
click=
"handAgree"
>
同意
</view>
-->
<!--
<view
class=
"pop-btn"
@
click=
"handleNoAgree"
>
不同意
</view>
-->
<!--
</view>
-->
<!--
</view>
-->
<!--
</view>
-->
<!--
</u-popup>
-->
</view>
<ELM
ref=
"elm"
:msg=
"tipMsg"
:isConfirm=
"isConfirm"
@
confirm=
"confirm"
></ELM>
</view>
</
template
>
<
script
>
import
ELM
from
'@/components/elm-toast/index.vue'
;
import
{
login
,
phoneLogin
,
getUserInfo
,
getPublicActivity
,
getDicts
,
getInfo
phoneLogin
}
from
'../../api/login/index'
;
export
default
{
data
()
{
...
...
@@ -48,11 +21,7 @@
//用户初始化登录 (可能用户类型传参错误)
initLoginError
:
false
,
img
:
this
.
$BASE_URL
,
tipsShow
:
false
,
falg
:
false
,
num
:
''
,
tipMsg
:
''
,
isConfirm
:
false
,
token
:
''
,
openId
:
''
,
};
...
...
@@ -68,15 +37,12 @@
})
},
onShow
()
{
// uni.switchTab({
// url: '/pages/tab/index'
// });
},
components
:
{
ELM
},
methods
:
{
// 用户登录
/**
* 用户登录
*/
usersLogin
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
//加载交互
...
...
@@ -89,7 +55,6 @@
let
code
=
{
code
:
res
.
code
,
}
console
.
log
(
"code"
,
code
)
login
(
code
).
then
(
res
=>
{
this
.
openId
=
res
.
data
.
openId
//证明不是第一次登录
...
...
@@ -99,11 +64,11 @@
this
.
userInfo
=
res
.
data
.
data
uni
.
setStorageSync
(
'token'
,
this
.
token
)
uni
.
setStorageSync
(
'userInfo'
,
JSON
.
stringify
(
this
.
userInfo
))
uni
.
reLaunch
({
url
:
'/pages/tab/index'
})
//停止加载
uni
.
hideLoading
()
uni
.
switchTab
({
url
:
'/pages/tab/index'
});
resolve
(
null
)
}
}).
catch
(
res
=>
{
...
...
@@ -116,7 +81,10 @@
})
});
},
// 页面跳转
/**
* 用户点击手机号登录
*/
async
getPhoneNumber
(
event
)
{
//加载交互
uni
.
showLoading
({
...
...
@@ -146,32 +114,29 @@
//获取token则不继续请求
if
(
this
.
token
)
{
// 根据获取的手机号信息请求登录接口
// 结束登录加载交互
uni
.
hideLoading
();
//添加确认登录校验用于处理登录页面未进行登录而能直接从启动页面进入首页的情况
uni
.
setStorageSync
(
"confirmLogin"
,
true
)
uni
.
reLaunch
({
url
:
'/pages/tab/index'
})
url
:
'pages/tab/index'
});
return
}
//encodeURIComponent是为了解决后端接收不到+/等特殊字符
let
code
=
{
let
params
=
{
encryptedData
:
encodeURIComponent
(
event
.
detail
.
encryptedData
),
iv
:
encodeURIComponent
(
event
.
detail
.
iv
),
openId
:
encodeURIComponent
(
this
.
openId
)
}
// 第一次登录请求
await
this
.
usersFirstLogin
(
code
).
catch
(
res
=>
{
//结束加载交互
console
.
log
(
"第一次登录错误信息"
,
res
);
//更改错误信息
await
phoneLogin
(
params
).
then
((
res
)
=>
{
this
.
token
=
res
.
data
.
token
// 存储token
// 存储用户信息
uni
.
setStorageSync
(
'token'
,
this
.
token
)
uni
.
setStorageSync
(
'userInfo'
,
JSON
.
stringify
(
res
.
data
.
data
))
}).
catch
(
res
=>
{
//错误信息
if
(
res
.
message
===
'该员工账号不存在'
||
res
.
message
===
'您的手机号被占用,请联系客服'
)
{
errMsg
=
res
.
message
}
...
...
@@ -179,16 +144,11 @@
// 判断是否获取到token
if
(
this
.
token
)
{
// 根据获取的手机号信息请求登录接口
//结束加载交互
console
.
log
(
'3333'
)
uni
.
hideLoading
();
//添加确认登录校验用于处理登录页面未进行登录而能直接从启动页面进入首页的情况
uni
.
setStorageSync
(
"confirmLogin"
,
true
)
console
.
log
(
"跳转2"
)
// this.$tab.reLaunch('/pages/index')
uni
.
reLaunch
({
uni
.
switchTab
({
url
:
'/pages/tab/index'
})
})
;
return
}
else
{
//结束加载交互
...
...
@@ -196,161 +156,10 @@
uni
.
showToast
({
title
:
errMsg
,
icon
:
"none"
// icon: 'error'
})
}
},
/**
* 用户第一次使用手机号登录
* @param {Object} code 登录所需的信息
*/
usersFirstLogin
(
code
)
{
return
phoneLogin
(
code
).
then
((
res
)
=>
{
this
.
token
=
res
.
data
.
token
// 存储token
// 存储用户信息
uni
.
setStorageSync
(
'token'
,
this
.
token
)
uni
.
setStorageSync
(
'userInfo'
,
JSON
.
stringify
(
res
.
data
.
data
))
})
},
/**
* 以下为原来的代码 暂时保留 后续没用了再删
*/
handleShowTips
()
{
this
.
getUserInfo
();
// this.tipsShow = true
},
getUserInfo
()
{
// #ifdef MP-WEIXIN
try
{
wx
.
getUserProfile
({
desc
:
'用于完善会员资料'
,
success
:
resinfo
=>
{
wx
.
login
({
success
:
res
=>
{
if
(
res
.
code
)
{
console
.
log
(
res
.
code
,
resinfo
);
this
.
setCode
(
res
.
code
,
resinfo
);
}
else
{}
},
fail
:
err
=>
{}
});
},
fail
:
errinfo
=>
{
this
.
setCode
(
this
.
generateRandomString
(
10
),
'null'
);
}
});
}
catch
{
wx
.
getUserInfo
({
success
:
resinfo
=>
{
wx
.
login
({
success
:
res
=>
{
if
(
res
.
code
)
{
console
.
log
(
res
.
code
,
resinfo
);
this
.
setCode
(
res
.
code
,
resinfo
);
}
else
{}
},
fail
:
err
=>
{}
});
},
fail
:
errinfo
=>
{}
});
}
// #endif
// #ifndef MP-WEIXIN
this
.
setCode
(
"ip"
,
'null'
);
// #endif
},
async
setCode
(
code
,
resinfo
)
{
console
.
log
(
code
);
const
res
=
await
this
.
$myRequest
({
url
:
'/token/wxAppletLogin'
,
data
:
{
code
:
code
},
method
:
'POST'
});
console
.
log
(
res
,
'delshoucang'
);
var
obj
=
{
code
:
code
,
state
:
res
.
data
.
code
,
nickName
:
resinfo
!=
'null'
?
resinfo
.
userInfo
.
nickName
:
"匿名用户"
};
uni
.
setStorageSync
(
'verification'
,
obj
);
if
(
res
.
data
.
code
==
200
)
{
this
.
num
=
0
;
this
.
tipsShow
=
true
;
var
info
=
{
birthday
:
res
.
data
.
data
.
info
.
birthday
,
city
:
res
.
data
.
data
.
info
.
city
,
gender
:
res
.
data
.
data
.
info
.
gender
,
headPortrait
:
res
.
data
.
data
.
info
.
headPortrait
,
id
:
res
.
data
.
data
.
info
.
id
,
nickName
:
res
.
data
.
data
.
info
.
nickName
};
uni
.
setStorageSync
(
'info'
,
info
);
uni
.
setStorageSync
(
'token'
,
res
.
data
.
data
.
token
);
var
itemobj
=
{
birthday
:
res
.
data
.
data
.
info
.
birthday
,
age
:
res
.
data
.
data
.
info
.
birthday
,
gender
:
res
.
data
.
data
.
info
.
gender
,
city
:
res
.
data
.
data
.
info
.
city
};
uni
.
setStorageSync
(
'itemobj'
,
itemobj
);
}
else
if
(
res
.
data
.
code
==
11002
)
{
this
.
tipsShow
=
true
;
this
.
num
=
1
;
}
else
{
this
.
tipMsg
=
res
.
data
.
msg
;
this
.
$refs
.
elm
.
showDialog
();
}
},
handleNoAgree
()
{
this
.
tipsShow
=
false
;
},
handAgree
()
{
this
.
tipsShow
=
false
;
if
(
this
.
num
==
0
)
{
uni
.
switchTab
({
url
:
'/pages/tab/index'
});
}
else
{
uni
.
navigateTo
({
url
:
'./gender'
});
}
},
// 生成指定长度的随机字符串
generateRandomString
(
length
)
{
let
result
=
uni
.
getStorageSync
(
'touristopenid'
);
if
(
result
!=
null
&&
result
!=
""
)
{
return
result
;
}
else
{
result
=
''
;
}
const
characters
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
;
// 包含大小写字母和数字的所有字符集合
for
(
let
i
=
0
;
i
<
length
;
i
++
)
{
const
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
characters
.
length
);
result
+=
characters
[
randomIndex
];
}
var
now
=
new
Date
();
var
year
=
now
.
getFullYear
();
// 年份
var
month
=
(
now
.
getMonth
()
+
1
).
toString
().
padStart
(
2
,
'0'
);
// 月份(注意要加上1)
var
day
=
now
.
getDate
().
toString
().
padStart
(
2
,
'0'
);
// 天数
var
hours
=
now
.
getHours
().
toString
().
padStart
(
2
,
'0'
);
// 小时
var
minutes
=
now
.
getMinutes
().
toString
().
padStart
(
2
,
'0'
);
// 分钟
var
seconds
=
now
.
getSeconds
().
toString
().
padStart
(
2
,
'0'
);
// 秒数
result
=
"touristopenid"
+
result
+
(
+
year
+
month
+
day
+
hours
+
minutes
+
seconds
);
uni
.
setStorageSync
(
'touristopenid'
,
result
);
return
result
;
}
}
};
</
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