瀏覽代碼

Merge branch 'feature/v1.2.11' of https://jygit.jydev.jianyu360.cn/jianyu/jy-docs into dev/v1.2.11_wmh

wenmenghao 1 年之前
父節點
當前提交
7b4c72386d

+ 2 - 1
jydocs-back/config.json

@@ -38,7 +38,8 @@
       "key": "jydocs.partnerlib.rpc",
       "address": [
         "192.168.3.206:2379"
-      ]
+      ],
+      "timeout": 5000
     }
   },
   "indexSearchTag": [

+ 2 - 2
jydocs-back/config/config.go

@@ -34,9 +34,9 @@ type appConfig struct {
 		Base int64 `json:"base"` // 价格基数
 	} `json:"price"`
 	DocMember struct {
-		Times        int   `json:"times"`        // 会员免费下载次数
+		Times        int64 `json:"times"`        // 会员免费下载次数
 		Discount     int64 `json:"discount"`     // 会员折扣
-		FreeDocLimit int   `json:"freeDocLimit"` // 豆丁会员免费下载限制
+		FreeDocLimit int64 `json:"freeDocLimit"` // 豆丁会员免费下载限制
 	} `json:"docMember"`
 }
 

+ 1 - 1
jydocs-back/db.json

@@ -17,7 +17,7 @@
   },
   "redis": {
     "main": {
-      "address": "session=192.168.3.149:1713,other=192.168.3.149:1712"
+      "address": "session=192.168.3.149:1713,other=192.168.3.149:1712,new_other=192.168.3.149:1712"
     }
   },
   "nsqConfig": {

+ 1 - 1
jydocs-back/go.mod

@@ -4,7 +4,7 @@ go 1.21
 
 require (
 	app.yhyue.com/moapp/jyPoints v1.1.2-0.20231020023521-1a4b1bbf9736
-	app.yhyue.com/moapp/jy_docs v1.1.9
+	app.yhyue.com/moapp/jy_docs v1.1.10
 	app.yhyue.com/moapp/jybase v0.0.0-20240523083821-42a82b37ae20
 	app.yhyue.com/moapp/jyfs v0.0.0-20231024061508-480c270480d4
 	app.yhyue.com/moapp/jypkg v1.21.5

+ 2 - 2
jydocs-back/go.sum

@@ -6,8 +6,8 @@ app.yhyue.com/moapp/jyMarketing v0.0.2-0.20230304035551-21bb1eedf547/go.mod h1:J
 app.yhyue.com/moapp/jyPoints v1.1.2-0.20231020023521-1a4b1bbf9736 h1:7Vl3qq1nJZyRQNyMDoCTC14ScKABZqbUmJP0WpOLnIQ=
 app.yhyue.com/moapp/jyPoints v1.1.2-0.20231020023521-1a4b1bbf9736/go.mod h1:NEkVbas7w0Lg4/BPoN4rkl808q4OKv7Bk5lwTXvOThU=
 app.yhyue.com/moapp/jy_docs v1.1.1/go.mod h1:54sK98Z5tpMFd2aPLN1IRfEyV3zpFRyFxKj6oi2C5/Q=
-app.yhyue.com/moapp/jy_docs v1.1.9 h1:S7fTrwc/Q//hv//gIuVFbiY36NxeUNa5ReqMtXyqjVc=
-app.yhyue.com/moapp/jy_docs v1.1.9/go.mod h1:lFwlF0Lrh0VuYejyfXqlxyaVR4xU1zdHGDCKYbc5MH4=
+app.yhyue.com/moapp/jy_docs v1.1.10 h1:+DrKP22V0jDNFVZ16g0cpmGSz6nVqQMSisjT+s5iSDc=
+app.yhyue.com/moapp/jy_docs v1.1.10/go.mod h1:KJqoPg6h/Zl0N9PAMNEisoRXjFabtMtUK6tL4zAj39o=
 app.yhyue.com/moapp/jybase v0.0.0-20210322021809-141cc2c37946/go.mod h1:29ShuI8y7qEyg2KviHSx1iamiCioBKdTMm2ndVzWAhk=
 app.yhyue.com/moapp/jybase v0.0.0-20220415064050-37ce64b3e2d4/go.mod h1:qNRA0sHuYqcLoYoP8irpaWnW9YsXixe6obBIkwaXpD0=
 app.yhyue.com/moapp/jybase v0.0.0-20220418104200-46c3fff161c7/go.mod h1:qNRA0sHuYqcLoYoP8irpaWnW9YsXixe6obBIkwaXpD0=

+ 5 - 0
jydocs-back/public/consts.go

@@ -19,4 +19,9 @@ const (
 	PartnerState            = 1 // 豆丁
 	DdUserBuyType0          = 0 // 购买类型: 剑鱼文库会员超过10篇免费或者文库会员购买精品文档
 	DdUserBuyType1          = 1 // 购买类型:1 币买文档
+
+	RepeatKey = "docBuy_%d" // 一秒内重复请求
+	RedisCode = "new_other"
+
+	file_upload_ing = "file_upload_ing_%s" // 文档正在上传
 )

+ 12 - 0
jydocs-back/public/util.go

@@ -1,6 +1,7 @@
 package public
 
 import (
+	"app.yhyue.com/moapp/jybase/redis"
 	"fmt"
 	"sync"
 )
@@ -56,3 +57,14 @@ func GetNewDocBuyLock(str string) *sync.Mutex {
 	PLock.Unlock()
 	return PLock.UserLock[str]
 }
+
+func RequestValidation(positionId int64) (err error) {
+	repeatKey := fmt.Sprintf(RepeatKey, positionId)
+	if ok, redisErr := redis.Exists(RedisCode, repeatKey); ok && redisErr == nil {
+		err = fmt.Errorf("请求频繁 稍后再试")
+		return
+	}
+	//方式重复性请求--1秒内 允许请求一次
+	redis.Put("other", repeatKey, "REPEAT", 1)
+	return
+}

+ 1 - 1
jydocs-back/rpc/partnerRpc.go

@@ -18,7 +18,7 @@ func init() {
 		Etcd: discov.EtcdConf{
 			Key:   config.JyDocsAppConfig.RpcServers.Partner.Key,
 			Hosts: config.JyDocsAppConfig.RpcServers.Partner.Address,
-		},
+		}, Timeout: config.JyDocsAppConfig.RpcServers.Partner.Timeout,
 	}))
 }
 

+ 5 - 2
jydocs-back/rpc/stdDocRpc.go

@@ -118,8 +118,9 @@ return
 
 type returnDetail struct {
 	*stdlib.DocInfo
-	DocMemberPrice    int64 `json:"docMemberPrice"`
-	DocMemberDiscount int64 `json:"docMemberDiscount"`
+	DocMemberPrice    int64  `json:"docMemberPrice"`
+	DocMemberDiscount int64  `json:"docMemberDiscount"`
+	ImgId             string `json:"imgId"`
 }
 
 func GetDocDetail(userId, docId string, isBuyDetail bool) (*returnDetail, bool, bool, error) {
@@ -141,6 +142,7 @@ func GetDocDetail(userId, docId string, isBuyDetail bool) (*returnDetail, bool,
 		return nil, false, false, fmt.Errorf("查询文档异常")
 	}
 	detail := resp.DocDeail
+	imgId := detail.PreviewImgId
 	if detail.Source == public.SourceDd {
 		priceConfig := config.JyDocsAppConfig.Price[detail.Source][detail.ProductType]
 		// 豆丁的预览图和价格需要重新计算
@@ -153,6 +155,7 @@ func GetDocDetail(userId, docId string, isBuyDetail bool) (*returnDetail, bool,
 	rs := returnDetail{
 		DocInfo:           detail,
 		DocMemberDiscount: config.JyDocsAppConfig.DocMember.Discount,
+		ImgId:             imgId,
 	}
 	// 会员免费
 	if detail.ProductType == public.ProductTypeMemberFree {

+ 4 - 4
jydocs-back/rpc/userDocRpc.go

@@ -141,7 +141,7 @@ func PayDoc(userId, docId string) error {
 	}
 	return nil
 }
-func TodayCount(userId string) (int64, error) {
+func TodayCount(userId string) (int64, int64, error) {
 	resp, err := jyUserDocLib.UserTodayCount(context.Background(), &userlib.UserTodayCountReq{
 		AppId:       config.JyDocsAppConfig.AppId,
 		UserId:      userId,
@@ -149,11 +149,11 @@ func TodayCount(userId string) (int64, error) {
 	})
 	if err != nil {
 		log.Printf("%s UserTodayCount call error %v\n", userId, err)
-		return 0, err
+		return 0, 0, err
 	}
 	if resp.Code != 1 {
 		log.Printf("%s UserTodayCount fail Message %v\n", userId, resp.Message)
-		return 0, fmt.Errorf("获取用户下载次数失败")
+		return 0, 0, fmt.Errorf("获取用户下载次数失败")
 	}
-	return resp.Count, nil
+	return resp.Count, resp.TotalCount, nil
 }

+ 5 - 2
jydocs-back/servers/stdDoc.go

@@ -111,12 +111,12 @@ func (stdDoc *StdDoc) Detail() {
 		detail.OssDocId = ""
 		downloadStatus := 0 // 1- 免费用户下载豆丁免费次数用完
 		// 如果是会员免费文档 并且不是文库会员 并且没有买过 时免费判断判断有没有超过10篇
-		if !isBuy && userId != "" {
+		if !isBuy && userId != "" && detail.ProductType == public.ProductTypeMemberFree {
 			mData := jy.GetBigVipUserBaseMsg(stdDoc.Session(), *config.Middleground)
 			if mData != nil && mData.Data != nil {
 				if mData.Data.Docs.Status <= 0 {
 					// 免费用户 判断豆丁免费文档下载次数
-					count, err2 := rpc.TodayCount(userId)
+					count, _, err2 := rpc.TodayCount(userId)
 					if err2 != nil {
 						return nil, err2
 					}
@@ -192,6 +192,9 @@ func (stdDoc *StdDoc) GetDoc(sign string) {
 		fileId := detail.OssPdfId
 		if sign == "Down" {
 			fileId = detail.OssDocId
+			if b, _ := redis.Exists(public.RedisCode, fmt.Sprintf("file_upload_ing_%s", fileId)); b {
+				return nil, fmt.Errorf("文档正在上传中,请稍后再试")
+			}
 		}
 		url, err := rpc.GetFileContext(userId, fileId)
 		if err != nil {

+ 20 - 10
jydocs-back/servers/userDoc.go

@@ -90,6 +90,10 @@ func (userDoc *UserDoc) CollectRemove() {
 func (userDoc *UserDoc) DocBuy() {
 	// 加用户锁
 	userInfo := public.GetUserBaseInfo(userDoc.Session())
+	if err := public.RequestValidation(userInfo.PositionId); err != nil {
+		userDoc.ServeJson(NewResult(nil, err))
+		return
+	}
 	userId := userInfo.UserId
 	pLock := public.GetNewDocBuyLock(fmt.Sprintf("%s", userId))
 	pLock.Lock()
@@ -120,21 +124,26 @@ func (userDoc *UserDoc) DocBuy() {
 		}
 		docMemberStatus := mData.Data.Docs.Status > 0
 		freeDownload := mData.Data.Docs.FreeDownload
-		surplus, use := 0, 0 // 今日下载剩余次数,今日消耗次数
+		surplus, douding, use := int64(0), int64(0), int64(0) // 今日下载剩余次数,,今日豆丁消耗次数,今日消耗次数
+		var err2 error
 		payWay := "剑鱼币"
 		if docInfo.ProductType == public.ProductTypeMemberFree {
 			// 如果是会员免费 判断是否超出进入下载次数
 			// 获取今日下载次数
-			count, err2 := rpc.TodayCount(userId)
+			douding, use, err2 = rpc.TodayCount(userId)
 			if err2 != nil {
 				return nil, err2
 			}
 			totalLimit := config.JyDocsAppConfig.DocMember.FreeDocLimit
 			if docMemberStatus {
 				totalLimit = config.JyDocsAppConfig.DocMember.Times
+				surplus = totalLimit - use
+			} else {
+				surplus = totalLimit - douding
+				if surplus <= 0 { // 免费用户出错误提示直接返回
+					return nil, errors.New("免费文档下载次数达到限制")
+				}
 			}
-			use = int(count)
-			surplus = totalLimit - use
 			if surplus <= 0 {
 				surplus = 0
 				use = totalLimit
@@ -193,8 +202,9 @@ func (userDoc *UserDoc) DocBuy() {
 			bytes, err := json.Marshal(map[string]interface{}{
 				"name":    docInfo.DocName,
 				"summary": docInfo.DocSummary,
-				"img":     docInfo.PreviewImgId,
+				"img":     docInfo.ImgId,
 				"fType":   docInfo.DocFileType,
+				"source":  docInfo.Source,
 			})
 			if err != nil {
 				return nil, fmt.Errorf("文库异常")
@@ -207,17 +217,17 @@ func (userDoc *UserDoc) DocBuy() {
 		// 没有ossdocId 说明是还没有下过的 需要先获得地址
 		if docInfo.OssDocId == "" && docInfo.Source == public.SourceDd {
 			// 如果是精品文档 或者 是免费文档剑鱼文库会员超过10篇   则需要先调购买接口
-			if docInfo.ProductType == public.ProductTypePremium || use >= config.JyDocsAppConfig.DocMember.FreeDocLimit {
-				buyType := common.If(docMemberStatus, public.DdUserBuyType0, public.DdUserBuyType1).(int64)
-				_, err2 := rpc.PartUserBuy(docId, userInfo.MgoUserId, userInfo.Phone, userInfo.PositionId, buyType)
+			if docInfo.ProductType == int64(public.ProductTypePremium) || douding >= config.JyDocsAppConfig.DocMember.FreeDocLimit {
+				buyType := common.If(docMemberStatus, public.DdUserBuyType0, public.DdUserBuyType1).(int)
+				_, err2 := rpc.PartUserBuy(docId, userInfo.MgoUserId, userInfo.Phone, userInfo.PositionId, int64(buyType))
 				if err2 != nil {
-					return nil, fmt.Errorf("获取失败")
+					log.Println("PartUserBuy 获取失败")
 				}
 			}
 			// 下载接口
 			_, err := rpc.PartDocDownload(docId, userInfo.MgoUserId, userInfo.Phone, userInfo.PositionId)
 			if err != nil {
-				return nil, fmt.Errorf("文档获取失败")
+				log.Println("PartDocDownload 获取失败")
 			}
 		}
 		//转存文库

+ 6 - 5
jydocs-back/test/p525.http

@@ -42,11 +42,11 @@ Cookie: SESSIONID=d6d16e5272466216cb3fb63c80f82cb2938a4e6c;
 
 docId=docin-3176669581
 ###
-POST http://127.0.0.1:821/jydocs/user/buy
+POST https://jybx3-webtest.jydev.jianyu360.com/jydocs/user/buy
 Content-Type: application/x-www-form-urlencoded
-Cookie: SESSIONID=751b0b54bed58be980d081413c75088de0b1b6cb;
+Cookie: SESSIONID=d6d16e5272466216cb3fb63c80f82cb2938a4e6c;
 
-docId=docin-3176669650&phone=18439509554&payType=1
+docId=e718b220-8d2b-11eb-93d6-0050568f1307
 
 ###
 POST https://jybx3-webtest.jydev.jianyu360.com/jydocs/user/collect/add
@@ -56,8 +56,9 @@ Cookie: SESSIONID=751b0b54bed58be980d081413c75088de0b1b6cb;
 docId=docin-3176670033
 
 ###
-POST https://jybx3-webtest.jydev.jianyu360.com/jydocs/user/list
+POST http://127.0.0.1:821/jydocs/user/list
 Content-Type: application/x-www-form-urlencoded
 Cookie: SESSIONID=d6d16e5272466216cb3fb63c80f82cb2938a4e6c;
 
-sign=1&num=1&size=10
+sign=1&num=1&size=10
+

+ 2 - 2
jydocs-pc/.npmrc

@@ -1,2 +1,2 @@
-registry=https://registry.npmmirror.com/
-@jianyu:registry=http://192.168.3.207:4873/
+registry=http://192.168.3.71:4873/
+@jianyu:registry=http://192.168.3.71:4873/

+ 11 - 4
jydocs-pc/package.json

@@ -9,13 +9,20 @@
     "lint": "vue-cli-service lint --fix"
   },
   "dependencies": {
+    "@js-preview/docx": "^1.6.0",
+    "@js-preview/excel": "^1.7.3",
+    "@js-preview/pdf": "^2.0.1",
+    "@vue-office/docx": "^1.6.0",
+    "@vue-office/excel": "^1.7.3",
+    "@vue-office/pdf": "^2.0.1",
+    "core-js": "^3.8.3",
+    "vue": "^2.7.16",
+    "vue-demi": "^0.14.6",
     "axios": "^0.21.1",
-    "core-js": "^3.4.3",
-    "element-ui": "^2.15.14-rc",
+    "element-ui": "^2.15.16-rc",
     "punycode": "^2.3.1",
     "single-spa-vue": "^1.5.4",
     "systemjs-webpack-interop": "^1.1.2",
-    "vue": "^2.6.11",
     "vue-router": "^3.1.3",
     "vuex": "^3.4.0"
   },
@@ -36,6 +43,6 @@
     "sass": "^1.26.5",
     "sass-loader": "^8.0.2",
     "vue-cli-plugin-single-spa": "^1.0.1",
-    "vue-template-compiler": "^2.6.10"
+    "vue-template-compiler": "^2.7.16"
   }
 }

+ 5 - 0
jydocs-pc/src/components/collect-info/CollectInfo.vue

@@ -587,6 +587,7 @@ export default {
         jyarticle_see3_plus_pc: '免费享无限次查看标讯体验',
         pc_article_original_one: '标讯详情页-免费用户获取1次查看原文链接机会',
         pc_article_original_more: '标讯详情页-获取更多查看原文链接机会',
+        pc_library_details_free: '剑鱼文库-免费下载文档',
       },
       sourceTitleTopMap: {
         article_collection: '为给您匹配精准的推荐信息,请完善个人信息',
@@ -1278,6 +1279,10 @@ export default {
   .el-popper[x-placement^='bottom'] .popper__arrow {
     display: none;
   }
+  .el-select-dropdown__list {
+    display: flex;
+    flex-direction: column;
+  }
   .el-select-dropdown__item.selected {
     color: #2cb7ca !important;
   }

+ 1 - 3
jydocs-pc/src/components/doc-item-card/Card.vue

@@ -144,9 +144,6 @@ export default {
       ])
     }
   },
-  mounted () {
-    console.log(this.highlightKey, 'highlightKey')
-  },
   methods: {
     clickCard () {
       this.$emit('onClick')
@@ -190,6 +187,7 @@ export default {
   @include diy-icon("excel");
   @include diy-icon("ppt");
   @include diy-icon("pdf");
+  @include diy-icon("txt");
 
   .docs-card-header {
     font-size: 16px;

+ 1 - 0
jydocs-pc/src/components/filters-item/SelectCard.vue

@@ -119,6 +119,7 @@
   display: flex;
   align-items: center;
   .j-checkbox-label {
+    margin-right: 16px;
     font-size: 14px;
     line-height: 22px;
     color: #686868;

+ 98 - 18
jydocs-pc/src/views/Content.vue

@@ -12,8 +12,8 @@
           <div class="cd-tips">
             <ul>
               <li class="li-tags" v-for="item in getContentTags" :key="item">{{ item }}</li>
-              <li>{{ datas.viewTimes }}次浏览<el-divider direction="vertical"></el-divider></li>
-              <li>{{ datas.downTimes }}次下载<el-divider direction="vertical"></el-divider></li>
+              <li>{{ datas.viewTimes || 0 }}次浏览<el-divider direction="vertical"></el-divider></li>
+              <li>{{ datas.downTimes || 0 }}次下载<el-divider direction="vertical"></el-divider></li>
               <li>共{{ datas.docPageSize }}页<el-divider direction="vertical"></el-divider></li>
               <li>{{ datas.docFileSize }}<el-divider direction="vertical"></el-divider></li>
               <li class="no-line">{{ datas.uploadDate }}上传</li>
@@ -37,7 +37,22 @@
         </div>
         <div class="bottoms" id="colWidth">
           <div class="page">
-            <div class="cont-p" id="pdfPage"></div>
+            <div class="cont-p" v-show="fileTypeThis !== 'docx' && fileTypeThis !== 'xlsx'" id="pdfPage"></div>
+            <div class="file-content file-word-docx" v-if="fileTypeThis === 'docx'">
+              <vue-office-docx
+                  :src="fileSrc.docSrc"
+                  style="height: 100vh;"
+                  @rendered="rendered"
+              />
+            </div>
+            <div class="file-content file-word-docx" v-if="fileTypeThis === 'xlsx'">
+              <vue-office-excel
+                  :src="fileSrc.excelSrc"
+                  style="height: 100vh;"
+                  @rendered="rendered"
+                  @error="errorHandler"
+              />
+            </div>
           </div>
           <div class="foot-tip tops" id="footp">
             <div class="member-time-tip" v-if="redShow && islogin">
@@ -80,7 +95,7 @@
                     <span>{{ datas.price }}</span>
                     <span>原价下载</span>
                   </el-button>
-                  <el-button class="prime-cost" @click="downLoadFreeEvent" v-if="buyed !== 1 && !docsInfo.docStatus && docsInfo.freeDownload !== 1">
+                  <el-button class="prime-cost" @click="downLoadFreeEvent" v-if="islogin && buyed !== 1 && !docsInfo.docStatus && docsInfo.freeDownload !== 1">
                     <span>使用免费下载特权</span>
                     <span>(1次机会)</span>
                   </el-button>
@@ -96,11 +111,11 @@
                     <span>{{ datas.price }}</span>
                     <span>原价下载</span>
                   </el-button>
-                  <div class="coin before-coin" v-if="docsInfo.docStatus > 0">
+                  <div class="coin before-coin" v-if="docsInfo.docStatus > 0 && buyed === 0">
                     原价:<i class="el-icon-jy-iconJianYu"></i>
                     <span style="text-decoration: line-through;">{{ datas.price }}</span>
                   </div>
-                  <div class="coin after-coin" v-if="docsInfo.docStatus > 0">
+                  <div class="coin after-coin" v-if="docsInfo.docStatus > 0 && buyed === 0">
                     会员价:<i class="el-icon-jy-iconJianYu"></i>
                     <span style="color: #FF3A20;font-size: 24px;">{{ datas.docMemberPrice }}</span>
                   </div>
@@ -130,7 +145,7 @@
       </common-dialog>
       <div class="d-right">
         <div class="r-tops">
-          <a :href="item.s_link" v-for="item in adsUrl" :key="item.s_pic">
+          <a :href="item.s_link ? item.s_link : 'javascript:;'" v-for="item in adsUrl" :key="item.s_pic">
             <img :src="item.s_pic">
           </a>
         </div>
@@ -150,6 +165,12 @@ import { getSearchTag } from '../api/modules/home'
 import { getDocPays } from '../api/modules/purchase'
 import { getJyAdListApi } from '../api/modules/publicapply'
 import { mapState } from 'vuex'
+//引入VueOfficeDocx组件
+import VueOfficeDocx from '@vue-office/docx'
+import VueOfficeExcel from '@vue-office/excel'
+//引入相关样式
+import '@vue-office/docx/lib/index.css'
+import '@vue-office/excel/lib/index.css'
 export default {
   components: {
     [Button.name]: Button,
@@ -158,7 +179,9 @@ export default {
     [Message.name]: Message,
     vRecommend,
     commonDialog,
-    CollectInfo
+    CollectInfo,
+    VueOfficeDocx,
+    VueOfficeExcel
   },
   data () {
     return {
@@ -172,6 +195,7 @@ export default {
       coinNum: 0,
       btnName: '',
       buyed: 0,
+      downloadStatus: 0,
       collectd: 0,
       offsetTop: 0,
       offsetWidth: 0,
@@ -212,6 +236,11 @@ export default {
         startDate: 0
       },
       surplusDay: 0, // 剩余多少天到期
+      fileSrc: {
+        docSrc: '',
+        excelSrc: ''
+      },
+      fileTypeThis: '' // 当前文件类型
     }
   },
   created () {
@@ -253,7 +282,7 @@ export default {
       return nArr.splice(0, 3)
     },
     showCostBtn () {
-      return this.buyed !== 1 && !this.docsInfo.docStatus && this.docsInfo.freeDownload === 1 && this.datas.downloadStatus !== 1
+      return (this.buyed !== 1 && !this.docsInfo.docStatus && this.docsInfo.freeDownload === 1 && this.downloadStatus !== 1) || !this.islogin
     }
   },
   watch: {
@@ -264,13 +293,15 @@ export default {
           const date = parseInt(new Date().getTime() / 1000)
           const sevenDay = 60 * 60 * 24 * 7
           const oneDay = 60 * 60 * 24
-          const surplus = val.docsInfo?.endDate - date
-          if (val.docsInfo?.endDate - date <= sevenDay && val.docsInfo.dataStatus === 1) {
+          const surplus = parseInt(val.docsInfo?.endDate - date)
+          if (surplus <= sevenDay && val.docsInfo.docStatus === 1) {
             this.redShow = true
-            this.surplusDay = Math.ceil(surplus / oneDay) + '天后'
+            this.surplusDay = (surplus / oneDay)
             // 如果剩余天数不到1天,则显示今天到期
             if (this.surplusDay < 1) {
               this.surplusDay = '今天'
+            } else {
+              this.surplusDay = this.surplusDay.toFixed(0) + '天后'
             }
           }
         }
@@ -279,6 +310,12 @@ export default {
     }
   },
   methods: {
+    rendered(){
+      console.log("渲染完成")
+    },
+    errorHandler() {
+      console.log("渲染失败")
+    },
     // 使用免费下载特权
     downLoadFreeEvent () {
       if (this.docsInfo?.freeDownload === 0) {
@@ -312,7 +349,12 @@ export default {
       if (text === '立即充值') {
         window.location.href = '/swordfish/integral/index/recharge?id=' + this.datas.docId
       } else if (text === '明日再来' || text === '我知道了') {
-        this.dialogInfo.visible = false
+        if(this.dialogInfo.title === '文档下载成功') {
+          // 加载文档内容,刷新页面
+          location.reload()
+        } else {
+          this.dialogInfo.visible = false
+        }
       }
     },
     dialogCancel () {
@@ -341,7 +383,6 @@ export default {
       this.adverse()
       this.tabs = recoveryPageData('jy-docs-search-tags-pc')
       this.getTags()
-      this.details()
     },
     getSimpleData_ () {
       getSimpleData({ t: new Date().getTime() }).then((res) => {
@@ -370,7 +411,7 @@ export default {
       const t = document.getElementById('pdfPage')
       const b = t.getBoundingClientRect().bottom
       const dom = document.getElementById('footp')
-      if (b < 877) {
+      if (b < 700) {
         dom.style.position = 'unset'
       } else {
         dom.style.position = 'fixed'
@@ -437,7 +478,25 @@ export default {
       getShow({ docId: this.docIds }).then(res => {
         if (res.data.error_code === 0) {
           this.conts = res.data
-          this.init()
+          let FileIndex = 0
+          const fileExtensions = ['doc', 'docx', 'pdf', 'xls', 'xlsx', 'ppt', 'txt']
+          fileExtensions.forEach((v, index) => {
+            if(this.conts.data.indexOf(v) > -1){
+              FileIndex = index
+            }
+          })
+          this.fileTypeThis = fileExtensions[FileIndex]
+          switch (fileExtensions[FileIndex]) {
+            case 'docx':
+              this.fileSrc.docSrc = res.data.data
+              break;
+            case 'xlsx':
+              this.fileSrc.excelSrc = res.data.data
+              break;
+            default:
+              this.init()
+              break;
+          }
         } else {
           Message({
             message: res.data.error_msg,
@@ -496,9 +555,14 @@ export default {
           this.datas = res.data.detail
           this.datas.docFileSize = formatSize(this.datas.docFileSize)
           this.datas.uploadDate = dateFormatter(this.datas.uploadDate.replace(/-/g, '/'), 'yyyy/MM/dd')
-          this.datas.docSummary = this.datas.docSummary.split('').length >= 500 ? this.datas.docSummary + '...' : this.datas.docSummary
+          if(this.datas.docSummary) {
+            this.datas.docSummary = this.datas.docSummary.split('').length >= 500 ? this.datas.docSummary + '...' : this.datas.docSummary
+          } else {
+            this.datas.docSummary = ''
+          }
           this.datas.tags = this.datas.tags.split(',')
           this.buyed = res.data.status
+          this.downloadStatus = res.data.downloadStatus
           if (this.buyed === 1) {
             document.getElementById('fixedTop').style.display = 'block'
             document.getElementById('footp').style.position = 'fixed'
@@ -571,7 +635,7 @@ export default {
         }
         return
       }
-      if (this.buyed !== 1 && !this.docsInfo.docStatus && this.docsInfo.freeDownload !== 1) {
+      if (this.buyed !== 1 && !this.docsInfo.docStatus && this.docsInfo.freeDownload !== 1 && this.datas.productType === 1) {
         this.downLoadFreeEvent()
       } else {
         this.loadFile()
@@ -705,12 +769,20 @@ export default {
 .high-light{
   color: #2ABED1;
 }
+.cont-p {
+  .page, .canvasWrapper, canvas {
+    width: 100%!important;
+    height: auto;
+  }
+}
+
 </style>
 <style lang="scss" scoped>
 @include diy-icon('pdf', 24);
 @include diy-icon('word', 24);
 @include diy-icon('excel', 24);
 @include diy-icon('ppt', 24);
+@include diy-icon('txt', 24);
 @include diy-icon('share', 18);
 @include diy-icon('jubao', 18);
 @include diy-icon('weiguanzhu', 18);
@@ -1044,6 +1116,14 @@ export default {
           background: #fff;
           // padding: 24px 40px 32px;
         }
+        ::v-deep {
+          .docx-wrapper {
+            padding: 0;
+          }
+          .vue-office-docx .docx-wrapper>section.docx{
+            width: 100%!important;
+          }
+        }
       }
 
       .foot-tip {

+ 8 - 7
jydocs-pc/src/views/Home.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="pages--home">
       <div class="top-search-group flex-c-c center">
-        <h1>剑鱼文库,亿万文档资源库</h1>
+        <h1>剑鱼文库,上亿级文档资料库</h1>
         <search-input @submit="goSubmit"></search-input>
       </div>
 
@@ -16,7 +16,7 @@
           <div class="new-list-group must-bottom">
             <div class="word-model">
               <div class="word-model-content" :class="{'launch-alone': !launchActive}">
-                <div class="word-model-list" @mouseenter="onSetWordModel(item)" :class="{'active': item.active}" v-for="(item, index) in wordModel" :key="index">
+                <div class="word-model-list" @click="onSetWordModel(item)" :class="{'active': item.active}" v-for="(item, index) in wordModel" :key="index">
                   {{item.value}}
                 </div>
               </div>
@@ -36,16 +36,16 @@
               </div>
             </div>
             <!-- 文库会员广告位 -->
-            <div class="word-file-ad">
+            <div class="word-file-ad" v-if="jyPcDocMember && jyPcDocMember.length">
               <el-carousel height="80px">
-                <el-carousel-item @click="onDocLink(item)" v-for="(item, index) in jyPcDocMember" :key="index">
-                  <img :src="item.s_pic" :alt="item.s_remark">
+                <el-carousel-item v-for="(item, index) in jyPcDocMember" :key="index">
+                  <img @click.prevent="onDocLink(item)" :src="item.s_pic" :alt="item.s_remark">
                 </el-carousel-item>
               </el-carousel>
             </div>
             <!-- 文库推荐广告位 -->
-            <div class="word-recommend-ad">
-              <div class="word-recommend-ad-list" @click="onDocLink(item)" v-for="(item, index) in jyPcDocRecommend" :key="index">
+            <div class="word-recommend-ad" v-if="jyPcDocRecommend && jyPcDocRecommend.length">
+              <div class="word-recommend-ad-list" @click.stop="onDocLink(item)" v-for="(item, index) in jyPcDocRecommend" :key="index">
                 <img :src="item.s_pic" :alt="item.s_remark">
               </div>
             </div>
@@ -379,6 +379,7 @@ export default {
     @include diy-icon('word', 24);
     @include diy-icon('excel', 24);
     @include diy-icon('ppt', 24);
+    @include diy-icon('txt', 24);
 
     .list-item {
       cursor: pointer;

+ 16 - 16
jydocs-pc/src/views/Search.vue

@@ -113,13 +113,13 @@ export default {
         }
       ],
       productTypeList: [
-        {
-          label: '会员免费',
-          value: 1
-        }, 
         {
           label: '精品',
           value: 2
+        },
+        {
+          label: '会员免费',
+          value: 1
         }
       ],
       sortTypeList: [
@@ -191,13 +191,11 @@ export default {
       if (isSame || !this.searchQuery.text) {
         return
       }
-      this.$router.replace({
-        name: 'search',
-        query: {
-          type: this.searchQuery.type,
-          text: this.searchQuery.text
-        }
-      })
+      try {
+        this.$router.replace(`/search?text=${this.searchQuery.text}`)
+      } catch (error) {
+        
+      }
     },
     getSearchState: function (search) {
       if (search) {
@@ -286,17 +284,19 @@ export default {
     calcSubInfo (item) {
       const { docFileSize: size, downTimes, uploadDate, docPageSize } = item
       const subInfoArr = []
-      if (uploadDate !== undefined) {
+      if (uploadDate) {
         const data = uploadDate.replace(/-/g, '/')
-        subInfoArr.push(dateFormatter(data, 'yyyy/MM/dd'))
+        subInfoArr.push(dateFormatter(data, 'yyyy/MM/dd') + '上传')
       }
-      if (downTimes !== undefined) {
+      if (downTimes) {
         subInfoArr.push(`${downTimes}次下载`)
+      } else {
+        subInfoArr.push('0次下载')
       }
-      if (docPageSize !== undefined) {
+      if (docPageSize) {
         subInfoArr.push(`共${docPageSize}页`)
       }
-      if (size !== undefined) {
+      if (size) {
         subInfoArr.push(formatSize(size))
       }
       return subInfoArr

+ 1 - 0
jydocs-pc/src/views/UserDocs.vue

@@ -206,6 +206,7 @@ export default {
 @include diy-icon('word', 24);
 @include diy-icon('excel', 24);
 @include diy-icon('ppt', 24);
+@include diy-icon('txt', 24);
 .user-docs {
   background-color: #fff;
   margin: 0 auto;

+ 6 - 1
jydocs-pc/src/views/purchase/purchase.vue

@@ -170,7 +170,11 @@ export default {
           this.sessioninfor.payTime = payTime
           this.sessioninfor.payWay = payWay
           sessionStorage.setItem('paydata', JSON.stringify(this.sessioninfor))
-          this.$router.push('/purchasesuccess/' + this.response.price)
+          if(this.docsInfo.docStatus > 0) {
+            this.$router.push('/purchasesuccess/' + this.response.docMemberPrice)
+          } else {
+            this.$router.push('/purchasesuccess/' + this.response.price)
+          }
         }
       })
     },
@@ -214,6 +218,7 @@ export default {
     @include diy-icon("excel");
     @include diy-icon("ppt");
     @include diy-icon("pdf");
+    @include diy-icon("txt");
     .icon_jianyu{
       display: flex;
       width: 24px;

+ 5 - 0
jydocs-pc/src/views/purchase/purchasesuccess.vue

@@ -85,6 +85,11 @@ export default {
       getDown({ docId: this.payinfor.docId }).then(res => {
         if (res.data.error_code === 0) {
           window.location.href = res.data.data
+        } else {
+          Message({
+            message: res.data.error_msg,
+            type: 'warning'
+          })
         }
       })
     }

文件差異過大導致無法顯示
+ 123 - 123
jydocs-pc/yarn.lock


部分文件因文件數量過多而無法顯示