future 1 anno fa
parent
commit
ccbe3dc459

+ 59 - 72
xs-app/App.vue

@@ -9,14 +9,6 @@
 	export default {
 		onLaunch: function() {
 			console.log('App Launch')
-			switch (tools.platform){
-				case config.Platform.WEIXIN:
-					wx.showShareMenu({
-						withShareTicket: true,
-						menus: ['shareAppMessage', 'shareTimeline']
-					});
-				break;
-			}
 			tools.requestLogin(()=>{
 				// tools.requestRechargeOrderBuy(config.pay_type.WEI_XIN,1,(order_id,data)=>{
 				// 	console.log("order_id",order_id)
@@ -32,7 +24,7 @@
 				// })
 			})
 		    // 订阅小程序初始化成功的事件
-			if(tools.platform==config.Platform.WEIXIN) {
+			if(tools.getCurPlatform()==config.Platform.WEIXIN) {
 				// 订阅小程序初始化成功的事件
 				novelPlugin.setLoggerConfig({
 				    info:false,
@@ -53,46 +45,43 @@
 	}
 	
 	function onNovelPluginLoad(data) {
-	  // data.id 句柄 用来获取novelManager实例
-	  const novelManager = novelPlugin.getNovelManager(data.id);
-				 console.log(novelManager.getPluginInfo())
-	  // getId() 返回当前manager对应的Id(即句柄)
-	  console.log('id:', novelManager.getId());
-
-	  // getBookId() 返回当前manager对应的bookId
-	  console.log('bookId:', novelManager.getBookId());
-	  
-	  // novelManager.onUserTriggerEvent((params)=>{
-		 //  console.log("params",params)
-	  // })
-	  
-	  novelManager.setClosePluginInfo({  //关闭后跳转的界面
-		  url: '/pages/bookstore/bookstore',
-		  mode: 'switchTab'  // 'redirectTo'
-	  })
-	  // console.log('novelManager:', novelManager);
-	  // setBookshelfStatus(Object params)
-	  // params.bookshelfStatus number类型 0 代表用户取消添加书架 1 代表用户添加书架
-	  // 因为是否添加书架的情况阅读器并不记录 所以需要接入方在接入的时候设置书架的状态
-	  // 默认情况该值为0 即未添加
-	  // 注:此处直接设置了未添加的状态 但实际情况应是接入方去拉取存储于接入方的用户数据
+		// data.id 句柄 用来获取novelManager实例
+		const novelManager = novelPlugin.getNovelManager(data.id);
+		console.log(novelManager.getPluginInfo())
+		// getId() 返回当前manager对应的Id(即句柄)
+		console.log('id:', novelManager.getId());
+		// getBookId() 返回当前manager对应的bookId
+		console.log('bookId:', novelManager.getBookId());
+		// novelManager.onUserTriggerEvent((params)=>{
+		// 	console.log("params",params)
+		// })
+		novelManager.setClosePluginInfo({  //关闭后跳转的界面
+			url: '/pages/bookstore/bookstore',
+			mode: 'switchTab'  // 'redirectTo'
+		})
+		// console.log('novelManager:', novelManager);
+		// setBookshelfStatus(Object params)
+		// params.bookshelfStatus number类型 0 代表用户取消添加书架 1 代表用户添加书架
+		// 因为是否添加书架的情况阅读器并不记录 所以需要接入方在接入的时候设置书架的状态
+		// 默认情况该值为0 即未添加
+		// 注:此处直接设置了未添加的状态 但实际情况应是接入方去拉取存储于接入方的用户数据
 		tools.getBookIdByWxBookId(novelManager.getBookId(),(book_id)=>{
 			tools.checkBookOnBookshelf(book_id,(is_on)=>{
-				  novelManager.setBookshelfStatus({
+				novelManager.setBookshelfStatus({
 					bookshelfStatus: is_on==true?1:0,
-				  });
+				});
 			})
 		})
-	  // var wx_book_id = novelManager.getBookId()
-	  // 监听用户点击书架的事件
-	  // params.bookshelfStatus number类型 0 代表用户取消添加书架 1 代表用户添加书架
-	  novelManager.onClickBookshelf((params) => {
-		// 此处逻辑应是接入方将用户设置的数据存储下来
-		// 之后将书架状态改变
-		// 如果接入方不去主动设置该状态 那么用户点击加入书架后 则不会有任何响应
-		// novelManager.setBookshelfStatus({
-		//   bookshelfStatus: params.bookshelfStatus === 0 ? 1 : 0,
-		// });
+		// var wx_book_id = novelManager.getBookId()
+		// 监听用户点击书架的事件
+		// params.bookshelfStatus number类型 0 代表用户取消添加书架 1 代表用户添加书架
+		novelManager.onClickBookshelf((params) => {
+			// 此处逻辑应是接入方将用户设置的数据存储下来
+			// 之后将书架状态改变
+			// 如果接入方不去主动设置该状态 那么用户点击加入书架后 则不会有任何响应
+			// novelManager.setBookshelfStatus({
+			//   bookshelfStatus: params.bookshelfStatus === 0 ? 1 : 0,
+			// });
 			tools.getBookIdByWxBookId(novelManager.getBookId(),(book_id)=>{
 				console.log("book_id:",book_id)
 				if(params.bookshelfStatus === 0 ){
@@ -109,35 +98,33 @@
 					})
 				}
 			})
-		
-	
-	  });
+		});
 
-	  // setContents 设置目录信息(Object params)
-	  // params.contents Array类型 是一个代表各个章节信息的数组
-	  // params.contents[i].index  number类型 代表章节下标(章节下标从0开始)
-	  // params.contents[i].status number类型 代表章节状态(0 免费章节 1 未付费章节 2 已付费章节 其余值非法)
-	  // 下方示例代表:第一章免费,第二张已付费,第三章未付费
-	  // 注1: 该接口设置的数据仅影响插件页目录的UI表现,插件页去拉取章节数据的时候还是会依赖后台返回的状态。
-	  // 注2: 该接口可以反复调用,因为某些章节数据量过大,如需要分页拉取的时候,该特性或许有用
-	  // 注3: 实际开发中,此数据应从接入方后台拉取
-	  // 注4: 若不设置此数据,则免费章节、未付费章节与已付费章节在目录UI上无法分辨,虽不会影响实际付费的逻辑,但还是强烈建议设置此数据
-	 //  novelManager.setContents({
-		// contents: [
-		//   {
-		// 	index: 0,
-		// 	status: 0,
-		//   },
-		//   {
-		// 	index: 1,
-		// 	status: 2,
-		//   },
-		//   {
-		// 	index: 2,
-		// 	status: 1,
-		//   },
-		// ],
-	 //  });
+	    // setContents 设置目录信息(Object params)
+	    // params.contents Array类型 是一个代表各个章节信息的数组
+	    // params.contents[i].index  number类型 代表章节下标(章节下标从0开始)
+	    // params.contents[i].status number类型 代表章节状态(0 免费章节 1 未付费章节 2 已付费章节 其余值非法)
+	    // 下方示例代表:第一章免费,第二张已付费,第三章未付费
+	    // 注1: 该接口设置的数据仅影响插件页目录的UI表现,插件页去拉取章节数据的时候还是会依赖后台返回的状态。
+	    // 注2: 该接口可以反复调用,因为某些章节数据量过大,如需要分页拉取的时候,该特性或许有用
+	    // 注3: 实际开发中,此数据应从接入方后台拉取
+	    // 注4: 若不设置此数据,则免费章节、未付费章节与已付费章节在目录UI上无法分辨,虽不会影响实际付费的逻辑,但还是强烈建议设置此数据
+	    // novelManager.setContents({
+	    // 	contents: [
+	    // 	  {
+	    // 		index: 0,
+	    // 		status: 0,
+	    // 	  },
+	    // 	  {
+	    // 		index: 1,
+	    // 		status: 2,
+	    // 	  },
+	    // 	  {
+	    // 		index: 2,
+	    // 		status: 1,
+	    // 	  },
+	    // 	],
+	    // });
 	}
 </script>
 	

+ 3 - 3
xs-app/framework/sdkUtil.ts

@@ -13,7 +13,7 @@ import { tools } from "./tools"
 export class sdkUtil {
 		
 	public static login(cb:Function) {
-		switch (tools.platform){
+		switch (tools.getCurPlatform()){
 			case config.Platform.H5:
 			    cb && cb(null)
 			    break
@@ -45,7 +45,7 @@ export class sdkUtil {
 	}
 	
 	public static showPayment(data:wx_pay_data,cb:Function){
-		switch (tools.platform){
+		switch (tools.getCurPlatform()){
 			case config.Platform.WEIXIN:
 			    wx.requestPayment({
 					timeStamp: data.timeStamp,
@@ -80,7 +80,7 @@ export class sdkUtil {
 	 * 添加桌面
 	 */
 	public static addShortcut(cb:Function) {
-		switch (tools.platform){
+		switch (tools.getCurPlatform()){
 			case config.Platform.WEIXIN:
 			    wx.addShortcut({
 					success() {

+ 5 - 0
xs-app/framework/tools.ts

@@ -17,6 +17,11 @@ export class tools {
 		// #ifdef  MP-WEIXIN
 			config.applet_id = config.applet_id_config.wx
 			tools.platform = config.Platform.WEIXIN
+			//微信初始化设置显示分享弹窗,右上角'···'才可以转发给朋友,复制链接
+			wx.showShareMenu({
+				withShareTicket: true,
+				menus: ['shareAppMessage', 'shareTimeline']
+			});
 		// #endif
 		
 		// #ifdef  MP-TOUTIAO

+ 1 - 1
xs-app/pages/bookstore/bookstore.vue

@@ -30,7 +30,7 @@
 	let H3_data_list = ref<Array<Array<book_item_data>>>([])
 	
 	let content_paddingTop = ref(0)
-	if(tools.platform == config.Platform.WEIXIN) {
+	if(tools.getCurPlatform() == config.Platform.WEIXIN) {
 		content_paddingTop.value = uni.getSystemInfoSync().safeArea.top + 40
 	}