index.vue 3.58 KB
<!--
 * @Date: 2022-09-19 14:11:06
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2022-11-01 11:06:35
 * @FilePath: /swx/src/pages/projectManage/index.vue
 * @Description: 主办方管理页面
-->
<template>
  <view class="project-manage-page">
    <view class="activity-title">
      <view class="box">
        <text class="bg-gradient" style="font-size: 1rem;">我创建的主办方</text>
      </view>
    </view>
    <view v-if="create_list.length" class="create-box">
      <view class="create-item" v-for="(item, index) in create_list" :key="index">
        <van-row>
          <van-col span="15">
            <view>
              <van-icon :name="icon_p" size="2.25rem" color="" style="vertical-align: middle;" />
              <text class="name">&nbsp;{{ item.name }}</text>
            </view>
          </van-col>
          <van-col span="4">
            <view class="manage-btn" @tap="onManage(item)">管理</view>
          </van-col>
          <van-col span="4" offset="1">
            <view class="delete-btn" @tap="onDelete(item)">删除</view>
          </van-col>
        </van-row>
      </view>
    </view>
    <view style="height: 1rem;"></view>
    <view class="activity-title">
      <view class="box">
        <text class="bg-gradient" style="font-size: 1rem;">我加入的主办方</text>
      </view>
    </view>
    <view v-if="join_list.length" class="join-box">
      <view class="join-item" v-for="(item, index) in join_list" :key="index">
        <van-row>
          <van-col span="24">
            <view>
              <van-icon :name="icon_p" size="2.25rem" color="" style="vertical-align: middle;" />
              <text class="name">&nbsp;{{ item.name }}</text>
            </view>
          </van-col>
        </van-row>
      </view>
      <view style="height: 7rem;"></view>
    </view>
  </view>
  <bottom-button @on-submit="onSubmit">新建主办方</bottom-button>
  <van-dialog id="van-dialog" />

</template>

<script setup>
import Taro from '@tarojs/taro'
import { ref, onMounted } from "vue";
import icon_p from '@/images/icon/zhubanfang@2x.png'
import bottomButton from "@/components/bottom-button";
import { deleteHostAPI, hostListAPI } from '@/api/Host/index';
import Dialog from '@/components/vant-weapp/dialog/dialog';

const onSubmit = () => {
  Taro.navigateTo({
    url: '../createProject/index'
  })
}

const onManage = (item) => {
  Taro.navigateTo({
    url: '../userManage/index?host_id=' + item.id + '&name=' + decodeURIComponent(item.name)
  })
}
</script>

<script>
import "./index.less";
import mixin from '@/utils/mixin';

export default {
  name: "projectManagePage",
  mixins: [mixin.init],
  data () {
    return {
      create_list: [],
      join_list: [],
    }
  },
  async onShow() {
    const { code, data } = await hostListAPI({ is_join: 1 });
    if (code) {
      this.create_list = data.my_hosts;
      this.join_list = data.join_hosts;
    }
  },
  methods: {
    onDelete (item) {
      Dialog.confirm({
        title: '温馨提示',
        message: '是否确认删除主办方?',
        confirmButtonColor: '#199a74'
      })
        .then(async () => {
          // on confirm
          const { code, data } = await deleteHostAPI({ i: item.id });
          if (code) {
            Taro.showToast({
              title: '删除成功',
              icon: 'success',
              duration: 2000
            });
            const { code, data } = await hostListAPI();
            if (code) {
              this.create_list = data.my_hosts;
            }
          }
        })
        .catch(() => {
          // on cancel
        });
    }
  }
};
</script>