liyongli 2 年之前
父节点
当前提交
afec5b5d4e
共有 2 个文件被更改,包括 54 次插入25 次删除
  1. 11 1
      src/api/SilkRoadSpringGala.js
  2. 43 24
      src/view/SilkRoadShanShiPinList/index.vue

+ 11 - 1
src/api/SilkRoadSpringGala.js

@@ -84,7 +84,17 @@ export function getEnrollList(data) {
 export function getVote(data) {
   return ajax({
     url: "vote/vote",
-    method: "POST",
+    method: "GET",
+	urlType: "slikRoad",
+    data,
+  });
+}
+
+// 投票次数
+export function getTimes(data) {
+  return ajax({
+    url: "vote/times",
+    method: "GET",
 	urlType: "slikRoad",
     data,
   });

+ 43 - 24
src/view/SilkRoadShanShiPinList/index.vue

@@ -15,8 +15,10 @@
             "
           />
           <van-row>
-            <van-col span="18">{{ item.name }}</van-col>
-            <van-col span="6">
+            <van-col :span="config.times  ? 18 : 24">{{
+              item.name
+            }}</van-col>
+            <van-col span="6" v-if="config.times ">
               <van-button
                 type="primary"
                 size="mini"
@@ -42,8 +44,10 @@
             "
           />
           <van-row>
-            <van-col span="18">{{ item.name }}</van-col>
-            <van-col span="6">
+            <van-col :span="config.times  ? 18 : 24">{{
+              item.name
+            }}</van-col>
+            <van-col span="6" v-if="config.times ">
               <van-button
                 type="primary"
                 size="mini"
@@ -56,7 +60,6 @@
         </van-col>
       </van-row>
     </van-cell-group>
-    <br />
   </div>
 </template>
 <script setup>
@@ -64,7 +67,7 @@ import { ref, reactive } from "vue";
 import { showDialog, showConfirmDialog, showToast } from "vant";
 // import { onMounted, reactive } from "vue";
 // import { isIpad, isIpod, isIphone } from "../../utils/isTerminal";
-import { getEnrollList, getVote } from "@/api/SilkRoadSpringGala.js";
+import { getEnrollList, getVote, getTimes } from "@/api/SilkRoadSpringGala.js";
 /**
  * window.$originData.orginParames.title 页面标题
  * window.$originData.orginParames.parameters 固定参数值
@@ -75,6 +78,16 @@ const width = ref((w - 16) / 2);
 const height = ref(width.value * 0.57);
 const list = ref([]);
 const listSelf = ref([]);
+const config = reactive({
+  times: -1,
+});
+const login = reactive({
+  name: localStorage.getItem("SilkRoadShanShiPinName") || "",
+  phone:
+    window.$shanshipin.Phone ||
+    localStorage.getItem("SilkRoadShanShiPinPhone") ||
+    "",
+});
 Promise.all([
   getEnrollList({
     type: "团队",
@@ -89,11 +102,6 @@ Promise.all([
   listSelf.value = resList[1] || [];
 });
 
-const login = reactive({
-  name: localStorage.getItem("SilkRoadShanShiPinName") || "",
-  phone: localStorage.getItem("SilkRoadShanShiPinPhone") || "",
-});
-
 if (!login.phone) {
   showDialog({
     title: "登录",
@@ -125,6 +133,14 @@ if (!login.phone) {
       return true;
     },
   });
+} else {
+  getTimes({
+    phone: login.phone,
+  }).then(r => {
+    const t = window.$shanshipin.UserId ? 5 : 1;
+    console.log(r.times ,t)
+    config.times = r.times - t >= 0;
+  });
 }
 
 const toupiao = function (item) {
@@ -133,20 +149,23 @@ const toupiao = function (item) {
     beforeClose: type => {
       console.log(type);
       if (type !== "confirm") return true;
-      getVote({
-        target: item.phone,
-        source: login.phone,
-        client: window.$shanshipin.UserId ? "闪视频" : "其他",
-        operateId: 2,
-      })
-        .then(r => {
-          console.log("----------->",r);
-          showToast("投票成功!");
-          return true;
+      return new Promise((resolve) => {
+        getVote({
+          target: item.phone,
+          source: login.phone,
+          client: window.$shanshipin.UserId ? "闪视频" : "其他",
+          operateId: 2,
         })
-        .catch(() => {
-            return true
-        });
+          .then(r => {
+            console.log("----------->", r);
+            showToast("投票成功!");
+            resolve(true);
+          })
+          .catch(() => {
+            console.log("----------->");
+            resolve(true);
+          });
+      });
     },
   });
 };