Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
store-assistant
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 ff77c3c5
authored
Oct 26, 2022
by
zhangquan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
更改授权过程
1 parent
76eac997
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
98 additions
and
46 deletions
app.json
components/Authorize/Authorize.js
pages/checkProduct/checkProduct.js
pages/checkProduct/checkProduct.wxml
pages/tab/discovery/components/product/product.js
pages/tab/discovery/components/product/product.wxml
pages/tab/discovery/discovery.js
app.json
View file @
ff77c3c
...
...
@@ -74,6 +74,7 @@
],
"usingComponents"
:
{
"navigation-bar"
:
"/components/NavigationBar/NavigationBar"
,
"authorize"
:
"/components/Authorize/Authorize"
,
"popup"
:
"/components/Popup/Popup"
,
"van-picker"
:
"@vant/weapp/picker/index"
,
"van-popup"
:
"@vant/weapp/popup/index"
,
...
...
components/Authorize/Authorize.js
View file @
ff77c3c
...
...
@@ -52,7 +52,7 @@ Component({
/**
* 禁止滑动
*/
noScroll
:
wx
.
$util
.
noScroll
(),
//
noScroll: wx.$util.noScroll(),
cancel
(
e
)
{
let
{
confirm
}
=
e
.
currentTarget
.
dataset
let
{
buttonType
,
title
}
=
this
.
data
...
...
pages/checkProduct/checkProduct.js
View file @
ff77c3c
...
...
@@ -19,7 +19,7 @@ Page({
fromLocal
:
0
,
// 模态框
isShow
:
true
,
showAuth
:
false
,
btnList
:
[
{
src
:
`
${
IMGURL
}
down.png`
,
...
...
@@ -203,16 +203,33 @@ Page({
content
:
'确认下载海报?'
,
success
:
async
(
res
)
=>
{
if
(
res
.
confirm
){
let
hasAuth
=
await
this
.
toSetting
()
if
(
hasAuth
){
this
.
createImg
()
}
wx
.
getSetting
({
success
:
(
res
)
=>
{
if
(
res
.
authSetting
[
'scope.writePhotosAlbum'
]){
this
.
createImg
()
}
else
{
this
.
setData
({
showAuth
:
true
})
}
}
})
}
},
fail
:
(
res
)
=>
{},
complete
:
(
res
)
=>
{},
})
},
authFail
(){
wx
.
showToast
({
title
:
"下载海报前需要您授权'添加到相册'权限"
,
icon
:
"none"
,
duration
:
2500
,
});
},
authSuccess
(){
this
.
createImg
()
},
toSetting
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
getSetting
({
...
...
pages/checkProduct/checkProduct.wxml
View file @
ff77c3c
<product actNum="{{actNum}}" navIdx="{{activeNavIdx}}" senceData="{{senceData}}" isShare="{{true}}"/>
<view style="padding-bottom: {{fromLocal==1? 150: 0}}rpx">
<product actNum="{{actNum}}" navIdx="{{activeNavIdx}}" senceData="{{senceData}}" isShare="{{true}}"/>
</view>
<!-- 分享弹框 -->
<!-- <view class="share-wrap" wx:if="{{isShow && fromLocal==1}}">
<view class="img-wrap" wx:if="{{posterUrl}}">
...
...
@@ -36,3 +39,7 @@
</view>
</view>
</view>
<block wx:if="{{showAuth}}">
<authorize scopeType="writePhotosAlbum" buttonType="openSetting" bindfail="authFail" bindsuccess="authSuccess" show="{{showAuth}}"></authorize>
</block>
pages/tab/discovery/components/product/product.js
View file @
ff77c3c
...
...
@@ -23,6 +23,7 @@ Component({
curTabIdx
:
0
,
//适用产品
intoViewId
:
'to-0'
,
actNum
:
0
,
//场景
showAuth
:
false
},
lifetimes
:{
ready
:
function
(){
...
...
@@ -124,26 +125,48 @@ Component({
curTabIdx
:
idx
})
},
async
downVideo
(
e
)
{
let
hasAuth
=
await
this
.
toSetting
()
if
(
hasAuth
){
let
{
url
}
=
e
.
target
.
dataset
wx
.
$api
.
showToast
(
'正在下载视频...'
)
wx
.
downloadFile
({
url
:
url
,
success
(
res
)
{
if
(
res
.
statusCode
===
200
)
{
wx
.
saveVideoToPhotosAlbum
({
filePath
:
res
.
tempFilePath
,
success
(
res
)
{
wx
.
$api
.
showToast
(
'下载成功!'
)
}
})
}
downVideo
(
e
)
{
let
{
url
}
=
e
.
target
.
dataset
this
.
setData
({
curVideoUrl
:
url
})
wx
.
getSetting
({
success
:
(
res
)
=>
{
if
(
res
.
authSetting
[
'scope.writePhotosAlbum'
]){
this
.
toDown
()
}
else
{
this
.
setData
({
showAuth
:
true
})
}
})
}
}
})
},
toDown
(){
wx
.
$api
.
showToast
(
'正在下载视频...'
)
wx
.
downloadFile
({
url
:
this
.
data
.
curVideoUrl
,
success
(
res
)
{
if
(
res
.
statusCode
===
200
)
{
wx
.
saveVideoToPhotosAlbum
({
filePath
:
res
.
tempFilePath
,
success
(
resp
)
{
wx
.
$api
.
showToast
(
'下载成功!'
)
}
})
}
}
})
},
authFail
(){
wx
.
showToast
({
title
:
"下载视频前需要您授权'添加到相册'权限"
,
icon
:
"none"
,
duration
:
2500
,
});
},
authSuccess
(){
this
.
toDown
()
},
toSetting
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
pages/tab/discovery/components/product/product.wxml
View file @
ff77c3c
...
...
@@ -49,4 +49,7 @@
</view>
</block>
</scroll-view>
</view>
\ No newline at end of file
</view>
<block wx:if="{{showAuth}}">
<authorize scopeType="writePhotosAlbum" buttonType="openSetting" bindfail="authFail" bindsuccess="authSuccess" show="{{showAuth}}"></authorize>
</block>
pages/tab/discovery/discovery.js
View file @
ff77c3c
...
...
@@ -27,7 +27,8 @@ Page({
changeSale
:
0
,
sceneCodeList
:[],
currentId
:
0
,
showPage
:
false
showPage
:
false
,
showAuth
:
false
},
/**
* 生命周期函数--监听页面加载
...
...
@@ -44,24 +45,24 @@ Page({
if
(
res
?.
length
>
0
){
let
sceneCodeList
=
[]
let
senceData
=
[...
this
.
data
.
senceData
]
//
let res = [
//
{
//
sceneCode: 'SC001',
//
status: 1
//
},
//
{
//
sceneCode: 'SC002',
//
status: 1
//
},
//
{
//
sceneCode: 'SC003',
//
status: 1
//
},
//
{
//
sceneCode: 'SC004',
//
status: 1
//
}
//
]
let
res
=
[
{
sceneCode
:
'SC001'
,
status
:
1
},
{
sceneCode
:
'SC002'
,
status
:
1
},
{
sceneCode
:
'SC003'
,
status
:
1
},
{
sceneCode
:
'SC004'
,
status
:
1
}
]
res
.
forEach
((
item
,
index
)
=>
{
if
(
item
.
status
==
1
)
{
let
sceneTarget
=
senceData
.
find
(
sitem
=>
sitem
.
sceneCode
==
item
.
sceneCode
)
...
...
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