forget.vue 4.58 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<template>
	<view>
		<dHeader :title="$lang.lang.forget.forget"></dHeader>
		<view class="start-bar"></view>
		<view class="forget">
			<view class="item">
				<image class="icons" src="../../static/img/phone-2.png" mode=""></image>
				<view class="items-vw">
					<view class="area">
						<picker :value="areaIndex" :range="areaName" @change="areaChange">
							<view class="uni-input">{{$request.checkAddIcon(areaData[areaIndex])}}</view>
						</picker>
						<image src="../../static/img/down.png" mode=""></image>
					</view>
					<input type="number" v-model="FormData.mobile" :placeholder="$lang.lang.notices.phone">
				</view>
			</view>
			<view class="item">
				<image class="icons" src="../../static/img/code-2.png" mode=""></image>
				<view class="items-vw">
					<input type="number" v-model="FormData.code" :placeholder="$lang.lang.notices.code">
					<text class="code" v-if="leftTime < 60">{{leftTime}}S</text>
honghy's avatar
honghy committed
23 24 25
					<picker class="code" :range="smsName" @change="sendCode" v-else>
					  <view class="uni-input">{{ $lang.lang.forget.code }}</view>
					</picker>
lanbaoming's avatar
lanbaoming committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
				</view>
			</view>
			<view class="item">
				<image class="icons" src="../../static/img/pass-2.png" mode=""></image>
				<view class="items-vw">
					<input type="password" v-model="FormData.password" maxlength="32" :placeholder="$lang.lang.notices.numPsd">
				</view>
			</view>
			<view class="item">
				<image class="icons" src="../../static/img/safe-2.png" mode=""></image>
				<view class="items-vw">
					<input type="password" v-model="FormData.passworded" maxlength="32" :placeholder="$lang.lang.notices.nextPsd">
				</view>
			</view>
		</view>
		<view class="forBtn" @click="forgetForm">{{$lang.lang.order.edit}}</view>
		<view class="desc">
			<image src="../../static/img/helps.png" mode=""></image>
			<view class="">{{$lang.lang.notices.contact}}<text class="red">	400-900-9962</text></view>
		</view>
	</view>
</template>

<script>
	import dHeader from '../../components/dHeader/index.vue'
	export default {
		components: {
			dHeader
		},
		data() {
			return {
				areaIndex: 0,
				areaData: [],
				areaName: [],
				leftTime: 60,
				FormData: {
					mobile: '',
					code: '',
					password: '',
					passworded: '',
				},
				rules: {
					mobile: this.$lang.lang.notices.phone,
					code: this.$lang.lang.notices.code,
					password: this.$lang.lang.notices.newPsd,
					passworded: this.$lang.lang.notices.nextPsd,
honghy's avatar
honghy committed
72 73 74 75
				},
				smsName: ['SMS','WhatsApp'],
				smsData: [1,2],
				smsIndex: 0
lanbaoming's avatar
lanbaoming committed
76 77 78 79 80 81 82 83 84 85 86 87
			}
		},
		onLoad() {
			this.Country()
		},
		methods: {
			Country () {
				let that = this
				that.$request.get('/app-api/ecw/country/list-all').then(res => {
					if(res.code == 0&&res.data&&res.data.length > 0){
						for(let i in res.data){
							that.areaData.push(res.data[i].tel)
Smile's avatar
Smile committed
88
              that.areaName.push(res.data[i].tel + ' ' + res.data[i][that.$lang.name])
lanbaoming's avatar
lanbaoming committed
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
						}
					}
				})
			},
			areaChange (e) {
				this.areaIndex = e.detail.value
			},
			forgetForm () {
				if(!this.$request.checkFormData(this.FormData, this.rules)){
					return false
				}
				if(this.FormData.passworded != this.FormData.password){
					return uni.showToast({
						title: this.$lang.lang.notices.different,
						icon: 'none'
					})
				}
				this.$request.post('/app-api/member/reset-password', this.FormData).then(res => {
					console.log(res)
					if(res.code == 0){
						uni.showToast({
							title: this.$lang.lang.notices.edited,
							icon: 'success'
						})
						setTimeout(() => {
							uni.navigateTo({
								url: '../login/login',
							})
						}, 1500)
					} else {
						uni.showToast({
							title: res.msg ,
							icon: 'none',
						})
					}
				})
			},
honghy's avatar
honghy committed
126
			sendCode (e) {
lanbaoming's avatar
lanbaoming committed
127 128 129
				if(this.FormData.mobile == ''){
					return uni.showToast({
						title: this.$lang.lang.notices.phone,
130
						icon: 'none',
lanbaoming's avatar
lanbaoming committed
131 132 133 134 135
					})
				}
				if (this.leftTime < 60) {
					return false
				}
honghy's avatar
honghy committed
136 137 138 139 140 141 142 143 144 145
				var data = {
				  mobile: this.FormData.mobile,
				  nodeValue: 'user-sms-reset-password',
				  areaCode: this.areaData[this.areaIndex],
				  isTransport: 0,
				  transportId: 0,
				  isOrders: 0,
				  messageType: this.smsData[e.detail.value]
				}
				this.$request.post('/app-api/member/send-sms-code', data).then(res => {
lanbaoming's avatar
lanbaoming committed
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
					if(res.code == 0){
						this.countDown()
					} else {
						uni.showToast({
							title: res.msg || 'error',
							icon: 'none',
						})
					}
				})
			},
			countDown() {
				this.leftTime--
				if (this.leftTime > 0) {
					setTimeout(this.countDown, 1000)
				} else {
					this.leftTime = 60
				}
			},
		}
	}
</script>

<style>
	@import url("../../static/css/forget.css");
170
	.area picker{
honghy's avatar
honghy committed
171
		width: 110upx;
172
	}
lanbaoming's avatar
lanbaoming committed
173
</style>