// pages/helpsell/helpsell.js const app = getApp(); const api = require('../../api/api'); Page({ /** * 页面的初始数据 */ data: { navbarData: { showCapsule: 1, capsuleMode: 'navBack', //显示模式(navBack:返回上一页;navHome:返回首页) }, head_id: 0, //团长id height: 0, //状态栏高度 user_info: {}, //团长个人信息 classify: [], //商品分类 info: {}, //详细信息 pintuan: [], //拼团列表 showphone: false, //显示打电话 phone: [], //电话 showfen: false, //显示分享 fenxiang: [{ name: '分享给朋友', openType: 'share' }, { name: '分享到朋友圈' }], enterType: 0, //进入类型(0:显示订阅按钮,不显示编辑按钮;1:不显示订阅按钮,显示编辑按钮) isSubscription: false, //是否已订阅团长 /* 组件参数 */ showPopup: false }, _navback() { wx.navigateBack() }, showfens() { this.setData({ showfen: true }) }, showphones() { this.setData({ showphone: true }) }, offzhe() { this.setData({ showfen: false, showphone: false }) }, phoneok(e) { wx.makePhoneCall({ phoneNumber: e.detail.name, }) }, gobianji() { wx.navigateTo({ url: '/pages/userinfo/userinfo', }) }, fenok(e) { if (e.detail.name === '分享给朋友') { console.log('分享朋友'); } else { wx.navigateTo({ url: '/pages/sharetofirend/sharetofirend?type=0&id=' + this.data.head_id, }) } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let that = this; that.setData({ height: app.globalData.height, enterType: Number(options.type), head_id: Number(options.id) }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { let that = this; // 获取团长详情 wx.showLoading({ title: '加载中', mask: true }) wx.request({ url: api.Head_info, header: { 'Authorization': wx.getStorageSync('token') }, data: { id: that.data.head_id, }, success(res) { console.log(res); if (res.data.code === 1) { that.setData({ user_info: res.data.data.user_info, classify: res.data.data.classification_info, info: res.data.data.info, pintuan: res.data.data.gang_list, isSubscription: res.data.data.subscribe === 1 ? true : false, phone: [{ name: res.data.data.user_info.phone }] }) } else { wx.showToast({ title: res.data.msg, mask: true, icon: 'none' }) } }, fail(err) { wx.showToast({ title: '发起网络请求失败', icon: 'none', mask: true }) }, complete() { wx.hideLoading() } }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { let head_id = this.data.user_info.id; //团长 return { title: '团长分享', path: '/pages/myhomepage/myhomepage?type=0&id=' + head_id, imageUrl: this.data.user_info.headimg } }, // 跳转团长微信二维码 navToWXQrcode() { let headimg = this.data.user_info.headimg; let name = this.data.user_info.name; let wechat_code = this.data.user_info.wechat_code; wx.navigateTo({ url: '/pages/wxqrcode/wxqrcode?headimg=' + headimg + '&name=' + name + '&wechat_code=' + wechat_code }) }, // 页面跳转 navgo(e) { let url = e.currentTarget.dataset.url; wx.navigateTo({ url: url }) }, // 订阅 subscription() { let that = this; if (that.data.isSubscription) { that.setData({ showPopup: true }) } else { wx.showLoading({ title: '加载中', mask: true }) wx.request({ url: api.subscribe, header: { 'Authorization': wx.getStorageSync('token') }, method: 'POST', data: { id: that.data.head_id }, success(res) { console.log(res); if (res.data.code === 1) { that.setData({ isSubscription: true, showPopup: false }) wx.showToast({ title: res.data.msg, icon: 'success', mask: true }) } else { wx.showToast({ title: res.data.msg, mask: true, icon: 'none' }) } }, fail(err) { wx.showToast({ title: '发起网络请求失败', icon: 'none', mask: true }) }, complete() { wx.hideLoading() } }) } }, // 关闭弹出层 closePopup() { this.setData({ showPopup: false }) }, // 确认弹出层 confirmPopup() { let that = this; wx.showLoading({ title: '加载中', mask: true }) wx.request({ url: api.unsubscribe, header: { 'Authorization': wx.getStorageSync('token') }, method: 'POST', data: { id: that.data.head_id }, success(res) { console.log(res); if (res.data.code === 1) { that.setData({ isSubscription: false, showPopup: false }) wx.showToast({ title: res.data.msg, icon: 'success', mask: true }) } else { wx.showToast({ title: res.data.msg, mask: true, icon: 'none' }) } }, fail(err) { wx.showToast({ title: '发起网络请求失败', icon: 'none', mask: true }) }, complete() { wx.hideLoading() } }) }, // 拼团跳转 navToPinTuanDetail(e) { let id = e.currentTarget.dataset.id; wx.navigateTo({ url: '/pages/pintuandetail/pintuandetail?type=dingyue&id=' + id, }) }, })