aamin 1 год назад
Родитель
Сommit
c445e893c7

+ 178 - 17
houtai/src/pages/A1Rule/index.tsx

@@ -6,7 +6,17 @@ import React, {
   useState,
 } from "react";
 import styles from "./index.module.scss";
-import { Button, Form, Input, Modal, Popconfirm, Table } from "antd";
+import {
+  Button,
+  Form,
+  Input,
+  Modal,
+  Popconfirm,
+  Radio,
+  RadioChangeEvent,
+  Select,
+  Table,
+} from "antd";
 import { useDispatch, useSelector } from "react-redux";
 import { RootState } from "@/store";
 import { RulesTableType } from "@/types";
@@ -36,6 +46,31 @@ function A1Rule() {
 
   const [surScoreLimit, setSurScoreLimit] = useState({} as any);
 
+  const addMonths = useCallback((date: any, months: string) => {
+    // 复制传入的日期对象以避免修改原始对象
+    var result = new Date(date.getTime());
+    console.log(timestampToDate(result));
+
+    // 增加月份,同时处理由于增加月份可能导致的日期溢出问题
+    result.setDate(result.getDate() + parseInt(months));
+
+    // // 如果日期溢出(比如2月29日加上1个月),则手动调整到正确的最后一天
+    // if (result.getDate() < date.getDate()) {
+    //   result.setDate(0);
+    // }
+
+    return result;
+  }, []);
+
+  const changeClearMonth = useCallback(
+    (e: any) => {
+      // @ts-ignore
+      setNewDate(timestampToDate(addMonths(new Date(), e.target.value)));
+      setClearMonth(e.target.value);
+    },
+    [addMonths]
+  );
+
   const getList = useCallback(async () => {
     dispatch(getRuleAPI("game"));
     const onlineRes = await getOnlineRuleAPI("online");
@@ -45,9 +80,13 @@ function A1Rule() {
     const res = await getScoreLimitAPI(1);
     if (res.code === 0) {
       setSurScoreLimit(res.data);
-      // alert(res.data)
+      let resetScoreData = JSON.parse(res.data.description);
+      console.log(resetScoreData);
+      setIsClear(resetScoreData.hasReset ? 1 : 2);
+      setClearMonth(resetScoreData.period);
+      changeClearMonth({ target: { value: resetScoreData.period } });
     }
-  }, [dispatch]);
+  }, [changeClearMonth, dispatch]);
 
   // 积分上限窗口开关
   const [limitScoreShow, setLimitScoreShow] = useState(false);
@@ -56,26 +95,70 @@ function A1Rule() {
   const editId = useRef(0);
   // 编辑模式 1是游戏规则 2是线上展厅
   const editMode = useRef(1);
-  const openEditPageFu = useCallback(
-    (type: number, id: number) => {
-      // alert('编辑2')
-      editMode.current = type;
-      editId.current = id;
-      setEditPageShow(true);
-      // console.log(editPageShow, editMode.current);
-    },
-    [editPageShow]
-  );
+  const openEditPageFu = useCallback((type: number, id: number) => {
+    // alert('编辑2')
+    editMode.current = type;
+    editId.current = id;
+    setEditPageShow(true);
+    // console.log(editPageShow, editMode.current);
+  }, []);
+
+  // 积分是否清除相关
+  const [isClear, setIsClear] = useState(2);
+  const onChange = (e: RadioChangeEvent) => {
+    // 从转换成是
+    if (e.target.value === 1 && clearMonth === "null") {
+      setClearMonth(undefined);
+    }
+    setIsClear(e.target.value);
+  };
+
+  const [clearMonth, setClearMonth] = useState(undefined);
+  const [newDate, setNewDate] = useState();
+
+  const timestampToDate = (timestamp: any) => {
+    var date = new Date(timestamp);
+    var year = date.getFullYear();
+    var month = ("0" + (date.getMonth() + 1)).slice(-2);
+    var day = ("0" + date.getDate()).slice(-2);
+
+    return year + "年" + month + "月" + day + "日";
+  };
+
+  function getFirstDayOfMonth() {
+    var now = new Date(); // 获取当前时间
+    var year = now.getFullYear(); // 获取当前年份
+    var month = now.getMonth(); // 获取当前月份(注意:月份从0开始,0表示一月)
+
+    return `${year}-${month + 1}-1 00:00:01`; // 返回时间戳
+  }
 
   const [form] = Form.useForm();
-  const [form2] = Form.useForm();
 
   const onFinish = useCallback(
     async (values: any) => {
+      if (isClear === 1) {
+        if (!clearMonth) {
+          MessageFu.error("积分清零的日数不能为空!");
+          return;
+        }
+        if (clearMonth <= 0 || clearMonth > 301) {
+          MessageFu.error("积分清零的日数范围为1-300!");
+          return;
+        }
+      }
       if (values.numberVal) {
+        let desc = {
+          hasReset: isClear === 1 ? true : false,
+          createTime: isClear === 1 ? getFirstDayOfMonth() : "null",
+          period:
+            isClear === 1 ? parseInt(clearMonth ? clearMonth : "null") : "null",
+        };
+        console.log(desc);
         const data = {
           ...surScoreLimit,
           score: values.numberVal,
+          description: JSON.stringify(desc),
         };
         const res: any = await scoreLimitSaveAPI(data);
         if (res.code === 0) {
@@ -85,7 +168,7 @@ function A1Rule() {
         }
       }
     },
-    [getList, surScoreLimit]
+    [clearMonth, getList, isClear, surScoreLimit]
   );
 
   const columns = useMemo(() => {
@@ -185,7 +268,9 @@ function A1Rule() {
     <>
       <div className={styles.A1Rule}>
         <div className="ruleTop">
-          <div className="pageTitle">游戏规则 <span>游戏规则需用户刷新浏览器后生效</span></div>
+          <div className="pageTitle">
+            游戏规则 <span>游戏规则需用户刷新浏览器后生效</span>
+          </div>
           <button
             className="scoreLimitBtn"
             onClick={() => {
@@ -193,7 +278,8 @@ function A1Rule() {
               setLimitScoreShow(true);
             }}
           >
-            单日可获得积分上限:<span>{surScoreLimit.score}</span>
+            {/* 单日可获得积分上限:<span>{surScoreLimit.score}</span> */}
+            其他规则设置
           </button>
           {/* 表格主体 */}
           <div className="tableBox1">
@@ -265,6 +351,80 @@ function A1Rule() {
                 placeholder="请输入正整数,不超过999999999"
               />
             </Form.Item>
+
+            <Form.Item
+              label="积分清零"
+              name="isClear"
+              style={{ marginTop: "40px" }}
+              initialValue={isClear}
+              rules={[{ required: true, message: "不能为空!" }]}
+              hide-required-asterisk={true}
+            >
+              <Radio.Group onChange={onChange} value={isClear}>
+                <Radio value={1}>是</Radio>
+                <Radio value={2}>否</Radio>
+              </Radio.Group>
+            </Form.Item>
+            {isClear === 1 ? (
+              <Form.Item
+                label=""
+                name="clearMonth"
+                style={{ marginTop: "-15px", marginLeft: "30%" }}
+                hide-required-asterisk={true}
+                getValueFromEvent={(e) =>
+                  e.target.value.replace(/^(0+)|[^\d]+/g, "")
+                }
+              >
+                <span style={{ color: "red", marginRight: "10px" }}>*</span>每
+                {/* <Select
+                  value={clearMonth}
+                  onChange={changeClearMonth}
+                  placeholder="请选择"
+                  options={[
+                    { value: "1", label: "1" },
+                    { value: "2", label: "2" },
+                    { value: "3", label: "3" },
+                    { value: "4", label: "4" },
+                    { value: "5", label: "5" },
+                    { value: "6", label: "6" },
+                    { value: "7", label: "7" },
+                    { value: "8", label: "8" },
+                    { value: "9", label: "9" },
+                    { value: "10", label: "10" },
+                    { value: "11", label: "11" },
+                    { value: "12", label: "12" },
+                  ]}
+                  style={{
+                    width: "130px",
+                    height: "30px",
+                    margin: "0 5px",
+                  }}
+                /> */}
+                <Input
+                  style={{
+                    width: "150px",
+                    height: "30px",
+                    margin: "0 5px",
+                  }}
+                  defaultValue={clearMonth}
+                  maxLength={3}
+                  onChange={changeClearMonth}
+                  placeholder="请选择数字,1-300"
+                />
+                个自然日清空一次
+                {clearMonth ? (
+                  <div
+                    style={{
+                      color: "gray",
+                      marginTop: "10px",
+                      marginLeft: "5%",
+                    }}
+                  >
+                    将在{newDate}清空积分
+                  </div>
+                ) : null}
+              </Form.Item>
+            ) : null}
             {/* 确定和取消按钮 */}
             <br />
             <Form.Item wrapperCol={{ offset: 9, span: 16 }}>
@@ -278,6 +438,7 @@ function A1Rule() {
                 cancelText="取消"
                 onConfirm={() => {
                   setLimitScoreShow(false);
+                  getList();
                 }}
                 okButtonProps={{ loading: false }}
               >

+ 7 - 7
zhengquan/public/staticData/data.js

@@ -626,37 +626,37 @@ const dataAll = {
   gameList: [
     {
       id: 1,
-      name: '乡村林场',
+      name: '一起来植树',
       code: ''
     },
     {
       id: 2,
-      name: '助农课堂',
+      name: '一起来助农',
       code: ''
     },
     {
       id: 3,
-      name: '企业翻翻看',
+      name: '一起来记录',
       code: ''
     },
     {
       id: 4,
-      name: '抗体大作战',
+      name: '一起来作战',
       code: ''
     },
     {
       id: 5,
-      name: '应急救灾',
+      name: '一起来救灾',
       code: ''
     },
     {
       id: 6,
-      name: '生态保护',
+      name: '一起来清理',
       code: ''
     },
     {
       id: 7,
-      name: '找回走失儿童',
+      name: '一起找儿童',
       code: ''
     }
   ],

BIN
zhengquan/public/staticData/game/pc/1.jpg


BIN
zhengquan/public/staticData/game/pc/1.png


BIN
zhengquan/public/staticData/game/pc/2.jpg


BIN
zhengquan/public/staticData/game/pc/2.png


BIN
zhengquan/public/staticData/game/pc/3.jpg


BIN
zhengquan/public/staticData/game/pc/3.png


BIN
zhengquan/public/staticData/game/pc/4.jpg


BIN
zhengquan/public/staticData/game/pc/4.png


BIN
zhengquan/public/staticData/game/pc/5.jpg


BIN
zhengquan/public/staticData/game/pc/5.png


BIN
zhengquan/public/staticData/game/pc/6.jpg


BIN
zhengquan/public/staticData/game/pc/6.png


BIN
zhengquan/public/staticData/game/pc/7.jpg


BIN
zhengquan/public/staticData/game/pc/7.png


+ 10 - 2
zhengquan/src/App.vue

@@ -9,10 +9,18 @@ onMounted(() => {
   // @ts-ignore
   store.dataAll = dataAll;
 
+  // 判断是否为首次进入场景
+  // 登录过就不算是首次
+  if (localStorage.getItem('isFirstEnterScene') == 'false') {
+    localStorage.setItem('isFirstEnterScene', 'false')
+  } else {
+    localStorage.setItem('isFirstEnterScene', 'true')
+  }
+
   // 重置alert标题
-  window.alert = function(name){
+  window.alert = function (name) {
     const iframe = document.createElement("IFRAME");
-    iframe.style.display="none";
+    iframe.style.display = "none";
     iframe.setAttribute("src", 'data:text/plain,');
     document.documentElement.appendChild(iframe);
     window.frames[0].window.alert(name);

+ 0 - 1
zhengquan/src/stores/index.ts

@@ -9,7 +9,6 @@ export const useStore = defineStore('home', {
       // 所有热点列表
       hotspots: [] as any,
       token: '',
-      isFirstTimeGoScene: true,
       userInfo: {} as any,
       currentUnit: {} as any,
       isShowGameThumb: true,

+ 6 - 1
zhengquan/src/views/Home/components/unitList.vue

@@ -140,6 +140,11 @@ onMounted(() => {
           <div class="bottom-left">
             <h2>{{ curUnit ? curUnit.title : '' }}</h2>
             <div class="left-disc">{{ curUnit ? curUnit.disc : '' }}</div>
+            <!-- 项目列表 -->
+            <!-- <div class="project-list" >
+              项目案例
+              <img src="" alt="">
+            </div> -->
           </div>
         </div>
       </div>
@@ -178,7 +183,7 @@ onMounted(() => {
           </div>
           <div v-if="startItem + item - 1 < store.dataAll.welfareList.length"
             :class="store.dataAll.welfareList[startItem + item - 1].title.length > 8 ? 'item-name' : ''"
-            :style="{ whiteSpace: 'nowrap' }"> {{ store.dataAll.welfareList[startItem + item -
+            :style="{ whiteSpace: 'nowrap', marginTop: '-0.2vh' }"> {{ store.dataAll.welfareList[startItem + item -
               1] ? store.dataAll.welfareList[startItem + item - 1].title : '' }}</div>
         </div>
       </div>

+ 124 - 18
zhengquan/src/views/Scene/ScenePage.vue

@@ -235,8 +235,8 @@ const checkLoginStatus = async () => {
   }
 }
 
-const Toast = (text: string) => {
-  let toastDom:HTMLElement = document.createElement('div')
+const Toast = (text: string, type?: string) => {
+  let toastDom: HTMLElement = document.createElement('div')
   toastDom.innerText = text
   toastDom.style.padding = '5px 15px'
   toastDom.style.display = 'flex'
@@ -249,10 +249,11 @@ const Toast = (text: string) => {
   toastDom.style.background = '#fff'
   toastDom.style.zIndex = '99'
   toastDom.style.borderRadius = '50px'
-  toastDom.style.boxShadow='0px 4px 16px 0px rgba(0, 0, 0, 0.5)'
+  toastDom.style.boxShadow = '0px 4px 16px 0px rgba(0, 0, 0, 0.5)'
   toastDom.style.fontSize = '15px'
+  toastDom.style.color = type == 'error' ? 'red' : 'black'
   document.body.appendChild(toastDom);
-  
+
   setTimeout(() => {
     document.body.removeChild(toastDom);
   }, 2000)
@@ -309,12 +310,13 @@ const isPassChange = ref(false)
 
 
 const changePassword = () => {
+
   if (oldPass.value == '' || newPass.value == '' || affirmPass.value == '') {
-    Toast('密码不能为空');
-    // alert('密码不能为空')
+    Toast('密码不能为空', 'error');
+  } else if (!/^[a-zA-Z0-9]{6,12}$/.test(oldPass.value) || !/^[a-zA-Z0-9]{6,12}$/.test(newPass.value) || !/^[a-zA-Z0-9]{6,12}$/.test(affirmPass.value)) {
+    Toast('密码格式不正确', 'error')
   } else if (newPass.value != affirmPass.value) {
-    // alert('两次密码不一致')
-    Toast('两次密码不一致')
+    Toast('两次密码不一致', 'error')
   } else {
     console.log(oldPass.value, newPass.value, affirmPass.value)
     const pwdNewEncrypted = encodeStr(Base64.encode(newPass.value))
@@ -329,12 +331,16 @@ const changePassword = () => {
         newPassword: pwdNewEncrypted,
         oldPassword: pwdOldEncrypted
       }
-    }).then(() => {
-      alert('修改成功,请重新进行登录')
-      // Toast)
-      logout()
-      isLogin.value = false
-      isPassChange.value = false
+    }).then((res: any) => {
+      if (res.data.code == 0) {
+        Toast('修改成功,请重新进行登录')
+        // Toast)
+        logout()
+        isLogin.value = false
+        isPassChange.value = false
+      } else {
+        Toast(res.data.msg, 'error')
+      }
     })
   }
 }
@@ -383,10 +389,27 @@ watch(() => store.customThemeId, () => {
 
 })
 
+// 首次进入且没有登录
+const isFirstEnterScene = ref(false)
+
+const changeFirstEnterScene = () => {
+  isFirstEnterScene.value = false
+  localStorage.setItem('isFirstEnterScene', 'false')
+}
+
+
+
 
 onMounted(() => {
   getAllHotspot()
 
+  // 首次打开场景且没有登录打开弹窗
+  if (localStorage.getItem('isFirstEnterScene') === 'true' && !localStorage.getItem('token') && !localStorage.getItem('userInfo')) {
+    setTimeout(() => {
+      isFirstEnterScene.value = true
+    }, 1000)
+  }
+
   setTimeout(() => {
     store.isShowGameThumb ? isShowExperienceGame.value = true : store.isShowGameThumb = true
   }, 500)
@@ -558,6 +581,33 @@ const changePassFu = () => {
     <img class="backBtn" v-show="isShowFigure && currentUnit.code != 'SHANGJJ' && currentUnit.code != 'FFF'"
       src="@/assets/images/scene/back.png" alt="" @click="goBack()">
 
+    <!-- 首次进入场景且未登录时,显示弹窗 -->
+    <div class="first-box" v-show="isFirstEnterScene">
+      <div class="box-content">
+        <div class="text">完成<bottom @click="() => {
+          router.push({
+            path: 'homePageMo',
+            query: {
+              src: '/game/index.html#/sign-up'
+            }
+          })
+          changeFirstEnterScene()
+        }">注册</bottom>或<bottom @click="() => { goLogin(); changeFirstEnterScene() }">登陆</bottom>
+          后,体验互动游戏,可以获得积分。<br v-show="browser.mobile" />积分可以在
+          <bottom @click="() => {
+            router.push({
+              path: 'homePageMo',
+              query: {
+                src: '/game/index.html#/shop-for-visitor'
+              }
+            })
+            changeFirstEnterScene()
+          }">商城</bottom>中兑换奖品。
+        </div>
+        <div class="i-know" @click="changeFirstEnterScene()">我知道了</div>
+      </div>
+    </div>
+
     <!-- 回到主页按钮 -->
     <div class="backHome" v-show="isShowFigure" @click="() => { router.replace('/home') }">
       <img src="@/assets/images/scene/backHome.png" alt="">
@@ -682,12 +732,14 @@ const changePassFu = () => {
     <!-- 修改密码弹窗 -->
     <div class="passChangeBox" v-if="isPassChange">
       <div class="conttent">
-        <div><span style="margin-right: 20px;">旧密码:</span><input v-model="oldPass" type="password" placeholder="请输入旧密码">
+        <div><span style="margin-right: 20px;">旧密码:</span><input v-model="oldPass" type="password"
+            placeholder="请输入6-10个数字或字母">
         </div>
-        <div><span style="margin-right: 20px;">新密码:</span><input v-model="newPass" type="password" placeholder="请输入新密码">
+        <div><span style="margin-right: 20px;">新密码:</span><input v-model="newPass" type="password"
+            placeholder="请输入6-10个数字或字母">
         </div>
         <div><span style="margin-right: 5px;">确认密码:</span><input v-model="affirmPass" type="password"
-            placeholder="请确认新密码">
+            placeholder="请输入6-10个数字或字母">
         </div>
         <div class="btns">
           <div @click="changePassword">修改密码</div>
@@ -782,7 +834,7 @@ const changePassFu = () => {
         justify-content: space-between;
 
         div {
-          width: 20%;
+          max-width: 30%;
           height: 30px;
           text-align: center;
           line-height: 30px;
@@ -807,6 +859,60 @@ const changePassFu = () => {
     cursor: pointer;
   }
 
+  .first-box {
+    width: 100%;
+    height: 100%;
+    position: fixed;
+    z-index: 99;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+
+    .box-content {
+      padding: 30px;
+      background: rgba(0, 0, 0, 0.5);
+      border-radius: 10px;
+      color: white;
+      line-height: 35px;
+      display: flex;
+      flex-direction: column;
+      justify-content: center;
+      align-items: center;
+
+      .text {
+        display: -webkit-inline-box;
+        // align-items: center;
+
+        bottom {
+          padding: 5px 20px;
+          font-size: 14px;
+          border: white solid 1px;
+          border-radius: 10px;
+          height: 30px;
+          cursor: pointer;
+          height: 20px;
+          margin: 0 5px;
+        }
+
+      }
+
+      .i-know {
+        width: 200px;
+        color: black;
+        background: white;
+        border-radius: 10px;
+        border: 1px solid rgba(0, 0, 0, 0.5);
+        cursor: pointer;
+        display: flex;
+        justify-content: center;
+        margin-top: 20px;
+      }
+
+
+    }
+
+  }
+
   .backHome {
     width: 40px;
     height: 40px;

+ 2 - 1
zhengquan/src/views/WelcomePage/WelcomePage.vue

@@ -14,6 +14,7 @@ const router = useRouter()
 const countDownNumber = ref(5)
 
 onMounted(() => {
+  
   let timer = setInterval(() => {
     if (countDownNumber.value > 0) {
       countDownNumber.value--;
@@ -95,7 +96,7 @@ onMounted(() => {
   }
 }
 
-@media screen and (max-width: 700px)  {
+@media screen and (max-width: 700px) {
   .welcome-page {
     .logo {
       position: absolute;