吴树波 1 日 前
コミット
bdbc448716
3 ファイル変更25 行追加26 行削除
  1. 5 2
      api/api.js
  2. 2 2
      common/request.js
  3. 18 22
      pages/index/index.vue

+ 5 - 2
api/api.js

@@ -6,8 +6,11 @@ let request = new Request().http
  export function callback(data) {
  	 return request('/baidu/callback',data,'GET');
  }
- export function getTemplate(no) {
- 	 return request('/baidu/getTemplate',{no},'GET');
+ export function getTemplateByNo(no) {
+ 	 return request('/baidu/getTemplateByNo',{no},'GET');
+ }
+ export function getTemplateById(id) {
+ 	 return request('/baidu/getTemplateById',{id},'GET');
  }
  export function youkuClickCallback(data) {
  	 return request('/baidu/youkuClickCallback',data,'GET');

+ 2 - 2
common/request.js

@@ -2,9 +2,9 @@
 export default class Request {
 	http(router, data = {}, method,contentType) {
 		let that = this;
-		// let path = 'http://localhost:8008';
+		let path = 'http://localhost:8008';
 		// let path = 'http://n9jxvn.natappfree.cc';
-		let path = 'https://bd.runtzh.com/prod-api';
+		// let path = 'https://bd.runtzh.com/prod-api';
 		uni.setStorageSync('requestPath',path)
 		// uni.showLoading({
 		// 	title: '載入中'

+ 18 - 22
pages/index/index.vue

@@ -8,7 +8,7 @@
 </template>
 <script>
 	import Clipboard from 'clipboard'; // 引入Clipboard
-	import {getTemplate,callback,youkuClickCallback, iqiyiClickCallback} from '../../api/api.js'
+	import {getTemplateByNo,getTemplateById,callback,youkuClickCallback, iqiyiClickCallback} from '../../api/api.js'
 	import {clicks} from '../../common/common.js'
 		
 		
@@ -22,7 +22,8 @@
 				vid: '',
 				click_id: '',
 				aid: '',
-				no: '',
+				id: null,
+				no: null,
 				type: 0,
 				show: false,
 				name: '',
@@ -40,21 +41,9 @@
 			window.vueInstance = this;  // 将 Vue 实例暴露到全局
 		},
 		onLoad(option) {
-			if(option.type == null || option.type == "" || option.type == undefined){
-				uni.showToast({
-					icon:'none',
-					title: '推广链接错误',
-				});
-				return;
-			}
-			if(option.accountId == null || option.accountId == "" || option.accountId == undefined){
-				uni.showToast({
-					icon:'none',
-					title: '推广链接错误',
-				});
-				return;
-			}
-			if(option.id == null || option.id == "" || option.id == undefined){
+			this.no = option.no;
+			this.id = option.tid;
+			if((this.id == null || this.id == "" || this.id == undefined) && (this.no == null || this.no == "" || this.no == undefined)){
 				uni.showToast({
 					icon:'none',
 					title: '推广链接错误',
@@ -82,11 +71,18 @@
 				this.impress_id = option.impress_id;
 				this.sign = option.sign;
 			}
-			getTemplate(option.id).then(e => {
-				this.data = e.data;
-				this.site = e.site;
-				this.json = JSON.parse(e.data.json)
-			})
+			if(this.id){
+				getTemplateById(this.id).then(e => {
+					this.data = e.data;
+					this.site = e.site;
+					this.json = JSON.parse(e.data.json)
+				})
+			}else if(this.no){
+				getTemplateByNo(this.no).then(e => {
+					this.data = e.data;
+					this.json = JSON.parse(e.data.json)
+				})
+			}
 			// callback({vid: this.vid}).then(e => {
 			// 	console.info(e)
 			// })