Showing
4 changed files
with
52 additions
and
13 deletions
| ... | @@ -42,8 +42,8 @@ | ... | @@ -42,8 +42,8 @@ |
| 42 | <script setup> | 42 | <script setup> |
| 43 | import { ref, defineProps } from 'vue' | 43 | import { ref, defineProps } from 'vue' |
| 44 | import icon_home1 from '@/images/icon/home01@2x.png' | 44 | import icon_home1 from '@/images/icon/home01@2x.png' |
| 45 | - | ||
| 46 | import Taro from '@tarojs/taro' | 45 | import Taro from '@tarojs/taro' |
| 46 | +import { getCurrentPageParam } from "@/utils/weapp"; | ||
| 47 | 47 | ||
| 48 | const props = defineProps({ | 48 | const props = defineProps({ |
| 49 | // player=参与者,可报名活动。 | 49 | // player=参与者,可报名活动。 |
| ... | @@ -76,8 +76,9 @@ const goTo = (type) => { | ... | @@ -76,8 +76,9 @@ const goTo = (type) => { |
| 76 | url: '../joinList/index' | 76 | url: '../joinList/index' |
| 77 | }) | 77 | }) |
| 78 | } else if (type === 'edit') { // 修改活动 | 78 | } else if (type === 'edit') { // 修改活动 |
| 79 | + const id = getCurrentPageParam().id; | ||
| 79 | Taro.navigateTo({ | 80 | Taro.navigateTo({ |
| 80 | - url: '../createActivity/index?type=edit' | 81 | + url: '../createActivity/index?id=' + id + '&type=edit' |
| 81 | }) | 82 | }) |
| 82 | } | 83 | } |
| 83 | } | 84 | } | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-26 21:52:25 | 2 | * @Date: 2022-09-26 21:52:25 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-10-18 09:52:24 | 4 | + * @LastEditTime: 2022-10-18 18:43:55 |
| 5 | * @FilePath: /swx/src/components/activity-editor.vue | 5 | * @FilePath: /swx/src/components/activity-editor.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -58,10 +58,10 @@ import Taro from '@tarojs/taro' | ... | @@ -58,10 +58,10 @@ import Taro from '@tarojs/taro' |
| 58 | import BASE_URL from '@/utils/config'; | 58 | import BASE_URL from '@/utils/config'; |
| 59 | 59 | ||
| 60 | export default { | 60 | export default { |
| 61 | - props: ['showTabBar', 'placeholder', 'name'], | 61 | + props: ['showTabBar', 'placeholder', 'name', 'htmlContent'], |
| 62 | data() { | 62 | data() { |
| 63 | return { | 63 | return { |
| 64 | - | 64 | + editorCtx: '' |
| 65 | } | 65 | } |
| 66 | }, | 66 | }, |
| 67 | methods: { | 67 | methods: { |
| ... | @@ -69,7 +69,15 @@ export default { | ... | @@ -69,7 +69,15 @@ export default { |
| 69 | const that = this; | 69 | const that = this; |
| 70 | Taro.createSelectorQuery().select('#editor').context(function (res) { | 70 | Taro.createSelectorQuery().select('#editor').context(function (res) { |
| 71 | that.editorCtx = res.context | 71 | that.editorCtx = res.context |
| 72 | - }).exec() | 72 | + }).exec(); |
| 73 | + // 如果有传值,还原重新编辑 | ||
| 74 | + if (this.htmlContent) { | ||
| 75 | + setTimeout(() => { | ||
| 76 | + this.editorCtx.setContents({ | ||
| 77 | + html: this.htmlContent | ||
| 78 | + }) | ||
| 79 | + }, 1000); | ||
| 80 | + } | ||
| 73 | }, | 81 | }, |
| 74 | //插入图片 | 82 | //插入图片 |
| 75 | _addImage: function (event) { | 83 | _addImage: function (event) { | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-26 14:36:57 | 2 | * @Date: 2022-09-26 14:36:57 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-10-18 17:47:13 | 4 | + * @LastEditTime: 2022-10-18 17:59:36 |
| 5 | * @FilePath: /swx/src/pages/activityDetail/index.vue | 5 | * @FilePath: /swx/src/pages/activityDetail/index.vue |
| 6 | * @Description: 活动详情页 | 6 | * @Description: 活动详情页 |
| 7 | --> | 7 | --> | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-21 16:04:10 | 2 | * @Date: 2022-09-21 16:04:10 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-10-18 13:15:36 | 4 | + * @LastEditTime: 2022-10-18 18:42:33 |
| 5 | * @FilePath: /swx/src/pages/createActivity/index.vue | 5 | * @FilePath: /swx/src/pages/createActivity/index.vue |
| 6 | * @Description: 创建活动页面 | 6 | * @Description: 创建活动页面 |
| 7 | --> | 7 | --> |
| ... | @@ -31,7 +31,7 @@ | ... | @@ -31,7 +31,7 @@ |
| 31 | <view class="divide-line"></view> | 31 | <view class="divide-line"></view> |
| 32 | <view class="form-item"> | 32 | <view class="form-item"> |
| 33 | <view class="form-item-title border">活动详情</view> | 33 | <view class="form-item-title border">活动详情</view> |
| 34 | - <activity-editor name="editor" :showTabBar="true" placeholder="开始输入活动详情介绍" @on-input="onEditorInput"></activity-editor> | 34 | + <activity-editor name="editor" :showTabBar="true" placeholder="开始输入活动详情介绍" @on-input="onEditorInput" :htmlContent="html_content"></activity-editor> |
| 35 | </view> | 35 | </view> |
| 36 | <view class="divide-line"></view> | 36 | <view class="divide-line"></view> |
| 37 | <view class="form-item"> | 37 | <view class="form-item"> |
| ... | @@ -261,7 +261,7 @@ | ... | @@ -261,7 +261,7 @@ |
| 261 | </template> | 261 | </template> |
| 262 | 262 | ||
| 263 | <script setup> | 263 | <script setup> |
| 264 | -import { ref, onMounted, nextTick, toRefs } from "vue"; | 264 | +import { ref, onMounted, nextTick, getCurrentInstance } from "vue"; |
| 265 | // import icon_home1 from '@/images/icon/home01@2x.png' | 265 | // import icon_home1 from '@/images/icon/home01@2x.png' |
| 266 | import icon_upload from '@/images/icon/upload@2x.png' | 266 | import icon_upload from '@/images/icon/upload@2x.png' |
| 267 | import icon_vip from '@/images/icon/vip@2x.png' | 267 | import icon_vip from '@/images/icon/vip@2x.png' |
| ... | @@ -275,6 +275,7 @@ import BASE_URL from '@/utils/config'; | ... | @@ -275,6 +275,7 @@ import BASE_URL from '@/utils/config'; |
| 275 | import Toast from '@/components/vant-weapp/toast/toast'; | 275 | import Toast from '@/components/vant-weapp/toast/toast'; |
| 276 | import { randomId } from '@/utils/tools' | 276 | import { randomId } from '@/utils/tools' |
| 277 | import * as dayjs from 'dayjs' | 277 | import * as dayjs from 'dayjs' |
| 278 | +import { activityInfoAPI } from '@/api/Host/index'; | ||
| 278 | 279 | ||
| 279 | const activity_name = ref(''); | 280 | const activity_name = ref(''); |
| 280 | const onChange = ({ detail }) => { | 281 | const onChange = ({ detail }) => { |
| ... | @@ -341,12 +342,17 @@ const removeUploadImage = () => { | ... | @@ -341,12 +342,17 @@ const removeUploadImage = () => { |
| 341 | } | 342 | } |
| 342 | /**********************************/ | 343 | /**********************************/ |
| 343 | 344 | ||
| 344 | -onMounted(() => { | 345 | +onMounted(async () => { |
| 345 | if (getCurrentPageParam().type === 'edit') { | 346 | if (getCurrentPageParam().type === 'edit') { |
| 346 | // 动态修改标题 | 347 | // 动态修改标题 |
| 347 | wx.setNavigationBarTitle({ | 348 | wx.setNavigationBarTitle({ |
| 348 | title: '修改活动', | 349 | title: '修改活动', |
| 349 | - }) | 350 | + }); |
| 351 | + const { code, data } = await activityInfoAPI({ i: getCurrentPageParam().id }); | ||
| 352 | + if (code) { | ||
| 353 | + // 更新活动信息 | ||
| 354 | + updateActivityInfo(data) | ||
| 355 | + } | ||
| 350 | } | 356 | } |
| 351 | nextTick(() => { | 357 | nextTick(() => { |
| 352 | setTimeout(() => { | 358 | setTimeout(() => { |
| ... | @@ -685,6 +691,28 @@ const onSubmit = async () => { | ... | @@ -685,6 +691,28 @@ const onSubmit = async () => { |
| 685 | } | 691 | } |
| 686 | } | 692 | } |
| 687 | } | 693 | } |
| 694 | + | ||
| 695 | +// 获取活动信息,还原 | ||
| 696 | +const html_content = ref(''); | ||
| 697 | +const updateActivityInfo = async ({ activity, host }) => { | ||
| 698 | + // 获取主办方列表信息 | ||
| 699 | + const { code, data } = await hostListAPI(); | ||
| 700 | + if (code) { | ||
| 701 | + const my_hosts = data.my_hosts; | ||
| 702 | + // 主办方 | ||
| 703 | + org_type.value = my_hosts.filter(item => item.id === host.id)[0]['name']; | ||
| 704 | + host_id.value = host.id; | ||
| 705 | + // 活动主题 | ||
| 706 | + activity_name.value = activity.name; | ||
| 707 | + // 活动封面 | ||
| 708 | + if (activity.cover) { | ||
| 709 | + has_image.value = true; | ||
| 710 | + uploader_image.value = activity.cover; | ||
| 711 | + } | ||
| 712 | + // 活动详情 | ||
| 713 | + html_content.value = activity.note; | ||
| 714 | + } | ||
| 715 | +} | ||
| 688 | </script> | 716 | </script> |
| 689 | 717 | ||
| 690 | <script> | 718 | <script> |
| ... | @@ -710,11 +738,13 @@ export default { | ... | @@ -710,11 +738,13 @@ export default { |
| 710 | // }, | 738 | // }, |
| 711 | async onShow () { | 739 | async onShow () { |
| 712 | // 获取主办方列表信息 | 740 | // 获取主办方列表信息 |
| 713 | - const { data } = await hostListAPI(); | 741 | + const { code, data } = await hostListAPI(); |
| 742 | + if (code) { | ||
| 714 | data.my_hosts.forEach(item => { | 743 | data.my_hosts.forEach(item => { |
| 715 | item.text = item.name | 744 | item.text = item.name |
| 716 | }) | 745 | }) |
| 717 | this.org_type_columns = data.my_hosts; | 746 | this.org_type_columns = data.my_hosts; |
| 718 | } | 747 | } |
| 748 | + } | ||
| 719 | }; | 749 | }; |
| 720 | </script> | 750 | </script> | ... | ... |
-
Please register or login to post a comment