124 lines
2.9 KiB
JavaScript
124 lines
2.9 KiB
JavaScript
// components/swiper.js
|
|
var request = require('../../utils/request.js')
|
|
Component({
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
source: {
|
|
type: Number,
|
|
value: 0
|
|
},
|
|
},
|
|
lifetimes:{
|
|
attached: function() {
|
|
// this.getData()
|
|
}
|
|
},
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
itemList:[],
|
|
imgList:["https://mmbiz.qpic.cn/mmbiz_png/jJtBNByXZuHuxiaoUr9CGcn4ibGpJxeNXRTG4Du0I2QqibHvDcwaDWcmqvN7cRROYoIO3k4V5ok8SsH5ABTfMAjnw/0?wx_fmt=png"],
|
|
testurl:'https://mmbiz.qpic.cn/mmbiz_png/jJtBNByXZuHuxiaoUr9CGcn4ibGpJxeNXRTG4Du0I2QqibHvDcwaDWcmqvN7cRROYoIO3k4V5ok8SsH5ABTfMAjnw/0?wx_fmt=png'
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
getData(){
|
|
request._get('/guest/finals/image',{target:this.data.source},
|
|
(res=>{
|
|
if(res.result == 0){
|
|
this.setData({
|
|
itemList:res.data
|
|
})
|
|
console.log(res.data)
|
|
}
|
|
})
|
|
)
|
|
},
|
|
Authorization(e){
|
|
let imgUrl=e.currentTarget.dataset.imgurl
|
|
this.setData({
|
|
testurl:imgUrl
|
|
})
|
|
wx.getSetting({
|
|
success:(res)=>{
|
|
if (!res.authSetting['scope.writePhotosAlbum']) {
|
|
wx.authorize({
|
|
scope: 'scope.writePhotosAlbum',
|
|
success:()=> {
|
|
// 同意授权
|
|
this.saveImg();
|
|
},
|
|
fail: (res) =>{
|
|
console.log(res);
|
|
}
|
|
})
|
|
}else{
|
|
// 已经授权了
|
|
this.saveImg();
|
|
}
|
|
},
|
|
fail:(res)=>{
|
|
console.log(res)
|
|
}
|
|
})
|
|
},
|
|
saveImg(){
|
|
console.log(this.data.testurl)
|
|
wx.getImageInfo({
|
|
src: this.data.testurl,
|
|
success:(res)=> {
|
|
let path = res.path;
|
|
wx.saveImageToPhotosAlbum({
|
|
filePath:path,
|
|
success:(res)=> {
|
|
wx.hideLoading();
|
|
setTimeout(() => {
|
|
wx.showToast({
|
|
title: '图片保存成功',
|
|
icon: 'success',
|
|
duration:3000
|
|
})
|
|
}, 200);
|
|
},
|
|
fail:(res)=>{
|
|
wx.hideLoading();
|
|
setTimeout(() => {
|
|
wx.showToast({
|
|
title: '图片保存失败',
|
|
icon: 'error',
|
|
duration:3000
|
|
})
|
|
}, 200);
|
|
}
|
|
})
|
|
},
|
|
fail:(res)=> {
|
|
console.log(res);
|
|
}
|
|
})
|
|
},
|
|
jumpTarget(e){
|
|
let imghref=e.currentTarget.dataset.imghref
|
|
if(imghref == 0){
|
|
wx.switchTab({
|
|
url: `/pages/baoming/geren`
|
|
})
|
|
}else if(imghref == 1){
|
|
wx.navigateTo({
|
|
url: `/pages/home/jpkc`
|
|
})
|
|
}else if(imghref == 2){
|
|
wx.navigateTo({
|
|
url: `/pages/baoming/erweima`
|
|
})
|
|
}
|
|
}
|
|
}
|
|
})
|