Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
mini-program
/
ai-card
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 70dbb42e
authored
Dec 13, 2022
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提交授权组件
1 parent
cb664ab0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
120 additions
and
99 deletions
app.js
components/PhoneNumber/PhoneNumber.js
components/PhoneNumber/PhoneNumber.scss
components/PhoneNumber/PhoneNumber.wxml
components/PhoneNumber/PhoneNumber.wxss
pages/tab/index/index.js
pages/tab/index/index.wxml
app.js
View file @
70dbb42
...
...
@@ -13,7 +13,7 @@ import util from './utils/util.js'
import
'./utils/Track'
import
{
ssoApi
,
wechatApi
}
from
'./api/api'
import
{
trackData
}
from
'./utils/data'
import
eventbus
from
'./utils/evenbus'
//
import eventbus from './utils/evenbus'
// 实例化对象存储
import
{
Storage
}
from
'./utils/cache/storage'
const
$Storage
=
new
Storage
()
...
...
@@ -62,7 +62,6 @@ App({
wx
.
$storage
.
set
(
'aicard_info'
,
wechatInfo
)
wx
.
$authStatus
=
res
.
code
!=
0
openId
=
wechatInfo
.
openId
console
.
log
(
wx
.
$trackData
)
wx
.
showMeasure
=
!!
wx
.
$trackData
.
scene
if
(
wx
.
$trackData
.
scene
)
{
// 初次进入小程序默认埋首页
...
...
@@ -74,11 +73,15 @@ App({
merchant
:
res
.
merchantId
,
cardId
:
res
.
cardId
})
_this
.
getUserInfo
(
openId
,
returnResponse
).
then
(
result
=>
{
wx
.
$Track
.
sendTrack
(
trackData
.
COMPANY
,
wechatInfo
)
resolve
(
result
)
})
const
userInfo
=
wx
.
$storage
.
get
(
'aicard_user_info'
)
if
(
!
userInfo
)
{
_this
.
getUserInfo
(
openId
,
returnResponse
).
then
(
result
=>
{
wx
.
$Track
.
sendTrack
(
trackData
.
COMPANY
,
wechatInfo
)
resolve
(
result
)
})
}
else
{
resolve
(
userInfo
)
}
})
}
else
{
// 其他的分享进来的页面走这里,在进页面的onshow中需对wx.$trackData先赋值
...
...
components/PhoneNumber/PhoneNumber.js
View file @
70dbb42
/*
* @Description:
* @Author: huyue
* @Date: 2022-12-09 13:58:15
* @LastEditors: huyue
* @LastEditTime: 2022-12-13 10:36:15
*/
// components/Login/Login.js
import
{
ssoApi
}
from
"../../api/api"
;
import
{
componentsMixin
}
from
"../../mixins/index"
;
...
...
@@ -24,18 +31,26 @@ Component({
value
:
true
},
/**
* type: 场景类型: 1.首页,整行;2.详情中的查看更多和申请合作切换;3.透明的;
* type: 场景类型: 1.首页,整行;2.详情中的查看更多和申请合作切换;3.透明的
(暂无)
;
*/
type
:
{
type
:
Number
,
value
:
1
},
hasPhoneNumber
:
{
type
:
Boolean
,
}
},
observers
:
{
'hasPhoneNumber'
(
val
)
{
console
.
log
(
val
)
}
},
observers
:
{},
/**
* 组件的初始数据
*/
data
:
{},
data
:
{
},
/**
* 组件的方法列表
...
...
@@ -43,40 +58,34 @@ Component({
methods
:
{
// 获取手机号
getPhoneNumber
({
detail
})
{
if
(
detail
.
errMsg
&&
// e.detail.errMsg == "getPhoneNumber:fail user deny"
detail
.
errMsg
.
indexOf
(
'user deny'
)
!==
-
1
)
{
if
(
detail
.
errMsg
&&
detail
.
errMsg
.
indexOf
(
'user deny'
)
!==
-
1
)
{
wx
.
hideLoading
()
return
;
}
else
{
// wx.$util.showLoading('正在授权...')
}
// this.triggerEvent("updatePhoneNumber", '18873336682');
wx
.
$util
.
showLoading
(
'正在授权...'
)
getApp
()
.
login
(
true
)
.
then
(({
data
})
=>
{
delete
detail
.
errMsg
;
if
(
detail
.
iv
&&
detail
.
encryptedData
)
{
ssoApi
.
authUserPhone
(
detail
).
then
(({
data
,
code
,
message
})
=>
{
wx
.
hideLoading
()
if
(
code
==
0
)
{
wx
.
$util
.
setUserInfo
(
data
);
// wx.$util.setSessionId(data.sessionId);
// 其他操作
this
.
triggerEvent
(
"updatePhoneNumber"
,
data
.
phone
);
}
else
{
wx
.
showToast
({
title
:
message
,
icon
:
'none'
,
duration
:
2000
})
}
});
delete
detail
.
errMsg
;
if
(
detail
.
iv
&&
detail
.
encryptedData
)
{
ssoApi
.
authUserPhone
(
detail
).
then
(({
data
,
code
,
message
})
=>
{
wx
.
hideLoading
()
if
(
code
==
0
)
{
wx
.
$util
.
setUserInfo
(
data
);
// 其他操作
this
.
triggerEvent
(
"updatePhoneNumber"
,
data
.
phone
);
}
else
{
wx
.
showToast
({
title
:
message
,
icon
:
'none'
,
duration
:
2000
})
}
});
}
},
jump
()
{
this
.
triggerEvent
(
'toApplication'
)
},
forward
()
{
this
.
triggerEvent
(
'toForward'
)
}
},
});
components/PhoneNumber/PhoneNumber.scss
View file @
70dbb42
.fixBottom
{
position
:
fixed
;
display
:
flex
;
bottom
:
0
;
width
:
100%
;
box-sizing
:
border-box
;
background-color
:
#fff
;
padding
:
16rpx
48rpx
76rpx
;
box-shadow
:
inset
0
2rpx
0
0
#F2F3F7
;
filter
:
blur
(
0
);
.phoneNumber
{
width
:
100%
;
...
...
@@ -15,9 +15,53 @@
font-size
:
32rpx
;
color
:
#FFFFFF
;
letter-spacing
:
0
;
height
:
72rpx
;
line-height
:
72rpx
;
}
.forward-box
{
width
:
136rpx
;
padding
:
4rpx
44rpx
;
height
:
88rpx
;
text-align
:
center
;
margin-right
:
40rpx
;
margin-top
:
-16rpx
;
box-shadow
:
8rpx
0
16rpx
0
rgba
(
202
,
211
,
230
,
0
.30
);
.forward-text
{
line-height
:
32rpx
;
}
}
.icon-forward
{
width
:
48rpx
;
height
:
48rpx
;
}
button
{
margin
:
0
;
line-height
:
88rpx
;
}
.phone-number
{
display
:
flex
;
width
:
100%
;
align-items
:
center
;
justify-content
:
center
;
// margin: 16rpx 48rpx;
color
:
#fff
;
font-size
:
28rpx
;
letter-spacing
:
0
.8rpx
;
background
:
#5850FF
;
background-image
:
linear-gradient
(
180deg
,
#4791FF
0%
,
#5850FF
100%
,
#643DFF
100%
);
border-radius
:
8rpx
;
line-height
:
72rpx
;
.icon-arrow
{
width
:
32rpx
;
height
:
32rpx
;
}
.icon-arrow
:first-child
{
margin-right
:
48rpx
;
}
.icon-arrow
:last-child
{
margin-left
:
48rpx
;
}
}
}
button
{
margin
:
0
;
line-height
:
88rpx
;
}
\ No newline at end of file
components/PhoneNumber/PhoneNumber.wxml
View file @
70dbb42
<view wx:if="{{type}}" class="fixBottom">
<button class="phoneNumber" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">合作申请</button>
<view wx:if="{{type == 1}}" class="fixBottom">
<button wx:if="{{hasPhoneNumber}}" class="phoneNumber" bindtap="jump">合作申请</button>
<button wx:else class="phoneNumber" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">合作申请</button>
</view>
<!-- <block wx:else>
<block wx:if="{{isImage}}">
<button class="imageBtn" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">
</button>
<view wx:if="{{type == 2}}" class="fixBottom">
<block wx:if="{{hasPhoneNumber}}">
<view class="forward-box">
<image class="icon-forward" webp src="{{IMGURL}}home/icon-forward.png"></image>
<view class="forward-text" bindtap="forward">转发</view>
</view>
<button class="phoneNumber" bindtap="jump">申请合作</button>
</block>
<block wx:else>
<button class="
{{isHidden ? 'hidden-phone':'phone-number'}}
" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">
<image
wx:if="{{showIcon}}"
class="icon-arrow" webp src="{{IMGURL}}home/icon-arrow.png"></image>
<button class="
phone-number
" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">
<image class="icon-arrow" webp src="{{IMGURL}}home/icon-arrow.png"></image>
{{phoneText}}
<image
wx:if="{{showIcon}}"
class="icon-arrow" webp src="{{IMGURL}}home/icon-arrow.png"></image>
<image class="icon-arrow" webp src="{{IMGURL}}home/icon-arrow.png"></image>
</button>
</block>
</block> -->
\ No newline at end of file
</view>
\ No newline at end of file
components/PhoneNumber/PhoneNumber.wxss
deleted
100644 → 0
View file @
cb664ab
/* 手机号授权 */
.phone-number {
display: flex;
align-items: center;
justify-content: center;
margin: 16rpx 48rpx;
color: #fff;
font-size: 28rpx;
letter-spacing: 0.8rpx;
background: #5850FF;
background-image: linear-gradient(180deg, #4791FF 0%, #5850FF 100%, #643DFF 100%);
border-radius: 8rpx;
}
.icon-arrow {
width: 32rpx;
height: 32rpx;
}
.icon-arrow:first-child {
margin-right: 48rpx;
}
.icon-arrow:last-child {
margin-left: 48rpx;
}
.hidden-phone {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 2;
background-color: transparent;
color: transparent;
}
.imageBtn {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: transparent;
}
\ No newline at end of file
pages/tab/index/index.js
View file @
70dbb42
...
...
@@ -93,12 +93,16 @@ Page({
// 更新手机号
updatePhoneNumber
(
e
)
{
console
.
log
(
e
)
if
(
e
.
detail
)
{
this
.
setData
({
hasPhoneNumber
:
true
,
});
}
},
toApplication
()
{
console
.
log
(
2323
)
},
jump
()
{
wx
.
$router
.
go
(
'/packagesList/pages/measure/measure/measure'
)
...
...
@@ -133,8 +137,9 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow
()
{
const
userInfo
=
wx
.
$util
.
getUserInfo
()
this
.
setData
({
hasPhoneNumber
:
wx
.
$util
.
getUserInfo
()
&&
wx
.
$util
.
getUserInfo
().
phone
hasPhoneNumber
:
!!
(
userInfo
&&
userInfo
.
phone
)
})
const
options
=
wx
.
getEnterOptionsSync
()
wx
.
$trackData
=
options
.
query
...
...
pages/tab/index/index.wxml
View file @
70dbb42
...
...
@@ -31,4 +31,4 @@
<image class="floating-icon" bindtap="handleOpen" webp src="{{IMGURL}}home/custom.png?v={{img_version}}"></image>
</view>
</view>
<phone-number type="{{1}}"></phone-number>
\ No newline at end of file
<phone-number type="{{1}}" bindtoApplication="toApplication" bindupdatePhoneNumber="updatePhoneNumber" hasPhoneNumber="{{hasPhoneNumber}}"></phone-number>
\ No newline at end of file
Write
Preview
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