Browse Source

vip的功能添加

zhangyujun 3 years ago
parent
commit
05587c49da

+ 17 - 0
src/api/modules/code.js

@@ -0,0 +1,17 @@
+import request from '../request'
+
+const code = {
+
+	//激活码
+	studentVipCode(params) {
+		return request({
+			url: "student/vip/code",
+			method: "PUT",
+            params
+		})
+	}
+
+
+}
+
+export default code

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

@@ -67,6 +67,14 @@ const exam = {
 			params
 		})
 	},
+	//查询免费的题库
+	studentQuestionInfoSelectFreeQuestionInfo(params) {
+		return request({
+			url: "student/question/info/selectFreeQuestionInfo",
+			method: 'get',
+			params
+		})
+	},
 	//新增模拟考成绩
 	studentScoreInfo(data) {
 		return request({

BIN
src/assets/img/douyin.png


BIN
src/assets/img/jihuoma.png


+ 54 - 0
src/otherPages/buyVip/component/userHead.vue

@@ -0,0 +1,54 @@
+<template>
+  <view class="box">
+    <view style="height: 38rpx; width: 100%"></view>
+    <image
+      class="box-headImg"
+      v-if="userInfo.headImage"
+      :src="userInfo.headImage"
+    ></image>
+    <image class="box-headImg" v-else :src="unLoginHead"></image>
+    <view  v-if="userInfo.nickName" class="box-name">{{userInfo.nickName}}</view>
+    <view  v-if="!userInfo.nickName" class="box-name">新用户</view>
+  </view>
+</template>
+
+<script>
+import unLoginHead from "@/assets/img/unLoginHead.png";
+export default {
+  data() {
+    return {
+      unLoginHead: unLoginHead,
+    };
+  },
+  computed: {
+    userInfo() {
+        console.log(this.$store.state.user.userInfo)
+      return this.$store.state.user.userInfo;
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.box {
+  width: 100%;
+  height: 316rpx;
+  justify-content: center;
+  display: flex;
+  flex-wrap: wrap;
+  align-content: flex-start;
+  align-items: flex-start;
+  background: linear-gradient(180deg, #498ef5 0%, #4da8e6 100%);
+  .box-headImg {
+    width: 120rpx;
+    height: 120rpx;
+    border-radius: 50%;
+  }
+  .box-name {
+    width: 100%;
+    color: #fff;
+    text-align: center;
+    margin-top: 20rpx;
+  }
+}
+</style>

+ 178 - 257
src/otherPages/buyVip/index.vue

@@ -1,121 +1,124 @@
 <template>
   <view>
-    <m-nav-bar title="开通会员" :transparent="true" />
-    <div class="buyvip-box">
-      <img class="top-img" :src="topImg" alt="头部背景" />
-      <div class="info-warn">您还未开通完整版系统,付费购买后享受更多功能</div>
-      <div class="item-box">
-        <van-cell class="cell-title" title="选择充值方式" />
-        <div class="radio-box">
-          <div
-            v-for="(item, index) in goodsList"
-            class="radio-item"
-            :class="{ select: index === goodsIndex }"
-            :key="index"
+    <userHead></userHead>
+    <view class="content">
+      <view class="vip">
+        <view
+          class="vip-item"
+          style="background: #e1e9f5; border: 2rpx solid #498ef5"
+          @click="
+            () => {
+              vipCodeVisible = true;
+            }
+          "
+        >
+          <view class="vip-item-icon"> <image :src="jihuoma"></image> </view>
+          <text style="font-size: 26rpx; color: #498ef5; margin-left: 18rpx"
+            >激活码激活</text
+          >
+        </view>
+        
+        <view
+          v-if="ios_vip_open||!isIos"
+          class="vip-item"
+          style="background: #feeaee; border: 2px solid #fe2c55"
+        >
+          <view>
+            <view @click="buy" style="display: flex; align-items: center">
+              <view class="vip-item-icon"> <image :src="douyin"></image> </view>
+
+              <text style="font-size: 26rpx; color: #fe2c55; margin-left: 18rpx"
+                >抖音充值激活\n
+                <text
+                  ><text style="font-size: 36rpx">{{ price }}元</text>
+                  <text
+                    style="margin-left: 12rpx; text-decoration: line-through"
+                    >{{ orginPrice }}元</text
+                  ></text
+                >
+              </text>
+            </view>
+            <!-- <view style="display: flex; align-items: center;margin-top:18rpx;">
+              <view>
+                <text style="color: #ff4d53; font-size: 44rpx">
+                  {{ price }}<text style="font-size: 26rpx;margin-right:14rpx;">元</text></text
+                >
+                <text style="color: #ff4d53; font-size: 26rpx">
+                  {{ orginPrice }}元</text
+                >
+              </view>
+            </view> -->
+          </view>
+        </view>
+      </view>
+    </view>
+    <van-overlay :show="vipCodeVisible">
+      <view class="popUps">
+        <view class="content">
+          <view
             @click="
               () => {
-                goodsIndex = index;
+                vipCodeVisible = false;
               }
             "
+            class="close"
+          >
+            <van-icon name="cross" size="24px" />
+          </view>
+
+          <view
+            style="
+              width: 100%;
+              text-align: center;
+              font-size: 30rpx;
+              margin-top: 20rpx;
+            "
+            >提示</view
           >
-            <span>{{ item.dictLabel }}</span>
-            <div v-if="index === 1" class="radio-item-recom">推荐</div>
-            <span>¥{{ item.dictValue.split(",")[0] }}</span>
-            <span>原价{{ item.dictValue.split(",")[1] }}元</span>
-          </div>
-        </div>
-      </div>
-      <div class="item-box">
-        <van-cell class="cell-title" title="使用说明" />
-        <div class="readme">
-          <span>1. 有效期内拥有VIP权限.</span>
-          <span>2. 过期后可以使用免费用户的权限.</span>
-          <span>3. 可以续费.</span>
-        </div>
-      </div>
-      <div class="button-box">
-        <div v-if="!isIos" class="button" @click="buy">立即开通</div>
-        <div v-if="isIos && !ios_vip_open" class="button_gray">ios不支持</div>
-        <div v-if="isIos && ios_vip_open" class="button" @click="buy">
-          立即开通
-        </div>
-      </div>
-      <div style="height: 60px"></div>
-    </div>
+          <view
+            style="
+              width: 100%;
+              text-align: center;
+              color: #5c6066;
+              font-size: 26rpx;
+              margin-top: 40rpx;
+            "
+            >您还未开通系统,请输入激活码开通!</view
+          >
+          <input
+            v-model="vipCode"
+            placeholder-style="font-size:13px"
+            class="content-input"
+            placeholder="请输入激活码"
+          />
+          <view @click="sendVipCode" class="content-open"> 立即开通 </view>
+        </view>
+      </view>
+    </van-overlay>
   </view>
 </template>
 
 <script>
-import topImg from "./top-background.png";
 import api from "@/api/index";
+import userHead from "./component/userHead.vue";
+import douyin from "@/assets/img/douyin.png";
+import jihuoma from "@/assets/img/jihuoma.png";
 export default {
   data() {
     return {
-      isIos: false,
+      douyin,
+      isIos:false,
       ios_vip_open: 0,
-      goodsList: [
-        {
-          searchValue: null,
-          createBy: "admin",
-          createTime: "2021-11-18 18:01:26",
-          updateTime: null,
-          updateBy: null,
-          remark: null,
-          params: {},
-          dictCode: 29,
-          dictSort: 0,
-          dictLabel: "一个月",
-          dictValue: "38,48,30",
-          dictType: "vip_type_price",
-          cssClass: null,
-          listClass: null,
-          isDefault: "N",
-          status: "0",
-          default: false,
-        },
-        {
-          searchValue: null,
-          createBy: "admin",
-          createTime: "2021-11-18 18:01:39",
-          updateTime: null,
-          updateBy: null,
-          remark: null,
-          params: {},
-          dictCode: 30,
-          dictSort: 0,
-          dictLabel: "六个月",
-          dictValue: "68,98,180",
-          dictType: "vip_type_price",
-          cssClass: null,
-          listClass: null,
-          isDefault: "N",
-          status: "0",
-          default: false,
-        },
-        {
-          searchValue: null,
-          createBy: "admin",
-          createTime: "2021-11-18 18:01:50",
-          updateTime: null,
-          updateBy: null,
-          remark: null,
-          params: {},
-          dictCode: 31,
-          dictSort: 0,
-          dictLabel: "两年",
-          dictValue: "98,128,730",
-          dictType: "vip_type_price",
-          cssClass: null,
-          listClass: null,
-          isDefault: "N",
-          status: "0",
-          default: false,
-        },
-      ],
-      goodsIndex: 1,
-      topImg,
+      jihuoma,
+      price: 0,
+      orginPrice: 0,
+      vipCodeVisible: false,
+      vipCode: "",
     };
   },
+  components: {
+    userHead,
+  },
   methods: {
     buy(e) {
       //studentTtPrepareOrder
@@ -136,11 +139,26 @@ export default {
         uni.pay({
           orderInfo: res.data,
           service: 5,
+          success(res) {},
         });
+        this.$store.dispatch("GetInfo");
       });
 
       //#endif
     },
+    sendVipCode() {
+      api.code
+        .studentVipCode({
+          vipCode: this.vipCode,
+        })
+        .then((res) => {
+          uni.showToast({
+            title: res.msg,
+            icon: "none",
+          });
+          this.$store.dispatch("GetInfo");
+        });
+    },
   },
   mounted() {
     const systemInfo = wx.getSystemInfoSync();
@@ -157,29 +175,10 @@ export default {
     //#ifdef MP-TOUTIAO
     this.goodsIndex = 0;
     api.buy.systemConfigConfigKey("vip_price").then((res) => {
-      api.buy.systemConfigConfigKey("vip_price_original").then((result) => {
-        this.goodsList = [
-          {
-            searchValue: null,
-            createBy: "admin",
-            createTime: "2021-11-18 18:01:26",
-            updateTime: null,
-            updateBy: null,
-            remark: null,
-            params: {},
-            dictCode: 29,
-            dictSort: 0,
-            dictLabel: "终身会员",
-            dictValue: res.data + "," + result.data,
-            dictType: "vip_type_price",
-            cssClass: null,
-            listClass: null,
-            isDefault: "N",
-            status: "0",
-            default: false,
-          },
-        ];
-      });
+      this.price = res.data;
+    });
+    api.buy.systemConfigConfigKey("vip_price_original").then((res) => {
+      this.orginPrice = res.data;
     });
     //#endif
   },
@@ -196,152 +195,74 @@ export default {
 </script>
 
 <style scoped lang="scss">
-.buyvip-box {
-  width: 100%;
-  margin-top: -50px;
-  min-height: 100vh;
+.popUps {
   display: flex;
+  justify-content: center;
+  align-content: center;
   align-items: center;
-  flex-direction: column;
-  background: #ffdda6;
-  .top-img {
-    width: 100%;
-  }
-  .info-warn {
-    width: 345px;
-    height: 49px;
-    background: #ffffff;
-    border-radius: 10px;
+  width: 100%;
+  height: 100vh;
+
+  .content {
+    width: 590rpx;
+    height: 480rpx;
+    background: #fff;
+    border-radius: 20rpx;
     display: flex;
     justify-content: center;
-    align-items: center;
-    font-size: 13px;
-    font-family: PingFang SC;
-    font-weight: 400;
-    color: #91540f;
-    margin-top: -70px;
-    margin-bottom: 10px;
-  }
-  .item-box {
-    width: 345px;
-    background: #ffffff;
-    border-radius: 10px;
-    padding: 15px;
-    margin-bottom: 10px;
-    .cell-title {
-      font-size: 16px;
-      font-family: PingFang SC;
-      font-weight: bold;
-      line-height: 20px;
-      color: #0a1a33;
-      margin-left: -10px;
-      margin-bottom: 15px;
+    align-content: flex-start;
+    align-items: flex-start;
+    flex-wrap: wrap;
+    position: relative;
+    .close {
+      position: absolute;
+      right: 30rpx;
     }
-  }
-  .readme {
-    display: flex;
-    flex-direction: column;
-    font-size: 13px;
-    line-height: 20px;
-    span {
-      margin-bottom: 5px;
+    .content-input {
+      width: 500rpx;
+      height: 60rpx;
+      background: rgba(242, 243, 245, 0.39);
+      border: 2rpx solid #e8e8e8;
+      opacity: 1;
+      border-radius: 30rpx;
+      padding-left: 15rpx;
+      margin-top: 40rpx;
     }
-  }
-  .radio-box {
-    display: flex;
-    justify-content: space-around;
-    align-items: center;
-    .select {
-      background: #fcf1de !important;
-    }
-    .radio-item {
-      position: relative;
-      .radio-item-recom {
-        position: absolute;
-        top: 0;
-        width: 30px;
-        height: 15px;
-        line-height: 15px;
-        font-size: 10px;
-        background: #ff4d53;
-        border-radius: 0%;
-        right: 0;
-        transform: translate(15%, -30%);
-        border-radius: 5px 0px 5px 0px;
-        color: #fff;
-      }
-    }
-    div {
-      width: 98px;
-      font-size: 20px;
-      display: flex;
-      flex-direction: column;
-      align-items: center;
-      justify-content: space-around;
-      background: #ffffff;
-      border: 1px solid #faca93;
-      height: 124px;
-      border-radius: 5px;
-      span {
-        font-family: PingFang SC;
-        &:nth-of-type(1) {
-          font-size: 13px;
-          font-weight: bold;
-          color: #91540f;
-        }
-        &:nth-of-type(2) {
-          font-size: 30px;
-          font-weight: bold;
-          color: #ff4d53;
-        }
-        &:nth-of-type(3) {
-          font-size: 11px;
-          font-weight: 400;
-          color: #8a9099;
-          text-decoration: line-through;
-        }
-      }
+    .content-open {
+      width: 200rpx;
+      height: 60rpx;
+      font-size: 26rpx;
+      background: #498ef5;
+      border-radius: 30rpx;
+      margin-top: 40rpx;
+      color: #fff;
+      line-height: 60rpx;
+      text-align: center;
     }
   }
-  .button-box {
-    position: fixed;
-    background-color: #ffffff;
-    bottom: 0;
-    width: 375px;
-    height: 60px;
+}
+.content {
+  padding-top: 20rpx;
+  padding-left: 30rpx;
+  padding-right: 30rpx;
+  .vip {
     display: flex;
-    justify-content: center;
-    align-items: center;
-    .button_gray {
-      width: 152px;
-      height: 40px;
-      background: #b1b1b1;
-      border-radius: 30px;
-      display: flex;
-      justify-content: center;
-      align-items: center;
-      font-size: 15px;
-      font-family: PingFang SC;
-      font-weight: 500;
-      color: #fff;
-      letter-spacing: 0px;
-    }
-    .button {
-      width: 152px;
-      height: 40px;
-      background: #faca93;
-      border-radius: 30px;
+    justify-content: space-between;
+    .vip-item {
+      width: 334rpx;
+      height: 200rpx;
       display: flex;
       justify-content: center;
+      align-content: center;
       align-items: center;
-      font-size: 15px;
-      font-family: PingFang SC;
-      font-weight: 500;
-      color: #91540f;
-      letter-spacing: 0px;
-
-      &:active {
-        background-color: red;
+      border-radius: 20rpx;
+      .vip-item-icon {
+        width: 42rpx;
+        height: 48rpx;
+        > image {
+          width: 100%;
+          height: 100%;
+        }
       }
     }
   }

+ 1 - 37
src/otherPages/mockExam/index.vue

@@ -394,43 +394,7 @@ export default {
   onLoad(query) {
     let that = this;
     this.query = query;
-    api.open
-      .questionInfoSelectTestK14QuestionInfoList({
-        ...this.query,
-      })
-      .then((res) => {
-        res.rows.forEach((element) => {
-          element.optsArr = [];
-          element.opts.split("-").forEach((item, index) => {
-            if (element.questionType == 3) {
-              element.optsArr.push({
-                selected: false,
-                value: item,
-                index: index,
-                isAnswer: element.answer.split("-").includes(item),
-              });
-            } else {
-              element.optsArr.push({
-                selected: false,
-                value: item,
-                index: index,
-                isAnswer: item === element.answer,
-              });
-            }
-          });
-          element.isCompleted = false;
-          element.userAnswer = [];
-        });
-        that.problemListTotal = res.total;
-        that.problemList = res.rows;
-      });
-    this.examTimer = setInterval(() => {
-      this.examTimeUse = this.examTimeUse + 1000;
-      if (this.examTimeUse > this.time) {
-        this.submitExam();
-        clearInterval(this.examTimer);
-      }
-    }, 1000);
+
   },
   computed: {
     //liceCar=1&liceTruck=&liceBus=&liceMoto=&name=科目一&cert=C1/C2/C3&vehicle=轿车&subject=1&title=顺序练习&sort=3

+ 34 - 3
src/pages/carVideo/components/tabCenter.vue

@@ -1,13 +1,15 @@
 <template>
   <view class="center">
     <view
-      @click="goPath(item)"
+      @click="goPath(item, index)"
       class="center-item"
       v-for="(item, index) in centerList"
       :key="index"
     >
       <image class="center-img" :src="item.img"></image>
-      <text v-if="index == 0"  class="center-text">{{ item.text+'\n500题'}}</text>
+      <text v-if="index == 0" class="center-text">{{
+        item.text + "\n500题"
+      }}</text>
       <text v-if="index == 1" class="center-text">{{ item.text }}</text>
     </view>
   </view>
@@ -20,10 +22,33 @@ export default {
     //exercise
     return {};
   },
+  computed: {
+    isVip() {
+      return this.$store.getters.isVip;
+    },
+  },
   methods: {
-    goPath(item) {
+    goPath(item, index) {
       let query = Object.assign({}, this.query);
       query.title = item.text;
+      if (this.needVipList.includes(index) && !this.isVip) {
+        uni.showModal({
+          title: "提示",
+          content: "需要vip才能使用这个功能",
+          confirmText: "购买vip",
+          cancelText: "取消",
+          success(res) {
+            console.log(res);
+            if (res.confirm) {
+              uni.navigateTo({
+                url: "/otherPages/buyVip/index",
+              });
+            }
+          },
+        });
+
+        return;
+      }
       if (item.path) {
         let str = utils.mapToUrlQuery(query);
         console.log(item.path + "?" + str, "str");
@@ -34,6 +59,12 @@ export default {
     },
   },
   props: {
+    needVipList: {
+      type: Array,
+      default: () => {
+        return [];
+      },
+    },
     query: {
       type: Object,
       default: () => {

+ 34 - 5
src/pages/carVideo/components/tabLeft.vue

@@ -1,7 +1,7 @@
 <template>
   <view class="left">
     <view v-for="(item, index) in leftList" :key="index" class="left-item">
-      <image @click="goPath(item)" :src="item.img"></image>
+      <image @click="goPath(item, index)" :src="item.img"></image>
       <text>{{ item.text }}</text>
     </view>
   </view>
@@ -13,20 +13,49 @@ export default {
   data() {
     return {};
   },
+  computed: {
+    isVip() {
+      return this.$store.getters.isVip;
+    },
+  },
   methods: {
-    goPath(item) {
-     let query = Object.assign({}, this.query);
+  goPath(item, index) {
+      let query = Object.assign({}, this.query);
       query.title = item.text;
+      if (this.needVipList.includes(index) && !this.isVip) {
+        uni.showModal({
+          title: "提示",
+          content: "需要vip才能使用这个功能",
+          confirmText: "购买vip",
+          cancelText: "取消",
+          success(res) {
+            console.log(res);
+            if (res.confirm) {
+              uni.navigateTo({
+                url: "/otherPages/buyVip/index",
+              });
+            }
+          },
+        });
+
+        return;
+      }
       if (item.path) {
         let str = utils.mapToUrlQuery(query);
-        console.log(item.path + "?" + str,'str')
+        console.log(item.path + "?" + str, "str");
         uni.navigateTo({
           url: item.path + "?" + str,
         });
       }
-    },
+    }
   },
   props: {
+    needVipList: {
+      type: Array,
+      default: () => {
+        return [];
+      },
+    },
     leftList: {
       type: Array,
       default: () => {

+ 39 - 13
src/pages/carVideo/components/tabRight.vue

@@ -1,7 +1,7 @@
 <template>
   <view class="right">
     <view v-for="(item, index) in rightList" :key="index" class="right-item">
-      <image @click="goPath(item)" :src="item.img"></image>
+      <image @click="goPath(item,index)" :src="item.img"></image>
       <text>{{ item.text }}</text>
     </view>
   </view>
@@ -13,12 +13,34 @@ export default {
   data() {
     return {};
   },
+  computed: {
+    isVip() {
+      return this.$store.getters.isVip;
+    },
+  },
   methods: {
-    goPath(item) {
+    goPath(item, index) {
       let query = Object.assign({}, this.query);
       query.title = item.text;
-      console.log(item);
-        if (item.path) {
+      if (this.needVipList.includes(index) && !this.isVip) {
+        uni.showModal({
+          title: "提示",
+          content: "需要vip才能使用这个功能",
+          confirmText: "购买vip",
+          cancelText: "取消",
+          success(res) {
+            console.log(res);
+            if (res.confirm) {
+              uni.navigateTo({
+                url: "/otherPages/buyVip/index",
+              });
+            }
+          },
+        });
+
+        return;
+      }
+      if (item.path) {
         let str = utils.mapToUrlQuery(query);
         console.log(item.path + "?" + str, "str");
         uni.navigateTo({
@@ -28,25 +50,29 @@ export default {
     },
   },
   props: {
+    needVipList: {
+      type: Array,
+      default: () => {
+        return [];
+      },
+    },
     rightList: {
       type: Array,
       default: () => {
         return [];
       },
     },
-    
+
     subject: {
       type: Number,
       default: 1,
     },
-    query:{
-      type:Object,
-      default:()=>{
-        return {
-          
-        }
-      }
-    }
+    query: {
+      type: Object,
+      default: () => {
+        return {};
+      },
+    },
   },
 };
 </script>

+ 0 - 1
src/pages/carVideo/components/userInfoHead.vue

@@ -20,7 +20,6 @@
       >
       <!-- <view v-if="isVip" style="color: #0a1a33; margin-left: 10px">VIP会员</view> -->
       <image
-        @click="goBuyVip"
         v-if="isVip"
         style="margin-left: 8px"
         class="diamond"

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

@@ -206,16 +206,19 @@
         <swiper-item id="tab1" style="display: inline-block; width: 100%">
           <view class="tab-container">
             <tab-left
+              :needVipList="[0, 1]"
               :subject="1"
               :query="tabQuery"
               :leftList="leftList1"
             ></tab-left>
             <tab-center
+              :needVipList="[0, 1]"
               :subject="1"
               :query="tabQuery"
               :centerList="centerList1"
             ></tab-center>
             <tab-right
+              :needVipList="[0, 1]"
               :subject="1"
               :query="tabQuery"
               :rightList="rightList1"
@@ -233,14 +236,14 @@
         </swiper-item>
 
         <swiper-item id="tab3" style="display: inline-block; width: 100%">
-          <van-grid column-num="4">
+          <!-- <van-grid column-num="4">
             <van-grid-item
               @click="goLightMock"
               icon="https://t1-1305573081.file.myqcloud.com/wxapp/static/imgs/home/lightmock.png"
               text="灯光模拟"
             >
             </van-grid-item>
-          </van-grid>
+          </van-grid> -->
           <view v-for="(item, index) in typeList" :key="index">
             <branch-two
               v-if="index == 2"
@@ -251,16 +254,19 @@
         <swiper-item id="tab4" style="display: inline-block; width: 100%">
           <view class="tab-container">
             <tab-left
+              :needVipList="[0, 1]"
               :query="tabQuery"
               :subject="4"
               :leftList="leftList4"
             ></tab-left>
             <tab-center
+              :needVipList="[0, 1]"
               :query="tabQuery"
               :subject="4"
               :centerList="centerList4"
             ></tab-center>
             <tab-right
+              :needVipList="[0, 1]"
               :query="tabQuery"
               :subject="4"
               :rightList="rightList4"

+ 10 - 1
src/pages/user/index.vue

@@ -44,13 +44,22 @@
       <!-- #endif -->
       <!-- #ifdef MP-TOUTIAO -->
       <van-cell
+        v-if="!isVip"
         title="会员有效期"
-        :value="isVip ? '已开通' : '开通会员'"
+        :value="'开通会员'"
         is-link
         center
         url="/otherPages/buyVip/index"
       >
       </van-cell>
+      <van-cell
+        v-if="isVip"
+        title="会员有效期"
+        :value="'已开通'"
+        is-link
+        center
+      >
+      </van-cell>
 
       <!-- #endif -->
       <!-- #ifdef MP-WEIXIN -->