js部分似乎代码不全,所以本文仅供参考来自原文地址UI图:为方便用户使用,提问页即为首页。提问页有问题输入框、问题描述输入框、图片上传、提交/重置表单元素。index.wxss代码:/**index.wxss**/page{ background- ...
UI图:
为方便用户使用,提问页即为首页。提问页有问题输入框、问题描述输入框、图片上传、提交/重置表单元素。
index.wxss代码:
/**index.wxss**/
page{
background-color: #efeff4;
}
.container{
padding:0px;
}
.container .tip{
width: 100%;
background-color: #FFFFFF;
margin-bottom: 10px;
}
.container .tip text{
display:block;
padding: 10px;
text-align: center;
font-size: 14px;
line-height: 30px;
}
.container .form{
width: 100%;
height:100%;
background-color: #FFFFFF;
}
.container .form form{
height:100%;
display: block;
padding: 10px;
text-align: center;
}
.container .form form .section{
text-align: left;
margin: 10px 0px;
}
.section.upload{
margin: 20px 0px!important;
}
.img-upload{
height: 100%;
width: 100%;
position: relative;
}
.img-upload .img-icon-box{
display: inline-block;
margin:0px 20px 15px 0px;
}
.img-upload icon{
position: absolute;
margin: -15px 0px auto 80px;
}
.img-upload .img-box{
border: 1px #eee solid;
}
.img-upload image{
width: 80px;
height: 80px;
}
input{
width: 95%;
border-radius: 5px;
border: 1px #eee solid;
font-size: 14px;
padding: 2%;
}
textarea{
width: 95%;
border-radius: 5px;
border: 1px #eee solid;
height: 100px;
font-size: 14px;
padding: 2%;
}
.container .form form .btns{
width: 100%;
}
/*版权*/
.copyright{
height:40px;
line-height: 40px;
color:#8f8f94;
font-size:12px;
float: left;
bottom: 20px;
}
/*字体图标*/
@font-face {
font-family: iconfont;
/*字体base64 https://transfonter.org/*/
src: url(data:font/truetype;charset=utf-8;base64,AAEAAAAQAQAABAAARkZUTX4kzbEAABSsAAAAHEdERUYAJwALAAAUjAAAAB5PUy8yVyRY7wAAAYgAAABWY21hcACN7OMAAAH0AAABUmN2dCANFf9EAAANeAAAACRmcGdtMPeelQAAA0gAAAmWZ2FzcAAAABAAABSEAAAACGdseWYrrMSWAAANqAAABGBoZWFkDUF4hwAAAQwAAAA2aGhlYQe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QrLbA6LLEJBCVCsAAWsAQlsAQlIC5HI0cjYSCwBCNCsAZFKyCwYFBYILBAUVizAiADIBuzAiYDGllCQiMgR7AEQ7CAYmAgsAArIIqKYSCwAkNgZCOwA0NhZFBYsAJDYRuwA0NgWbADJbCAYmGwAiVGYTgjIDwjOBshICBGI0ewACsjYTghWbEkARQrLbA7LLAuKy6xJAEUKy2wPCywLyshIyAgPLAEI0IjOLEkARQrsARDLrAkKy2wPSywABUgR7AAI0KyAAEBFRQTLrAqKi2wPiywABUgR7AAI0KyAAEBFRQTLrAqKi2wPyyxAAEUE7ArKi2wQCywLSotsEEssAAWRSMgLiBGiiNhOLEkARQrLbBCLLAJI0KwQSstsEMssgAAOistsEQssgABOistsEUssgEAOistsEYssgEBOistsEcssgAAOystsEgssgABOystsEkssgEAOystsEossgEBOystsEsssgAANystsEwssgABNystsE0ssgEANystsE4ssgEBNystsE8ssgAAOSstsFAssgABOSstsFEssgEAOSstsFIssgEBOSstsFMssgAAPCstsFQssgABPCstsFUssgEAPCstsFYssgEBPCstsFcssgAAOCstsFgssgABOCstsFkssgEAOCstsFossgEBOCstsFsssDArLrEkARQrLbBcLLAw*A0Ky2wXSywMCuwNSstsF4ssAAWsDArsDYrLbBfLLAxKy6xJAEUKy2wYCywMSuwNCstsGEssDErsDUrLbBiLLAx*A2Ky2wYyywMisusSQBFCstsGQssDIrsDQrLbBlLLAy*A1Ky2wZiywMiuwNistsGcssDMrLrEkARQrLbBoLLAz*A0Ky2waSywMyuwNSstsGossDMrsDYrLbBrLCuwCGWwAyRQeLABFTAtAABLuADIUlixAQGOWbkIAAgAYyCwASNEILADI3CwDkUgIEu4AA5RS7AGU1pYsDQbsChZYGYgilVYsAIlYbABRWMjYrACI0SzCgkFBCuzCgsFBCuzDg8FBCtZsgQoCUVSRLMKDQYE*EGAUSxJAGIUViwQIhYsQYDRLEmAYhRWLgEAIhYsQYBRFlZWVm4Af+FsASNsQUARAAAAAAAAAAAAAAAAAAAAAAAAAAAMgAy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YAIAAtAHMAAFZlcnNpb24gMS4wOyB0dGZhdXRvaGludCAodjAuOTQpIC1sIDggLXIgNTAgLUcgMjAwIC14IDE0IC13ICJHIiAtZiAtcwAAaQBjAG8AbgBmAG8AbgB0AABpY29uZm9udAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAQACAFsBAg10aWFuamlhdHVwaWFuAAAAAQAB//8ADwABAAAADAAAABYAAAACAAEAAQAEAAEABAAAAAIAAAAAAAAAAQAAAADUJJkmAAAAANUAGkUAAAAA1QAaRQ==) format(truetype);
}
.iconfont {
font-family:iconfont !important;
font-size:16px;
font-style:normal;
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.2px;
}
.icon-zengjia:before { content: e64e; }
index.js代码:
var app = getApp();//初始化实例
var functions = require(../../function.js);//引入公共函数库
var Promise = require(../../es6-promise.min.js);//引入ES6
var imgUrls=Array();
Page({
//初始化数据
data: {
},
onLoad: function () {
var that = this;
//更新用户信息
var getUserInfo = function(){
return new Promise(function(resolve,reject){
app.getUserInfo();
resolve();
});
};
getUserInfo().then(function(){
});
},
//分享
onShareAppMessage: function () {
return {
title: 搜问网,
desc: 一键提交问题,坐等答案自动推送到您的微信上。,
path: pages/index/index
}
},
//下拉刷新
onPullDownRefresh: function(){
wx.stopPullDownRefresh();
},
//选择图片
chooseImage:function(){
var that=this;
wx.chooseImage({
count: 1,
sizeType: [compressed],
success: function(res){
var tempFilePaths = res.tempFilePaths;
console.log(tempFilePaths);
wx.uploadFile({
url: https://www.soswen.com/weixin/Question/upload, //仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
name: file,
header: {
content-type: multipart/form-data
},
success: function(res){
var data = JSON.parse(res.data);
if(data.status){
console.log(data.data);
imgUrls.push(data.data);
that.setData({
imgUrls:imgUrls
});
console.log(imgUrls);
}else{
console.log(res);
}
},
fail:function(res){
console.log(res);
}
});
}
});
},
//预览图片
previewImage:function(e){
wx.previewImage({
current:e.currentTarget.dataset.src,
urls: imgUrls
});
},
//删除图片
delImage:function(e){
console.log(e.currentTarget.dataset.key);
var tempimgUrls=Array();
for(var i=0;i