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.

124 lines
2.3 KiB

5 years ago
// pages/ask/index.js
const device = wx.getSystemInfoSync(),rect = wx.getMenuButtonBoundingClientRect(); // 获取设备信息
const width = device.windowWidth // 示例为一个与屏幕等宽的正方形裁剪框
import commonApi from "../../utils/https/common"
import util from "../../utils/util"
Page({
/**
* 页面的初始数据
*/
data: {
menuWidth:width - rect.right + rect.width + 6,
list:[],
page_no:1,
total:1,
ques:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(!options.id){
util.back()
return;
}
this.setData({
id:options.id
})
this.getList()
},
getList:function(){
let list = this.data.list;
if(list.length>=this.data.total) return;
commonApi._post("ask/getQuestionList",{
scene_id:this.data.id,
page_no:this.data.page_no,
page_num:10
}).then(res=>{
this.setData({
list:list.concat(res.data.rows),
total:res.data.total,
page_no:this.data.page_no+1
})
console.log(res)
})
},
inputQues:function(e){
this.setData({
ques:e.detail.value
})
},
question:function(){
if(!this.data.ques){
wx.showToast({
title: '请输入问题!',
})
return;
}
commonApi.user_post("ask/postQuestion",{
scene_id:this.data.id,
question:this.data.ques
}).then(res=>{
if(res.code==1){
wx.showToast({
title: '提交成功待审核',
icon: 'success'
})
this.setData({
ques:""
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.getList()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})