11
jhzh
2024-05-26 166f212ef296c70084bcd1bf5882b2e7adc4517d
11
1 files added
388 ■■■■■ changed files
src/page/list/favorites/data.list.vue 388 ●●●●● patch | view | raw | blame | history
src/page/list/favorites/data.list.vue
New file
@@ -0,0 +1,388 @@
<template>
  <div class="list-data">
    <div class="header-box">
      <van-row type="flex" align="center" gutter="20">
        <van-col span="9">
          <div>
            {{ $t("hj39") }}
          </div>
        </van-col>
        <van-col span="9"
          ><div style="text-align: left">
            {{ $t("hj40") }}
          </div>
        </van-col>
        <van-col span="6">
          <div style="text-align: right">
            {{ $t("hj42") }}
          </div>
        </van-col>
      </van-row>
    </div>
    <van-list
      v-model="loadings"
      :finished-text="$t('hj43')"
      :loading-text="$t('hj430')"
      :immediate-check="false"
    >
      <div
        class="item"
        v-for="item in listArr"
        :key="item.indexCode"
        @click="shengou(item)"
        v-if="item.zt==0"
      >
        <van-row type="flex" align="center" gutter="20" >
          <van-col span="9">
            <div>
              <div class="tp">
                <span class="collection" @click="optionszx(item)">
                  <span
                    class="shu"
                    :class="item.isOption == '1' ? 'shublue' : ''"
                  ></span>
                </span>
                <span
                  class="title_color"
                  style="
                    overflow: hidden;
                    -webkit-line-clamp: 1;
                    text-overflow: ellipsis;
                    display: -webkit-box;
                    -webkit-box-orient: vertical;
                  "
                  >{{ item.name }}</span
                >
              </div>
              <div class="bt">
                <span>{{ item.code }}</span>
              </div>
            </div></van-col
          >
          <van-col span="9">
            <div style="text-align: left">
              <div class="tp">
                <span class="price_color">{{ item.price }}</span>
              </div>
              <div class="bt">
                <span>Max: {{ item.orderNumber }}</span>
              </div>
            </div>
          </van-col>
          <van-col span="6">
            <div style="text-align: right">
              <div class="xgsgType">
                <span class="price_color">{{ $t("hj45") }}</span>
              </div>
            </div>
          </van-col>
        </van-row>
      </div>
    </van-list>
    <van-popup
      v-model="show"
      :style="{
        minHeight: '30%',
        borderTopLeftRadius: '10px',
        borderTopRightRadius: '10px',
      }"
      position="bottom"
    >
      <div class="popup-box">
        <div class="input-box">
          <div class="laber">{{ $t("hj57") }}:</div>
          <input type="number" :value="fromData.value" @input="fromDatavalue" />
        </div>
        <div class="shijian">
          <div class="xgsj">
            <div class="sjtlt">{{ $t("hj59") }}:</div>
            <div class="xgTime">
              {{
                $moment(shengouObj.subscribeTime).format("YYYY-MM-DD HH:mm:ss")
              }}
            </div>
          </div>
          <div class="xgsj">
            <div class="sjtlt">{{ $t("hj60") }}:</div>
            <div class="xgTime">
              {{
                $moment(shengouObj.subscriptionTime).format(
                  "YYYY-MM-DD HH:mm:ss"
                )
              }}
            </div>
          </div>
          <div class="xgsj">
            <div class="sjtlt">{{ $t("最大購買") }}:</div>
            <div class="xgTime">{{ shengouObj.orderNumber }}</div>
          </div>
          <div class="xgsj">
            <div class="sjtlt">{{ $t("hj120") }}:</div>
            <div class="xgTime">{{ shengouObj.price }}</div>
          </div>
          <!-- <div class="xgsj">
            <div class="sjtlt">上市時間:</div>
          </div> -->
        </div>
        <van-button class="but" type="info" @click="newAddxg">{{
          $t("hj58")
        }}</van-button>
      </div>
    </van-popup>
  </div>
</template>
<script>
import * as api from "@/axios/api";
import handleDt from "@/utils/deTh";
import { Notify } from "vant";
// getNewAdd
export default {
  props: {
    active: {
      type: String,
      default: "",
    },
    zxactive: {
      type: String,
      default: "",
    },
    sousuo: {
      type: String,
      default: "",
    },
    tabsList: {
      type: Array,
      default: [],
    },
  },
  watch: {
    active(e) {
      this.listArr = [];
      this.getStock(e, this.zxactive);
    },
    zxactive(e) {
      this.listArr = [];
      this.getStock(this.active, e);
    },
    sousuo(e) {
      this.listArr = [];
      this.getStock(this.active, this.zxactive);
    },
  },
  data() {
    return {
      fromData: {
        value: 1,
      },
      loadings: false,
      show: false,
      finished: false,
      listArr: [],
      pageNumVal: 1,
      shengouObj: {},
    };
  },
  mounted() {
    this.listArr = [];
    this.pageNumVal = 1;
    this.getStock(this.active, this.zxactive);
  },
  methods: {
    fromDatavalue(e) {
      this.fromData.value = e.target.value;
    },
    async newAddxg() {
      const res = await api.getNewAdd({
        newCode: this.shengouObj.code,
        applyNums: this.fromData.value,
      });
      if (res.status === 0) {
        console.log(333);
        Notify({ type: "success", message: res.msg });
      } else {
        Notify({ type: "warning", message: res.msg });
      }
    },
    shengou(item) {
      this.show = true;
      this.shengouObj = item;
    },
    filterSH(val) {
      if (val === "sh") {
        return 1;
      } else if (val === "bj" || val === "sz") {
        return 0;
      }
    },
    // 获取列表
    getStock: handleDt.debounce(async function (a, b) {
      a = this.active;
      let stockType = "";
      console.log(this.tabsList, a, this.active);
      if (a !== "") {
        let array = this.tabsList.filter((item) => item.key === a);
        stockType = array[0].name;
      }
      let opt = {
        // pageNum: this.pageNumVal,
        // pageSize: 15,
        // stockPlate: "",
        keyWords: this.sousuo,
        // stockType: stockType,
        // orderBy: "",
      };
      let data = await api.getStocklist(opt);
      this.loading = false;
      if (data.status === 0) {
        if (this.listArr.length >= data.data.total) {
          this.finished = true;
        }
        if (this.pageNumVal !== 1) {
          this.listArr = [...this.listArr, ...data.data.list];
        } else {
          this.listArr = data.data.list;
        }
      } else {
        this.loading = false;
        this.finished = true;
      }
    }, 500),
    onLoads() {
      if (!this.loading) {
        this.pageNumVal++;
        this.loading = true;
        this.getStock();
      }
    },
    optionszx() {},
  },
};
</script>
<style lang="less" scoped>
.popup-box {
  padding: 30px 20px;
  .input-box {
    height: 1.3rem;
    background: #f3f3f3;
    border-radius: 0.15rem;
    line-height: 1.3rem;
    padding-left: 10px;
    display: flex;
    padding-left: 0.2rem;
    font-size: 0.3975rem;
    .laber {
      margin-right: 10px;
    }
    // margin-top: 0.8rem;
  }
  .but {
    width: 100%;
    height: 1.3rem;
    border-radius: 0.15rem;
    background: #5c288c;
    color: #fff;
    font-size: 0.4615rem;
    margin-top: 0.5rem;
  }
  .shijian {
    width: 100%;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    .xgsj {
      margin-top: 10px;
      font-size: 0.3875rem;
      // font-weight: 600;
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      height: 50%;
      -webkit-box-align: center;
      -ms-flex-align: center;
      align-items: center;
      .sjtlt {
        width: 25%;
        margin-left: 0.4rem;
      }
    }
  }
}
.list-data {
  width: 100%;
  background-color: #fff;
  .header-box {
    padding: 20px 15px;
    color: rgb(140, 159, 173);
  }
}
.item {
  // width: 100%;
  margin: 12px 15px;
  padding-bottom: 15px;
  // display: flex;
  // justify-content: space-between;
  border-bottom: 1px solid #f0f2f3;
  .right_bs {
    text-align: center;
    border-radius: 0.05333rem;
    font-family: PingFang SC;
    font-style: normal;
    font-weight: 500;
    font-size: 0.32rem;
    line-height: 0.64rem;
    color: #fff;
    min-width: 2.13333rem;
    padding: 0 0.16rem;
    height: 0.64rem;
    background-color: rgb(3, 173, 143);
    font-weight: 900;
  }
  .green {
    background-color: rgb(3, 173, 143);
  }
  .red {
    background-color: rgb(208, 75, 100);
  }
}
.center_price {
  font-style: normal;
  font-weight: 500;
  font-size: 0.4rem;
  line-height: 0.56rem;
  text-align: right;
  color: #14181f;
  text-align: right;
  flex: 1;
  margin-right: 20px;
}
.title_color {
  font-style: normal;
  font-weight: 500;
  font-size: 0.4rem;
  line-height: 0.56rem;
  width: 4rem;
  text-align: left;
  color: #14181f;
}
.xgsgType {
  border-radius: 0.1rem;
  background-color: rgba(102, 204, 153, 0.1);
  border: 0.04rem solid #5ce398;
  color: #5ce398;
  text-align: center;
  line-height: 35px;
}
</style>