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.
 

456 lines
9.9 KiB

// pages/detail/detail.js
// const { config } = require('process')
const axios = require('../../api/index')
let loading = false
Page({
/**
* 页面的初始数据
*/
data: {
banner_img: [],
is_show_complain_modal: false,//投诉
is_show_modal: false,//打电扣钱
is_show_phone_lack_currency: false,//钱不够的时候提示
is_show_refresh_mask: false,//刷新
refresh_is_show_lack_currency:false,//刷新前不够
is_show_top_mask:false,//置顶
is_show_lack_currency:false,//置顶不够钱
id: 0,
detail: {
},
user_info_id:1,
userId:0,
zk:true,
is_show_share_mask:false,//
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var id = options.id
if(id){
this.setData({
id
})
}
const scene = decodeURIComponent(options.scene)
if(scene!='undefined'){
var arr= scene.split(',')
var shareType_e = 'newusers'
var userId_e = arr[1]
var id_e=arr[0]
wx.setStorageSync('shareType', shareType_e)
wx.setStorageSync('userId', userId_e);
this.setData({
id:id_e
})
}
let {
shareType,
userId,
} = options;
if (shareType!='undefined' && userId!='undefined') {
wx.setStorageSync('shareType', shareType)
wx.setStorageSync('userId', userId)
}
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.get_detail()
this.setData({
user_info_id: wx.getStorageSync('userInfo').id
})
},
// 分享
bindshare(){
console.log(11)
this.setData({
is_show_share_mask:true
})
},
hide_share_mask_fn(){
this.setData({
is_show_share_mask:false
})
},
bigimgs(e){
console.log(e.currentTarget.dataset.index)
console.log(this.data.detail.equipmentPictures[e.currentTarget.dataset.index].pictureLink)
// 图片点击放大
var arr=[]
var imagearr=[]
arr= this.data.detail.equipmentPictures
console.log(arr)
arr.forEach((item)=>{
imagearr.push(item.pictureLink)
})
wx.previewImage({
current: this.data.detail.equipmentPictures[e.currentTarget.dataset.index].pictureLink, // 当前显示图片的http链接
urls:imagearr// 需要预览的图片http链接列表
})
},
zkfun(){
this.setData({
zk:!this.data.zk
})
},
// 根据id获取详情
get_detail() {
axios.getEquipmentById(this.data.id).then(res => {
console.log(res)
this.setData({
userId: res.data.userId,
detail: res.data
})
}).catch(err => {
console.log(err)
})
},
// 点击收藏
collection() {
let token = wx.getStorageSync('token')
if (!token) {
wx.navigateTo({
url: '/pages/login/login',
})
return
}
if (this.data.detail.isCollection) {//取消收藏
axios.cancelCollection(this.data.detail.id).then(res => {
console.log(res)
wx.showToast({
title: res.msg || '',
icon: 'none',
duration: 1000
})
this.get_detail()
})
} else {//收藏
axios.addCollection(this.data.detail.id).then(res => {
console.log(res)
wx.showToast({
title: res.msg || '',
icon: 'none',
duration: 1000
})
this.get_detail()
})
}
},
// 点击投诉
complain_fn() {
// let {
// detail
// } = this.data;
// if (!detail.isGetPhone) {
// wx.showToast({
// title: '请获取完整的手机号码后再操作!',
// icon: 'none'
// });
// return
// }
this.setData({
is_show_complain_modal: true
})
},
// 打电话
show_phone_modal() {
let token = wx.getStorageSync('token')
if (!token) {
wx.navigateTo({
url: '/pages/login/login',
})
return
}
let { detail } = this.data
console.log(detail)
if (detail.isGetPhone) {//有电话
wx.makePhoneCall({
phoneNumber: detail.contactPhone
})
} else {//没电话
this.setData({
is_show_modal: true
})
}
},
//点击客服
service() {
let token = wx.getStorageSync('token')
if (!token) {
wx.navigateTo({
url: '/pages/login/login',
})
return
}
wx.makePhoneCall({
phoneNumber: '18680026251',
})
},
// 隐藏弹框
hide_modal() {
this.setData({
is_show_complain_modal: false,//投诉
is_show_modal: false,//打电扣钱
is_show_phone_lack_currency: false,//钱不够的时候提示
is_show_refresh_mask: false,//刷新
refresh_is_show_lack_currency:false,//刷新前不够
is_show_top_mask:false,//置顶
is_show_lack_currency:false,//置顶不够钱
})
},
// 打电话确定
confirm_fn() {
if (loading) return
loading = true
this.setData({
is_show_complain_modal: false,
is_show_modal: false,
is_show_phone_lack_currency: false
})
let { detail } = this.data
axios.getPhone(detail.id).then(res => {
loading = false
console.log(res)
if(res.code==1){
wx.makePhoneCall({
phoneNumber: res.data,
})
this.setData({
is_show_modal: false
})
this.get_detail()
}else{
this.setData({
is_show_modal: false,
is_show_phone_lack_currency: true
})
return
}
})
},
//积分不够的时候确定
earn_currency() {
this.setData({
is_show_lack_currency: false,
is_show_phone_lack_currency: false,
refresh_is_show_lack_currency: false
})
wx.navigateTo({
url: '/pages/my_obtain/my_obtain?is_come=1',
})
},
// 刷新
show_refresh_mask() {
this.setData({
is_show_refresh_mask: true
})
},
// 刷新
refresh_confirm_fn(e) {
this.setData({
is_show_refresh_mask: false,
}, () => {
this.refresh_job()
})
},
refresh_cancel_fn() {
this.setData({
is_show_refresh_mask: false,
})
},
// 刷新
refresh_job() {
if (loading) return
loading = true
let {
detail
} = this.data;
axios.refreshMyJobRec( detail.id).then(res => {
loading = false
if (res.code == 2) {
this.setData({
refresh_is_show_lack_currency: true
})
return
}
wx.showToast({
title: res.message || '刷新成功',
icon: 'none'
})
this.get_detail()
}).catch(err => {
loading = false
})
},
// 编辑
edit_job(){
wx.showModal({
title: '提示',
content: '编辑之后需要重新审核,是否编辑?',
cancelText: '再想想',
cancelColor: '#666666',
confirmColor: '#3476FE',
confirmText: '确定',
success: res => {
if (res.confirm) {
let url = '',
{
type,
detail
} = this.data;
url = `/pages/new_show/new_show?data=${escape(JSON.stringify(detail))}`
wx.navigateTo({
url,
})
}
}
})
},
// 置顶
// 置顶hide_share_mask_fn
show_top_mask_fn() {
let {
detail
} = this.data;
if (detail.isTop) {
wx.showToast({
title: '该信息已置顶,请勿重复置顶',
icon: 'none',
duration: 1000,
})
return
}
this.setData({
is_show_top_mask: true
})
},
top_confirm_fn(e) {
this.setData({
is_show_top_mask: false,
}, () => {
this.is_top()
})
},
top_cancel_fn() {
this.setData({
is_show_top_mask: false,
is_show_lack_currency: false,
refresh_is_show_lack_currency: false
})
},
// 置顶成功
is_top() {
let {
detail
} = this.data;
axios.upthrustTop(detail.id).then(res => {
// if (res.code == 2) {
// // wx.showToast({
// // title: res.msg,
// // icon: 'none'
// // })
// this.setData({
// is_show_lack_currency: true
// })
// return
// }
if (res.code == 2) {
// wx.showToast({
// title: res.msg,
// icon: 'none'
// })
this.setData({
is_show_lack_currency: true
})
return
}
wx.showToast({
title: res.msg || '置顶成功',
icon: 'none'
})
this.get_detail()
})
},
// 投诉确定
complain_confirm_fn() {
console.log('投诉确定')
wx.makePhoneCall({
phoneNumber: '18680026251',
})
this.setData({
is_show_complain_modal: false,
is_show_modal: false,
is_show_phone_lack_currency: false
})
},
//去卖家主页
go_seller_home() {
wx.navigateTo({
url: '/pages/seller_home/seller_home?id='+this.data.detail.userId,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function (e) {
let {
detail,
} = this.data;
let userInfo = wx.getStorageSync('userInfo');
// if(e.from=="button"){
return {
imageUrl:detail.equipmentPictures[0].pictureLink,
title: `${detail.title}`,
path: `/pages/detail/detail?id=${detail.id}&shareType=newusers&userId=${userInfo.id}`
}
// }else{
// let share_data = getApp().global_share()
// return share_data
// }
}
})