...
|
...
|
@@ -5,292 +5,14 @@ const a = getApp() |
|
|
Page({
|
|
|
data: {
|
|
|
imagesUrl: a.globalData.baseUrl,
|
|
|
swiperList: [],
|
|
|
detailsContent: [],
|
|
|
zanPersonList: [],
|
|
|
id: '',
|
|
|
other_id: '', // 分享用户ID
|
|
|
_num: 1,
|
|
|
txtContent: '暂无数据',
|
|
|
content: '',
|
|
|
changeZan: '点赞',
|
|
|
msg: '', // 提示消息
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
let that = this
|
|
|
console.log("点赞商品详情", options)
|
|
|
that.setData({
|
|
|
id: options.id
|
|
|
})
|
|
|
// 获得popup组件
|
|
|
this.popup = this.selectComponent("#popup");
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token) {
|
|
|
this.getDetailsContent()
|
|
|
} else {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '您尚未登录,请授权登录',
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/authorization/authorization'
|
|
|
})
|
|
|
} else {
|
|
|
console.log('点击取消回调')
|
|
|
this.setData({
|
|
|
msg: '请登录后操作'
|
|
|
})
|
|
|
this.popMaskTest()
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
// this.getZanPerson()
|
|
|
msg: '',
|
|
|
},
|
|
|
|
|
|
getDetailsContent() {
|
|
|
let that = this;
|
|
|
request({
|
|
|
url: 'api/shop/zanGoodDetail',
|
|
|
data: {
|
|
|
id: that.data.id,
|
|
|
}
|
|
|
})
|
|
|
.then(res => {
|
|
|
that.setData({
|
|
|
detailsContent: res.data.data,
|
|
|
content: that.text(res.data.data.content)
|
|
|
})
|
|
|
console.log("详情数组2", that.data.detailsContent);
|
|
|
})
|
|
|
},
|
|
|
getZanPerson() {
|
|
|
let that = this;
|
|
|
request({
|
|
|
url: 'api/shop/listClickGoods',
|
|
|
data: {
|
|
|
goods_id: that.data.goods_id,
|
|
|
}
|
|
|
})
|
|
|
.then(res => {
|
|
|
// console.log(that.data.goods_id);
|
|
|
that.setData({
|
|
|
zanPersonList: res.data.data
|
|
|
})
|
|
|
// console.log(that.data.zanPersonList);
|
|
|
})
|
|
|
},
|
|
|
onShareAppMessage(options) {
|
|
|
var that = this;
|
|
|
// 设置菜单中的转发按钮触发转发事件时的转发内容
|
|
|
var shareObj = {
|
|
|
title: "点赞产品", // 默认是小程序的名称(可以写slogan等)
|
|
|
path: '/pages/praise/praise?id=' + that.data.id, // 默认是当前页面,必须是以‘/’开头的完整路径
|
|
|
imageUrl: '', //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
|
|
|
success: function (res) {
|
|
|
// 转发成功之后的回调
|
|
|
// console.log(res);
|
|
|
if (res.errMsg == 'shareAppMessage:ok') {
|
|
|
request({
|
|
|
url: 'api/shop/zanGoodDetail',
|
|
|
data: {
|
|
|
id: that.data.id,
|
|
|
other_id: '',
|
|
|
}
|
|
|
})
|
|
|
.then(res => {
|
|
|
that.setData({
|
|
|
other_idList: res.data.data
|
|
|
})
|
|
|
console.log(that.data.zanPersonList);
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
fail: function () {
|
|
|
// 转发失败之后的回调
|
|
|
if (res.errMsg == 'shareAppMessage:fail cancel') {
|
|
|
// 用户取消转发
|
|
|
} else if (res.errMsg == 'shareAppMessage:fail') {
|
|
|
// 转发失败,其中 detail message 为详细失败信息
|
|
|
}
|
|
|
},
|
|
|
// complete: fucntion() {
|
|
|
// // 转发结束之后的回调(转发成不成功都会执行)
|
|
|
// }
|
|
|
};
|
|
|
|
|
|
// 返回shareObj
|
|
|
return shareObj;
|
|
|
},
|
|
|
changeTitle(e) {
|
|
|
this.setData({
|
|
|
_num: e.currentTarget.dataset.num
|
|
|
})
|
|
|
// this.popup.toggleDialog()
|
|
|
onLoad: function (options) {
|
|
|
|
|
|
},
|
|
|
// 立即购买
|
|
|
gotopay() {
|
|
|
// this.showModal();
|
|
|
request({
|
|
|
url: 'api/shop/zan',
|
|
|
data: {
|
|
|
id: that.data.id,
|
|
|
other_id: '',
|
|
|
}
|
|
|
})
|
|
|
.then(res => {
|
|
|
that.setData({
|
|
|
other_idList: res.data.data,
|
|
|
changeZan: '已点赞',
|
|
|
msg: res.data.msg
|
|
|
})
|
|
|
this.popSuccessTest()
|
|
|
console.log(that.data.zanPersonList);
|
|
|
})
|
|
|
},
|
|
|
// 加入购物车
|
|
|
addShopCart(e) {
|
|
|
console.log(e, "加入购物车");
|
|
|
id = e.currentTarget.dataset.id
|
|
|
},
|
|
|
// 弹窗
|
|
|
//显示对话框
|
|
|
showModal() {
|
|
|
// 显示遮罩层
|
|
|
var animation = wx.createAnimation({
|
|
|
duration: 200,
|
|
|
timingFunction: "linear",
|
|
|
delay: 0
|
|
|
})
|
|
|
this.animation = animation
|
|
|
animation.translateY(300).step()
|
|
|
this.setData({
|
|
|
animationData: animation.export(),
|
|
|
showModalStatus: true
|
|
|
})
|
|
|
setTimeout(function () {
|
|
|
animation.translateY(0).step()
|
|
|
this.setData({
|
|
|
animationData: animation.export()
|
|
|
})
|
|
|
}.bind(this), 100)
|
|
|
},
|
|
|
//隐藏对话框
|
|
|
hideModal() {
|
|
|
// 隐藏遮罩层
|
|
|
var animation = wx.createAnimation({
|
|
|
duration: 200,
|
|
|
timingFunction: "linear",
|
|
|
delay: 0
|
|
|
})
|
|
|
this.animation = animation
|
|
|
animation.translateY(300).step()
|
|
|
this.setData({
|
|
|
animationData: animation.export(),
|
|
|
})
|
|
|
setTimeout(function () {
|
|
|
animation.translateY(0).step()
|
|
|
this.setData({
|
|
|
animationData: animation.export(),
|
|
|
showModalStatus: false
|
|
|
})
|
|
|
}.bind(this), 100)
|
|
|
},
|
|
|
popConfirm() {
|
|
|
wx.showModal({
|
|
|
title: 'confirm的弹窗',
|
|
|
content: '确认要删除该项吗?',
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
console.log('点击确认回调')
|
|
|
} else {
|
|
|
console.log('点击取消回调')
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
text(details) {
|
|
|
|
|
|
var texts = ''; //待拼接的内容
|
|
|
|
|
|
while (details.indexOf('<img') != -1) { //寻找img 循环
|
|
|
|
|
|
texts += details.substring('0', details.indexOf('<img') + 4); //截取到<img前面的内容
|
|
|
|
|
|
details = details.substring(details.indexOf('<img') + 4); //<img 后面的内容
|
|
|
|
|
|
if (details.indexOf('style=') != -1 && details.indexOf('style=') < details.indexOf('>')) {
|
|
|
|
|
|
texts += details.substring(0, details.indexOf('style="') + 7) + "width:750rpx;height:auto;margin:0 auto;"; //从 <img 后面的内容 截取到style= 加上自己要加的内容
|
|
|
|
|
|
details = details.substring(details.indexOf('style="') + 7); //style后面的内容拼接
|
|
|
|
|
|
} else {
|
|
|
|
|
|
texts += ' style="width:100%;height:auto;margin:0 auto;" ';
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
while (details.indexOf('<td') != -1) { //寻找img 循环
|
|
|
|
|
|
texts += details.substring('0', details.indexOf('<td') + 4); //截取到<img前面的内容
|
|
|
|
|
|
details = details.substring(details.indexOf('<td') + 4); //<img 后面的内容
|
|
|
|
|
|
if (details.indexOf('style=') != -1 && details.indexOf('style=') < details.indexOf('>')) {
|
|
|
|
|
|
texts += details.substring(0, details.indexOf('style="') + 7) + "width:750rpx!important;height:auto;margin:0 auto;"; //从 <img 后面的内容 截取到style= 加上自己要加的内容
|
|
|
|
|
|
details = details.substring(details.indexOf('style="') + 7); //style后面的内容拼接
|
|
|
|
|
|
} else {
|
|
|
texts += ' style="width:750rpx;height:auto;margin:0 auto;" ';
|
|
|
}
|
|
|
}
|
|
|
texts += details; //最后拼接的内容
|
|
|
// console.log(texts)
|
|
|
return texts;
|
|
|
onShow: function () {
|
|
|
|
|
|
},
|
|
|
popSuccessTest() {
|
|
|
wx.showToast({
|
|
|
title: this.data.msg,
|
|
|
icon: '', //默认值是success,就算没有icon这个值,就算有其他值最终也显示success
|
|
|
duration: 2000, //停留时间
|
|
|
})
|
|
|
},
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
// onShareAppMessage: function () {
|
|
|
|
|
|
|
|
|
// // let url = encodeURIComponent('/packageNews/pages/news_detail/news_detail?news_id=' + this.data.news_id);
|
|
|
|
|
|
// return {
|
|
|
// title: "点赞商品详情",
|
|
|
// path: `api/shop/clickGoods?url=${url}`
|
|
|
// }
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|