|
- const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px';
- 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: {
- navigationBarHeight,
- 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) {
- if (e.currentTarget.dataset.id == undefined) {
- return
- }
- 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=316424281708658688&cuserId=316369316574887936&couponId=316424281708658688&coverImg=https://iformall-net.s3.cn-northwest-1.amazonaws.com.cn/456/90d50e2d-547c-43e1-a801-2f6e15f622d2.jpg&userName=轻泉漪溪&avatarUrl=https://wx.qlogo.cn/mmopen/vi_32/oibIKqnzXT21eZJdjKVKY91A36FqLbD3ibEFc2oxIC4iahLniccDQKVu1Tgp4kJupxRZjtEpW0ravJ9QW1HuncGVjA/132&couponOrderId=316424688259530752&updateDate=1564553135000',
- // })
- },
- onShareAppMessage: function (res) {
- if (res.from === 'button') {
- console.log(this.data.cardDetail)
- console.log(111)
- // 来自页面内转发按钮
- 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;
-
- if (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
- })
- },
- });
|