在微信小程序中如何实现B站封面下载功能?

/ 0评 / 0

八月初chinajoy很多小姐姐

哔哩哔哩分享了很多
今天来讲一下在微信小程序实现这个B站封面下载功能
<view>
<form bindsubmit="getImage">
<input class="input" name="biliUrl" placeholder="粘贴B站视频链接在这" type="text" value="{{videoUrl}}"></input>
<button bindtap="reset" class="button">清空</button>
<button bindtap="getUrl" class="button">粘贴</button>
<button class="button" formType="submit">获取图片</button>
</form>
<image bindtap="previewImage" class="image" mode="aspectFit" src="{{imageUrl}}" wx:if="{{imageUrl}}"></image>
</view><view class="adContainer">
<ad unit-id="adunit-db83411bc0a7051e" ad-intervals="30" bindload="adLoad" binderror="adError" bindclose="adClose"></ad>
</view>

前端需求很少,功能够行
var t = "https://api.isoyu.com/app";

Page({
data: {
videoUrl: "",
imageUrl: "",
urlList: []
},
onLoad: function(t) {},
getImage: function(a) {
var i = this, e = a.detail.value.biliUrl;
e.match("bilibili") ? wx.request({
url: t + "/bilibiliImage.php",
method: "POST",
data: {
url: e
},
header: {
"content-type": "application/x-www-form-urlencoded"
},
success: function(t) {
var a = [];
a.push(t.data), t.data ? wx.showToast({
title: "获取成功",
icon: "success"
}) : wx.showToast({
title: "获取失败",
icon: "none"
}), i.setData({
imageUrl: t.data,
urlList: a
}), console.log(i.data.imageUrl);
}
}) : wx.showToast({
title: "请先输入视频链接",
icon: "none"
});
},
previewImage: function(t) {
var a = this;
wx.previewImage({
current: a.data.imageUrl,
urls: a.data.urlList
});
},
reset: function(t) {
this.setData({
videoUrl: ""
});
},
getUrl: function(t) {
var a = this;
wx.getClipboardData({
success: function(t) {
var i = t.data;
i.match("bilibili") ? a.setData({
videoUrl: i
}) : wx.showToast({
title: "请先复制视频链接",
icon: "none"
});
}
});
},
onShareAppMessage: function(a) {
return {
title: "一个木函--B站封面下载",
path: "/pages/tools/bilibiliDown/bilibiliDown",
imageUrl: t + "/logo.png"
};
}
});

大城小爱的歌很好听~搭配这个小程序功能更棒哦

评论已关闭。