diff --git a/high-unionPay/Utils/Api.js b/high-unionPay/Utils/Api.js index 86d19ec..e170ace 100644 --- a/high-unionPay/Utils/Api.js +++ b/high-unionPay/Utils/Api.js @@ -162,6 +162,10 @@ export const againReceiveCoupon = params => { //查询我的优惠券 export const getUserDiscountList = params => { return POST('GET', `${base}/userDiscount/getUserDiscountList`, params).then(res => res.data); +} +//使用优惠券 +export const useDiscount = params => { + return POST('GET', `${base}/discount/useDiscount`, params).then(res => res.data); } //我的优惠券查详情 export const getDiscountByUserDiscountId = params => { diff --git a/high-unionPay/pages/goods/externalCoupon/externalCoupon.vue b/high-unionPay/pages/goods/externalCoupon/externalCoupon.vue index 543ad38..e23bcf3 100644 --- a/high-unionPay/pages/goods/externalCoupon/externalCoupon.vue +++ b/high-unionPay/pages/goods/externalCoupon/externalCoupon.vue @@ -14,13 +14,38 @@ - - - 去使用 - + + + + + + 立即使用 + + + + 立即查看 + + + + + + + + 去使用 + - + @@ -35,13 +60,11 @@ - + {{ product.highCoupon.discountPrice*100}} - + {{ product.highCoupon.salesPrice*100}} @@ -62,7 +85,8 @@ receiveDiscount, HandleCode, getUserInfo, - loginByPhone + loginByPhone, + useDiscount } from '../../../Utils/Api.js'; // import authorize from '../../../components/Authorize'; let app = getApp(); @@ -75,7 +99,10 @@ minecoupones: [], imageUrl: app.globalData.imgUrl, imagewxUrl: app.globalData.imageWxImg, - imgadres:'noorder.png', + imgadres: 'noorder.png', + imgadres1: 'noCoupon.jpg', + imgadres2: 'onCoupon.jpg', + imgadres3: 'showCoupon.jpg', pageNum: 1, pageSize: 10, isNoMoreData: false, @@ -109,7 +136,7 @@ } else { this.userInfo = 1; } - + uni.login({ provider: 'weixin', success: function(loginRes) { @@ -169,10 +196,11 @@ if (res.return_code == '000000') { uni.showToast({ icon: 'none', - title: res.return_data, + title: '操作成功', duration: 2000 }) - }else{ + this.getDiscountByQrCode(); + } else { uni.showToast({ icon: 'none', title: res.return_msg, @@ -186,71 +214,71 @@ getuserinfo() { let that = this; // wx.login({ - // success(res) { - // if (res.code) { - // 发起网络请求 - // var code = res.code; - // 获取微信用户信息 - uni.getUserProfile({ - desc: '登录中...', - success: function(res) { - let params = { - openId: app.globalData.openId, - iv: res.iv, - encryptedData: res.encryptedData - } - getUserInfo(params).then(res => { - if (res.return_code == '000000') { - uni.hideLoading(); - app.globalData.userInfo = res - .return_data - .object - .highUser; - app.globalData.token = res - .return_data.uniqueCode; - uni.setStorage({ - key: "user", - data: res.return_data - .object - .highUser - }) - uni.setStorage({ - key: "token", - data: res.return_data - .uniqueCode - }) - that.receiveDiscount(); - that.userInfo = 2; - } else { - uni.hideLoading(); - uni.showToast({ - title: res.return_msg, - icon: 'none', - duration: 2000 - }) - } - }); - }, - fail: res => { - uni.showToast({ - title: "微信登录授权失败", - icon: "none" - }); - } - }) - // } else { - // uni.showToast({ - // title: "微信登录授权失败", - // icon: "none" - // }); - // } - // } + // success(res) { + // if (res.code) { + // 发起网络请求 + // var code = res.code; + // 获取微信用户信息 + uni.getUserProfile({ + desc: '登录中...', + success: function(res) { + let params = { + openId: app.globalData.openId, + iv: res.iv, + encryptedData: res.encryptedData + } + getUserInfo(params).then(res => { + if (res.return_code == '000000') { + uni.hideLoading(); + app.globalData.userInfo = res + .return_data + .object + .highUser; + app.globalData.token = res + .return_data.uniqueCode; + uni.setStorage({ + key: "user", + data: res.return_data + .object + .highUser + }) + uni.setStorage({ + key: "token", + data: res.return_data + .uniqueCode + }) + that.receiveDiscount(); + that.userInfo = 2; + } else { + uni.hideLoading(); + uni.showToast({ + title: res.return_msg, + icon: 'none', + duration: 2000 + }) + } + }); + }, + fail: res => { + uni.showToast({ + title: "微信登录授权失败", + icon: "none" + }); + } + }) + // } else { + // uni.showToast({ + // title: "微信登录授权失败", + // icon: "none" + // }); + // } + // } // }) }, // 微信获取手机号 loginByPhone(PhoneNumber) { - if(PhoneNumber.detail.iv == undefined){ + if (PhoneNumber.detail.iv == undefined) { uni.showToast({ title: "用户取消授权", icon: "none" @@ -289,17 +317,38 @@ } }); }, + //使用优惠券 + useDiscount() { + let datas = { + discountAgentCodeId: this.couponsDetails.highDiscountAgentCode.id + } + useDiscount(datas).then(res => { + if (res.return_code == '000000') { + uni.showModal({ + title: '温馨提示', + content: '请前往中石油“中油好客E站”小程序使用,须在有效期30天内使用。(中油好客E站APP也可使用)', + success: function(res) {} + }) + } else { + uni.showToast({ + title: res.return_msg, + duration: 2000, + icon: 'none' + }) + } + }) + }, //跳转登录 jumpres() { uni.navigateTo({ - url:'../../login/register?id=2' + url: '../../login/register?id=2' }) }, //商品跳转 toGoods(e) { if (app.globalData.userInfo) { uni.navigateTo({ - url: '../../order/confirmation?id=' + e +'&typeid=2' + url: '../../order/confirmation?id=' + e + '&typeid=2' }) } else { uni.showToast({ @@ -308,6 +357,12 @@ duration: 2000 }) } + }, + //跳转列表 + jumpCounlist() { + uni.reLaunch({ + url: '/pages/user/coupon/coupon' + }) } } @@ -323,7 +378,13 @@ width: 80px; height: 80px; } - + .btnno { + height: 40px; + line-height: 40PX; + display: flex; + justify-content: center; + color: #ffffff; + } .product-list { display: flex; justify-content: space-between; diff --git a/high-unionPay/pages/user/coupon/coupon.vue b/high-unionPay/pages/user/coupon/coupon.vue index 7595d9c..37ba110 100644 --- a/high-unionPay/pages/user/coupon/coupon.vue +++ b/high-unionPay/pages/user/coupon/coupon.vue @@ -104,7 +104,8 @@