Browse Source

feature-tiktok-1.0:fix bug

feature-1.0
chengkun 4 years ago
parent
commit
14f3f44568
  1. 9
      api/creator.js
  2. 2
      pages/creator/creator.vue
  3. 328
      pages/creator/imgDetail.vue

9
api/creator.js

@ -109,4 +109,13 @@ export function insertOrUpdatePreInviteProfit(data) {
method: 'post',
data
})
}
// 检查某平台用户当日下载次数是否超标
export function checkUserCanDownload(data) {
return request({
url: `${serviceTitle}/img/mini/tiktok/checkUserCanDownload`,
method: 'post',
data
})
}

2
pages/creator/creator.vue

@ -66,7 +66,7 @@
duration: 1000,
indicatorDots: true,
pageNum: 1,
pageSize: 2,
pageSize: 10,
creatorInfo: {}
}
},

328
pages/creator/imgDetail.vue

@ -42,7 +42,8 @@
tiktokUnCollect, //
queryCreatorScanCodeById, //
insertOrUpdatePreAdProfit, ///广
insertOrUpdatePreInviteProfit // /
insertOrUpdatePreInviteProfit, // /
checkUserCanDownload //
} from '@/api/creator.js'
export default {
data() {
@ -52,8 +53,9 @@
isDownload: false, //
isLike: false, // /
isCollect: false, // ,
scanCode: undefined ,//
scanCode: undefined, //
canDownload: false // false
}
},
created() {
@ -69,7 +71,7 @@
console.log(res)
}
return {
title: '来看看艺术家['+this.scanCode+']精心准备的图片吧~',
title: '来看看艺术家[' + this.scanCode + ']精心准备的图片吧~',
path: `/pages/creator/imgDetail?id=${this.userInfo.id}`,
bgImgUrl: `${this.detailMsg.imgUrl}`
}
@ -82,14 +84,14 @@
//
async getImgDetail(id) {
const res = await detailsTiktokImg(id)
console.log('res',res)
console.log('res', res)
if (res.data.code === 200) {
this.detailMsg = res.data.data
console.log('图片详情', res)
const result = await queryCreatorScanCodeById(this.detailMsg.creatorId)
if(result.data.code === 200){
if (result.data.code === 200) {
this.scanCode = result.data.data.scanCode
}else{
} else {
uni.showToast({
title: '该艺术家不存在!',
icon: 'none'
@ -102,6 +104,7 @@
console.log('userInfo', this.userInfo)
this.searchIsLike()
this.searchisCollect()
this.checkUserDownload()
}
})
} else {
@ -202,11 +205,12 @@
},
//广
async insertPreAdProfit(){
async insertPreAdProfit() {
const params = {
imgId: this.detailMsg.id,
creatorId: this.detailMsg.creatorId,
scanCode: this.scanCode,
userId: this.userInfo.id,
appType: '0',
platform: '0'
}
@ -214,16 +218,16 @@
if (res.data.code === 200) {
console.log("写入广告收益成功!")
this.adResult = res.data.code;
}else{
} else {
uni.showToast({
title: '图片下载失败!',
icon: 'none'
})
}
},
//
async insertPreInviteProfit(){
async insertPreInviteProfit() {
const params = {
imgId: this.detailMsg.id,
creatorId: this.detailMsg.creatorId,
@ -235,146 +239,179 @@
if (res.data.code === 200) {
console.log("写入邀请收益成功");
this.inviteResult = res.data.code;
}else{
} else {
uni.showToast({
title: '图片下载失败!',
icon: 'none'
})
}
}
},
//
async checkUserDownload() {
const params = {
userId: this.userInfo.id,
appType: '0',
platform: '0'
}
const res = await checkUserCanDownload(params);
if (res.data.code === 200) {
console.log("当日下载结果为", res.data.data)
this.canDownload = res.data.data;
} else {
uni.showToast({
title: '检查下载状态失败!',
icon: 'none'
})
}
},
//
download(url) {
this.isDownload = true
uni.showLoading({
title: '正在保存图片...'
});
this.insertPreAdProfit();
this.insertPreInviteProfit();
console.log('广告响应结果',this.adResult);
console.log('邀请响应',this.inviteResult)
// if(aResult === 200 && iResult === 200){
// }
//
uni.getSetting({
success: (res) => {
//
if (!res.authSetting["scope.writePhotosAlbum"]) {
//
tt.authorize({
scope: "scope.album",
success: () => {
//
uni.downloadFile({
url,
success: (res) => {
console.log('下载路径', res)
if (res.statusCode === 200) {
uni.saveImageToPhotosAlbum({
//
filePath: res.tempFilePath,
success: (res) => {
console.log(
'success',
res)
let that = this;
if (this.canDownload != true) {
//
this.isDownload = true
uni.showLoading({
title: '正在保存图片...'
});
//
uni.getSetting({
success: (res) => {
//
if (!res.authSetting["scope.writePhotosAlbum"]) {
//
tt.authorize({
scope: "scope.album",
success: () => {
//
uni.downloadFile({
url,
success: (res) => {
console.log('下载路径', res)
if (res.statusCode === 200) {
uni.saveImageToPhotosAlbum({
//
filePath: res
.tempFilePath,
success: (res) => {
console.log(
'success',
res)
},
fail: (res) => {
console.log('fail',
res)
return uni
.showToast({
title: res
.errMsg,
icon: 'none'
});
},
complete: (res) => {
uni.hideLoading();
if (res.errMsg !==
"saveImageToPhotosAlbum:ok"
) {
return uni
.showToast({
title: "下载失败!",
icon: 'none'
});
} else {
},
fail: (res) => {
console.log(
'fail',
res)
return uni
.showToast({
title: "下载成功!",
title: res
.errMsg,
icon: 'none'
});
}
},
});
} else {
uni.showToast({
title: "下载失败!",
icon: 'none'
});
}
}
})
},
//
fail: () => {
uni.hideLoading();
uni.showModal({
title: "您已拒绝获取相册权限",
content: "是否进入权限管理,调整授权?",
success: (res) => {
if (res.confirm) {
//
uni.openSetting({
success: (
res) => {
console
.log(
res
.authSetting
);
},
});
} else if (res.cancel) {
return uni.showToast({
title: "已取消!",
icon: 'none'
});
},
complete: (res) => {
uni
.hideLoading();
if (res
.errMsg !==
"saveImageToPhotosAlbum:ok"
) {
return uni
.showToast({
title: "下载失败!",
icon: 'none'
});
} else {
return uni
.showToast({
title: "下载成功!",
icon: 'none',
success() {
that.insertPreAdProfit();
that.insertPreInviteProfit();
}
});
}
},
});
} else {
uni.showToast({
title: "下载失败!",
icon: 'none'
});
}
}
},
});
},
});
} else {
//
uni.saveImageToPhotosAlbum({
filePath: url,
success: (res) => {
uni.hideLoading();
return uni.showToast({
title: "保存成功!",
icon: 'none'
});
},
fail: (res) => {
uni.hideLoading();
console.log(res.errMsg);
return uni.showToast({
title: res.errMsg,
icon: 'none'
});
},
//
complete: (res) => {
uni.hideLoading();
},
});
}
},
fail: (res) => {},
});
})
},
//
fail: () => {
uni.hideLoading();
uni.showModal({
title: "您已拒绝获取相册权限",
content: "是否进入权限管理,调整授权?",
success: (res) => {
if (res.confirm) {
//
uni.openSetting({
success: (
res) => {
console
.log(
res
.authSetting
);
},
});
} else if (res.cancel) {
return uni.showToast({
title: "已取消!",
icon: 'none'
});
}
},
});
},
});
} else {
//
uni.saveImageToPhotosAlbum({
filePath: url,
success: (res) => {
uni.hideLoading();
return uni.showToast({
title: "保存成功!",
icon: 'none'
});
},
fail: (res) => {
uni.hideLoading();
console.log(res.errMsg);
return uni.showToast({
title: res.errMsg,
icon: 'none'
});
},
//
complete: (res) => {
uni.hideLoading();
},
});
}
},
fail: (res) => {},
});
} else {
// canDownloadtrue
uni.showToast({
title: '当日下载次数已用完,请明日再来!',
icon: 'none'
})
}
},
//
share() {
@ -407,20 +444,23 @@
right: 10px;
border-radius: 60px;
padding-top: 40rpx;
.share-box{
>button{
line-height: 0!important;
.share-box {
>button {
line-height: 0 !important;
padding: 0;
outline: none;
background: none;
border: none;
}
>button::after{
>button::after {
border: none;
}
}
.toolbar-box {
height: 60px;
text-align: center;

Loading…
Cancel
Save