<template>
	<u-popup v-model="showTitle" mode="center" height="380rpx" width="80%">
		<view style="padding: 30rpx 30rpx 0 30rpx; height: 100%;">
			<view style="font-size: 34rpx; width: 100%; text-align: center; margin-bottom: 20rpx;">
				设置产品线名称
			</view>
			<u-form label-width="110">
				<u-form-item label="名称:">
					<u-input
						v-model="title"
						:type="type"
						:border="true"
						clearable
						placeholder="请输入名称"
					/>
				</u-form-item>
			</u-form>
			<u-button :maxlength="11" type="error" style="margin-top: 40rpx;" @tap="saveTitle">
				保存
			</u-button>
		</view>
	</u-popup>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useStore } from '@/store/useStore';

let store = useStore();
let showTitle = ref(false);
let title = ref(store.title);
let type = ref('text');

let saveTitle = () => {
	if (title.value) {
		store.$patch({
			title: title.value,
		});
		uni.showToast({
			title: '设置成功',
			icon: 'none',
		});
		showTitle.value = false;
	} else {
		uni.showToast({
			title: '设置失败',
			icon: 'none',
		});
	}
};

defineExpose({
	showTitle,
	title,
});
</script>

<style></style>
