123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- var app = getApp();
- var WxParse = require('../../wxParse/wxParse.js');
- Page({
- data: {
- hiddenmodal: true,
- getFlag : 0,
- couponFlag : 0,
- shareFlag : 1
- },
- onLoad:function(options){
- var that = this;
- var shareFlag = options.shareFlag;
- if (shareFlag != '' && shareFlag != null && shareFlag != undefined) {
- that.setData({
- shareFlag: shareFlag
- })
- }
- },
-
- getCoupon:function(e){
- var that = this;
- var host = getApp().globalData.servsers;
- var un_id = getApp().globalData.un_id;
-
- wx.login({
- success: function (res) {
- var code = res.code;
- wx.getUserInfo({
- withCredentials: true,
- success: function (res) {
- wx.request({
- url: host + "userapi/insertadd",
- data: {
- user_id: code,
- name: res.userInfo.nickName,
- icon: res.userInfo.avatarUrl,
- iv: res.iv,
- encryptedData: res.encryptedData,
- },
- method: 'GET',
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- that.setData({
- un_id: res.data.unionId
- })
- var un_id = res.data.unionId;
- console.log(un_id);
- if (un_id != undefined && un_id != '' && un_id != null) {
-
- wx.request({
- url: host + "mycouponapi/insertaddno3",
- data: {
- user_id: un_id,
- coupon_id: '7',
- batch_no: '3'
- },
- method: 'GET',
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data.result == 0) {
-
- that.setData({
- hiddenmodal: false,
- modalCont: '领取成功'
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true
- })
- }, 1000)
- } else if (res.data.result == 1) {
-
- that.setData({
- hiddenmodal: false,
- modalCont: '您已领取过此优惠劵'
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true
- })
- }, 1000)
- } else {
-
- that.setData({
- hiddenmodal: false,
- modalCont: '优惠劵已被抢空'
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true
- })
- wx.redirectTo({
- url: '/pages/girlsDay/girlsDay'
- })
- }, 1000)
- }
- }
- })
- }
-
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- })
- }
- })
- }
- })
- },
- onShareAppMessage: function (res) {
- var that = this;
- var host = getApp().globalData.servsers;
- if (res.from === 'button') {
-
- console.log(res.target)
- }
- return {
- title: '大良造-送您一张无门槛优惠劵!',
- path: '/pages/indepCoupon3/indepCoupon3?shareFlag=1',
- success: function (res) {
- that.setData({
- hiddenmodal: false,
- modalCont: '分享成功'
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true
- })
- wx.redirectTo({
- url: '/pages/girlsDay/girlsDay'
- })
- }, 1000)
- },
- fail: function (res) {
-
- }
- }
- },
-
- backIndex: function (e) {
- wx.switchTab({
- url: '/pages/index/index',
- })
- }
- })
- var that;
- var imageUtil = require('../../utils/util.js');
|