cuiyalong 4 жил өмнө
parent
commit
50c069e3a0

+ 0 - 8
jydocs-mobile/src/api/main.ts

@@ -44,8 +44,6 @@ export function getMyLibList (params: any) {
 }
 
 export function getDetails (data: any) {
-  console.log(data)
-  // data = qs.stringify(data)
   return $request({
     url: '/detail',
     method: 'post',
@@ -70,8 +68,6 @@ export function getDown (data: any) {
 }
 
 export function getAdd (data: any) {
-  console.log(data)
-  // data = qs.stringify(data)
   return $request({
     url: '/user/collect/add',
     method: 'post',
@@ -80,8 +76,6 @@ export function getAdd (data: any) {
 }
 
 export function getRemove (data: any) {
-  console.log(data)
-  // data = qs.stringify(data)
   return $request({
     url: '/user/collect/remove',
     method: 'post',
@@ -90,7 +84,6 @@ export function getRemove (data: any) {
 }
 
 export function getCoin (data: any) {
-  console.log(data)
   return $request({
     baseURL: '/jyintegral',
     url: '/getList',
@@ -100,7 +93,6 @@ export function getCoin (data: any) {
 }
 
 export function getShare (data: any) {
-  console.log(data)
   return $request({
     url: '/share/url',
     method: 'post',

+ 1 - 1
jydocs-mobile/src/components/Recharge.vue

@@ -59,7 +59,7 @@ export default class extends Vue {
     }
 
     buyMoney () {
-      window.location.href = '/swordfish/integral/index/recharge?id=' + this.detailData.docId
+      window.location.href = '/page_points_app/pay'
     }
 }
 </script>

+ 64 - 0
jydocs-mobile/src/utils/wxShare.ts

@@ -0,0 +1,64 @@
+import Vue from 'vue'
+import WeiXinSDK from '@/utils/wx-js-sdk-register.ts'
+import { isWeiXinBrowser, androidOrIOS } from '@/utils/globalFunctions'
+import { getWxSdkSign } from '@/api/index.ts'
+
+declare module 'vue/types/vue' {
+  interface Vue {
+    $env: any;
+    $registerWxSdk: any;
+    $wxSdk: any;
+  }
+}
+
+const inWeiXinBrowser = isWeiXinBrowser()
+const isAndroidOrIos = androidOrIOS()
+const firstUrl = location.href.split('#')[0]
+
+export async function getSdkSign (url: string) {
+  const sdkInfo = await getWxSdkSign({ url })
+  if (!sdkInfo) return
+  const info = sdkInfo.data
+  if (info && info.wxsdk && Array.isArray(info.wxsdk)) {
+    const sdk = info.wxsdk
+    return new WeiXinSDK({
+      appId: sdk[0],
+      timestamp: sdk[1],
+      nonceStr: sdk[2],
+      signature: sdk[3]
+    })
+  }
+}
+
+/* 微信自定义分享封装函数 */
+/**
+ * url:获取微信分享签名的url地址
+ * isShare:当前所在路径是否需要分享
+ *  */
+export async function weChatShare (options: any) {
+  if (!inWeiXinBrowser) return
+
+  const device = isAndroidOrIos
+  // 获取并注册sdkSign
+  const url = location.href.split('#')[0]
+  if (device === 'ios') {
+    // url = firstUrl
+    console.log(firstUrl)
+  }
+  const wxSdk: any = await getSdkSign(url)
+  Vue.prototype.$wxSdk = wxSdk
+  wxSdk.shareToFriendAndQQ(options)
+  wxSdk.shareToFriendsAndQZone(options)
+  return wxSdk
+}
+
+export async function weChatPay (options: any) {
+  if (!inWeiXinBrowser) return
+
+  // 获取并注册sdkSign
+  const url = location.href.split('#')[0]
+  const wxSdk: any = await getSdkSign(url)
+  Vue.prototype.$wxSdk = wxSdk
+  wxSdk.chooseWXPayForWeiXinJSBridge(options)
+  return wxSdk
+}

+ 15 - 4
jydocs-mobile/src/views/details/details.vue

@@ -41,6 +41,7 @@ import { Icon, Toast, GoodsAction, GoodsActionIcon, GoodsActionButton } from 'va
 import Recharge from '@/components/Recharge.vue'
 import sharePop from '@/components/SharePopup.vue'
 import { MixinTop } from '@/utils/mixin-top'
+import { weChatShare } from '@/utils/wxShare'
 const pdfjsLib = require('pdfjs-dist/build/pdf.js')
 const pdfjsViewer = require('pdfjs-dist/web/pdf_viewer.js')
 
@@ -120,12 +121,21 @@ export default class extends Vue {
     window.removeEventListener('scroll', this.watchPage)
   }
 
+  async getShareUrl () {
+    const { data } = await this.getShare({ docId: this.docIds })
+    this.links = data.url || location.href
+    // 注册微信sdk
+    weChatShare({
+      config: {
+        title: this.detailData.docName,
+        desc: this.detailData.docSummary,
+        url: this.links
+      }
+    })
+  }
+
   shared () {
     ;(this.$refs.shares as any).show = true
-    this.getShare({ docId: this.docIds }).then((res: any) => {
-      console.log(res)
-      this.links = res.data
-    })
   }
 
   // updateText (type: any, value = '') {
@@ -208,6 +218,7 @@ export default class extends Vue {
         this.buyShow()
       }
       this.collectd = res.data.collect
+      this.getShareUrl()
     })
     this.getCoin({ B: true }).then((res: any) => {
       console.log(res.data.data)

+ 1 - 1
jydocs-mobile/src/views/user/Library.vue

@@ -155,7 +155,7 @@ export default class UserLibrary extends Vue {
   }
 
   toDocDetail (item: any) {
-    const { docId: id } = item
+    const { DocId: id } = item
     this.saveState()
     this.$router.push({
       name: 'details',