123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <template>
- <view class="wrap">
- <uni-forms :modelValue="formData" :label-width="50" ref="form">
- <uni-forms-item label="标题" name="taskTitle" required>
- <uni-easyinput type="text" v-model="formData.taskTitle" placeholder="请输入标题" />
- </uni-forms-item>
- <uni-forms-item label="内容" name="taskContent" required>
- <uni-easyinput
- v-model="formData.taskContent"
- :maxlength="-1" type="textarea"
- autoHeight
- placeholder="请输入内容" />
- </uni-forms-item>
- </uni-forms>
- <button @click="submitForm" class="submit-bt">提交</button>
- </view>
- </template>
- <script>
- import {createMemory} from '@/api/user.js'
- export default {
- data() {
- return {
- rules: {
- taskTitle: {
- rules:[
- {
- required: true,
- errorMessage: '请填写标题',
- }
- ],
- label:'标题',
- validateTrigger:'submit'
- },
- taskContent: {
- rules:[
- {
- required: true,
- errorMessage: '请填写内容',
- }
- ],
- label:'内容',
- validateTrigger:'submit'
- }
- },
- formData:{
- taskTitle:"",
- taskContent:""
- }
- }
- },
- onReady() {
- this.$refs.form.setRules(this.rules)
- },
- methods: {
- submitForm(){
- let accountId=uni.getStorageSync('accountId')
- this.$refs.form.validate().then(res => {
- createMemory({
- ...res,
- accountId
- }).then((resq)=>{
- uni.showToast({
- title:"提交成功!",
- icon:"none"
- })
- setTimeout(()=>{
- uni.switchTab({
- url:'/pages/history/history'
- })
- },1000)
- })
- }).catch(err => {
- console.log('表单错误信息:', err);
- })
- }
- },
- onShareAppMessage() {
- return {
- title: '记忆',
- path: '/pages/index/index'
- }
- },
- onShareTimeline() {
- return {
- title: '记忆',
- path: '/pages/index/index'
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- *{
- padding: 0;
- margin: 0;
- }
- .wrap{
- padding:20rpx;
- .submit-bt{
- width: 240rpx;
- height: 72rpx;
- line-height: 72rpx;
- text-align: center;
- background:#3D90F4;
- border-radius: 36rpx;
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: 400;
- color: #FFFFFF;
- z-index: 999;
- float: right;
- }
- }
- </style>
|