Commit 34b2ccbb by 前端

Merge branch 'zq_dev_3.0' into 'v3.0'

更改授权过程

See merge request !84
2 parents e7aaa522 ff77c3c5
......@@ -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",
......
......@@ -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
......
......@@ -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({
......
<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>
......@@ -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)=>{
......
......@@ -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>
......@@ -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)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!