Browse Source

增加分享

HW 4 years ago
parent
commit
16e40e0024

+ 1 - 1
src/app.config.js

@@ -4,7 +4,7 @@ export default {
     'pages/index/index',
     'pages/user/index',
     'pages/details/index',
-    'pages/webDetails/index',
+    // 'pages/webDetails/index',
     'pages/liveList/index',
     'pages/liveRoom/index',
   ],

File diff suppressed because it is too large
+ 1 - 0
src/components/common/wPicker/areadata/areadata.js


+ 904 - 0
src/components/common/wPicker/datePicker/index.js

@@ -0,0 +1,904 @@
+import Taro from '@tarojs/taro'
+import React, { Component } from 'react'
+import { View, Text,PickerView,PickerViewColumn } from '@tarojs/components'
+import './index.scss'
+import PropTypes from 'prop-types';
+export default class DatePicker extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            pickVal: [],
+            range: {
+                years: [],
+                months: [],
+                days: [],
+                hours: [],
+                minutes: [],
+                seconds: []
+            },
+            checkObj: {},
+            values:this.props.value,
+            fields2:this.props.fields,          
+        }
+    }
+    
+    componentWillMount() {
+        this.initData();
+    }
+
+    componentDidMount() { 
+    }
+
+    componentWillUnmount() { }
+
+    componentDidShow() { }
+
+    componentDidHide() { }
+
+    componentDidUpdate(prevProps, prevState) {
+        if (prevProps.value !== this.state.values) {
+            // this.initData();
+            this.setState({
+                values: prevProps.value,
+            }, () => {
+                this.initData();
+            })
+        }
+        if (prevProps.fields !== this.state.fields2) {
+            // this.initData();
+            this.setState({
+                fields2: prevProps.fields,
+            }, () => {
+                this.initData();
+            })
+        }
+    }
+
+    formatNum = (n) => {
+        return (Number(n) < 10 ? '0' + Number(n) : Number(n) + '');
+    }
+
+    checkValue = (value) => {
+        let strReg, example
+        switch (this.props.fields) {
+            case "year":
+                strReg = /^\d{4}$/;
+                example = "2019";
+                break;
+            case "month":
+                strReg = /^\d{4}-\d{2}$/;
+                example = "2019-02";
+                break;
+            case "day":
+                strReg = /^\d{4}-\d{2}-\d{2}$/;
+                example = "2019-02-01";
+                break;
+            case "hour":
+                strReg = /^\d{4}-\d{2}-\d{2} \d{2}(:\d{2}){1,2}?$/;
+                example = "2019-02-01 18:00:00或2019-02-01 18";
+                break;
+            case "minute":
+                strReg = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2}){0,1}?$/;
+                example = "2019-02-01 18:06:00或2019-02-01 18:06";
+                break;
+            case "second":
+                strReg = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
+                example = "2019-02-01 18:06:01";
+                break;
+        }
+        if (!strReg.test(value)) {
+            console.log(new Error("请传入与mode、fields匹配的value值,例value=" + example + ""))
+        }
+        return strReg.test(value);
+    }
+
+    resetData = (year, month, day, hour, minute) => {
+        let curDate = this.getCurrenDate();
+        let curFlag = this.props.current;
+        let curYear = curDate.curYear;
+        let curMonth = curDate.curMonth;
+        let curDay = curDate.curDay;
+        let curHour = curDate.curHour;
+        let curMinute = curDate.curMinute;
+        let curSecond = curDate.curSecond;
+        let months = [], days = [], hours = [], minutes = [], seconds = [];
+        let disabledAfter = this.props.disabledAfter;
+        let monthsLen = disabledAfter ? (year * 1 < curYear ? 12 : curMonth) : 12;
+        let totalDays = new Date(year, month, 0).getDate();//计算当月有几天;
+        let daysLen = disabledAfter ? ((year * 1 < curYear || month * 1 < curMonth) ? totalDays : curDay) : totalDays;
+        let hoursLen = disabledAfter ? ((year * 1 < curYear || month * 1 < curMonth || day * 1 < curDay) ? 24 : curHour + 1) : 24;
+        let minutesLen = disabledAfter ? ((year * 1 < curYear || month * 1 < curMonth || day * 1 < curDay || hour * 1 < curHour) ? 60 : curMinute + 1) : 60;
+        let secondsLen = disabledAfter ? ((year * 1 < curYear || month * 1 < curMonth || day * 1 < curDay || hour * 1 < curHour || minute * 1 < curMinute) ? 60 : curSecond + 1) : 60;
+        for (let month = 1; month <= monthsLen; month++) {
+            months.push(this.formatNum(month));
+        };
+        for (let day = 1; day <= daysLen; day++) {
+            days.push(this.formatNum(day));
+        }
+        for (let hour = 0; hour < hoursLen; hour++) {
+            hours.push(this.formatNum(hour));
+        }
+        for (let minute = 0; minute < minutesLen; minute++) {
+            minutes.push(this.formatNum(minute));
+        }
+        for (let second = 0; second < secondsLen; second++) {
+            seconds.push(this.formatNum(second));
+        }
+        return {
+            months,
+            days,
+            hours,
+            minutes,
+            seconds
+        }
+    }
+
+    getData(dVal) {
+        //用来处理初始化数据
+        let curFlag = this.props.current;
+        let disabledAfter = this.props.disabledAfter;
+        let fields = this.props.fields;
+        let curDate = this.getCurrenDate();
+        let curYear = curDate.curYear;
+        let curMonthdays = curDate.curMonthdays;
+        let curMonth = curDate.curMonth;
+        let curDay = curDate.curDay;
+        let curHour = curDate.curHour;
+        let curMinute = curDate.curMinute;
+        let curSecond = curDate.curSecond;
+        let defaultDate = this.getDefaultDate();
+        let startYear = this.getStartDate().getFullYear();
+        let endYear = this.getEndDate().getFullYear();
+        //颗粒度,禁用当前之后日期仅对year,month,day,hour生效;分钟秒禁用没有意义,
+        let years = [], months = [], days = [], hours = [], minutes = [], seconds = [];
+        let year = dVal[0] * 1;
+        let month = dVal[1] * 1;
+        let day = dVal[2] * 1;
+        let hour = dVal[3] * 1;
+        let minute = dVal[4] * 1;
+        let monthsLen = disabledAfter ? (year < curYear ? 12 : curDate.curMonth) : 12;
+        let daysLen = disabledAfter ? ((year < curYear || month < curMonth) ? defaultDate.defaultDays : curDay) : (curFlag ? curMonthdays : defaultDate.defaultDays);
+        let hoursLen = disabledAfter ? ((year < curYear || month < curMonth || day < curDay) ? 24 : curHour + 1) : 24;
+        let minutesLen = disabledAfter ? ((year < curYear || month < curMonth || day < curDay || hour < curHour) ? 60 : curMinute + 1) : 60;
+        let secondsLen = disabledAfter ? ((year < curYear || month < curMonth || day < curDay || hour < curHour || minute < curMinute) ? 60 : curSecond + 1) : 60;
+        for (let year = startYear; year <= (disabledAfter ? curYear : endYear); year++) {
+            years.push(year.toString())
+        }
+        for (let month = 1; month <= monthsLen; month++) {
+            months.push(this.formatNum(month));
+        }
+        for (let day = 1; day <= daysLen; day++) {
+            days.push(this.formatNum(day));
+        }
+        for (let hour = 0; hour < hoursLen; hour++) {
+            hours.push(this.formatNum(hour));
+        }
+        for (let minute = 0; minute < minutesLen; minute++) {
+            minutes.push(this.formatNum(minute));
+        }
+        // for(let second=0;second<(disabledAfter?curDate.curSecond+1:60);second++){
+        // 	seconds.push(this.formatNum(second));
+        // }
+        for (let second = 0; second < 60; second++) {
+            seconds.push(this.formatNum(second));
+        }
+        return {
+            years,
+            months,
+            days,
+            hours,
+            minutes,
+            seconds
+        }
+    }
+
+    getCurrenDate() {
+        let curDate = new Date();
+        let curYear = curDate.getFullYear();
+        let curMonth = curDate.getMonth() + 1;
+        let curMonthdays = new Date(curYear, curMonth, 0).getDate();
+        let curDay = curDate.getDate();
+        let curHour = curDate.getHours();
+        let curMinute = curDate.getMinutes();
+        let curSecond = curDate.getSeconds();
+        return {
+            curDate,
+            curYear,
+            curMonth,
+            curMonthdays,
+            curDay,
+            curHour,
+            curMinute,
+            curSecond
+        }
+    }
+
+    getDefaultDate() {
+        let value = this.props.value;
+        let reg = /-/g;
+        let defaultDate = value ? new Date(value.replace(reg, "/")) : new Date();
+        let defaultYear = defaultDate.getFullYear();
+        let defaultMonth = defaultDate.getMonth() + 1;
+        let defaultDay = defaultDate.getDate();
+        let defaultDays = new Date(defaultYear, defaultMonth, 0).getDate() * 1;
+        return {
+            defaultDate,
+            defaultYear,
+            defaultMonth,
+            defaultDay,
+            defaultDays
+        }
+    }
+
+    getStartDate = () => {
+        let start = this.props.startYear;
+        let startDate = "";
+        let reg = /-/g;
+        if (start) {
+            startDate = new Date(start + "/01/01");
+        } else {
+            startDate = new Date("1970/01/01");
+        }
+        return startDate;
+    }
+
+    getEndDate = () => {
+        let end = this.props.endYear;
+        let reg = /-/g;
+        let endDate = "";
+        if (end) {
+            endDate = new Date(end + "/12/01");
+        } else {
+            endDate = new Date();
+        }
+        return endDate;
+    }
+
+    getDval() {
+        let value = this.props.value;
+        let fields = this.props.fields;
+        let dVal = null;
+        let aDate = new Date();
+        let year = this.formatNum(aDate.getFullYear());
+        let month = this.formatNum(aDate.getMonth() + 1);
+        let day = this.formatNum(aDate.getDate());
+        let hour = this.formatNum(aDate.getHours());
+        let minute = this.formatNum(aDate.getMinutes());
+        let second = this.formatNum(aDate.getSeconds());
+        if (value) {
+            let flag = this.checkValue(value);
+            if (!flag) {
+                dVal = [year, month, day, hour, minute, second]
+            } else {
+                switch (this.props.fields) {
+                    case "year":
+                        dVal = value ? [value] : [];
+                        break;
+                    case "month":
+                        dVal = value ? value.split("-") : [];
+                        break;
+                    case "day":
+                        dVal = value ? value.split("-") : [];
+                        break;
+                    case "hour":
+                        dVal = [...value.split(" ")[0].split("-"), ...value.split(" ")[1].split(":")];
+                        break;
+                    case "minute":
+                        dVal = value ? [...value.split(" ")[0].split("-"), ...value.split(" ")[1].split(":")] : [];
+                        break;
+                    case "second":
+                        dVal = [...value.split(" ")[0].split("-"), ...value.split(" ")[1].split(":")];
+                        break;
+                }
+            }
+        } else {
+            dVal = [year, month, day, hour, minute, second]
+        }
+        return dVal;
+    }
+
+    initData() {
+        let startDate, endDate, startYear, endYear, startMonth, endMonth, startDay, endDay;
+        let years = [], months = [], days = [], hours = [], minutes = [], seconds = [];
+        let dVal = [], pickVal = [];
+        let value = this.props.value;
+        let reg = /-/g;
+        let range = {};
+        let result = "", full = "", year, month, day, hour, minute, second, obj = {};
+        let defaultDate = this.getDefaultDate();
+        let defaultYear = defaultDate.defaultYear;
+        let defaultMonth = defaultDate.defaultMonth;
+        let defaultDay = defaultDate.defaultDay;
+        let defaultDays = defaultDate.defaultDays;
+        let curFlag = this.props.current;
+        let disabledAfter = this.props.disabledAfter;
+        let curDate = this.getCurrenDate();
+        let curYear = curDate.curYear;
+        let curMonth = curDate.curMonth;
+        let curMonthdays = curDate.curMonthdays;
+        let curDay = curDate.curDay;
+        let curHour = curDate.curHour;
+        let curMinute = curDate.curMinute;
+        let curSecond = curDate.curSecond;
+        let dateData = [];
+        dVal = this.getDval();
+
+        startDate = this.getStartDate();
+        endDate = this.getEndDate();
+        startYear = startDate.getFullYear();
+        startMonth = startDate.getMonth();
+        startDay = startDate.getDate();
+        endYear = endDate.getFullYear();
+        endMonth = endDate.getMonth();
+        endDay = endDate.getDate();
+        dateData = this.getData(dVal);
+        years = dateData.years;
+        months = dateData.months;
+        days = dateData.days;
+        hours = dateData.hours;
+        minutes = dateData.minutes;
+        seconds = dateData.seconds;
+        switch (this.props.fields) {
+            case "year":
+                pickVal = disabledAfter ? [
+                    dVal[0] && years.indexOf(dVal[0]) != -1 ? years.indexOf(dVal[0]) : 0
+                ] : (curFlag ? [
+                    years.indexOf(curYear + '')
+                ] : [
+                        dVal[0] && years.indexOf(dVal[0]) != -1 ? years.indexOf(dVal[0]) : 0
+                    ]);
+                range = { years };
+                year = dVal[0] ? dVal[0] : years[0];
+                result = full = `${year}`;
+                obj = {
+                    year
+                }
+                break;
+            case "month":
+                pickVal = disabledAfter ? [
+                    dVal[0] && years.indexOf(dVal[0]) != -1 ? years.indexOf(dVal[0]) : 0,
+                    dVal[1] && months.indexOf(dVal[1]) != -1 ? months.indexOf(dVal[1]) : 0
+                ] : (curFlag ? [
+                    years.indexOf(curYear + ''),
+                    months.indexOf(this.formatNum(curMonth))
+                ] : [
+                        dVal[0] && years.indexOf(dVal[0]) != -1 ? years.indexOf(dVal[0]) : 0,
+                        dVal[1] && months.indexOf(dVal[1]) != -1 ? months.indexOf(dVal[1]) : 0
+                    ]);
+                range = { years, months };
+                year = dVal[0] ? dVal[0] : years[0];
+                month = dVal[1] ? dVal[1] : months[0];
+                result = full = `${year + '-' + month}`;
+                obj = {
+                    year,
+                    month
+                }
+                break;
+            case "day":
+                pickVal = disabledAfter ? [
+                    dVal[0] && years.indexOf(dVal[0]) != -1 ? years.indexOf(dVal[0]) : 0,
+                    dVal[1] && months.indexOf(dVal[1]) != -1 ? months.indexOf(dVal[1]) : 0,
+                    dVal[2] && days.indexOf(dVal[2]) != -1 ? days.indexOf(dVal[2]) : 0
+                ] : (curFlag ? [
+                    years.indexOf(curYear + ''),
+                    months.indexOf(this.formatNum(curMonth)),
+                    days.indexOf(this.formatNum(curDay)),
+                ] : [
+                        dVal[0] && years.indexOf(dVal[0]) != -1 ? years.indexOf(dVal[0]) : 0,
+                        dVal[1] && months.indexOf(dVal[1]) != -1 ? months.indexOf(dVal[1]) : 0,
+                        dVal[2] && days.indexOf(dVal[2]) != -1 ? days.indexOf(dVal[2]) : 0
+                    ]);
+                range = { years, months, days };
+                year = dVal[0] ? dVal[0] : years[0];
+                month = dVal[1] ? dVal[1] : months[0];
+                day = dVal[2] ? dVal[2] : days[0];
+                result = full = `${year + '-' + month + '-' + day}`;
+                obj = {
+                    year,
+                    month,
+                    day
+                }
+                break;
+            case "hour":
+                pickVal = disabledAfter ? [
+                    dVal[0] && years.indexOf(dVal[0]) != -1 ? years.indexOf(dVal[0]) : 0,
+                    dVal[1] && months.indexOf(dVal[1]) != -1 ? months.indexOf(dVal[1]) : 0,
+                    dVal[2] && days.indexOf(dVal[2]) != -1 ? days.indexOf(dVal[2]) : 0,
+                    dVal[3] && hours.indexOf(dVal[3]) != -1 ? hours.indexOf(dVal[3]) : 0
+                ] : (curFlag ? [
+                    years.indexOf(curYear + ''),
+                    months.indexOf(this.formatNum(curMonth)),
+                    days.indexOf(this.formatNum(curDay)),
+                    hours.indexOf(this.formatNum(curHour)),
+                ] : [
+                        dVal[0] && years.indexOf(dVal[0]) != -1 ? years.indexOf(dVal[0]) : 0,
+                        dVal[1] && months.indexOf(dVal[1]) != -1 ? months.indexOf(dVal[1]) : 0,
+                        dVal[2] && days.indexOf(dVal[2]) != -1 ? days.indexOf(dVal[2]) : 0,
+                        dVal[3] && hours.indexOf(dVal[3]) != -1 ? hours.indexOf(dVal[3]) : 0
+                    ]);
+                range = { years, months, days, hours };
+                year = dVal[0] ? dVal[0] : years[0];
+                month = dVal[1] ? dVal[1] : months[0];
+                day = dVal[2] ? dVal[2] : days[0];
+                hour = dVal[3] ? dVal[3] : hours[0];
+                result = `${year + '-' + month + '-' + day + ' ' + hour}`;
+                full = `${year + '-' + month + '-' + day + ' ' + hour + ':00:00'}`;
+                obj = {
+                    year,
+                    month,
+                    day,
+                    hour
+                }
+                break;
+            case "minute":
+                pickVal = disabledAfter ? [
+                    dVal[0] && years.indexOf(dVal[0]) != -1 ? years.indexOf(dVal[0]) : 0,
+                    dVal[1] && months.indexOf(dVal[1]) != -1 ? months.indexOf(dVal[1]) : 0,
+                    dVal[2] && days.indexOf(dVal[2]) != -1 ? days.indexOf(dVal[2]) : 0,
+                    dVal[3] && hours.indexOf(dVal[3]) != -1 ? hours.indexOf(dVal[3]) : 0,
+                    dVal[4] && minutes.indexOf(dVal[4]) != -1 ? minutes.indexOf(dVal[4]) : 0
+                ] : (curFlag ? [
+                    years.indexOf(curYear + ''),
+                    months.indexOf(this.formatNum(curMonth)),
+                    days.indexOf(this.formatNum(curDay)),
+                    hours.indexOf(this.formatNum(curHour)),
+                    minutes.indexOf(this.formatNum(curMinute)),
+                ] : [
+                        dVal[0] && years.indexOf(dVal[0]) != -1 ? years.indexOf(dVal[0]) : 0,
+                        dVal[1] && months.indexOf(dVal[1]) != -1 ? months.indexOf(dVal[1]) : 0,
+                        dVal[2] && days.indexOf(dVal[2]) != -1 ? days.indexOf(dVal[2]) : 0,
+                        dVal[3] && hours.indexOf(dVal[3]) != -1 ? hours.indexOf(dVal[3]) : 0,
+                        dVal[4] && minutes.indexOf(dVal[4]) != -1 ? minutes.indexOf(dVal[4]) : 0
+                    ]);
+                range = { years, months, days, hours, minutes };
+                year = dVal[0] ? dVal[0] : years[0];
+                month = dVal[1] ? dVal[1] : months[0];
+                day = dVal[2] ? dVal[2] : days[0];
+                hour = dVal[3] ? dVal[3] : hours[0];
+                minute = dVal[4] ? dVal[4] : minutes[0];
+                full = `${year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':00'}`;
+                result = `${year + '-' + month + '-' + day + ' ' + hour + ':' + minute}`;
+                obj = {
+                    year,
+                    month,
+                    day,
+                    hour,
+                    minute
+                }
+                break;
+            case "second":
+                pickVal = disabledAfter ? [
+                    dVal[0] && years.indexOf(dVal[0]) != -1 ? years.indexOf(dVal[0]) : 0,
+                    dVal[1] && months.indexOf(dVal[1]) != -1 ? months.indexOf(dVal[1]) : 0,
+                    dVal[2] && days.indexOf(dVal[2]) != -1 ? days.indexOf(dVal[2]) : 0,
+                    dVal[3] && hours.indexOf(dVal[3]) != -1 ? hours.indexOf(dVal[3]) : 0,
+                    dVal[4] && minutes.indexOf(dVal[4]) != -1 ? minutes.indexOf(dVal[4]) : 0,
+                    dVal[5] && seconds.indexOf(dVal[5]) != -1 ? seconds.indexOf(dVal[5]) : 0
+                ] : (curFlag ? [
+                    years.indexOf(curYear + ''),
+                    months.indexOf(this.formatNum(curMonth)),
+                    days.indexOf(this.formatNum(curDay)),
+                    hours.indexOf(this.formatNum(curHour)),
+                    minutes.indexOf(this.formatNum(curMinute)),
+                    seconds.indexOf(this.formatNum(curSecond)),
+                ] : [
+                        dVal[0] && years.indexOf(dVal[0]) != -1 ? years.indexOf(dVal[0]) : 0,
+                        dVal[1] && months.indexOf(dVal[1]) != -1 ? months.indexOf(dVal[1]) : 0,
+                        dVal[2] && days.indexOf(dVal[2]) != -1 ? days.indexOf(dVal[2]) : 0,
+                        dVal[3] && hours.indexOf(dVal[3]) != -1 ? hours.indexOf(dVal[3]) : 0,
+                        dVal[4] && minutes.indexOf(dVal[4]) != -1 ? minutes.indexOf(dVal[4]) : 0,
+                        dVal[5] && seconds.indexOf(dVal[5]) != -1 ? seconds.indexOf(dVal[5]) : 0
+                    ]);
+                range = { years, months, days, hours, minutes, seconds };
+                year = dVal[0] ? dVal[0] : years[0];
+                month = dVal[1] ? dVal[1] : months[0];
+                day = dVal[2] ? dVal[2] : days[0];
+                hour = dVal[3] ? dVal[3] : hours[0];
+                minute = dVal[4] ? dVal[4] : minutes[0];
+                second = dVal[5] ? dVal[5] : seconds[0];
+                result = full = `${year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second}`;
+                obj = {
+                    year,
+                    month,
+                    day,
+                    hour,
+                    minute,
+                    second
+                }
+                break;
+            default:
+                range = { years, months, days };
+                break;
+        }
+        this.setState({
+            range,
+            checkObj:obj
+        })
+        this.props.change({
+            result: result,
+            value: full,
+            obj: obj
+        })
+        Taro.nextTick(() => {
+            this.setState({
+                pickVal
+            })
+        });
+    }
+    isLeapYear = (Year) => {
+        if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {
+            return true;
+        } else { 
+            return false; 
+        }
+    }
+    handlerChange = (e) => {
+        let arr = [...e.detail.value];
+        let data = this.state.range;
+        let year = "", month = "", day = "", hour = "", minute = "", second = "";
+        let result = "", full = "", obj = {};
+        let months = null, days = null, hours = null, minutes = null, seconds = null;
+        let disabledAfter = this.props.disabledAfter;
+        let range = Object.assign({}, this.state.range);
+        let leapYear= false,resetData={};
+        year = (arr[0] || arr[0] == 0) ? data.years[arr[0]] || data.years[data.years.length - 1] : "";
+        month = (arr[1] || arr[1] == 0) ? data.months[arr[1]] || data.months[data.months.length - 1] : "";
+        day = (arr[2] || arr[2] == 0) ? data.days[arr[2]] || data.days[data.days.length - 1] : "";
+        hour = (arr[3] || arr[3] == 0) ? data.hours[arr[3]] || data.hours[data.hours.length - 1] : "";
+        minute = (arr[4] || arr[4] == 0) ? data.minutes[arr[4]] || data.minutes[data.minutes.length - 1] : "";
+        second = (arr[5] || arr[5] == 0) ? data.seconds[arr[5]] || data.seconds[data.seconds.length - 1] : "";
+        resetData = this.resetData(year, month, day, hour, minute);
+        leapYear = this.isLeapYear(year);
+        switch (this.props.fields) {
+            case "year":
+                result = full = `${year}`;
+                obj = {
+                    year
+                };
+                break;
+            case "month":
+                result = full = `${year + '-' + month}`;
+                if (this.props.disabledAfter) months = resetData.months;
+                if (months) {
+                    range.months = months;
+                    this.setState({
+                        range,
+                        pickVal:e.detail.value
+                    })
+                }
+                obj = {
+                    year,
+                    month
+                }
+                break;
+            case "day":
+                result = full = `${year + '-' + month + '-' + day}`;
+                if (this.props.disabledAfter) {
+                    months = resetData.months;
+                    days = resetData.days;
+                } else {
+                    if (leapYear || (month != this.state.checkObj.month)) {
+                        days = resetData.days;
+                    }
+                } 
+                if (months) range.months=months;
+                if (days) range.days=days;
+                this.setState({
+                    range,
+                    pickVal:e.detail.value
+                })
+                obj = {
+                    year,
+                    month,
+                    day
+                }
+                break;
+            case "hour":
+                result = `${year + '-' + month + '-' + day + ' ' + hour}`;
+                full = `${year + '-' + month + '-' + day + ' ' + hour + ':00:00'}`;
+                if (this.props.disabledAfter) {
+                    months = resetData.months;
+                    days = resetData.days;
+                    hours = resetData.hours;
+                } else {
+                    if (leapYear || (month != this.state.checkObj.month)) {
+                        days = resetData.days;
+                    }
+                }
+                if (months) range.months = months;
+                if (days) range.days = days;
+                if (hours) range.hours = hours;
+                this.setState({
+                    range,
+                    pickVal:e.detail.value
+                })
+                obj = {
+                    year,
+                    month,
+                    day,
+                    hour
+                }
+                break;
+            case "minute":
+                full = `${year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':00'}`;
+                result = `${year + '-' + month + '-' + day + ' ' + hour + ':' + minute}`;
+                if (this.props.disabledAfter) {
+                    months = resetData.months;
+                    days = resetData.days;
+                    hours = resetData.hours;
+                    minutes = resetData.minutes;
+                } else {
+                    if (leapYear || (month != this.state.checkObj.month)) {
+                        days = resetData.days;
+                    }
+                }
+                if (months) range.months = months;
+                if (days) range.days = days;
+                if (hours) range.hours = hours;
+                if (minutes) range.minutes = minutes;
+                this.setState({
+                    range,
+                    pickVal:e.detail.value
+                })
+                obj = {
+                    year,
+                    month,
+                    day,
+                    hour,
+                    minute
+                };
+                break;
+            case "second":
+                result = full = `${year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second}`;
+                if (this.props.disabledAfter) {
+                    months = resetData.months;
+                    days = resetData.days;
+                    hours = resetData.hours;
+                    minutes = resetData.minutes;
+                    //seconds=resetData.seconds;
+                } else {
+                    if (leapYear || (month != this.state.checkObj.month)) {
+                        days = resetData.days;
+                    }
+                }
+                if (months) range.months = months;
+                if (days) range.days = days;
+                if (hours) range.hours = hours;
+                if (minutes) range.minutes = minutes;
+                //if(seconds)this.range.seconds=seconds;
+                this.setState({
+                    range,
+                    pickVal:e.detail.value
+                })
+                obj = {
+                    year,
+                    month,
+                    day,
+                    hour,
+                    minute,
+                    second
+                }
+                break;
+        }
+        this.setState({
+            checkObj:obj
+        })
+        this.props.change({
+            result: result,
+            value: full,
+            obj: obj
+        })
+    }
+
+
+    render() {
+        const { pickVal, range } = this.state
+        return (
+            <View className='w-picker-view'>
+                {this.props.fields == 'year' ? (
+                    <PickerView className="d-picker-view" indicatorStyle={this.props.itemHeight} value={pickVal} onChange={this.handlerChange}>
+                        <PickerViewColumn>
+                            {
+                                range.years.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}年</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                    </PickerView>
+                ) : null}
+
+                {this.props.fields == 'month' ? (
+                    <PickerView className="d-picker-view" indicatorStyle={this.props.itemHeight} value={pickVal} onChange={this.handlerChange}>
+                        <PickerViewColumn>
+                            {
+                                range.years.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}年</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.months.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}月</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                    </PickerView>
+                ) : null}
+
+                {this.props.fields == 'day' ? (
+                    <PickerView className="d-picker-view" indicatorStyle={this.props.itemHeight} value={pickVal} onChange={this.handlerChange}>
+                        <PickerViewColumn>
+                            {
+                                range.years.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}年</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.months.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}月</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.days.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}日</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                    </PickerView>
+                ) : null}
+
+                {this.props.fields == 'hour' ? (
+                    <PickerView className="d-picker-view" indicatorStyle={this.props.itemHeight} value={pickVal} onChange={this.handlerChange}>
+                        <PickerViewColumn>
+                            {
+                                range.years.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}年</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.months.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}月</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.days.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}日</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.hours.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}时</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                    </PickerView>
+                ) : null}
+                {this.props.fields == 'minute' ? (
+                    <PickerView className="d-picker-view" indicatorStyle={this.props.itemHeight} value={pickVal} onChange={this.handlerChange}>
+                        <PickerViewColumn>
+                            {
+                                range.years.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}年</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.months.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}月</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.days.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}日</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.hours.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}时</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.minutes.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}分</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                    </PickerView>
+                ) : null}
+                {this.props.fields == 'second' ? (
+                    <PickerView className="d-picker-view" indicatorStyle={this.props.itemHeight} value={pickVal} onChange={this.handlerChange}>
+                        <PickerViewColumn>
+                            {
+                                range.years.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}年</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.months.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}月</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.days.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}日</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.hours.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}时</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.minutes.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}分</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                        <PickerViewColumn>
+                            {
+                                range.seconds.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}秒</View>)
+                                })
+                            }
+                        </PickerViewColumn>
+                    </PickerView>
+                ) : null}
+            </View>
+
+        )
+    }
+}
+DatePicker.PropTypes = {
+    itemHeight: PropTypes.string,
+    startYear: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.number,
+    ]),
+    endYear: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.number,
+    ]),
+    value: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.array,
+        PropTypes.number
+    ]),
+    current: PropTypes.bool,//是否默认选中当前日期
+    disabledAfter: PropTypes.bool,//是否禁用当前之后的日期
+    fields: PropTypes.string
+}
+DatePicker.defaultProps = {
+    itemHeight: "44px",
+    startYear: "",
+    endYear: "",
+    value: "",
+    current: false,
+    disabledAfter: false,
+    fields: "day"
+}

+ 26 - 0
src/components/common/wPicker/datePicker/index.scss

@@ -0,0 +1,26 @@
+.w-picker-flex2{
+	flex:2;
+}
+.w-picker-flex1{
+	flex:1;
+}
+.w-picker-view {
+	width: 100%;
+	height: 476px;
+	overflow: hidden;
+	background-color: rgba(255, 255, 255, 1);
+	z-index: 666;
+}
+.d-picker-view{
+	height: 100%;
+}
+
+.w-picker-item {
+  text-align: center;
+  width: 100%;
+  height: 88px;
+  line-height: 88px;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+  font-size: 30px;
+}

+ 398 - 0
src/components/common/wPicker/halfPicker/index.js

@@ -0,0 +1,398 @@
+import Taro from '@tarojs/taro'
+import React, { Component } from 'react'
+import { View, Text,PickerView,PickerViewColumn } from '@tarojs/components'
+import './index.scss'
+import PropTypes from 'prop-types';
+export default class HalfPicker extends Component {
+
+    
+    constructor(props) {
+        super(props);
+        this.state = {
+            pickVal: [],
+            range: {},
+            checkObj: {},
+            values:this.props.value
+        }
+    }
+
+    componentWillMount() {
+        this.initData();
+    }
+
+    componentDidMount() { }
+
+    componentWillUnmount() { }
+
+    componentDidShow() { }
+
+    componentDidHide() { }
+
+    componentDidUpdate(prevProps, prevState) {
+        if (prevProps.value !== this.state.values) {
+            // this.initData();
+            this.setState({
+                values: prevProps.value,
+            }, () => {
+                this.initData();
+            })
+        }
+    }
+
+    formatNum = (n) => {
+        return (Number(n) < 10 ? '0' + Number(n) : Number(n) + '');
+    }
+
+    checkValue = (value) => {
+        let strReg = /^\d{4}-\d{2}-\d{2} [\u4e00-\u9fa5]{2}$/, example;
+        if (!strReg.test(value)) {
+            console.log(new Error("请传入与mode、fields匹配的value值,例value=" + example + ""))
+        }
+        return strReg.test(value);
+    }
+
+    resetData = (year, month, day) => {
+        let curDate = this.getCurrenDate();
+        let curFlag = this.props.current;
+        let curYear = curDate.curYear;
+        let curMonth = curDate.curMonth;
+        let curDay = curDate.curDay;
+        let curHour = curDate.curHour;
+        let months = [], days = [], sections = [];
+        let disabledAfter = this.props.disabledAfter;
+        let monthsLen = disabledAfter ? (year * 1 < curYear ? 12 : curMonth) : 12;
+        let totalDays = new Date(year, month, 0).getDate();//计算当月有几天;
+        let daysLen = disabledAfter ? ((year * 1 < curYear || month * 1 < curMonth) ? totalDays : curDay) : totalDays;
+        let sectionFlag = disabledAfter ? ((year * 1 < curYear || month * 1 < curMonth || day * 1 < curDay) == true ? false : true) : (curHour > 12 == true ? true : false);
+        sections = ["上午", "下午"];
+        for (let month = 1; month <= monthsLen; month++) {
+            months.push(this.formatNum(month));
+        };
+        for (let day = 1; day <= daysLen; day++) {
+            days.push(this.formatNum(day));
+        }
+        if (sectionFlag) {
+            sections = ["上午"];
+        }
+        return {
+            months,
+            days,
+            sections
+        }
+    }
+
+    getData = (dVal) => {
+        //用来处理初始化数据
+        let curFlag = this.props.current;
+        let disabledAfter = this.props.disabledAfter;
+        let curDate = this.getCurrenDate();
+        let curYear = curDate.curYear;
+        let curMonthdays = curDate.curMonthdays;
+        let curMonth = curDate.curMonth;
+        let curDay = curDate.curDay;
+        let curHour = curDate.curHour;
+        let defaultDate = this.getDefaultDate();
+        let startYear = this.getStartDate().getFullYear();
+        let endYear = this.getEndDate().getFullYear();
+        let years = [], months = [], days = [], sections = [];
+        let year = dVal[0] * 1;
+        let month = dVal[1] * 1;
+        let day = dVal[2] * 1;
+        let monthsLen = disabledAfter ? (year < curYear ? 12 : curDate.curMonth) : 12;
+        let daysLen = disabledAfter ? ((year < curYear || month < curMonth) ? defaultDate.defaultDays : curDay) : (curFlag ? curMonthdays : defaultDate.defaultDays);
+        let sectionFlag = disabledAfter ? ((year * 1 < curYear || month * 1 < curMonth || day * 1 < curDay) == true ? false : true) : (curHour > 12 == true ? true : false);
+        for (let year = startYear; year <= (disabledAfter ? curYear : endYear); year++) {
+            years.push(year.toString())
+        }
+        for (let month = 1; month <= monthsLen; month++) {
+            months.push(this.formatNum(month));
+        }
+        for (let day = 1; day <= daysLen; day++) {
+            days.push(this.formatNum(day));
+        }
+        if (sectionFlag) {
+            sections = ["下午"];
+        } else {
+            sections = ["上午", "下午"];
+        }
+        return {
+            years,
+            months,
+            days,
+            sections
+        }
+    }
+
+    getCurrenDate = () => {
+        let curDate = new Date();
+        let curYear = curDate.getFullYear();
+        let curMonth = curDate.getMonth() + 1;
+        let curMonthdays = new Date(curYear, curMonth, 0).getDate();
+        let curDay = curDate.getDate();
+        let curHour = curDate.getHours();
+        let curSection = "上午";
+        if (curHour >= 12) {
+            curSection = "下午";
+        }
+        return {
+            curDate,
+            curYear,
+            curMonth,
+            curMonthdays,
+            curDay,
+            curHour,
+            curSection
+        }
+    }
+
+    getDefaultDate = () => {
+        let value = this.props.value;
+        let reg = /-/g;
+        let defaultDate = value ? new Date(value.split(" ")[0].replace(reg, "/")) : new Date();
+        let defaultYear = defaultDate.getFullYear();
+        let defaultMonth = defaultDate.getMonth() + 1;
+        let defaultDay = defaultDate.getDate();
+        let defaultDays = new Date(defaultYear, defaultMonth, 0).getDate() * 1;
+        return {
+            defaultDate,
+            defaultYear,
+            defaultMonth,
+            defaultDay,
+            defaultDays
+        }
+    }
+
+    getStartDate = () => {
+        let start = this.props.startYear;
+        let startDate = "";
+        let reg = /-/g;
+        if (start) {
+            startDate = new Date(start + "/01/01");
+        } else {
+            startDate = new Date("1970/01/01");
+        }
+        return startDate;
+    }
+
+    getEndDate = () => {
+        let end = this.props.endYear;
+        let reg = /-/g;
+        let endDate = "";
+        if (end) {
+            endDate = new Date(end + "/12/31");
+        } else {
+            endDate = new Date();
+        }
+        return endDate;
+    }
+
+    getDval = () => {
+        let value = this.props.value;
+        let dVal = null;
+        let aDate = new Date();
+        let year = this.formatNum(aDate.getFullYear());
+        let month = this.formatNum(aDate.getMonth() + 1);
+        let day = this.formatNum(aDate.getDate());
+        let hour = aDate.getHours();
+        let section = "上午";
+        if (hour >= 12) section = "下午";
+        if (value) {
+            let flag = this.checkValue(value);
+            if (!flag) {
+                dVal = [year, month, day, section]
+            } else {
+                let v = value.split(" ");
+                dVal = [...v[0].split("-"), v[1]];
+            }
+        } else {
+            dVal = [year, month, day, section]
+        }
+        return dVal;
+    }
+
+    initData = () => {
+        let startDate, endDate, startYear, endYear, startMonth, endMonth, startDay, endDay;
+        let years = [], months = [], days = [], sections = [];
+        let dVal = [], pickVal = [];
+        let value = this.props.value;
+        let reg = /-/g;
+        let range = {};
+        let result = "", full = "", year, month, day, section, obj = {};
+        let defaultDate = this.getDefaultDate();
+        let defaultYear = defaultDate.defaultYear;
+        let defaultMonth = defaultDate.defaultMonth;
+        let defaultDay = defaultDate.defaultDay;
+        let defaultDays = defaultDate.defaultDays;
+        let curFlag = this.props.current;
+        let disabledAfter = this.props.disabledAfter;
+        let curDate = this.getCurrenDate();
+        let curYear = curDate.curYear;
+        let curMonth = curDate.curMonth;
+        let curMonthdays = curDate.curMonthdays;
+        let curDay = curDate.curDay;
+        let curSection = curDate.curSection;
+        let dateData = [];
+        dVal = this.getDval();
+        startDate = this.getStartDate();
+        endDate = this.getEndDate();
+        startYear = startDate.getFullYear();
+        startMonth = startDate.getMonth();
+        startDay = startDate.getDate();
+        endYear = endDate.getFullYear();
+        endMonth = endDate.getMonth();
+        endDay = endDate.getDate();
+        dateData = this.getData(dVal);
+        years = dateData.years;
+        months = dateData.months;
+        days = dateData.days;
+        sections = dateData.sections;
+        pickVal = disabledAfter ? [
+            dVal[0] && years.indexOf(dVal[0]) != -1 ? years.indexOf(dVal[0]) : 0,
+            dVal[1] && months.indexOf(dVal[1]) != -1 ? months.indexOf(dVal[1]) : 0,
+            dVal[2] && days.indexOf(dVal[2]) != -1 ? days.indexOf(dVal[2]) : 0,
+            dVal[3] && sections.indexOf(dVal[3]) != -1 ? sections.indexOf(dVal[3]) : 0
+        ] : (curFlag ? [
+            years.indexOf(curYear + ''),
+            months.indexOf(this.formatNum(curMonth)),
+            days.indexOf(this.formatNum(curDay)),
+            sections.indexOf(curSection),
+        ] : [
+                dVal[0] && years.indexOf(dVal[0]) != -1 ? years.indexOf(dVal[0]) : 0,
+                dVal[1] && months.indexOf(dVal[1]) != -1 ? months.indexOf(dVal[1]) : 0,
+                dVal[2] && days.indexOf(dVal[2]) != -1 ? days.indexOf(dVal[2]) : 0,
+                dVal[3] && sections.indexOf(dVal[3]) != -1 ? sections.indexOf(dVal[3]) : 0
+            ]);
+        range = { years, months, days, sections };
+        year = dVal[0] ? dVal[0] : years[0];
+        month = dVal[1] ? dVal[1] : months[0];
+        day = dVal[2] ? dVal[2] : days[0];
+        section = dVal[3] ? dVal[3] : sections[0];
+        result = full = `${year + '-' + month + '-' + day + ' ' + section}`;
+        obj = {
+            year,
+            month,
+            day,
+            section
+        }
+        this.setState({
+            range,
+            checkObj: obj
+        })
+        Taro.nextTick(() => {
+            this.setState({
+                pickVal
+            })
+        });
+        this.props.change({
+            result: result,
+            value: full,
+            obj: obj
+        })
+    }
+
+    handlerChange = (e) => {
+        let arr = [...e.detail.value];
+        let data = this.state.range;
+        let year = "", month = "", day = "", section = "";
+        let result = "", full = "", obj = {};
+        let months = null, days = null, sections = null;
+        let disabledAfter = this.props.disabledAfter;
+        let range = Object.assign({}, this.state.range);
+        year = (arr[0] || arr[0] == 0) ? data.years[arr[0]] || data.years[data.years.length - 1] : "";
+        month = (arr[1] || arr[1] == 0) ? data.months[arr[1]] || data.months[data.months.length - 1] : "";
+        day = (arr[2] || arr[2] == 0) ? data.days[arr[2]] || data.days[data.days.length - 1] : "";
+        section = (arr[3] || arr[3] == 0) ? data.sections[arr[3]] || data.sections[data.sections.length - 1] : "";
+        result = full = `${year + '-' + month + '-' + day + ' ' + section}`;
+        let resetData = this.resetData(year, month, day);
+        if (this.props.disabledAfter) {
+            months = resetData.months;
+            days = resetData.days;
+            sections = resetData.sections;
+        } else {
+            if (year % 4 == 0 || (month != this.state.checkObj.month)) {
+                days = resetData.days;
+            }
+        }
+        if (months) range.months = months;
+        if (days) range.days = days;
+        if (sections) range.sections = sections;
+        obj = {
+            year,
+            month,
+            day,
+            section
+        }
+        this.setState({
+            range,
+            checkObj: obj,
+            pickVal:e.detail.value
+        })
+        this.props.change({
+            result: result,
+            value: full,
+            obj: obj
+        })
+    }
+
+    render() {
+        const { pickVal,range } = this.state
+        return (
+            <View className='w-picker-view'>
+                <PickerView className="d-picker-view" indicatorStyle={this.props.itemHeight} value={pickVal} onChange={this.handlerChange}>
+                    <PickerViewColumn>
+                        {
+                            range.years.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item}年</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                    <PickerViewColumn>
+                        {
+                            range.months.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item}月</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                    <PickerViewColumn>
+                        {
+                            range.days.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item}日</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                    <PickerViewColumn>
+                        {
+                            range.sections.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item}</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                </PickerView>
+            </View>
+        )
+    }
+}
+HalfPicker.PropTypes = {
+    itemHeight: PropTypes.string,
+    value: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.array,
+        PropTypes.number
+    ]),
+    current: PropTypes.bool,
+    startYear: PropTypes.oneOfType([
+        PropTypes.string,
+    ]),
+    endYear: PropTypes.oneOfType([
+        PropTypes.string,
+    ]),
+    disabledAfter: PropTypes.bool
+}
+HalfPicker.defaultProps = {
+    itemHeight: "44px",
+    value: "",
+    current: false,
+    startYear: "",
+    endYear: "",
+    disabledAfter: false
+}

+ 26 - 0
src/components/common/wPicker/halfPicker/index.scss

@@ -0,0 +1,26 @@
+.w-picker-flex2{
+	flex:2;
+}
+.w-picker-flex1{
+	flex:1;
+}
+.w-picker-view {
+	width: 100%;
+	height: 476px;
+	overflow: hidden;
+	background-color: rgba(255, 255, 255, 1);
+	z-index: 666;
+}
+.d-picker-view{
+	height: 100%;
+}
+
+.w-picker-item {
+  text-align: center;
+  width: 100%;
+  height: 88px;
+  line-height: 88px;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+  font-size: 30px;
+}

+ 264 - 0
src/components/common/wPicker/index.js

@@ -0,0 +1,264 @@
+import Taro from '@tarojs/taro'
+import React, { Component } from 'react'
+import { View, Text } from '@tarojs/components'
+import TimePicker from "./timePicker/index"
+import ShorttermPicker from "./shorttermPicker/index"
+import SelectorPicker from "./selectorPicker/index"
+import RegionPicker from "./regionPicker/index"
+import RangePicker from "./rangePicker/index"
+import LinkagePicker from "./linkagePicker/index"
+import HalfPicker from "./halfPicker/index"
+import DatePicker from "./datePicker/index"
+import PropTypes from 'prop-types';
+import './index.scss'
+let defaultTime = new Date().getFullYear()
+export default class WPicker extends Component {
+    state = {
+        itemHeight: `height: 88rpx;`,
+        visible: false,
+        result: {},
+        confirmFlag: true,
+        createKey: null
+    }
+    componentWillMount() {
+        this.props.onRef(this)
+        this.setState({
+            createKey: Math.random() * 1000
+        })
+    }
+
+    componentDidMount() { }
+
+    componentWillUnmount() { }
+
+    componentDidShow() { }
+
+    componentDidHide() { }
+
+    touchStart = () => {
+        if (this.props.timeout) {
+            this.setState({
+                confirmFlag: false
+            })
+        }
+    }
+    touchEnd = () => {
+        if (this.props.timeout) {
+            setTimeout(() => {
+                this.setState({
+                    confirmFlag: true
+                })
+            }, 500)
+        }
+    }
+    handlerChange = (res) => {
+        this.setState({
+            result: { ...res }
+        })
+    }
+    show = () => {
+        this.setState({
+            visible: true
+        })
+    }
+    hide = () => {
+        this.setState({
+            visible: false
+        })
+    }
+
+    onCancel = (res) => {
+        this.setState({
+            visible: false
+        })
+        this.props.cancel();
+    }
+
+    pickerConfirm = () => {
+        if (!this.state.confirmFlag) {
+            return;
+        };
+        this.props.confirm(this.state.result);
+        this.setState({
+            visible: false
+        })
+    }
+
+    render() {
+        const { itemHeight, visible, confirmFlag, createKey } = this.state
+        return (
+            <View class="w-picker" key={createKey} data-key={createKey}>
+                <View class={'mask' + (visible ? ' visible' : '')} onTap={this.onCancel} catchtouchmove={true}></View>
+                <View class={'w-picker-cnt' + (visible ? ' visible' : '')}>
+                    <View class="w-picker-header" catchtouchmove={true}>
+                        <Text onTap={this.onCancel}>取消</Text>
+                        {this.props.children}
+                        <Text style={'color:' + this.props.themeColor} onTap={this.pickerConfirm}>确定</Text>
+                    </View>
+
+                    <View>{this.props.mode == 'time' ? (<TimePicker
+                        class="w-picker-wrapper"
+                        value={this.props.value}
+                        itemHeight={itemHeight}
+                        current={this.props.current}
+                        disabledAfter={this.props.disabledAfter}
+                        second={this.props.second}
+                        change={this.handlerChange}
+                        touchstart={this.touchStart}
+                        touchend={this.touchEnd}>
+                    </TimePicker>) : null}</View>
+
+                    <View>{this.props.mode == 'shortTerm' ? (<ShorttermPicker
+                        class="w-picker-wrapper"
+                        startYear={this.props.startYear}
+                        endYear={this.props.endYear}
+                        value={this.props.value}
+                        itemHeight={itemHeight}
+                        current={this.props.current}
+                        disabledAfter={this.props.disabledAfter}
+                        change={this.handlerChange}
+                        touchstart={this.touchStart}
+                        touchend={this.touchEnd}
+                        expand={60}>
+                    </ShorttermPicker>) : null}</View>
+
+                    <View>{this.props.mode == 'selector' ? (<SelectorPicker
+                        class="w-picker-wrapper"
+                        value={this.props.value}
+                        itemHeight={itemHeight}
+                        options={this.props.options}
+                        defaultType={this.props.defaultType}
+                        defaultProps={this.props.defaultProps}
+                        change={this.handlerChange}
+                        touchstart={this.touchStart}
+                        touchend={this.touchEnd}>
+                    </SelectorPicker>) : null}</View>
+
+                    <View>{this.props.mode == 'region' ? (<RegionPicker
+                        class="w-picker-wrapper"
+                        value={this.props.value}
+                        hideArea={this.props.hideArea}
+                        itemHeight={itemHeight}
+                        defaultType={this.props.defaultType}
+                        change={this.handlerChange}
+                        touchstart={this.touchStart}
+                        touchend={this.touchEnd}>
+                    </RegionPicker>) : null}</View>
+
+                    <View>{this.props.mode == 'range' ? (<RangePicker
+                        class="w-picker-wrapper"
+                        startYear={this.props.startYear}
+                        endYear={this.props.endYear}
+                        value={this.props.value}
+                        itemHeight={itemHeight}
+                        current={this.props.current}
+                        change={this.handlerChange}
+                        touchstart={this.touchStart}
+                        touchend={this.touchEnd}>
+                    </RangePicker>) : null}</View>
+
+                    <View>{this.props.mode == 'linkage' ? (<LinkagePicker
+                        class="w-picker-wrapper"
+                        value={this.props.value}
+                        options={this.props.options}
+                        level={this.props.level}
+                        defaultType={this.props.defaultType}
+                        defaultProps={this.props.defaultProps}
+                        itemHeight={itemHeight}
+                        change={this.handlerChange}
+                        touchstart={this.touchStart}
+                        touchend={this.touchEnd}>
+                    </LinkagePicker>) : null}</View>
+                    
+                    <View>{this.props.mode == 'half' ? (<HalfPicker
+                        class="w-picker-wrapper"
+                        startYear={this.props.startYear}
+                        endYear={this.props.endYear}
+                        value={this.props.value}
+                        itemHeight={itemHeight}
+                        current={this.props.current}
+                        disabledAfter={this.props.disabledAfter}
+                        change={this.handlerChange}
+                        touchstart={this.touchStart}
+                        touchend={this.touchEnd}>
+                    </HalfPicker>) : null}</View>
+
+                    <View>{this.props.mode == 'date' ? (<DatePicker
+                        class="w-picker-wrapper"
+                        startYear={this.props.startYear}
+                        endYear={this.props.endYear}
+                        value={this.props.value}
+                        fields={this.props.fields}
+                        itemHeight={itemHeight}
+                        current={this.props.current}
+                        disabledAfter={this.props.disabledAfter}
+                        change={this.handlerChange}
+                        touchstart={this.touchStart}
+                        touchend={this.touchEnd}>
+                    </DatePicker>) : null}</View>
+
+                </View>
+            </View >
+        )
+    }
+}
+WPicker.propTypes = {
+    value: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.number,
+        PropTypes.array
+    ]),//默认值
+    current: PropTypes.bool,//是否默认显示当前时间,如果是,传的默认值将失效
+    second: PropTypes.bool,//time-picker是否显示秒
+    mode: PropTypes.string,
+    themeColor: PropTypes.string,//确认按钮主题颜色
+    fields: PropTypes.string,//日期颗粒度:year、month、day、hour、minute、second
+    disabledAfter: PropTypes.bool,//是否禁用当前之后的日期
+    options: PropTypes.oneOfType([//selector,region数据源
+        PropTypes.array,
+        PropTypes.object,
+    ]),
+    defaultProps: PropTypes.object,//selector,linkagle字段转换配置
+    defaultType: PropTypes.string,
+    hideArea: PropTypes.bool,//mode=region时,是否隐藏区县列
+    level: PropTypes.oneOfType([//多级联动层级,表示几级联动,区间2-4;
+        PropTypes.string,
+        PropTypes.number,
+    ]),
+    timeout: PropTypes.bool,//是否开启点击延迟,当快速滚动 还没有滚动完毕点击关闭时得到的值是不准确的
+    expand: PropTypes.oneOfType([//mode=shortterm 默认往后拓展天数
+        PropTypes.string,
+        PropTypes.number,
+    ]),
+    startYear: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.number,
+    ]),
+    endYear: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.number,
+    ])
+}
+WPicker.defaultProps = {
+    value: "",
+    current: false,
+    second: true,
+    mode: "date",
+    themeColor: "#f5a200",
+    fields: "date",
+    disabledAfter: false,
+    options: [],
+    defaultProps: {
+        label: "label",
+        value: "value",
+        children: "children"
+    },
+    defaultType: "label",
+    hideArea: false,
+    level: 2,
+    timeout: false,
+    expand: 30,
+    startYear: 1970,
+    endYear: defaultTime
+};
+

+ 69 - 0
src/components/common/wPicker/index.scss

@@ -0,0 +1,69 @@
+.w-picker-item {
+    text-align: center;
+    width: 100%;
+    height: 88px;
+    line-height: 88px;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    font-size: 30px;
+  }
+  .w-picker{
+      z-index: 888;
+      .mask {
+        position: fixed;
+        z-index: 10002;
+        top: 0;
+        right: 0;
+        left: 0;
+        bottom: 0;
+        background: rgba(0, 0, 0, 0.6);
+        visibility: hidden;
+        opacity: 0;
+        transition: all 0.3s ease;
+      }
+      .mask.visible{
+          visibility: visible;
+          opacity: 1;
+      }
+      .w-picker-cnt {
+        position: fixed;
+        bottom: 0;
+        left: 0;
+        width: 100%;
+        transition: all 0.3s ease;
+        transform: translateY(100%);
+        z-index: 10003;
+        background-color: #fff;
+      }
+      .w-picker-cnt.visible {
+        transform: translateY(0);
+      }
+      .w-picker-header{
+        display: flex;
+        align-items: center;
+        padding: 0 30px;
+        height: 88px;
+        background-color: #fff;
+        position: relative;
+        text-align: center;
+        font-size: 32px;
+        justify-content: space-between;
+        border-bottom: solid 1px #eee;
+        .w-picker-btn{
+            font-size: 30px;
+        }
+      }
+      
+      .w-picker-hd:after {
+        content: ' ';
+        position: absolute;
+        left: 0;
+        bottom: 0;
+        right: 0;
+        height: 1px;
+        border-bottom: 1px solid #e5e5e5;
+        color: #e5e5e5;
+        transform-origin: 0 100%;
+        transform: scaleY(0.5);
+      }
+  }

+ 313 - 0
src/components/common/wPicker/linkagePicker/index.js

@@ -0,0 +1,313 @@
+import Taro from '@tarojs/taro'
+import React, { Component } from 'react'
+import { View, Text,PickerView,PickerViewColumn} from '@tarojs/components'
+import './index.scss'
+import PropTypes from 'prop-types';
+export default class LinkagePicker extends Component {
+
+    state = {
+        pickVal: [],
+        range: [],
+        checkObj: {},
+        value2: null,
+        options2: null
+    }
+
+    componentWillMount() {
+        if (this.props.options.length != 0) {
+            this.initData();
+        }
+    }
+
+    componentDidMount() { }
+
+    componentWillUnmount() { }
+
+    componentDidShow() { }
+
+    componentDidHide() { }
+
+    componentDidUpdate(prevProps, prevState) {
+        if (prevProps.value != this.state.value2) {
+            this.setState({
+                value2: prevProps.value,
+            }, () => {
+                if (this.props.options.length != 0) {
+                    this.initData();
+                }
+            })
+        }
+        if (prevProps.options != this.state.options2) {
+            this.setState({
+                options2: prevProps.options,
+            }, () => {
+                this.initData();
+            })
+        }
+    }
+
+
+    nodeKey = () => {
+        return this.props.defaultProps.label;
+    }
+
+    nodeVal = () => {
+        return this.props.defaultProps.value;
+    }
+
+    nodeChild = () => {
+        return this.props.defaultProps.children;
+    }
+
+    getData = () => {
+        //用来处理初始化数据
+        let options = this.props.options;
+        let col1 = {}, col2 = {}, col3 = {}, col4 = {};
+        let arr1 = options, arr2 = [], arr3 = [], arr4 = [];
+        let col1Index = 0, col2Index = 0, col3Index = 0, col4Index = 0;
+        let a1 = "", a2 = "", a3 = "", a4 = "";
+        let dVal = [], obj = {};
+        let value = this.props.value;
+        let data = [];
+        a1 = value[0];
+        a2 = value[1];
+        if (this.props.level > 2) {
+            a3 = value[2];
+        }
+        if (this.props.level > 3) {
+            a4 = value[3];
+        };
+        /*第1列*/
+        col1Index = arr1.findIndex((v) => {
+            return v[this.props.defaultType] == a1
+        });
+        col1Index = value ? (col1Index != -1 ? col1Index : 0) : 0;
+        col1 = arr1[col1Index];
+
+        /*第2列*/
+        arr2 = arr1[col1Index][this.nodeChild()];
+        col2Index = arr2.findIndex((v) => {
+            return v[this.props.defaultType] == a2
+        });
+        col2Index = value ? (col2Index != -1 ? col2Index : 0) : 0;
+        col2 = arr2[col2Index];
+
+        /*第3列*/
+        if (this.props.level > 2) {
+            arr3 = arr2[col2Index][this.nodeChild()];
+            col3Index = arr3.findIndex((v) => {
+                return v[this.props.defaultType] == a3;
+            });
+            col3Index = value ? (col3Index != -1 ? col3Index : 0) : 0;
+            col3 = arr3[col3Index];
+        };
+
+
+        /*第4列*/
+        if (this.props.level > 3) {
+            arr4 = arr3[col4Index][this.nodeChild()];
+            col4Index = arr4.findIndex((v) => {
+                return v[this.props.defaultType] == a4;
+            });
+            col4Index = value ? (col4Index != -1 ? col4Index : 0) : 0;
+            col4 = arr4[col4Index];
+        };
+        switch (this.props.level * 1) {
+            case 2:
+                dVal = [col1Index, col2Index];
+                obj = {
+                    col1,
+                    col2
+                }
+                data = [arr1, arr2];
+                break;
+            case 3:
+                dVal = [col1Index, col2Index, col3Index];
+                obj = {
+                    col1,
+                    col2,
+                    col3
+                }
+                data = [arr1, arr2, arr3];
+                break;
+            case 4:
+                dVal = [col1Index, col2Index, col3Index, col4Index];
+                obj = {
+                    col1,
+                    col2,
+                    col3,
+                    col4
+                }
+                data = [arr1, arr2, arr3, arr4];
+                break
+        }
+        return {
+            data,
+            dVal,
+            obj
+        }
+    }
+
+    initData = () => {
+        let dataData = this.getData();
+        let data = dataData.data;
+        let arr1 = data[0];
+        let arr2 = data[1];
+        let arr3 = data[2] || [];
+        let arr4 = data[3] || [];
+        let obj = dataData.obj;
+        let col1 = obj.col1, col2 = obj.col2, col3 = obj.col3 || {}, col4 = obj.col4 || {};
+        let result = "", value = [];
+        let range = [];
+        switch (this.props.level) {
+            case 2:
+                value = [col1[this.nodeVal()], col2[this.nodeVal()]];
+                result = `${col1[this.nodeKey()] + col2[this.nodeKey()]}`;
+                range = [arr1, arr2];
+                break;
+            case 3:
+                value = [col1[this.nodeVal()], col2[this.nodeVal()], col3[this.nodeVal()]];
+                result = `${col1[this.nodeKey()] + col2[this.nodeKey()] + col3[this.nodeKey()]}`;
+                range = [arr1, arr2, arr3];
+                break;
+            case 4:
+                value = [col1[this.nodeVal()], col2[this.nodeVal()], col3[this.nodeVal()], col4[this.nodeVal()]];
+                result = `${col1[this.nodeKey()] + col2[this.nodeKey()] + col3[this.nodeKey()] + col4[this.nodeKey()]}`;
+                range = [arr1, arr2, arr3, arr4];
+                break;
+        }
+        this.setState({
+            range,
+            checkObj: obj
+        })
+        Taro.nextTick(() => {
+            this.setState({
+                pickVal: dataData.dVal
+            })
+        });
+        this.props.change({
+            result: result,
+            value: value,
+            obj: obj
+        })
+    }
+
+    handlerChange = (e) => {
+        let arr = [...e.detail.value];
+        let col1Index = arr[0], col2Index = arr[1], col3Index = arr[2] || 0, col4Index = arr[3] || 0;
+        let arr1 = [], arr2 = [], arr3 = [], arr4 = [];
+        let col1, col2, col3, col4, obj = {};
+        let result = "", value = [];
+        arr1 = this.props.options;
+        arr2 = (arr1[col1Index] && arr1[col1Index][this.nodeChild()]) || arr1[arr1.length - 1][this.nodeChild()] || [];
+        col1 = arr1[col1Index] || arr1[arr1.length - 1] || {};
+        col2 = arr2[col2Index] || arr2[arr2.length - 1] || {};
+        if (this.props.level > 2) {
+            arr3 = (arr2[col2Index] && arr2[col2Index][this.nodeChild()]) || arr2[arr2.length - 1][this.nodeChild()];
+            col3 = arr3[col3Index] || arr3[arr3.length - 1] || {};
+        }
+        if (this.props.level > 3) {
+            arr4 = (arr3[col3Index] && arr3[col3Index][this.nodeChild()]) || arr3[arr3.length - 1][this.nodeChild()] || [];
+            col4 = arr4[col4Index] || arr4[arr4.length - 1] || {};
+        }
+        switch (this.props.level) {
+            case 2:
+                obj = {
+                    col1,
+                    col2
+                }
+                this.setState({
+                    range: [arr1, arr2]
+                })
+                result = `${(col1[this.nodeKey()] || '') + (col2[this.nodeKey()] || '')}`;
+                value = [col1[this.nodeVal()] || '', col2[this.nodeVal()] || ''];
+                break;
+            case 3:
+                obj = {
+                    col1,
+                    col2,
+                    col3
+                }
+                this.setState({
+                    range: [arr1, arr2, arr3]
+                })
+                result = `${(col1[this.nodeKey()] || '') + (col2[this.nodeKey()] || '') + (col3[this.nodeKey()] || '')}`;
+                value = [col1[this.nodeVal()] || '', col2[this.nodeVal()] || '', col3[this.nodeVal()] || ''];
+                break;
+            case 4:
+                obj = {
+                    col1,
+                    col2,
+                    col3,
+                    col4
+                }
+                this.setState({
+                    range: [arr1, arr2, arr3, arr4],
+                })
+                result = `${(col1[this.nodeKey()] || '') + (col2[this.nodeKey()] || '') + (col3[this.nodeKey()] || '') + (col4[this.nodeKey()] || '')}`;
+                value = [col1[this.nodeVal()] || '', col2[this.nodeVal()] || '', col3[this.nodeVal()] || '', col4[this.nodeVal()] || ''];
+                break;
+        }
+        this.setState({
+            pickVal: arr,
+            checkObj: obj
+        })
+        this.props.change({
+            result: result,
+            value: value,
+            obj: obj
+        })
+    }
+
+    render() {
+        const { pickVal,range } = this.state
+        return (
+            <View className='w-picker-view'>
+                <PickerView className="d-picker-view" indicatorStyle={this.props.itemHeight} value={pickVal} onChange={this.handlerChange}>
+
+                    {
+                        range.map((group, gIndex) => {
+                            return (<PickerViewColumn key={gIndex}>
+                                {
+                                    group.map((item, index) => {
+                                        return (<View className="w-picker-item" key={index}>{item[this.nodeKey()]}</View>)
+                                    })
+                                }
+
+                            </PickerViewColumn>)
+                        })
+                    }
+
+                </PickerView>
+            </View>
+
+        )
+    }
+}
+
+LinkagePicker.PropTypes = {
+    itemHeight: PropTypes.string,
+    value: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.array
+    ]),
+    defaultType: PropTypes.string,
+    options: PropTypes.array,
+    defaultProps: PropTypes.object,
+    level: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.number
+    ]),
+}
+LinkagePicker.defaultProps = {
+    itemHeight: "44px",
+    value: "",
+    defaultType: "label",
+    options: [],
+    defaultProps: {
+        lable: "label",
+        value: "value",
+        children: "children"
+    },
+    level: 2
+}

+ 26 - 0
src/components/common/wPicker/linkagePicker/index.scss

@@ -0,0 +1,26 @@
+.w-picker-flex2{
+	flex:2;
+}
+.w-picker-flex1{
+	flex:1;
+}
+.w-picker-view {
+	width: 100%;
+	height: 476px;
+	overflow: hidden;
+	background-color: rgba(255, 255, 255, 1);
+	z-index: 666;
+}
+.d-picker-view{
+	height: 100%;
+}
+
+.w-picker-item {
+  text-align: center;
+  width: 100%;
+  height: 88px;
+  line-height: 88px;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+  font-size: 30px;
+}

+ 422 - 0
src/components/common/wPicker/rangePicker/index.js

@@ -0,0 +1,422 @@
+import Taro from '@tarojs/taro'
+import React, { Component } from 'react'
+import { View, PickerView, PickerViewColumn } from '@tarojs/components'
+import './index.scss'
+import PropTypes from 'prop-types';
+let defaultTime = new Date().getFullYear()
+export default class RangePicker extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            pickVal: [],
+            range: {},
+            checkObj: {},
+            values: null
+        }
+    }
+
+    componentWillMount() {
+        this.initData();
+    }
+
+    componentDidMount() { }
+
+    componentWillUnmount() { }
+
+    componentDidShow() { }
+
+    componentDidHide() { }
+
+    componentDidUpdate(prevProps, prevState) {
+        if (prevProps.value !== this.state.values) {
+            // this.initData();
+            this.setState({
+                values: prevProps.value,
+            }, () => {
+                this.initData();
+            })
+        }
+    }
+
+    formatNum(n) {
+        return (Number(n) < 10 ? '0' + Number(n) : Number(n) + '');
+    }
+
+    checkValue = (value) => {
+        let strReg = /^\d{4}-\d{2}-\d{2}$/, example = "2020-04-03";
+        if (!strReg.test(value[0]) || !strReg.test(value[1])) {
+            console.log(new Error("请传入与mode匹配的value值,例[" + example + "," + example + "]"))
+        }
+        return strReg.test(value[0]) && strReg.test(value[1]);
+    }
+
+    resetToData = (fmonth, fday, tyear, tmonth) => {
+        let range = this.state.range;
+        let tmonths = [], tdays = [];
+        let yearFlag = tyear != range.tyears[0];
+        let monthFlag = tyear != range.tyears[0] || tmonth != range.tmonths[0];
+        let ttotal = new Date(tyear, tmonth, 0).getDate();
+        for (let i = yearFlag ? 1 : fmonth * 1; i <= 12; i++) {
+            tmonths.push(this.formatNum(i))
+        }
+        for (let i = monthFlag ? 1 : fday * 1; i <= ttotal; i++) {
+            tdays.push(this.formatNum(i))
+        }
+        return {
+            tmonths,
+            tdays
+        }
+    }
+
+    resetData = (fyear, fmonth, fday, tyear, tmonth) => {
+        let fyears = [], fmonths = [], fdays = [], tyears = [], tmonths = [], tdays = [];
+        let startYear = this.props.startYear;
+        let endYear = this.props.endYear;
+        let ftotal = new Date(fyear, fmonth, 0).getDate();
+        let ttotal = new Date(tyear, tmonth, 0).getDate();
+        for (let i = startYear * 1; i <= endYear; i++) {
+            fyears.push(this.formatNum(i))
+        }
+        for (let i = 1; i <= 12; i++) {
+            fmonths.push(this.formatNum(i))
+        }
+        for (let i = 1; i <= ftotal; i++) {
+            fdays.push(this.formatNum(i))
+        }
+        for (let i = fyear * 1; i <= endYear; i++) {
+            tyears.push(this.formatNum(i))
+        }
+        for (let i = fmonth * 1; i <= 12; i++) {
+            tmonths.push(this.formatNum(i))
+        }
+        for (let i = fday * 1; i <= ttotal; i++) {
+            tdays.push(this.formatNum(i))
+        }
+        return {
+            fyears,
+            fmonths,
+            fdays,
+            tyears,
+            tmonths,
+            tdays
+        }
+    }
+
+    getData = (dVal) => {
+        let start = this.props.startYear * 1;
+        let end = this.props.endYear * 1;
+        let value = dVal;
+        let flag = this.props.current;
+        let aToday = new Date();
+        let tYear, tMonth, tDay, tHours, tMinutes, tSeconds, pickVal = [];
+        let initstartDate = new Date(start.toString());
+        let endDate = new Date(end.toString());
+        if (start > end) {
+            initstartDate = new Date(end.toString());
+            endDate = new Date(start.toString());
+        };
+        let startYear = initstartDate.getFullYear();
+        let startMonth = initstartDate.getMonth() + 1;
+        let endYear = endDate.getFullYear();
+        let fyears = [], fmonths = [], fdays = [], tyears = [], tmonths = [], tdays = [], returnArr = [], startDVal = [], endDVal = [];
+        let curMonth = flag ? value[1] * 1 : (startDVal[1] * 1 + 1);
+        let curMonth1 = flag ? value[5][1] * 1 : (value[5] * 1 + 1);
+        let totalDays = new Date(value[0], value[1], 0).getDate();
+        let totalDays1 = new Date(value[4], value[5], 0).getDate();
+        for (let s = startYear; s <= endYear; s++) {
+            fyears.push(this.formatNum(s));
+        };
+        for (let m = 1; m <= 12; m++) {
+            fmonths.push(this.formatNum(m));
+        };
+        for (let d = 1; d <= totalDays; d++) {
+            fdays.push(this.formatNum(d));
+        };
+        for (let s = value[0] * 1; s <= endYear; s++) {
+            tyears.push(this.formatNum(s));
+        };
+
+        if (value[4] * 1 > value[0] * 1) {
+            for (let m = 1; m <= 12; m++) {
+                tmonths.push(this.formatNum(m));
+            };
+            for (let d = 1; d <= totalDays1; d++) {
+                tdays.push(this.formatNum(d));
+            };
+        } else {
+            for (let m = value[1] * 1; m <= 12; m++) {
+                tmonths.push(this.formatNum(m));
+            };
+            for (let d = value[2] * 1; d <= totalDays1; d++) {
+                tdays.push(this.formatNum(d));
+            };
+        };
+
+        pickVal = [
+            fyears.indexOf(value[0]) == -1 ? 0 : fyears.indexOf(value[0]),
+            fmonths.indexOf(value[1]) == -1 ? 0 : fmonths.indexOf(value[1]),
+            fdays.indexOf(value[2]) == -1 ? 0 : fdays.indexOf(value[2]),
+            0,
+            tyears.indexOf(value[4]) == -1 ? 0 : tyears.indexOf(value[4]),
+            tmonths.indexOf(value[5]) == -1 ? 0 : tmonths.indexOf(value[5]),
+            tdays.indexOf(value[6]) == -1 ? 0 : tdays.indexOf(value[6])
+        ];
+        return {
+            fyears,
+            fmonths,
+            fdays,
+            tyears,
+            tmonths,
+            tdays,
+            pickVal
+        }
+    }
+
+    getDval = () => {
+        let value = this.props.value;
+        let fields = this.props.fields;
+        let dVal = null;
+        let aDate = new Date();
+        let fyear = this.formatNum(aDate.getFullYear());
+        let fmonth = this.formatNum(aDate.getMonth() + 1);
+        let fday = this.formatNum(aDate.getDate());
+        let tyear = this.formatNum(aDate.getFullYear());
+        let tmonth = this.formatNum(aDate.getMonth() + 1);
+        let tday = this.formatNum(aDate.getDate());
+        if (value && value.length > 0) {
+            let flag = this.checkValue(value);
+            if (!flag) {
+                dVal = [fyear, fmonth, fday, "-", tyear, tmonth, tday]
+            } else {
+                dVal = [...value[0].split("-"), "-", ...value[1].split("-")];
+            }
+        } else {
+            dVal = [fyear, fmonth, fday, "-", tyear, tmonth, tday]
+        }
+        return dVal;
+    }
+
+    initData = () => {
+        let range = [], pickVal = [];
+        let result = "", full = "", obj = {};
+        let dVal = this.getDval();
+        let dateData = this.getData(dVal);
+        let fyears = [], fmonths = [], fdays = [], tyears = [], tmonths = [], tdays = [];
+        let fyear, fmonth, fday, tyear, tmonth, tday;
+        pickVal = dateData.pickVal;
+        fyears = dateData.fyears;
+        fmonths = dateData.fmonths;
+        fdays = dateData.fdays;
+        tyears = dateData.tyears;
+        tmonths = dateData.tmonths;
+        tdays = dateData.tdays;
+        range = {
+            fyears,
+            fmonths,
+            fdays,
+            tyears,
+            tmonths,
+            tdays,
+        }
+        fyear = range.fyears[pickVal[0]];
+        fmonth = range.fmonths[pickVal[1]];
+        fday = range.fdays[pickVal[2]];
+        tyear = range.tyears[pickVal[4]];
+        tmonth = range.tmonths[pickVal[5]];
+        tday = range.tdays[pickVal[6]];
+        obj = {
+            fyear,
+            fmonth,
+            fday,
+            tyear,
+            tmonth,
+            tday
+        }
+        result = full = `${fyear + '-' + fmonth + '-' + fday + '至' + tyear + '-' + tmonth + '-' + tday}`;
+        this.setState({
+            range,
+            checkObj: obj
+        })
+        Taro.nextTick(() => {
+            this.setState({
+                pickVal
+            })
+        });
+        this.props.change({
+            result: result,
+            value: full,
+            obj: obj
+        })
+    }
+
+    handlerChange = (e) => {
+        let arr = [...e.detail.value];
+        let result = "", full = "", obj = {};
+        let year = "", month = "", day = "", hour = "", minute = "", second = "", note = [], province, city, area;
+        let checkObj = this.state.checkObj;
+        let days = [], months = [], endYears = [], endMonths = [], endDays = [], startDays = [];
+        let mode = this.props.mode;
+        let col1, col2, col3, d, a, h, m;
+        let xDate = new Date().getTime();
+        let range = Object.assign({}, this.state.range);
+        let fyear = range.fyears[arr[0]] || range.fyears[range.fyears.length - 1];
+        let fmonth = range.fmonths[arr[1]] || range.fmonths[range.fmonths.length - 1];
+        let fday = range.fdays[arr[2]] || range.fdays[range.fdays.length - 1];
+        let tyear = range.tyears[arr[4]] || range.tyears[range.tyears.length - 1];
+        let tmonth = range.tmonths[arr[5]] || range.tmonths[range.tmonths.length - 1];
+        let tday = range.tdays[arr[6]] || range.tdays[range.tdays.length - 1];
+        let resetData = this.resetData(fyear, fmonth, fday, tyear, tmonth);
+        if (fyear != checkObj.fyear || fmonth != checkObj.fmonth || fday != checkObj.fday) {
+            arr[4] = 0;
+            arr[5] = 0;
+            arr[6] = 0;
+            range.tyears = resetData.tyears;
+            range.tmonths = resetData.tmonths;
+            range.tdays = resetData.tdays;
+            this.setState({
+                range
+            },()=>{
+                range = Object.assign({}, this.state.range);
+                tyear = range.tyears[0];
+                checkObj.tyears = range.tyears[0];
+                tmonth = range.tmonths[0];
+                checkObj.tmonths = range.tmonths[0];
+                tday = range.tdays[0];
+                checkObj.tdays = range.tdays[0];
+            })       
+        }
+        if (fyear != checkObj.fyear || fmonth != checkObj.fmonth) {
+            range.fdays = resetData.fdays;
+            this.setState({
+                range
+            },()=>{
+                range = Object.assign({}, this.state.range);
+            }) 
+        };
+        if (tyear != checkObj.tyear) {
+            arr[5] = 0;
+            arr[6] = 0;
+            let toData = this.resetToData(fmonth, fday, tyear, tmonth);
+            range.tmonths = toData.tmonths;
+            range.tdays = toData.tdays;
+            this.setState({
+                range
+            },()=>{
+                range = Object.assign({}, this.state.range);
+                tmonth = range.tmonths[0];
+                checkObj.tmonths = range.tmonths[0];
+                tday = range.tdays[0];
+                checkObj.tdays = range.tdays[0];
+            })            
+        };
+        if (tmonth != checkObj.tmonth) {
+            arr[6] = 0;
+            let toData = this.resetToData(fmonth, fday, tyear, tmonth);
+            range.tdays = toData.tdays;
+            this.setState({
+                range
+            },()=>{
+                range = Object.assign({}, this.state.range);
+                tday = range.tdays[0];
+                checkObj.tdays = range.tdays[0];
+            })            
+        };
+        result = full = `${fyear + '-' + fmonth + '-' + fday + '至' + tyear + '-' + tmonth + '-' + tday}`;
+        obj = {
+            fyear, fmonth, fday, tyear, tmonth, tday
+        }
+        this.setState({
+            checkObj: obj,
+            pickVal: arr
+        })
+        Taro.nextTick(() => {
+            this.setState({
+                pickVal: arr
+            })
+        });
+        this.props.change({
+            result: result,
+            value: full,
+            obj: obj
+        })
+    }
+
+    render() {
+        const { pickVal,range }=this.state
+        return (
+            <View className='w-picker-view'>
+                <PickerView className="d-picker-view" indicatorStyle={this.props.itemHeight} value={pickVal} onChange={this.handlerChange}>
+                    <PickerViewColumn className="w-picker-flex2">
+                        {
+                            range.fyears.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item}年</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                    <PickerViewColumn className="w-picker-flex2">
+                        {
+                            range.fmonths.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item}月</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                    <PickerViewColumn className="w-picker-flex2">
+                        {
+                            range.fdays.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item}日</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                    <PickerViewColumn className="w-picker-flex1">
+                        <View className="w-picker-item">-</View>
+                    </PickerViewColumn>
+                    <PickerViewColumn className="w-picker-flex2">
+                        {
+                            range.tyears.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item}年</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                    <PickerViewColumn className="w-picker-flex2">
+                        {
+                            range.tmonths.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item}月</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                    <PickerViewColumn className="w-picker-flex2">
+                        {
+                            range.tdays.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item}日</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                </PickerView>
+            </View>
+        )
+    }
+}
+
+RangePicker.PropTypes = {
+    itemHeight: PropTypes.string,
+    value: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.array
+    ]),
+    current: PropTypes.bool,
+    startYear: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.number,
+    ]),
+    endYear: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.number,
+    ])
+}
+RangePicker.defaultProps = {
+    itemHeight: "44px",
+    value: [],
+    current: false,
+    startYear: 1970,
+    endYear: defaultTime
+}

+ 26 - 0
src/components/common/wPicker/rangePicker/index.scss

@@ -0,0 +1,26 @@
+.w-picker-flex2{
+	flex:2;
+}
+.w-picker-flex1{
+	flex:1;
+}
+.w-picker-view {
+	width: 100%;
+	height: 476px;
+	overflow: hidden;
+	background-color: rgba(255, 255, 255, 1);
+	z-index: 666;
+}
+.d-picker-view{
+	height: 100%;
+}
+
+.w-picker-item {
+  text-align: center;
+  width: 100%;
+  height: 88px;
+  line-height: 88px;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+  font-size: 30px;
+}

+ 234 - 0
src/components/common/wPicker/regionPicker/index.js

@@ -0,0 +1,234 @@
+import Taro from '@tarojs/taro'
+import React, { Component } from 'react'
+import { View, PickerView, PickerViewColumn } from '@tarojs/components'
+import './index.scss'
+import PropTypes from 'prop-types';
+import areaData from "../areadata/areadata.js"
+
+export default class RegionPicker extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            pickVal: [],
+            range: {
+                provinces: [],
+                citys: [],
+                areas: []
+            },
+            checkObj: {},
+            values: null
+        }
+    }
+    
+    componentWillMount() {
+        this.initData();
+    }
+
+    componentDidMount() { }
+
+    componentWillUnmount() { }
+
+    componentDidShow() { }
+
+    componentDidHide() { }
+    componentDidUpdate(prevProps, prevState) {
+        if (prevProps.value !== this.state.values) {
+            // this.initData();
+            this.setState({
+                values: prevProps.value,
+            }, () => {
+                this.initData();
+            })
+        }
+    }
+
+    getData = () => {
+        //用来处理初始化数据
+        let provinces = areaData;
+        let dVal = [];
+        let value = this.props.value;
+        let a1 = value[0];//默认值省
+        let a2 = value[1];//默认值市
+        let a3 = value[2];//默认值区、县
+        let province, city, area;
+        let provinceIndex = provinces.findIndex((v) => {
+            return v[this.props.defaultType] == a1
+        });
+        provinceIndex = value ? (provinceIndex != -1 ? provinceIndex : 0) : 0;
+        let citys = provinces[provinceIndex].children;
+        let cityIndex = citys.findIndex((v) => {
+            return v[this.props.defaultType] == a2
+        });
+        cityIndex = value ? (cityIndex != -1 ? cityIndex : 0) : 0;
+        let areas = citys[cityIndex].children;
+        let areaIndex = areas.findIndex((v) => {
+            return v[this.props.defaultType] == a3;
+        });
+        areaIndex = value ? (areaIndex != -1 ? areaIndex : 0) : 0;
+        dVal = this.props.hideArea ? [provinceIndex, cityIndex] : [provinceIndex, cityIndex, areaIndex];
+        province = provinces[provinceIndex];
+        city = citys[cityIndex];
+        area = areas[areaIndex];
+        let obj = this.props.hideArea ? {
+            province,
+            city
+        } : {
+                province,
+                city,
+                area
+            }
+        return this.props.hideArea ? {
+            provinces,
+            citys,
+            dVal,
+            obj
+        } : {
+                provinces,
+                citys,
+                areas,
+                dVal,
+                obj
+            }
+    }
+
+    initData = () => {
+        let dataData = this.getData();
+        let provinces = dataData.provinces;
+        let citys = dataData.citys;
+        let areas = this.props.hideArea ? [] : dataData.areas;
+        let obj = dataData.obj;
+        let province = obj.province, city = obj.city, area = this.props.hideArea ? {} : obj.area;
+        let value = this.props.hideArea ? [province.value, city.value] : [province.value, city.value, area.value];
+        let result = this.props.hideArea ? `${province.label + city.label}` : `${province.label + city.label + area.label}`;
+        this.setState({
+            range: (this.props.hideArea ? {
+                provinces,
+                citys,
+            } : {
+                    provinces,
+                    citys,
+                    areas
+                })
+        })
+        this.setState({
+            checkObj: obj
+        })
+        Taro.nextTick(() => {
+            this.setState({
+                pickVal: dataData.dVal
+            })
+        });
+        this.props.change({
+            result: result,
+            value: value,
+            obj: obj
+        })
+    }
+
+    handlerChange = (e) => {
+        let range = { ...this.state.range }
+        console.log(range)
+        let arr = [...e.detail.value];
+        let provinceIndex = arr[0], cityIndex = arr[1], areaIndex = this.props.hideArea ? 0 : arr[2];
+        let provinces = areaData;
+        let citys = (provinces[provinceIndex] && provinces[provinceIndex].children) || provinces[provinces.length - 1].children || [];
+        let areas = this.props.hideArea ? [] : ((citys[cityIndex] && citys[cityIndex].children) || citys[citys.length - 1].children || []);
+        let province = provinces[provinceIndex] || provinces[provinces.length - 1],
+            city = citys[cityIndex] || [citys.length - 1],
+            area = this.props.hideArea ? {} : (areas[areaIndex] || [areas.length - 1]);
+        let obj = this.props.hideArea ? {
+            province,
+            city
+        } : {
+                province,
+                city,
+                area
+            }
+        if (this.state.checkObj.province.label != province.label) {
+            //当省更新的时候需要刷新市、区县的数据;
+            range.citys = citys;
+            if (!this.props.hideArea) {
+                range.areas = areas;
+            }
+            this.setState({
+                range
+            })
+
+        }
+        if (this.state.checkObj.city.label != city.label) {
+            //当市更新的时候需要刷新区县的数据;
+            if (!this.props.hideArea) {
+                range.areas = areas;
+            }
+            this.setState({
+                range
+            })
+        }
+        this.setState({
+            checkObj: obj,
+            pickVal: arr
+        })
+        Taro.nextTick(() => {
+            this.setState({
+                pickVal: arr
+            })
+        });
+        let result = this.props.hideArea ? `${province.label + city.label}` : `${province.label + city.label + area.label}`;
+        let value = this.props.hideArea ? [province.value, city.value] : [province.value, city.value, area.value];
+        this.props.change({
+            result: result,
+            value: value,
+            obj: obj
+        })
+
+    }
+
+    render() {
+        const { pickVal,range }=this.state
+        return (
+            <View className='w-picker-view'>
+                <PickerView className="d-picker-view" indicatorStyle={this.props.itemHeight} value={pickVal} onChange={this.handlerChange}>
+                    <PickerViewColumn>
+                        {
+                            range.provinces.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item.label}</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                    <PickerViewColumn>
+                        {
+                            range.citys.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item.label}</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                    <PickerViewColumn>
+                        {
+                            range.areas.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item.label}</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                </PickerView>
+            </View>
+
+        )
+    }
+}
+
+RegionPicker.propTypes = {
+    itemHeight: PropTypes.string,
+    value: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.number,
+        PropTypes.array
+    ]),
+    defaultType: PropTypes.string,
+    hideArea: PropTypes.bool
+}
+RegionPicker.defaultProps = {
+    itemHeight: "44px",
+    value: "",
+    defaultType: "label",
+    hideArea: false
+};

+ 26 - 0
src/components/common/wPicker/regionPicker/index.scss

@@ -0,0 +1,26 @@
+.w-picker-flex2{
+	flex:2;
+}
+.w-picker-flex1{
+	flex:1;
+}
+.w-picker-view {
+	width: 100%;
+	height: 476px;
+	overflow: hidden;
+	background-color: rgba(255, 255, 255, 1);
+	z-index: 666;
+}
+.d-picker-view{
+	height: 100%;
+}
+
+.w-picker-item {
+  text-align: center;
+  width: 100%;
+  height: 88px;
+  line-height: 88px;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+  font-size: 30px;
+}

+ 157 - 0
src/components/common/wPicker/selectorPicker/index.js

@@ -0,0 +1,157 @@
+import Taro from '@tarojs/taro'
+import React, { Component } from 'react'
+import { View, PickerView, PickerViewColumn } from '@tarojs/components'
+import './index.scss'
+import PropTypes from 'prop-types';
+
+export default class SelectorPicker extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            pickVal: [],
+            value2: null,
+            options2: null,
+        }
+    }
+    
+    componentWillMount() {
+        if (this.props.options.length != 0) {
+            this.initData();
+        }
+    }
+
+    componentDidMount() {
+    }
+
+    componentWillUnmount() { }
+
+    componentDidShow() { }
+
+    componentDidHide() { }
+
+    componentDidUpdate(prevProps, prevState) {
+        if (prevProps.value != this.state.value2) {
+            this.setState({
+                value2: prevProps.value,
+            }, () => {
+                if (this.props.options.length != 0) {
+                    this.initData();
+                }
+            })
+        }
+        if (prevProps.options != this.state.options2) {
+            this.setState({
+                options2: prevProps.options,
+            }, () => {
+                this.initData();
+            })
+        }
+    }
+
+    nodeKey = () => {
+        return this.props.defaultProps.label;
+    }
+    nodeValue = () => {
+        return this.props.defaultProps.value;
+    }
+    range = () => {
+        return this.props.options
+    }
+
+    initData=()=>{
+        let dVal=this.props.value||"";
+        let data=this.range();
+        let pickVal=[0];
+        let cur=null;
+        let label="";
+        let value,idx;
+        if(this.props.defaultType==this.nodeValue()){
+            value=data.find((v)=>v[this.nodeValue()]==dVal);
+            idx=data.findIndex((v)=>v[this.nodeValue()]==dVal);
+        }else{
+            value=data.find((v)=>v[this.nodeKey()]==dVal);
+            idx=data.findIndex((v)=>v[this.nodeKey()]==dVal);
+        }
+        pickVal=[idx!=-1?idx:0];
+        Taro.nextTick(() => {
+            this.setState({
+                pickVal   
+            })
+        });
+        if(this.props.defaultType==this.nodeValue()){
+            this.props.change({
+                result:value?value[this.nodeKey()]:data[0][this.nodeKey()],
+                value:dVal||data[0][this.nodeKey()],
+                obj:value?value:data[0]
+            })
+        }else{
+            this.props.change({
+                result:dVal||data[0][this.nodeKey()],
+                value:value?value[this.nodeValue()]:data[0][this.nodeValue()],
+                obj:value?value:data[0]
+            })
+        }
+        
+    }
+    handlerChange=(e)=>{
+        let arr=[...e.detail.value];
+        let pickVal=[arr[0]||0];
+        let data=this.range();
+        let cur=data[arr[0]];
+        let label="";
+        let value="";
+        this.setState({
+            pickVal   
+        })
+        Taro.nextTick(() => {
+            this.setState({
+                pickVal   
+            })
+        });
+        this.props.change({
+            result:cur['name'],
+            value:cur['id'],
+            obj:cur
+        })
+    }
+
+    render() {
+        const { pickVal }=this.state
+        return (
+            <View className='w-picker-view'>
+                <PickerView className="d-picker-view" indicatorStyle={this.props.itemHeight} value={pickVal} onChange={this.handlerChange}>
+                    <PickerViewColumn>
+                        {
+                            this.range().map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item[this.nodeKey()]}</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                </PickerView>
+            </View>
+
+        )
+    }
+}
+
+SelectorPicker.propTypes = {
+    itemHeight: PropTypes.string,
+    options: PropTypes.oneOfType([
+        PropTypes.array,
+        PropTypes.object
+    ]),
+    value: PropTypes.string,
+    defaultType: PropTypes.string,
+    defaultProps: PropTypes.object
+}
+SelectorPicker.defaultProps = {
+    itemHeight: "44px",
+    options: [],
+    value: "",
+    defaultType: "label",
+    defaultProps: {
+        label: "label",
+        value: "value"
+    }
+};
+

+ 26 - 0
src/components/common/wPicker/selectorPicker/index.scss

@@ -0,0 +1,26 @@
+.w-picker-flex2{
+	flex:2;
+}
+.w-picker-flex1{
+	flex:1;
+}
+.w-picker-view {
+	width: 100%;
+	height: 476px;
+	overflow: hidden;
+	background-color: rgba(255, 255, 255, 1);
+	z-index: 666;
+}
+.d-picker-view{
+	height: 100%;
+}
+
+.w-picker-item {
+  text-align: center;
+  width: 100%;
+  height: 88px;
+  line-height: 88px;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+  font-size: 30px;
+}

+ 299 - 0
src/components/common/wPicker/shorttermPicker/index.js

@@ -0,0 +1,299 @@
+import Taro from '@tarojs/taro'
+import React, { Component } from 'react'
+import { View, PickerView, PickerViewColumn } from '@tarojs/components'
+import './index.scss'
+import PropTypes from 'prop-types';
+
+export default class ShorttermPicker extends Component {
+
+    constructor(props) {
+        super(props);
+        this.state = {
+            pickVal: [],
+            range: {},
+            checkObj: {},
+            values: null
+        }
+    }
+    componentWillMount() {
+        this.initData();
+    }
+
+    componentDidMount() { }
+
+    componentWillUnmount() { }
+
+    componentDidShow() { }
+
+    componentDidHide() { }
+
+    componentDidUpdate(prevProps, prevState) {
+        if (prevProps.value !== this.state.values) {
+            // this.initData();
+            this.setState({
+                values: prevProps.value,
+            }, () => {
+                this.initData();
+            })
+        }
+    }
+
+    formatNum = (n) => {
+        return (Number(n) < 10 ? '0' + Number(n) : Number(n) + '');
+    }
+
+    checkValue = (value) => {
+        let strReg = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/, example = "2019-12-12 18:05:00或者2019-12-12 18:05";
+        if (!strReg.test(value)) {
+            console.log(new Error("请传入与mode、fields匹配的value值,例value=" + example + ""))
+        }
+        return strReg.test(value);
+    }
+
+    resetData = (year, month, day) => {
+        let curDate = this.getCurrenDate();
+        let curFlag = this.props.current;
+        let curYear = curDate.curYear;
+        let curMonth = curDate.curMonth;
+        let curDay = curDate.curDay;
+        let curHour = curDate.curHour;
+        let months = [], days = [], sections = [];
+        let disabledAfter = this.props.disabledAfter;
+        let monthsLen = disabledAfter ? (year * 1 < curYear ? 12 : curMonth) : 12;
+        let totalDays = new Date(year, month, 0).getDate();//计算当月有几天;
+        for (let month = 1; month <= monthsLen; month++) {
+            months.push(this.formatNum(month));
+        };
+        for (let day = 1; day <= daysLen; day++) {
+            days.push(this.formatNum(day));
+        }
+        return {
+            months,
+            days,
+            sections
+        }
+    }
+
+    getData = (dVal) => {
+        //用来处理初始化数据
+        let curFlag = this.props.current;
+        let disabledAfter = this.props.disabledAfter;
+        let dates = [], hours = [], minutes = [];
+        let curDate = new Date();
+        let curYear = curDate.getFullYear();
+        let curMonth = curDate.getMonth();
+        let curDay = curDate.getDate();
+        let aDate = new Date(curYear, curMonth, curDay);
+        for (let i = 0; i < this.props.expand * 1; i++) {
+            aDate = new Date(curYear, curMonth, curDay + i);
+            let year = aDate.getFullYear();
+            let month = aDate.getMonth() + 1;
+            let day = aDate.getDate();
+            let label = year + "-" + this.formatNum(month) + "-" + this.formatNum(day);
+            switch (i) {
+                case 0:
+                    label = "今天";
+                    break;
+                case 1:
+                    label = "明天";
+                    break;
+                case 2:
+                    label = "后天";
+                    break
+            }
+            dates.push({
+                label: label,
+                value: year + "-" + this.formatNum(month) + "-" + this.formatNum(day)
+            })
+        };
+        for (let i = 0; i < 24; i++) {
+            hours.push({
+                label: this.formatNum(i),
+                value: this.formatNum(i)
+            })
+        }
+        for (let i = 0; i < 60; i++) {
+            minutes.push({
+                label: this.formatNum(i),
+                value: this.formatNum(i)
+            })
+        }
+        return {
+            dates,
+            hours,
+            minutes
+        }
+    }
+
+    getDefaultDate = () => {
+        let value = this.props.value;
+        let reg = /-/g;
+        let defaultDate = value ? new Date(value.replace(reg, "/")) : new Date();
+        let defaultYear = defaultDate.getFullYear();
+        let defaultMonth = defaultDate.getMonth() + 1;
+        let defaultDay = defaultDate.getDate();
+        let defaultDays = new Date(defaultYear, defaultMonth, 0).getDate() * 1;
+        return {
+            defaultDate,
+            defaultYear,
+            defaultMonth,
+            defaultDay,
+            defaultDays
+        }
+    }
+
+    getDval = () => {
+        let value = this.props.value;
+        let dVal = null;
+        let aDate = new Date();
+        let year = this.formatNum(aDate.getFullYear());
+        let month = this.formatNum(aDate.getMonth() + 1);
+        let day = this.formatNum(aDate.getDate());
+        let date = this.formatNum(year) + "-" + this.formatNum(month) + "-" + this.formatNum(day);
+        let hour = aDate.getHours();
+        let minute = aDate.getMinutes();
+        if (value) {
+            let flag = this.checkValue(value);
+            if (!flag) {
+                dVal = [date, hour, minute]
+            } else {
+                let v = value.split(" ");
+                dVal = [v[0], ...v[1].split(":")];
+            }
+        } else {
+            dVal = [date, hour, minute]
+        }
+        return dVal;
+    }
+
+    initData() {
+        let startDate, endDate, startYear, endYear, startMonth, endMonth, startDay, endDay;
+        let dates = [], hours = [], minutes = [];
+        let dVal = [], pickVal = [];
+        let value = this.props.value;
+        let reg = /-/g;
+        let range = {};
+        let result = "", full = "", date, hour, minute, obj = {};
+        let defaultDate = this.getDefaultDate();
+        let defaultYear = defaultDate.defaultYear;
+        let defaultMonth = defaultDate.defaultMonth;
+        let defaultDay = defaultDate.defaultDay;
+        let defaultDays = defaultDate.defaultDays;
+        let curFlag = this.props.current;
+        let disabledAfter = this.props.disabledAfter;
+        let dateData = [];
+        dVal = this.getDval();
+        console.log(dVal)
+        dateData = this.getData(dVal);
+        console.log(dateData)
+        dates = dateData.dates;
+        hours = dateData.hours;
+        minutes = dateData.minutes;
+        pickVal = [
+            dates.findIndex(n => n.value == dVal[0]) != -1 ? dates.findIndex(n => n.value == dVal[0]) : 0,
+            hours.findIndex(n => n.value == dVal[1]) != -1 ? hours.findIndex(n => n.value == dVal[1]) : 0,
+            minutes.findIndex(n => n.value == dVal[2]) != -1 ? minutes.findIndex(n => n.value == dVal[2]) : 0,
+        ];
+        range = { dates, hours, minutes };
+        console.log(range)
+        date = dVal[0] ? dVal[0] : dates[0].label;
+        hour = dVal[1] ? dVal[1] : hours[0].label;
+        minute = dVal[2] ? dVal[2] : minutes[0].label;
+        result = full = `${date + ' ' + hour + ':' + minute}`;
+        obj = {
+            date,
+            hour,
+            minute
+        }
+        this.setState({
+            range: range,
+            checkObj: obj
+        })
+        Taro.nextTick(() => {
+            this.setState({
+                pickVal
+            })
+        });
+        this.props.change({
+            result: result,
+            value: full,
+            obj: obj
+        })
+    }
+
+    handlerChange = (e) => {
+        let arr = [...e.detail.value];
+        let data = this.state.range;
+        let date = "", hour = "", minute = "";
+        let result = "", full = "", obj = {};
+        let disabledAfter = this.props.disabledAfter;
+        date = (arr[0] || arr[0] == 0) ? data.dates[arr[0]] || data.dates[data.dates.length - 1] : "";
+        hour = (arr[1] || arr[1] == 0) ? data.hours[arr[1]] || data.hours[data.hours.length - 1] : "";
+        minute = (arr[2] || arr[2] == 0) ? data.minutes[arr[2]] || data.minutes[data.minutes.length - 1] : "";
+        result = full = `${date.label + ' ' + hour.label + ':' + minute.label + ':00'}`;
+        obj = {
+            date,
+            hour,
+            minute
+        }
+        this.setState({
+            checkObj: obj,
+            pickVal: e.detail.value
+        })
+        this.props.change({
+            result: result,
+            value: full,
+            obj: obj
+        })
+    }
+
+    render() {
+        const { pickVal, range } = this.state
+        return (
+            <View className='w-picker-view'>
+                <PickerView className="d-picker-view" indicatorStyle={this.props.itemHeight} value={pickVal} onChange={this.handlerChange}>
+                    <PickerViewColumn>
+                        {
+                            range.dates.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item.label}</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                    <PickerViewColumn>
+                        {
+                            range.hours.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item.label}时</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                    <PickerViewColumn>
+                        {
+                            range.minutes.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item.label}分</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                </PickerView>
+            </View>
+        )
+    }
+}
+ShorttermPicker.propTypes = {
+    itemHeight: PropTypes.string,
+    value: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.number,
+        PropTypes.array
+    ]),
+    current: PropTypes.bool,
+    expand: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.number
+    ])
+}
+ShorttermPicker.defaultProps = {
+    itemHeight: "44px",
+    value: "",
+    current: false,
+    expand: 30
+};

+ 26 - 0
src/components/common/wPicker/shorttermPicker/index.scss

@@ -0,0 +1,26 @@
+.w-picker-flex2{
+	flex:2;
+}
+.w-picker-flex1{
+	flex:1;
+}
+.w-picker-view {
+	width: 100%;
+	height: 476px;
+	overflow: hidden;
+	background-color: rgba(255, 255, 255, 1);
+	z-index: 666;
+}
+.d-picker-view{
+	height: 100%;
+}
+
+.w-picker-item {
+  text-align: center;
+  width: 100%;
+  height: 88px;
+  line-height: 88px;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+  font-size: 30px;
+}

+ 263 - 0
src/components/common/wPicker/timePicker/index.js

@@ -0,0 +1,263 @@
+import Taro from '@tarojs/taro'
+import React, { Component } from 'react'
+import { View, PickerView, PickerViewColumn } from '@tarojs/components'
+import './index.scss'
+import PropTypes from 'prop-types';
+
+export default class TimePicker extends Component {
+
+    state = {
+        pickVal: [],
+        range: {},
+        checkObj: {},
+        values:null
+    }
+    componentWillMount() {
+        this.initData();
+    }
+
+    componentDidMount() { }
+
+    componentWillUnmount() { }
+
+    componentDidShow() { }
+
+    componentDidHide() { }
+
+    componentDidUpdate(prevProps, prevState){
+        if (prevProps.value!==this.state.values){
+            // this.initData();
+            this.setState({
+                values:prevProps.value,
+            },()=>{
+                this.initData();
+            })
+        }
+    }
+
+    formatNum = (n) => {
+        return (Number(n) < 10 ? '0' + Number(n) : Number(n) + '');
+    }
+
+    checkValue = (value) => {
+        let strReg = /^\d{2}:\d{2}:\d{2}$/, example = "18:00:05";
+        if (!strReg.test(value)) {
+            console.log(new Error("请传入与mode、fields匹配的value值,例value=" + example + ""))
+        }
+        return strReg.test(value);
+    }
+
+    resetData = (year, month, day, hour, minute) => {
+        let curDate = this.getCurrenDate();
+        let curFlag = this.props.current;
+        let curHour = curDate.curHour;
+        let curMinute = curDate.curMinute;
+        let curSecond = curDate.curSecond;
+        for (let hour = 0; hour < 24; hour++) {
+            hours.push(this.formatNum(hour));
+        }
+        for (let minute = 0; minute < 60; minute++) {
+            minutes.push(this.formatNum(minute));
+        }
+        for (let second = 0; second < 60; second++) {
+            seconds.push(this.formatNum(second));
+        }
+        return {
+            hours,
+            minutes,
+            seconds
+        }
+    }
+    getData = (curDate) => {
+        //用来处理初始化数据
+        let hours = [], minutes = [], seconds = [];
+        let curFlag = this.props.current;
+        let disabledAfter = this.props.disabledAfter;
+        let fields = this.props.fields;
+        let curHour = curDate.curHour;
+        let curMinute = curDate.curMinute;
+        let curSecond = curDate.curSecond;
+        for (let hour = 0; hour < 24; hour++) {
+            hours.push(this.formatNum(hour));
+        }
+        for (let minute = 0; minute < 60; minute++) {
+            minutes.push(this.formatNum(minute));
+        }
+        for (let second = 0; second < 60; second++) {
+            seconds.push(this.formatNum(second));
+        }
+        return this.props.second ? {
+            hours,
+            minutes,
+            seconds
+        } : {
+                hours,
+                minutes
+            }
+    }
+
+    getCurrenDate = () => {
+        let curDate = new Date();
+        let curHour = curDate.getHours();
+        let curMinute = curDate.getMinutes();
+        let curSecond = curDate.getSeconds();
+        return this.props.second ? {
+            curHour,
+            curMinute,
+            curSecond
+        } : {
+                curHour,
+                curMinute,
+            }
+    }
+
+    getDval = () => {
+        let value = this.props.value;
+        let fields = this.props.fields;
+        let dVal = null;
+        let aDate = new Date();
+        let hour = this.formatNum(aDate.getHours());
+        let minute = this.formatNum(aDate.getMinutes());
+        let second = this.formatNum(aDate.getSeconds());
+        if (value) {
+            let flag = this.checkValue(value);
+            if (!flag) {
+                dVal = [hour, minute, second]
+            } else {
+                dVal = value ? value.split(":") : [];
+            }
+        } else {
+            dVal = this.props.second ? [hour, minute, second] : [hour, minute]
+        }
+        return dVal;
+    }
+
+    initData=()=>{
+        let curDate = this.getCurrenDate();
+        let dateData = this.getData(curDate);
+        let pickVal = [], obj = {}, full = "", result = "", hour = "", minute = "", second = "";
+        let dVal = this.getDval();
+        let curFlag = this.props.current;
+        let disabledAfter = this.props.disabledAfter;
+        let hours = dateData.hours;
+        let minutes = dateData.minutes;
+        let seconds = dateData.seconds;
+        let defaultArr = this.props.second ? [
+            dVal[0] && hours.indexOf(dVal[0]) != -1 ? hours.indexOf(dVal[0]) : 0,
+            dVal[1] && minutes.indexOf(dVal[1]) != -1 ? minutes.indexOf(dVal[1]) : 0,
+            dVal[2] && seconds.indexOf(dVal[2]) != -1 ? seconds.indexOf(dVal[2]) : 0
+        ] : [
+                dVal[0] && hours.indexOf(dVal[0]) != -1 ? hours.indexOf(dVal[0]) : 0,
+                dVal[1] && minutes.indexOf(dVal[1]) != -1 ? minutes.indexOf(dVal[1]) : 0
+            ];
+        pickVal = disabledAfter ? defaultArr : (curFlag ? (this.props.second ? [
+            hours.indexOf(this.formatNum(curDate.curHour)),
+            minutes.indexOf(this.formatNum(curDate.curMinute)),
+            seconds.indexOf(this.formatNum(curDate.curSecond)),
+        ] : [
+                hours.indexOf(this.formatNum(curDate.curHour)),
+                minutes.indexOf(this.formatNum(curDate.curMinute))
+            ]) : defaultArr);
+        this.setState({
+            range:dateData,
+            checkObj:obj   
+        })
+        hour = dVal[0] ? dVal[0] : hours[0];
+        minute = dVal[1] ? dVal[1] : minutes[0];
+        if (this.props.second) second = dVal[2] ? dVal[0] : seconds[0];
+        result = this.props.second ? `${hour + ':' + minute + ':' + second}` : `${hour + ':' + minute}`;
+        full = this.props.second ? `${hour + ':' + minute + ':' + second}` : `${hour + ':' + minute + ':00'}`;
+        Taro.nextTick(() => {
+            this.setState({
+                pickVal   
+            })
+        });
+        // EventChannel.$emit("change", {
+        //     result: result,
+        //     value: full,
+        //     obj: obj
+        // })
+        this.props.change({
+            result: result,
+            value: full,
+            obj: obj
+        })
+    }
+
+    handlerChange=(e)=>{
+        let arr=[...e.detail.value];
+        let data=this.state.range;
+        let hour="",minute="",second="",result="",full="",obj={};
+        hour=(arr[0]||arr[0]==0)?data.hours[arr[0]]||data.hours[data.hours.length-1]:"";
+        minute=(arr[1]||arr[1]==0)?data.minutes[arr[1]]||data.minutes[data.minutes.length-1]:"";
+        if(this.props.second)second=(arr[2]||arr[2]==0)?data.seconds[arr[2]]||data.seconds[data.seconds.length-1]:"";
+        obj=this.props.second?{
+            hour,
+            minute,
+            second
+        }:{
+            hour,
+            minute
+        };
+        this.setState({
+            checkObj: obj,
+            pickVal:e.detail.value
+        })
+        result=this.props.second?`${hour+':'+minute+':'+second}`:`${hour+':'+minute}`;
+        full=this.props.second?`${hour+':'+minute+':'+second}`:`${hour+':'+minute+':00'}`;
+        this.props.change({
+            result: result,
+            value: full,
+            obj: obj
+        })
+    }
+
+    render() {
+        const { pickVal, range } = this.state
+        return (
+            <View className='w-picker-view'>
+                <PickerView className="d-picker-view" indicatorStyle={this.props.itemHeight} value={pickVal} onChange={this.handlerChange}>
+                    <PickerViewColumn>
+                        {
+                            range.hours.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item}时</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                    <PickerViewColumn>
+                        {
+                            range.minutes.map((item, index) => {
+                                return (<View className="w-picker-item" key={index}>{item}分</View>)
+                            })
+                        }
+                    </PickerViewColumn>
+                    {
+                        this.props.second?(<PickerViewColumn>
+                            {
+                                range.seconds.map((item, index) => {
+                                    return (<View className="w-picker-item" key={index}>{item}秒</View>)
+                                })
+                            }
+                        </PickerViewColumn>):null
+                    }
+                </PickerView>
+            </View>
+        )
+    }
+}
+TimePicker.propTypes = {
+    itemHeight: PropTypes.string,
+    value: PropTypes.oneOfType([
+        PropTypes.string,
+        PropTypes.number,
+        PropTypes.array
+    ]),
+    current: PropTypes.bool,
+    second: PropTypes.bool
+}
+TimePicker.defaultProps = {
+    itemHeight: "44px",
+    value: "",
+    current: false,
+    second: true
+};

+ 26 - 0
src/components/common/wPicker/timePicker/index.scss

@@ -0,0 +1,26 @@
+.w-picker-flex2{
+	flex:2;
+}
+.w-picker-flex1{
+	flex:1;
+}
+.w-picker-view {
+	width: 100%;
+	height: 476px;
+	overflow: hidden;
+	background-color: rgba(255, 255, 255, 1);
+	z-index: 666;
+}
+.d-picker-view{
+	height: 100%;
+}
+
+.w-picker-item {
+  text-align: center;
+  width: 100%;
+  height: 88px;
+  line-height: 88px;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+  font-size: 30px;
+}

+ 34 - 2
src/pages/details/index.jsx

@@ -1,10 +1,10 @@
 import { Component } from 'react';
-import Taro, {getCurrentPages} from '@tarojs/taro';
+import Taro from '@tarojs/taro';
 import {View, Image, Video} from '@tarojs/components'
 import AudioPlayer from '../../components/audio';
 
 import API from '../../utils/API';
-import { pay,payClose,getSelectProject,wxQuery,login } from '../../utils/servers/servers';
+import { pay,payClose,getSelectProject,wxQuery,login,getWeChatShareDetails } from '../../utils/servers/servers';
 import {resourceAddress} from '../../utils/config';
 
 import './index.less'
@@ -23,20 +23,52 @@ class Details extends Component {
     super(props);
     this.state={
       projectInfor: {},
+      weChatShareDetails: {},
     }
     this.pay= this.pay.bind(this);
     this.payClose= this.payClose.bind(this);
     this.wxQuery= this.wxQuery.bind(this);
+    this.getWeChatShareDetails= this.getWeChatShareDetails.bind(this);
   }
 
   componentDidMount() {
     this.getSelectProject();
+    this.getWeChatShareDetails();
   }
 
   onPullDownRefresh(){
     this.getSelectProject();
   }
 
+  getWeChatShareDetails(){
+    getWeChatShareDetails({type:0,pid:this.inst.router.params.id}).then(v=>{
+      if(v.error.length === 0){
+        this.setState({
+          weChatShareDetails:v.data || {}
+        })
+      }else{
+        Taro.showToast({title:v.error[0].message,icon:'none'})
+      }
+    })
+  }
+
+  onShareAppMessage(){
+    return {
+      title: this.state.weChatShareDetails.title || this.state.projectInfor.name,
+      path: 'pages/details/index?id='+this.inst.router.params.id,
+      imageUrl: this.state.weChatShareDetails.shareUrl ? (resourceAddress + this.state.weChatShareDetails.shareUrl) : (resourceAddress + this.state.projectInfor.thumbnailUrl)
+    }
+  }
+
+  //朋友圈分享
+  onShareTimeline(){
+    return {
+      title: this.state.weChatShareDetails.title,
+      query: 'id=6',
+      imageUrl: this.state.weChatShareDetails.momentsUrl ? (resourceAddress + this.state.weChatShareDetails.momentsUrl) : (resourceAddress + this.state.projectInfor.thumbnailUrl)
+    }
+  }
+
   pay(){
     let token = Taro.getStorageSync('token');
     if(!token){

+ 31 - 1
src/pages/index/index.jsx

@@ -3,7 +3,7 @@ import Taro from '@tarojs/taro';
 import { connect } from 'react-redux'
 import { View, Image } from '@tarojs/components'
 import { set } from '../../actions/counter'
-import { getProjecList } from '../../utils/servers/servers'
+import { getProjecList,getWeChatShareDetails } from '../../utils/servers/servers'
 import {resourceAddress} from '../../utils/config';
 
 import NavBar from '../../components/NavBar';
@@ -30,13 +30,16 @@ class Index extends Component {
       list: [],
       pageNo: 0,
       listState: 'LOADING',
+      weChatShareDetails:{},
     }
     this.getProjecList= this.getProjecList.bind(this);
+    this.getWeChatShareDetails= this.getWeChatShareDetails.bind(this);
   }
 
   componentDidShow() {
     //设置barter的选择状态
     this.props.set(0);
+    this.getWeChatShareDetails()
   }
 
   async componentDidMount() {
@@ -90,6 +93,33 @@ class Index extends Component {
     Taro.stopPullDownRefresh();
   }
 
+  getWeChatShareDetails(){
+    getWeChatShareDetails({type:1}).then(v=>{
+      if(v.error.length === 0){
+        this.setState({
+          weChatShareDetails:v.data
+        })
+      }else{
+        Taro.showToast({title:v.error[0].message,icon:'none'})
+      }
+    })
+  }
+
+  onShareAppMessage(){
+    return {
+      title: this.state.weChatShareDetails.title,
+      imageUrl: resourceAddress + this.state.weChatShareDetails.shareUrl
+    }
+  }
+
+  //朋友圈分享
+  onShareTimeline(){
+    return {
+      title: this.state.weChatShareDetails.title,
+      imageUrl: resourceAddress + this.state.weChatShareDetails.momentsUrl
+    }
+  }
+
   render () {
     return (
       <View className='indexPage'>

+ 4 - 6
src/pages/user/index.jsx

@@ -40,12 +40,10 @@ class Index extends Component {
 
   async componentDidShow() {
     this.props.set(1);
-    if(!Taro.getStorageSync('token')){
-      this.setState({
-        list: [],
-        token: '',
-      })
-    }
+    this.setState({
+      userInfor:Taro.getStorageSync('userInfor') || '',
+      token: Taro.getStorageSync('token') || '',
+    })
   }
 
   async componentDidMount() {

+ 3 - 13
src/pages/webDetails/index.jsx

@@ -3,22 +3,15 @@ import Taro from '@tarojs/taro';
 import {View, Image, Video} from '@tarojs/components'
 import AudioPlayer from '../../components/audio';
 
-import API from '../../utils/API';
 import { payClose,getSelectProject,wxQuery } from '../../utils/servers/servers';
 import {resourceAddress} from '../../utils/config';
 
 import './index.less'
-import 'taro-ui/dist/style/components/tag.scss';
-import "taro-ui/dist/style/components/progress.scss";
-import "taro-ui/dist/style/components/icon.scss";
-import "taro-ui/dist/style/components/slider.scss";
 
 import background from '../../assets/images/background.png';
 
 class Details extends Component {
 
-  inst = Taro.getCurrentInstance()
-
   constructor(props) {
     super(props);
     this.state={
@@ -73,7 +66,7 @@ class Details extends Component {
 
   getSelectProject(){
     getSelectProject({
-      id:this.inst.router.params.id,
+      id:27,
     }).then(v => {
       if(v.error.length === 0){
         this.setState({
@@ -89,6 +82,7 @@ class Details extends Component {
     Taro.stopPullDownRefresh();
   }
 
+
   render () {
     const { projectInfor } = this.state;
     return (
@@ -147,11 +141,7 @@ class Details extends Component {
         </View>
         <View className='detailsContent'>
           <View className='details'>产品详情</View>
-          {
-            Taro.getEnv() === 'WEAPP' ?
-              <mp-html content={projectInfor.buy === 0 ? projectInfor.content : projectInfor.commodityContent} />:
-              <View dangerouslySetInnerHTML={{__html:projectInfor.buy === 0 ? projectInfor.content+'' : projectInfor.commodityContent+''}}/>
-          }
+          <mp-html content={projectInfor.buy === 0 ? projectInfor.content : projectInfor.commodityContent} />
         </View>
         <View className='shop'>
           <View className='singlePurchase' onClick={()=>{

+ 5 - 0
src/utils/servers/servers.js

@@ -78,6 +78,11 @@ export const setDecryptData = (postData) => {
   return HTTPREQUEST.post('/api/user/decryptData', postData)
 }
 
+//获取分享详情
+export const getWeChatShareDetails = (postData) => {
+  return HTTPREQUEST.get('/open/weChatDetails', postData)
+}
+
 //测试
 export const test = (postData) => {
   return HTTPREQUEST.get('/open/test', postData)