consult_add.vue 4.18 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 23 24 25 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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
<template>
	<view>
		<view class="consult">
			<dHeader :title="$lang.lang.consult.consult"></dHeader>
		</view>
		<view class="start-bar"></view>
		<view class="consultAdd">
			<view class="consult-item">
				<view class="consult-item-label">
					<image src="../../static/img/consulta-1.png" mode=""></image>
					<text>{{$lang.lang.consult.title}}</text>
				</view>
				<view class="consult-item-put">
					<input class="consolt_title" v-model="params.title" type="text" :placeholder="$lang.lang.notices.title">
				</view>			
			</view>
			<view class="consult-item">
				<view class="consult-item-label">
					<image src="../../static/img/consulta-2.png" mode=""></image>
					<text>{{$lang.lang.consult.type}}</text>
				</view>
				<view class="consult-item-put noborder">
					<radio-group @change="typeChange">
						<label class="radio">
							<radio value="1" :checked="params.type == 1" /><text>{{$lang.lang.index.consult}}</text>
						</label>
						<label class="radio">
							<radio value="2" :checked="params.type == 2" /><text>{{$lang.lang.consult.advice}}</text>
						</label>
					</radio-group>
				</view>
			</view>
			<view class="consult-item">
				<view class="consult-item-label">
					<image src="../../static/img/consulta-3.png" mode=""></image>
					<text>{{$lang.lang.consult.name}}</text>
				</view>
				<view class="consult-item-put">
					<input v-model="params.name" disabled type="text" >
				</view>
			</view>
			<view class="consult-item">
				<view class="consult-item-label">
					<image src="../../static/img/consulta-4.png" mode=""></image>
					<text>{{$lang.lang.consult.phone}}</text>
				</view>
				<view class="consult-item-put">
					<input v-model="params.phone" disabled type="number">
				</view>
			</view>
			<view class="consult-item">
				<view class="consult-item-label">
					<image src="../../static/img/consulta-5.png" mode=""></image>
					<text>{{$lang.lang.consult.orderNo}}</text>
				</view>
				<view class="consult-item-put">
					<input class="consolt_title" v-model="params.orderCode" type="text" :placeholder="$lang.lang.notices.orderNo">
				</view>
			</view>
			<view class="consult-item-2">
				<view class="consult-item-label-2">
					<image src="../../static/img/consulta-6.png" mode=""></image>
					<text>{{$lang.lang.consult.contented}}</text>
				</view>
				<view class="consult-item-put-2">
					<textarea class="textarea" v-model="params.content" :placeholder="$lang.lang.notices.content" id="" cols="30" rows="5"></textarea>
				</view>
			</view>
		</view>
		<view class="consult-btn">
			<view class="" @click="submitForm">{{$lang.lang.consult.sumbit}}</view>
			<view class="" @click="resetForm">{{$lang.lang.consult.reset}}</view>
		</view>
	</view>
</template>

<script>
	import dHeader from '../../components/dHeader/index.vue'
	export default {
		components: {
			dHeader
		},
		data() {
			return {
				params: {
					title: '',
					type: 1,
					content: '',
					name: '',
					phone: '',
					orderCode: '',
				},
				rules: {
					title: this.$lang.lang.notices.title,
					type: this.$lang.lang.notices.type,
					content: this.$lang.lang.notices.content,
				},
				userInfo:{}
			}
		},
		onLoad() {
			this.getUserInfo()
		},
		methods: {
			typeChange (e) {
				console.log()
				this.params.type = e.detail.value
			},
			getUserInfo() {
				this.$request.get('/app-api/member/user/get').then(res => {
					if(res.code==0&&res.data){
						this.userInfo = res.data
						this.params.name = res.data.nickname
						this.params.phone = res.data.mobile
					}

				})
			},
			submitForm () {
				if(!this.$request.checkFormData(this.params, this.rules)){
					return false
				}
				this.$request.post('/app-api/ecw/message-leave/create', this.params).then(res => {
					if(res.code==0){
						uni.showToast({
							title: this.$lang.lang.notices.success,
							icon: 'success',
						})
						setTimeout(() => {
							uni.navigateBack()
						}, 1500)
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},
			resetForm(){
				for(let i in this.params){
					this.params[i] = (i == 'type') ? 0 : ''
				}
				this.typeChange()
			}
		}
	}
</script>

<style>
	@import url("../../static/css/consult_add.css");
</style>