zuozhanbaolishi.vue 7.4 KB
<template>
  <div class="container">
    <div class="flextwo sharetopk" @click="back">
      <div class="leftrow leftrowkimg">
        <img src="../../../assets/leftrow.png" alt />
      </div>
      <div class="sharemiddle">作战包历史</div>
      <div class="sharebtn">
        <!-- <img src="../../../assets/sharebtn.png" alt /> -->
      </div>
    </div>
    <div class="zuozhantopkkk flextwo">
      <div class="zuozhanitem" :class="iszuo==1?'zuozhanactive':''" @click="yixiang(1)">意向顾问</div>
      <div class="zuozhanitem" :class="iszuo==2?'zuozhanactive':''" @click="yixiang(2)">意向经销商</div>
    </div>
    <!-- 意向顾问 -->
    <div class="yixiangbox">
      <div class="yixiangboxtop flexone">
        <img src="../../../assets/yixiangimg.png" alt class="yixiangimg" />
        作战包生成次数:{{count}}次
      </div>

      <div class="yiixangpage" v-if="iszuo==1">
        <div class="yixiangpagetop flexone">
          <div class="yiitem">顾客姓名</div>
          <div class="yiitem">生成时间</div>
          <div class="yiitem">查看内容</div>
          <div class="yiitem jingxiao">经销商姓名</div>
          <div class="yiitem caozuo">操作</div>
        </div>
        <div class="yixiangcontent">
          <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
            <div
              class="yixiangpagetop yixiangpagetopk flexone"
              v-for="(item,index) in yixianglist"
              :key="index"
            >
              <div class="yiitem yiname">{{item.name}}</div>
              <div class="yiitem yiname yidate">{{item.createtime}}</div>
              <div class="yiitem yisee" @click="seecontent(item.id)">查看</div>
              <div class="yiitem yiname jingxiao">{{item.agent.name}}</div>
              <div class="yiitem yisee caozuo" @click="delgu(item.id)">删除</div>
            </div>
          </van-list>
        </div>
      </div>
      <div class="yiixangpage" v-if="iszuo==2">
        <div class="yixiangpagetop flexone">
          <div class="yiitem yijing">意向经销商</div>
          <div class="yiitem">生成时间</div>
          <div class="yiitem yicha">查看内容</div>
          <div class="yiitem jingxiao">经销商姓名</div>
          <div class="yiitem caozuo caojing">操作</div>
        </div>
        <div class="yixiangcontent">
          <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
            <div
              class="yixiangpagetop yixiangpagetopk flexone"
              v-for="(item,index) in yixianglist"
              :key="index"
            >
              <div class="yiitem yiname yijing">{{item.name}}</div>
              <div class="yiitem yiname yidate">{{item.createtime}}</div>
              <div class="yiitem yisee yicha" @click="jingxiaosee(item.id)">查看</div>
              <div class="yiitem yiname jingxiao">{{item.agent.name}}</div>
              <div class="yiitem yisee caozuo caojing" @click="deljing(item.id)">删除</div>
            </div>
          </van-list>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Vue from "vue";
import { Dialog } from 'vant';
import { List, Toast } from "vant";
Vue.use(Toast, List)
export default {
  data() {
    return {
      iszuo: 1,
      page: 1,
      yixianglist: [],
      finished: false,
      loading: false,
      this_page: "",
      total_page: "",
      count: ''
    }
  },
  created() {
    this.getguwenlist()
  },
  methods: {
    back() {
      this.$router.go(-1)
    },
    yixiang(id) {
      this.iszuo = id;
      this.page = 1;
      this.yixianglist = [];
      if (this.iszuo == 1) {
        this.getguwenlist()
      } else[
        this.getjingxiaolist()
      ]
    },
    //顾问查看
    seecontent(id) {
      this.$router.push({
        path: "/productintro",
        query: { subid: id }
      });
    },
    // 经销商查看
    jingxiaosee(id) {
      this.$router.push({
        path: "/companyintro",
        query: { subid: id }
      });
    },
    //列表上拉加载
    onLoad() {
      console.log(437843787)
      let that = this;
      // 异步更新数据
      // setTimeout 仅做示例,真实场景中一般为 ajax 请求
      setTimeout(() => {
        console.log(3434);

        let newpage = that.page;
        newpage++;
        that.page = newpage;


        if (that.iszuo == 1) {
          that.getguwenlist();
        } else {
          that.getjingxiaolist();
        }
        // 加载状态结束
        this.loading = false;
        // 数据全部加载完成
        if (that.this_page == that.total_page) {
          this.finished = true;
        }
      }, 1000);
    },
    // 获取意向顾客列表
    getguwenlist() {
      let that = this;
      var url = "/api/user/assistance_list";
      let param = {
        page: this.page
      };

      that.$axios
        .post(url, param)
        .then(function (res) {
          console.log(res);
          that.yixianglist = that.yixianglist.concat(res.data.list)
          that.this_page = res.data.this_page;
          that.total_page = res.data.total_page;
          that.count = res.data.count
        })
        .catch(function (error) {
          console.log(error);
        });
    },
    // 获取意向经销商列表
    getjingxiaolist() {
      let that = this;
      var url = "/api/user/purpose_list";
      let param = {
        page: this.page
      };

      that.$axios
        .post(url, param)
        .then(function (res) {
          console.log(res);
          that.yixianglist = that.yixianglist.concat(res.data.list);
          that.this_page = res.data.this_page;
          that.total_page = res.data.total_page;
          that.count = res.data.count
        })
        .catch(function (error) {
          console.log(error);
        });
    },
    // 删除顾客
    delgu(id) {
      Dialog.confirm({
        title: '是否删除意向顾客',

      })
        .then((res) => {
          console.log(3489348)
          let that = this
          var url = "/api/user/assistance_del";
          let param = {
            assistance_id: id
          };

          that.$axios
            .post(url, param)
            .then(function (res) {
              console.log(res);
              Toast("删除成功")
              that.page = 1;
              that.yixianglist = [];
              that.getguwenlist()


            })
            .catch(function (err) {
              console.log(err);
            });
          // on confirm
        })
        .catch((res) => {

          // on cancel
        });
    },
    // 删除经销商
    deljing(id) {
      Dialog.confirm({
        title: '是否删除意向顾客',

      })
        .then((res) => {
          console.log(3489348)
          let that = this
          var url = "/api/user/purpose_del";
          let param = {
            purpose_id: id
          };

          that.$axios
            .post(url, param)
            .then(function (res) {
              console.log(res);
              Toast("删除成功")
              that.page = 1;
              that.yixianglist = [];
              that.getjingxiaolist()


            })
            .catch(function (err) {
              console.log(err);
            });
          // on confirm
        })
        .catch((res) => {

          // on cancel
        });
    }
  }

}
</script>

<style scoped>
@import "../../../style/usercenter.css";
</style>