qinyan 1 year ago
parent
commit
94d337f852
4 changed files with 46 additions and 86 deletions
  1. 1 1
      src/pages/about/about.vue
  2. 10 0
      src/pages/detail/detail.vue
  3. 35 85
      src/pages/index/index.vue
  4. BIN
      src/static/share.jpg

+ 1 - 1
src/pages/about/about.vue

@@ -1,6 +1,6 @@
 <template>
   <view class="about">
-    <text class="tip">queen.show</text>
+    <text class="tip">Queen.show</text>
   </view>
 </template>
 

+ 10 - 0
src/pages/detail/detail.vue

@@ -20,6 +20,10 @@ export default {
     this.id = e.id;
     this.url = `https://show.3dqueen.cloud/share.html?id=${e.id}`;
     this.getData();
+    // wx.showShareMenu({
+    //   withShareTicket: true,
+    //   menus: ["shareAppMessage", "shareTimeline"],
+    // });
   },
   onShareAppMessage() {
     return {
@@ -29,6 +33,12 @@ export default {
       imageUrl: this.designData.thumbnail,
     };
   },
+  // onShareTimeline() {
+  //   return {
+  //     title: this.designData.title,
+  //     imageUrl: this.designData.thumbnail,
+  //   };
+  // },
 
   methods: {
     async getData() {

+ 35 - 85
src/pages/index/index.vue

@@ -27,7 +27,14 @@
             <view class="card_data_text" @click="goDataPage(item)">
               <image class="icon_data" src="/static/data-view.svg"></image>
             </view>
-            <view @click.stop="share(item)" class="card-share-view"></view>
+            <view>
+              <button
+                :data-record="item"
+                open-type="share"
+                class="card-share-view"
+                plain="true"
+              ></button>
+            </view>
           </view>
         </view>
       </block>
@@ -52,7 +59,21 @@ export default {
       refreshing: false,
       list: [],
       fetchPageNum: 1,
-      providerList: [],
+    };
+  },
+  onShareAppMessage(e) {
+    if (e.from == "menu") {
+      return {
+        title: "Queen.show",
+        path: "/pages/index/index",
+        imageUrl: "/static/share.jpg",
+      };
+    }
+    const record = e.target.dataset.record;
+    return {
+      title: record.title,
+      path: "/pages/detail/detail?id=" + record._id,
+      imageUrl: record.thumbnail,
     };
   },
   onLoad() {
@@ -61,7 +82,6 @@ export default {
       this.login = true;
       this.getData();
     }
-    this.getProvider();
   },
   onReachBottom() {
     // console.log("滑动到页面底部");
@@ -75,40 +95,6 @@ export default {
     this.getData();
   },
   methods: {
-    getProvider() {
-      uni.getProvider({
-        service: "share",
-        success: (e) => {
-          let data = [];
-          for (let i = 0; i < e.provider.length; i++) {
-            switch (e.provider[i]) {
-              case "weixin":
-                data.push({
-                  name: "分享到微信好友",
-                  id: "weixin",
-                });
-                data.push({
-                  name: "分享到微信朋友圈",
-                  id: "weixin",
-                  type: "WXSenceTimeline",
-                });
-                data.push({
-                  name: "复制链接",
-                  id: "weixin",
-                  type: "copyLink",
-                });
-                break;
-              default:
-                break;
-            }
-          }
-          this.providerList = data;
-        },
-        fail: (e) => {
-          console.log("获取分享通道失败", e);
-        },
-      });
-    },
     formatTime(value) {
       const date = new Date(value);
       const y = date.getFullYear();
@@ -149,46 +135,6 @@ export default {
         url: "/pages/index/data?id=" + data._id,
       });
     },
-    share(record) {
-      const itemList = this.providerList.map(function (value) {
-        return value.name;
-      });
-      uni.showActionSheet({
-        itemList: itemList,
-        success: (res) => {
-          if (this.providerList[res.tapIndex].type == "copyLink") {
-            const url = `https://show.3dqueen.cloud/share.html?id=${record._id}`;
-            console.log("url: ", url);
-            return;
-          }
-          this.setShare(record, res);
-        },
-      });
-    },
-    setShare(record, res) {
-      uni.share({
-        provider: this.providerList[res.tapIndex].id,
-        scene:
-          this.providerList[res.tapIndex].type &&
-          this.providerList[res.tapIndex].type === "WXSenceTimeline"
-            ? "WXSenceTimeline"
-            : "WXSceneSession",
-        type: 0,
-        title: record.title,
-        summary: record.desc,
-        imageUrl: record.title,
-        href: "/pages/detail/detail?id=" + record._id,
-        success: (res) => {
-          console.log("success:" + JSON.stringify(res));
-        },
-        fail: (e) => {
-          uni.showModal({
-            content: e.errMsg,
-            showCancel: false,
-          });
-        },
-      });
-    },
   },
 };
 </script>
@@ -230,20 +176,18 @@ export default {
 .icon_data {
   width: 36rpx;
   height: 36rpx;
+  padding: 10rpx;
   line-height: 1;
 }
 .card-num-view {
-  line-height: 1;
   display: inline-flex;
   align-items: center;
   justify-content: center;
+  border-radius: 4rpx;
   padding: 3px 6px;
   color: #ffffff;
   font-size: 12px;
-  text-align: center;
-  justify-content: center;
-  align-items: center;
-  border-radius: 4rpx;
+  line-height: 1;
   background-color: #41969c;
 }
 .icon_view {
@@ -278,10 +222,16 @@ export default {
   color: #999;
 }
 .card-share-view {
-  margin-right: 20rpx;
-  color: #41969c;
-  font-size: 30upx;
+  /* margin-right: 20rpx; */
+  padding: 10rpx;
+  color: #41969c !important;
+  font-size: 36upx !important;
   font-family: texticons;
+  line-height: 1 !important;
+}
+
+button[plain] {
+  border: 0;
 }
 
 .card-share-view:before {

BIN
src/static/share.jpg