suggest.vue 1.4 KB
<template>
	<view class="page">
		<textarea class="textarea" v-model="txt" maxlength="300" placeholder="可以提出您想实现的彩店功能、或者对现有产品的改进"></textarea>
		<button type="default" class="btn" @click="save">提交</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				txt: ''
			}
		},
		async onLoad(e) {},
		methods: {
			async save() {
				let txt = this.txt.trim()
				if (txt.length < 20) {
					uni.showToast({
						icon: 'error',
						title: '您描述的问题内容太少'
					})
					return
				}

				const res = await uni.$u.request.graphql({
					type: 'mutation',
					name: 'suggestAdd',
					args: `url:"",img:"",typeId:5,content:"${txt}"`
				})

				if (res.Error) {
					uni.showToast({
						icon: 'error',
						title: res.Error
					})

					return
				}

				uni.showToast({
					title: '提交成功'
				})
				this.txt = ''
			}
		}
	}
</script>

<style lang="scss" scoped>
	body {
		max-width: $sys-max-width;
		-webkit-tap-highlight-color: transparent;
		box-shadow: 0 2px 2px rgb(0 0 0 / 30%);
	}

	.page {
		width: 100%;
		height: 100vh;
		background-color: #F1F1F1;
		font-size: 14px;
	}

	.textarea {
		width: calc(100% - 20px);
		padding: 10px;
		min-height: 150px;
		background-color: #FFFFFF;
	}

	.btn {
		height: 44px;
		margin: 20px 10px;
		background-color: #D23338;
		color: #FFFFFF;
	}
</style>