wzx vor 1 Jahr
Ursprung
Commit
bce9b4e2f2
5 geänderte Dateien mit 163 neuen und 11 gelöschten Zeilen
  1. 53 3
      custom/common/api.js
  2. 10 0
      custom/common/tools.js
  3. 2 2
      custom/manifest.json
  4. 32 0
      custom/package.json
  5. 66 6
      custom/pages/shanda/challenge/success.uvue

+ 53 - 3
custom/common/api.js

@@ -1,4 +1,54 @@
-export const apiServer = 'https://colormaprun.com/api/custom/';
+export const ossUrl = process.env.OSS_URL;
+export const apiServer = process.env.API_BASE_URL;
 
-// test
-// export const apiTest = apiServer + 'test';
+export const token = '';
+// export const token = '96ba3c924394934f7d30fa869a94ce0d';
+
+// 根据游戏id查询卡片信息
+export const apiCardUrlQuery = apiServer + 'CardUrlQuery';
+
+
+import tools from '/common/tools';
+
+// 检测request的返回值
+export function checkResCode(res) {
+	if (res.data.code == 0) {
+		return true;
+	} else if (res.statusCode == 401) { // 未登录
+		uni.showToast({
+			title: `您尚未登录`,
+			icon: 'none',
+			duration: 3000
+		});
+		
+		const url = `action://to_login/`;
+		tools.appAction(url);
+		return false;
+	} else {
+		uni.showToast({
+			title: `${res.data.message}`,
+			icon: 'none',
+			duration: 3000
+		});
+		return false;
+	}
+};
+
+// 检测token
+export function checkToken(token) {
+	const regex = /^[0-9A-Za-f]{32}$/;
+	if (regex.test(token)) {
+		return true;
+	} else { // 未登录
+		console.log('checkToken err: ', token);
+		uni.showToast({
+			title: `您尚未登录`,
+			icon: 'none',
+			duration: 3000
+		});
+		
+		const url = `action://to_login/`;
+		tools.appAction(url);
+		return false;
+	}
+};

+ 10 - 0
custom/common/tools.js

@@ -1,4 +1,14 @@
 var tools = {
+	
+	// 导航到彩图奔跑APP内的某个页面或执行APP内部的某些功能
+	appAction(url) {
+		console.log("appAction", url);
+		// console.log("getApp", getApp());
+		// getApp().$audio.destroy();
+		// getApp().$audio.pause();
+		window.location.href = url;
+	},
+	
 	// 秒数转换成时分秒
 	convertSecondsToHMS(seconds) {
 		var hours = Math.floor(seconds / 3600);

+ 2 - 2
custom/manifest.json

@@ -2,8 +2,8 @@
     "name" : "custom",
     "appid" : "__UNI__F860CDD",
     "description" : "彩虹定向APP内客户定制样式页面",
-    "versionName" : "1.1.0",
-    "versionCode" : 110,
+    "versionName" : "1.1.1",
+    "versionCode" : 111,
     "uni-app-x" : {},
     /* 快应用特有相关 */
     "quickapp" : {},

+ 32 - 0
custom/package.json

@@ -0,0 +1,32 @@
+{
+  "name": "custom",
+  "version": "1.0.0",
+  "description": "",
+  "main": "main.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "keywords": [],
+  "author": "",
+  "license": "ISC",
+  "uni-app": {
+  		"scripts": {
+  			"dev": {
+  				"title": "开发版",
+  				"env": {
+  					"UNI_PLATFORM": "h5",
+  					"API_BASE_URL":"https://t-mapi.colormaprun.com/api/card/",
+					"OSS_URL": "http://t-oss-card.colormaprun.com/card/"
+  				}
+  			},
+  			"prod": {
+  				"title": "正式版",
+  				"env": {
+  					"UNI_PLATFORM": "h5",
+  					"API_BASE_URL":"https://colormaprun.com/api/card/",
+					"OSS_URL": "http://oss-card.colormaprun.com/card/"
+  				}
+  			}
+  		}
+  	}
+}

+ 66 - 6
custom/pages/shanda/challenge/success.uvue

@@ -1,5 +1,5 @@
 <!-- 
-http://localhost:5173/custom/#/pages/shanda/challenge/index?pagetype=challenge_result&distance=1320&status=success&name=天生我材必有用&cal=13500100&duration=3600&accuracy=50&syscount=25
+http://localhost:5173/custom/#/pages/shanda/challenge/index?actId=18&matchType=3&pagetype=challenge_result&distance=1320&status=success&name=天生我材必有用&cal=13500100&duration=3600&accuracy=50&syscount=25
 https://oss-mbh5.colormaprun.com/custom/#/pages/shanda/challenge/index?pagetype=challenge_result&distance=1320&status=success&name=天生我材必有用&cal=13500100&duration=3600&accuracy=50&syscount=25
  -->
 <template>
@@ -50,18 +50,30 @@ https://oss-mbh5.colormaprun.com/custom/#/pages/shanda/challenge/index?pagetype=
 </template>
 
 <script>
-	import tools from '../../../common/tools';
+	import tools from '/common/tools';
+	import {
+		token,
+		apiCardUrlQuery,
+		checkResCode
+	} from '/common/api';
 
 	export default {
 		data() {
 			return {
+				token: "",
+				matchType: 0, 	// 游戏类型 1 普通活动 2 线下赛 3 线上赛
+				ecId: 0, 		// 卡片id
+				
 				status: "",		// success: 挑战成功, ok: 挑战完成(没在规定时间完成,但打了所有点), fail: 挑战结束
 				name: "",		// 用户名
 				duration: 0,	// 总用时,秒
 				distance: 0,	// 总里程,米
 				cal: 0,			// 卡路里,卡 int
 				accuracy: 0,	// 脑力值百分比
-				syscount: 0		// 点数
+				syscount: 0		,// 点数
+				
+				actId: 0, 		// 活动或关联id
+				urlRs: [],		// Url集合
 			}
 		},
 		computed: {
@@ -88,6 +100,11 @@ https://oss-mbh5.colormaprun.com/custom/#/pages/shanda/challenge/index?pagetype=
 		},
 		onLoad(event) { // 类型非必填,可自动推导
 			console.log('[challenge result] onLoad');
+			
+			this.token = event["token"] ?? token;
+			this.actId = event["actId"] ?? 0;
+			this.matchType = event["matchType"] ?? 0;
+			
 			this.status = event["status"] ?? "";
 			this.name = event["name"] ?? "";
 			this.duration = event["duration"] ?? 0;
@@ -95,12 +112,55 @@ https://oss-mbh5.colormaprun.com/custom/#/pages/shanda/challenge/index?pagetype=
 			this.cal = event["cal"] ?? 0;
 			this.accuracy = event["accuracy"] ?? 0;
 			this.syscount = event["syscount"] ?? 0;
+			
+			this.cardUrlQuery();
 		},
 		methods: {
+			// 根据游戏id查询卡片信息
+			cardUrlQuery() {
+				uni.request({
+					url: apiCardUrlQuery,
+					header: {
+						"Content-Type": "application/x-www-form-urlencoded",
+						"token": this.token,
+					},
+					method: "POST",
+					data: {
+						actId: this.actId,
+						matchType: this.matchType
+					},
+					success: (res) => {
+						// console.log("cardUrlQuery", res);
+						if (res.data.code == 0) {
+							const data = res.data.data;
+							this.ecId = data.ecId;
+							this.urlRs = data.urlRs;
+						}
+					},
+					fail: (err) => {
+						console.log("cardUrlQuery err", err);
+					},
+				});
+			},
 			btnRankList() {
-				// uni.navigateTo({
-				// 	url: '/pages/bm/style1/rankList?' + this.queryString
-				// });
+				// console.log("urlRs", this.urlRs);
+				// const rankListUrl = this.urlRs.find(item => item.name === 'rankListUrl');
+				const rankListUrl = this.urlRs.rankListUrl;
+				// console.log("rankListUrl", rankListUrl);
+				if (rankListUrl != null) {
+					const url = rankListUrl + '?token=' + this.token + '&id=' + this.ecId;
+					console.log("url", url);
+					// uni.navigateTo({
+					// 	url: url
+					// });
+					window.location.href = url;
+				} else {
+					uni.showToast({
+						title: '网址错误:' + rankListUrl,
+						icon: 'none',
+						duration: 3000
+					});
+				}
 			}
 		}
 	}