| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <template>
- <view class="container">
- <!-- #ifdef H5 -->
- <view style="color: #fff;">
- <tn-nav-bar @back="handleBack" backgroundColor="#26B3A0" :bottomShadow="false"
- @rightClick="jumpScoreRed">支付状态
- <!-- <template slot="right">
- 课程购买记录
- </template> -->
- </tn-nav-bar>
- <view :style="{ height: tobheight + 'px' }"></view>
- </view>
- <!-- #endif -->
- <!-- <view class="content" v-if="orderDetail.status"> -->
- <view class="content">
- <view class="topIcon">
- <!-- <image src="../../../static/posImg.png" mode=""></image> -->
- <icon type="success" size="54" color="#26B3A0" />
- <view class="txt">
- 支付成功
- </view>
- </view>
- <view class="btn" @click="handleShowRes">
- {{resShow?'收起学习资料':'查看学习资料'}}
- </view>
- <view class="res" v-if="resShow&&this.detail.content">
- <view class="inner" v-for="(i,index) in this.detail.content" @click="downLoad(i)">
- <text style="text-decoration: underline;">
- {{'学习资料'+(index+1)}}</text><text>{{i.slice(i.lastIndexOf('.'))}}</text>
- </view>
- </view>
- </view>
- <!-- <view class="content" v-else>
- <view class="topIcon">
- <icon type="info" size="54" color="red" />
- <view class="txt" style="color: red;">
- 支付失败
- </view>
- </view>
- </view> -->
- </view>
- </template>
- <script>
- import {
- courseDetail
- } from '@/api/score/index.js'
- import {
- downLoad2
- } from '@/utils/download2.js'
- import {
- myScoreOrderDetail
- } from '@/api/my/index.js'
- export default {
- components: {},
- data() {
- return {
- detail: {},
- tobheight: 45,
- resShow: false,
- orderDetail: {
- status: 0
- }
- };
- },
- computed: {
- },
- watch: {
- },
- async onLoad(o) {
- let res = await courseDetail({
- course_id: o.id
- })
- if (res.code == 0) {
- this.detail = res.data
- }
- // let res1 = await myScoreOrderDetail({
- // course_order_id: o.orderId
- // })
- // if (res1.code == 0) {
- // this.orderDetail = res1.data
- // // this.orderDetail.status = 1
- // }
- // console.log('支付状态页-订单状态返回值:', res1);
- console.log('支付成功--课程详情返回值', res);
- },
- onReady() {
- },
- onShow() {
- if (uni.getStorageSync('clickStudyBtn')) {
- uni.removeStorageSync('clickStudyBtn')
- }
- if (uni.getStorageSync('myScoreId')) {
- uni.removeStorageSync('myScoreId')
- }
- },
- onUnload() {
- },
- methods: {
- handleBack() {
- uni.setStorageSync('from', 'index')
- },
- handleShowRes() {
- this.resShow = !this.resShow
- },
- downLoad(fileName) {
- let _this = this
- //判断是否在微信
- var ua = navigator.userAgent.toLowerCase();
- var isWeixin = ua.indexOf('micromessenger') != -1;
- const detectDeviceType = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
- navigator.userAgent) ? false : true;
- if (isWeixin) {
- if (fileName.endsWith('.pdf')) {
- uni.navigateTo({
- url: '/pages/user/score/prePdf/index?url=' + fileName
- })
- } else if (fileName.endsWith('.mp4')) {
- uni.navigateTo({
- url: '/pages/user/score/preMp4/index?url=' + fileName
- })
- } else if (fileName.endsWith('.jpg') || fileName.endsWith('.png') || fileName.endsWith('.jpeg')) {
- uni.navigateTo({
- url: '/pages/user/score/preImg/index?url=' + fileName
- })
- } else if (fileName.endsWith('.zip') || fileName.endsWith('.rar')) {
- let _that = this
- uni.showModal({
- title: '温馨提示',
- content: '微信浏览器不支持直接打开zip或rar类型的文件,请复制链接至手机浏览器打开哦~',
- confirmText: '复制',
- confirmColor: '#26B3A0',
- success: function(res) {
- if (res.confirm) {
- console.log('用户点击确定');
- uni.setClipboardData({
- data: fileName,
- success: function() {
- console.log('success');
- uni.showToast({
- title: "复制成功",
- icon: 'success',
- })
- }
- });
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- })
- }
- } else if (detectDeviceType()) {
- // pc端
- uni.downloadFile({
- url: fileName, //文件链接
- success: (res) => {
- if (res.statusCode === 200) {
- var oA = document.createElement("a");
- oA.download = _this.detail.course.name + '-学习资料'; // 设置下载的文件名,默认是'下载'
- oA.href = res.tempFilePath; //临时路径再保存到本地
- document.body.appendChild(oA);
- oA.click();
- oA.remove(); // 下载之后把创建的元素删除
- }
- },
- fail: (err) => {
- uni.showToast({
- icon: 'none',
- mask: true,
- title: '失败请重新下载',
- });
- },
- })
- } else {
- // 其他手机浏览器
- if (fileName.endsWith('.pdf')) {
- uni.navigateTo({
- url: '/pages/user/score/prePdf/index?url=' + fileName
- })
- } else if (fileName.endsWith('.mp4')) {
- uni.navigateTo({
- url: '/pages/user/score/preMp4/index?url=' + fileName
- })
- } else if (fileName.endsWith('.jpg') || fileName.endsWith('.png') || fileName.endsWith('.jpeg')) {
- uni.navigateTo({
- url: '/pages/user/score/preImg/index?url=' + fileName
- })
- } else if (fileName.endsWith('.zip') || fileName.endsWith('.rar')) {
- downLoad2(fileName, this.detail.course.name + '-学习资料', 'application/zip')
- // window.open(
- // fileName
- // )
- }
- }
- },
- goPay() {
- uni.navigateTo({
- url: '/pages/index/scorePaySuc/index'
- })
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- @import './index.scss';
- </style>
|