收藏
回答

navigateTo与redirectTo跳转出现问题

问题模块 框架类型 问题类型 操作系统 工具版本
开发者工具 小程序 Bug Windows 最新版本

// 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为空

最后一次编辑于  01-07  (未经腾讯允许,不得转载)
邀请回答
复制链接收藏投诉关注问题回答

5 个回答

  • 前端工程师-天道酬勤
    前端工程师-天道酬勤
    01-08

    跟页面栈有关系???

    01-08
    赞同 1
    回复 1
    • _R
      _R
      01-08

      嗯,是页面栈的问题,已解决,谢谢您

      01-08
      回复
  • _R
    _R
    01-07

    感谢各位大佬,有奖赏的哦~

    01-07
    赞同
    回复
  • 管凯旋
    管凯旋
    01-07

    不如做个代码片段咯

    01-07
    赞同
    回复 15
    • _R
      _R
      01-07

      我现在就是跳转进入语音识别的页面,page的data中的followContent,用setData渲染不上文字,但

      redirectTo跳转进入followContent就能渲染上值

      01-07
      回复
    • 管凯旋
      管凯旋
      01-07回复_R

      太乱不想看

      01-07
      2
      回复
    • _R
      _R
      01-07回复管凯旋

      https://developers.weixin.qq.com/s/1efyYfmE7k5e

      01-07
      回复
    • _R
      _R
      01-07回复管凯旋

      大哥,还能帮看一看吗?


      01-07
      回复
    • 管凯旋
      管凯旋
      01-07回复_R

      两种方式myPage好像不一致,先去吃饭,等下回来看下

      01-07
      1
      回复
    查看更多(10)
  • fireKnight
    fireKnight
    01-08

    不用想,肯定是‘to’得太多了,不停to来to去,导致页面栈超过10的数量,就to不动了

    01-08
    赞同
    回复
  • 广州远传信息科技有限公司
    广州远传信息科技有限公司
    01-09

    页面栈超过10了,这代码乱得,,,

    01-09
    赞同
    回复 1
    • _R
      _R
      01-09

      新手,自学...确实是页面栈的问题,但没超过10

      01-09
      回复