From 27d01f3731d0737d8ffb61fd4c15829d10a6a7dd Mon Sep 17 00:00:00 2001 From: wk Date: 星期四, 06 六月 2024 15:20:59 +0800 Subject: [PATCH] feta:注册时间 --- pages/login/userPassword.vue | 6 + pages/login/user.vue | 211 +++++++++++++++++++++++++++++++++++ pages/driver-page/drvier-my/drvier-my.vue | 95 +++++++++++---- pages/register/register.vue | 25 +++ utils/status.js | 2 5 files changed, 306 insertions(+), 33 deletions(-) diff --git a/pages/driver-page/drvier-my/drvier-my.vue b/pages/driver-page/drvier-my/drvier-my.vue index 8705be9..34f1faf 100644 --- a/pages/driver-page/drvier-my/drvier-my.vue +++ b/pages/driver-page/drvier-my/drvier-my.vue @@ -478,7 +478,7 @@ label="韬唤璇佽繃鏈熸椂闂�" labelWidth="20%" borderBottom> - <uni-datetime-picker v-model="registerFormModel.expirationTimeIdcard" type="datetime" /> + <uni-datetime-picker v-model="registerFormModel.expirationTimeIdcard" type="datetime" :start="minDate" /> </u-form-item> <u-form-item prop="drivingImg" label="琛岄┒璇�" @@ -502,7 +502,7 @@ label="琛岄┒璇佽繃鏈熸椂闂�" labelWidth="20%" borderBottom> - <uni-datetime-picker v-model="registerFormModel.expirationTimeDriving" type="datetime" /> + <uni-datetime-picker v-model="registerFormModel.expirationTimeDriving" type="datetime" :start="minDate" /> </u-form-item> <u-form-item prop="driverImg" label="椹鹃┒璇�" @@ -526,7 +526,7 @@ label="椹鹃┒璇佽繃鏈熸椂闂�" labelWidth="20%" borderBottom> - <uni-datetime-picker v-model="registerFormModel.expirationTimeDriver" type="datetime" /> + <uni-datetime-picker v-model="registerFormModel.expirationTimeDriver" type="datetime" :start="minDate" /> </u-form-item> <u-form-item prop="tradeQualificationImg" label="浠庝笟璧勬牸璇�" @@ -552,7 +552,7 @@ labelWidth="20%" borderBottom v-if="registerFormModel.type == 3||registerFormModel.type == 4"> - <uni-datetime-picker v-model="registerFormModel.expirationTimeTradequalification" type="datetime" /> + <uni-datetime-picker v-model="registerFormModel.expirationTimeTradequalification" type="datetime" :start="minDate" /> </u-form-item> </u--form> <view class="person-utils"> @@ -646,7 +646,7 @@ label="杩愯緭璇佽繃鏈熸椂闂�" labelWidth="20%" borderBottom> - <uni-datetime-picker v-model="tranSportForm.expirationTime" type="datetime" /> + <uni-datetime-picker v-model="tranSportForm.expirationTime" type="datetime" :start="minDate" /> </u-form-item> <view class="adddelete"> <u-button text="娣诲姞椹鹃┒鍛�" @@ -782,6 +782,7 @@ components: { previewImage, noobTour, printerStyle,qianTree }, data() { return { + minDate: this.getToday(), selfDeliverShow: false, customerNameList:[], customerName:"", @@ -1016,6 +1017,20 @@ }, methods: { ...mapMutations(['changeisUploadimg']), + getToday() { + let now = new Date(); + let year = now.getFullYear(); + let month = this.padStart(now.getMonth() + 1); // 鏈堜唤鏄粠0寮�濮嬬殑 + let day = this.padStart(now.getDate()); + let hour = this.padStart(now.getHours()); + let minute = this.padStart(now.getMinutes()); + let second = this.padStart(now.getSeconds()); + console.log(`${year}-${month}-${day} ${hour}:${minute}:${second}`) + return `${year}-${month}-${day} ${hour}:${minute}:${second}`; + }, + padStart(value) { + return value.toString().padStart(2, '0'); + }, init() { this.$reqGet('getProductTree').then(res => { this.productData = res.data; @@ -1359,29 +1374,53 @@ }, // 淇敼璇佷欢淇℃伅 updateDoc(){ - this.$reqPost('saveDriverDocs', { - userId:this.registerFormModel.customerid, - idCardImg:this.registerFormModel.cardImg1+","+this.registerFormModel.cardImg2, - expirationTimeIdcard:this.registerFormModel.expirationTimeIdcard.slice(0,16), - drivingImg:this.registerFormModel.drivingImg, - expirationTimeDriving:this.registerFormModel.expirationTimeDriving.slice(0,16), - driverImg:this.registerFormModel.driverImg, - expirationTimeDriver:this.registerFormModel.expirationTimeDriver.slice(0,16), - tradeQualificationImg:this.registerFormModel.tradeQualificationImg, - expirationTimeTradequalification:this.registerFormModel.expirationTimeTradequalification, - }, 'json').then(res => { - this.editDocShow = false; - if (res.code == 0) { - this.$u.toast('淇敼鎴愬姛'); - this.init(); - } else { - uni.showToast({ - title: res.msg, - icon: 'none', - duration: 2000 - }); - } - }) + if(this.registerFormModel.type == 3||this.registerFormModel.type == 4){ + this.$reqPost('saveDriverDocs', { + userId:this.registerFormModel.customerid, + idCardImg:this.registerFormModel.cardImg1+","+this.registerFormModel.cardImg2, + expirationTimeIdcard:this.registerFormModel.expirationTimeIdcard.slice(0,16), + drivingImg:this.registerFormModel.drivingImg, + expirationTimeDriving:this.registerFormModel.expirationTimeDriving.slice(0,16), + driverImg:this.registerFormModel.driverImg, + expirationTimeDriver:this.registerFormModel.expirationTimeDriver.slice(0,16), + tradeQualificationImg:this.registerFormModel.tradeQualificationImg, + expirationTimeTradequalification:this.registerFormModel.expirationTimeTradequalification.slice(0,16), + }, 'json').then(res => { + this.editDocShow = false; + if (res.code == 0) { + this.$u.toast('淇敼鎴愬姛'); + this.init(); + } else { + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }); + } + }) + }else{ + this.$reqPost('saveDriverDocs', { + userId:this.registerFormModel.customerid, + idCardImg:this.registerFormModel.cardImg1+","+this.registerFormModel.cardImg2, + expirationTimeIdcard:this.registerFormModel.expirationTimeIdcard.slice(0,16), + drivingImg:this.registerFormModel.drivingImg, + expirationTimeDriving:this.registerFormModel.expirationTimeDriving.slice(0,16), + driverImg:this.registerFormModel.driverImg, + expirationTimeDriver:this.registerFormModel.expirationTimeDriver.slice(0,16), + }, 'json').then(res => { + this.editDocShow = false; + if (res.code == 0) { + this.$u.toast('淇敼鎴愬姛'); + this.init(); + } else { + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }); + } + }) + } }, // 淇敼鐢ㄦ埛淇℃伅 updateUser() { diff --git a/pages/login/user.vue b/pages/login/user.vue new file mode 100644 index 0000000..08d574e --- /dev/null +++ b/pages/login/user.vue @@ -0,0 +1,211 @@ +<template> + <div class="drop-down-search" @click.stop> + <view style="display: flex; align-items: center;"> +<!-- <u--input v-model="username" + clearable + maxlength="32" + type="text" + placeholder="璇疯緭鍏ユ墜鏈哄彿" + prefixIcon="account" + prefixIconStyle="font-size: 22px;color: #909399"></u--input> --> + <input + @focus="handleFocus" + @blur="closeDropDown" + :style="{height: '100%', paddingRight: clear? '60rpx' : '16rpx', display: 'flex'}" + type="text" + v-model="searchText" + @input="handleSearch" + :placeholder="placeholder"/> + + <text v-if="searchText.length && clear" @click="handleClearInput" class="iconfont icon-shanchu"></text> + <view + @click="handleDropDownBox" + v-if="icon" + :class="['dropdown-container', { rotated: isDropDownVisible}]" + ></view> <!-- 娣诲姞灏忎笁瑙掑浘鏍� --> + </view> + + <scroll-view + :scroll-y="true" + class="dropdown-scroll" + :style="{ maxHeight: (isDropDownVisible && hasOptions) ? dropdownHeight + 'rpx' : '0rpx' }"> + <div class="dropdown-content"> + <div v-for="(option, index) in filteredOptions" :key="index" class="option" @click="selectOption(option, $event)"> + {{ option.username }} + </div> + </div> + </scroll-view> + + </div> + </template> + + <script> + export default { + props: { + options: { + type: Array, + default: [] + }, + value: { + type: [String, Number], + default: '' + }, + dropdownHeight: { // 涓嬫媺妗嗙殑楂樺害 + type: Number, + default: 200 + }, + placeholder: { + type: String, + default: '' + }, + icon: { + type: Boolean, + default: true + }, + clear: { + type: Boolean, + default: true, + } + }, + data() { + return { + searchText: this.value.toString(), // 榛樿灏嗘暟瀛楄浆瀛楃涓� + isDropDownVisible: false, + hasOptions: false, + }; + }, + computed: { + // 鏍规嵁鎼滅储鏂囨湰杩囨护閫夐」 + filteredOptions() { + return this.options.filter(option =>{ + if(this.searchText.username){ + return option.username.toLowerCase().includes(this.searchText.username.toLowerCase()) + }else{ + return option.username.toLowerCase().includes(this.searchText.toLowerCase()) + } + } + ); + } + }, + watch: { // 鐩戝惉 options 鏁扮粍锛岃鏄緭鍏ョ殑涓滆タ娌℃湁锛屽氨鍏抽棴涓嬫媺妗� + searchText() { + this.hasOptions = (this.filteredOptions.length > 0) + }, + }, + mounted() { + // 娣诲姞鐐瑰嚮澶栭儴鍏抽棴涓嬫媺妗嗙殑浜嬩欢鐩戝惉鍣� + // document.addEventListener('click', this.closeDropDown.bind(this)); + }, + methods: { + handleClearInput() { // 娓呴櫎 input 杈撳叆妗嗗唴瀹� + this.searchText = '' + this.$emit('input',''); // 鍚戠埗缁勪欢浼犻�掗�変腑鐨勫�� // 閲嶆柊鑾峰彇鏂扮殑鏁版嵁 + }, + handleDropDownBox() { // 鎺у埗涓夎鍥捐〃浜嬩欢 + this.isDropDownVisible = !this.isDropDownVisible + this.hasOptions = (this.filteredOptions.length > 0) + }, + // 澶勭悊鎼滅储浜嬩欢 + handleSearch(e) { + this.$emit('input', e.target.value); // 鍚戠埗缁勪欢浼犻�掗�変腑鐨勫�� + this.isDropDownVisible = this.hasOptions; + }, + handleFocus() { + this.isDropDownVisible = true; + this.hasOptions = true; + }, + // 閫夋嫨閫夐」 + selectOption(option, event) { + event.stopPropagation(); + // 澶勭悊閫夐」閫夋嫨閫昏緫锛屾瘮濡傝Е鍙戜簨浠躲�佹洿鏂扮粦瀹氬�肩瓑 + this.searchText = option.username; // 閫変腑閫夐」鍚庢洿鏂版悳绱㈡枃鏈� + this.isDropDownVisible = false; // 闅愯棌涓嬫媺妗� + this.hasOptions = false; + this.$emit('changeInput', option); // 鍚戠埗缁勪欢浼犻�掗�変腑鐨勫�� + }, + // // 鑾峰彇褰撳墠杈撳叆鐨勫�� + // getSearchText() { + // return this.searchText; + // }, + closeDropDown() { + // 鐐瑰嚮浜嬩欢鐨勭洰鏍囦笉鍖呭惈鎼滅储妗嗘垨涓嬫媺妗嗘椂锛岄殣钘忎笅鎷夋 + // this.isDropDownVisible = true; + // this.hasOptions = true; + if (!this.$el||!this.$el.contains(event.target)) { + this.isDropDownVisible = false; + } + } + } + }; + </script> + + <style scoped> + .drop-down-search { + position: relative; + height: 100% !important; + } + + .dropdown-scroll { + position: absolute; + top: calc(100% + 12rpx); + left: 0; + width: 100%; + background: #fff; + z-index: 99; + /* border: 1rpx solid #ccc; */ + box-shadow: 0 14rpx 30rpx rgb(0, 0, 0, 0.1); + transition: max-height 0.3s ease; + } + + .dropdown-content { + padding: 10rpx; + } + + .option { + padding: 10rpx; + cursor: pointer; + border-bottom: 1rpx solid #ccc; + } + + input { + width: 100%; + padding: 10rpx; + box-sizing: border-box; + } + + .iconfont { + position: absolute; + top: 50%; + right: 55rpx; + font-size: 50rpx; + transform: translateY(-50%); + font-size: 20rpx; + color: #999; + cursor: pointer; + } + .dropdown-container { + position: relative; + width: 30rpx; + height: 30rpx; + margin-right: 10rpx; + transform: rotate(180deg); + } + + .dropdown-container::before { + content: ''; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 0; + height: 0; + border-left: 15rpx solid transparent; + border-right: 15rpx solid transparent; + border-bottom: 15rpx solid #ccc; /* 浣跨敤border-bottom鍒涘缓鍚戜笅鐨勪笁瑙掑舰 */ + transition: transform 0.3s ease; /* 娣诲姞杩囨浮鏁堟灉 */ + } + + .rotated::before { + transform: translate(-50%, -50%) rotate(180deg); /* 鏃嬭浆涓夎褰� */ + } + </style> \ No newline at end of file diff --git a/pages/login/userPassword.vue b/pages/login/userPassword.vue index b3850b7..8608e2c 100644 --- a/pages/login/userPassword.vue +++ b/pages/login/userPassword.vue @@ -99,6 +99,12 @@ uni.setStorageSync("userId", res.data.userId) uni.setStorageSync("carNo", res.data.carNo) uni.setStorageSync("userInfo", res.data) + let data=uni.getStorageSync('userList')?JSON.parse(uni.getStorageSync('userList')):[]; + let id = data.length + 1; + if (data.filter(item=> item.username == this.username).length == 0){ + data.push({username: this.username,password: this.password,type:res.data.type}) + } + uni.setStorageSync("userList", JSON.stringify(data)) setCustomerId(res.data.customerid); setName(res.data.name); uni.hideLoading(); diff --git a/pages/register/register.vue b/pages/register/register.vue index f7cae80..f298b23 100644 --- a/pages/register/register.vue +++ b/pages/register/register.vue @@ -82,7 +82,7 @@ label="韬唤璇佽繃鏈熸椂闂�" labelWidth="20%" borderBottom> - <uni-datetime-picker v-model="registerFormModel.expirationTimeIdcard" type="datetime" /> + <uni-datetime-picker v-model="registerFormModel.expirationTimeIdcard" type="datetime" :start="minDate" /> </u-form-item> <u-form-item prop="phone" label="鎵嬫満鍙�" @@ -179,7 +179,7 @@ labelWidth="20%" borderBottom v-if="radiovalue1 == '鍙告満'"> - <uni-datetime-picker v-model="registerFormModel.expirationTimeDriving" type="datetime" /> + <uni-datetime-picker v-model="registerFormModel.expirationTimeDriving" type="datetime" :start="minDate" /> </u-form-item> <u-form-item prop="driverImg" label="椹鹃┒璇�" @@ -205,7 +205,7 @@ labelWidth="20%" borderBottom v-if="radiovalue1 == '鍙告満'"> - <uni-datetime-picker v-model="registerFormModel.expirationTimeDriver" type="datetime" /> + <uni-datetime-picker v-model="registerFormModel.expirationTimeDriver" type="datetime" :start="minDate" /> </u-form-item> <u-form-item prop="tradeQualificationImg" label="浠庝笟璧勬牸璇�" @@ -234,7 +234,7 @@ labelWidth="20%" borderBottom v-if="radiovalue1 == '鍙告満'"> - <uni-datetime-picker v-model="registerFormModel.expirationTimeTradequalification" type="datetime" /> + <uni-datetime-picker v-model="registerFormModel.expirationTimeTradequalification" type="datetime" :start="minDate" /> </u-form-item> <u-form-item label="鏄惁闈炵叅杞﹁締" v-if="radiovalue1 == '鍙告満'" @@ -302,6 +302,7 @@ }, data() { return { + minDate: this.getToday(), // 杞︾墝鍙烽敭鐩樻帶鍒� carNumShow: false, keyValue: '', @@ -529,6 +530,20 @@ }, methods: { ...mapMutations(['changeisUploadimg']), + getToday() { + let now = new Date(); + let year = now.getFullYear(); + let month = this.padStart(now.getMonth() + 1); // 鏈堜唤鏄粠0寮�濮嬬殑 + let day = this.padStart(now.getDate()); + let hour = this.padStart(now.getHours()); + let minute = this.padStart(now.getMinutes()); + let second = this.padStart(now.getSeconds()); + console.log(`${year}-${month}-${day} ${hour}:${minute}:${second}`) + return `${year}-${month}-${day} ${hour}:${minute}:${second}`; + }, + padStart(value) { + return value.toString().padStart(2, '0'); + }, productcarTypeChange(e){ console.log(this.registerFormModel.carType,this.radiolist2.find(v => v.value === e).value) this.registerFormModel.carType = this.radiolist2.find(v => v.value === e).value @@ -573,7 +588,7 @@ uni.redirectTo({ url: '/pages/login/login' }); }, 1000); } else { - this.$u.toast(res.data.msg ? res.data.msg : '娣诲姞澶辫触'); + this.$u.toast(res.msg ? res.msg : '娣诲姞澶辫触'); } }) .catch(err => { diff --git a/utils/status.js b/utils/status.js index 08ae5c6..e930f61 100644 --- a/utils/status.js +++ b/utils/status.js @@ -21,7 +21,9 @@ }) } export const redirectLogin = (path) => { + let data=uni.getStorageSync('userList')?JSON.parse(uni.getStorageSync('userList')):[]; uni.clearStorageSync(); + uni.setStorageSync("userList", JSON.stringify(data)) uni.reLaunch({ url: path || FailRedirect }) -- Gitblit v1.9.1