- 微信小程序getStorage本地缓存,用户关闭小程序本地缓存数据会清除吗?
微信小程序getStorage本地缓存,用户关闭小程序本地缓存数据会清除吗?
2019-01-11 - ios日历显示问题,真机调试没问题,上传之后扫码之后日历的日期部分无法显示,安卓
ios日历显示问题,真机调试没问题,上传之后扫码之后日历的日期部分无法显示,安卓没问题~ 日历代码: <view class='date-box'> <block wx:for='{{dateArr}}' wx:key=''> <view class='{{isToday == item.isToday ? "nowDay" : ""}}' > <view class='date-head {{selectnum == item.dateNum ? "select" :""}}' bindtap='lookHuoDong' data-year='{{year}}' data-month='{{month}}' data-datenum='{{item.dateNum}}' bindtap='updataList'> <view>{{item.dateNum}}</view> </view> </view> </block> </view> js: dateInit: function (setYear, setMonth) { //全部时间的月份都是按0~11基准,显示月份才+1 let dateArr = []; //需要遍历的日历数组数据 let arrLen = 0; //dateArr的数组长度 let now = setYear ? new Date(setYear, setMonth) : new Date(); let year = setYear || now.getFullYear(); let nextYear = 0; let month = setMonth || now.getMonth(); //没有+1方便后面计算当月总天数 let nextMonth = (month + 1) > 11 ? 1 : (month + 1); let startWeek = new Date(year + ',' + (month + 1) + ',' + 1).getDay(); //目标月1号对应的星期 let dayNums = new Date(year, nextMonth, 0).getDate(); //获取目标月有多少天 let obj = {}; let num = 0; if (month + 1 > 11) { nextYear = year + 1; dayNums = new Date(nextYear, nextMonth, 0).getDate(); } arrLen = startWeek + dayNums; for (let i = 0; i < arrLen; i++) { if (i >= startWeek) { num = i - startWeek + 1; obj = { isToday: '' + year + (month + 1) + num, dateNum: num, weight: 5 } } else { obj = {}; } dateArr[i] = obj; } this.setData({ dateArr: dateArr }) let nowDate = new Date(); let nowYear = nowDate.getFullYear(); let nowMonth = nowDate.getMonth() + 1; let nowWeek = nowDate.getDay(); let getYear = setYear || nowYear; let getMonth = setMonth >= 0 ? (setMonth + 1) : nowMonth; if (nowYear == getYear && nowMonth == getMonth) { this.setData({ isTodayWeek: true, todayIndex: nowWeek }) } else { this.setData({ isTodayWeek: false, todayIndex: -1 }) } console.log(new Date(year, nextMonth, 0).getDate(),dateArr, arrLen, now, year, month, nextMonth, startWeek) },
2019-01-10 - 小程序真机调试的时候跳转页面的很慢
就是小程序在真机调试的时候,在点击跳转的时候,有的会等待1~2秒左右才进入页面,调试的时候感觉很卡,跪求大佬,帮忙分析一波,在电脑上没问题
2019-01-10 - navigateTo与redirectTo跳转出现问题
// 获取录音管理器对象 const recorderManager = wx.getRecorderManager(); // 当前页面的对象 let myPage; // 结束录音的时候自己触发 recorderManager.onStop((res) => { // 获取到了录音文件的路径 const { tempFilePath } = res; // console.log(tempFilePath); console.log("开始发送"); // 把录音发送到后台 wx.uploadFile({ url:"http://231772m5y6.iok.la:48568/smart_order", filePath: tempFilePath, name:"wx_record", success:function(r){ console.log("成功",r); var result=JSON.parse(r.data); // 判断返回的状态 if(result.code=="00000"){ console.log(result.data); myPage.setData({ iSay: result.data.text }) }else{ // 失败 } }, fail:function(e){ console.log("失败",e); } }); }) Page({ /** * 页面的初始数据 */ data: { iSay:"", xfSay:"" }, // 按下录音 start_say(){ // console.log(1) // 开始录音 recorderManager.start(); }, // 结束录音 end_say(){ // console.log(2) // 结束录音 recorderManager.stop(); }, onReady: function () { this.audioCtx = wx.createAudioContext('myAudio'); myPage = getCurrentPages()[0] }, })
2019-01-07 - navigateTo与redirectTo跳转出现问题
// pages/addCustomer/addCustomer.js var util = require('../../utils/util.js') var dateTimePicker = require('../../utils/dateTimePicker.js'); var app = getApp();// 获取录音管理器对象 const recorderManager = wx.getRecorderManager(); // 当前页面的对象 var myPage; // 结束录音的时候自己触发 recorderManager.onStop((res) => { // 获取到了录音文件的路径 const { tempFilePath } = res; // console.log(tempFilePath); console.log("开始发送"); // 把录音发送到后台 wx.uploadFile({ url: "http://231772m5y6.iok.la:48568/smart_order", filePath: tempFilePath, name: "wx_record", success: function (r) { console.log("成功", r); var result = JSON.parse(r.data); // 判断返回的状态 if (result.code == "00000") { console.log(result.data); console.log(myPage) myPage.setData({ followContent: result.data.text, }) console.log(myPage.data.followContent) } else { // 失败 } }, fail: function (e) { console.log("失败", e); } }); }) Page({ /** * 页面的初始数据 */ data: { date: '' || util.formatTime(new Date), time: '', dateTimeArray: null, dateTime: null, dateTimeArray1: null, dateTime1: null, startYear: 2000, endYear: 2050, // date: "" || util.formatTime(new Date), name: "", tel: "", company: "", money: "", followContent: "123", address: "", userId :"", content: "", way: "", project: "", locationAddress:"", location:"" }, // 按下录音 start_say() { // console.log(1) // 开始录音 recorderManager.start(); }, // 结束录音 end_say() { // console.log(2) // 结束录音 var that = this recorderManager.stop(); setTimeout(function(){ console.log(that.data.followContent) },10000) }, // 获取input的value值 name: function(e) { this.setData({ name: e.detail.value }) }, followContent: function (e) { this.setData({ followContent: e.detail.value }) console.log(this.data.followContent) }, tel: function(e) { this.setData({ tel: e.detail.value }) }, company: function(e) { this.setData({ company: e.detail.value }) }, money: function(e) { this.setData({ money: e.detail.value }) }, go: function(e) { wx.navigateTo({ url: '../keHuYiXiang/keHuYiXiang' }) }, go1: function(e) { wx.navigateTo({ url: '../dataType/dataType' }) }, go2: function(e) { wx.navigateTo({ url: '../SelObject/SelObject' }) }, // 选择当前的位置 chooseLocation() { wx.getSetting({ success(res) { if (!res.authSetting['scope.userLocation']) { wx.authorize({ scope: 'scope.userLocation', success() { wx.chooseLocation({ success(res) { console.log(res) that.setData({ location:res.longitude+'&'+res.latitude, locationAddress: res.address }) } }) } }) }else{ wx.chooseLocation({ success(res) { console.log(res) that.setData({ location: res.longitude + '&' + res.latitude, locationAddress: res.address }) } }) } } }) const that = this }, finish: function() { wx.setStorage({ key: 'common', data: { "name": this.data.name, "tel": this.data.tel, "company": this.data.company, "money": this.data.money, "followContent": this.data.followContent, "localtion": this.data.location, 'localtionAddress': this.data.locationAddress }, }) var that = this var name = "" var tel = "" var company = "" var kehu = "" var type = "" var selobject = "" var money = "" var followContent = "" var localtion = "" var localtionAddress = "" // 当先输入完条跳转页面时,ding'j var userId = this.data.userId wx.getStorage({ key: 'common', success: function(res) { name = res.data.name tel = res.data.tel company = res.data.company money = res.data.money followContent = res.data.followContent localtion = res.data.location, localtionAddress = res.data.locationAddress console.log(res.data) if (name == "" || tel == "" || company == "" || money == "" || followContent == "" || localtion == "") { wx.showToast({ title: '内容需要填写完整', icon: 'none' }) return; } wx.getStorage({ key: 'xhyx', success: function(res) { kehu = res.data[1] wx.getStorage({ key: 'dataType', success: function(res) { type = res.data[1], wx.getStorage({ key: 'selobject', success: function(res) { var date = that.data.date + that.data.time; console.log(date) selobject = res.data[1] if (kehu == "" || type == "" || selobject == ""){ wx.showToast({ title: '内容需要填写完整', icon: 'none' }) return; } wx.showModal({ title: '操作提示', content: '确定添加该成员吗?', success: function (res) { if (res.confirm) {//这里是点击了确定以后 wx.request({ //获取openid接口12 url: app.globalUrl +'customer/addcustomer', data: { customerName: name, customerPhone: tel, customerCompany: company, customerIntentionId: kehu, customerFlowModeId: type, customerProjectId: selobject, projectAmount: money, userId: userId, customerFollowContent: followContent, appointment: date }, method: "POST", success: function (res) { console.log(res.data) if(res.data.state == 0){ wx.navigateBack({ deIta: 1 }) wx.removeStorage({ key: 'common', }) wx.removeStorage({ key: 'xhyx', }) wx.removeStorage({ key: 'dataType', }) wx.removeStorage({ key: 'selobject', }) }else{ wx.showToast({ title:res.data.message, icon:'none' }) } } }) } else {//这里是点击了取消以后 console.log('用户点击取消') } } }) }, }) }, }) }, }) }, }) }, /** * 生命周期函数--监听页面显示 */ onShow: function(options) { var that = this; // 客户意向 wx.getStorage({ key: 'xhyx', success(res) { console.log(res.data) that.setData({ content: res.data[0], }) } }) // 更近方式 wx.getStorage({ key: 'dataType', success(res) { console.log(res.data) that.setData({ way: res.data[0], }) } }) // 所属项目 wx.getStorage({ key: 'selobject', success(res) { console.log(res.data) that.setData({ project: res.data[0], }) } }) //name,tel,company,money的存储 wx.getStorage({ key: 'common', success(res) { that.setData({ name: res.data.name, tel: res.data.tel, company: res.data.company, money: res.data.money, followContent: res.data.followContent }) console.log(res.data) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ /** * 生命周期函数--监听页面加载 */ onLoad: function() { myPage = getCurrentPages()[0] var that = this wx.getStorage({ key: 'loginSign', success: function (res) { that.setData({ userId:res.data.userId }) }, }) var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear); var obj1 = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear); // 精确到分的处理,将数组的秒去掉 var lastArray = obj1.dateTimeArray.pop(); var lastTime = obj1.dateTime.pop(); this.setData({ dateTime: obj.dateTime, dateTimeArray: obj.dateTimeArray, dateTimeArray1: obj1.dateTimeArray, dateTime1: obj1.dateTime }); }, changeDate(e) { this.setData({ date: e.detail.value }); }, changeTime(e) { this.setData({ time: e.detail.value }); }, changeDateTime(e) { this.setData({ dateTime: e.detail.value }); }, changeDateTime1(e) { this.setData({ dateTime1: e.detail.value }); }, changeDateTimeColumn(e) { var arr = this.data.dateTime, dateArr = this.data.dateTimeArray; arr[e.detail.column] = e.detail.value; dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]); this.setData({ dateTimeArray: dateArr, dateTime: arr }); }, changeDateTimeColumn1(e) { var arr = this.data.dateTime1, dateArr = this.data.dateTimeArray1; arr[e.detail.column] = e.detail.value; dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]); this.setData({ dateTimeArray1: dateArr, dateTime1: arr }); }, /** * 生命周期函数--监听页面隐藏 */ // onHide: function() { // var that = this // wx.setStorage({ // key: 'common', // data: { // "name": this.data.name, // "tel": this.data.tel, // "company": this.data.company, // "money": this.data.money, // "followContent": this.data.followContent || "" // }, // }) // wx.getStorage({ // key: 'common', // success(res) { // that.setData({ // name: res.data.name, // tel: res.data.tel, // company: res.data.company, // money: res.data.money, // followContent:res.data.followContent // }) // console.log(res.data) // } // }) // }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { wx.removeStorage({ key: 'common', }) wx.removeStorage({ key: 'xhyx', }) wx.removeStorage({ key: 'dataType', }) wx.removeStorage({ key: 'selobject', }) }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { }, }) 语音识别页面,redirectTo进入语音识别页面,文字也可以渲染,navigateT进入语音识别页面,文字无法渲染,this.followContent为空
2019-01-07