chending1994 4 rokov pred
rodič
commit
2c7ce3bbe0
3 zmenil súbory, kde vykonal 44 pridanie a 24 odobranie
  1. 2 1
      src/App.vue
  2. 2 22
      src/pages.json
  3. 40 1
      src/utils/utils.js

+ 2 - 1
src/App.vue

@@ -15,13 +15,14 @@
 				if (isWechat()) {
 					const url = window.location.href.split('#')[0];
 					await wxConfigH5(url);
+					wxShare();
 				}
 				// #endif
 				// 获取页面设置配置
 				if(process.env.NODE_ENV === 'production') {
 					const code = getQueryString('code');
 					const storageCode = uni.getStorageInfoSync('code');
-					if((code && !storageCode) || (storageCode && code != storageCode)) {
+					if (code && code != storageCode) {
 						uni.setStorageSync('code', code)
 						weixinLogin();
 					}

+ 2 - 22
src/pages.json

@@ -1,10 +1,10 @@
 {
-	"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
+	"pages": [
 		{
 			"path": "pages/index/index",
 			"style": {
 				"enablePullDownRefresh": false,
-				"navigationBarTitleText": "逻辑狗挑战赛",
+				"navigationBarTitleText": "中德智慧教育 全球儿童思维教育专家 全球优质教育内容输出平台",
 				"onReachBottomDistance": 50,
 				"navigationStyle": "custom"
 			}
@@ -189,24 +189,4 @@
 		"app-plus": { "titileNView": false },
 		"navigationStyle": "custom"
 	}
-	// "tabBar": {
-	// 	"borderStyle": "white",
-	// 	"color": "#999999",
-	// 	"selectedColor": "#23D321",
-	// 	"backgroundColor": "#ffffff",
-	// 	"list": [
-	// 		{
-	// 			"pagePath": "pages/index/index",
-	// 			"iconPath": "static/img/tabbar/index.png",
-	// 			"selectedIconPath": "static/img/tabbar/indexHL.png",
-	// 			"text": "首页"
-	// 		},
-	// 		{
-	// 			"pagePath": "pages/me/index",
-	// 			"iconPath": "static/img/tabbar/me.png",
-	// 			"selectedIconPath": "static/img/tabbar/meHL.png",
-	// 			"text": "我的"
-	// 		}
-	// 	]
-	// }
 }

+ 40 - 1
src/utils/utils.js

@@ -1,7 +1,6 @@
 import wx from 'weixin-js-sdk';
 import { http } from '@/utils/request';
 import { wechatConfig } from '@/api/common';
-import mHelper from '@/utils/helper';
 
 export function isWechat() {
   // #ifdef H5
@@ -57,6 +56,46 @@ export async function wxConfigH5(url) {
   })
 }
 
+export function wxShare(title, imgUrl, desc, link) {
+  const url = window.location.href.split('#')[0];
+  const shareTitle = title || '中德智慧教育';
+  const shareDesc = desc || '全球思维儿童教育专家 全球优质教育内容输出平台';
+  const shareLink = link || url;
+  const shareImgUrl = imgUrl || 'http://res.training.luojigou.vip/FiLdD-zXCwM6A6JkVzAp8nKM7WLx';
+  wx.ready(() => {
+    wx.onMenuShareTimeline({
+      title: shareTitle, // 分享时的标题
+      link: shareLink, // 分享时的链接
+      imgUrl: shareImgUrl, // 分享时的图标
+      success() {
+        // Toast('分享成功');
+        console.log('分享成功');
+      },
+      cancel() {
+        // Toast('取消分享');
+        console.log('取消分享');
+      },
+    });
+    // 分享给朋友
+    wx.onMenuShareAppMessage({
+      title: shareTitle,
+      desc: shareDesc,
+      link: shareLink,
+      imgUrl: shareImgUrl,
+      type: '',
+      dataUrl: '',
+      success() {
+        // Toast('分享成功');
+        console.log('分享成功');
+      },
+      cancel() {
+        // Toast('取消分享');
+        console.log('取消分享');
+      },
+    });
+  });
+}
+
 export function getQueryString(name) {
   let reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`, 'i');
   let r = window.location.search.substr(1).match(reg); // 获取url中"?"符后的字符串并正则匹配