吴树波 1 month ago
parent
commit
17e3e10a53
2 changed files with 75 additions and 56 deletions
  1. 3 0
      api/api.js
  2. 72 56
      pages/index/index.vue

+ 3 - 0
api/api.js

@@ -12,6 +12,9 @@ let request = new Request().http
  export function getTemplateById(id) {
  	 return request('/baidu/getTemplateById',{id},'GET');
  }
+ export function baiduClickCallback(data) {
+ 	 return request('/baidu/baiduClickCallback',data,'GET');
+ }
  export function youkuClickCallback(data) {
  	 return request('/baidu/youkuClickCallback',data,'GET');
  }

+ 72 - 56
pages/index/index.vue

@@ -10,12 +10,13 @@
 	import Clipboard from 'clipboard'; // 引入Clipboard
 	import {getTemplateByNo,getTemplateById,callback,youkuClickCallback, iqiyiClickCallback} from '../../api/api.js'
 	import {clicks} from '../../common/common.js'
-		
-		
+
+
 	export default {
 		data() {
 			return {
-				images: [],
+        images: [],
+        params: {},
 				site: {},
 				data: {},
 				json: {},
@@ -41,8 +42,9 @@
 			window.vueInstance = this;  // 将 Vue 实例暴露到全局
 		},
 		onLoad(option) {
-			this.no = option.no;
-			this.id = option.tid;
+      this.params = option;
+			this.no = this.params.no;
+			this.id = this.params.tid;
 			if((this.id == null || this.id == "" || this.id == undefined) && (this.no == null || this.no == "" || this.no == undefined)){
 				uni.showToast({
 					icon:'none',
@@ -50,38 +52,22 @@
 				});
 				return;
 			}
-			this.accountId = option.accountId;
-			this.type = option.type;
-			this.no = option.no;
-			// 百度
-			if(this.type == 0){
-				this.vid = option.bd_vid;
-			}
-			// 优酷
-			if(this.type == 1){
-				this.vid = option.bd_vid;
-				this.aid = option.aid;
-				this.click_id = option.click_id;
-				this.ip = option.ip;
-			}
-			// 爱奇艺
-			if(this.type == 2){
-				this.order_plan_id = option.order_plan_id;
-				this.creative_id = option.creative_id;
-				this.impress_id = option.impress_id;
-				this.sign = option.sign;
-			}
+			this.accountId = this.params.accountId;
+			this.type = this.params.type;
+			this.no = this.params.no;
 			if(this.id){
 				getTemplateById(this.id).then(e => {
 					this.data = e.data;
 					this.site = e.site;
 					this.type = e.site.type;
 					this.json = JSON.parse(e.data.json)
+          this.setData();
 				})
 			}else if(this.no){
 				getTemplateByNo(this.no).then(e => {
 					this.data = e.data;
 					this.json = JSON.parse(e.data.json)
+          this.setData();
 				})
 			}
 			// callback({vid: this.vid}).then(e => {
@@ -89,6 +75,26 @@
 			// })
 		},
 		methods: {
+      setData(){
+        // 百度
+        if(this.type == 0){
+          this.vid = this.params.bd_vid;
+        }
+        // 优酷
+        if(this.type == 1){
+          this.vid = this.params.bd_vid;
+          this.aid = this.params.aid;
+          this.click_id = this.params.click_id;
+          this.ip = this.params.ip;
+        }
+        // 爱奇艺
+        if(this.type == 2){
+          this.order_plan_id = this.params.order_plan_id;
+          this.creative_id = this.params.creative_id;
+          this.impress_id = this.params.impress_id;
+          this.sign = this.params.sign;
+        }
+      },
 			handleImageLoad(index, item){
 				if(item.classText.indexOf("footer") != -1){
 					const imgElement  = this.$refs["myImage" + index];
@@ -105,51 +111,61 @@
 				// 百度
 				if(this.type == 0){
 					let data = {
-						accountId: this.accountId, 
-						id: this.id, 
-						url: window.location.href, 
-						no: this.no, 
-						bdVid: this.vid, 
-						t: 67,
+						id: this.id,
+						url: window.location.href,
+						vid: this.vid,
+						clickType: 67,
 					};
-					callback(data).then(e => {
+					baiduClickCallback(data).then(e => {
 						window.location.href = workUrl + "?customer_channel=" + this.vid;
 					})
 				}
 				// 优酷
 				if(this.type == 1){
 					let data = {
-						accountId: this.accountId, 
-						deeplink_url: window.location.href, 
-						no: this.no, 
-						id: this.id, 
-						bd_vid: this.vid, 
-						aid: this.aid, 
-						click_id: this.click_id, 
+						id: this.id,
+						url: window.location.href,
+						vid: this.vid,
+						aid: this.aid,
+						clickId: this.click_id,
 						ip: this.ip,
 					};
 					youkuClickCallback(data).then(e => {
 						window.location.href = workUrl + "?customer_channel=" + this.vid;
 					})
 				}
-				// 优酷
+				// 爱奇艺
 				if(this.type == 2){
-					let data = {
-						accountId: this.accountId, 
-						url: window.location.href, 
-						no: this.no, 
-						id: this.id, 
-						order_plan_id: this.order_plan_id,
-						creative_id: this.creative_id,
-						impress_id: this.impress_id,
-						sign: this.sign,
-						clickType: "200"
-					};
-					iqiyiClickCallback(data).then(e => {
-						window.location.href = workUrl + "?customer_channel=" + this.impress_id;
-					})
+          if(this.id){
+            let data = {
+              url: window.location.href,
+              id: this.id,
+              planId: this.order_plan_id,
+              creativeId: this.creative_id,
+              vid: this.impress_id,
+              sign: this.sign,
+              clickType: "200"
+            };
+            iqiyiClickCallback(data).then(e => {
+              window.location.href = workUrl + "?customer_channel=" + this.impress_id;
+            })
+          }else{
+            let data = {
+              accountId: this.accountId,
+              url: window.location.href,
+              no: this.no,
+              planId: this.order_plan_id,
+              creativeId: this.creative_id,
+              vid: this.impress_id,
+              sign: this.sign,
+              clickType: "200"
+            };
+            iqiyiClickCallback(data).then(e => {
+              window.location.href = workUrl + "?customer_channel=" + this.impress_id;
+            })
+          }
 				}
-				
+
 			},
 			click(item){
 				if(!item.addWxFun){