浏览代码

Merge branch 'master' of http://192.168.3.207:10080/jianyu/jy-docs

cuiyalong 4 年之前
父节点
当前提交
84682a6221

+ 2 - 1
jydocs-back/config.json

@@ -32,5 +32,6 @@
         "127.0.0.1:2379"
       ]
     }
-  }
+  },
+  "shareUrl": "https://web-jydev-wky.jianyu360.cn/swordfish/docs/index/content/%s"
 }

+ 1 - 0
jydocs-back/config/config.go

@@ -17,6 +17,7 @@ type appConfig struct {
 		Points  rpcConfig `json:"points"`  //剑鱼积分rpc接口
 		JyFile  rpcConfig `json:"jyFile"`  //剑鱼文件rpc接口
 	} `json:"rpcServers"` //rpc服务配置
+	ShareUrl string `json:"shareUrl"`
 }
 
 type rpcConfig struct {

+ 1 - 0
jydocs-back/go.mod

@@ -7,5 +7,6 @@ require (
 	app.yhyue.com/moapp/jy_docs v0.0.0-20210319063914-d48d51e0cc46
 	app.yhyue.com/moapp/jybase v0.0.0-20210319015107-fe59d2046cf8
 	app.yhyue.com/moapp/jyfs v0.0.0-20210319011832-6cf539ddc5cd
+	github.com/SKatiyar/qr v0.0.0-20151201054752-25b6bdf44e67
 	github.com/tal-tech/go-zero v1.1.5
 )

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

@@ -26,7 +26,7 @@ func init() {
 //获取用户对话pdf文件地址
 func GetFileContext(userId, ossId string) (string, error) {
 	resp, err := jyFilelLib.GetOssUril(context.Background(), &filesystem.LoadFileReq{
-		Domain: config.JyDocsAppConfig.OssAdmin,
+		Domain: config.JyDocsAppConfig.OssBucket.Std,
 		FileId: ossId,
 	})
 	if err != nil {

+ 1 - 0
jydocs-back/servers/a_init.go

@@ -21,6 +21,7 @@ func init() {
 	xweb.RootApp().BasePath = "/jydocs"
 
 	xweb.AddAction(&Ad{})
+	xweb.AddAction(&Share{})
 	xweb.AddAction(&StdDoc{})
 	xweb.AddAction(&UserDoc{})
 }

+ 49 - 0
jydocs-back/servers/share.go

@@ -0,0 +1,49 @@
+package servers
+
+import (
+	. "app.yhyue.com/moapp/jybase/api"
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"fmt"
+	"github.com/SKatiyar/qr"
+	"jy-docs/config"
+	"log"
+)
+
+type Share struct {
+	*xweb.Action
+	shareUrl xweb.Mapper `xweb:"/share/url"` //地址分享
+	shareImg xweb.Mapper `xweb:"/share/img"` //链接分享
+}
+
+func (share *Share) ShareUrl() {
+	userId := common.ObjToString(share.GetSession("userId"))
+	rData, errMsg := func() (interface{}, error) {
+		docId := share.GetString("docId") //分享地址
+		return map[string]interface{}{
+			"url": getShareUrl(userId, docId),
+		}, nil
+	}()
+	if errMsg != nil {
+		log.Printf("%s Share  err:%s\n", errMsg.Error(), userId)
+	}
+	share.ServeJson(NewResult(rData, errMsg))
+}
+
+func (share *Share) ShareImg() {
+	userId := common.ObjToString(share.GetSession("userId"))
+	docId := share.GetString("docId") //分享地址
+	data := getShareUrl(userId, docId)
+
+	w := share.ResponseWriter
+	w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
+	w.Header().Set("Pragma", "no-cache")
+	w.Header().Set("Expires", "0")
+	w.Header().Set("Content-Type", "image/png")
+	r, _ := qr.Encode(data, qr.M)
+	_, _ = w.Write(r.PNG())
+}
+
+func getShareUrl(userId, docId string) string {
+	return fmt.Sprintf(config.JyDocsAppConfig.ShareUrl+"?userId=%s", docId, userId)
+}

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

@@ -47,7 +47,7 @@
             </div>
             <div class="apply_footer">
                 <button class="j-button-cancel btn_active" @click="closePopup()">取消</button>
-                <button class="j-button-sure btn_active" :disabled="!this.checked" @click="exchange()">去充值</button>
+                <button class="j-button-sure btn_active" :disabled="!this.checked" @click="exchange()">剑鱼币购买</button>
             </div>
         </div>
     </van-popup>

+ 79 - 13
jydocs-mobile/src/views/purchase/purchase.vue

@@ -3,25 +3,35 @@
     <div class="j-main exchange_main">
       <div class="docs_infor">
         <div class="docs_left">
-          <img src="" class="docs_img" alt="">
+          <img :src="response.previewImgId" class="docs_img" alt="">
+          <span class="icon_word"></span>
         </div>
         <div class="docs_right">
           <div class="docs_title ellipsis-2">
-            优化招投标市场营商环境与国企采购人主体责任、采购与招标优化招投标市场营商环境与国企采购人主体责任、采购与招标
+            {{response.docName}}
           </div>
           <div class="docs_other">
-            <div class="docs_auther">贡献者:张三</div>
+            <!-- <div class="docs_auther">贡献者:张三</div> -->
             <div class="docs_download">
-              <span>2020次下载</span> | 共18页 | 220K
+              <span>{{response.downTimes}}次下载</span> | 共{{response.docPageSize}}页 | {{response.docFileSize}}K
             </div>
-            <div class="docs_money"><span class="docs_num">500</span> 剑鱼币</div>
+            <div class="docs_money"><span class="docs_num">{{response.price}}</span> 剑鱼币</div>
           </div>
         </div>
       </div>
       <div class="docs_phone">
-        <van-cell-group>
+        <!-- <van-cell-group>
           <van-field v-model="tel" type="number" label="手机号码" placeholder="请输入手机号码" />
-        </van-cell-group>
+        </van-cell-group> -->
+        <van-field
+          class="editable"
+          v-model="tel"
+          name="phone"
+          type="tel"
+          label="手机号码"
+          placeholder="请输入手机号码"
+          :rules="phoneRules"
+        />
       </div>
     </div>
     <div class="j-footer exchange_footer">
@@ -30,7 +40,7 @@
           支付积分:
         </div>
         <div class="det_right">
-          <span class="det_money">500</span>
+          <span class="det_money">{{response.price}}</span>
           <span>剑鱼币</span>
         </div>
       </div>
@@ -48,7 +58,8 @@
 import { Component, Vue } from 'vue-property-decorator'
 import { Checkbox, CheckboxGroup, Field, CellGroup } from 'vant'
 import { mapActions } from 'vuex'
-import { getDocPay } from '../../api/main'
+// import { getDocPay } from '../../api/main'
+const regPhoneExg = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57]|19[0-9])[0-9]{8}$/
 @Component({
   name: 'purchase-page',
   components: {
@@ -59,24 +70,68 @@ import { getDocPay } from '../../api/main'
   },
   methods: {
     ...mapActions({
-      getDocPay: 'main/getDocPay'
+      getDocPay: 'main/getDocPay',
+      getDetails: 'main/getDetails'
     })
   }
 })
 export default class extends Vue {
-  // protected getDocPay!: any
+  protected getDocPay!: any
+  protected getDetails!: any
   checked = false
   tel = ''
   $router: any
+  response = {
+    docName: '',
+    price: '',
+    downTimes: '',
+    docFileSize: '',
+    docPageSize: '',
+    previewImgId: ''
+  }
+
+  created () {
+    this.getWordInfor()
+  }
+
+  // 文档信息
+  getWordInfor () {
+    this.getDetails({ docId: '4f6c00ba-8882-11eb-8699-0050568f51e7' }).then((res: any) => {
+      console.log(res)
+      const item = res.data.detail
+      if (res.error_code === 0) {
+        this.response.docName = item.docName
+        this.response.price = item.price
+        this.response.downTimes = item.downTimes
+        this.response.docFileSize = item.docFileSize
+        this.response.docPageSize = item.docPageSize
+        this.response.previewImgId = item.previewImgId
+      }
+    })
+  }
 
   // 确定兑换
   exchange () {
-    getDocPay({ docId: 'RJ82241sM3DyHwrupW7w', phone: '18439509554' }).then((res: any) => {
+    this.getDocPay({ docId: '4f6c00ba-8882-11eb-8699-0050568f51e7', phone: '18439509554' }).then((res: any) => {
       console.log(res)
+      if (res.data === 'success') {
+        this.$router.push('/purchasesuccess')
+      }
     })
-    // this.$router.push('/purchasesuccess')
   }
 
+  phoneRules = [{
+    validator: (val: string) => {
+      const status = regPhoneExg.test(val)
+      if (val === '') {
+        console.log(true)
+        return true
+      }
+      return status
+    },
+    message: '手机号格式错误'
+  }]
+
   // 剑鱼标讯服务条款
   clause () {
     // this.$router.push('/readme')
@@ -95,6 +150,7 @@ export default class extends Vue {
         padding: 20px 16px;
         background: #ffffff;
         .docs_left{
+          position: relative;
           width: 100px;
           height: 124px;
           border-radius: 4px;
@@ -103,6 +159,16 @@ export default class extends Vue {
             width: 100%;
             height: 100%;
           }
+          .icon_word{
+            position: absolute;
+            right: 0;
+            bottom: 0;
+            display: flex;
+            width: 24px;
+            height: 24px;
+            background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJASURBVHgB7Zm/TuQwEMY/J5x016B7gC2oqbju2muuuOoKClooqEGiodliGxokqLdYXoACWireACpqin0ARAMCEvONcXaXf+sQjTdI+CclTuKJM+NMnBkbSCQSiTYxdYS+79gFCh7wcInbT8TG4MhabN5um8uwaACv/BlmofhzrizwK2TEHAIYgz1YKm9wmN2hV2S4RkRMhg6LDT5v2b/1P9PkM4Sw+O/KEvuxlXePKzEsHtDzp0sh+bABEw1jRmTjjgq6bW0DPivJgLZJBrRN8D/wHibHZXVsCyygARptJBdqm2RA20QzwAVlOfosd/MS84hE41EoBKPYPotFCdjtN5YF/iECUd6A9LoV5T1yLNcQAXUDqKiL5V9XML6XOmVUDfDKj5Sk9wzY+4OxAOsyrEERtW+AMfxfO6E8FT/h3/UpMcmdO/2WQ34bXZ5fs+4QCqi8ASq+WJpnPj7M77FVnRT3WKdBFyN5oCv3QAEVA9j7fbpLNVQOqeHKZPopGZaxWHd1cK41L/dAAa1voONLp/xb6ae7JnUYGdaBAqofcVnSVabkzlLHbQWKqBnAiage3eQiJOdltqCEjgEG+5x2GdQVdyOQ3KNAcwMqBVjah48r4+6ZaAMNCU4t/tihc6B5xtSUKlu72TZTdUzhdNt8CQOuZBczKXmJn6GuRR0DzmVXzqH7kYab4juqCgqPQ/LBaJRD0Kpb4HiK8Zc5OkSlHLcvCxzB/CH4BmSFRFZKGG0eYTaI4qd1VmcSiUSifR4BOQuhbc3lgT4AAAAASUVORK5CYII=) no-repeat;
+            background-size: contain;
+          }
         }
         .docs_right{
           flex: 1;

+ 21 - 21
jydocs-mobile/src/views/purchase/purchasesuccess.vue

@@ -10,7 +10,7 @@
           <span class="icon_num"></span>
           <span class="money_num">500</span>
         </div>
-        <p class="success_days">2s后自动跳转到文档页面</p>
+        <p class="success_days">{{count}}s后自动跳转到文档页面</p>
       </div>
       <div class="logout_infor">
         <div class="infor_group">
@@ -42,30 +42,30 @@ import { Component, Vue } from 'vue-property-decorator'
 @Component({
   name: 'test',
   components: {
-  },
-  methods: {
-  },
-  computed: {
-    // ...mapState('logout', {
-    //   logout: function (state: any) {
-    //     return state.logoutdata
-    //   }
-    // })
   }
-//   beforeRouteLeave (to, form, next) {
-//     setTimeout(() => {
-//       history.go(-history.length + 1)
-//     }, 50)
-//     next(false)
-//   }
 })
 export default class extends Vue {
-  protected logout: any
+  count = 3
+  timer: any
+  $router: any
 
-  // 注销完成,返回我的页面
-  // complete () {
-  // history.go(-history.length + 1)
-  // }
+  created () {
+    this.setCountDown()
+  }
+
+  setCountDown () {
+    if (!this.timer) {
+      this.timer = setInterval(() => {
+        if (this.count > 0 && this.count <= 10) {
+          this.count--
+        } else {
+          clearInterval(this.timer)
+          this.timer = null
+          this.$router.push('/home')
+        }
+      }, 1000)
+    }
+  }
 }
 </script>
 <style lang="scss">