You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
2.8 KiB

// pages/quest/subpage/detail/components/link/link.js
import {
http
} from '../../../../../../utils/util'
Component({
/**
* 组件的属性列表
*/
properties: {
data: {
type: Object,
value: {}
},
linkre: {
type: Array,
value: {}
}
},
/**
* 组件的初始数据
*/
data: {
platforms: [{
id: 1,
name: '抖音'
}, {
id: 2,
name: '快手'
},
// {
// id: 3,
// name: '朋友圈'
// }, {
// id: 4,
// name: '视频号'
// }
],
platform: null,
platformdia: false,
link: '',
cdn: getApp().globalData.cdn,
link_type: false,
image: null
},
/**
* 组件的方法列表
*/
methods: {
plachoose(e) {
this.setData({
platformdia: true
})
},
plachoose2(e) {
console.log(e.currentTarget.dataset.mes)
if (e.currentTarget.dataset.mes.id === 3) {
this.setData({
link_type: true
})
} else {
this.setData({
link_type: false
})
}
this.setData({
platform: e.currentTarget.dataset.mes,
platformdia: false
})
},
linkin(e) {
// console.log(e.detail.value)
this.setData({
link: e.detail.value
})
},
up(e) {
if (!this.data.platform) {
wx.showToast({
title: '请选择平台',
icon: 'none',
duration: 2000
})
} else if (!this.data.link) {
wx.showToast({
title: '请输入链接',
icon: 'none',
duration: 2000
})
} else {
http("/video/userAdd", "post", {
id: this.data.data.id,
type: this.data.platform.id,
url: this.data.link
}).then(res => {
wx.showToast({
title: res.data,
icon: 'none',
duration: 2000
}).then(res => {
this.triggerEvent('getdata', '')
this.setData({
link_type: false,
platform: null,
link: ''
})
})
})
}
},
chooseImage() {
let that = this
wx.chooseImage({
success(res) {
const tempFilePaths = res.tempFilePaths
// console.log(res)
wx.uploadFile({
url: that.data.host + '/util/upload',
filePath: tempFilePaths[0],
name: 'file',
formData: {
'test': 'test'
},
success(res) {
console.log(JSON.parse(res.data).data.fileUrl)
that.setData({
image: JSON.parse(res.data).data.fileUrl
})
//do something
}
})
}
})
}
}
})