提交 a2b32744 authored 作者: 何喜's avatar 何喜

增加我要提问

上级 0c3096ea
{
"pages": [
"pages/index/index",
"pages/learnSystem/question/question",
"pages/outSite/outSite",
"pages/videoPlayer/show",
"pages/learnSystem/home/home",
......
......@@ -11,6 +11,12 @@ Page({
goMyDiscuss: function () { wx.navigateTo({ url: '/pages/learnSystem/myDiscuss/myDiscuss' }) },
/* 我的学分 */
goMyScore: function () { wx.navigateTo({ url: '/pages/learnSystem/myScore/myScore' }) },
// 我要提问
question:function(){
wx.navigateTo({
url:'/pages/learnSystem/question/question'
})
},
/* 退出系统 */
outSystem: function () {
......
......@@ -19,9 +19,9 @@
<image class='img' src='../icons/my/out-system.png' mode='aspectFit'></image>
<view class='text'>退出系统</view>
</view>
<view class='item'>
<image class='img' src='../icons/my/my-waiting.png' mode='aspectFit'></image>
<view class='text'>敬请期待</view>
<view class='item' bindtap='question'>
<image class='img' src='../icons/my/my-discuss.png' mode='aspectFit'></image>
<view class='text'>我要提问</view>
</view>
</view>
<!-- 增加 关联公众号组件 - 模拟器上不显示,真机没问题 -->
......
// pages/learnSystem/question/question.js
const util = require('../../../utils/util.js')
Page({
/**
* 页面的初始数据
*/
data: {
title:'',
contents:'',
type_id: '',
list:[
{name:'全部',value:'0'},
{name:'教务',value:'1'},
{name:'技术',value:'2'},
],
objUrl: {},
imgUrl:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
// 标题输入
titleInput:function(e){
this.setData({
title: e.detail.value
})
},
// 内容输入
contentsInput:function(e){
this.setData({
contents: e.detail.value
})
},
// 问题类型
radioChange: function (e) {
this.setData({
type_id: e.detail.value
})
},
// 选择图片
chooseFile:function(){
const that = this;
wx.chooseImage({
count: 9,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success (res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFiles = res.tempFiles;
let obj = {};
for(let i = 0;i<tempFiles.length;i++){
obj[tempFiles[i].path] = tempFiles[i].size;
}
let _objUrl = that.data.objUrl;
Object.assign(_objUrl,obj);
console.log('res',Object.keys(_objUrl));
that.setData({
imgUrl: Object.keys(_objUrl),
objUrl: _objUrl
})
}
})
},
// 删除照片
deleteImg:function(e){
let _url = e.target.dataset.url;
let _objUrl = this.data.objUrl;
delete _objUrl[_url]
this.setData({
imgUrl: Object.keys(_objUrl),
objUrl: _objUrl
})
},
// 上传数据
submit:function(){
if(!this.data.title){
util.showTips({title:'请输入标题'})
return;
}
if(!this.data.contents){
util.showTips({title:'请输入详细描述'})
return;
}
if(!this.data.type_id){
util.showTips({title:'请选择问题类型'})
return;
}
const that = this;
util.requestApi({
url: util.config.URL_PATH1 + '/v2/feedback/commit',
data: {
title: that.data.title,
contents: that.data.contents,
type_id: that.data.type_id,
attachments: JSON.stringify([{
name: '',
url: ''
}])
},
method: 'POST',
callback: function (res) {
util.showTips({title:'提交成功',icon:'success',duration: 3000})
that.setData({
title: '',
contents: '',
type_id: ''
})
}
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/learnSystem/question/question.wxml-->
<!-- 我要提问页面 -->
<view >
<view class="form-input">
<view class="title">标题</view>
<input class="input" value="{{title}}" type="text" maxlength="25" cursor-spacing="10" focus="true" placeholder="请输入标题" placeholder-class="input-placeholder" bindinput="titleInput"/>
</view>
<view class="list">
<textarea placeholder="详细描述" placeholder-class="input-placeholder" value="{{contents}}" bindinput="contentsInput" />
</view>
<view class="form-input">
<view class="title">问题类型</view>
<radio-group class="input " bindchange="radioChange">
<label class="radio-list" wx:for="{{list}}" wx:for-item="item" wx:key="{{item.value}}">
<radio value="{{item.value}}" /><text >{{item.name}}</text>
</label>
</radio-group>
</view>
<!-- <view class="form-file"> -->
<!-- <view class="input-file preview" wx:for="{{imgUrl}}" wx:for-item="item" wx:key="{{item}}">
<view class="delete" bindtap="deleteImg"><icon type="cancel" size="23" data-url="{{item}}"/></view>
<image mode="aspectFit" src="{{item}}"/>
</view>
<view class="input-file upload" bindtap="chooseFile">
<view class="input-placeholder title">上传图片(可选)</view>
<view class="icon">+</view>
</view>
</view> -->
<button class="submit" type="primary" bindtap="submit">提交</button>
</view>
/* pages/learnSystem/question/question.wxss */
page{
background-color: rgba(178, 178, 178, .1);
}
.form-input{
width: 750rpx;
height: 88rpx;
position: relative;
font-size: 34rpx;
line-height: 88rpx;
margin-top: 40rpx;
background-color: #fff;
}
.form-input .title{
position: absolute;
left: 30rpx;
top: 0;
height: 88rpx;
width: 140rpx;
line-height: 88rpx;
}
.form-input .input{
padding-left: 170rpx;
line-height: 88rpx;
height: 88rpx;
background-color: #fff;
font-size: 34rpx;
}
.form-input radio-group.input{
padding-left: 190rpx;
}
.form-input .radio-list{
width: 170rpx;
display: inline-block;
}
.form-input .radio-list radio{
transform: scale(.5);
}
.list{
margin-top: 40rpx;
background-color: #fff;
padding: 12rpx 30rpx;
width: 690rpx;
}
.input-placeholder{
font-size: 30rpx;
}
.form-file{
margin: 30rpx 30rpx 100rpx;
width: 750rpx;
overflow: hidden;
}
.form-file .title{
text-align: center;
}
.input-file{
width: 200rpx;
height: 200rpx;
float: left;
margin-top: 20rpx;
}
/* .input-file:first-child{
margin-left: 30rpx;
} */
.form-file .input-file .title{
margin-top: 40rpx;
font-size: 26rpx;
}
.form-file .icon{
font-size: 120rpx;
text-align: center;
font-weight: 500;
line-height: .5;
color: #b2b2b2;
}
.preview{
margin-right: 20rpx;
position: relative;
}
.preview .delete{
position: absolute;
right: -10rpx;
top: -10rpx;
}
.preview image{
display: block;
width: 200rpx;
height: 200rpx;
background-color: #fff;
}
.input-file.upload{
background-color: #fff;
}
.submit{
display: block;
margin: 100rpx auto;
width: 680rpx;
}
\ No newline at end of file
......@@ -230,6 +230,19 @@ const sendformid = (formId) => {
})
}
// 消息提示
const showTips = (obj) => {
wx.showToast({
title: obj.title,
icon: obj.icon || 'none',
image: obj.image|| '',
duration: obj.duration || 2000,
mask: false,
success: (result) => {},
fail: () => {},
complete: () => {}
});
}
/**
* localStorage 中存放的 各种值
* userSession - 调用 login 获取对应的 sessionKey openId等值
......@@ -244,5 +257,6 @@ module.exports = {
requestApi: requestApi,
durationToTimeString: durationToTimeString,
sendformid: sendformid,
showTips: showTips,
LoginAgainAndJumpPage: LoginAgainAndJumpPage
};
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论