yangg преди 2 месеца
родител
ревизия
0aa3762404

+ 6 - 0
pages.json

@@ -93,6 +93,12 @@
 			"style": {
 				"navigationBarTitleText": "用户协议"
 			}
+		},
+		{
+			"path": "pages/test/test",
+			"style": {
+				"navigationBarTitleText": "测试页面"
+			}
 		}
 	],
 	

+ 200 - 0
pages/test/test.vue

@@ -0,0 +1,200 @@
+<template>
+    <view class="container">
+      <view class="progress">
+        进度: {{ currentQuestionIndex + 1 }}/{{ questions.length }}
+      </view>
+      <scroll-view 
+        scroll-y 
+        :scroll-top="scrollTop" 
+        scroll-with-animation 
+        class="scroll-view"
+        :style="{height: scrollHeight + 'px'}"
+      >
+        <view 
+          v-for="(item, index) in questions" 
+          :key="item.id" 
+          class="question-item"
+          :id="'question-' + index"
+        >
+          <view class="question">{{ item.question }}</view>
+          <view 
+            v-for="option in item.options" 
+            :key="option.value"
+            class="option"
+            @click="selectAnswer(index, option.value)"
+            :class="{ 'selected': selectedAnswers[index] === option.value }"
+          >
+            {{ option.label }}
+          </view>
+          <button 
+            v-if="index === questions.length - 1 && selectedAnswers[index]" 
+            class="submit-btn" 
+            @click="submit"
+          >
+            提交
+          </button>
+        </view>
+      </scroll-view>
+    </view>
+  </template>
+  
+  <script>
+  export default {
+    data() {
+      return {
+        questions: [
+          { id: 1, question: "问题1", options: [{value: 'A', label: '选项A'}, {value: 'B', label: '选项B'},{value: 'c', label: '选项c'},{value: 'D', label: '选项D'}] },
+          { id: 2, question: "问题2", options: [{value: 'A', label: '选项A'}, {value: 'B', label: '选项B'},{value: 'c', label: '选项c'},{value: 'D', label: '选项D'}] },
+          { id: 3, question: "问题3", options: [{value: 'A', label: '选项A'}, {value: 'B', label: '选项B'},{value: 'c', label: '选项c'},{value: 'D', label: '选项D'}] },
+          { id: 4, question: "问题4", options: [{value: 'A', label: '选项A'}, {value: 'B', label: '选项B'},{value: 'c', label: '选项c'},{value: 'D', label: '选项D'}] },
+          { id: 5, question: "问题5", options: [{value: 'A', label: '选项A'}, {value: 'B', label: '选项B'},{value: 'c', label: '选项c'},{value: 'D', label: '选项D'}] },
+          { id: 6, question: "问题6", options: [{value: 'A', label: '选项A'}, {value: 'B', label: '选项B'},{value: 'c', label: '选项c'},{value: 'D', label: '选项D'}] },
+          { id: 7, question: "问题7", options: [{value: 'A', label: '选项A'}, {value: 'B', label: '选项B'},{value: 'c', label: '选项c'},{value: 'D', label: '选项D'}] },
+          { id: 8, question: "问题8", options: [{value: 'A', label: '选项A'}, {value: 'B', label: '选项B'},{value: 'c', label: '选项c'},{value: 'D', label: '选项D'}] },
+          { id: 9, question: "问题9", options: [{value: 'A', label: '选项A'}, {value: 'B', label: '选项B'},{value: 'c', label: '选项c'},{value: 'D', label: '选项D'}] },
+           { id: 10, question: "问题10", options: [{value: 'A', label: '选项A'}, {value: 'B', label: '选项B'},{value: 'c', label: '选项c'},{value: 'D', label: '选项D'}] },
+            { id: 11, question: "问题11", options: [{value: 'A', label: '选项A'}, {value: 'B', label: '选项B'},{value: 'c', label: '选项c'},{value: 'D', label: '选项D'}] },
+            { id: 12, question: "问题12", options: [{value: 'A', label: '选项A'}, {value: 'B', label: '选项B'},{value: 'c', label: '选项c'},{value: 'D', label: '选项D'}] },
+            { id: 13, question: "问题13", options: [{value: 'A', label: '选项A'}, {value: 'B', label: '选项B'},{value: 'c', label: '选项c'},{value: 'D', label: '选项D'}] },
+            { id: 14, question: "问题14", options: [{value: 'A', label: '选项A'}, {value: 'B', label: '选项B'},{value: 'c', label: '选项c'},{value: 'D', label: '选项D'}] },
+          // 更多问题...
+        ],
+        selectedAnswers: [],
+        scrollTop: 0,
+        currentQuestionIndex: 0,
+        scrollHeight: 0,
+        scrollDelay: 500,
+        questionPositions: []  // 用于存储每个问题的位置
+      }
+    },
+    onLoad() {
+      const res = uni.getSystemInfoSync();
+      this.scrollHeight = res.windowHeight;
+      
+      // 延迟一下,确保DOM已经渲染
+      setTimeout(() => {
+        this.calculateQuestionPositions();
+      }, 300);
+    },
+    methods: {
+      selectAnswer(index, value) {
+        this.$set(this.selectedAnswers, index, value);
+        
+        if (index < this.questions.length - 1) {
+          setTimeout(() => {
+            this.currentQuestionIndex = index + 1;
+            this.scrollToQuestion(this.currentQuestionIndex);
+          }, this.scrollDelay);
+        } else {
+          setTimeout(() => {
+            this.scrollToBottom();
+          }, this.scrollDelay);
+        }
+      },
+      goToNext(index) {
+        if (index < this.questions.length - 1) {
+          this.currentQuestionIndex = index + 1;
+          this.scrollToQuestion(this.currentQuestionIndex);
+        }
+      },
+      calculateQuestionPositions() {
+        uni.createSelectorQuery()
+          .selectAll('.question-item')
+          .boundingClientRect(rects => {
+            if (rects) {
+              let accumulatedHeight = 0;
+              this.questionPositions = rects.map(rect => {
+                accumulatedHeight += rect.height;
+                return accumulatedHeight - rect.height;
+              });
+            }
+          })
+          .exec();
+      },
+      scrollToQuestion(index) {
+        if (this.questionPositions[index] !== undefined) {
+          this.scrollTop = this.questionPositions[index];
+        }
+      },
+      scrollToBottom() {
+        const lastIndex = this.questions.length - 1;
+        if (this.questionPositions[lastIndex] !== undefined) {
+          this.scrollTop = this.questionPositions[lastIndex] + 200; // 额外滚动以显示提交按钮
+        }
+      },
+      submit() {
+        uni.showToast({
+          title: '提交成功',
+          icon: 'success'
+        });
+        // 这里可以添加提交逻辑
+      }
+    }
+  }
+  </script>
+  
+  <style>
+  .container {
+    position: relative;
+    background-color: #f5f5f5;
+  }
+  
+  .progress {
+    position: fixed;
+    top: 10px;
+    right: 10px;
+    background: rgba(0,0,0,0.5);
+    color: white;
+    padding: 5px 10px;
+    border-radius: 10px;
+    font-size: 12px;
+    z-index: 100;
+  }
+  
+  .scroll-view {
+    width: 100%;
+  }
+  
+  .question-item {
+    /* min-height: 100vh; */
+    padding: 20px;
+    box-sizing: border-box;
+    display: flex;
+    flex-direction: column;
+    justify-content: flex-start;
+    background-color: #f5f5f5;
+  }
+  
+  .question {
+    font-size: 16px;
+    margin-bottom: 20px;
+    color: #333;
+  }
+  
+  .option {
+    padding: 15px;
+    margin: 10px 0;
+    border: 1px solid #eee;
+    border-radius: 5px;
+    background-color: #fff;
+    color: #333;
+  }
+  
+  .option.selected {
+    background-color: #f0f0f0;
+    border-color: #007AFF;
+  }
+  
+  .submit-btn {
+    margin-top: 20px;
+    background-color: #4F4FFF;
+    color: white;
+    border-radius: 5px;
+    font-size: 14px;
+    width: 80px;
+    height: 36px;
+    line-height: 36px;
+    text-align: center;
+    align-self: flex-end;
+  }
+  </style>

+ 1 - 0
unpackage/dist/dev/mp-weixin/app.js

@@ -17,6 +17,7 @@ if (!Math) {
   "./pages/preview/preview.js";
   "./pages/interview_success/interview_success.js";
   "./pages/agreement/agreement.js";
+  "./pages/test/test.js";
 }
 const _sfc_main = {
   onLaunch: function() {

+ 2 - 1
unpackage/dist/dev/mp-weixin/app.json

@@ -13,7 +13,8 @@
     "pages/interview-question/interview-question",
     "pages/preview/preview",
     "pages/interview_success/interview_success",
-    "pages/agreement/agreement"
+    "pages/agreement/agreement",
+    "pages/test/test"
   ],
   "window": {
     "navigationBarTextStyle": "black",

+ 0 - 51
unpackage/dist/dev/mp-weixin/pages/privacy/privacy.js

@@ -1,51 +0,0 @@
-"use strict";
-const common_vendor = require("../../common/vendor.js");
-const api_user = require("../../api/user.js");
-const _sfc_main = {
-  data() {
-    return {
-      agreementContent: "",
-      loading: true,
-      error: false,
-      errorMsg: "加载失败,请重试"
-    };
-  },
-  onLoad() {
-    this.fetchAgreement();
-  },
-  methods: {
-    goBack() {
-      common_vendor.index.navigateBack();
-    },
-    fetchAgreement() {
-      this.loading = true;
-      this.error = false;
-      api_user.getUserAgreement().then((res) => {
-        console.log(res);
-        this.loading = false;
-        this.agreementContent = res.content || "";
-        console.log(this.agreementContent);
-      }).catch((err) => {
-        console.error("获取用户协议失败:", err);
-        this.error = true;
-        this.errorMsg = "网络异常,请稍后重试";
-      }).finally(() => {
-        this.loading = false;
-      });
-    }
-  }
-};
-function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
-  return common_vendor.e({
-    a: $data.loading
-  }, $data.loading ? {} : $data.error ? {
-    c: common_vendor.t($data.errorMsg),
-    d: common_vendor.o((...args) => $options.fetchAgreement && $options.fetchAgreement(...args))
-  } : {
-    e: $data.agreementContent
-  }, {
-    b: $data.error
-  });
-}
-const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
-wx.createPage(MiniProgramPage);

+ 0 - 4
unpackage/dist/dev/mp-weixin/pages/privacy/privacy.json

@@ -1,4 +0,0 @@
-{
-  "navigationBarTitleText": "隐私政策",
-  "usingComponents": {}
-}

+ 0 - 1
unpackage/dist/dev/mp-weixin/pages/privacy/privacy.wxml

@@ -1 +0,0 @@
-<view class="agreement-container"><scroll-view scroll-y class="agreement-content"><view wx:if="{{a}}" class="loading"><text>加载中...</text></view><view wx:elif="{{b}}" class="error"><text>{{c}}</text><button class="retry-btn" bindtap="{{d}}">重新加载</button></view><rich-text wx:else nodes="{{e}}"></rich-text></scroll-view></view>

+ 0 - 88
unpackage/dist/dev/mp-weixin/pages/privacy/privacy.wxss

@@ -1,88 +0,0 @@
-
-.agreement-container {
-  /* display: flex;
-  flex-direction: column; */
-  height: 100vh;
-  background-color: #fff;
-}
-.agreement-header {
-  display: flex;
-  align-items: center;
-  justify-content: space-between;
-  height: 90rpx;
-  background-color: #fff;
-  padding: 0 30rpx;
-  position: relative;
-  border-bottom: 1rpx solid #eee;
-}
-.back-btn {
-  width: 60rpx;
-  height: 60rpx;
-  display: flex;
-  align-items: center;
-  justify-content: center;
-}
-.icon-back {
-  font-size: 40rpx;
-  color: #333;
-}
-.title {
-  font-size: 34rpx;
-  font-weight: 500;
-  color: #333;
-}
-.placeholder {
-  width: 60rpx;
-}
-.agreement-content {
-  width: 100%;
-  padding: 20rpx 30rpx;
-  box-sizing: border-box;
-  background-color: #fff;
-}
-.agreement-title {
-  font-size: 36rpx;
-  font-weight: bold;
-  text-align: center;
-  margin-bottom: 40rpx;
-  color: #333;
-}
-.section {
-  margin-bottom: 30rpx;
-}
-.section-title {
-  font-size: 32rpx;
-  font-weight: 500;
-  color: #333;
-  margin-bottom: 20rpx;
-}
-.section-content {
-  font-size: 28rpx;
-  color: #666;
-  line-height: 1.6;
-}
-.paragraph {
-  display: block;
-  margin-bottom: 20rpx;
-  text-align: justify;
-}
-.loading, .error {
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-  justify-content: center;
-  padding: 40rpx;
-  color: #666;
-  font-size: 28rpx;
-}
-.error {
-  color: #ff4d4f;
-}
-.retry-btn {
-  margin-top: 20rpx;
-  padding: 10rpx 30rpx;
-  background-color: #1890ff;
-  color: #fff;
-  border-radius: 8rpx;
-  font-size: 28rpx;
-}

+ 117 - 0
unpackage/dist/dev/mp-weixin/pages/test/test.js

@@ -0,0 +1,117 @@
+"use strict";
+const common_vendor = require("../../common/vendor.js");
+const _sfc_main = {
+  data() {
+    return {
+      questions: [
+        { id: 1, question: "问题1", options: [{ value: "A", label: "选项A" }, { value: "B", label: "选项B" }, { value: "c", label: "选项c" }, { value: "D", label: "选项D" }] },
+        { id: 2, question: "问题2", options: [{ value: "A", label: "选项A" }, { value: "B", label: "选项B" }, { value: "c", label: "选项c" }, { value: "D", label: "选项D" }] },
+        { id: 3, question: "问题3", options: [{ value: "A", label: "选项A" }, { value: "B", label: "选项B" }, { value: "c", label: "选项c" }, { value: "D", label: "选项D" }] },
+        { id: 4, question: "问题4", options: [{ value: "A", label: "选项A" }, { value: "B", label: "选项B" }, { value: "c", label: "选项c" }, { value: "D", label: "选项D" }] },
+        { id: 5, question: "问题5", options: [{ value: "A", label: "选项A" }, { value: "B", label: "选项B" }, { value: "c", label: "选项c" }, { value: "D", label: "选项D" }] },
+        { id: 6, question: "问题6", options: [{ value: "A", label: "选项A" }, { value: "B", label: "选项B" }, { value: "c", label: "选项c" }, { value: "D", label: "选项D" }] },
+        { id: 7, question: "问题7", options: [{ value: "A", label: "选项A" }, { value: "B", label: "选项B" }, { value: "c", label: "选项c" }, { value: "D", label: "选项D" }] },
+        { id: 8, question: "问题8", options: [{ value: "A", label: "选项A" }, { value: "B", label: "选项B" }, { value: "c", label: "选项c" }, { value: "D", label: "选项D" }] },
+        { id: 9, question: "问题9", options: [{ value: "A", label: "选项A" }, { value: "B", label: "选项B" }, { value: "c", label: "选项c" }, { value: "D", label: "选项D" }] },
+        { id: 10, question: "问题10", options: [{ value: "A", label: "选项A" }, { value: "B", label: "选项B" }, { value: "c", label: "选项c" }, { value: "D", label: "选项D" }] },
+        { id: 11, question: "问题11", options: [{ value: "A", label: "选项A" }, { value: "B", label: "选项B" }, { value: "c", label: "选项c" }, { value: "D", label: "选项D" }] },
+        { id: 12, question: "问题12", options: [{ value: "A", label: "选项A" }, { value: "B", label: "选项B" }, { value: "c", label: "选项c" }, { value: "D", label: "选项D" }] },
+        { id: 13, question: "问题13", options: [{ value: "A", label: "选项A" }, { value: "B", label: "选项B" }, { value: "c", label: "选项c" }, { value: "D", label: "选项D" }] },
+        { id: 14, question: "问题14", options: [{ value: "A", label: "选项A" }, { value: "B", label: "选项B" }, { value: "c", label: "选项c" }, { value: "D", label: "选项D" }] }
+        // 更多问题...
+      ],
+      selectedAnswers: [],
+      scrollTop: 0,
+      currentQuestionIndex: 0,
+      scrollHeight: 0,
+      scrollDelay: 500,
+      questionPositions: []
+      // 用于存储每个问题的位置
+    };
+  },
+  onLoad() {
+    const res = common_vendor.index.getSystemInfoSync();
+    this.scrollHeight = res.windowHeight;
+    setTimeout(() => {
+      this.calculateQuestionPositions();
+    }, 300);
+  },
+  methods: {
+    selectAnswer(index, value) {
+      this.$set(this.selectedAnswers, index, value);
+      if (index < this.questions.length - 1) {
+        setTimeout(() => {
+          this.currentQuestionIndex = index + 1;
+          this.scrollToQuestion(this.currentQuestionIndex);
+        }, this.scrollDelay);
+      } else {
+        setTimeout(() => {
+          this.scrollToBottom();
+        }, this.scrollDelay);
+      }
+    },
+    goToNext(index) {
+      if (index < this.questions.length - 1) {
+        this.currentQuestionIndex = index + 1;
+        this.scrollToQuestion(this.currentQuestionIndex);
+      }
+    },
+    calculateQuestionPositions() {
+      common_vendor.index.createSelectorQuery().selectAll(".question-item").boundingClientRect((rects) => {
+        if (rects) {
+          let accumulatedHeight = 0;
+          this.questionPositions = rects.map((rect) => {
+            accumulatedHeight += rect.height;
+            return accumulatedHeight - rect.height;
+          });
+        }
+      }).exec();
+    },
+    scrollToQuestion(index) {
+      if (this.questionPositions[index] !== void 0) {
+        this.scrollTop = this.questionPositions[index];
+      }
+    },
+    scrollToBottom() {
+      const lastIndex = this.questions.length - 1;
+      if (this.questionPositions[lastIndex] !== void 0) {
+        this.scrollTop = this.questionPositions[lastIndex] + 200;
+      }
+    },
+    submit() {
+      common_vendor.index.showToast({
+        title: "提交成功",
+        icon: "success"
+      });
+    }
+  }
+};
+function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
+  return {
+    a: common_vendor.t($data.currentQuestionIndex + 1),
+    b: common_vendor.t($data.questions.length),
+    c: common_vendor.f($data.questions, (item, index, i0) => {
+      return common_vendor.e({
+        a: common_vendor.t(item.question),
+        b: common_vendor.f(item.options, (option, k1, i1) => {
+          return {
+            a: common_vendor.t(option.label),
+            b: option.value,
+            c: common_vendor.o(($event) => $options.selectAnswer(index, option.value), option.value),
+            d: $data.selectedAnswers[index] === option.value ? 1 : ""
+          };
+        }),
+        c: index === $data.questions.length - 1 && $data.selectedAnswers[index]
+      }, index === $data.questions.length - 1 && $data.selectedAnswers[index] ? {
+        d: common_vendor.o((...args) => $options.submit && $options.submit(...args), item.id)
+      } : {}, {
+        e: item.id,
+        f: "question-" + index
+      });
+    }),
+    d: $data.scrollTop,
+    e: $data.scrollHeight + "px"
+  };
+}
+const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
+wx.createPage(MiniProgramPage);

+ 4 - 0
unpackage/dist/dev/mp-weixin/pages/test/test.json

@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "测试页面",
+  "usingComponents": {}
+}

+ 1 - 0
unpackage/dist/dev/mp-weixin/pages/test/test.wxml

@@ -0,0 +1 @@
+<view class="container"><view class="progress"> 进度: {{a}}/{{b}}</view><scroll-view scroll-y scroll-top="{{d}}" scroll-with-animation class="scroll-view" style="{{'height:' + e}}"><view wx:for="{{c}}" wx:for-item="item" wx:key="e" class="question-item" id="{{item.f}}"><view class="question">{{item.a}}</view><view wx:for="{{item.b}}" wx:for-item="option" wx:key="b" bindtap="{{option.c}}" class="{{['option', option.d && 'selected']}}">{{option.a}}</view><button wx:if="{{item.c}}" class="submit-btn" bindtap="{{item.d}}"> 提交 </button></view></scroll-view></view>

+ 58 - 0
unpackage/dist/dev/mp-weixin/pages/test/test.wxss

@@ -0,0 +1,58 @@
+
+.container {
+    position: relative;
+    background-color: #f5f5f5;
+}
+.progress {
+    position: fixed;
+    top: 10px;
+    right: 10px;
+    background: rgba(0,0,0,0.5);
+    color: white;
+    padding: 5px 10px;
+    border-radius: 10px;
+    font-size: 12px;
+    z-index: 100;
+}
+.scroll-view {
+    width: 100%;
+}
+.question-item {
+    /* min-height: 100vh; */
+    padding: 20px;
+    box-sizing: border-box;
+    display: flex;
+    flex-direction: column;
+    justify-content: flex-start;
+    background-color: #f5f5f5;
+}
+.question {
+    font-size: 16px;
+    margin-bottom: 20px;
+    color: #333;
+}
+.option {
+    padding: 15px;
+    margin: 10px 0;
+    border: 1px solid #eee;
+    border-radius: 5px;
+    background-color: #fff;
+    color: #333;
+}
+.option.selected {
+    background-color: #f0f0f0;
+    border-color: #007AFF;
+}
+.submit-btn {
+    margin-top: 20px;
+    background-color: #4F4FFF;
+    color: white;
+    border-radius: 5px;
+    font-size: 14px;
+    width: 80px;
+    height: 36px;
+    line-height: 36px;
+    text-align: center;
+    align-self: flex-end;
+}
+