var config = require("../../config/config.js"); var app = getApp(); const Http = require("../../utils/HttpBasics"); const util = require("../../utils/util"); const imgurl = require("../../utils/imgurl"); Page({ data: { fenxiangUrl: imgurl.fenxiang.url, clockUrl: imgurl.clock.url, teljpgUrl: imgurl.teljpg.url, closedUrl: imgurl.closed.url, quesGouUrl: imgurl.ques_gou.url, headbgUrl: imgurl.headbg.url, quesBgUrl: imgurl.ques_bg.url, dingdanUrl: imgurl.dingdan.url, weixinTitle: imgurl.weixinTitle.url, home: imgurl.home.url, cardDetail: null, data: { title: null }, showPage: false, questions1: null, questions2: null, carList: [], couponChannelId: null, couponId: null, orderId: "", hour: null, minute: "", tempFilePaths: null, userInfo: {}, hasUserInfo: false, canIUse: wx.canIUse('button.open-type.getUserInfo'), id: null, result: [], end_time: null, checked: false, clock: "已经截止", questionnaire: {}, questionId: null, widthScreen: null, moveData: null, rotateData: null, alphaData: null, scaleData: null, skewData: null, matrixData: null, opacity: 0, queueData: null, zIndex: 11, display: "none", showbutton: false, hidden: "hidden", height: "", more: "点击查看更多", showMore: true, supportTransfer:1, showIndexReuturn:false }, phone: function(e) { let that = this; wx.makePhoneCall({ phoneNumber: e.target.dataset.merchantlinkphone }); }, /** * 跳转到门店列表的详情页面 */ gotoDetail(e) { wx.navigateTo({ url: `/pages/index/searchbar/detail/index?id=${e.currentTarget.dataset.id}` }) }, gotoIndex(){ wx.navigateTo({ url: '/pages/index/index', }) }, goToTranser(){ this.onShareAppMessage(); // wx.navigateTo({ // url: '/pages/index/index?couponChannelId=' + this.data.cardDetail.couponChannelId + '&cuserId=' + this.data.cardDetail.cuserId + '&couponId=' + this.data.cardDetail.couponId, // }) }, onShareAppMessage: function (res) { if (res.from === 'button') { console.log(res,3333333333333333333333) // 来自页面内转发按钮 let _this = this; return { title: _this.data.userName + '赠送您一张' + _this.data.cardDetail.title, path: '/pages/index/index?couponChannelId=' + this.data.cardDetail.couponChannelId + '&cuserId=' + this.data.cardDetail.ownerId + '&couponId=' + this.data.cardDetail.couponId + '&coverImg=' + this.data.cardDetail.coverImg + '&userName=' + this.data.userName + '&avatarUrl=' + this.data.avatarUrl + '&couponOrderId=' + this.data.cardDetail.id + '&updateDate=' + this.data.cardDetail.updateDate, imageUrl: this.data.cardDetail.coverImg, success: function (res) { // 转发成功 }, fail: function (res) { // 转发失败 } } }else{ console.log(res, 444444444444444444) } }, // 点击查看更多 more: function() { let that = this; if (that.data.more == '点击查看更多') { this.setData({ hidden: "", height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx', more: "点击收起", showMore: true }) } else { this.setData({ hidden: "hidden", height: 4* 140 + 'rpx', more: "点击查看更多", showMore: true }) } }, onLoad(options) { let that = this; console.log(options.cardId) that.cardpayList(options.cardId); that.cardDetail(options.cardId); if (options.from){ this.setData({ showIndexReuturn:true }) } wx.hideShareMenu() }, cardpayList: function(cardId) { let that = this; wx.showLoading({ title: "加载中..." }); var parmer = { url: config.api.cardpayList, data: { cardId: cardId, pageNum: 1, pageSize: 100 } }; Http.get(parmer) .then(res => { console.log(res); if (res.code == 200 && res.data.list.length > 0) { that.setData({ showPage: true }) } else {} wx.hideLoading(); res.data.list.map(file => { file.updateDate = util.formatTime(file.updateDate, "yyyy-MM-dd hh:mm:ss") }) that.setData({ data: res.data.list }); }).catch(err => { wx.showToast({ title: err.message, icon: 'none', duration: 2000, mask: false }); }) }, getUserInfo: function () { let that = this; // 获取用户信息 Http.get({ url: config.api.getScore, data: {} }) .then(res => { console.log(res) that.setData({ userName: res.data.nickName, avatarUrl: res.data.avatarUrl }) }) }, cardDetail: function(couponOrderId) { let that = this; Http.get({ url: config.api.cardDetail, data: { couponOrderId: couponOrderId } }) .then(res => { console.log(res) if (res.code == 200) { res.data.expiredTime = util.formatTime(res.data.expiredTime, "yyyy-MM-dd hh:mm:ss") that.setData({ showPage: true, cardDetail: res.data, supportTransfer: res.data.supportTransfer }) /** * 若可转赠获取用户头像信息 */ if (res.data.supportTransfer){ that.getUserInfo() } if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length<=4){ that.setData({ height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx', showMore:false }) } else if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length > 4){ that.setData({ height: 4 * 140 + 'rpx' }) } } }) .catch(err => { console.log(err) }) }, onShow() { let that = this; that.setData({ showbutton: false }) }, });