From f26f29d84e0a68831a6af14dab3eec5500496d2e Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 28 五月 2025 16:48:52 +0800
Subject: [PATCH] 初始化项目

---
 uview-ui/components/u-picker/u-picker.vue |  676 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 676 insertions(+), 0 deletions(-)

diff --git a/uview-ui/components/u-picker/u-picker.vue b/uview-ui/components/u-picker/u-picker.vue
new file mode 100644
index 0000000..f0032ab
--- /dev/null
+++ b/uview-ui/components/u-picker/u-picker.vue
@@ -0,0 +1,676 @@
+<template>
+	<u-popup :maskCloseAble="maskCloseAble" mode="bottom" :popup="false" v-model="value" length="auto" :safeAreaInsetBottom="safeAreaInsetBottom" @close="close" :z-index="uZIndex">
+		<view class="u-datetime-picker">
+			<view class="u-picker-header" @touchmove.stop.prevent="">
+				<view class="u-btn-picker u-btn-picker--tips" 
+					:style="{ color: cancelColor }" 
+					hover-class="u-opacity" 
+					:hover-stay-time="150" 
+					@tap="getResult('cancel')"
+				>{{cancelText}}</view>
+				<view class="u-picker__title">{{ title }}</view>
+				<view
+					class="u-btn-picker u-btn-picker--primary"
+					:style="{ color: moving ? cancelColor : confirmColor }"
+					hover-class="u-opacity"
+					:hover-stay-time="150"
+					@touchmove.stop=""
+					@tap.stop="getResult('confirm')"
+				>
+					{{confirmText}}
+				</view>
+			</view>
+			<view class="u-picker-body">
+				<picker-view v-if="mode == 'region'" :value="valueArr" @change="change" class="u-picker-view" @pickstart="pickstart" @pickend="pickend">
+					<picker-view-column v-if="!reset && params.province">
+						<view class="u-column-item" v-for="(item, index) in provinces" :key="index">
+							<view class="u-line-1">{{ item.label }}</view>
+						</view>
+					</picker-view-column>
+					<picker-view-column v-if="!reset && params.city">
+						<view class="u-column-item" v-for="(item, index) in citys" :key="index">
+							<view class="u-line-1">{{ item.label }}</view>
+						</view>
+					</picker-view-column>
+					<picker-view-column v-if="!reset && params.area">
+						<view class="u-column-item" v-for="(item, index) in areas" :key="index">
+							<view class="u-line-1">{{ item.label }}</view>
+						</view>
+					</picker-view-column>
+				</picker-view>
+				<picker-view v-else-if="mode == 'time'" :value="valueArr" @change="change" class="u-picker-view" @pickstart="pickstart" @pickend="pickend">
+					<picker-view-column v-if="!reset && params.year">
+						<view class="u-column-item" v-for="(item, index) in years" :key="index">
+							{{ item }}
+							<text class="u-text" v-if="showTimeTag">骞�</text>
+						</view>
+					</picker-view-column>
+					<picker-view-column v-if="!reset && params.month">
+						<view class="u-column-item" v-for="(item, index) in months" :key="index">
+							{{ formatNumber(item) }}
+							<text class="u-text" v-if="showTimeTag">鏈�</text>
+						</view>
+					</picker-view-column>
+					<picker-view-column v-if="!reset && params.day">
+						<view class="u-column-item" v-for="(item, index) in days" :key="index">
+							{{ formatNumber(item) }}
+							<text class="u-text" v-if="showTimeTag">鏃�</text>
+						</view>
+					</picker-view-column>
+					<picker-view-column v-if="!reset && params.hour">
+						<view class="u-column-item" v-for="(item, index) in hours" :key="index">
+							{{ formatNumber(item) }}
+							<text class="u-text" v-if="showTimeTag">鏃�</text>
+						</view>
+					</picker-view-column>
+					<picker-view-column v-if="!reset && params.minute">
+						<view class="u-column-item" v-for="(item, index) in minutes" :key="index">
+							{{ formatNumber(item) }}
+							<text class="u-text" v-if="showTimeTag">鍒�</text>
+						</view>
+					</picker-view-column>
+					<picker-view-column v-if="!reset && params.second">
+						<view class="u-column-item" v-for="(item, index) in seconds" :key="index">
+							{{ formatNumber(item) }}
+							<text class="u-text" v-if="showTimeTag">绉�</text>
+						</view>
+					</picker-view-column>
+				</picker-view>
+				<picker-view v-else-if="mode == 'selector'" :value="valueArr" @change="change" class="u-picker-view" @pickstart="pickstart" @pickend="pickend">
+					<picker-view-column v-if="!reset">
+						<view class="u-column-item" v-for="(item, index) in range" :key="index">
+							<view class="u-line-1">{{ getItemValue(item, 'selector') }}</view>
+						</view>
+					</picker-view-column>
+				</picker-view>
+				<picker-view v-else-if="mode == 'multiSelector'" :value="valueArr" @change="change" class="u-picker-view" @pickstart="pickstart" @pickend="pickend">
+					<picker-view-column v-if="!reset" v-for="(item, index) in range" :key="index">
+						<view class="u-column-item" v-for="(item1, index1) in item" :key="index1">
+							<view class="u-line-1">{{ getItemValue(item1, 'multiSelector') }}</view>
+						</view>
+					</picker-view-column>
+				</picker-view>
+			</view>
+		</view>
+	</u-popup>
+</template>
+
+<script>
+import provinces from '../../libs/util/province.js';
+import citys from '../../libs/util/city.js';
+import areas from '../../libs/util/area.js';
+
+/**
+ * picker picker寮瑰嚭閫夋嫨鍣�
+ * @description 姝ら�夋嫨鍣ㄦ湁涓ょ寮瑰嚭妯″紡锛氫竴鏄椂闂存ā寮忥紝鍙互閰嶇疆骞达紝鏃ワ紝鏈堬紝鏃讹紝鍒嗭紝绉掑弬鏁� 浜屾槸鍦板尯妯″紡锛屽彲浠ラ厤缃渷锛屽競锛屽尯鍙傛暟
+ * @tutorial https://www.uviewui.com/components/picker.html
+ * @property {Object} params 闇�瑕佹樉绀虹殑鍙傛暟锛岃瀹樼綉璇存槑
+ * @property {String} mode 妯″紡閫夋嫨锛宺egion-鍦板尯绫诲瀷锛宼ime-鏃堕棿绫诲瀷锛堥粯璁ime锛�
+ * @property {String Number} start-year 鍙�夌殑寮�濮嬪勾浠斤紝mode=time鏃舵湁鏁堬紙榛樿1950锛�
+ * @property {String Number} end-year 鍙�夌殑缁撴潫骞翠唤锛宮ode=time鏃舵湁鏁堬紙榛樿2050锛�
+ * @property {Boolean} safe-area-inset-bottom 鏄惁寮�鍚簳閮ㄥ畨鍏ㄥ尯閫傞厤锛堥粯璁alse锛�
+ * @property {Boolean} show-time-tag 鏃堕棿妯″紡鏃讹紝鏄惁鏄剧ず鍚庨潰鐨勫勾鏈堟棩涓枃鎻愮ず
+ * @property {String} cancel-color 鍙栨秷鎸夐挳鐨勯鑹诧紙榛樿#606266锛�
+ * @property {String} confirm-color 纭鎸夐挳鐨勯鑹诧紙榛樿#497bff锛�
+ * @property {String} default-time 榛樿閫変腑鐨勬椂闂达紝mode=time鏃舵湁鏁�
+ * @property {String} confirm-text 纭鎸夐挳鐨勬枃瀛�
+ * @property {String} cancel-text 鍙栨秷鎸夐挳鐨勬枃瀛�
+ * @property {String} default-region 榛樿閫変腑鐨勫湴鍖猴紝涓枃褰㈠紡锛宮ode=region鏃舵湁鏁�
+ * @property {String} default-code 榛樿閫変腑鐨勫湴鍖猴紝缂栧彿褰㈠紡锛宮ode=region鏃舵湁鏁�
+ * @property {Boolean} mask-close-able 鏄惁鍏佽閫氳繃鐐瑰嚮閬僵鍏抽棴Picker锛堥粯璁rue锛�
+ * @property {String Number} z-index 寮瑰嚭鏃剁殑z-index鍊硷紙榛樿1075锛�
+ * @property {Array} default-selector 鏁扮粍褰㈠紡锛屽叾涓瘡涓�椤硅〃绀洪�夋嫨浜唕ange瀵瑰簲椤逛腑鐨勭鍑犱釜
+ * @property {Array} range 鑷畾涔夐�夋嫨鐨勬暟鎹紝mode=selector鎴杕ode=multiSelector鏃舵湁鏁�
+ * @property {String} range-key 褰搑ange鍙傛暟鐨勫厓绱犱负瀵硅薄鏃讹紝鎸囧畾Object涓殑鍝釜key鐨勫�间綔涓洪�夋嫨鍣ㄦ樉绀哄唴瀹�
+ * @event {Function} confirm 鐐瑰嚮纭畾鎸夐挳锛岃繑鍥炲綋鍓嶉�夋嫨鐨勫��
+ * @event {Function} cancel 鐐瑰嚮鍙栨秷鎸夐挳锛岃繑鍥炲綋鍓嶉�夋嫨鐨勫��
+ * @example <u-picker v-model="show" mode="time"></u-picker>
+ */
+export default {
+	name: 'u-picker',
+	props: {
+		// picker涓渶瑕佹樉绀虹殑鍙傛暟
+		params: {
+			type: Object,
+			default() {
+				return {
+					year: true,
+					month: true,
+					day: true,
+					hour: false,
+					minute: false,
+					second: false,
+					province: true,
+					city: true,
+					area: true,
+					timestamp: true,
+				};
+			}
+		},
+		// 褰搈ode=selector鎴栬�卪ode=multiSelector鏃讹紝鎻愪緵鐨勬暟缁�
+		range: {
+			type: Array,
+			default() {
+				return [];
+			}
+		},
+		// 褰搈ode=selector鎴栬�卪ode=multiSelector鏃讹紝鎻愪緵鐨勯粯璁ら�変腑鐨勪笅鏍�
+		defaultSelector: {
+			type: Array,
+			default() {
+				return [0];
+			}
+		},
+		// 褰� range 鏄竴涓� Array锛淥bject锛� 鏃讹紝閫氳繃 range-key 鏉ユ寚瀹� Object 涓� key 鐨勫�间綔涓洪�夋嫨鍣ㄦ樉绀哄唴瀹�
+		rangeKey: {
+			type: String,
+			default: ''
+		},
+		// 妯″紡閫夋嫨锛宺egion-鍦板尯绫诲瀷锛宼ime-鏃堕棿绫诲瀷锛宻elector-鍗曞垪妯″紡锛宮ultiSelector-澶氬垪妯″紡
+		mode: {
+			type: String,
+			default: 'time'
+		},
+		// 骞翠唤寮�濮嬫椂闂�
+		startYear: {
+			type: [String, Number],
+			default: 1950
+		},
+		// 骞翠唤缁撴潫鏃堕棿
+		endYear: {
+			type: [String, Number],
+			default: 2050
+		},
+		// "鍙栨秷"鎸夐挳鐨勯鑹�
+		cancelColor: {
+			type: String,
+			default: '#606266'
+		},
+		// "纭畾"鎸夐挳鐨勯鑹�
+		confirmColor: {
+			type: String,
+			default: '#497bff'
+		},
+		// 榛樿鏄剧ず鐨勬椂闂达紝2025-07-02 || 2025-07-02 13:01:00 || 2025/07/02
+		defaultTime: {
+			type: String,
+			default: ''
+		},
+		// 榛樿鏄剧ず鐨勫湴鍖猴紝鍙紶绫讳技["娌冲寳鐪�", "绉︾殗宀涘競", "鍖楁埓娌冲尯"]
+		defaultRegion: {
+			type: Array,
+			default() {
+				return [];
+			}
+		},
+		// 鏃堕棿妯″紡鏃讹紝鏄惁鏄剧ず鍚庨潰鐨勫勾鏈堟棩涓枃鎻愮ず
+		showTimeTag: {
+			type: Boolean,
+			default: true
+		},
+		// 榛樿鏄剧ず鍦板尯鐨勭紪鐮侊紝defaultRegion鍜宎reaCode鍚屾椂瀛樺湪锛宎reaCode浼樺厛锛屽彲浼犵被浼糩"13", "1303", "130304"]
+		areaCode: {
+			type: Array,
+			default() {
+				return [];
+			}
+		},
+		safeAreaInsetBottom: {
+			type: Boolean,
+			default: false
+		},
+		// 鏄惁鍏佽閫氳繃鐐瑰嚮閬僵鍏抽棴Picker
+		maskCloseAble: {
+			type: Boolean,
+			default: true
+		},
+		// 閫氳繃鍙屽悜缁戝畾鎺у埗缁勪欢鐨勫脊鍑轰笌鏀惰捣
+		value: {
+			type: Boolean,
+			default: false
+		},
+		// 寮瑰嚭鐨剒-index鍊�
+		zIndex: {
+			type: [String, Number],
+			default: 0
+		},
+		// 椤堕儴鏍囬
+		title: {
+			type: String,
+			default: ''
+		},
+		// 鍙栨秷鎸夐挳鐨勬枃瀛�
+		cancelText: {
+			type: String,
+			default: '鍙栨秷'
+		},
+		// 纭鎸夐挳鐨勬枃瀛�
+		confirmText: {
+			type: String,
+			default: '纭'
+		}
+	},
+	data() {
+		return {
+			years: [],
+			months: [],
+			days: [],
+			hours: [],
+			minutes: [],
+			seconds: [],
+			year: 0,
+			month: 0,
+			day: 0,
+			hour: 0,
+			minute: 0,
+			second: 0,
+			reset: false,
+			startDate: '',
+			endDate: '',
+			valueArr: [],
+			provinces: provinces,
+			citys: citys[0],
+			areas: areas[0][0],
+			province: 0,
+			city: 0,
+			area: 0,
+			moving: false // 鍒楁槸鍚﹁繕鍦ㄦ粦鍔ㄤ腑锛屽井淇″皬绋嬪簭濡傛灉鍦ㄦ粦鍔ㄤ腑灏辩偣纭畾锛岀粨鏋滃彲鑳戒笉鍑嗙‘
+		};
+	},
+	mounted() {
+		this.init();
+	},
+	computed: {
+		propsChange() {
+			// 寮曠敤杩欏嚑涓彉閲忥紝鏄负浜嗙洃鍚叾鍙樺寲
+			return `${this.mode}-${this.defaultTime}-${this.startYear}-${this.endYear}-${this.defaultRegion}-${this.areaCode}`;
+		},
+		regionChange() {
+			// 寮曠敤杩欏嚑涓彉閲忥紝鏄负浜嗙洃鍚叾鍙樺寲
+			return `${this.province}-${this.city}`;
+		},
+		yearAndMonth() {
+			return `${this.year}-${this.month}`;
+		},
+		uZIndex() {
+			// 濡傛灉鐢ㄦ埛鏈変紶閫抸-index鍊硷紝浼樺厛浣跨敤
+			return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
+		}
+	},
+	watch: {
+		propsChange() {
+			this.reset = true;
+			setTimeout(() => this.init(), 10);
+		},
+		// 濡傛灉鍦板尯鍙戠敓鍙樺寲锛屼负浜嗚picker鑱斿姩璧锋潵锛屽繀椤婚噸缃畉his.citys鍜宼his.areas
+		regionChange(val) {
+			this.citys = citys[this.province];
+			this.areas = areas[this.province][this.city];
+		},
+		// watch鐩戝惉鏈堜唤鐨勫彉鍖栵紝瀹炴椂鍙樻洿鏃ョ殑澶╂暟锛屽洜涓轰笉鍚屾湀浠斤紝澶╂暟涓嶄竴鏍�
+		// 涓�涓湀鍙兘鏈�30锛�31澶╋紝鐢氳嚦闂板勾2鏈堢殑29澶╋紝骞冲勾2鏈�28澶�
+		yearAndMonth(val) {
+			if (this.params.year) this.setDays();
+		},
+		// 寰俊鍜孮Q灏忕▼搴忕敱浜庝竴浜涘鎬殑鍘熷洜(鏁呭悓鏃跺鎵�鏈夊钩鍙板潎鍒濆鍖栦竴閬�)锛岄渶瑕侀噸鏂板垵濮嬪寲鎵嶈兘鏄剧ず姝g‘鐨勫��
+		value(n) {
+			if (n) {
+				this.reset = true;
+				setTimeout(() => this.init(), 10);
+			}
+		}
+	},
+	methods: {
+		// 鏍囪瘑婊戝姩寮�濮嬶紝鍙湁寰俊灏忕▼搴忔墠鏈夎繖鏍风殑浜嬩欢
+		pickstart() {
+			// #ifdef MP-WEIXIN
+			this.moving = true;
+			// #endif
+		},
+		// 鏍囪瘑婊戝姩缁撴潫
+		pickend() {
+			// #ifdef MP-WEIXIN
+			this.moving = false;
+			// #endif
+		},
+		// 瀵瑰崟鍒楀拰澶氬垪褰㈠紡鐨勫垽鏂槸鍚︽湁浼犲叆鍙橀噺鐨勬儏鍐�
+		getItemValue(item, mode) {
+			// 鐩墠(2020-05-25)uni-app瀵瑰井淇″皬绋嬪簭缂栬瘧鏈夐敊璇紝瀵艰嚧v-if涓篺alse涓殑鍐呭涔熸墽琛岋紝閿欒瀵艰嚧
+			// 鍗曞垪妯″紡鎴栬�呭鍒楁ā寮忎腑鐨刧etItemValue鍚屾椂琚墽琛岋紝鏁呭湪杩欓噷鍐嶅姞涓�灞傚垽鏂�
+			if (this.mode == mode) {
+				return typeof item == 'object' ? item[this.rangeKey] : item;
+			}
+		},
+		// 灏忎簬10鍓嶉潰琛�0锛岀敤浜庢湀浠斤紝鏃ユ湡锛屾椂鍒嗙绛�
+		formatNumber(num) {
+			return +num < 10 ? '0' + num : String(num);
+		},
+		// 鐢熸垚閫掕繘鐨勬暟缁�
+		generateArray: function(start, end) {
+			// 杞负鏁板�兼牸寮忥紝鍚﹀垯鐢ㄦ埛缁檈nd-year绛変紶閫掑瓧绗︿覆鍊兼椂锛屼笅闈㈢殑end+1浼氬鑷村瓧绗︿覆鎷兼帴锛岃�屼笉鏄浉鍔�
+			start = Number(start);
+			end = Number(end);
+			end = end > start ? end : start;
+			// 鐢熸垚鏁扮粍锛岃幏鍙栧叾涓殑绱㈠紩锛屽苟鍓嚭鏉�
+			return [...Array(end + 1).keys()].slice(start);
+		},
+		getIndex: function(arr, val) {
+			let index = arr.indexOf(val);
+			// 濡傛灉index涓�-1(鍗虫壘涓嶅埌index鍊�)锛寏(-1)=-(-1)-1=0锛屽鑷存潯浠朵笉鎴愮珛
+			return ~index ? index : 0;
+		},
+		//鏃ユ湡鏃堕棿澶勭悊
+		initTimeValue() {
+			// 鏍煎紡鍖栨椂闂达紝鍦↖E娴忚鍣�(uni涓嶅瓨鍦ㄦ鎯呭喌)锛屾棤娉曡瘑鍒棩鏈熼棿鐨�"-"闂撮殧绗﹀彿
+			let fdate = this.defaultTime.replace(/\-/g, '/');
+			fdate = fdate && fdate.indexOf('/') == -1 ? `2020/01/01 ${fdate}` : fdate;
+			let time = null;
+			if (fdate) time = new Date(fdate);
+			else time = new Date();
+			// 鑾峰彇骞存棩鏈堟椂鍒嗙
+			this.year = time.getFullYear();
+			this.month = Number(time.getMonth()) + 1;
+			this.day = time.getDate();
+			this.hour = time.getHours();
+			this.minute = time.getMinutes();
+			this.second = time.getSeconds();
+		},
+		init() {
+			this.valueArr = [];
+			this.reset = false;
+			if (this.mode == 'time') {
+				this.initTimeValue();
+				if (this.params.year) {
+					this.valueArr.push(0);
+					this.setYears();
+				}
+				if (this.params.month) {
+					this.valueArr.push(0);
+					this.setMonths();
+				}
+				if (this.params.day) {
+					this.valueArr.push(0);
+					this.setDays();
+				}
+				if (this.params.hour) {
+					this.valueArr.push(0);
+					this.setHours();
+				}
+				if (this.params.minute) {
+					this.valueArr.push(0);
+					this.setMinutes();
+				}
+				if (this.params.second) {
+					this.valueArr.push(0);
+					this.setSeconds();
+				}
+			} else if (this.mode == 'region') {
+				if (this.params.province) {
+					this.valueArr.push(0);
+					this.setProvinces();
+				}
+				if (this.params.city) {
+					this.valueArr.push(0);
+					this.setCitys();
+				}
+				if (this.params.area) {
+					this.valueArr.push(0);
+					this.setAreas();
+				}
+			} else if (this.mode == 'selector') {
+				this.valueArr = this.defaultSelector;
+			} else if (this.mode == 'multiSelector') {
+				this.valueArr = this.defaultSelector;
+				this.multiSelectorValue = this.defaultSelector;
+			}
+			this.$forceUpdate();
+		},
+		// 璁剧疆picker鐨勬煇涓�鍒楀��
+		setYears() {
+			// 鑾峰彇骞翠唤闆嗗悎
+			this.years = this.generateArray(this.startYear, this.endYear);
+			// 璁剧疆this.valueArr鏌愪竴椤圭殑鍊硷紝鏄负浜嗚picker棰勯�変腑鏌愪竴涓��
+			this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.years, this.year));
+		},
+		setMonths() {
+			this.months = this.generateArray(1, 12);
+			this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.months, this.month));
+		},
+		setDays() {
+			let totalDays = new Date(this.year, this.month, 0).getDate();
+			this.days = this.generateArray(1, totalDays);
+			let index = 0;
+			// 杩欓噷涓嶈兘浣跨敤绫讳技setMonths()涓殑this.valueArr.splice(this.valueArr.length - 1, xxx)鍋氭硶
+			// 鍥犱负this.month鍜宼his.year鍙樺寲鏃讹紝浼氳Е鍙憌atch涓殑this.setDays()锛屽鑷磘his.valueArr.length璁$畻鏈夎
+			if (this.params.year && this.params.month) index = 2;
+			else if (this.params.month) index = 1;
+			else if (this.params.year) index = 1;
+			else index = 0;
+			// 褰撴湀浠藉彉鍖栨椂锛屼細瀵艰嚧鏃ユ湡鐨勫ぉ鏁颁篃浼氬彉鍖栵紝濡傛灉鍘熸潵閫夌殑澶╂暟澶т簬鍙樺寲鍚庣殑澶╂暟锛屽垯閲嶇疆涓哄彉鍖栧悗鐨勬渶澶у��
+			// 姣斿鍘熸潵閫変腑3鏈�31鏃ワ紝璋冩暣涓�2鏈堝悗锛屾棩鏈熷彉涓烘渶澶�29锛岃繖鏃跺鏋渄ay鍊肩户缁负31鏄剧劧涓嶅悎鐞嗭紝浜庢槸灏嗗叾缃负29(picker-column浠�1寮�濮�)
+			if(this.day > this.days.length) this.day = this.days.length;
+			this.valueArr.splice(index, 1, this.getIndex(this.days, this.day));
+		},
+		setHours() {
+			this.hours = this.generateArray(0, 23);
+			this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.hours, this.hour));
+		},
+		setMinutes() {
+			this.minutes = this.generateArray(0, 59);
+			this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.minutes, this.minute));
+		},
+		setSeconds() {
+			this.seconds = this.generateArray(0, 59);
+			this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.seconds, this.second));
+		},
+		setProvinces() {
+			// 鍒ゆ柇鏄惁闇�瑕乸rovince鍙傛暟
+			if (!this.params.province) return;
+			let tmp = '';
+			let useCode = false;
+			// 濡傛灉鍚屾椂閰嶇疆浜哾efaultRegion鍜宎reaCode锛屼紭鍏堜娇鐢╝reaCode鍙傛暟
+			if (this.areaCode.length) {
+				tmp = this.areaCode[0];
+				useCode = true;
+			} else if (this.defaultRegion.length) tmp = this.defaultRegion[0];
+			else tmp = 0;
+			// 鍘嗛亶鐪佷唤鏁扮粍鍖归厤
+			provinces.map((v, k) => {
+				if (useCode ? v.value == tmp : v.label == tmp) {
+					tmp = k;
+				}
+			});
+			this.province = tmp;
+			this.provinces = provinces;
+			// 璁剧疆榛樿鐪佷唤鐨勫��
+			this.valueArr.splice(0, 1, this.province);
+		},
+		setCitys() {
+			if (!this.params.city) return;
+			let tmp = '';
+			let useCode = false;
+			if (this.areaCode.length) {
+				tmp = this.areaCode[1];
+				useCode = true;
+			} else if (this.defaultRegion.length) tmp = this.defaultRegion[1];
+			else tmp = 0;
+			citys[this.province].map((v, k) => {
+				if (useCode ? v.value == tmp : v.label == tmp) {
+					tmp = k;
+				}
+			});
+			this.city = tmp;
+			this.citys = citys[this.province];
+			this.valueArr.splice(1, 1, this.city);
+		},
+		setAreas() {
+			if (!this.params.area) return;
+			let tmp = '';
+			let useCode = false;
+			if (this.areaCode.length) {
+				tmp = this.areaCode[2];
+				useCode = true;
+			} else if (this.defaultRegion.length) tmp = this.defaultRegion[2];
+			else tmp = 0;
+			areas[this.province][this.city].map((v, k) => {
+				if (useCode ? v.value == tmp : v.label == tmp) {
+					tmp = k;
+				}
+			});
+			this.area = tmp;
+			this.areas = areas[this.province][this.city];
+			this.valueArr.splice(2, 1, this.area);
+		},
+		close() {
+			this.$emit('input', false);
+		},
+		// 鐢ㄦ埛鏇存敼picker鐨勫垪閫夐」
+		change(e) {
+			this.valueArr = e.detail.value;
+			let i = 0;
+			if (this.mode == 'time') {
+				// 杩欓噷浣跨敤i++锛屾槸鍥犱负this.valueArr鏁扮粍鐨勯暱搴︽槸涓嶇‘瀹氶暱搴︾殑锛屽畠鏍规嵁this.params鐨勫�兼潵閰嶇疆闀垮害
+				// 杩涘叆if瑙勫垯锛宨浼氬姞1锛屼繚璇佷簡鑳借幏鍙栧噯纭殑鍊�
+				if (this.params.year) this.year = this.years[this.valueArr[i++]];
+				if (this.params.month) this.month = this.months[this.valueArr[i++]];
+				if (this.params.day) this.day = this.days[this.valueArr[i++]];
+				if (this.params.hour) this.hour = this.hours[this.valueArr[i++]];
+				if (this.params.minute) this.minute = this.minutes[this.valueArr[i++]];
+				if (this.params.second) this.second = this.seconds[this.valueArr[i++]];
+			} else if (this.mode == 'region') {
+				if (this.params.province) this.province = this.valueArr[i++];
+				if (this.params.city) this.city = this.valueArr[i++];
+				if (this.params.area) this.area = this.valueArr[i++];
+			} else if (this.mode == 'multiSelector') {
+				let index = null;
+				// 瀵规瘮鍓嶅悗涓や釜鏁扮粍锛屽鎵惧彉鏇寸殑鏄摢涓�鍒楋紝濡傛灉鏌愪竴涓厓绱犱笉鍚岋紝鍗冲彲鍒ゅ畾璇ュ垪鍙戠敓浜嗗彉鍖�
+				this.defaultSelector.map((val, idx) => {
+					if (val != e.detail.value[idx]) index = idx;
+				});
+				// 涓轰簡璁╃敤鎴峰澶氬垪鍙樺寲鏃讹紝瀵瑰姩鎬佽缃叾浠栧垪鐨勫彉鏇�
+				if (index != null) {
+					this.$emit('columnchange', {
+						column: index,
+						index: e.detail.value[index]
+					});
+				}
+			}
+		},
+		// 鐢ㄦ埛鐐瑰嚮纭畾鎸夐挳
+		getResult(event = null) {
+			// #ifdef MP-WEIXIN
+			if (this.moving) return;
+			// #endif
+			let result = {};
+			// 鍙繑鍥炵敤鎴峰湪this.params涓厤缃簡涓簍rue鐨勫瓧娈�
+			if (this.mode == 'time') {
+				if (this.params.year) result.year = this.formatNumber(this.year || 0);
+				if (this.params.month) result.month = this.formatNumber(this.month || 0);
+				if (this.params.day) result.day = this.formatNumber(this.day || 0);
+				if (this.params.hour) result.hour = this.formatNumber(this.hour || 0);
+				if (this.params.minute) result.minute = this.formatNumber(this.minute || 0);
+				if (this.params.second) result.second = this.formatNumber(this.second || 0);
+				if (this.params.timestamp) result.timestamp = this.getTimestamp();
+			} else if (this.mode == 'region') {
+				if (this.params.province) result.province = provinces[this.province];
+				if (this.params.city) result.city = citys[this.province][this.city];
+				if (this.params.area) result.area = areas[this.province][this.city][this.area];
+			} else if (this.mode == 'selector') {
+				result = this.valueArr;
+			} else if (this.mode == 'multiSelector') {
+				result = this.valueArr;
+			}
+			if (event) this.$emit(event, result);
+			this.close();
+		},
+		// 鑾峰彇鏃堕棿鎴�
+		getTimestamp() {
+			// yyyy-mm-dd涓哄畨鍗撳啓娉曪紝涓嶆敮鎸乮OS锛岄渶瑕佷娇鐢�"/"鍒嗛殧锛屾墠鑳戒簩鑰呭吋瀹�
+			let time = this.year + '/' + this.month + '/' + this.day + ' ' + this.hour + ':' + this.minute + ':' + this.second;
+			return new Date(time).getTime() / 1000;
+		}
+	}
+};
+</script>
+
+<style lang="scss" scoped>
+@import '../../libs/css/style.components.scss';
+
+.u-datetime-picker {
+	position: relative;
+	z-index: 999;
+}
+
+.u-picker-view {
+	height: 100%;
+	box-sizing: border-box;
+}
+
+.u-picker-header {
+	width: 100%;
+	height: 90rpx;
+	padding: 0 40rpx;
+	@include vue-flex;
+	justify-content: space-between;
+	align-items: center;
+	box-sizing: border-box;
+	font-size: 30rpx;
+	background: #fff;
+	position: relative;
+}
+
+.u-picker-header::after {
+	content: '';
+	position: absolute;
+	border-bottom: 1rpx solid #eaeef1;
+	-webkit-transform: scaleY(0.5);
+	transform: scaleY(0.5);
+	bottom: 0;
+	right: 0;
+	left: 0;
+}
+
+.u-picker__title {
+	color: $u-content-color;
+}
+
+.u-picker-body {
+	width: 100%;
+	height: 500rpx;
+	overflow: hidden;
+	background-color: #fff;
+}
+
+.u-column-item {
+	@include vue-flex;
+	align-items: center;
+	justify-content: center;
+	font-size: 32rpx;
+	color: $u-main-color;
+	padding: 0 8rpx;
+}
+
+.u-text {
+	font-size: 24rpx;
+	padding-left: 8rpx;
+}
+
+.u-btn-picker {
+	padding: 16rpx;
+	box-sizing: border-box;
+	text-align: center;
+	text-decoration: none;
+}
+
+.u-opacity {
+	opacity: 0.5;
+}
+
+.u-btn-picker--primary {
+	color: $u-type-primary;
+}
+
+.u-btn-picker--tips {
+	color: $u-tips-color;
+}
+</style>

--
Gitblit v1.9.3