Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
Y
ybf
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
xulili
ybf
Commits
e3ad46bf
Commit
e3ad46bf
authored
Apr 08, 2020
by
xd
Browse files
Options
Browse Files
Download
Plain Diff
冲突
parents
539266b5
18ebed80
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
164 additions
and
19 deletions
+164
-19
auth.js
wx_application/src/api/wx/auth.js
+0
-0
wxAuth.vue
wx_application/src/components/wxAuth.vue
+59
-0
activeDetail.vue
wx_application/src/views/active/activeDetail.vue
+105
-19
No files found.
wx_application/src/api/wx/auth.js
0 → 100644
View file @
e3ad46bf
wx_application/src/components/wxAuth.vue
0 → 100644
View file @
e3ad46bf
<
template
>
<van-dialog
v-if=
"showAuth"
v-model=
"show"
id=
"wx-auth"
title=
"微信授权"
show-cancel-button
@
confirm=
"handleConfirm"
>
<img
class=
"logo"
src=
"/img/photo.png"
alt=
"logo"
/>
<div
class=
"small-tips"
>
<p>
为您提供优质服务,亿百分需要获取以下信息
</p>
<p>
·
您的公开信息(昵称、头像等)
</p>
</div>
</van-dialog>
</
template
>
<
script
>
export
default
{
name
:
"wxAuth"
,
components
:
{},
props
:
{
showAuth
:
{
type
:
Boolean
,
default
:
false
}
},
data
()
{
return
{
show
:
true
};
},
methods
:
{
handleConfirm
()
{
this
.
$emit
(
'confirm'
);
}
}
};
</
script
>
<
style
lang=
"scss"
>
#wx-auth
{
.logo
{
width
:
20%
;
margin
:
15px
auto
;
display
:
block
;
border-radius
:
50%
;
}
.small-tips
{
margin-left
:
15px
;
p
{
padding
:
5px
10px
;
}
p
:first-child
{
font-size
:
14px
;
color
:
#333
;
}
p
:last-child
{
font-size
:
12px
;
color
:
#ccc
;
}
}
}
</
style
>
wx_application/src/views/active/activeDetail.vue
View file @
e3ad46bf
...
...
@@ -69,16 +69,23 @@
</div>
</
template
>
<div
class=
"btn-share"
:style=
"type === 'coupon'? 'bottom: 0': ''"
@
click=
"handleShare"
>
立即分享
</div>
<wx-auth
:show-auth=
"showAuthDialog"
@
confirm=
"handleCheckAuth"
></wx-auth>
</div>
</template>
<
script
>
import
wxAuth
from
"@/components/wxAuth"
;
export
default
{
name
:
"active-detail"
,
components
:
{},
components
:
{
wxAuth
},
data
()
{
return
{
code
:
''
,
showAuthDialog
:
false
,
nowUrl
:
""
,
userId
:
""
,
code
:
""
,
active_id
:
""
,
type
:
"coupon"
,
freeze
:
false
,
rolling
:
false
,
...
...
@@ -119,10 +126,23 @@ export default {
};
},
created
()
{
console
.
log
(
"活动详情1"
);
window
.
console
.
log
(
"活动详情2"
);
console
.
log
(
"url"
,
location
.
href
);
this
.
active_id
=
this
.
$route
.
query
.
id
;
this
.
type
=
this
.
$route
.
query
.
type
;
// 检测用户身份
// 获取code
this
.
zReadyUserId
()
console
.
log
(
"query"
,
this
.
$route
.
query
);
// 验证用户是否登录
if
(
!
sessionStorage
.
getItem
(
"userId"
))
{
// 1.获取code
if
(
this
.
$route
.
query
.
code
===
undefined
)
{
this
.
showAuthDialog
=
true
;
}
else
{
console
.
log
(
"code"
,
this
.
$route
.
query
.
code
);
// 拿code 换取access_token
this
.
getAccessToken
();
}
}
},
watch
:
{
prizeNumber
()
{
...
...
@@ -140,31 +160,35 @@ export default {
}
},
methods
:
{
zReadyUserId
()
{
if
(
this
.
$route
.
query
.
code
===
undefined
)
{
alert
(
"没code"
);
console
.
log
(
'code'
,
this
.
$route
.
query
.
code
);
this
.
zTestPreAuthCode
();
}
else
{
alert
(
"有code"
);
// this.zTestGetNowUrlInfo();
// this.zTestGetUserInfoByOldToken();
}
getAccessToken
()
{
const
base
=
{
baseUrl
:
"https://api.weixin.qq.com/sns/oauth2/access_token?"
,
appId
:
"ww4df265003b43fa0d"
,
secret
:
"kF8_-TZE2qad9OMaE2wYAED5rKjOb3Y5IUhHFLHVQAo"
,
code
:
this
.
code
,
grant_type
:
"authorization_code"
};
},
handleCheckAuth
()
{
this
.
showAuthDialog
=
false
;
this
.
getAuthCode
();
},
// 获取code
zTestPre
AuthCode
()
{
get
AuthCode
()
{
// alert('获取code')
const
basicInfo
=
{
head
:
"https://open.weixin.qq.com/connect/oauth2/authorize?"
,
// appId: "wwd1cdbca7b8b2b6c4",
appId
:
"ww4df265003b43fa0d"
,
redirectUrI
:
encodeURIComponent
(
"oysales.oywanhao.com:8087/activeDetail?id=2&type=wheel"
),
redirectUrI
:
encodeURIComponent
(
`oysales.oywanhao.com:8087/activeDetail?id=
${
this
.
active_id
}
&type=
${
this
.
type
}
`
),
responseType
:
"code"
,
scope
:
"snsapi_base"
,
state
:
"ztest"
,
tail
:
"#wechat_redirect"
};
console
.
log
(
"redir_url"
,
basicInfo
.
redirectUrI
);
let
url
=
basicInfo
.
head
+
"appid="
+
...
...
@@ -180,6 +204,68 @@ export default {
basicInfo
.
tail
;
window
.
location
.
href
=
url
;
},
getUserInfo
()
{
let
headerData
=
{
agentId
:
"1000033"
,
corpId
:
"ww4df265003b43fa0d"
};
axios
({
url
:
"http://139.155.48.151:8085/workWx/auth/user/get?userId="
+
this
.
userId
,
method
:
"get"
,
headers
:
headerData
})
.
then
(
res
=>
{
window
.
console
.
log
(
"用户信息"
,
res
);
})
.
catch
(
err
=>
{
console
.
log
(
err
);
});
},
getUserId
()
{
if
(
this
.
$route
.
query
.
code
===
undefined
)
{
alert
(
"没code"
);
this
.
zTestPreAuthCode
();
}
else
{
alert
(
"有code"
);
this
.
zTestGetNowUrlInfo
();
this
.
zTestGetUserInfoByOldToken
();
}
},
zTestGetNowUrlInfo
()
{
this
.
nowUrl
=
JSON
.
stringify
(
this
.
$route
.
query
);
this
.
code
=
String
(
this
.
$route
.
query
.
code
);
console
.
log
(
"nowUrl"
,
this
.
nowUrl
);
console
.
log
(
"code"
,
this
.
code
);
},
zTestGetUserInfoByOldToken
()
{
let
postData
=
{
code
:
this
.
code
};
let
headerData
=
{
agentId
:
"1000033"
,
corpId
:
"ww4df265003b43fa0d"
};
this
.
zcache
.
userInfoResOld
=
"PostData:"
+
JSON
.
stringify
(
postData
);
axios
({
url
:
"http://139.155.48.151:8085/workWx/auth/oauth2/getUserInfo?code="
+
this
.
code
,
method
:
"post"
,
headers
:
headerData
})
.
then
(
res
=>
{
alert
(
"获取用户信息接口成功"
);
this
.
userId
=
String
(
res
.
data
.
data
.
userId
);
this
.
getUserInfo
();
})
.
catch
(
err
=>
{
console
.
log
(
err
);
});
},
Start_Game
()
{
this
.
rolling
=
true
;
const
{
wheelDeg
,
prizeList
}
=
this
;
...
...
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