生成藏头诗代码,藏头诗接口:https://py.myie9.com/cangtoutest/
genHeadPoem() {
this.debug(this.keywordInput)
this.keywordInput = this.keywordInput.replace(/[\s]+/g, "").replace(/\n/g, "").replace(/\r/g, "")
this.debug(this.keywordInput)
if (this.keywordInput === "") {
this.showToast("请随便输入4个不同的汉字")
return
}
let url = "https://py.myie9.com/cangtoutest/" + this.keywordInput
let that = this
this.resultPoemInput = ""
that.resultShow = "hidden"
this.showToast("生成中...,请等待10秒")
fetch.fetch({
url: url,
method: 'GET',
responseType: 'text',
success: function (ret) {
that.debug(JSON.stringify(ret))
if (500 == ret.code) {
that.showToast("您的这句诗我接不上哦。换一句吧")
return
}
let data = ret.data
that.debug(data.toString())
that.showTips(data.toString(), "藏头诗生成成功")
that.$element('keyPoem').focus(false)
},
fail: function (data, code) {
if (data.code == 500) {
that.showToast("您的这句诗我接不上哦。换一句吧")
} else {
that.showToast("发生错误,请重试。错误码:" + code + '。' + JSON.stringify(data))
}
}
})
}
复制生成整首诗代码,续写诗接口:https://py.myie9.com/xuxietest/
genPoem() {
this.debug(this.headPoemInput)
this.headPoemInput = this.headPoemInput.replace(/[\s]+/g, "").replace(/\n/g, "").replace(/\r/g, "")
this.debug(this.headPoemInput)
if (this.headPoemInput === "") {
this.showToast("请随便输入第一句诗")
return
}
let url = "https://py.myie9.com/xuxietest/" + this.headPoemInput
let that = this
this.resultPoemInput = ""
that.resultShow = "hidden"
this.showToast("生成中...,请等待10秒")
fetch.fetch({
url: url,
method: 'GET',
responseType: 'text',
success: function (ret) {
that.debug(JSON.stringify(ret))
if (500 == ret.code) {
that.showToast("您的这句诗我接不上哦。换一句吧")
return
}
let data = ret.data
that.debug(data.toString())
that.showTips(data.toString(), "藏头诗生成成功")
that.$element('keyPoem').focus(false)
},
fail: function (data, code) {
if (data.code == 500) {
that.showToast("您的这句诗我接不上哦。换一句吧")
} else {
that.showToast("发生错误,请重试。错误码:" + code + '。' + JSON.stringify(data))
}
}
})
}
复制弹窗-UI界面-接口参考(JS及TS API)-手机、平板、智慧屏和智能穿戴开发-JS API参考-HarmonyOS应用开发
数据请求-已停止维护的接口-接口参考(JS及TS API)-手机、平板、智慧屏和智能穿戴开发-JS API参考-HarmonyOS应用开发https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-http-0000001281201030)
