111 lines
2.2 KiB
JavaScript
111 lines
2.2 KiB
JavaScript
// packageE/others/case_library/mycomponents/share.js
|
||
const app = getApp();
|
||
|
||
Component({
|
||
/**
|
||
* 组件的属性列表
|
||
*/
|
||
properties: {
|
||
title: {
|
||
type: null
|
||
},
|
||
desc: {
|
||
type: null
|
||
},
|
||
img: {
|
||
type: null
|
||
},
|
||
kid: {
|
||
type: null
|
||
},
|
||
type: {
|
||
type: null
|
||
}
|
||
},
|
||
lifetimes: {
|
||
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
||
attached() {
|
||
console.log(this.data);
|
||
},
|
||
moved() {},
|
||
detached() {},
|
||
},
|
||
observers:{
|
||
'kid': function(kid) {
|
||
// 在 numberA 或者 numberB 被设置时,执行这个函数
|
||
console.log(kid,'11112');
|
||
this.setData({
|
||
id:kid
|
||
});
|
||
}
|
||
},
|
||
/**
|
||
* 组件的初始数据
|
||
*/
|
||
data: {
|
||
share_show: false,
|
||
link: '',
|
||
posterShow: false,
|
||
img_url: '',
|
||
id:''
|
||
},
|
||
|
||
/**
|
||
* 组件的方法列表
|
||
*/
|
||
methods: {
|
||
tapPosterShow(){
|
||
this.setData({
|
||
posterShow:false
|
||
});
|
||
},
|
||
openShare(){
|
||
this.setData({
|
||
share_show:true
|
||
});
|
||
},
|
||
closeShare(e){
|
||
this.setData({
|
||
share_show:false
|
||
});
|
||
},
|
||
// 生成海报
|
||
creatPoster() {
|
||
let that = this;
|
||
that.share_show = false;
|
||
let urlStr = '';
|
||
let json = { id: that.properties.id };
|
||
console.log(that.data.type);
|
||
if (that.data.type == 'case') {
|
||
urlStr = app.getNetAddresss('plugin.case-library.api.release.get-case-poster');
|
||
} else if (that.data.type == 'subject') {
|
||
urlStr = app.getNetAddresss('plugin.case-library.api.release.get-special-poster');
|
||
}
|
||
console.log(urlStr);
|
||
app._postNetWork({
|
||
url: urlStr,
|
||
data:json,
|
||
success: function (resdata) {
|
||
var res = resdata.data;
|
||
if (res.result == 1) {
|
||
that.setData({
|
||
posterShow:true,
|
||
img_url:res.data.url,
|
||
share_show:false
|
||
});
|
||
} else {
|
||
wx.showToast({
|
||
title: res.msg,
|
||
icon: "none",
|
||
duration: 1000,
|
||
});
|
||
}
|
||
},
|
||
fail: function (res) {
|
||
console.log(res);
|
||
}
|
||
});
|
||
},
|
||
}
|
||
});
|