|
@@ -7,23 +7,23 @@ Component({
|
|
|
* 组件的属性列表
|
|
|
*/
|
|
|
properties: {
|
|
|
- showDialog:{
|
|
|
- type:Boolean,
|
|
|
- value:false,
|
|
|
- observer:function(newVal,oldVal){
|
|
|
+ showDialog: {
|
|
|
+ type: Boolean,
|
|
|
+ value: false,
|
|
|
+ observer: function (newVal, oldVal) {
|
|
|
console.log(newVal);
|
|
|
const _self = this;
|
|
|
const parmas = this.properties;
|
|
|
- if(newVal == true) {
|
|
|
- _self.getDataTimer = setInterval(function(){
|
|
|
+ if (newVal == true) {
|
|
|
+ _self.getDataTimer = setInterval(function () {
|
|
|
let goods_id = parmas.goods_id
|
|
|
- if(goods_id > 0) {
|
|
|
+ if (goods_id > 0) {
|
|
|
_self.requestData(goods_id);
|
|
|
}
|
|
|
- },5000)
|
|
|
+ }, 5000)
|
|
|
}
|
|
|
else {
|
|
|
- if(_self.getDataTimer) {
|
|
|
+ if (_self.getDataTimer) {
|
|
|
clearInterval(this.getDataTimer)
|
|
|
}
|
|
|
}
|
|
@@ -34,14 +34,14 @@ Component({
|
|
|
observer() {
|
|
|
console.log('observer goods_id = ', this.properties.goods_id)
|
|
|
let goods_id = this.properties.goods_id
|
|
|
- if(goods_id > 0) {
|
|
|
+ if (goods_id > 0) {
|
|
|
this.requestData(goods_id);
|
|
|
- this.setData({shareModel: app.cardShareInfo()})
|
|
|
+ this.setData({ shareModel: app.cardShareInfo() })
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -49,22 +49,25 @@ Component({
|
|
|
* 组件的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- current_goodsid:0,
|
|
|
+ current_goodsid: 0,
|
|
|
fGoodsRequesting: false,
|
|
|
- tip:'',
|
|
|
- invitess:[],
|
|
|
- policy:[],
|
|
|
- tip_title:'',
|
|
|
- tip_num:0,
|
|
|
- shareModel:{}
|
|
|
+ tip: '',
|
|
|
+ invitess: [],
|
|
|
+ policy: [],
|
|
|
+ tip_title: '',
|
|
|
+ tip_num: 0,
|
|
|
+ shareModel: {},
|
|
|
+ mini_code:'',
|
|
|
+ share_code:'',
|
|
|
+ showRCode:false
|
|
|
},
|
|
|
|
|
|
pageLifetimes: {
|
|
|
// 组件所在页面的生命周期函数
|
|
|
show: function () {
|
|
|
console.log('pageLifetimes show goods_id = ', this.properties.goods_id)
|
|
|
- },
|
|
|
- hide: function () {
|
|
|
+ },
|
|
|
+ hide: function () {
|
|
|
console.log('pageLifetimes hide goods_id = ', this.properties.goods_id)
|
|
|
},
|
|
|
resize: function () { },
|
|
@@ -104,13 +107,49 @@ Component({
|
|
|
console.log('onCloseDialog');
|
|
|
this.triggerEvent('closeDialog', {})
|
|
|
},
|
|
|
- onShareInfo(){
|
|
|
+ onShareInfo() {
|
|
|
console.log('onShareInfo');
|
|
|
this.triggerEvent('onShareInfo', {})
|
|
|
},
|
|
|
- requestData(goods_id)
|
|
|
- {
|
|
|
- console.log('requestData goods_id=',goods_id)
|
|
|
+ onShareFriends() {
|
|
|
+ console.log('onShareFriends');
|
|
|
+ let self = this;
|
|
|
+ app.writePhotosAlbum(function () {
|
|
|
+ console.log('starting image ...');
|
|
|
+ var imgSrc = self.data.share_code
|
|
|
+ if (imgSrc == '') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ wx.showLoading();
|
|
|
+ wx.downloadFile({
|
|
|
+ url: imgSrc,
|
|
|
+ success: function (res) {
|
|
|
+ console.log(res);
|
|
|
+ wx.saveImageToPhotosAlbum({
|
|
|
+ filePath: res.tempFilePath,
|
|
|
+ success: function (data) {
|
|
|
+ wx.hideLoading();
|
|
|
+ wx.showModal({
|
|
|
+ title: '分享到朋友圈图片已经保存到相册',
|
|
|
+ confirmText: "知道了",
|
|
|
+ showCancel: false,
|
|
|
+ success: function (res) {
|
|
|
+ console.log();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: function (err) {
|
|
|
+ wx.hideLoading();
|
|
|
+ console.log(err);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ requestData(goods_id) {
|
|
|
+ console.log('requestData goods_id=', goods_id)
|
|
|
if (this.fGoodsRequesting) return;
|
|
|
|
|
|
this.fGoodsRequesting = true
|
|
@@ -123,14 +162,24 @@ Component({
|
|
|
if (res.code == 200) {
|
|
|
if (res.datas) {
|
|
|
let invitess = res.datas.invitess
|
|
|
- let policy = res.datas.policy
|
|
|
+ let policy = res.datas.policy
|
|
|
let tip_title = res.datas.tip_title
|
|
|
let tip_num = res.datas.tip_num
|
|
|
- this.setData({ tip_title,tip_num,invitess, policy })
|
|
|
+ let mini_code = res.datas.mini_code;
|
|
|
+ let share_code = res.datas.share_code;
|
|
|
+
|
|
|
+ this.setData({ tip_title, tip_num, invitess, policy, mini_code, share_code})
|
|
|
}
|
|
|
}
|
|
|
- this.fGoodsRequesting = false
|
|
|
+ this.fGoodsRequesting = false;
|
|
|
})
|
|
|
+ },
|
|
|
+ onShareFace() {
|
|
|
+ this.setData({ showRCode: true })
|
|
|
+ },
|
|
|
+ onCloseMiniDialog() {
|
|
|
+ console.log('share dialog,onCloseMiniDialog')
|
|
|
+ this.setData({ showRCode: false })
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
})
|