123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- var app = getApp();
- Page({
- data: {
- discStatus: '',
- couponId: '',
- storeId: '',
- storeTopicId: '',
- tickDiscount: {},
- isShare: '',
- referrer: 0,
- discId: ''
- },
- onLoad: function(options) {
- // 页面初始化 options为页面跳转所带来的参数
- // options.scene = "4&8&0";
- if (options.scene) {
- var scene = decodeURIComponent(options.scene);
- console.log("scene is ", scene);
- var scanArray = scene.split('&');
- var discId = scanArray[0];
- var storeId = scanArray[1];
- var isShare = scanArray[2];
- // console.log("discId is ", discId);
- // console.log("storeId is ", storeId);
- // console.log("isShare is ", isShare);
- this.setData({
- discId: discId,
- storeId: storeId,
- isShare: isShare
- });
- if (storeId) {
- wx.setStorageSync('storeId', storeId);
- }
- } else {
- if (options.couponId) {
- this.setData({
- couponId: options.couponId,
- storeId: options.storeId,
- isShare: options.isShare
- });
- }
- if (options.discId) {
- this.setData({
- discId: options.discId,
- storeId: options.storeId,
- isShare: options.isShare
- });
- }
- }
- console.log("discId is ", options.discId);
- console.log("storeId is ", options.storeId);
- console.log("isShare is ", options.isShare);
- this.getTickDiscountDetail();
- },
- onReady: function() {},
- onShow: function() {},
- onHide: function() {
- // 页面隐藏
- },
- onUnload: function() {
- // 页面关闭
- },
- getTickDiscountDetail() {
- var that = this;
- util.request(api.DiscountDetail, {
- couponId: that.data.couponId,
- storeId: that.data.storeId,
- discId: that.data.discId
- })
- .then(function(res) {
- if (res.errno === 0) {
- console.log(res.data);
- if (res.data) {
- that.setData({
- tickDiscount: res.data
- });
- }
- }
- });
- },
- linkCouponInfo(event) {
- // let url = event.currentTarget.dataset.couponUrl;
- let discId = event.currentTarget.dataset.discId;
- let storeId = wx.getStorageSync('storeId');
- let couponId = event.currentTarget.dataset.couponId;
- console.log('couponId' + couponId)
- console.log('discId' + discId)
- if (couponId) {
- console.log('couponId' + couponId)
- wx.navigateTo({
- url: '../couponTickInfo/couponTickInfo?couponId=' + couponId + '&&storeId=' + storeId
- })
- }
- if (discId) {
- console.log('discId' + discId)
- wx.navigateTo({
- url: '../couponTickInfo/couponTickInfo?discId=' + discId + '&&storeId=' + storeId
- })
- }
- },
- linkMyCoupon() {
- wx.navigateTo({
- url: '../coupon/coupon'
- })
- },
- /**
- * 领取优惠券
- */
- getUserCoupon(event) {
- var that = this;
- let tickDiscId = event.currentTarget.dataset.tickId;
- let storeTopicId = event.currentTarget.dataset.storeTopicId;
- let storeId = wx.getStorageSync('storeId');
- util.request(api.getUserCoupon, {
- tickDiscId: tickDiscId,
- storeTopicId: storeTopicId,
- storeId: storeId
- }, 'POST').then(function(res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '领取成功'
- });
- that.setData({
- discStatus: 0
- });
- that.getTickDiscountDetail();
- } else {
- wx.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- });
- },
- /**
- * 优惠券可使用商品
- */
- linkCoupon(event) {
- // let url = event.currentTarget.dataset.couponUrl;
- let tickDiscId = event.currentTarget.dataset.tickId;
- let storeTopicId = event.currentTarget.dataset.storeTopicId;
- let storeId = wx.getStorageSync('storeId');
- wx.navigateTo({
- url: '../ticketDiscountGoods/ticketDiscountGoods?tickDiscId=' + tickDiscId + '&&storeId=' + storeId + '&&storeTopicId=' + storeTopicId
- })
- },
- })
|