首页 > 小程序教程 > 微信小程序评论回复页面样式教程

微信小程序评论回复页面样式教程

上一篇 下一篇
本文给大家带来的是微信小程序微信小程序评论回复页面样式教程,制作好以后效果图如下:
一、wxml页面代码如下:
<view class="page">
<view class="weui-toptips weui-toptips_warn" wx:if="{{showTopTips}}">{{errorMsg}}</view>
    <view class="weui-cells weui-cells_after-title">
        <view class="weui-cell">
            <view class="weui-cell__bd">
                <textarea class="weui-textarea" auto-focus bindfocus="bindfocus" bindinput="bindinput" placeholder="回复{{data.reply}}" style="height: 5.3em" />
            </view>
        </view>
        <view class="weui-cell__bd">
            <view class="weui-uploader">
                <view class="weui-uploader__bd">
                    <view class="weui-uploader__files" id="uploaderFiles">
                        <block wx:for="{{files}}" wx:key="*this">
                            <view class="weui-uploader__file" bindtap="previewImage" id="{{item}}">
                                <image class="weui-uploader__img" src="{{item}}" mode="aspectFill" />
                            </view>
                        </block>
                    </view>
                    <view class="weui-uploader__input-box">
                        <view class="weui-uploader__input" bindtap="chooseImage"></view>
                    </view>
                </view>
            </view>
        </view>
    </view>
        <button class="weui-btn" bindtap="submit" type="primary">发布</button>
</view>
 
二、wxss样式文件代码如下:
.page{margin:10rpx;}
.weui-btn{background: #f4de3b!important;color:#000!important;}
.weui-cells::before{border-top: 0!important;}
.weui-cells{margin-top:15px;}
三、js页面代码如下:
// pages/comment/index.js
var app = getApp();
var util = require('../../utils/util.js');  
Page({
    data: {
        files: [],
        content:'',
        gender:1
    },
  chooseImage: function (e) {
      var that = this;
      wx.chooseImage({
          sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
          sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
          success: function (res) {
              // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
              res.tempFilePaths.forEach(function(item){
                wx.uploadFile({
                  url: 'https://xcx.codems.cn/api/upload', 
                  filePath: item,
                  name: 'file',
                  formData:{
                    'user': app.globalData.userInfo.id
                  },
                  success: function(res){
                    var data = JSON.parse(res.data);
                    console.log(data);
                    if(data.status == 1){
                      that.setData({
                          files: that.data.files.concat(data.data)
                      });
                      util.clearError(that);
                    }else{
                      console.log(data.msg);
                      util.isError(data.msg, that);
                    }
                  },
                  fail:function(){
                    util.isError('图片上传失败', that);
                  }
                })
              })
          }
      })
  },
  bindinput: function(e) {
    this.setData({content:e.detail.value});
  },
  previewImage: function(e){
      wx.previewImage({
          current: e.currentTarget.id, // 当前显示图片的http链接
          urls: this.data.files // 需要预览的图片http链接列表
      })
  },
  bindfocus:function(){
      util.clearError(this);
  },
  submit:function(){
    var that = this;
    var content = that.data.content;
    //console.log(content);return false;
    if(content == '' && ((that.data.files).length == 0)){
      util.isError('请输入内容或者至少选择一张图片', that);
      return false;
    }
    util.req('comment/add',{
      'iid':that.data.data.id,
      'reply':(that.data.data.reply == '楼主')?'':that.data.data.reply,
      'type':'info',
      'content':content,
      'img':JSON.stringify(that.data.files),
      'sk':app.globalData.sk
      },function(data){
      if(data.status == 1){
        wx.navigateBack({
          delta: 1
        })
      }
    })
    
    
    
  },
  onLoad:function(options){
    this.setData({
      'data.id':options.id,
      'data.reply':(options.reply)?options.reply:'楼主',
    });
  }
})

模板简介:该模板名称为【微信小程序评论回复页面样式教程】,大小是,文档格式为.,推荐使用打开,作品中的图片,文字等数据均可修改,图片请在作品中选中图片替换即可,文字修改直接点击文字修改即可,您也可以新增或修改作品中的内容,该模板来自用户分享,如有侵权行为请联系网站客服处理。欢迎来懒人模板【小程序教程】栏目查找您需要的精美模板。

相关搜索
  • 下载密码 lanrenmb
  • 下载次数 75,691次
  • 使用软件
  • 文件格式
  • 文件大小
  • 上传时间 06-22
  • 作者 网友投稿
  • 肖像权 人物画像及字体仅供参考
栏目分类 更多 >
热门推荐 更多 >
企业网站 响应式 html5 自适应 微信模板 微信文章 单页式简历模板 微信图片 微信公众平台 微信素材
您可能会喜欢的其他模板