Explorar o código

联调,canvas海报

bayi hai 1 ano
pai
achega
a6f382111a

+ 27 - 3
components/createPoster/index.js

@@ -1,8 +1,7 @@
 Component({
-    properties: {
-    },
+    properties: {},
     data: {
-        state: false,
+        state: true,
         img: ''
     },
     methods: {
@@ -15,6 +14,31 @@ Component({
             this.setData({
                 state: false
             })
+        },
+        savePoster() {
+            const query = wx.createSelectorQuery().in(this);
+            query
+                .select('#cavansId')
+                .fields({
+                    node: true,
+                    size: true
+                }).exec(async (res) => {
+                    const canvas = res[0].node;
+                    const ctx = canvas.getContext('2d');
+                    const dpr = wx.getSystemInfoSync().pixelRatio;
+                    canvas.width = res[0].width * dpr;
+                    canvas.height = res[0].height * dpr;
+                    let pic = canvas.createImage();
+                    pic.src = 'https://reader-wx.ai160.com/images/reader/pay/shareBg.jpg'
+                    pic.onload = () => {
+                        ctx.drawImage(pic, 0, 0, 646, 959);
+                        let pl = canvas.createImage();
+                        pl.src = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQEs8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyZzR0ZTE2T2M5N1UxYURaYU5CY1QAAgSHoQplAwQgHAAA'
+                        pl.onload = () => {
+                            ctx.drawImage(pl, 25, 747, 173, 173)
+                        }
+                    }
+                })
         }
     }
 })

+ 10 - 0
components/createPoster/index.less

@@ -57,6 +57,16 @@
             border-radius: 39rpx;
         }
     }
+
+    .canvas {
+        width: 646rpx;
+        height: 959rpx;
+        position: absolute;
+        left: 10rpx;
+        top: 10rpx;
+        /* left: -9999rpx;
+        top: -9999rpx; */
+    }
 }
 
 /* 转圈动画 */

+ 7 - 3
components/createPoster/index.wxml

@@ -1,10 +1,14 @@
 <view class="mediaBox" wx:if="{{state}}">
-    <view class="poster">
+    <!-- <view class="poster">
         <image src="/static/lollipop.png" class="close" catchtap="closeMediaBox" />
         <image src="https://reader-wx.ai160.com/images/reader/pay/shareBg.jpg" class="img" />
-    </view>
+    </view> -->
     <view class="btns">
         <view class="btn">立即分享</view>
-        <view class="btn" style="background: linear-gradient(180deg, #FFB382 0%, #FFA45D 100%);">保存海报</view>
+        <view class="btn" bindtap="savePoster" style="background: linear-gradient(180deg, #FFB382 0%, #FFA45D 100%);">
+            保存海报
+        </view>
     </view>
+    <canvas class="canvas" type="2d" id="cavansId" />
+
 </view>

+ 9 - 0
components/createPoster/index.wxss

@@ -51,6 +51,15 @@
   box-shadow: 0rpx 6rpx 4rpx 0rpx rgba(0, 0, 0, 0.08);
   border-radius: 39rpx;
 }
+.mediaBox .canvas {
+  width: 646rpx;
+  height: 959rpx;
+  position: absolute;
+  left: 10rpx;
+  top: 10rpx;
+  /* left: -9999rpx;
+        top: -9999rpx; */
+}
 /* 转圈动画 */
 @keyframes falsh-identifier {
   0% {

+ 2 - 2
mixins/share.js

@@ -8,8 +8,8 @@ module.exports = Behavior({
             from,
             target
         }) {
-            let video = target.dataset.info
-            if (from == 'button' && video) {
+            if (from == 'button') {
+                let video = target.dataset.info
                 const promise = new Promise(resolve => {
                     this.creatShare(video).then(res => {
                         resolve(res)

+ 1 - 1
pages/my/index.js

@@ -212,7 +212,7 @@ Page({
     onShareAppMessage: function (res) {
         return {
             title: '自从用了它,家里朗朗书声,美妙极了!你家孩子也快来试试!',
-            path: '/pages/index/index',
+            path: `/pages/index/index?uid=${wx.getStorageSync('uid')}`,
             imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/375-300-1.jpg'
         }
     },

+ 0 - 1
salesperson/pages/history/index.js

@@ -10,7 +10,6 @@ Page({
     },
     onLoad(options) {
         this.resetData();
-        this.openInvite()
     },
     bindDateChange(e) {
         console.log('携带值为', e.detail.value)

+ 2 - 1
salesperson/pages/management/index.wxml

@@ -6,7 +6,8 @@
         </view>
     </view>
     <scroll-view class="orderList" scroll-y="true" enhanced show-scrollbar="{{false}}" bindscrolltolower='loadMore'>
-        <view class="tips">温馨提示:退款的订单不计入收益系统 <view class="close">×</view>
+        <view class="tips" wx:if="{{currentIndex=='2'}}">温馨提示:退款的订单不计入收益系统
+            <!--  <view class="close">×</view> -->
         </view>
         <view class="order" wx:for="{{list}}" wx:key="index">
             <view class="above">