首页 > 小程序教程 > 微信小程序新建投票简单表单填写样式模板制作设计下载

微信小程序新建投票简单表单填写样式模板制作设计下载

上一篇 下一篇
今天给大家带来新建投票简单表单填写,制作好以后效果图如下:
一、wxml页面代码如下:
<view class="page">
    
    <view class="page__bd">
        <view class="weui-form-preview">
            <view class="weui-form-preview__hd">
                <view class="weui-form-preview__item">
                    <view class="weui-form-preview__label text-font-my-family">课程名称/老师:</view>
                    <view class="weui-form-preview__label">

                        <!--<picker bindchange="bindCoursePickerChange" value="{{courseIndex}}" range="{{courseNames}}">
                            <view class="weui-input text-font-my-family">{{courseNames[courseIndex]}}</view>
                        </picker>-->
                        <input bindinput="bindCourseNameInput" type="text" value=""/>

                    </view>
                </view>
            </view>
            <block wx:for="{{options}}" wx:key="{{item}}">
                <view class="weui-form-preview__bd">
                    <view class="weui-form-preview__item">
                        <view class="weui-form-preview__label text-font-my-family">{{item}}</view>
                    </view>
                </view>
            </block>
            <view class="weui-form-preview__bd">
                <view class="weui-form-preview__item">
                    <view class="weui-form-preview__label text-font-my-family">
                        <input bindinput="bindKeyInput" class="text-font-my-family" value="{{option}}" type="text" placeholder="请输入选项"/>
                    </view>
                </view>
            </view>
            <view class="weui-form-preview__ft">
                <view bindtap="addOption" class="weui-form-preview__btn weui-form-preview__btn_primary" hover-class="weui-form-preview__btn_active text-font-my-family">
                    <text>添加选项</text>
                </view>
            </view>
        </view>
    </view>
</view>

    <view class="page-section">
      <view class="weui-cells weui-cells_after-title">
        <view class="weui-cell weui-cell_switch">
          <view class="weui-cell__bd text-font-my-family">红包奖励</view>
          <view class="weui-cell__ft">
            <switch checked />
          </view>
        </view>
        <view class="weui-cell weui-cell_switch">
          <view class="weui-cell__bd text-font-my-family">截止日期</view>
          <view class="weui-cell__ft">

            <view class="new-vote-select-date">
                <picker mode="date" value="{{date}}" start="2015-09-01" end="2017-09-01" bindchange="bindDateChange">
                    <view class="weui-input text-font-my-family">日期:{{date}}</view>
                </picker>
            </view>

            <view class="new-vote-select-time">
                <picker mode="time" value="{{time}}" start="09:01" end="21:01" bindchange="bindTimeChange">
                    <view class="weui-input text-font-my-family">时间:{{time}}</view>
                </picker>
            </view> 
          </view>
        </view>
      </view>
    </view>

    <button type="primary" bindtap="newVote">完成</button>
 
二、wxss样式文件代码如下:
@import "../common/lib/weui.wxss";

.weui-form-preview{
    margin-bottom: 25px;
}
.new-vote-select-date {
    float: left;
}
.new-vote-select-time {
    margin-left: 20rpx;
    float: left;
}
.text-font-my-family {
    font-family: SimHei;
}
三、js页面代码如下:
var app = getApp()

Page({
    data: {
        index: 0,
        date: '2016-09-01',
        time: '12:01',
        options: [],
        option: "",
        courseInfos: null,
        courseNames: null,
        courseIndex: 0,
        courseNameInput: null,
    },

    onShow: function() {
        app.getCourseInfos(this.updateCourseInfos)
    },

    // 更新课程信息
    updateCourseInfos: function(courseInfos) {
        var courseNames = new Array();
        for(var courseInfo in courseInfos) {
            courseNames.push(courseInfos[courseInfo].courseName)
        }
        this.setData({
            courseInfos: courseInfos,
            courseNames: courseNames
        })
    },
    // 课程选择
    bindCoursePickerChange: function(e) {
        this.setData({
            courseIndex: e.detail.value
        })
    },

    bindDateChange: function(e) {
        this.setData({
            date: e.detail.value
        })
    },
    bindTimeChange: function(e) {
        this.setData({
            time: e.detail.value
        })
    },

    bindKeyInput: function(e) {
        this.setData({
            option: e.detail.value
        })
    },

    // 添加评价
    addOption: function(e) {
        var newOptions = this.data.options;
        newOptions.push(this.data.option);
        console.log(newOptions[0]);
        this.setData({
            options: newOptions,
            option: ""
        })
    },
    // 添加投票
    newVote: function(e) {
        var courseObject = new Object()
        var courseNo = "xxx"
        var courseName = this.data.courseNameInput
        var courseType = "艺术课"
        var courseSocre = 9.5
        courseObject.courseNo =  courseNo
        courseObject.courseName =  courseName
        courseObject.courseType =  courseType
        courseObject.courseSocre =  courseSocre
        
        var evaluation = new Array();
        for(var option in this.data.options) {
            var optionObject = new Object()
            optionObject.name =  this.data.options[option]
            optionObject.data = 1
            evaluation.push(optionObject)
        }
        courseObject.evaluation = evaluation
        console.log(courseObject)
        var newCourseInfos = this.data.courseInfos
        newCourseInfos.push(courseObject)
        this.setData({
            courseInfos: newCourseInfos
        })

        wx.setStorage({
          key: 'courseInfos',
          data: newCourseInfos,
          success: function(res){
            // success
            console.log("投票添加成功")
            wx.showToast({
                title: '添加成功(可在首页查看)',
                icon: 'success',
                duration: 2000
            })
          },
          fail: function() {
            // fail
          },
          complete: function() {
            // complete
          }
        })
    },
    // 添加投票
    bindCourseNameInput: function(e) {
        this.setData({
            courseNameInput: e.detail.value
        })
        console.log(this.data.courseNameInput)
    }
});

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

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