浏览代码

新增 图片分享

wangzhihui 4 年之前
父节点
当前提交
e99782d4ec

+ 1 - 1
miniprogram/pages/cachePage/cachePage.js

@@ -105,7 +105,7 @@ Page({
         type: wx.getStorageSync('type'),
         location: `${this.data.longitude},${this.data.latitude}`
       }, 1)
-      console.log(res)
+      wx.setStorageSync('shareImageUrl', res.result.mediaInfo.viewUrl)
       if (res.status == 0) {
         let {
           shipInfo,

+ 5 - 59
miniprogram/pages/share/share.js

@@ -1,66 +1,12 @@
 // pages/share/share.js
 Page({
-
-  /**
-   * 页面的初始数据
-   */
   data: {
-
+    shareImageUrl: ''
   },
-
-  /**
-   * 生命周期函数--监听页面加载
-   */
   onLoad: function (options) {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady: function () {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow: function () {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide: function () {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload: function () {
-
-  },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh: function () {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom: function () {
-
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-
+    // 小程序解析带有多个等号的参数时,无法解析等号后面的参数,故=号互相替换%%%%%%
+    this.setData({
+      shareImageUrl: options.shareImageUrl.replace(/%%%%%%/g, "=")
+    })
   }
 })

+ 2 - 1
miniprogram/pages/share/share.json

@@ -1,3 +1,4 @@
 {
-  "usingComponents": {}
+  "usingComponents": {},
+  "navigationBarTitleText": "汇很多"
 }

+ 1 - 2
miniprogram/pages/share/share.wxml

@@ -1,2 +1 @@
-<!--pages/share/share.wxml-->
-<text>pages/share/share.wxml</text>
+<image mode="aspectFit" src="{{shareImageUrl}}" style="width: 100%;margin-top: 30%;"></image>

+ 14 - 0
miniprogram/pages/takePhoto/success/success.js

@@ -3,5 +3,19 @@ Page({
     wx.navigateTo({
       url: '/pages/takePhoto/takePhoto',
     })
+  },
+  share() {
+
+  },
+  onShareAppMessage() {
+    let shareImageUrl = wx.getStorageSync('shareImageUrl')
+
+
+    return {
+      title: '真实 实时 精准',
+      // 小程序解析带有多个等号的参数时,无法解析等号后面的参数,故=号互相替换%%%%%%
+      path: `/pages/share/share?shareImageUrl=${shareImageUrl.replace(/=/g,'%%%%%%')}`,
+      imageUrl: shareImageUrl
+    }
   }
 })

+ 1 - 1
miniprogram/pages/takePhoto/success/success.wxml

@@ -4,4 +4,4 @@
 <view style="width: 100%;height: 48rpx;text-align:center;font-size: 34rpx;font-family: PingFangSC-Medium,PingFang SC;font-weight: 500;color: #0094FE;line-height: 48rpx;margin-top: 60rpx;">视频/图片上传成功
 </view>
 <view bindtap="go" style="margin:0 auto;margin-top:156rpx;width: 650rpx;height: 80rpx;background:#0094FE;border-radius: 4rpx;color: #fff;text-align: center;font-size: 34rpx;font-family: PingFangSC-Regular, PingFang SC;font-weight: 400;line-height: 80rpx;">继续拍照</view>
-<view bindtap="go" style="margin:0 auto;margin-top:40rpx;width: 650rpx;height: 80rpx;border-radius: 4rpx;color: #0094FE;text-align: center;font-size: 34rpx;font-family: PingFangSC-Regular, PingFang SC;font-weight: 400;line-height: 80rpx;border: 1px solid #0094FE;">返回</view>
+<button open-type="share" bindtap="share" style="margin:0 auto;margin-top:40rpx;width: 650rpx;height: 80rpx;line-height:50rpx!important;border-radius: 4rpx;color: #0094FE;text-align: center;font-size: 34rpx;font-family: PingFangSC-Regular, PingFang SC;font-weight: 400;line-height: 80rpx;border: 1px solid #0094FE;">分享</button>

+ 2 - 0
miniprogram/pages/takePhoto/takePhoto.js

@@ -76,6 +76,7 @@ Page({
                       location: `${this.data.longitude},${this.data.latitude}`
                     })
                     if (res.status == 0) {
+                      console.log(res)
                       wx.showToast({
                         title: res.msg
                       })
@@ -126,6 +127,7 @@ Page({
                       wx.showToast({
                         title: res.msg
                       })
+                      wx.setStorageSync('shareImageUrl', res.result.viewUrl)
                       wx.downloadFile({
                         url: res.result.viewUrl,
                         success: e => {