xiebaomin hace 1 año
padre
commit
e7220a1ab7

+ 2 - 0
.env.development

@@ -8,6 +8,8 @@ LOCALHOSE = 'https://sell-b.caimei365.com'
 #VUE_APP_URL = 'http://192.168.2.103:18002'
 VUE_APP_URL = 'https://core-b.caimei365.com'
 
+VUE_IMG_URL = 'https://img-b.caimei365.com'
+
 # 静态资源文件地址
 STATIC_URL = 'https://static.caimei365.com/app/mini-distribution'
 

+ 2 - 2
package-lock.json

@@ -15974,7 +15974,7 @@
     },
     "node_modules/vue-scroller": {
       "version": "2.2.4",
-      "resolved": "https://registry.npmjs.org/vue-scroller/-/vue-scroller-2.2.4.tgz",
+      "resolved": "https://registry.npmmirror.com/vue-scroller/-/vue-scroller-2.2.4.tgz",
       "integrity": "sha512-UcQp4OJri7uYLdYSLWQ5rKEpnehlGkAf2X40LQllzscQuGFNl98pQAQO5yk9B3QGF0kI8sOOnyk1CerWX6zNmQ==",
       "dependencies": {
         "vue": "^2.2.6"
@@ -29933,7 +29933,7 @@
     },
     "vue-scroller": {
       "version": "2.2.4",
-      "resolved": "https://registry.npmjs.org/vue-scroller/-/vue-scroller-2.2.4.tgz",
+      "resolved": "https://registry.npmmirror.com/vue-scroller/-/vue-scroller-2.2.4.tgz",
       "integrity": "sha512-UcQp4OJri7uYLdYSLWQ5rKEpnehlGkAf2X40LQllzscQuGFNl98pQAQO5yk9B3QGF0kI8sOOnyk1CerWX6zNmQ==",
       "requires": {
         "vue": "^2.2.6"

+ 1 - 0
public/index.html

@@ -7,6 +7,7 @@
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
     <link rel="icon" href="<%= BASE_URL %>favicon.ico">
     <title><%= htmlWebpackPlugin.options.title %></title>
+    <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
   </head>
   <body>
     <noscript>

+ 1 - 1
src/api/institutionApi/order.js

@@ -91,7 +91,7 @@ export const shareOrderCode = (params) => http({
 })
 
 export const shareCodeCheck = (params) => http({
-  url: '/order/club/share/code/check',
+  url: 'order/club/share/distributionCode/check',
   params,
   method: 'GET',
   headers: {

+ 9 - 6
src/components/poster.vue

@@ -25,16 +25,16 @@
             backgroundSize: '100% 100%',
           }">
             <div class="logo">
-              <van-image src="https://static.caimei365.com/app/img/icon/logo-fanbai.png" mode="" class="titleImgUrl"
-                cross></van-image>
+              <img src="https://static.caimei365.com/app/img/icon/logo-fanbai.png" mode="" class="titleImgUrl"
+                cross>
             </div>
             <div class="card-contain">
               <div style="display: flex">
                 <div class="card-head">
-                  <van-image :src="userInfo.image && userInfo.image.length > 12
+                  <img ref="head" crossorigin="anonymous" :src="userInfo.image && userInfo.image.length > 12
                       ? userInfo.image
                       : 'https://static.caimei365.com/app/img/icon/default-head-new.png'
-                    " mode="" class="head"></van-image>
+                    " mode="" class="head">
                 </div>
                 <div class="card-info">
                   <div class="card-info-head">
@@ -54,7 +54,7 @@
               </div>
               <div class="card-qrcode">
                 <div class="qrcode-message">
-                  <van-image :src="userInfo.qrCode || ''" class="qrcode" mode=""></van-image>
+                  <img :src="userInfo.qrCode || ''" class="qrcode" mode="">
                 </div>
                 <div class="tips">长按或扫二维码—-联系我-—</div>
               </div>
@@ -69,6 +69,7 @@
 <script>
 import html2Canvas from 'html2canvas'
 import { Toast } from 'vant'
+import { getBase64Image } from '@/config/index'
 
 export default {
   props: {
@@ -106,9 +107,11 @@ export default {
       }
     },
     userInfo: {
-      handler (val) {
+      async handler (val) {
         if (val) {
           console.log(val)
+          const data = await getBase64Image(this.$refs.head)
+          console.log(data)
         }
       },
       deep: true

+ 1 - 1
src/components/share-modal.vue

@@ -3,7 +3,7 @@
     <div class="seller-card-mine" v-if="modal" @click="changeModal">
       <van-image
           :src="userInfo.image.length > 12 ? userInfo.image : 'https://static.caimei365.com/app/img/icon/default-head-new.png'"
-          style="width: 100%;height: 100%;object-fit: contain;border-radius: 50%;"
+          style="width: 100%;height: 100%;object-fit: contain;border-radius: 50%;overflow: hidden;"
       ></van-image>
     </div>
     <van-overlay :show="show" @click="show = false, modal = true">

+ 33 - 15
src/config/index.js

@@ -1,18 +1,36 @@
-export function getBase64Image (src) {
-  return new Promise(resolve => {
-    const img = new Image()
-    img.crossOrigin = ''
-    console.log(src)
-    img.src = src
-    img.onload = function () {
-      const canvas = document.createElement('canvas')
-      canvas.width = img.width
-      canvas.height = img.height
-      const ctx = canvas.getContext('2d')
-      ctx.drawImage(img, 0, 0, img.width, img.height)
-      const ext = img.src.substring(img.src.lastIndexOf('.') + 1).toLowerCase()
-      const dataURL = canvas.toDataURL('image/' + ext)
-      resolve(dataURL)
+// export function getBase64Image (src) {
+//  return new Promise(resolve => {
+//    const img = new Image()
+//    const canvas = document.createElement('canvas')
+//    img.crossOrigin = 'anonymous'
+//    console.log(src)
+//    img.src = src
+//    img.onload = function () {
+//      canvas.width = img.width
+//      canvas.height = img.height
+//      const ctx = canvas.getContext('2d')
+//      ctx.drawImage(img, 0, 0, img.width, img.height)
+//      const ext = img.src.substring(img.src.lastIndexOf('.') + 1).toLowerCase()
+//      const dataURL = canvas.toDataURL('image/' + ext)
+//      resolve(dataURL)
+//    }
+//  })
+// }
+
+export function getBase64Image (ref) {
+  return new Promise((resolve, reject) => {
+    console.log(ref)
+    const canvas = document.createElement('canvas')
+    canvas.width = ref.naturalWidth // 使用 naturalWidth 为了保证图片的清晰度
+    canvas.height = ref.naturalHeight
+    canvas.style.width = canvas.width
+    canvas.style.height = canvas.height
+    const ctx = canvas.getContext('2d')
+    if (!ctx) {
+      return null
     }
+    ctx.drawImage(ref, 0, 0)
+    const base64 = canvas.toDataURL('image/png')
+    resolve(base64)
   })
 }

+ 1 - 1
src/permission.js

@@ -7,7 +7,7 @@ import { Toast } from 'vant'
 
 NProgress.configure({ showSpinner: false })
 
-const whiteList = ['/login', '/pwlogin', '/forgotPW']
+const whiteList = ['/login', '/pwlogin', '/forgotPW', '/goods-detail', '/order-list', '/share', '/order-detail']
 
 router.beforeEach((to, from, next) => {
   NProgress.start()

+ 4 - 6
src/plugin/jsSdk.js

@@ -1,23 +1,21 @@
 import Vue from 'vue'
-import { appId, jsApiList } from '@/config/js-config'
-import wx from 'jweixin-module'
+import { appId } from '@/config/js-config'
 import { shareSDK } from '@/api/userApi/share'
 
-const dev = process.env.EVN
+const dev = process.env.NODE_ENV
 
 Vue.prototype.$wxReady = async (callback, apiList = []) => {
   try {
     const url = 'https://sell-b.caimei365.com/#/shopping-mall'
     // console.log('当前页面地址:', url)
     const res = await shareSDK({ url: url, appId })
-    console.log(res)
     wx.config({
       debug: false, // 开启调试模式,调用的所有 api 的返回值会在客户端 alert 出来,若要查看传入的参数,可以在 pc 端打开,参数信息会通过 log 打出,仅在 pc 端时才会打印。
       appId: appId, // 必填,公众号的唯一标识
       timestamp: res.timestamp, // 必填,生成签名的时间戳
       nonceStr: res.noncestr, // 必填,生成签名的随机串
       signature: res.signature, // 必填,签名
-      jsApiList: [...jsApiList] // 必填,需要使用的 JS 接口列表
+      jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'] // 必填,需要使用的 JS 接口列表
     })
     wx.ready(callback(wx))
     wx.error(function (error) {
@@ -26,7 +24,7 @@ Vue.prototype.$wxReady = async (callback, apiList = []) => {
     })
   } catch (error) {
     if (dev === 'development') {
-      console.warn('jssdk init error:' + error.msg || error.message)
+      console.warn('jssdk init error:' + error)
     } else {
       console.warn('jssdk init error')
     }

+ 2 - 2
src/util/http.js

@@ -28,7 +28,7 @@ request.interceptors.request.use(
     Vue.$showLoading = true
     Toast.loading({
       message: '加载中...',
-      forbidClick: true
+      forbidClick: false
     })
     let cancelFunction // 引用取消请求的cancelToken
     // 挂载请求key
@@ -111,7 +111,7 @@ request.interceptors.response.use(
     } else {
       Toast.loading({
         message: '加载中...',
-        forbidClick: true
+        forbidClick: false
       })
       return Promise.resolve(data)
     }

+ 1 - 1
src/views/order-list/components/order-btn-type.vue

@@ -221,7 +221,7 @@ export default {
       this.show = true
     },
     share () {
-      this.$router.push(`/share?type=1&shopOrderId=${this.productInfo.shopOrderId}&userId=${this.productInfo.userId}`)
+      this.$emit('shareOrder', this.productInfo)
       this.show = false
     },
     handlerCode ($event) {

+ 23 - 0
src/views/order-list/index.vue

@@ -46,6 +46,7 @@
               @orderPay="orderPay"
               @orderQuery="orderQuery"
               @orderConfirm="orderConfirm"
+              @shareOrder="shareOrder"
             />
           </div>
         </template>
@@ -58,6 +59,7 @@
 import { orderList, orderInsList } from '@/api/institutionApi/order'
 import OrderBtnType from './components/order-btn-type'
 import orderIndex from './mixins/order-index'
+import { Toast } from 'vant'
 export default {
   mixins: [orderIndex],
   components: { OrderBtnType },
@@ -195,6 +197,27 @@ export default {
     },
     orderConfirm () {
       this.handlerManage(this.activeBtn)
+    },
+    // 分享当前页面
+    initAppMessageShareData (info) {
+      this.$wxReady((wx) => {
+        // 需在用户可能点击分享按钮前就先调用
+        wx.updateAppMessageShareData({
+          title: '分享订单', // 分享标题
+          desc: '分享订单', // 分享描述
+          link: `https://sell-b.caimei365.com/#/share?type=1&shopOrderId=${info.shopOrderId}&userId=${info.userId}`, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
+          imgUrl: 'https://static.caimei365.com/app/mini-distribution/qrcode.png', // 分享图标
+          fail: () => {
+            this.initAppMessageShareData()
+          }
+        })
+      })
+    },
+    shareOrder (info) {
+      this.initAppMessageShareData(info)
+      setTimeout(() => {
+        Toast.success('请点击右上角...进行分享')
+      }, 1000)
     }
   }
 }

+ 7 - 1
src/views/shopping-mall/components/goods-sku.vue

@@ -18,7 +18,7 @@
     </template>
     <template #sku-actions="props">
       <div class="van-sku-actions">
-        <van-button @click="onPayProduct(props)" color="#FF5B00">立即购买</van-button>
+        <van-button v-if="isLock" @click="onPayProduct(props)" color="#FF5B00">立即购买</van-button>
       </div>
     </template>
     </van-sku>
@@ -101,6 +101,12 @@ export default {
         }
       }
       return {}
+    },
+    suid () {
+      return this.$route.query.suid
+    },
+    isLock () {
+      return this.$route.query.isLock
     }
   },
   methods: {

+ 17 - 2
src/views/shopping-mall/detail.vue

@@ -53,7 +53,7 @@ export default {
       return this.$route.query.isLock
     },
     suid () {
-      return this.$route.query.suid
+      return this.$route.query.suid * 1
     },
     cId () {
       return this.$route.query.cId
@@ -62,6 +62,7 @@ export default {
   async mounted () {
     await this.productDetail()
     await this.getUserInfo()
+    this.initAppMessageShareData()
   },
   methods: {
     async productDetail () {
@@ -81,7 +82,21 @@ export default {
     async getUserInfo () {
       const data = await getUserInfo({ userId: this.suid ? this.suid : this.$store.getters.userId })
       this.userInfo = data
-      // this.dataInfo.productImage = await getImage2Blob(this.dataInfo.productImage)
+    },
+    // 分享当前页面
+    initAppMessageShareData () {
+      this.$wxReady((wx) => {
+        // 需在用户可能点击分享按钮前就先调用
+        wx.updateAppMessageShareData({
+          title: '商品详情', // 分享标题
+          desc: '商品详情', // 分享描述
+          link: `https://sell-b.caimei365.com/#/goods-detail?productId=${this.productId}&typeId=0&suid=${this.$store.getters.userId}`, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
+          imgUrl: 'https://static.caimei365.com/app/mini-distribution/qrcode.png', // 分享图标
+          fail: () => {
+            this.initAppMessageShareData()
+          }
+        })
+      })
     }
   }
 }

+ 0 - 16
src/views/shopping-mall/index.vue

@@ -29,7 +29,6 @@ export default {
   },
   mounted () {
     this.productList()
-    this.initAppMessageShareData()
   },
   methods: {
     getMoreInfo () {
@@ -43,21 +42,6 @@ export default {
       const { results: data, hasNextPage } = await productList(this.formData)
       this.dataList = [...data, ...this.dataList]
       this.hasNextPage = hasNextPage
-    },
-    // 分享当前页面
-    initAppMessageShareData () {
-      this.$wxReady((wx) => {
-        // 需在用户可能点击分享按钮前就先调用
-        wx.updateAppMessageShareData({
-          title: '官方正品授权查询', // 分享标题
-          desc: '官方正品授权', // 分享描述
-          link: '', // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
-          imgUrl: '', // 分享图标
-          fail: () => {
-            this.initAppMessageShareData()
-          }
-        })
-      })
     }
   }
 }

+ 8 - 1
vue.config.js

@@ -1,4 +1,5 @@
 /* eslint-disable no-dupe-keys */
+const VUE_IMG_URL = 'https://img-b.caimei365.com/'
 module.exports = {
   publicPath: process.env.NODE_ENV === 'production' ? './' : './',
   outputDir: 'dist',
@@ -12,7 +13,6 @@ module.exports = {
     }
   },
   devServer: {
-    host: '0.0.0.0',
     proxy: {
       '/api': {
         target: process.env.VUE_APP_URL,
@@ -20,6 +20,13 @@ module.exports = {
         pathRewrite: {
           '^/api': ''
         }
+      },
+      '/api2': {
+        target: VUE_IMG_URL,
+        changeOrigin: true,
+        pathRewrite: {
+          '^/api2': ''
+        }
       }
     }
   }