瀏覽代碼

[change] new vip module

x 5 年之前
父節點
當前提交
bf829ef11f
共有 2 個文件被更改,包括 164 次插入90 次删除
  1. 8 0
      src/api/user.js
  2. 156 90
      src/views/user/UserVip.vue

+ 8 - 0
src/api/user.js

@@ -356,3 +356,11 @@ export function getRechargeApi() {
 export function getCodeApi() {
   return request.get("verify_code", {}, { login: false });
 }
+
+export function getVIP() {
+  return request.get("user/vip/info");
+}
+
+export function drawVIP() {
+  return request.post("user/vip/withdraw");
+}

+ 156 - 90
src/views/user/UserVip.vue

@@ -2,23 +2,25 @@
   <div class="member-center">
     <div class="header">
       <NavBar></NavBar>
-      <div class="slider-banner banner">
-        <swiper class="swiper-wrapper" :options="swiperVip" ref="mySwiper">
-          <swiperSlide
-            class="swiper-slide memberBg"
-            :class="item.class"
-            v-for="(item, index) in vipList"
-            :key="index"
-            :style="{ backgroundImage: 'url(' + item.image + ')' }"
-          >
-            <!--            <img :src="item.icon" />-->
-            <div class="name">{{ item.name }}</div>
-            <div class="discount">
-              可享受商品折扣: {{ item.discount / 10 }}折<span
+      <div class="slider-banner banner" style="padding: 0 0.6rem">
+        <!-- <div class="swiper-wrapper"> -->
+        <div
+          class="swiper-slide memberBg"
+          :style="{ backgroundImage: 'url(' + vipInfo.image + ')' }"
+        >
+          <!--            <img :src="item.icon" />-->
+          <!-- <div class="name"></div> -->
+          <div class="cardNO">
+            NO.{{ userInfo.vip_card_id.toUpperCase() }}
+            <!-- 商品折扣: {{ item.discount / 10 }}折<span
                 class="iconfont icon-zhekou"
-              ></span>
-            </div>
-            <div class="nav acea-row" v-if="item.grade == grade">
+              ></span> -->
+          </div>
+          <div class="spacer"></div>
+          <div class="date">
+            {{ formatTime(userInfo.vip_time) }}
+          </div>
+          <!-- <div class="nav acea-row" v-if="vipInfo.grade == grade">
               <div
                 class="item"
                 v-for="(val, indexn) in vipComplete"
@@ -27,54 +29,78 @@
                 <div class="num">{{ val.number }}</div>
                 <div>{{ val.real_name }}</div>
               </div>
-            </div>
-            <div class="lock" v-if="grade < item.grade">
-              <span class="iconfont icon-quanxianguanlisuozi"></span
-              >该会员等级尚未解锁
-            </div>
-            <div class="lock" v-if="grade > item.grade">
+            </div> -->
+          <!-- <div class="lock" v-if="grade < vipInfo.grade"> -->
+          <!-- <span class="iconfont icon-quanxianguanlisuozi"></span
+              >该会员等级尚未解锁 -->
+          <!-- </div> -->
+          <!-- <div class="lock" v-if="grade > vipInfo.grade">
               <span class="iconfont icon-xuanzhong1"></span>已解锁更高等级
-            </div>
-          </swiperSlide>
-        </swiper>
+            </div> -->
+        </div>
+        <!-- </div> -->
       </div>
     </div>
     <div class="wrapper">
       <div class="title acea-row row-between-wrapper">
-        <div><span class="iconfont icon-jingyanzhi"></span>会员升级要求</div>
-        <div class="num">
+        <div><span class="iconfont icon-jingyanzhi"></span>会员推广佣金</div>
+        <!-- <div class="num">
           <span class="current">{{ taskCount }}</span
           >/{{ vipRequire.length }}
-        </div>
+        </div> -->
       </div>
       <div class="list">
-        <div class="item" v-for="(item, index) in vipComplete" :key="index">
+        <div class="item">
           <div class="top acea-row row-between-wrapper">
             <div class="name">
-              {{ item.name
-              }}<span
-                class="iconfont icon-wenti"
-                v-if="item.illustrate"
-                @click="showGrow(item)"
-              ></span>
+              当前可领取
+            </div>
+          </div>
+
+          <div class="title acea-row row-between-wrapper">
+            <div>金额:</div>
+            <div class="font-color-red">¥{{ moneyAvialable.toFixed(2) }}</div>
+            <div
+              :class="moneyAvialable > 0 ? 'but' : 'but on'"
+              @click="drawClick"
+            >
+              领取
             </div>
-            <div>{{ item.finish ? "已满足条件" : "未满足条件" }}</div>
           </div>
-          <div class="cu-progress">
-            <div class="bg-red" :style="{ width: item.speed + '%' }"></div>
+        </div>
+        <div class="item">
+          <div class="top acea-row row-between-wrapper">
+            <div class="name">{{ colorNames[userInfo.vip_level] }}可领取</div>
+            <!-- <div>升级后即可领取</div> -->
           </div>
-          <div class="experience acea-row row-between-wrapper">
-            <div>{{ item.task_type_title }}</div>
-            <div>
-              <span class="num">{{ item.new_number }}</span
-              >/{{ item.number }}
+          <div class="title acea-row row-between-wrapper">
+            <div>金额:</div>
+            <div class="font-color-red">¥{{ moneyNext.toFixed(2) }}</div>
+            <div
+              :class="moneyNext > 0 ? 'but' : 'but on'"
+              @click="upgradeClick"
+            >
+              去购买
             </div>
           </div>
         </div>
       </div>
+
+      <div class="title acea-row row-between-wrapper">
+        <div><span class="iconfont icon-jingyanzhi"></span>会员权益说明</div>
+      </div>
+      <div class="list">
+        <div
+          v-for="(item, idx) in tipsList"
+          :key="idx"
+          style="padding: 0.2rem 0.2rem; line-height: 0.3rem"
+        >
+          <p>{{ item }}</p>
+        </div>
+      </div>
     </div>
-    <Recommend></Recommend>
-    <div class="growthValue" :class="growthValue === false ? 'on' : ''">
+    <!-- <Recommend></Recommend> -->
+    <!-- <div class="growthValue" :class="growthValue === false ? 'on' : ''">
       <div class="pictrue">
         <img src="@assets/images/value.jpg" /><span
           class="iconfont icon-guanbi3"
@@ -85,21 +111,22 @@
         {{ illustrate }}
       </div>
     </div>
-    <div class="mask" :hidden="growthValue" @click="growthTap"></div>
+    <div class="mask" :hidden="growthValue" @click="growthTap"></div> -->
   </div>
 </template>
 <script>
-import { swiper, swiperSlide } from "vue-awesome-swiper";
-import "@assets/css/swiper.min.css";
-import Recommend from "@components/Recommend";
-import { getVipInfo, getVipTask, setDetection } from "../../api/user";
+import {
+  getVipInfo,
+  getVipTask,
+  setDetection,
+  getVIP,
+  drawVIP,
+  getUserInfo
+} from "../../api/user";
 import NavBar from "@components/NavBar";
 export default {
   name: "Poster",
   components: {
-    swiper,
-    swiperSlide,
-    Recommend,
     NavBar
   },
   props: {},
@@ -110,44 +137,51 @@ export default {
       vipComplete: [], //完成情况
       taskCount: 0, //任务数
       grade: 0, //当前会员等级
-      swiperVip: {
-        speed: 1000,
-        effect: "coverflow",
-        slidesPerView: "auto",
-        centeredSlides: true,
-        // loop: true,
-        coverflowEffect: {
-          rotate: 0, // 旋转的角度
-          stretch: -20, // 拉伸   图片间左右的间距和密集度
-          depth: 100, // 深度   切换图片间上下的间距和密集度
-          modifier: 2, // 修正值 该值越大前面的效果越明显
-          slideShadows: false // 页面阴影效果
-        },
-        observer: true,
-        observeParents: true
-      },
       loading: false,
       growthValue: true,
       illustrate: "",
-      activeIndex: 0
+      activeIndex: 0,
+      vipInfo: {
+        name: "会员",
+        grade: 1,
+        discount: 99,
+        class: ""
+      },
+      moneyAvialable: 0,
+      moneyNext: 0,
+      tipsList: [],
+      userInfo: {
+        vip_card_id: "",
+        date: ""
+      },
+      productId: 0,
+      colorNames: [
+        "红色卡",
+        "橙色卡",
+        "黄色卡",
+        "绿色卡",
+        "青色卡",
+        "蓝色卡",
+        "紫色卡"
+      ]
     };
   },
   watch: {
     vipList: function() {
-      let that = this,
-        gradeArray = [];
-      if (that.vipList.length > 0) {
-        that.vipList.forEach(function(item, index) {
-          if (item.is_clear === true) {
-            that.swiper.slideTo(index);
-            that.activeIndex = index;
-            gradeArray.push(item.grade);
-          }
-        });
-      }
-      if (gradeArray.length) {
-        that.grade = gradeArray[0];
-      }
+      // let that = this,
+      //   gradeArray = [];
+      // if (that.vipList.length > 0) {
+      //   that.vipList.forEach(function(item, index) {
+      //     if (item.is_clear === true) {
+      //       that.swiper.slideTo(index);
+      //       that.activeIndex = index;
+      //       gradeArray.push(item.grade);
+      //     }
+      //   });
+      // }
+      // if (gradeArray.length) {
+      //   that.grade = gradeArray[0];
+      // }
     }
   },
   computed: {
@@ -156,15 +190,20 @@ export default {
     }
   },
   mounted: function() {
-    let that = this;
     setDetection();
-    that.getInfo();
-    that.swiper.on("slideChange", function() {
-      that.activeIndex = that.swiper.activeIndex;
-      that.getTask();
-    });
+    this.update();
   },
   methods: {
+    update: function() {
+      var that = this;
+      that.getInfo();
+      getVIP().then(res => {
+        that.productId = res.data.card_updater_id;
+        that.moneyAvialable = res.data.money_available;
+        that.moneyNext = res.data.money_next;
+        that.tipsList = res.data.card_benefit.split("\n");
+      });
+    },
     growthTap: function() {
       this.growthValue = true;
     },
@@ -176,6 +215,10 @@ export default {
           that.vipRequire = res.data.task.list;
           that.vipComplete = res.data.task.task;
           that.taskCount = res.data.task.reach_count;
+          getUserInfo().then(res => {
+            that.userInfo = res.data;
+            that.vipInfo = that.vipList[that.userInfo.vip_level - 1];
+          });
         },
         err => {
           that.$dialog.message(err.msg);
@@ -198,6 +241,29 @@ export default {
     showGrow: function(item) {
       if (this.illustrate != item.illustrate) this.illustrate = item.illustrate;
       this.growthValue = false;
+    },
+    drawClick: function() {
+      var that = this;
+      drawVIP().then(res => {
+        if (res.status == 200) {
+          that.$dialog.message("领取成功!");
+          that.update();
+        } else {
+          that.$dialog.message(res.msg);
+        }
+      });
+    },
+    upgradeClick: function() {
+      this.$router.push({ path: "/detail/" + this.productId });
+    },
+    formatTime: function(UnixTime) {
+      var date = new Date(UnixTime * 1000);
+      var y = date.getFullYear();
+      var m = date.getMonth() + 1;
+      m = m < 10 ? "0" + m : m;
+      var d = date.getDate();
+      d = d < 10 ? "0" + d : d;
+      return y + "-" + m + "-" + d;
     }
   }
 };