zoukankan      html  css  js  c++  java
  • yb课堂 下单页面组件开发 《四十三》

    Pay.vue

    <template>
      <!--视频信息-->
      <div>
        <div class="info">
          <p class="info_title">商品信息</p>
          <div class="box">
            <div class="imgdiv">
              <img :src="videoinfo.cover_img" alt="课程照片" />
            </div>
            <div class="txtdiv">
              <p class="c_title">{{videoinfo.title}}</p>
              <p class="price">¥:&nbsp;&nbsp;{{(videoinfo.price/100).toFixed(2)}}</p>
            </div>
          </div>
        </div>
        <!--底部支付-->
        <div class="footer">
          <p class="money">实付&nbsp;&nbsp;{{(videoinfo.price/100).toFixed(2)}}</p>
          <p class="submit" @click="pay">立刻支付</p>
        </div>
      </div>
    </template>
    <script>
    import { getVideoDetail, saveOrder } from "@/api/getData.js";
    export default {
      data() {
        return {
          videoinfo: {}
        };
      },
      methods: {
        //获取视频详情
        async getDetail(vid) {
          try {
            const result = await getVideoDetail(vid);
            if (result.data.code == 0) {
              this.videoinfo = result.data.data;
            }
          } catch (err) {
            console.log(err);
          }
        },
        //下单
        async pay() {
          try {
            const result = await saveOrder(
              this.$store.state.token,
              this.$route.query.video_id
            );
            if (result.data.code == 0) {
              const toast = this.$createToast({
                txt: "购买成功",
                type: "correct",
                time: 2000,
                onTimeout: () => {
                  this.$router.push({ path: "/order" });
                }
              });
              toast.show();
            }else{
              const toast = this.$createToast({
                txt: `${result.data.msg}`,
                type: "correct",
                time: 2000
              });
              toast.show();
            }
          } catch (err) {
            console.log(err);
          }
        }
      },
      mounted() {
        this.getDetail(this.$route.query.video_id);
      }
    };
    </script>
    <style lang="scss" scoped>
    // 视频标题
    .info_title {
      padding: 10px 20px;
      background-color: #fff;
      border-bottom: 1px solid #d9dde1;
    }
    .box {
      background-color: #fff;
      box-sizing: border-box;
      padding: 20px;
      display: flex;
      margin-bottom: 15px;
      .imgdiv {
         105px;
        height: 59px;
        flex-shrink: 0;
        img {
           100%;
          height: 100%;
        }
      }
      .textdiv {
        margin-left: 20px;
        height: 59px;
        flex-grow: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        .price {
          flex-shrink: 0;
        }
      }
    }
    //底部
    .footer {
      position: fixed;
      bottom: 0;
       100%;
      height: 50px;
      background-color: #fff;
      display: flex;
      justify-content: space-between;
      box-shadow: 0 -2px 4px 0 rgba(0, 0, 0, 0.1);
      font-size: 16px;
      .money {
        height: 50px;
        line-height: 50px;
        flex: 2;
        text-align: center;
        background-color: #fff;
      }
      .submit {
        height: 50px;
        line-height: 50px;
        flex: 1;
        text-align: center;
        background-color: #ff2d50;
        color: #fff;
      }
    }
    </style>
    作者:陈彦斌

    个性签名:没有学不会的技术,只有不学习的人!
    联系方式:543210188(WeChat/QQ),推荐WeChat
  • 相关阅读:
    20155213 2016-2017-2 《Java程序设计》第五周学习总结
    20155213 2016-2017-2《Java程序设计》第四周学习总结
    20155213 2016-2017-2《Java程序设计》第三周学习总结
    20155213 2016-2017-2 《Java程序设计》第二周学习总结
    20145109《Java程序设计》第一周学习总结
    《暗时间》读书笔记(三)
    调查问卷
    《Python学习手册》(四)
    《Python学习手册》(三)
    20165322 第五周学习总结
  • 原文地址:https://www.cnblogs.com/chenyanbin/p/13355434.html
Copyright © 2011-2022 走看看