xiebaomin il y a 1 an
Parent
commit
24b1d31fc8

+ 129 - 123
components/cm-module/scrollTop/scrollTop.vue

@@ -1,133 +1,139 @@
 <template name="scrollTop">
-	<!-- 商品详情价格判断 -->
-	<view>
-		<view class="scrollTop" :style="{bottom:bottom+'rpx'}">
-            <view class="supplierLogo" v-if="isShowSupplier" @click="$api.navigateTo('/pages/login/supplier_login')"></view>
-			<view class="icon msg">
-				<!-- #ifdef MP-WEIXIN -->
-				<button class="contact-btn" open-type="contact" @bindcontact="handleContact">
-					<text class="iconfont icon-zixunrexian"></text>
-				</button>	
-				<!-- #endif -->
-			</view>
-			<view class="icon top" @click="onPageScrollTop" :class="isScrollTop ? 'show' : 'none'">
-				<text class="iconfont icon-zhiding"></text>
-			</view>
-		</view>
-	</view>
+    <!-- 商品详情价格判断 -->
+    <view>
+        <view
+            class="supplierLogo"
+            v-if="isShowSupplier && isShowIcon"
+            @click="$api.navigateTo('/pages/login/supplier_login')"
+            :style="{ bottom: bottom + 120 + 'rpx' }"
+        >
+            <image class="logo" src="https://static.caimei365.com/app/img/icon/supplier_logo.png" mode=""></image>
+            <image
+                class="close"
+                @click.stop="isShowIcon = false"
+                src="https://static.caimei365.com/app/img/supplier-login/close_icon.png"
+                mode=""
+            ></image>
+        </view>
+        <view class="scrollTop" :style="{ bottom: bottom + 'rpx' }">
+            <view class="icon msg">
+                <!-- #ifdef MP-WEIXIN -->
+                <button class="contact-btn" open-type="contact" @bindcontact="handleContact">
+                    <text class="iconfont icon-zixunrexian"></text>
+                </button>
+                <!-- #endif -->
+            </view>
+            <view class="icon top" @click="onPageScrollTop" :class="isScrollTop ? 'show' : 'none'">
+                <text class="iconfont icon-zhiding"></text>
+            </view>
+        </view>
+    </view>
 </template>
 
 <script>
-	export default{
-		name:'scrollTop',
-		props:{
-			bottom:{
-				type:Number,
-				default:100
-			},
-			isScrollTop:{
-				type:Boolean,
-				default:false
-			},
-            isShowSupplier: { // 是否展示供应商服务图标
-                type: Boolean,
-                default: false
-            }
-		},
-		data() {
-			return{
-				isPhone:false,
-				telPhone:'0755-22907771',
-				mobilePhone:'15338851365'
-			}
-		},
-		created() {
-			
-		},
-		methods:{
-			onPageScrollTop(){
-				uni.pageScrollTo({
-				    scrollTop: 0,
-				    duration: 600
-				})
-			},
-			handleContact(e){
-				console.log(e.detail.path)
-				console.log(e.detail.query)
-			},
-		},		
-	}
+export default {
+    name: 'scrollTop',
+    props: {
+        bottom: {
+            type: Number,
+            default: 100
+        },
+        isScrollTop: {
+            type: Boolean,
+            default: false
+        },
+        isShowSupplier: {
+            // 是否展示供应商服务图标
+            type: Boolean,
+            default: false
+        }
+    },
+    data() {
+        return {
+            isPhone: false,
+            telPhone: '0755-22907771',
+            mobilePhone: '15338851365',
+            isShowIcon: true
+        }
+    },
+    created() {},
+    methods: {
+        onPageScrollTop() {
+            uni.pageScrollTo({
+                scrollTop: 0,
+                duration: 600
+            })
+        },
+        handleContact(e) {
+            console.log(e.detail.path)
+            console.log(e.detail.query)
+        }
+    }
+}
 </script>
 
-<style lang="scss">	
-	.scrollTop{
-		width: 80rpx;
-		height: 200rpx;
-		position: fixed;
-		right: 20rpx;
-		z-index: 99;
-        .supplierLogo {
+<style lang="scss">
+.supplierLogo {
+    position: fixed;
+    right: 20rpx;
+    z-index: 100;
+    width: 120rpx;
+    height: 130rpx;
+    display: flex;
+    align-items: flex-end;
+    justify-content: flex-end;
+    .logo {
+        width: 120rpx;
+        height: 120rpx;
+    }
+    .close {
+        position: absolute;
+        top: 0;
+        right: 0;
+        width: 30rpx;
+        height: 30rpx;
+    }
+}
+.scrollTop {
+    width: 80rpx;
+    height: 120rpx;
+    position: fixed;
+    right: 20rpx;
+    z-index: 99;
+    .icon {
+        width: 80rpx;
+        height: 80rpx;
+        border-radius: 50%;
+        float: left;
+        margin: 10rpx 0;
+        line-height: 80rpx;
+        text-align: center;
+        .contact-btn {
             width: 80rpx;
             height: 80rpx;
-            background: url(https://static.caimei365.com/app/img/icon/supplier_logo.png) no-repeat;
-            background-size: contain;
-            transform: scale(1.5);
+            background-color: rgba(0, 0, 0, 0);
+            line-height: 80rpx;
+            .iconfont {
+                font-size: $font-size-44;
+                color: #ffffff;
+            }
+        }
+        &.msg {
+            background-image: linear-gradient(0deg, #f28e31 0%, #ff5b00 100%);
+        }
+        &.top {
+            background-color: rgba(0, 0, 0, 0.4);
+            &.show {
+                opacity: 1;
+            }
+            &.none {
+                opacity: 0;
+            }
+        }
+        .iconfont {
+            font-size: $font-size-44;
+            color: #ffffff;
         }
-		.icon{
-			width: 80rpx;
-			height: 80rpx;
-			border-radius: 50%;
-			float: left;
-			margin: 10rpx 0;
-			line-height: 80rpx;
-			text-align: center;
-			.contact-btn{
-				width: 80rpx;
-				height: 80rpx;
-				background-color: rgba(0,0,0,0);
-				line-height: 80rpx;
-				.iconfont{
-					font-size: $font-size-44;
-					color: #FFFFFF;
-				}
-			}
-			&.msg{
-				background-image: linear-gradient(0deg, #f28e31 0%, #FF5B00 100%);
-			}
-			&.top{
-				background-color: rgba(0,0,0,0.4);
-				&.show{
-					opacity: 1;
-				}
-				&.none{
-					opacity: 0;
-				}
-			}
-			.iconfont{
-				font-size: $font-size-44;
-				color: #FFFFFF;
-			}
-		}
-	}
+    }
+}
 </style>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

+ 8 - 1
pages.json

@@ -182,7 +182,14 @@
 						"enablePullDownRefresh": false,
 						"navigationStyle": "custom"
 					}
-				}
+				},
+                {
+                	"path": "goods-file-preview",
+                	"style": {
+                		"navigationBarTitleText": "文件预览",
+                		"enablePullDownRefresh": false
+                	}
+                }
 			]
 		},
 		{

+ 69 - 77
pages/goods/components/cm-product-doc.vue

@@ -16,7 +16,7 @@
                             <template v-if="item.imageList">
                                 <image
                                     :src="image.url"
-                                    @click="previewImage(i, item.imageList)"
+                                    @click="previewImage(i, item.imageList, item)"
                                     mode="aspectFill"
                                     v-for="(image, i) in imageFormat(item.imageList, index)"
                                     :key="i"
@@ -57,7 +57,7 @@
                                 show-mute-btn
                                 play-btn-position="center"
                                 @timeupdate="onPlayVideo($event)"
-                                @play="handlePlayer('myVideo' + index)"
+                                @play="handlePlayer('myVideo' + index, item)"
                                 v-if="item.fileUrl"
                                 @loadedmetadata="loadedmetadata"
                             ></video>
@@ -119,7 +119,6 @@
 
 <script>
 import { mapState } from 'vuex'
-
 export default {
     props: {
         product: {
@@ -168,7 +167,7 @@ export default {
             timer: null,
             tipStatus: true, // 状态
             userInfo: {}, // 用户信息
-            num: 0,
+            num: 0
         }
     },
     computed: {
@@ -190,8 +189,8 @@ export default {
     },
     watch: {
         TipStatus(val) {
-            if(this.TipStatus) {
-                this.timer = setTimeout(()=>{
+            if (this.TipStatus) {
+                this.timer = setTimeout(() => {
                     this.tipStatus = false
                     clearTimeout(this.timer)
                 }, 10000)
@@ -273,12 +272,15 @@ export default {
             this.$set(this.videoStyle, e.currentTarget.id, `width:${rw}rpx;height:${rh}rpx;`)
         },
         // 视频播放
-        handlePlayer(id) {
+        handlePlayer(id, info) {
             // if (this.checkPermission()) {
             //     this.handleStop(id)
             //     return
             // }
             console.log('视频播放id', id)
+            if (info) {
+                this.GetStatisticsAddPv(1, info.archiveContentId)
+            }
             // 如果点击同一个播放器,就
             if (this.prevVideoId === id) return
             // this.handleFullScreen(id) // 点击播放时全屏
@@ -290,10 +292,10 @@ export default {
         // 监听video时长
         onPlayVideo(e) {
             console.log(e)
-            const allTime = parseInt(((e.detail.duration)% 3600) / 60) // 获取分钟
-            const inPlay = parseInt(((e.detail.duration)% 3600) / 60)
+            const allTime = parseInt((e.detail.duration % 3600) / 60) // 获取分钟
+            const inPlay = parseInt((e.detail.duration % 3600) / 60)
             if (this.permission === 2 || this.permission === 4 || this.permission === 1) {
-                if(allTime >= 10 && (3 < inPlay)) {
+                if (allTime >= 10 && 3 < inPlay) {
                     this.handleStop(e.target.id)
                     this.checkPermission()
                 }
@@ -327,30 +329,23 @@ export default {
             const vContext = uni.createVideoContext(id, this)
             vContext.requestFullScreen()
         },
+        // 浏览记录
+        async GetStatisticsAddPv(type, authorId) {
+            try {
+                await this.BeautyArchive.GetStatisticsAddPv({ type, authorId })
+                console.log('记录成功')
+            } catch (e) {
+                //TODO handle the exception
+            }
+        },
         // 预览图片
-        previewImage(index, previewImageList) {
-            // if (this.permission === 1) {
-            //     if(previewImageList.length >= 5) {
-            //         if (index < 3) {
-            //             uni.previewImage({
-            //                 current: index,
-            //                 indicator: 'number',
-            //                 urls: previewImageList,
-            //                 loop: true,
-            //                 success() {
-            //                     that.$emit('previewImage', true)
-            //                 }
-            //             })
-            //         }else {
-            //             this.checkPermission()
-            //         }
-            //     } else {
-            //         this.checkPermission()
-            //     }
-            // }else if (this.permission === 2) {
+        previewImage(index, previewImageList, info) {
+            if (info) {
+                this.GetStatisticsAddPv(1, info.archiveContentId)
+            }
             if (this.permission === 2 || this.permission === 4 || this.permission === 1) {
-                if(previewImageList.length >= 5) {
-                    if(index < 2) {
+                if (previewImageList.length >= 5) {
+                    if (index < 2) {
                         uni.previewImage({
                             current: index,
                             indicator: 'number',
@@ -363,40 +358,21 @@ export default {
                     } else {
                         if (this.checkPermission()) return
                     }
-                }else {
+                } else {
                     if (this.checkPermission()) return
                 }
-            }
-            // } else if (this.permission === 3) {
-            //     if(previewImageList.length >= 5) {
-            //         if (index < 3) {
-            //             uni.previewImage({
-            //                 current: index,
-            //                 indicator: 'number',
-            //                 urls: previewImageList,
-            //                 loop: true,
-            //                 success() {
-            //                     that.$emit('previewImage', true)
-            //                 }
-            //             })
-            //         } else {
-            //             if (this.checkPermission()) return
-            //         }
-            //     } else {
-            //         if (this.checkPermission()) return
-            //     }
-            else {
-               if (this.checkPermission()) return
-               const that = this
-               uni.previewImage({
-                   current: index,
-                   indicator: 'number',
-                   urls: previewImageList,
-                   loop: true,
-                   success() {
-                       that.$emit('previewImage', true)
-                   }
-               })
+            } else {
+                if (this.checkPermission()) return
+                const that = this
+                uni.previewImage({
+                    current: index,
+                    indicator: 'number',
+                    urls: previewImageList,
+                    loop: true,
+                    success() {
+                        that.$emit('previewImage', true)
+                    }
+                })
             }
         },
         //用户权限校验拦截
@@ -470,9 +446,16 @@ export default {
         // 文件预览
         previewFile(file) {
             // if (this.checkPermission()) return
-            // 获取文件后缀
+            // // 获取文件后缀
             // const index = file.fileName.lastIndexOf('.')
             // const suffix = file.fileName.substring(index)
+            if (uni.getStorageSync('fileInfo')) {
+                uni.removeStorageSync('fileInfo')
+            }
+            if (file) {
+                this.GetStatisticsAddPv(1, file.archiveContentId)
+            }
+            uni.setStorageSync('fileInfo', file.content || '文章预览')
             this.openDocument(file)
             // if (suffix === '.doc' || suffix === '.ppt' || suffix === '.pptx' || suffix === '.docx') {
             //     //先将链接缓存
@@ -495,8 +478,16 @@ export default {
         // 打开文档
         openDocument(file) {
             uni.showLoading({
-                title:'加载中'
+                title: '加载中'
             })
+            if (this.permission !== 0) {
+                this.$api.navigateTo(
+                    `/pages/goods/goods-file-preview?userId=${this.userId}&archiveId=${this.archiveId}&permission=${
+                        this.permission
+                    }&fileName=${file.fileName}`
+                )
+                return
+            }
             // 获取文件后缀
             const index = file.fileName.lastIndexOf('.')
             const suffix = file.fileName.substring(index + 1)
@@ -505,23 +496,24 @@ export default {
                 url: file.fileUrl,
                 success(res) {
                     const filePath = res.tempFilePath
-                    console.log(filePath) 
+                    console.log(filePath)
                     console.log(file, res, '文件数据')
                     // 打开文件
                     uni.openDocument({
                         filePath: filePath,
                         fileType: suffix,
+                        showMenu: true,
                         success(res) {
                             console.log(res)
                             uni.showToast({
-                                icon:'success',
-                                title:'打开成功',
+                                icon: 'success',
+                                title: '打开成功',
                                 duration: 1200
                             })
                             uni.hideLoading()
                         },
                         fail(err) {
-                            if(err.errMsg.indexOf('fail filetype not supported')){
+                            if (err.errMsg.indexOf('fail filetype not supported')) {
                                 uni.showModal({
                                     content: '不支持的文件预览',
                                     cancelColor: '#666',
@@ -532,14 +524,14 @@ export default {
                         }
                     })
                 },
-                fail(err){
+                fail(err) {
                     uni.showToast({
                         title: JSON.stringify(err),
-                        icon:'none',
+                        icon: 'none',
                         duration: 5000
                     })
                     uni.hideLoading()
-                },
+                }
             })
         }
     }
@@ -570,17 +562,17 @@ export default {
     &.maxBottom {
         bottom: -100rpx;
         z-index: 999;
-        animation: permiMove .3s ease-in-out;
+        animation: permiMove 0.3s ease-in-out;
         animation-fill-mode: forwards;
     }
     text {
         font-size: 26rpx;
-        color: #FF5B00;
+        color: #ff5b00;
     }
     .cm-btn {
         width: 136rpx;
         height: 48rpx;
-        background: #FF5B00;
+        background: #ff5b00;
         border-radius: 28px;
         font-size: 26rpx;
         text-align: center;
@@ -652,7 +644,7 @@ export default {
                 .cm-preview {
                     font-size: 26rpx;
                     font-weight: 400;
-                    color: #FF5B00;
+                    color: #ff5b00;
                 }
                 .cm-time {
                     padding: 0;

+ 224 - 0
pages/goods/goods-file-preview.vue

@@ -0,0 +1,224 @@
+<template>
+    <view class="file-preview">
+        <view class="file" v-html="fileInfo"></view>
+        <view class="more" @click="checkPermission">查看更多</view>
+        <view
+            class="cm-login"
+            :class="{ maxBottom: !bottom && isIphoneX }"
+            :style="{ bottom: bottom }"
+            v-if="TipStatus && tipStatus"
+        >
+            <text>{{ TipStatus.text }}</text>
+            <view class="cm-btn" @click="nextAction(TipStatus.redirect)">{{ TipStatus.btn }}</view>
+        </view>
+        
+        <tui-modal
+            :show="showModal"
+            :content="TipStatus.text"
+            shape="circle"
+            :button="modalButton"
+            :fadeIn="true"
+            @click="handleModalClick"
+        ></tui-modal>
+    </view>
+</template>
+
+<script>
+    import { mapState } from 'vuex'
+    export default {
+        data() {
+            return {
+                modalButton: [
+                    {
+                        text: '取消',
+                        type: 'gray',
+                        plain: true //是否空心
+                    },
+                    {
+                        text: '确认',
+                        customStyle: {
+                            color: '#fff',
+                            bgColor: 'linear-gradient(90deg, #F28F31 0%, #FF5B00 100%)'
+                        },
+                        plain: false
+                    }
+                ],
+                showModal: false,
+                //用户信息相关
+                permission: 5, //用户权限  0可查看,1未登录,2需升级会员机构,3需升级医美会员机构,4需要抵扣采美豆,5无权限查看
+                userId: -1,
+                archiveId: -1,
+                fileInfo: '', // 文章预览
+                fileName: '', // 文章标题
+            }
+        },
+        computed: {
+            ...mapState(['isIphoneX']),
+            //资料查看状态提示
+            TipStatus() {
+                // 资料权限
+                const statusText = [
+                    false, // 正常访问
+                    { text: '请登录后查看!', btn: '去登录', redirect: '/pages/login/login' },
+                    { text: '请升级成为会员机构后方可查看!', btn: '去升级', redirect: '/pages/login/apply' },
+                    { text: '请升级成为医美会员机构后方可查看!', btn: '去升级', redirect: '/pages/login/apply' },
+                    { text: '需抵扣100采美豆方可查看!', btn: '去查看', redirect: 10 },
+                    { text: '无权限查看!', btn: '确认' }
+                ]
+                // 0可查看,1未登录,2需升级会员机构,3需升级医美会员机构,4需要抵扣采美豆,5无权限查看
+                return statusText[this.permission]
+            }
+        },
+        watch: {
+            TipStatus(val) {
+                if(this.TipStatus) {
+                    this.timer = setTimeout(()=>{
+                        this.tipStatus = false
+                        clearTimeout(this.timer)
+                    }, 10000)
+                }
+                this.$emit('tipStatus', this.TipStatus)
+            }
+        },
+        mounted() {
+            this.fileInfo = uni.getStorageSync('fileInfo')
+        },
+        onLoad(options) {
+            this.userId = options.userId
+            this.archiveId = options.archiveId
+            this.permission = options.permission
+            this.fileName = options.fileName
+            uni.setNavigationBarTitle({
+                title: this.fileName
+            })
+        },
+        methods: {
+            //用户权限校验拦截
+            checkPermission() {
+                //permission:查看权限:0可查看,1未登录,2需升级会员机构,3需升级医美会员机构,4需要抵扣采美豆,5无权限查看
+                const _self = this
+                // 如果 TipStatus 返回false 就放行
+                if (!_self.TipStatus) return 0
+                this.modalButton[1].text = this.TipStatus.btn
+                this.showModal = true
+                return -1
+            },
+            // 点击按钮后要做的事
+            nextAction(redirect) {
+                const _self = this
+                if (typeof redirect == 'string') {
+                    // 跳转链接
+                    this.$api.navigateTo(redirect)
+                }
+                if (redirect === 10) {
+                    this.searchArchiveByBean()
+                }
+            },
+            // modal 按钮点击
+            handleModalClick(e) {
+                // 点击确认按钮
+                if (e.index === 1) {
+                    this.showModal = false
+                    this.nextAction(this.TipStatus.redirect) //执行下一步
+                } else {
+                    this.showModal = false
+                }
+            },
+            //采美豆抵扣
+            searchArchiveByBean() {
+                this.BeautyArchive.SearchArchiveByBeans({
+                    userId: this.userId,
+                    archiveId: this.archiveId
+                })
+                    .then(res => {
+                        uni.showToast({
+                            duration: 1500,
+                            title: res.msg
+                        })
+                        setTimeout(() => {
+                            //刷新资料列表
+                            this.getDetail()
+                        }, 1500)
+                    })
+                    .catch(err => {
+                        uni.showToast({
+                            icon: 'none',
+                            duration: 1500,
+                            title: err.msg
+                        })
+                    })
+            },
+        }
+    }
+</script>
+
+<style lang="scss">
+    page {
+        background-color: #ccc;
+    }
+    .file-preview {
+        position: relative;
+        padding-bottom: 5%;
+        .file {
+            width: 90%;
+            min-height: 600rpx;
+            margin: 5% auto 0 auto;
+            background: #fff;
+            position: relative;
+        }
+        .file::after {
+            content: ' ';
+            position: absolute;
+            left: 0;
+            bottom: 0;
+            box-shadow: 0 -8px 15px red;
+            width: 100%;
+            height: 6rpx;
+        }
+        .more {
+            color: red;
+            position: absolute;
+            bottom: 0;
+            left: 50%;
+            transform: translate(-50%, -100%);
+            background: rgba(255, 255, 255, 0.8);
+            width: 90%;
+            text-align: center;
+        }
+    }
+    .cm-login {
+        position: fixed;
+        left: 24rpx;
+        bottom: 115rpx; // 包含商品导航
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        padding: 0 32rpx;
+        width: 702rpx;
+        height: 90rpx;
+        background: #ffe6dc;
+        border-radius: 16px;
+        box-sizing: border-box;
+        z-index: 9;
+        &.maxBottom {
+            bottom: -100rpx;
+            z-index: 999;
+            animation: permiMove .3s ease-in-out;
+            animation-fill-mode: forwards;
+        }
+        text {
+            font-size: 26rpx;
+            color: #FF5B00;
+        }
+        .cm-btn {
+            width: 136rpx;
+            height: 48rpx;
+            background: #FF5B00;
+            border-radius: 28px;
+            font-size: 26rpx;
+            text-align: center;
+            line-height: 48rpx;
+            color: #ffffff;
+        }
+    }
+</style>

+ 11 - 0
services/beautyArchive.service.js

@@ -36,4 +36,15 @@ export default class BeautyArchiveService {
               
         })
     }
+    
+    // 用户浏览资料记录
+    GetStatisticsAddPv(data = {}) {
+        return this.AjaxService.get({
+            url: '/commodity/statistics/addPv',
+            data,
+            isLoading: true,
+              
+        })
+    }
+    
 }