let tempForm = document.createElement('form')
tempForm.action = 'http://hzpt-test.ykyao.com/task/third/thirdInfo.php'
tempForm.method = 'post'
tempForm.style.display = 'none'
for (var x in this.params) {
var opt = document.createElement('input')
if(x==this.params.jump_flag)
{
opt.name = x
opt.value = item.url
}else{
opt.name = x
opt.value = this.params[x]
}
tempForm.appendChild(opt)
}
document.body.appendChild(tempForm)
tempForm.submit()
组件中使用
<template>
<div class="list">
<ul>
<li v-for="(item, index) of dataShow" :key="index">
<a @click="handleClickTo(item)"><img :src="item.img"/>
<p class="title">{{item.title}}</p>
<div class="Slash">某宝价格:<span>{{item.originalPrice}}</span></div>
<p>普康特惠价:<span>{{item.price}}</span></p>
</a>
</li>
</ul>
<div style="clear:both"></div>
</div>
</template>
<script>
export default {
name:'columns',
props:['dataShow','listNum','cardCode'],
data(){
return{
params: {
cooperation_id:'pukang',
cust_group:'A',
cust_id:8888,
cust_mobile:18012345678,
send_time:'',
cooperation_pwd:'pukang2020',
sign:'',
error_url:'',
jump_flag:''
}
}
},
methods: {
mds(){
return this.sign=md5(this.cooperation_id+this.cust_group+this.cust_id+this.cust_mobile+this.send_time+this.cooperation_pwd)
},
getNowFormatDate() {
var date = new Date();
var seperator1 = "-"
var seperator2 = ":"
var month = date.getMonth() + 1<10? "0"+(date.getMonth() + 1):date.getMonth() + 1
var strDate = date.getDate()<10? "0" + date.getDate():date.getDate();
return this.send_time = date.getFullYear() + seperator1 + month + seperator1 + strDate
+ " " + date.getHours() + seperator2 + date.getMinutes()
+ seperator2 + date.getSeconds()
},
handleClickTo(item) {
this.getNowFormatDate(),
this.mds(),
console.log(this.sign)
console.log(this.send_time)
if(item.goodId.indexOf('yk')>=0)
{ //post请求以form形式提交
let tempForm = document.createElement('form')
tempForm.action = 'http://hzpt-test.ykyao.com/task/third/thirdInfo.php'
tempForm.method = 'post'
tempForm.style.display = 'none'
for (var x in this.params) {
var opt = document.createElement('input')
if(x==this.params.jump_flag)
{
opt.name = x
opt.value = item.url
}else{
opt.name = x
opt.value = this.params[x]
}
tempForm.appendChild(opt)
}
document.body.appendChild(tempForm)
tempForm.submit()
}
else {
this.$http('/commProduct/getSpliceThirdpartyLink',
{
cardCode: this.cardCode || '4000000000003246',
type: item.type,
url: item.url,
name:item.goodId,
}).then(res=>{
// console.log(res.data)
if(!this.cardCode){
this.$toast('卡号缺失')
return
}
if (res.data.errorCode === 0 && res.data.linkProductUrl)
{
window.location.href = res.data.linkProductUrl
console.log(res.data.linkProductUrl)
}
else
{
this.$toast.fail(res.data.errorMessage)
}
}).catch(err => console.log(err))
}
// }
}
}
</script>