|
|
@@ -3,7 +3,7 @@
|
|
|
<Nav title="实习岗位" leftColor="#fff" bgckgroundBox='transparent' titleColor="#fff"></Nav>
|
|
|
<image class="bg" src="@/static/img/index/sxgw.png" mode=""></image>
|
|
|
<image class="code-img" :src="codeImg" mode="aspectFit"></image>
|
|
|
- <image @click="saveImg" class="but-img" src="@/static/img/index/bcdxc.png" mode=""></image>
|
|
|
+ <!-- <image @click="saveImg" class="but-img" src="@/static/img/index/bcdxc.png" mode=""></image> -->
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
@@ -34,40 +34,71 @@
|
|
|
console.log('触底');
|
|
|
},
|
|
|
saveImg() {
|
|
|
- uni.downloadFile({
|
|
|
- url: this.codeImg,
|
|
|
- success: downloadResult => {
|
|
|
- if (downloadResult.statusCode === 200) {
|
|
|
- // 下载成功,保存图片到系统相册
|
|
|
- uni.saveImageToPhotosAlbum({
|
|
|
- filePath: downloadResult.tempFilePath,
|
|
|
- success: () => {
|
|
|
- uni.showToast({
|
|
|
- title: '图片保存成功'
|
|
|
- });
|
|
|
- },
|
|
|
- fail: () => {
|
|
|
- uni.showToast({
|
|
|
- title: '图片保存失败',
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
+ let that = this
|
|
|
+ //获取授权列表,查看是否授权写入相册权限
|
|
|
+ uni.getSetting({
|
|
|
+ success(res) {
|
|
|
+ if (!res.authSetting['scope.writePhotosAlbum']) {
|
|
|
+ uni.authorize({
|
|
|
+ scope: 'scope.writePhotosAlbum',
|
|
|
+ success() {
|
|
|
+ that.saveimgtoAlbum(that.codeImg)
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
} else {
|
|
|
- uni.showToast({
|
|
|
- title: '图片下载失败',
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
+ that.saveimgtoAlbum(that.codeImg)
|
|
|
}
|
|
|
- },
|
|
|
- fail: () => {
|
|
|
- uni.showToast({
|
|
|
- title: '图片下载失败',
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
+ saveimgtoAlbum(imgurl) {
|
|
|
+ //图片保存到本地
|
|
|
+ let that = this
|
|
|
+ uni.downloadFile({
|
|
|
+ url: imgurl,
|
|
|
+ success: function(res) {
|
|
|
+ uni.showLoading()
|
|
|
+ uni.saveImageToPhotosAlbum({
|
|
|
+ filePath: res.tempFilePath,
|
|
|
+ success: function(data) {
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showToast({
|
|
|
+ title: '保存成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: function(err) {
|
|
|
+ uni.hideLoading()
|
|
|
+ if (err.errMsg === "saveImageToPhotosAlbum:fail auth deny") {
|
|
|
+ uni.openSetting({
|
|
|
+ success(settingdata) {
|
|
|
+ if (settingdata.authSetting[
|
|
|
+ 'scope.writePhotosAlbum']) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '您已授权成功,请重新保存',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '尚未授权,无法保存',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ complete(res) {
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
},
|
|
|
}
|
|
|
</script>
|