Pārlūkot izejas kodu

🎨 修改显示细节问题

快乐的梦鱼 2 mēneši atpakaļ
vecāks
revīzija
054176b161

+ 2 - 2
src/common/components/form/RichTextEditor.vue

@@ -40,7 +40,7 @@ function preview() {
   uni.setStorage({
     key: 'editorContent',
     data: props.modelValue,
-    success: () => navTo('/pages/editor/preview'),
+    success: () => navTo('/pages/article/editor/preview'),
   })
 }
 function edit() {
@@ -52,7 +52,7 @@ function edit() {
   uni.setStorage({
     key: 'editorContent',
     data: props.modelValue,
-    success: () => navTo('/pages/editor/editor'),
+    success: () => navTo('/pages/article/editor/editor'),
   })
 }
 

+ 7 - 3
src/pages/discover.vue

@@ -50,9 +50,7 @@
         title="非遗百科问答"
         desc="可获积分:500"
       >
-        <Button :radius="40" type="primary" size="small" @click="navTo('/pages/article/web/ewebview', {
-          url: `https://mn.wenlvti.net/app_static/minnan-answer?token=${authStore.token}#/pages/home/dashboard`
-        })">立即报名</Button>
+        <Button :radius="40" type="primary" size="small" @click="goAnswer">立即报名</Button>
       </Box2LineRightSlot>
 
       <!-- 文化社区 -->
@@ -312,6 +310,12 @@ const topicsData = useSimpleDataLoader(async () => {
   ]
 });
 
+function goAnswer() {
+  const url = `https://mn.wenlvti.net/app_static/minnan-answer?token=${authStore.token}#/pages/home/dashboard`
+  console.log(url)
+  navTo('/pages/article/web/ewebview', { url: url })
+}
+
 onShareTimeline(() => {
   return {}; 
 })

+ 9 - 4
src/pages/inhert/language/list.vue

@@ -3,7 +3,10 @@
     <view class="top-tab bg-base">
       <Tabs
         :tabs="tabs.content.value || []" 
-        :currentIndex="tab"
+        v-model:currentIndex="tab"
+        :autoItemWidth="false"
+        :autoScroll="true"
+        :defaultItemWidth="205"
         class="top-tab"
         @click="(e: any) => tab = e.id"
       />
@@ -79,7 +82,9 @@ import SearchBar from '@/components/form/SearchBar.vue';
 
 const tabs = useSimpleDataLoader(async () => {
   const res = await CommonContent.getModelColumList(5, 1, 50);
-  tab.value = res[0].id
+  setTimeout(() => {
+    tab.value = 0
+  }, 200);
   return res.map((item) => ({
     ...item,
     text: item.name,
@@ -93,12 +98,12 @@ const playAuto = ref(Boolean(uni.getStorageSync('LanguageAutoPlay')));
 console.log(playAuto);
 
 const searchValue = ref('');
-const tab = ref(0)
+const tab = ref(-1)
 const listLoader = useSimplePageListLoader(8, async (page, pageSize) => {
   const res = await CommonContent.getContentList(new GetContentListParams()
     .setModelId(5)
     .setKeywords(searchValue.value)
-    .setMainBodyColumnId(tab.value)
+    .setMainBodyColumnId(tabs.content.value?.[tab.value].id ?? 0)
   , page, pageSize);
   return { list: res.list.map((item) => {
     return {

+ 3 - 6
src/pages/user/contribute/list.vue

@@ -1,14 +1,10 @@
 <template>
   <view class="d-flex flex-column bg-base" style="min-height:100vh">
     <view class="p-3">
-      <uni-search-bar 
+      <SearchBar
         v-model="searchText"
-        radius="100"
-        bgColor="#fff"
         placeholder="搜一搜" 
-        clearButton="auto"
-        cancelButton="none"
-        @confirm="search"
+        @search="search"
       />
     </view>
     <view class="d-flex flex-column p-3">
@@ -37,6 +33,7 @@ import { navTo } from '@/components/utils/PageAction';
 import { onLoad } from '@dcloudio/uni-app';
 import ContributeApi from '@/api/user/ContributeApi';
 import Box2LineImageRightShadow from '@/pages/parts/Box2LineImageRightShadow.vue';
+import SearchBar from '@/components/form/SearchBar.vue';
 
 const searchText = ref('');
 const listLoader = useSimplePageListLoader<GetContentListItem>(

+ 87 - 94
src/pages/user/contribute/submit.vue

@@ -3,8 +3,8 @@
     <LoadingPage v-if="loading" /> 
     <DynamicForm
       ref="formRef"
+      :model="formModel"
       :options="formDefine"
-      :formModelInit="formModelInit"
     />
     <Button type="primary" @click="submit">提交</Button>
     <XBarSpace />
@@ -20,121 +20,114 @@ import Button from '@/components/basic/Button.vue';
 import XBarSpace from '@/components/layout/space/XBarSpace.vue';
 import DynamicForm from '@/components/dynamic/DynamicForm.vue';
 import type { IDynamicFormOptions, IDynamicFormRef } from '@/components/dynamic';
+import type { FormProps } from '@/components/form/Form.vue';
 
 const loading = ref(false);
 
 const formRef = ref<IDynamicFormRef>();
+const formModel = ref(new ContributeItem());
 const formDefine : IDynamicFormOptions = {
+  formAdditionaProps: {
+    labelFlex: 3,
+    inputFlex: 7
+  } as FormProps,
   formItems: [
     {
-      name: '',
-      children: {
-        type: 'group',
-        props: {
-          class: 'form-block',
-        },
-        propNestType: 'nest', 
-        items: [
-          { 
-            label: '栏目', 
-            name: 'mainBodyColumnId',
-            type: 'dynamic-select', 
-            params: {
-              loadData: async () => {
-                /* (await ContributeApi.getCanClaimVallageList())
-                  .map((p) => ({
-                    value: p.id,
-                    text: p.villageName,
-                  })) */
-               return []
-              },
-            } as DynamicSelectProps,
-            rules: [{
-              required: true,
-              errorMessage: '请选择投稿栏目',
-            }],
-            onChange: (_, value, model) => {
-              //model.
-            }
-          },
-          { 
-            label: '文章标题', 
-            name: 'title', 
-            type: 'text', 
-            defaultValue: '',
-            params: {
-              placeholder: '请输入文章标题',
+      name: 'a',
+      type: 'flat-group',
+      children: [
+        { 
+          label: '栏目', 
+          name: 'mainBodyColumnId',
+          type: 'select-id', 
+          additionalProps: {
+            loadData: async () => {
+              /* (await ContributeApi.getCanClaimVallageList())
+                .map((p) => ({
+                  value: p.id,
+                  text: p.villageName,
+                })) */
+              return []
             },
-            rules:  [{
-              required: true,
-              errorMessage: '请输入文章标题',
-            }] 
           },
-          { 
-            label: '内容类型', 
-            name: 'type', 
-            type: 'select', 
-            params: {
-              disabled: true,
-              localdata: [
-                { value: 1, text: "文章" },
-                { value: 2, text: "音频" },
-                { value: 3, text: "视频" },
-                { value: 4, text: "相册" },
-              ],
-              clear: false,
+          rules: [{
+            required: true,
+            message: '请选择投稿栏目',
+          }],
+        },
+        { 
+          label: '文章标题', 
+          name: 'title', 
+          type: 'text', 
+          defaultValue: '',
+          additionalProps: {
+            placeholder: '请输入文章标题',
+          },
+          rules:  [{
+            required: true,
+            message: '请输入文章标题',
+          }] 
+        },
+        { 
+          label: '内容类型', 
+          name: 'type', 
+          type: 'select-id', 
+          additionalProps: {
+            disabled: true,
+            loadData: async () => {
+              return [
+                { id: 1, text: "文章" },
+                { id: 2, text: "音频" },
+                { id: 3, text: "视频" },
+                { id: 4, text: "相册" },
+              ]
             },
-            defaultValue: 1,
-            rules: [{
-              required: true,
-              errorMessage: '请选择类型',
-            }]
           },
-        ]
-      }
+          defaultValue: 1,
+          rules: [{
+            required: true,
+            message: '请选择类型',
+          }]
+        },
+      ]
     },
     {
-      name: '',
-      children: {
-        type: 'group',
-        props: {
-          class: 'form-block',
-        },
-        propNestType: 'nest', 
-        items: [
-          {
-            label: '内容',
-            name: 'intro',
-            type: 'richtext',
-            defaultValue: '',
-            params: {
-              placeholder: '请输入内容',
-              saveTempKey: 'contribute',
-            },
-            rules: [{
-              required: true,
-              errorMessage: '请输入内容',
-            }]
-          }
-        ]
-      }
+      name: 'b',
+      type: 'flat-group',
+      children: [
+        {
+          label: '内容',
+          name: 'intro',
+          type: 'richtext',
+          defaultValue: '',
+          additionalProps: {
+            placeholder: '请输入内容',
+            saveTempKey: 'contribute',
+          },
+          rules: [{
+            required: true,
+            message: '请输入内容',
+          }]
+        }
+      ]
     },
   ]
 }
 
-function formModelInit() {
-  return new ContributeItem();
-}
-
 async function submit() {
   if (!formRef.value)
     return;
   try {
-    const data = await formRef.value.submitForm<ContributeItem>();
-    if (!data)
-      return;
+    await formRef.value.validate();
+  } catch {
+    uni.showToast({
+      title: '有必填项未填写,请检查',
+      icon: 'none',
+    });
+  }
+  try { 
     loading.value = true;
-    await ContributeApi.contribute(data);
+    await ContributeApi.contribute(formModel.value as ContributeItem);
     uni.showModal({
       title: '提交成功',
       content: '感谢您的投稿,我们将尽快审核并通知您结果。',

+ 9 - 82
src/pages/user/login.vue

@@ -1,59 +1,17 @@
 <template>
   <view class="p-3">
-    <view v-if="type == 'mobile'" class="d-flex flex-column align-center justify-center">
-      <image class="width-300 m-5" src="https://mncdn.wenlvti.net/app_static/minnan/logo.png" mode="widthFix"></image>
-      <view class="w-100 mt-3 mb-3">
-        <u-form
-          labelPosition="top"
-          labelWidth="180"
-          :model="loginFormModel"
-          :rules="loginFormRules"
-          ref="uForm"
-        >
-          <u-form-item
-            label="手机号"
-            prop="mobile"
-            borderBottom
-          >
-            <u-input
-              v-model="loginFormModel.mobile"
-              placeholder="请输入手机号"
-            />
-          </u-form-item>
-          <u-form-item
-            label="密码"
-            prop="password"
-            borderBottom
-          >
-            <u-input
-              v-model="loginFormModel.password"
-              :password="true"
-              placeholder="请输入密码(6-16位)"
-            ></u-input>
-          </u-form-item>
-        </u-form>
-      </view>
-      <u-button type="primary" @click="loginMobile">
-        登录
-      </u-button>
-      <view class="mt-3" />
-      <u-button class="mt-3" type="primary" :plain="true" @click="type='wechat'">
-        微信登录
-      </u-button>
-    </view>
-
-    <view v-if="type == 'wechat'" class="d-flex flex-column align-center justify-center">
+    <view class="d-flex flex-column align-center justify-center">
       <image class="width-300 m-5" src="https://mncdn.wenlvti.net/app_static/minnan/logo.png" mode="widthFix"></image>
       <view class="mt-3 mb-3">
         <text class="text-align-center">请点击微信登录,并授权获取公开信息, 登录后您将获得更多权益</text>
       </view>
-      <u-button type="primary" @click="loginWechat">
+      <Button type="primary" block @click="loginWechat">
         微信登录
-      </u-button>
-      <!-- <view class="mt-3" />
-      <u-button type="primary" :plain="true" @click="type='mobile'">
-        手机号登录
-      </u-button> -->
+      </Button>
+      <Height :height="20" />
+      <Button block @click="back">
+        返回
+      </Button>
     </view>
   </view>
 </template>
@@ -63,33 +21,12 @@ import { useAuthStore } from '@/store/auth';
 import { onLoad } from '@dcloudio/uni-app';
 import { back } from '@/components/utils/PageAction';
 import { toast } from '@/components/utils/DialogAction';
-import { ref } from 'vue';
 import { showError } from '@/common/composeabe/ErrorDisplay';
+import Button from '@/components/basic/Button.vue';
+import Height from '@/components/layout/space/Height.vue';
 
-const type = ref('wechat');
 const authStore = useAuthStore();
 
-const loginFormModel = ref({
-  mobile: '',
-  password: '',
-});
-const loginFormRules = {
-  'mobile': {
-    type: 'string',
-    required: true,
-    message: '请填写手机号',
-    trigger: ['blur', 'change']
-  },
-  'password': {
-    type: 'string',
-    min: 6,
-    max: 16,
-    required: true,
-    message: '请填写密码(6-16位)',
-    trigger: ['blur', 'change']
-  },
-}
-
 function loginWechat() {
   uni.showLoading({ title: '登录中...' });
   Promise.all([
@@ -107,16 +44,6 @@ function loginWechat() {
     .catch(showError)
     .finally(() => uni.hideLoading());
 }
-function loginMobile() {
-  uni.showLoading({ title: '登录中...' });
-  authStore.loginMobile(
-    loginFormModel.value.mobile, 
-    loginFormModel.value.password
-  ).then(() => {
-    toast('登录成功');
-    setTimeout(back, 200);
-  }).catch(showError)
-}
 onLoad(() => {
   if (authStore.isLogged) {
     setTimeout(() => {

+ 3 - 6
src/pages/video/list.vue

@@ -1,14 +1,10 @@
 <template>
   <view class="video_list">
     <view class="search">
-      <uni-search-bar 
+      <SearchBar
         v-model="searchText"
-        radius="100"
-        bgColor="#fff"
         placeholder="搜一搜" 
-        clearButton="auto"
-        cancelButton="none"
-        @confirm="search"
+        @search="search"
       />
     </view>
     <view class="post-list">
@@ -43,6 +39,7 @@ import { navTo } from '@/components/utils/PageAction';
 import { onLoad } from '@dcloudio/uni-app';
 import NewsIndexContent from '@/api/news/NewsIndexContent';
 import SimplePageListLoader from '@/common/components/SimplePageListLoader.vue';
+import SearchBar from '@/components/form/SearchBar.vue';
 
 const searchText = ref('');
 const listLoader = useSimplePageListLoader<

+ 2 - 9
src/store/auth.ts

@@ -20,15 +20,7 @@ export const useAuthStore = defineStore('auth', {
         this.token = authInfo.token;
         this.userId = authInfo.userId;
         this.expireAt = authInfo.expireAt;
-
-        // 检查token是否过期,如果快要过期,则刷新token
-        if (Date.now() > this.expireAt + 1000 * 3600 * 5) {
-          const refreshResult = await UserApi.refresh();
-          this.loginResultHandle(refreshResult);
-          this.userInfo = refreshResult.mainBodyUserInfo;
-        } else {
-          this.userInfo = await UserApi.getUserInfo(this.userId);
-        }
+        this.userInfo = authInfo.userInfo;
       } catch (error) {
         this.token = '';
         this.userId = 0;
@@ -69,6 +61,7 @@ export const useAuthStore = defineStore('auth', {
           token: this.token, 
           userId: this.userId ,
           expireAt: this.expireAt,
+          userInfo: this.userInfo,
         }) 
       });
     },