You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
2.4 KiB
130 lines
2.4 KiB
5 years ago
|
// miniprogram/pages/lookmyTxt/lookmyTxt.js
|
||
|
var CloudPath=''
|
||
|
var Path=''
|
||
|
Page({
|
||
|
|
||
|
/**
|
||
|
* 页面的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
list: '',
|
||
|
picturePath:''
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
onLoad: function (options) {
|
||
|
console.log("picture=" + options.picturepath);
|
||
|
Path = options.path;
|
||
|
this.setData({
|
||
|
// list: options.list,
|
||
|
picturePath:options.picturepath,
|
||
|
path:Path
|
||
|
})
|
||
|
this.onQuery()
|
||
|
//console.log('cloudpath'+CloudPath)
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
*/
|
||
|
onReady: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面显示
|
||
|
*/
|
||
|
onShow: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面隐藏
|
||
|
*/
|
||
|
onHide: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面卸载
|
||
|
*/
|
||
|
onUnload: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
*/
|
||
|
onPullDownRefresh: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面上拉触底事件的处理函数
|
||
|
*/
|
||
|
onReachBottom: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 用户点击右上角分享
|
||
|
*/
|
||
|
onShareAppMessage: function () {
|
||
|
|
||
|
},
|
||
|
RequestTxt:function(CloudPath){
|
||
|
wx.request({//获取文本内容
|
||
|
url: CloudPath,
|
||
|
header: { 'cntent-type': 'application/json;charset=utf-8' },
|
||
|
success: (res) => {
|
||
|
console.log(res.data);
|
||
|
this.setData({
|
||
|
list: res.data,
|
||
|
})
|
||
|
try {
|
||
|
wx.setStorageSync('list', res.data)
|
||
|
} catch (e) {
|
||
|
};
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
play:function(){
|
||
|
wx.playVoice({
|
||
|
filePath: Voice,
|
||
|
success: function () {
|
||
|
wx.showToast({
|
||
|
title: '播放结束',
|
||
|
})
|
||
|
},
|
||
|
})
|
||
|
},
|
||
|
onQuery: function () {
|
||
|
const db = wx.cloud.database()
|
||
|
var i;
|
||
|
// 查询当前用户所有的 counters
|
||
|
console.log('path'+Path)
|
||
|
db.collection('text').where({
|
||
|
picture:Path,
|
||
|
}).get({
|
||
|
success: res => {
|
||
|
this.setData({
|
||
|
queryResult: JSON.stringify,
|
||
|
})
|
||
|
console.log('[数据库] [查询记录] 成功: ', res)
|
||
|
CloudPath=res.data[0].cloudPath;
|
||
|
this.RequestTxt(CloudPath)
|
||
|
console.log('cloudpathfhdkhkhk'+CloudPath)
|
||
|
},
|
||
|
fail: err => {
|
||
|
wx.showToast({
|
||
|
icon: 'none',
|
||
|
title: '查询记录失败'
|
||
|
})
|
||
|
console.error('[数据库] [查询记录] 失败:', err)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
})
|