Bladeren bron

feat: update

SilenceLeo 2 jaren geleden
bovenliggende
commit
c5ad21ad3d
3 gewijzigde bestanden met toevoegingen van 27 en 9 verwijderingen
  1. 9 2
      src/components/vip-card/vip-card.vue
  2. 2 0
      src/lib/api/vip.js
  3. 16 7
      src/pages/vip/vip.vue

+ 9 - 2
src/components/vip-card/vip-card.vue

@@ -2,8 +2,7 @@
   <view
     class="card"
     :style="{
-      backgroundImage:
-        userInfo && userInfo.card_img ? `url(${userInfo.card_img})` : '',
+      backgroundImage: image ? `url(${image})` : '',
     }"
   >
     <view class="card-title">VIP会员</view>
@@ -54,6 +53,10 @@ export default {
       type: Boolean,
       default: false,
     },
+    img: {
+      type: String,
+      default: "",
+    },
   },
 
   data() {
@@ -64,6 +67,10 @@ export default {
     isVip() {
       return this.userInfo && this.userInfo.type === "1";
     },
+
+    image() {
+      return this.img || (this.userInfo && this.userInfo.card_img) || "";
+    },
   },
 
   created() {

+ 2 - 0
src/lib/api/vip.js

@@ -28,3 +28,5 @@ export const getCardStyleList = () => request.get(`/weapp/cardStyle/list`);
  */
 export const useCardStyle = (data) =>
   request.post(`/weapp/cardStyle/use`, data);
+
+export const useCardImage = () => request.get(`/weapp/init`);

+ 16 - 7
src/pages/vip/vip.vue

@@ -1,6 +1,11 @@
 <template>
   <view class="page">
-    <vip-card :user-info="userInfo" @login="handleLogin" ref="card" />
+    <vip-card
+      :user-info="userInfo"
+      @login="handleLogin"
+      ref="card"
+      :img="cardImg"
+    />
     <!-- <view class="list-title">VIP会员专享{{ list.length }}项权益</view>
     <view class="list">
       <view class="item" v-for="item in list" :key="item.name">
@@ -8,12 +13,7 @@
         {{ item.name }}
       </view>
     </view> -->
-    <image
-      class="img"
-      v-if="userInfo"
-      :src="userInfo.vip_img"
-      mode="widthFix"
-    ></image>
+    <image class="img" v-if="img" :src="img" mode="widthFix"></image>
     <view class="footer" v-if="!isVip">
       <view class="footer-body">
         <text class="bold">&yen;</text><text class="bold big">99</text>/年
@@ -40,6 +40,7 @@
 <script>
 import login from "@/lib/utils/login";
 import { getUserInfo } from "@/lib/api/user";
+import { useCardImage } from "@/lib/api/vip";
 import VipCard from "@/components/vip-card/vip-card.vue";
 
 export default {
@@ -49,6 +50,8 @@ export default {
     return {
       id: 0,
       userInfo: null,
+      cardImg: "",
+      img: "",
       list: [
         {
           name: "10000积分",
@@ -84,6 +87,12 @@ export default {
     },
   },
 
+  onLoad() {
+    useCardImage().then(({ data }) => {
+      this.cardImg = data.vip_card;
+      this.img = data.vip_img;
+    });
+  },
   async onShow() {
     this.userInfo = await login.getUserInfo();
     if (this.userInfo && this.userInfo.session) {