Commit b6426068 authored by 不吃草的咩's avatar 不吃草的咩
Browse files

增加验证,重置数据

parent 8e7ca8f1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import { colorUISdk } from './config/mp-sdk'
App({
    colorUI,//挂载到app上
    colorUISdk,
    information:{},
    onLaunch() {
        //console.log(colorUISdk.isRandom.getRandom(6))
        //console.log(colorUISdk.version)
+2 −2
Original line number Diff line number Diff line
@@ -8,7 +8,8 @@
        "pages/demo/login/login",
        "pages/demo/set/set",
        "pages/signup/signup",
        "pages/uploadcard/uploadcard"
        "pages/uploadcard/uploadcard",
        "pages/seeSignup/seeSignup"
    ],
    "subpackages": [
        {
@@ -129,7 +130,6 @@
        "van-col": "/vantPackage/col/index",
        "van-nav-bar": "/vantPackage/nav-bar/index",
        "van-toast": "/vantPackage/toast/index"

    },
    "tabBar": {
        "color": "#aaaaaa",
+114 −30
Original line number Diff line number Diff line
// pages/document/subsign/subsign.js
import Toast from '../../../vantPackage/toast/toast';
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        username:'', //姓名
        card:'', 
        phone:'',
        company:'',
        beizhu:'',
        isShow:false,
        isShowStudy:false,
        isShowHomework:false,
@@ -20,7 +27,8 @@ Page({
            homework:'', //作业类别
            zige:'', //资格类型
            peixun:'', //培训类型
            beizhu:'' //备注
            beizhu:'', //备注
            price:''  //价格
        },
        popup:{
            genderText:'点击选择性别',
@@ -33,30 +41,37 @@ Page({
            { text: '', type:0 },
            { text: '' ,type:1},
        ],
        // columnsStudy:[
        //     {text:'初中',index:1},
        //     {text:'高中',index:2},
        //     {text:'中专',index:3},
        //     {text:'专科',index:4},
        //     {text:'本科',index:5},
        //     {text:'研究生及以上',index:6},
        // ],
        columnsStudy:[
            {text:'初中',index:0},
            {text:'高中',index:1},
            {text:'中专',index:2},
            {text:'专科',index:3},
            {text:'本科',index:4},
            {text:'研究生及以上',index:5},
        ],
        columnsHomework:[
            {text:'电工作业',index:0},
            {text:'焊接与热切割作业',index:1},
            {text:'高处作业',index:2},
            {text:'制冷与空调作业',index:3},
            {text:'金属与非金属矿山作业',index:4},
            {text:'危险化学品作业',index:5},
        ],
        columnsZige:[
            {text:'职业资格',index:0}
            '初中',
            '高中',
            '中专',
            '专科',
            '本科','研究生及以上'
        ],
        columnsPeixun:[
            {text:'新办',index:0},
            {text:'复审',index:1},
            {text:'换证',index:2},
        ]
        columnsHomework:['电工作业','焊接与热切割作业','高处作业','制冷与空调作业','金属与非金属矿山作业','危险化学品作业'],
        // columnsHomework:[
        //     {text:'电工作业',index:1},
        //     {text:'焊接与热切割作业',index:2},
        //     {text:'高处作业',index:3},
        //     {text:'制冷与空调作业',index:4},
        //     {text:'金属与非金属矿山作业',index:5},
        //     {text:'危险化学品作业',index:6},
        // ],
        columnsZige:['职业资格'],
        columnsPeixun:['新办','复审','换证']
        // columnsPeixun:[
        //     {text:'新办',index:1},
        //     {text:'复审',index:2},
        //     {text:'换证',index:3},
        // ]
        
    },
    onDisplay(){
@@ -95,26 +110,75 @@ Page({
    },
    onConfirmStudy(event){
        const { picker, value, index } = event.detail;
        this.setData({["fromDate.studyhigh"]:value.index,["popup.studyText"]:value.text,isShowStudy:false})
        this.setData({["fromDate.studyhigh"]:value,["popup.studyText"]:value,isShowStudy:false})
    },

    onConfirmHomework(event){
        const { picker, value, index } = event.detail;
        this.setData({["fromDate.homework"]:value.index,["popup.homeworkText"]:value.text,isShowHomework:false})
        this.setData({["fromDate.homework"]:value,["popup.homeworkText"]:value,isShowHomework:false})
    },
    onConfirmPeixun(event){
        const { picker, value, index } = event.detail;
        this.setData({["fromDate.peixun"]:value.index,["popup.peixunTypeText"]:value.text,isShowPeixun:false})
        this.setData({["fromDate.peixun"]:value,["popup.peixunTypeText"]:value,isShowPeixun:false})
    },
    onConfirmZige(event){
        const { picker, value, index } = event.detail;
        this.setData({["fromDate.zige"]:value.index,["popup.zigeTypeText"]:value.text,isShowZige:false})
        this.setData({["fromDate.zige"]:value,["popup.zigeTypeText"]:value,isShowZige:false})
    },
    nextCard(){
        //bug问题 重新赋值
        this.setData({
            ["fromDate.username"]:this.data.username,
            ["fromDate.card"]:this.data.card,
            ["fromDate.phone"]:this.data.phone,
            ["fromDate.company"]:this.data.company,
            ["fromDate.beizhu"]:this.data.beizhu
        });
        let params = this.data.fromDate;
        let gender = '';
        if(params.gender !== ''){
            gender = this.data.fromDate.gender == 0 ? '' :''
        }
        let reg = /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/;
        let phonereg = /^(?:(?:\+|00)86)?1\d{10}$/
        if(params.username == ''){
            Toast('姓名不能为空');
            return;
        }else if(gender == ''){
            Toast('请选择您的性别');
            return;
        }else if(!(reg.test(params.card))){
            Toast('身份证号不正确');
            return;
        }else if(!(phonereg.test(params.phone))){
            Toast('手机号格式不正确');
            return;
        }else if(params.homework == ''){
            Toast('请选择作业类别');
            return;
        }else if(params.zige == ''){
            Toast('请选择资格类型');
            return;
        }else if(params.peixun == ''){
            Toast('请选择培训类型');
            return;
        }
        app.information = this.data.fromDate;
        wx.navigateTo({
          url: '/pages/uploadcard/uploadcard',
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

        // let price = 0;
        // if(options.price == null || options.price == undefined){
        //     price = 
        // }
        this.setData({
            ["fromDate.price"]:options.price
        })
    },

    /**
@@ -128,7 +192,27 @@ Page({
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

        //有一个不为空说明已经有数据就回显数据
        if(app.information.username != undefined){
            this.setData({
                fromDate:app.information,
                username:app.information.username,
                card:app.information.card, 
                phone:app.information.phone,
                company:app.information.company,
                beizhu:app.information.beizhu,
                ["popup.genderText"]:app.information.gender == "0" ? '':'',
                ["popup.studyText"]:app.information.studyhigh == '' ? '点击选择文化程度' : app.information.studyhigh,
                ["popup.homeworkText"]:app.information.homework == '' ? '点击选择作业类别':app.information.homework,
                ["popup.zigeTypeText"]:app.information.zige == '' ? '点击选择资格类型' : app.information.zige,
                ["popup.peixunTypeText"]:app.information.peixun == '' ? '点击选择培训类型' : app.information.peixun
            });
        }
    },
    onClickLeft(){
        wx.switchTab({
          url: '/pages/signup/signup',
        })
    },

    /**
+3 −0
Original line number Diff line number Diff line
@@ -39,3 +39,6 @@

    }
}
.van-nav-bar{
    padding-top: 0px !important;
}
 No newline at end of file
+22 −11
Original line number Diff line number Diff line
<!-- 个人&&企业报名 -->
<ui-sys>
    <ui-navbar backtext="返回" isCenter>
        <text slot="center">在线培训</text>
    <ui-navbar isSlot>
        <view style="width: 100%;height: 100%;">
            <van-nav-bar
  title="在线培训"
  left-text="返回"
  left-arrow
  border="{{false}}"
  bind:click-left="onClickLeft"
/>
        </view>
    </ui-navbar>
    <view class="box">
        <van-cell-group>
            <van-cell center>
                <view slot="title"  class="txt"><text class="req">* </text><text>姓名</text></view>
                <van-field model:value="{{ fromDate.username }}" placeholder-style="place" custom-style="placeholder" placeholder="请输入用户名"  input-align="right" border="{{ false }}" />
                <van-field model:value="{{username}}" placeholder-style="place" custom-style="placeholder" placeholder="请输入用户名"  input-align="right" border="{{ false }}" />
            </van-cell>
            <van-cell center  value="{{popup.genderText}}" bind:click="onDisplay" value-class="placeholder">
                <view slot="title"  class="txt"><text class="req">* </text><text>性别</text></view>
            </van-cell>
            <van-cell center>
                <view slot="title"  class="txt"><text class="req">* </text><text>身份证号</text></view>
                <van-field model:value="{{ fromDate.card }}" placeholder="请输入您的身份证号"  input-align="right" border="{{ false }}" />
                <van-field model:value="{{ card }}" placeholder="请输入您的身份证号"  input-align="right" border="{{ false }}" />
            </van-cell>
            <van-cell center  value="{{popup.studyText}}" bind:click="onDisplayStudy" value-class="placeholder">
                <view slot="title"  class="txt"><text>文化程度</text></view>
            </van-cell>
            <van-cell center>
                <view slot="title"  class="txt"><text class="req">* </text><text>手机号</text></view>
                <van-field model:value="{{ fromDate.phone }}" placeholder="请输入您的手机号"  input-align="right" border="{{ false }}" />
                <van-field model:value="{{ phone }}" placeholder="请输入您的手机号"  input-align="right" border="{{ false }}" />
            </van-cell>
            <van-cell center>
                <view slot="title"  class="txt"><text>单位名称</text></view>
                <van-field model:value="{{ fromDate.company }}" placeholder="请输入您的单位名称" input-align="right" border="{{ false }}" />
                <van-field model:value="{{ company }}" placeholder="请输入您的单位名称" input-align="right" border="{{ false }}" />
            </van-cell>
        </van-cell-group>
    </view>
@@ -43,7 +51,7 @@
            <van-cell center>
                <view slot="title"  class="txt"><text>留言</text></view>
                <van-field placeholder-style="placeholder"
    value="{{ fromDate.beizhu }}"
                model:value="{{ beizhu }}"
    type="textarea"
    show-word-limit
    placeholder="请输入备注信息"
@@ -54,10 +62,13 @@
  />
            </van-cell>
        </van-cell-group>
        <view class="price"><text class="tit">培训费用</text><text class="pri">¥812元</text></view>
        <view class="price"><text class="tit">审核后需支付费用</text><text class="pri">¥812元</text></view>
        <view class="price"><van-button type="default" block color="#1989fa">下一步,上传资料</van-button></view>
        <view class="price"><text class="tit">培训费用</text><text class="pri">¥{{fromDate.price}}元</text></view>
        <view class="price"><text class="tit">审核后需支付费用</text><text class="pri">¥{{fromDate.price}}元</text></view>
        <view class="price">
                <van-button type="default" block color="#1989fa" bind:click="nextCard">下一步,上传资料</van-button>
        </view>
    </view>
    <van-toast id="van-toast" />
</ui-sys>
<van-popup show="{{ isShow }}" bind:close="onClose" position="bottom" round>
    <van-picker columns="{{ columns }}" bind:cancel="onClose" bind:confirm="onConfirm" show-toolbar />
@@ -74,6 +85,6 @@
    <van-picker columns="{{ columnsZige }}" bind:cancel="onCloseZige" bind:confirm="onConfirmZige" show-toolbar />
</van-popup>
<!-- 培训类型 -->
<van-popup show="{{ isShowStudy }}" bind:close="onClosePeixun" position="bottom" round>
<van-popup show="{{isShowPeixun}}" bind:close="onClosePeixun" position="bottom" round>
    <van-picker columns="{{ columnsPeixun }}" bind:cancel="onClosePeixun" bind:confirm="onConfirmPeixun" show-toolbar />
</van-popup>
 No newline at end of file
Loading