xgwangman 4 vuotta sitten
vanhempi
commit
9fa6607af5

+ 2 - 0
.gitignore

@@ -29,3 +29,5 @@ yarn-error.log*
 *.7z
 .vscode
 jydocs-mobile/page_docs_app
+jydocs-pc/pc
+jydocs-pc/app

+ 18 - 0
README.md

@@ -100,3 +100,21 @@ location ^~/page_docs {
 }
 ```
 
+```
+# 静态资源配置
+# 1. 禁止html缓存
+location ~ ^\/(.*).html {
+    add_header         Pragma   no-cache;
+    add_header         Expires  0;
+    add_header         Cache-Control no-cache,no-store,must-revalidate;
+    
+    root html;
+}
+# 2. 静态资源配置(vue程序刷新404问题)
+location ~ ^\/page_(.*?)\/ {
+    root html;
+    index index.html;
+    try_files $uri $uri/ /page_$1/index.html;
+}
+```
+

+ 4 - 1
jydocs-back/db.json

@@ -15,7 +15,10 @@
       "password": "123456"
     }
   },
-  "nsqAddress": "192.168.3.240:4260",
+  "nsqConfig": {
+    "address": "192.168.3.240:4260",
+    "appName": "jywx_node"
+  },
   "redis": {
     "main": {
       "address": "session=192.168.3.128:1712,other=192.168.3.128:1712"

+ 5 - 3
jydocs-back/go.mod

@@ -3,10 +3,12 @@ module jy-docs
 go 1.13
 
 require (
-	app.yhyue.com/moapp/jyPoints v0.0.0-20210319072011-5430a201e0aa
-	app.yhyue.com/moapp/jy_docs v0.0.0-20210322023024-a4be186876a3
-	app.yhyue.com/moapp/jybase v0.0.0-20210319015107-fe59d2046cf8
+	app.yhyue.com/moapp/jyPoints v0.0.0-20210319094929-f8c029fa5c82
+	app.yhyue.com/moapp/jy_docs v0.0.0-20210323032815-1d9b66bd95c0
+	app.yhyue.com/moapp/jybase v0.0.0-20210322021809-141cc2c37946
 	app.yhyue.com/moapp/jyfs v0.0.0-20210319011832-6cf539ddc5cd
+	app.yhyue.com/moapp/message v0.0.0-20210322082125-2a9762351105
 	github.com/SKatiyar/qr v0.0.0-20151201054752-25b6bdf44e67
+	github.com/nsqio/go-nsq v1.0.8
 	github.com/tal-tech/go-zero v1.1.5
 )

+ 13 - 0
jydocs-back/go.sum

@@ -13,6 +13,8 @@ app.yhyue.com/moapp/jyPoints v0.0.0-20210319020458-484a38074edd h1:O/QPSt7jIG5KK
 app.yhyue.com/moapp/jyPoints v0.0.0-20210319020458-484a38074edd/go.mod h1:nz39UQcXwZV90vOC7rIfos4LgrjGDcywHo96rdywdzk=
 app.yhyue.com/moapp/jyPoints v0.0.0-20210319072011-5430a201e0aa h1:SsH/bCryyvPUuorQqBPBDWFlz8jAO94DTvIb0mjfiEg=
 app.yhyue.com/moapp/jyPoints v0.0.0-20210319072011-5430a201e0aa/go.mod h1:ZuQoeKgip9OrJPRDpXkv4XOHV/oFIqL1aK+tcfIN+KQ=
+app.yhyue.com/moapp/jyPoints v0.0.0-20210319094929-f8c029fa5c82 h1:GoyZQMQNVfi+f1DEZjc+xrwOMyejEp7Nk+/grjc20fg=
+app.yhyue.com/moapp/jyPoints v0.0.0-20210319094929-f8c029fa5c82/go.mod h1:ZuQoeKgip9OrJPRDpXkv4XOHV/oFIqL1aK+tcfIN+KQ=
 app.yhyue.com/moapp/jy_docs v0.0.0-20210317071040-be6d030d6122 h1:KzsaloFf6dT2JdcshC4CvYMFPVrpF1dD/pQ1H0wRAHk=
 app.yhyue.com/moapp/jy_docs v0.0.0-20210317071040-be6d030d6122/go.mod h1:PfrdcgOFwgvShGRVjDaMnv5masAd8Hl0URHFARyeqZ8=
 app.yhyue.com/moapp/jy_docs v0.0.0-20210317080833-0136e1a73ba8 h1:xizJ4BYH42vmYrgteaPNPcwF7/9G7uJO6uGgeuRDrwk=
@@ -47,16 +49,26 @@ app.yhyue.com/moapp/jy_docs v0.0.0-20210322014639-b4fe40444b05 h1:Dy0xuYezteDAkr
 app.yhyue.com/moapp/jy_docs v0.0.0-20210322014639-b4fe40444b05/go.mod h1:jfOmPb/ZELpHsA39HDAhCkBPUH/3Jaix7JhzPzcmK6A=
 app.yhyue.com/moapp/jy_docs v0.0.0-20210322023024-a4be186876a3 h1:5BhmeUgOf9lA8lXifqMcIJ70v+vMpPBEQfZvZbzySMA=
 app.yhyue.com/moapp/jy_docs v0.0.0-20210322023024-a4be186876a3/go.mod h1:jfOmPb/ZELpHsA39HDAhCkBPUH/3Jaix7JhzPzcmK6A=
+app.yhyue.com/moapp/jy_docs v0.0.0-20210322055013-5f0c3625a092 h1:HPNzAliG4sLQOzqN7JjoRRdv+8PqQPuTyUMxDRbiPvA=
+app.yhyue.com/moapp/jy_docs v0.0.0-20210322055013-5f0c3625a092/go.mod h1:XQ0SPQX4rLnOBelx6WRl8wyRT6T9xhfGzxldglLsBgU=
+app.yhyue.com/moapp/jy_docs v0.0.0-20210323011904-8fb7e73d8a90 h1:csXuChAsCUi+73azeDgDsdBJyxSC8ahC0yBHN+8jcU4=
+app.yhyue.com/moapp/jy_docs v0.0.0-20210323011904-8fb7e73d8a90/go.mod h1:XQ0SPQX4rLnOBelx6WRl8wyRT6T9xhfGzxldglLsBgU=
+app.yhyue.com/moapp/jy_docs v0.0.0-20210323032815-1d9b66bd95c0 h1:I8NVbS/fuLVMmEjrzQ3xDgd6qG5kATn2vXo11z2fMtg=
+app.yhyue.com/moapp/jy_docs v0.0.0-20210323032815-1d9b66bd95c0/go.mod h1:XQ0SPQX4rLnOBelx6WRl8wyRT6T9xhfGzxldglLsBgU=
 app.yhyue.com/moapp/jybase v0.0.0-20210317020927-18b0165f5ff9 h1:LVIuqXMqcclMwBbSmqEzXi0nIEiir+a2GpWAqksmfzk=
 app.yhyue.com/moapp/jybase v0.0.0-20210317020927-18b0165f5ff9/go.mod h1:29ShuI8y7qEyg2KviHSx1iamiCioBKdTMm2ndVzWAhk=
 app.yhyue.com/moapp/jybase v0.0.0-20210318061912-f5594310c8fe h1:RSQIrriyi534CCrI/sSLGW+Rd0X/0W4VDDXIalHVo8c=
 app.yhyue.com/moapp/jybase v0.0.0-20210318061912-f5594310c8fe/go.mod h1:29ShuI8y7qEyg2KviHSx1iamiCioBKdTMm2ndVzWAhk=
 app.yhyue.com/moapp/jybase v0.0.0-20210319015107-fe59d2046cf8 h1:0wnq1iFfpPrASDJzO24+Lr2pMO18ISNDf1n4TU3faTQ=
 app.yhyue.com/moapp/jybase v0.0.0-20210319015107-fe59d2046cf8/go.mod h1:29ShuI8y7qEyg2KviHSx1iamiCioBKdTMm2ndVzWAhk=
+app.yhyue.com/moapp/jybase v0.0.0-20210322021809-141cc2c37946 h1:w4voEoJ5RqjlUyGhNC15sk3RdwCCi2U5uX33Btw9BMc=
+app.yhyue.com/moapp/jybase v0.0.0-20210322021809-141cc2c37946/go.mod h1:29ShuI8y7qEyg2KviHSx1iamiCioBKdTMm2ndVzWAhk=
 app.yhyue.com/moapp/jyfs v0.0.0-20210309070327-ecad67beabb8 h1:Mg5E4O+5mCjRyW2b4/bNRQMz8ilzWfa7qaOjKT7SNRY=
 app.yhyue.com/moapp/jyfs v0.0.0-20210309070327-ecad67beabb8/go.mod h1:iflE6z/Ee5f7YZy2DSj7S6asyL1yCbu3BjK/xMYMiDY=
 app.yhyue.com/moapp/jyfs v0.0.0-20210319011832-6cf539ddc5cd h1:9BfrTYqDEeF41+CWT26fstOiMio0GKl5jgIrBeWZFkY=
 app.yhyue.com/moapp/jyfs v0.0.0-20210319011832-6cf539ddc5cd/go.mod h1:iflE6z/Ee5f7YZy2DSj7S6asyL1yCbu3BjK/xMYMiDY=
+app.yhyue.com/moapp/message v0.0.0-20210322082125-2a9762351105 h1:XT+Gwe8Axff2pkcpoQb0a31ZtAiLoFzlEc4RvVTtCEk=
+app.yhyue.com/moapp/message v0.0.0-20210322082125-2a9762351105/go.mod h1:ZkUh8EKI2GgWNuV5XAgS1fAZdJKbe4zgR+DO3ZuQFFs=
 cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
@@ -328,6 +340,7 @@ github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJ
 github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
 github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
 github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
+github.com/nsqio/go-nsq v1.0.8/go.mod h1:vKq36oyeVXgsS5Q8YEO7WghqidAVXQlcFxzQbQTuDEY=
 github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
 github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
 github.com/olivere/elastic/v7 v7.0.22/go.mod h1:VDexNy9NjmtAkrjNoI7tImv7FR4tf5zUA3ickqu5Pc8=

+ 16 - 5
jydocs-back/public/db.go

@@ -2,6 +2,7 @@ package public
 
 import (
 	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/redis"
 	"app.yhyue.com/moapp/message/model"
@@ -27,8 +28,7 @@ type dbConf struct {
 	Redis struct {
 		Main *redisConf
 	}
-	NsqAppMsgName string
-	NsqAddress    string
+	NsqConfig *NsqConfig
 }
 
 type mgoConf struct {
@@ -42,6 +42,10 @@ type mgoConf struct {
 	Collection_back string
 }
 
+type NsqConfig struct {
+	Address string
+	AppName string
+}
 type redisConf struct {
 	Address string
 }
@@ -76,10 +80,10 @@ func init() {
 			log.Println("初始化 redis")
 			redis.InitRedisBySize(DbConf.Redis.Main.Address, 100, 30, 300)
 		}
-		if DbConf.NsqAddress != "" {
+		if DbConf.NsqConfig != nil {
 			log.Println("初始化 nsq")
 			var NsqErr error
-			NSQ_Producer, NsqErr = nsq.NewProducer("192.168.3.240:4260", nsq.NewConfig())
+			NSQ_Producer, NsqErr = nsq.NewProducer(DbConf.NsqConfig.Address, nsq.NewConfig())
 			if NsqErr != nil {
 				log.Printf("初始化 nsq 异常 %v\n", NsqErr)
 			}
@@ -89,16 +93,23 @@ func init() {
 
 //分享打开文库赚积分
 func OpenShareJydoc(fromId, openId, docId string) {
+	fromId = encrypt.SE.DecodeString(fromId)
 	if fromId == "" || openId == fromId || openId == "" || docId == "" {
 		return
 	}
+	//判断是否是合法用户
+	if MQFW.Count("user", map[string]interface{}{
+		"_id": mongodb.StringTOBsonId(fromId),
+	}) == 0 {
+		return
+	}
 	if redis.Get("other", fmt.Sprintf("integral_article_%s_%s", fromId, docId)) == nil {
 		pushErr := func() error {
 			b, _ := json.Marshal(&model.Message{
 				E_code:   "jydocs_doc_open",
 				E_userId: fromId,
 				E_time:   time.Now().Unix(),
-				E_app:    DbConf.NsqAppMsgName,
+				E_app:    DbConf.NsqConfig.AppName,
 			})
 			if err := NSQ_Producer.Publish("jy_event", b); err != nil {
 				log.Printf("消息发布异常%v\n", err)

+ 7 - 4
jydocs-back/rpc/stdDocRpc.go

@@ -106,7 +106,7 @@ return
 	DocInfo 文库详情
 	error 异常
 */
-func GetDocDetail(userId, docId string) (*stdlib.DocInfo, bool, error) {
+func GetDocDetail(userId, docId string) (*stdlib.DocInfo, bool, bool, error) {
 	resp, err := jyStdDocStdlib.DocGetCheck(context.Background(), &stdlib.DocGetCheckReq{
 		AppId:  config.JyDocsAppConfig.AppId,
 		UserId: userId,
@@ -114,11 +114,14 @@ func GetDocDetail(userId, docId string) (*stdlib.DocInfo, bool, error) {
 	})
 	if err != nil {
 		log.Printf("%s GetDocDetail call error %v\n", userId, err)
-		return nil, false, err
+		return nil, false, false, err
 	}
 	if resp.Code != 1 {
 		log.Printf("%s GetDocDetail fail Message %v\n", userId, resp.Msg)
-		return nil, false, fmt.Errorf("获取内容失败")
+		return nil, false, false, fmt.Errorf("获取内容失败")
 	}
-	return resp.DocDeail, resp.IsBuy, nil
+	if resp.DocDeail == nil {
+		return nil, false, false, fmt.Errorf("查询文档异常")
+	}
+	return resp.DocDeail, resp.IsBuy, resp.IsCollect, nil
 }

+ 0 - 1
jydocs-back/rpc/userDocRpc.go

@@ -48,7 +48,6 @@ func GetUserDocs(userId string, pageNum, pageSize, colloctType int64) (interface
 		log.Printf("%s GetUserDocs fail Message %v\n", userId, resp.Message)
 		return nil, -1, fmt.Errorf("获取文库列表失败")
 	}
-	log.Printf("用户id:%s appid:%d 返回值:%+v\n", userId, config.JyDocsAppConfig.AppId, resp)
 	return resp.Data, resp.Count, nil
 }
 

+ 17 - 7
jydocs-back/servers/stdDoc.go

@@ -63,10 +63,14 @@ func (stdDoc *StdDoc) Detail() {
 	userId := common.ObjToString(stdDoc.GetSession("userId"))
 	rData, errMsg := func() (interface{}, error) {
 		docId := stdDoc.GetString("docId")
+		from := stdDoc.GetString("from")
 		if docId == "" {
 			return nil, fmt.Errorf("参数异常")
 		}
-		detail, isBuy, err := rpc.GetDocDetail(userId, docId)
+		if from != "" { //分享赚积分
+			go public.OpenShareJydoc(from, userId, docId)
+		}
+		detail, isBuy, IsCollect, err := rpc.GetDocDetail(userId, docId)
 		if err != nil {
 			return nil, err
 		}
@@ -74,9 +78,11 @@ func (stdDoc *StdDoc) Detail() {
 		detail.OssPdfId = ""
 		detail.OssDocId = ""
 		detail.PreviewImgId = fmt.Sprintf("https://%s.%s/%s", config.JyDocsAppConfig.OssBucket.Priv, config.JyDocsAppConfig.OssAdmin, detail.PreviewImgId)
+
 		return map[string]interface{}{
-			"status": common.If(isBuy, 1, 0),
-			"detail": detail,
+			"status":  common.If(isBuy, 1, 0),
+			"collect": common.If(IsCollect, 1, 0),
+			"detail":  detail,
 		}, nil
 	}()
 	if errMsg != nil {
@@ -92,7 +98,7 @@ func (stdDoc *StdDoc) GetDoc(sign string) {
 		if docId == "" {
 			return nil, fmt.Errorf("参数异常")
 		}
-		detail, isBuy, err := rpc.GetDocDetail(userId, docId)
+		detail, isBuy, _, err := rpc.GetDocDetail(userId, docId)
 		if err != nil {
 			return nil, err
 		}
@@ -107,6 +113,9 @@ func (stdDoc *StdDoc) GetDoc(sign string) {
 		if err != nil {
 			return nil, err
 		}
+		if strings.HasPrefix(url, "http://") {
+			url = strings.Replace(url, "http://", "https://", 1)
+		}
 		return url, nil
 	}()
 	if errMsg != nil {
@@ -132,7 +141,6 @@ func (stdDoc *StdDoc) TopList() {
 			return nil, fmt.Errorf("未知请求")
 		}
 		//存入redis缓存
-
 		list, _, err := rpc.GetDocQuery(userId, "", "", 1, num, reqSort)
 		if err != nil {
 			return nil, err
@@ -160,8 +168,10 @@ func (stdDoc *StdDoc) ActivityList() {
 		if err != nil {
 			return nil, err
 		}
-		for i := 0; i < len(list); i++ {
-			list[i].DocImg = fmt.Sprintf("https://%s.%s/%s", config.JyDocsAppConfig.OssBucket.Priv, config.JyDocsAppConfig.OssAdmin, list[i].DocImg)
+		if list != nil && len(list) > 0 {
+			for i := 0; i < len(list); i++ {
+				list[i].DocImg = fmt.Sprintf("https://%s.%s/%s", config.JyDocsAppConfig.OssBucket.Priv, config.JyDocsAppConfig.OssAdmin, list[i].DocImg)
+			}
 		}
 		return list, nil
 	}()

+ 1 - 1
jydocs-back/servers/userDoc.go

@@ -100,7 +100,7 @@ func (userDoc *UserDoc) DocBuy() {
 			return nil, err
 		}
 		//查询文档所需积分
-		docInfo, isBuy, err := rpc.GetDocDetail(userId, docId)
+		docInfo, isBuy, _, err := rpc.GetDocDetail(userId, docId)
 		if err != nil {
 			return nil, err
 		}

+ 1 - 1
jydocs-mobile/.env.production

@@ -2,4 +2,4 @@ NODE_ENV=production
 VUE_APP_BASE_API='/jydocs/'
 BASE_URL = '/page_docs_app/'
 VUE_APP_BASE_URL = '/page_docs_app/'
-VUE_APP_LOG_URL='https://web2-jytest.jianyu360.cn/jyintegral/pointsLogs?logAction='
+VUE_APP_LOG_URL='https://web2-jytest.jydev.jianyu360.com/jyLogs/pointsLogs?logAction='

+ 5 - 0
jydocs-mobile/.env.test

@@ -0,0 +1,5 @@
+NODE_ENV=production
+VUE_APP_BASE_API='/jydocs/'
+BASE_URL = '/page_docs_app/'
+VUE_APP_BASE_URL = '/page_docs_app/'
+VUE_APP_LOG_URL='https://web2-jytest.jydev.jianyu360.com/jyLogs/pointsLogs?logAction='

+ 1 - 0
jydocs-mobile/package.json

@@ -5,6 +5,7 @@
   "scripts": {
     "serve": "vue-cli-service serve",
     "build": "vue-cli-service build",
+    "build:test": "vue-cli-service build --mode test",
     "lint": "vue-cli-service lint"
   },
   "dependencies": {

+ 14 - 4
jydocs-mobile/src/views/Search.vue

@@ -178,6 +178,7 @@ export default class extends Vue {
       finished: true,
       pageNum: 1,
       total: 0,
+      scrollTop: 0,
       list: []
     }
     Object.assign(this.listState, state)
@@ -190,6 +191,7 @@ export default class extends Vue {
   docTypeChange () {
     if (!this.listState.value) return
     this.resetListState()
+    this.setScrollTop()
     this.listState.finished = false
     this.getList()
   }
@@ -206,12 +208,14 @@ export default class extends Vue {
     }
     if (!this.listState.value) return
     this.resetListState()
+    this.setScrollTop()
     this.listState.finished = false
     this.getList()
   }
 
   doSearch () {
     this.resetListState()
+    this.setScrollTop()
     this.listState.finished = false
     this.getList()
   }
@@ -278,6 +282,13 @@ export default class extends Vue {
     return [dateFormatter(uploadDate, 'yyyy/MM/dd'), `${downTimes}次下载`]
   }
 
+  setScrollTop () {
+    this.$nextTick(() => {
+      const wrapper: any = this.$refs.scrollWrap
+      wrapper.scrollTop = this.listState.scrollTop
+    })
+  }
+
   reStoreState () {
     const listInfo = this.searchState
     if (!listInfo || Object.keys(listInfo).length === 0) {
@@ -286,11 +297,10 @@ export default class extends Vue {
       for (const key in listInfo) {
         this.$data[key] = listInfo[key]
       }
-      this.$nextTick(() => {
-        const wrapper: any = this.$refs.scrollWrap
-        wrapper.scrollTop = this.listState.scrollTop
+      setTimeout(() => {
+        this.setScrollTop()
         this.clearSearchState()
-      })
+      }, 50)
       return true
     }
   }

+ 3 - 3
jydocs-pc/.env.development

@@ -1,6 +1,6 @@
 NODE_ENV=development
 VUE_APP_BASE_API='/jydocs/'
-VUE_APP_BASE_URL='/swordfish/frontPage/docs/free/index/'
-VUE_APP_MOCK=true
+VUE_APP_BASE_URL='/swordfish/frontPage/docs/sess/index/'
+VUE_APP_MOCK=false
 VUE_APP_BASE_PUBLIC='http://localhost:8080/'
-VUE_APP_LOG_URL='https://web2-jytest.jianyu360.cn/jyintegral/pointsLogs?logAction='
+VUE_APP_LOG_URL='https://web2-jytest.jydev.jianyu360.com/jyLogs/pointsLogs?logAction='

+ 1 - 1
jydocs-pc/.env.production

@@ -2,4 +2,4 @@ NODE_ENV=production
 VUE_APP_BASE_API='/jydocs/'
 VUE_APP_BASE_URL='/swordfish/docs/index'
 VUE_APP_BASE_PUBLIC='/page_docs/'
-VUE_APP_LOG_URL='https://web2-jytest.jianyu360.cn/jyintegral/pointsLogs?logAction='
+VUE_APP_LOG_URL='https://www.jianyu360.com/jyLogs/pointsLogs?logAction='

+ 5 - 0
jydocs-pc/.env.test

@@ -0,0 +1,5 @@
+NODE_ENV=production
+VUE_APP_BASE_API='/jydocs/'
+VUE_APP_BASE_URL='/swordfish/docs/index'
+VUE_APP_BASE_PUBLIC='/page_docs/'
+VUE_APP_LOG_URL='https://web2-jytest.jydev.jianyu360.com/jyLogs/pointsLogs?logAction='

+ 3 - 1
jydocs-pc/package.json

@@ -6,13 +6,15 @@
     "serve": "vue-cli-service serve --port 8080",
     "serve:alone": "vue-cli-service serve --mode alone",
     "build": "vue-cli-service build",
+    "build:test": "vue-cli-service build --mode test",
     "lint": "vue-cli-service lint --fix"
   },
   "dependencies": {
     "axios": "^0.21.1",
     "core-js": "^3.4.3",
     "element-ui": "^2.15.1",
-    "pdfjs": "^2.4.2",
+    "pdfh5": "^1.3.20",
+    "pdfjs-dist": "^2.6.347",
     "single-spa-vue": "^1.5.4",
     "systemjs-webpack-interop": "^1.1.2",
     "vue": "^2.6.10",

+ 1 - 0
jydocs-pc/src/api/modules/detail.js

@@ -60,6 +60,7 @@ export function getRemove (data) {
 export function getCoin (data) {
   console.log(data)
   return request({
+    baseURL: '/jyintegral',
     url: '/getList',
     method: 'post',
     data

+ 1 - 0
jydocs-pc/src/api/modules/purchase.js

@@ -22,6 +22,7 @@ export function getDocPays (data) {
 export function getJYchannel (data) {
   data = qs.stringify(data)
   return request({
+    baseURL: '/jyintegral',
     url: '/getList',
     method: 'post',
     data: data

+ 3 - 1
jydocs-pc/src/components/Search.vue

@@ -59,7 +59,9 @@ export default {
               label: v
             }
           })
-          this.type = this.tabs[0].type
+          if (this.type === '') {
+            this.type = this.tabs[0].type
+          }
           sessionStorage.setItem('jy-docs-search-tags-pc', JSON.stringify(this.tabs))
         }
       })

+ 3 - 11
jydocs-pc/src/router.js

@@ -18,23 +18,13 @@ export default new Router({
       name: 'content',
       component: () => import('@/views/Content.vue')
     },
-    {
-      path: '/keep',
-      name: 'keep',
-      component: () => import('@/views/Keep.vue')
-    },
-    {
-      path: '/mine',
-      name: 'mine',
-      component: () => import('@/views/Mine.vue')
-    },
     {
       path: '/search',
       name: 'search',
       component: () => import('@/views/Search.vue')
     },
     {
-      path: '/purchase',
+      path: '/purchase/:id',
       name: 'purchase',
       component: () => import('@/views/purchase/purchase.vue')
     },
@@ -46,12 +36,14 @@ export default new Router({
     {
       // 我的文库
       path: '/user/docs',
+      alias: '/mine',
       name: 'user-docs',
       component: () => import('@/views/UserDocs.vue')
     },
     {
       // 我的收藏
       path: '/user/collections',
+      alias: '/keep',
       name: 'user-docs',
       component: () => import('@/views/UserCollections.vue')
     },

+ 25 - 0
jydocs-pc/src/views/404.vue

@@ -1,5 +1,30 @@
 <template>
   <div class="page-404">
     <h3>这里什么也没有</h3>
+    <div v-if="false">
+      <el-button @click="getTest" :loading="fullscreenLoading" type="primary">模拟Ajax</el-button>
+      <el-button  @click="getLoginStatus" type="info">获取登录状态</el-button>
+    </div>
   </div>
 </template>
+
+<script>
+import { Button } from 'element-ui'
+
+export default {
+  name: '404',
+  components: {
+    [Button.name]: Button
+  },
+  data () {
+    return {
+      fullscreenLoading: false
+    }
+  },
+  methods: {
+    getLoginStatus: function () {
+      alert(loginflag)
+    }
+  }
+}
+</script>

+ 17 - 12
jydocs-pc/src/views/Content.vue

@@ -86,8 +86,8 @@
 <script>
 import { Button, Tooltip, Divider, Message } from 'element-ui'
 import { getDetails, getShow, getDown, getAdverse, getCoin, getAdd, getRemove } from '../api/modules/detail'
-// import { pdfjsViewer } from 'pdfviewerjs'
-// import { pdfjsLib } from 'pdfjs'
+const pdfjsLib = require('pdfjs-dist/build/pdf.js')
+const pdfjsViewer = require('pdfjs-dist/web/pdf_viewer.js')
 export default {
   components: {
     [Button.name]: Button,
@@ -114,7 +114,10 @@ export default {
       pdfDocument: null,
       config: {
         PAGE_TO_VIEW: 0,
-        SCALE: 1.0
+        SCALE: 1.0,
+        CMAP_URL: 'https://cdn.jsdelivr.net/npm/pdfjs-dist@2.6.347/cmaps/',
+        CMAP_PACKED: true,
+        workerSrc: 'https://cdn.jsdelivr.net/npm/pdfjs-dist@2.6.347/es5/build/pdf.worker.min.js'
       },
       pData: {
         heightList: []
@@ -123,13 +126,12 @@ export default {
   },
   created () {
     this.docIds = this.$route.params.id
-    // this.docIds = '19d53d64-8890-11eb-8699-0050568f51e7'
     this.locaHref = window.location.origin
     this.setTop()
-    this.details()
     this.adverse()
   },
   mounted () {
+    this.details()
     // 监听滚轮
     window.addEventListener('scroll', this.initHeight)
   },
@@ -173,8 +175,12 @@ export default {
     },
     init () {
       console.log(this.conts.data)
+      // Loading document.
+      pdfjsLib.GlobalWorkerOptions.workerSrc = this.config.workerSrc
       const loadingTask = pdfjsLib.getDocument({
-        url: this.conts.data
+        url: this.conts.data,
+        cMapUrl: this.config.CMAP_URL,
+        cMapPacked: this.config.CMAP_PACKED
       })
       loadingTask.promise.then((pdfDocument) => {
         this.pdfDocument = pdfDocument
@@ -199,7 +205,7 @@ export default {
       }
     },
     details () {
-      getDetails({ docId: this.docIds }).then(res => {
+      getDetails({ docId: this.docIds, from: this.$route.query.from }).then(res => {
         console.log(res)
         if (res.data.error_code === 0) {
           this.datas = res.data.data.detail
@@ -209,9 +215,9 @@ export default {
         }
       })
       getCoin({ B: true }).then(res => {
-        console.log(res)
+        console.log(res.data, '111111')
         if (res.data.error_code === 0) {
-          this.coinNum = res.data.data.data.points.balance
+          this.coinNum = res.data.data.points.balance
           if (this.buyed) {
             this.btnName = '下载文档'
           } else {
@@ -224,7 +230,6 @@ export default {
         }
       })
       getShow({ docId: this.docIds }).then(res => {
-        console.log(res.data)
         if (res.data.error_code === 0) {
           this.conts = res.data
           this.init()
@@ -284,9 +289,9 @@ export default {
         })
       } else {
         if (this.coinNum < this.datas.price) {
-          window.location.href = '/page_points/recharge?id=' + this.detailData.docId
+          window.location.href = '/page_points/recharge?id=' + this.datas.docId
         } else {
-          this.$router.push({ path: '/purchase', query: { id: this.detailData.docId } })
+          this.$router.push({ name: 'purchase', params: { id: this.datas.docId } })
         }
       }
     },

+ 5 - 0
jydocs-pc/src/views/Home.vue

@@ -421,6 +421,11 @@ export default {
         padding-bottom: 34px;
         box-sizing: border-box;
         margin-top: 40px;
+
+      .title-group h5 {
+          color: #863700;
+        }
+
         .new-list-group {
             background-color: white;
             border-radius: 8px;

+ 0 - 27
jydocs-pc/src/views/Keep.vue

@@ -1,27 +0,0 @@
-<template>
-  <div class="home">
-      <el-button @click="getTest" :loading="fullscreenLoading" type="primary">模拟Ajax</el-button>
-      <el-button  @click="getLoginStatus" type="info">获取登录状态</el-button>
-  </div>
-</template>
-
-<script>
-import { Button } from 'element-ui'
-
-export default {
-  name: 'home',
-  components: {
-    [Button.name]: Button
-  },
-  data () {
-    return {
-      fullscreenLoading: false
-    }
-  },
-  methods: {
-    getLoginStatus: function () {
-      alert(loginflag)
-    }
-  }
-}
-</script>

+ 0 - 27
jydocs-pc/src/views/Mine.vue

@@ -1,27 +0,0 @@
-<template>
-  <div class="home">
-      <el-button @click="getTest" :loading="fullscreenLoading" type="primary">模拟Ajax</el-button>
-      <el-button  @click="getLoginStatus" type="info">获取登录状态</el-button>
-  </div>
-</template>
-
-<script>
-import { Button } from 'element-ui'
-
-export default {
-  name: 'home',
-  components: {
-    [Button.name]: Button
-  },
-  data () {
-    return {
-      fullscreenLoading: false
-    }
-  },
-  methods: {
-    getLoginStatus: function () {
-      alert(loginflag)
-    }
-  }
-}
-</script>

+ 2 - 2
jydocs-pc/src/views/purchase/purchase.vue

@@ -99,8 +99,8 @@ export default {
     // 文档信息
     async getWordDetail () {
       getDetails({ docId: this.query, phone: this.tel }).then((res) => {
-        console.log(res)
-        if (res.data.data.status === 1) {
+        console.log(res.data.data)
+        if (res.data.data.error_msg !== '') {
           const item = res.data.data.detail
           console.log(item)
           this.response.docName = item.docName

+ 5 - 0
jydocs-pc/yarn.lock

@@ -6452,6 +6452,11 @@ pdfjs@^2.4.2:
     unorm "^1.6.0"
     uuid "^8.3.1"
 
+pdfjs-dist@^2.6.347:
+  version "2.6.347"
+  resolved "https://registry.npm.taobao.org/pdfjs-dist/download/pdfjs-dist-2.6.347.tgz#f257ed66e83be900cd0fd28524a2187fb9e25cd5"
+  integrity sha1-8lftZug76QDND9KFJKIYf7niXNU=
+
 performance-now@^2.1.0:
   version "2.1.0"
   resolved "https://registry.npm.taobao.org/performance-now/download/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"