Rorschach 5 年 前
コミット
aa590b6c35

+ 17 - 1
app.js

@@ -1,6 +1,9 @@
 //app.js
+import {GetQueryString} from 'utils/util'
 App({
-  onLaunch: function () {
+  onLaunch: function (options) {
+   
+
     // 展示本地存储能力
     var logs = wx.getStorageSync('logs') || []
     logs.unshift(Date.now())
@@ -33,6 +36,19 @@ App({
       }
     })
   },
+  // onShow: function(options){
+  //   console.log(options)
+  //   const type = GetQueryString(decodeURIComponent(options.query.scene), "type");
+  //   const sceneId = GetQueryString(decodeURIComponent(options.query.scene), "id");
+  //   console.log(type, sceneId)
+  //   switch (type) {
+  //     case "works":
+  //       wx.navigateTo({
+  //         url: `../social/works/works?id=${sceneId}&title="测试"`
+  //       })
+  //       break
+  //   };
+  // },
   globalData: {
     userInfo: null
   }

+ 31 - 0
component/goBackHome/goBackHome.js

@@ -0,0 +1,31 @@
+// compontents/dialog/dialog.js
+Component({
+    /**
+     * 组件的属性列表
+     */
+    properties: {
+        show: {
+            type: 'Boolean',
+            value: false
+          },
+    },
+  
+    /**
+     * 组件的初始数据
+     */
+    data: {
+    //   show: false
+    },
+  
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+        goBackHome: function(){
+            wx.redirectTo({
+                url: '../../index/index'
+            })
+      }
+    }
+  })
+  

+ 4 - 0
component/goBackHome/goBackHome.json

@@ -0,0 +1,4 @@
+{
+    "component": true,
+    "usingComponents": {}
+  }

+ 3 - 0
component/goBackHome/goBackHome.wxml

@@ -0,0 +1,3 @@
+<view class="goBackHome" bindtap="goBackHome" >
+    <image src="../../static/image/goBackHome.png" />
+</view>

+ 12 - 0
component/goBackHome/goBackHome.wxss

@@ -0,0 +1,12 @@
+.goBackHome {
+    width: 100rpx;
+    height: 100rpx;
+    position: fixed;
+    bottom: 168rpx;
+    right: 45rpx;
+
+}
+.goBackHome image{
+    width: 100%;
+    height: 100%;
+}

+ 19 - 7
component/share/share.js

@@ -86,12 +86,12 @@ Component({
                   canvasId: 'myCanvas',
                   success: (res) => {
                     console.log(res.tempFilePath)
-                    wx.saveImageToPhotosAlbum({
-                      filePath: res.path,
-                      success(res) {
-                        console.log(res);
-                      }
-                    })
+                    // wx.saveImageToPhotosAlbum({
+                    //   filePath: res.path,
+                    //   success(res) {
+                    //     console.log(res);
+                    //   }
+                    // })
                     that.setData({
                       imgUrls: res.tempFilePath
                     }, () => {
@@ -160,6 +160,17 @@ Component({
         })
       }
     },
+    //关闭弹框
+    close: function(e){
+      console.log(e)
+      this.setData({
+        shareFlag: !this.data.shareFlag,
+        imgUrls: ''
+      })
+    },
+    nothing: function(e){
+      return
+    },
     // 保存图片到本地
     saveImg: function () {
       console.log('yibuububu')
@@ -329,7 +340,8 @@ Component({
     PreservationImg: function () {
       wx.saveImageToPhotosAlbum({
         filePath: this.data.imgUrls,
-        success(res) {
+        success: (res)=> {
+          console.log(res)
           this.setData({
             imgUrls: false
           })

+ 3 - 3
component/share/share.wxml

@@ -1,5 +1,5 @@
-<view class="share" bindtap="share" wx:if="{{shareFlag}}">
-   <view class="btn" wx:if="{{!imgUrls}}">
+<view class="share" bindtap="close" wx:if="{{shareFlag}}">
+   <view class="btn" wx:if="{{!imgUrls}}" id="btnArea" bindtap="nothing">
        <image class="bg" src="../../static/groupImg/share.png"></image>
        <view class="share-btn">
             <button class="share-friend" open-type="share" catchtap="shareFriend">
@@ -12,7 +12,7 @@
             </view>           
        </view>
    </view>
-   <view class="share-img" wx:if="{{imgUrls}}">
+   <view class="share-img" wx:if="{{imgUrls}}" id="imgArea" bindtap="nothing">
        <cover-image class="img" src="{{imgUrls}}"></cover-image>
        <view class="Preservation">
            <image class="PreservationBg" src="../../static/groupImg/Preservation.png"></image>

+ 13 - 8
component/share/share.wxss

@@ -18,19 +18,22 @@
 }
 
 .btn .bg {
-    width: 90%;
-    margin: 46rpx 5%;
+  display: block;
+    width: 500rpx;
+    margin: 5% auto;
     height: 42rpx;
 }
-
+.btn text{
+  font-size: 28rpx;
+}
 .share-btn {
     display: flex;
     justify-content: space-around;
 }
 
 .share-btn image {
-    width: 66rpx;
-    height: 66rpx;
+    width: 68rpx;
+    height: 68rpx;
 }
 
 .share-btn view {
@@ -40,6 +43,7 @@
     align-items: center;
     font-size: 32rpx;
     height: 120rpx;
+    width: 180rpx
 }
 
 .img {
@@ -86,12 +90,13 @@
     margin:0;
     border-radius:0;    
     height: 140rpx;
-    font-size:32rpx;  
+    font-size:32rpx;
+    width: 180rpx;  
 }
 
 .share-friend image {
-    width: 66rpx;
-    height: 66rpx;
+    width: 68rpx;
+    height: 68rpx;
 }
 
 button::after{ border: none; } 

+ 17 - 5
pages/index/index.js

@@ -20,6 +20,9 @@ import {
 // import '../../utils/hls';
 import httpRequestApi from '../../utils/APIClient';
 import httputil from '../../utils/httpUtil';
+import {
+  GetQueryString
+} from '../../utils/util';
 
 Page({
   data: {
@@ -78,7 +81,7 @@ Page({
       templates
     });
     if (myIndex == 0) {
-      
+
       groupInit(this);
     }
     if (myIndex == 1) {
@@ -105,9 +108,18 @@ Page({
     }
   },
   onLoad: function (options) {
-    console.log(options)
-    this.uid = wx.getStorageSync('uid');
 
+    this.uid = wx.getStorageSync('uid');
+    // const type = GetQueryString(decodeURIComponent(options.scene),"type");
+    // const sceneId = GetQueryString( decodeURIComponent(options.scene),"id");
+    // console.log(type,sceneId)
+    // switch(type){
+    //   case "works":
+    //   wx.navigateTo({
+    //     url: `../social/works/works?id=${sceneId}&title="测试"`
+    //   })
+    //   break
+    // };
     wx.getSystemInfo({
       success: (res) => {
         this.setData({
@@ -161,7 +173,7 @@ Page({
   },
   // 触底加载
   onReachBottom: function () {
-    
+
     // 当前在推荐页面 加载推荐
     if (this.data.myIndex === 1) {
       console.log(this.data.recommendPageNo)
@@ -196,6 +208,6 @@ Page({
     wx.startPullDownRefresh();
     setTimeout(() => {
       wx.stopPullDownRefresh()
-    },10)
+    }, 10)
   }
 })

+ 8 - 3
pages/main/class/class.js

@@ -17,10 +17,15 @@ Page({
     pageNo: 1,
     totalNo: 0,
     collectFlag: false,
+    goBackHome: false
   },
   onLoad: function (option) {
     console.log(option);
-    
+    if(option.scene){
+      this.setData({
+          goBackHome: true
+      })
+  }
     this.setData({
       // title: option.title,
       id: option.id
@@ -126,8 +131,8 @@ Page({
     // let uid =  wx.getStorageSync('uid');
     let data = {
       targetCode: this.data.id,
-      title: this.data.title,
-      iconImg: this.data.iconImg
+      // title: this.data.title,
+      // iconImg: this.data.iconImg
     }
     httpRequestApi.collectClass(this.uid, data).success(res => {
       this.setData({

+ 2 - 1
pages/main/class/class.json

@@ -5,6 +5,7 @@
     "component": true,
     "usingComponents": {
         "shareDialog": "/component/share/share",
-        "popup": "/component/popup/popup"
+        "popup": "/component/popup/popup",
+        "goBackHome": "/component/goBackHome/goBackHome"
     }
 }

+ 1 - 0
pages/main/class/class.wxml

@@ -39,4 +39,5 @@
     </view>
     <canvas canvas-id="myCanvas" style="width:370px;z-index=99999; height: 507px; position: absolute; left: -999rpx; top: -9999rpx;"></canvas>
     <shareDialog id="share-dialog" shareType='class' />
+    <goBackHome id="goBackHome" shareType="{{goBackHome}}" wx:if="{{goBackHome}}" />
 </view>

+ 16 - 5
pages/social/works/works.js

@@ -24,13 +24,18 @@ Page({
         replyModal: false,
         totalRead: 0,
         pageNo: 1,
-        pageSize: 2
+        pageSize: 2,
+        goBackHome: false
         // shareFlag: false
     },
     onLoad: function (option) {
         console.log(option)
         let id = option.id ? option.id : option.scene.replace('QR', '')
-
+        if(option.scene){
+            this.setData({
+                goBackHome: true
+            })
+        }
         wx.setNavigationBarTitle({
             title: option.title //页面标题为路由参数
         })
@@ -92,7 +97,8 @@ Page({
 
         });
     },
-    onShow() {
+    onShow(options) {
+        console.log(options)
         this.setData({
             replyList: [],
             pageNo: 1,
@@ -135,7 +141,7 @@ Page({
             iconImg: this.data.iconImg,
             title: this.data.title,
             path: `pages/social/works/works`,
-            scene: `QR${this.data.id}`
+            scene: `this.data.id`
             // tip: this.data.tip,
         }
         this.shareDialog.share(data);
@@ -421,5 +427,10 @@ Page({
             }
         })
     },
-
+    // 回到首页
+    goBackHome: function(){
+        wx.redirectTo({
+            url: '../../index/index'
+        })
+    }
 })

+ 2 - 1
pages/social/works/works.json

@@ -2,7 +2,8 @@
     "component": true,
     "usingComponents": {
         "shareDialog": "/component/share/share",
-        "popup": "/component/popup/popup"
+        "popup": "/component/popup/popup",
+        "goBackHome": "/component/goBackHome/goBackHome"
     },
     "window": {
         "onReachBottomDistance": 50

+ 5 - 0
pages/social/works/works.wxml

@@ -95,4 +95,9 @@
         </cover-view>
         <cover-image class="quitBtn" bindtap="quitReward" src="../../../static/groupImg/cha.png" />
     </cover-view>
+    <!-- 回到首页弹窗 -->
+    <!-- <view class="goBackHome" bindtap="goBackHome" wx:if="{{goBackHome}}">
+        <image src="../../../static/image/goBackHome.png" />
+    </view> -->
+    <goBackHome id="goBackHome" shareType="{{goBackHome}}" wx:if="{{goBackHome}}" />
 </view>

+ 15 - 1
pages/social/works/works.wxss

@@ -232,7 +232,8 @@
     margin-left: 8rpx;
 }
 
-.btnWrapper .commentText, .likeText {
+.btnWrapper .commentText,
+.likeText {
     width: 58rpx;
     height: 40rpx;
     color: #545454;
@@ -462,4 +463,17 @@ button::after {
     width: 100%;
     height: 300rpx;
     text-indent: 4rpx;
+}
+
+.goBackHome {
+    width: 100rpx;
+    height: 100rpx;
+    position: fixed;
+    bottom: 168rpx;
+    right: 45rpx;
+
+}
+.goBackHome image{
+    width: 100%;
+    height: 100%;
 }

BIN
static/groupImg/Preservation.png


BIN
static/groupImg/circle.png


BIN
static/groupImg/share.png


BIN
static/groupImg/weixin.png


BIN
static/image/goBackHome.png


+ 8 - 1
utils/util.js

@@ -32,7 +32,14 @@ function formatDate(time, flag) {
 		return month + '-' + day + ' ' + hour + ':' + minute;
 	}
 }
+function GetQueryString(str,name){
+	var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
+	var r = str.match(reg);
+	if(r!=null) return  unescape(r[2]); 
+	return null;
+}
 module.exports = {
   formatTime: formatTime,
-  formatDate
+	formatDate,
+	GetQueryString
 }