Browse Source

立即购买,继续学习跳转

apeng 4 years ago
parent
commit
f60e5e0b67
2 changed files with 38 additions and 31 deletions
  1. 2 2
      package.json
  2. 36 29
      pages/frontend/learn/detail/_id.vue

+ 2 - 2
package.json

@@ -76,9 +76,9 @@
     "style-loader": "^0.23.1",
     "t2css": "^0.1.6",
     "ts-loader": "^8.0.3",
+    "vue-cnzz-analytics": "^2.2.0",
     "vue-lazyload": "^1.3.3",
-    "webpack": "^4.43.0",
-    "vue-cnzz-analytics": "^2.2.0"
+    "webpack": "^4.43.0"
   },
   "resolutions": {
     "jspdf/file-saver": "1.3.8"

+ 36 - 29
pages/frontend/learn/detail/_id.vue

@@ -14,7 +14,7 @@
             <div class="purchased">
               <a :href="`${'/lv/'+sale_id}`" class="video">
                 <img class="play" src="@/assets/img/learn/video@2x.png" alt="play">
-                <img class="bg-img" :src="learnDetail.info.img" alt="">
+                <img class="bg-img" :src="defaultImg" v-real-img="learnDetail.info.img" alt="">
               </a>
               <div class="intro">
                 <div class="title">
@@ -32,18 +32,18 @@
                   </div>
                 </div>
                 <div class="lectruer">
-                  11人学过<span class="line">|</span><span>老师:</span><span class="txt">李婷婷</span>
+                  {{ learnDetail.info.buy_num }}人学过<span class="line">|</span><span>老师:</span><span class="txt">{{ learnDetail.teacher.name }}</span>
                 </div>
                 <div class="price">
                   <span class="new">¥{{ learnDetail.info.price.toFixed(2) }}</span><span class="old">原价¥{{ learnDetail.info.yprice.toFixed(2) }}</span>
                 </div>
                 <div class="btns">
                   <div>
-                    <el-button type="primary" class="go-buy" v-if="!learnDetail.info.is_buy">
+                    <el-button type="primary" class="go-buy" v-if="!learnDetail.info.is_buy" @click="goBtn">
                       <img class="icon" src="@/assets/img/learn/car@2x.png" alt="car"/>
                       立即购买
                     </el-button>
-                    <el-button v-else>继续学习</el-button>
+                    <el-button v-else @click="goBtn">继续学习</el-button>
                   </div>
                   <div class="brief">
                     <span>{{ learnDetail.info.video_num }}集</span>
@@ -65,7 +65,7 @@
               </div>
               <!--介绍-->
               <div class="introduction" v-show="tabActive==0">
-                <img :src="learnDetail.content.video_img" alt=""/>
+                <img :src="defaultImg" v-real-img="learnDetail.content.video_img" alt="">
                 <p v-html="learnDetail.content.content"></p>
               </div>
               <!--目录-->
@@ -133,11 +133,11 @@
               <div class="r-lectruer">
                 <div class="lectruer-img">
                   <span class="l-img">
-                    <img :src="learnDetail.teacher.img" alt="李婷婷">
+                    <img :src="defaultImg" v-real-img="learnDetail.teacher.img" :alt="learnDetail.teacher.name">
                     <span>讲师</span>
                   </span>
-                  <span class="name">李婷婷</span>
-                  <span class="job">资深前端工程师</span>
+                  <span class="name">{{ learnDetail.teacher.name }}</span>
+                  <span class="job">{{ learnDetail.teacher.op }}</span>
                 </div>
                 <p class="lectruer-info">{{ learnDetail.teacher.content }}</p>
               </div>
@@ -197,7 +197,8 @@ export default {
             baseUrl: '',
             isWeixinApp: true,
             collapseName: 1,
-            tabActive: 0
+            tabActive: 0,
+            defaultImg: require('@/assets/img/common/empty@2x.png')
         }
     },
     components: {
@@ -266,8 +267,8 @@ export default {
         }
     },
     mounted () {
-        this.baseUrl = this.$store.state.domainConfig.siteUrl
-        this.isWeixinApp = navigator.userAgent.indexOf("miniProgram") > -1
+      this.baseUrl = this.$store.state.domainConfig.siteUrl
+      this.isWeixinApp = navigator.userAgent.indexOf("miniProgram") > -1
     },
     methods: {
       // 是否收藏
@@ -302,28 +303,34 @@ export default {
        * 点击购买:
        * 跳转共用支付界面
        */
-      handleClickPay () {
-        const query = {
-          product_type: 505,
-          product_id: this.sale_id,
-          next: location.href + '?act=pay'
-        }
-        if (!this.userinfo || !this.userinfo.nickname) {
-          // 未登录时 => 去登录
-          if (this.deviceType.ios || this.deviceType.android) {
-            location.href = "proginn://login?backToPage=true";
-          } else {
-            location.href = this.baseUrl + "/?loginbox=show&next=" + encodeURIComponent(location.href)
+      goBtn () {
+        // 立即购买
+        if(!this.learnDetail.info.is_buy){
+          const query = {
+            product_type: 505,
+            product_id: this.sale_id,
+            next: location.href + '?act=pay'
           }
-        } else {
-          // 已登录,跳转支付
-          if (this.deviceType.ios || this.deviceType.android) {
-            location.href = "proginn://pay?" + qs.stringify(query)
+          if (!this.userinfo || !this.userinfo.nickname) {
+            // 未登录时 => 去登录
+            if (this.deviceType.ios || this.deviceType.android) {
+              window.location.href = "proginn://login?backToPage=true";
+            } else {
+              window.location.href = this.baseUrl + "/?loginbox=show&next=" + encodeURIComponent(location.href)
+            }
           } else {
-            location.href = this.baseUrl + "/pay?" + qs.stringify(query)
+            // 已登录,跳转支付
+            if (this.deviceType.ios || this.deviceType.android) {
+              window.location.href = "proginn://pay?" + qs.stringify(query)
+            } else {
+              window.location.href = this.baseUrl + "/pay?" + qs.stringify(query)
+            }
           }
+        // 继续学习
+        }else {
+          window.location.href = '/lv/'+ this.sale_id
         }
-      },
+      }
     }
 }
 </script>