Silent %!s(int64=6) %!d(string=hai) anos
pai
achega
331bc3f1f5
Modificáronse 3 ficheiros con 56 adicións e 45 borrados
  1. 25 29
      wechat/pages/index/index.js
  2. 15 16
      wechat/pages/index/index.wxml
  3. 16 0
      wechat/pages/index/index.wxss

+ 25 - 29
wechat/pages/index/index.js

xqd xqd xqd
@@ -20,7 +20,8 @@ Page({
     shareText: '',
     shareTextPosX: '',
     shareTextPosY: '',
-    shareTempFilePath: ''
+    shareTempFilePath: '',
+    showPopup: false
   },
   onLoad: function () {
     wx.getSystemInfo({
@@ -122,6 +123,11 @@ Page({
     });
     return res;
   },
+  hidePhotoPopup() {
+    this.setData({
+      showPopup: false
+    })
+  },
   handleBtnClick() {
     wx.getLocation({
       success: (res) => {
@@ -285,34 +291,24 @@ Page({
     //     })
     //   }
     //   }, this)
-    wx.showModal({
-      title: '确定生成图片吗',
-      content: '生成图片发到朋友圈',
-      success: res => {
-        if(res.confirm) {
-          if (!this.data.shareTempFilePath) {
-            wx.showModal({
-              title: '提示',
-              content: '图片绘制中,请稍后重试',
-              showCancel: false
-            })
-          }
-          wx.saveImageToPhotosAlbum({
-            filePath: this.data.shareTempFilePath,
-            success: (res) => {
-
-            },
-            complete: res => {
-              this.setData({
-                showPopup: false
-              })
-            }
-          })
-        } else if (res.cancel) {
-          this.setData({
-            showPopup: false
-          })
-        }
+    if (!this.data.shareTempFilePath) {
+      wx.showModal({
+        title: '提示',
+        content: '图片绘制中,请稍后重试',
+        showCancel: false
+      })
+    }
+    wx.saveImageToPhotosAlbum({
+      filePath: this.data.shareTempFilePath,
+      success: (res) => {
+        this.setData({
+          showPopup: false
+        })
+      },
+      complete: res => {
+        this.setData({
+          showPopup: false
+        })
       }
     })
   },

+ 15 - 16
wechat/pages/index/index.wxml

xqd xqd
@@ -3,28 +3,22 @@
   <view class="logo">
     <image class="logo-img" src="../../images/img_gqsj_01@2x.png" style="width:208px; height:71px" />
   </view>
-  <swiper
-    style="height: {{bannerHeight}}px"
-    autoplay="true"
-    indicator-dots="true"
-    indicator-color="#fff"
-    indicator-active-color="red"
-  >
+  <swiper style="height: {{bannerHeight}}px" autoplay="true" indicator-dots="true" indicator-color="#fff" indicator-active-color="red">
     <swiper-item class="swiper-item">
-     <image src="../../images/img_banner01@2x.png" style="width: 100%; height: {{bannerHeight}}px"/>
-     <view class="swiper-item__text">
+      <image src="../../images/img_banner01@2x.png" style="width: 100%; height: {{bannerHeight}}px" />
+      <view class="swiper-item__text">
         <text class="swiper-item__title">钢琴课程</text>
         <text class="swiper-item__subtitle">带您提高音乐素养</text>
         <text class="swiper-item__desc">为您打造一系列定制课程</text>
-     </view>
+      </view>
     </swiper-item>
     <swiper-item class="swiper-item">
-     <image src="../../images/img_banner01@2x.png" style="width: 100%; height: {{bannerHeight}}px"/>
-     <view class="swiper-item__text">
+      <image src="../../images/img_banner01@2x.png" style="width: 100%; height: {{bannerHeight}}px" />
+      <view class="swiper-item__text">
         <text class="swiper-item__title">钢琴课程</text>
         <text class="swiper-item__subtitle">带您提高音乐素养</text>
         <text class="swiper-item__desc">为您打造一系列定制课程</text>
-     </view>
+      </view>
     </swiper-item>
   </swiper>
   <view class="time">
@@ -44,8 +38,13 @@
     <button class="start-btn" bindtap="handleBtnClick">{{isLearning ? '结束' : '开始' }}</button>
   </view>
   <zan-popup show="{{ showPopup }}" bindclose="togglePopup">
-    <canvas canvas-id="shareCanvas" style="width: {{shareCanvasWidth}}px; height:{{shareCanvasHeight}}px">
-    </canvas>
+    <view class='{{ showPopup ? "sg-show-popup" : "sg-hide-popup" }}'>
+      <view class='hide-popup-btn' bindtap='hidePhotoPopup'>
+        <icon type='cancel' color='white'></icon>
+      </view>
+      <canvas canvas-id="shareCanvas" style="width: {{shareCanvasWidth}}px; height:{{shareCanvasHeight}}px">
+      </canvas>
+    </view>
     <button class="share-btn" bindtap="handleShare" type='primary'>生成图片发到朋友圈</button>
   </zan-popup>
-</view>
+</view>

+ 16 - 0
wechat/pages/index/index.wxss

xqd
@@ -130,4 +130,20 @@ swiper {
 .close-btn,
 .share-btn {
   width: 80%;
+}
+.sg-show-popup {
+  width: 100%;
+  height: 100%;
+}
+.sg-hide-popup {
+  width: 0;
+  height: 0;
+  margin-left: 1000rpx;
+  display: block;
+  overflow: hidden;
+}
+.hide-popup-btn {
+  position: fixed;
+  top: -50rpx;
+  right: -10rpx;
 }