소스 검색

收藏和错题改版完

JXDS18FUJT 2 년 전
부모
커밋
c923508d77
6개의 변경된 파일235개의 추가작업 그리고 105개의 파일을 삭제
  1. 8 0
      src/api/modules/user.js
  2. 17 10
      src/components/m-do-topic/m-do-topic.vue
  3. 137 69
      src/otherPages/collection/index.vue
  4. 1 1
      src/otherPages/userInfoAuth/index.vue
  5. 2 4
      src/pages/carVideo/index.vue
  6. 70 21
      src/pages/user/index.vue

+ 8 - 0
src/api/modules/user.js

@@ -95,6 +95,14 @@ const user = {
 			method:'GET',
 			params
 		})
+	},
+	//更新昵称、手机号码、头像
+	userInfoUserInfo(params){
+		return request({
+			url:'/user/info/userInfo',
+			method:'GET',
+			params
+		})
 	}
 }
 

+ 17 - 10
src/components/m-do-topic/m-do-topic.vue

@@ -1165,7 +1165,8 @@ export default {
       });
     },
     collectTopics(e) {
-      let userCollectionIds = uni.getStorageSync("userCollectionIds") || [];
+      let storageName = uni.getStorageSync("userInfo").xcxOpenid+'_userCollectionIds_'+this.query.subject
+      let userCollectionIds = uni.getStorageSync(storageName) || [];
 
       if (!this.problemList[this.problemListIndex].isCollect) {
         if (
@@ -1174,7 +1175,7 @@ export default {
           )
         ) {
           userCollectionIds.push(this.problemList[this.problemListIndex].id);
-          uni.setStorageSync("userCollectionIds", userCollectionIds);
+          uni.setStorageSync(storageName, userCollectionIds);
         }
         this.$set(this.problemList[this.problemListIndex], "isCollect", true);
         uni.showToast({
@@ -1192,7 +1193,7 @@ export default {
             ),
             1
           );
-          uni.setStorageSync("userCollectionIds", userCollectionIds);
+          uni.setStorageSync(storageName, userCollectionIds);
         }
 
         this.$set(this.problemList[this.problemListIndex], "isCollect", false);
@@ -1259,6 +1260,7 @@ export default {
       return String.fromCharCode(index + 65);
     },
     confirmMult(e) {
+      let storageName = uni.getStorageSync("userInfo").xcxOpenid+'_userWrongIds_'+this.query.subject
       this.$set(this.problemList[this.problemListIndex], "isCompleted", true);
       if (
         JSON.stringify(
@@ -1278,12 +1280,12 @@ export default {
           : this.errQuestionIds.push(
               this.problemList[this.problemListIndex].id
             );
-        let userWrongIds = uni.getStorageSync("userWrongIds") || [];
+        let userWrongIds = uni.getStorageSync(storageName) || [];
         if (
           !userWrongIds.includes(this.problemList[this.problemListIndex].id)
         ) {
           userWrongIds.push(this.problemList[this.problemListIndex].id);
-          uni.setStorageSync("userWrongIds", userWrongIds);
+          uni.setStorageSync(storageName, userWrongIds);
         }
         // 目前改为保存本地
         // api.exam.studentQuestionWrong({
@@ -1353,19 +1355,20 @@ export default {
     changeRadioGroup(e) {
       console.log(e, "changeRadioGroup");
       // #ifdef MP-WEIXIN
+      let storageName = uni.getStorageSync("userInfo").xcxOpenid+ '_userWrongIds_'+this.query.subject
       this.$set(this.problemList[this.problemListIndex], "isCompleted", true);
       if (e.detail == this.problemList[this.problemListIndex].answer) {
         this.trueNum = this.trueNum + 1;
         this.$emit("update:trueNum", this.trueNum);
       } else {
         this.falseNum = this.falseNum + 1;
-        let userWrongIds = uni.getStorageSync("userWrongIds") || [];
+        let userWrongIds = uni.getStorageSync(storageName) || [];
 
         if (
           !userWrongIds.includes(this.problemList[this.problemListIndex].id)
         ) {
           userWrongIds.push(this.problemList[this.problemListIndex].id);
-          uni.setStorageSync("userWrongIds", userWrongIds);
+          uni.setStorageSync(storageName, userWrongIds);
         }
 
         //目前改为保存在本地,降低服务器压力
@@ -1481,6 +1484,7 @@ export default {
   },
   mounted() {
     let that = this;
+    let storageName=''
     uni.showLoading({
       title: "加载题目中",
     });
@@ -1505,8 +1509,9 @@ export default {
     //   })
 
     // }
-
+    
     switch (that.type) {
+      
       case "specify":
         api.exam
           .studentQuestionInfoGetQuestionInfoByIds({
@@ -1657,9 +1662,10 @@ export default {
         break;
       case "wrong":
         //studentQuestionWrongWrongByUser(废弃)
+         storageName = uni.getStorageSync("userInfo").xcxOpenid+'_userWrongIds_'+this.query.subject
         api.exam
           .studentQuestionInfoGetQuestionInfoByIds({
-            ids: uni.getStorageSync("userWrongIds")?uni.getStorageSync("userWrongIds").join(","):'',
+            ids: uni.getStorageSync(storageName)?uni.getStorageSync(storageName).join(","):null,
           })
           .then((res) => {
             console.log(res);
@@ -1695,9 +1701,10 @@ export default {
 
         break;
       case "collect":
+          storageName = uni.getStorageSync("userInfo").xcxOpenid+'_userCollectionIds_'+this.query.subject
         api.exam
           .studentQuestionInfoGetQuestionInfoByIds({
-            ids: uni.getStorageSync("userCollectionIds")?uni.getStorageSync("userCollectionIds").join(","):'',
+            ids: uni.getStorageSync(storageName)?uni.getStorageSync(storageName).join(","):null,
           })
           .then((res) => {
             console.log(res);

+ 137 - 69
src/otherPages/collection/index.vue

@@ -137,9 +137,9 @@
         "
         @confirm="syncWrongQuestion"
         :columns="[
-          { text: '合并本机和云端收藏', type: 'wrong', value: 0 },
-          { text: '备份本机收藏到云端', type: 'wrong', value: 1 },
-          { text: '恢复云端收藏到本机', type: 'wrong', value: 2 },
+          { text: '合并本机和云端错题', type: 'wrong', value: 0 },
+          { text: '备份本机错题到云端', type: 'wrong', value: 1 },
+          { text: '恢复云端错题到本机', type: 'wrong', value: 2 },
         ]"
         show-toolbar
         title="同步错题"
@@ -213,19 +213,31 @@ export default {
       wrongSyncShow: false,
       collectSyncShow: false,
       wrongList: [],
-      wrongListCount: uni.getStorageSync("userWrongIds")
-        ? uni.getStorageSync("userWrongIds").length
-        : 0,
+      wrongListCount: 0,
 
       collectionList: [],
-      collectionListCount: uni.getStorageSync("userCollectionIds")
-        ? uni.getStorageSync("userCollectionIds").length
-        : 0,
+      collectionListCount: 0,
     };
   },
   onLoad(query) {
     this.query = query;
     this.user;
+    let storageName1 =
+      uni.getStorageSync("userInfo").xcxOpenid +
+      "_userWrongIds_" +
+      this.query.subject;
+
+    let storageName2 =
+      uni.getStorageSync("userInfo").xcxOpenid +
+      "_userCollectionIds_" +
+      this.query.subject;
+
+    this.wrongListCount = uni.getStorageSync(storageName1)
+      ? uni.getStorageSync(storageName1).length
+      : 0;
+    this.collectionListCount = uni.getStorageSync(storageName2)
+      ? uni.getStorageSync(storageName2).length
+      : 0;
 
     // api.exam
     //   .studentQuestionWrongWrongCountByUser({
@@ -241,51 +253,75 @@ export default {
   methods: {
     syncCollectQuestion(e) {
       let select = e.detail.value;
+      let storageName =
+        uni.getStorageSync("userInfo").xcxOpenid +
+        "_userCollectionIds_" +
+        this.query.subject;
+      uni.getStorageSync(storageName)
+        ? ""
+        : uni.setStorageSync(storageName, []);
       switch (select.value) {
-      case 0:
+        case 0:
           api.exam
-            .studentQuestionCollectionBakCollections({
+            .studentQuestionCollectionCollections({
               km: Number(this.query.subject),
-              questionIds: uni
-                .getStorageSync("userCollectionIds")
-                .map((item) => item),
+              questionIds: uni.getStorageSync(storageName).map((item) => item),
             })
             .then((res) => {
-              api.exam.studentQuestionCollectionCollectionByUser().then((result) => {
-                let userCollectionIds = result.data.map((item) => {
-                  return item.id;
+              uni.showToast({
+                title:"合并成功"
+              })
+              api.exam
+                .studentQuestionCollectionCollectionByUser({
+                  km: Number(this.query.subject),
+                })
+                .then((result) => {
+                  let userCollectionIds = result.data.map((item) => {
+                    return item.id;
+                  });
+                  uni.setStorageSync(storageName, userCollectionIds);
+                  this.collectionListCount = userCollectionIds.length;
                 });
-                uni.setStorageSync("userCollectionIds", userCollectionIds);
-                this.collectionListCount = userCollectionIds.length;
-              });
             });
           break;
         case 1:
           api.exam
-            .studentQuestionWrongBakWrongs({
+            .studentQuestionCollectionBakCollections({
               km: Number(this.query.subject),
-              questionIds: uni
-                .getStorageSync("userCollectionIds")
-                .map((item) => item),
+              questionIds: uni.getStorageSync(storageName).map((item) => item),
             })
             .then((res) => {
-              api.exam.studentQuestionWrongWrongByUser().then((result) => {
-                let userCollectionIds = result.data.map((item) => {
-                  return item.id;
+               uni.showToast({
+                title:"备份成功"
+              })
+              api.exam
+                .studentQuestionCollectionCollectionByUser({
+                  km: Number(this.query.subject),
+                })
+                .then((result) => {
+                  let userCollectionIds = result.data.map((item) => {
+                    return item.id;
+                  });
+                  uni.setStorageSync(storageName, userCollectionIds);
+                  this.collectionListCount = userCollectionIds.length;
                 });
-                uni.setStorageSync("userCollectionIds", userCollectionIds);
-                this.collectionListCount = userCollectionIds.length;
-              });
             });
           break;
         case 2:
-          api.exam.studentQuestionWrongWrongByUser().then((result) => {
-            let userCollectionIds = result.data.map((item) => {
-              return item.id;
+          api.exam
+            .studentQuestionCollectionCollectionByUser({
+              km: Number(this.query.subject),
+            })
+            .then((result) => {
+               uni.showToast({
+                title:"恢复成功"
+              })
+              let userCollectionIds = result.data.map((item) => {
+                return item.id;
+              });
+              uni.setStorageSync(storageName, userCollectionIds);
+              this.collectionListCount = userCollectionIds.length;
             });
-            uni.setStorageSync("userCollectionIds", userCollectionIds);
-            this.collectionListCount = userCollectionIds.length;
-          });
           break;
         default:
           break;
@@ -294,52 +330,77 @@ export default {
     },
     syncWrongQuestion(e) {
       let select = e.detail.value;
+      let storageName =
+        uni.getStorageSync("userInfo").xcxOpenid +
+        "_userWrongIds_" +
+        this.query.subject;
+      uni.getStorageSync(storageName)
+        ? ""
+        : uni.setStorageSync(storageName, []);
+
       console.log(e);
       switch (select.value) {
         case 0:
           api.exam
             .studentQuestionWrongWrongs({
               km: Number(this.query.subject),
-              questionIds: uni
-                .getStorageSync("userWrongIds")
-                .map((item) => item),
+              questionIds: uni.getStorageSync(storageName).map((item) => item),
             })
             .then((res) => {
-              api.exam.studentQuestionWrongWrongByUser().then((result) => {
-                let userWrongIds = result.data.map((item) => {
-                  return item.id;
+              uni.showToast({
+                title:'合并成功'
+              })
+              api.exam
+                .studentQuestionWrongWrongByUser({
+                  km: Number(this.query.subject),
+                })
+                .then((result) => {
+                  let userWrongIds = result.data.map((item) => {
+                    return item.id;
+                  });
+                  uni.setStorageSync(storageName, userWrongIds);
+                  this.wrongListCount = userWrongIds.length;
                 });
-                uni.setStorageSync("userWrongIds", userWrongIds);
-                this.wrongListCount = userWrongIds.length;
-              });
             });
           break;
         case 1:
           api.exam
             .studentQuestionWrongBakWrongs({
               km: Number(this.query.subject),
-              questionIds: uni
-                .getStorageSync("userWrongIds")
-                .map((item) => item),
+              questionIds: uni.getStorageSync(storageName).map((item) => item),
             })
             .then((res) => {
-              api.exam.studentQuestionWrongWrongByUser().then((result) => {
-                let userWrongIds = result.data.map((item) => {
-                  return item.id;
+               uni.showToast({
+                title:'备份成功'
+              })
+              api.exam
+                .studentQuestionWrongWrongByUser({
+                  km: Number(this.query.subject),
+                })
+                .then((result) => {
+                  let userWrongIds = result.data.map((item) => {
+                    return item.id;
+                  });
+                  uni.setStorageSync(storageName, userWrongIds);
+                  this.wrongListCount = userWrongIds.length;
                 });
-                uni.setStorageSync("userWrongIds", userWrongIds);
-                this.wrongListCount = userWrongIds.length;
-              });
             });
           break;
         case 2:
-          api.exam.studentQuestionWrongWrongByUser().then((result) => {
-            let userWrongIds = result.data.map((item) => {
-              return item.id;
+          api.exam
+            .studentQuestionWrongWrongByUser({
+              km: Number(this.query.subject),
+            })
+            .then((result) => {
+               uni.showToast({
+                title:'恢复成功'
+              })
+              let userWrongIds = result.data.map((item) => {
+                return item.id;
+              });
+              uni.setStorageSync(storageName, userWrongIds);
+              this.wrongListCount = userWrongIds.length;
             });
-            uni.setStorageSync("userWrongIds", userWrongIds);
-            this.wrongListCount = userWrongIds.length;
-          });
           break;
         default:
           break;
@@ -377,22 +438,26 @@ export default {
     },
     clearTopics(type) {
       let that = this;
+      let storageName = "";
       if (type === "wrong") {
-        uni.showModal({
+        storageName = uni.showModal({
           title: "是否清空错题",
           success(res) {
+            let storageName =
+              uni.getStorageSync("userInfo").xcxOpenid +
+              "_userWrongIds_" +
+              that.query.subject;
             if (res.confirm) {
               api.exam
                 .studentQuestionWrongCancelAll({
                   carType: that.gsMap[that.query.gs],
-                  km: that.query.subject === "1" ? "科目一" : "科目四",
+                  km: Number(that.query.subject),
                 })
                 .then((res) => {
-                  uni.setStorageSync("userWrongIds", []);
+                  uni.setStorageSync(storageName, []);
                   api.exam
                     .studentQuestionWrongWrongCountByUser({
-                      carType: that.gsMap[that.query.gs],
-                      km: that.query.subject === "1" ? "科目一" : "科目四",
+                      km: Number(that.query.subject),
                       pageNum: 1,
                       pageSize: 10000,
                     })
@@ -407,18 +472,21 @@ export default {
         uni.showModal({
           title: "是否清空收藏题",
           success(res) {
+            let storageName =
+              uni.getStorageSync("userInfo").xcxOpenid +
+              "_userCollectionIds_" +
+              that.query.subject;
             if (res.confirm) {
               api.exam
                 .studentQuestionCollectionCancelAll({
-                  carType: that.gsMap[that.query.gs],
-                  km: that.query.subject === "1" ? "科目一" : "科目四",
+                  km: Number(that.query.subject),
                 })
                 .then((res) => {
-                  uni.setStorageSync("userCollectionIds", []);
+                  uni.setStorageSync(storageName, []);
                   api.exam
                     .studentQuestionCollectionCollectionCountByUser({
                       carType: that.gsMap[that.query.gs],
-                      km: that.query.subject === "1" ? "科目一" : "科目四",
+                      km: Number(that.query.subject),
                       pageNum: 1,
                       pageSize: 10000,
                     })

+ 1 - 1
src/otherPages/userInfoAuth/index.vue

@@ -29,7 +29,7 @@ import api from '@/api'
 export default {
     data() {
         return {
-            headImage: "https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0",
+            headImage: "http://tmp/ekMKUCOq9knR5cb11ccf64e25bcec14a65f89951c334.jpeg",
             nickName: ""
         }
     },

+ 2 - 4
src/pages/carVideo/index.vue

@@ -34,12 +34,10 @@
     </van-tabs> -->
     <!-- #ifdef MP-WEIXIN -->
     <topbar>
-      <userInfoHead :userData="userData"></userInfoHead>
+      <!-- <userInfoHead :userData="userData"></userInfoHead> -->
     </topbar>
     <!-- #endif -->
-    <!-- #ifdef MP-TOUTIAO -->
-    <userInfoHead :userData="userData"></userInfoHead>
-    <!-- #endif -->
+ 
     <view>
       <swiper :indicator-dots="false" style="height: 200rpx">
         <swiper-item class="swiperBanner">

+ 70 - 21
src/pages/user/index.vue

@@ -3,19 +3,24 @@
     <scroll-view scroll-y class="bg">
       <div class="user">
         <van-cell custom-class="head-cell" is-link label-class="" center>
-          <view class="flex" slot="title">
-            <image class="user-headImg" v-if="userInfo.headImage" :src="userInfo.headImage"></image>
+          <button open-type="getPhoneNumber" @getphonenumber="getPhoneByUser" class="userButton" slot="title">
+            <image
+              class="user-headImg"
+              v-if="userInfo.headImage"
+              :src="userInfo.headImage"
+            ></image>
             <image class="user-headImg" v-else :src="unLoginHead"></image>
-            <view class="" style="width:50%;padding-left: 24rpx;">
-              <view style="font-size:38rpx;color: #0A1A33;">{{ userInfo.nickName }}</view>
-              <!-- <view style="font-size:26rpx;color: #8A9099;"> {{ '未绑定手机号' }}</view> -->
-
+            <view class="flex" style="width: 60%; padding-left: 24rpx;text-align:left;">
+              <view style="font-size: 38rpx; color: #0a1a33;width: 100%;">{{
+                userInfo.nickName || "新用户"
+              }}</view>
+              <view style="font-size: 26rpx; color: #8a9099;width: 100%;">
+                {{ "点击绑定手机号" }}</view
+              >
             </view>
-
-          </view>
+          </button>
         </van-cell>
 
-
         <!-- <van-cell title="我要提现" value="" is-link center @click="goCashOut">
         </van-cell> -->
         <!-- <van-cell title="我的下级" value="" is-link center @click="goMyBranch">
@@ -43,11 +48,29 @@
 
         <!-- #endif -->
         <!-- #ifdef MP-TOUTIAO -->
-        <van-cell v-if="!isVip" title="会员有效期" :value="'开通会员'" is-link center url="/otherPages/buyVip/index">
+        <van-cell
+          v-if="!isVip"
+          title="会员有效期"
+          :value="'开通会员'"
+          is-link
+          center
+          url="/otherPages/buyVip/index"
+        >
         </van-cell>
-        <van-cell v-if="isVip" title="会员有效期" :value="'已开通'" is-link center>
+        <van-cell
+          v-if="isVip"
+          title="会员有效期"
+          :value="'已开通'"
+          is-link
+          center
+        >
         </van-cell>
-        <van-cell title="资料下载" is-link @click="goVipPath('/otherPages/pdfList/index')" center>
+        <van-cell
+          title="资料下载"
+          is-link
+          @click="goVipPath('/otherPages/pdfList/index')"
+          center
+        >
           <template #icon>
             <m-icon type="fkbz" class="cell-icon" />
           </template>
@@ -65,15 +88,28 @@
         <!-- #endif -->
       </div>
       <view class="list">
-        <van-cell title-class="uni-app-fontsize-paragraph" title="电子资料" is-link
-          @click="goPath('/pages/extraWeb/index?src=https://nbjk-h5.zzxcx.net/pdfImages')" center>
+        <van-cell
+          title-class="uni-app-fontsize-paragraph"
+          title="电子资料"
+          is-link
+          @click="
+            goPath(
+              '/pages/extraWeb/index?src=https://nbjk-h5.zzxcx.net/pdfImages'
+            )
+          "
+          center
+        >
           <template #icon>
             <m-icon type="fkbz" class="cell-icon" />
           </template>
         </van-cell>
       </view>
       <view class="wxad">
-        <ad ad-type="video" :ad-intervals="100" unit-id="adunit-8eb44bbd7e3147d4"></ad>
+        <ad
+          ad-type="video"
+          :ad-intervals="100"
+          unit-id="adunit-8eb44bbd7e3147d4"
+        ></ad>
       </view>
 
       <!-- <view class="ad-box serviceBox">
@@ -106,11 +142,12 @@ export default {
   },
   mounted() {
     this.$store.dispatch("GetInfo");
-
   },
   methods: {
+    getPhoneByUser(e) {
+      console.log(e);
+    },
     goPath(url) {
-
       uni.navigateTo({
         url,
       });
@@ -123,7 +160,7 @@ export default {
       } else {
         uni.showToast({
           title: "vip才能使用",
-          icon: 'none'
+          icon: "none",
         });
       }
     },
@@ -168,12 +205,26 @@ export default {
   flex-wrap: wrap;
   flex-direction: row;
 }
+.userButton::after {
+  border: 0;
+}
+.userButton {
+   border: 0;
+  display: flex;
+  flex-wrap: wrap;
+  flex-direction: row;
+  background: transparent;
+  align-items: flex-start;
+  height: auto;
+  padding: 0;
+  line-height: 1.4;
+}
 
 .bg {
   width: 100%;
   min-height: 812rpx;
   // background: #fff;
-  background-image: url('https://ct.zzxcx.net/ctjk/mp-wx/user/bg.png');
+  background-image: url("https://ct.zzxcx.net/ctjk/mp-wx/user/bg.png");
 }
 
 .list {
@@ -183,8 +234,6 @@ export default {
 .user {
   padding: 0 15rpx;
 
-
-
   /* height: 100vh; */
   .group {
     margin: 10px 0;