You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
376 lines
10 KiB
376 lines
10 KiB
<template>
|
|
<view id="off-detail" v-if="init">
|
|
<!-- <view class="top">
|
|
<view>线下优惠专享券</view>
|
|
<view>{{detail.discount.starts_at}} 至 {{detail.discount.ends_at}}</view>
|
|
</view>
|
|
<view class="middle">
|
|
<image src="{{barcode.base64}}" />
|
|
<view>{{detail.code}}</view>
|
|
</view>
|
|
<view class="tips">
|
|
<view>使用规则:</view>
|
|
<view>{{detail.discount.intro}}</view>
|
|
</view>-->
|
|
<view class="coupon">
|
|
<view class="coupon-left" :class="is_coupon != 1 ? 'discount' : ''" :style="'background: ' + config.mainColor">
|
|
<view class="text-wrap">
|
|
<view class="text-box">
|
|
<view class="text">
|
|
<text class="money" v-if="detail.action_type.type == 'cash'">¥</text>
|
|
<sapn>{{ detail.action_type.value }}</sapn>
|
|
|
|
<text class="money" v-if="detail.action_type.type == 'discount'">折</text>
|
|
</view>
|
|
<text class="label text">{{ detail.label }}</text>
|
|
</view>
|
|
</view>
|
|
<view class="dot-wrap">
|
|
<view class="dot-item">
|
|
|
|
</view>
|
|
<view class="dot-item">
|
|
|
|
</view>
|
|
<view class="dot-item">
|
|
|
|
</view>
|
|
<view class="dot-item">
|
|
|
|
</view>
|
|
<view class="dot-item">
|
|
|
|
</view>
|
|
<view class="dot-item">
|
|
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="coupon-right">
|
|
<view class="top">
|
|
<span class="type">
|
|
<span v-if="detail.channel == 'ec'">商城</span>
|
|
<span v-else>门店</span>
|
|
</span>
|
|
<text class="info">{{detail.title}}</text>
|
|
</view>
|
|
<view class="bottom">
|
|
<view class="bottom-use">
|
|
<view class="tiem-box">
|
|
<text>{{detail.use_start_time}}至{{detail.use_end_time}}</text>
|
|
</view>
|
|
<view v-if="is_coupon == 1">
|
|
<view class="btn use" :style="'background: ' + config.mainColor" v-if="!detail.has_get" @tap.stop="getCoupon">
|
|
点击领取
|
|
</view>
|
|
<!--<view class="btn already" wx:else @tap.stop="jumpList">
|
|
去使用
|
|
</view>-->
|
|
</view>
|
|
|
|
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!--<view class="detail-item">
|
|
<view class="title">
|
|
可用门店
|
|
</view>
|
|
<view class="shop-info mx-1px-top">
|
|
<view><i class="iconfont icon--weizhi"></i>米尔长沙高桥店</view>
|
|
<view><i class="iconfont icon--dianpu"></i> 长沙高桥服饰城二楼北四区27号</view>
|
|
<view><i class="iconfont icon--dianhua"></i> 0731-8402245</view>
|
|
</view>
|
|
<view class="shop-info mx-1px-top">
|
|
<view><i class="iconfont icon--weizhi"></i>米尔长沙高桥店</view>
|
|
<view><i class="iconfont icon--dianpu"></i> 长沙高桥服饰城二楼北四区27号</view>
|
|
<view><i class="iconfont icon--dianhua"></i> 0731-8402245</view>
|
|
</view>
|
|
</view>-->
|
|
<view class="detail-item user-info" v-if="detail.intro">
|
|
<view class="title">
|
|
使用说明
|
|
</view>
|
|
<view class="info mx-1px-top">
|
|
{{detail.intro}}
|
|
</view>
|
|
</view>
|
|
<view class="qr_code" v-if="detail.qr_code_img">
|
|
<image :src="detail.qr_code_img"></image>
|
|
</view>
|
|
<view class="home" @tap="jumpHome" :style="'background: ' + config.mainColor">
|
|
<i class="iconfont icon--shouye"></i>
|
|
<view>
|
|
首页
|
|
</view>
|
|
</view>
|
|
<view class="button-box" v-if="is_coupon == 1 && !detail.has_get">
|
|
<view class="btn" :style="'background: ' + config.mainColor" v-if="!detail.has_get" @tap.stop="getCoupon">
|
|
点击领取
|
|
</view>
|
|
<!--<view class="btn" wx:else @tap.stop="jumpList">
|
|
去使用
|
|
</view>-->
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
</template>
|
|
<script>
|
|
import {pageLogin, getUrl,config} from '@/common/js/utils.js';
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
detail: '',
|
|
barcode: '',
|
|
is_coupon: 1,
|
|
// 用于判断是否为优惠券 1:优惠券 0:促销折扣
|
|
init: false,
|
|
agent_code: '',
|
|
config: ''
|
|
|
|
};
|
|
},
|
|
|
|
onShow() {
|
|
/* let app =getApp();
|
|
app.isBirthday().then(()=>{
|
|
if(this.$cookieStorage.get("birthday_gift")){
|
|
var giftData=this.$cookieStorage.get("birthday_gift").data;
|
|
new app.ToastPannel().__page.showText(giftData);
|
|
}
|
|
});*/
|
|
},
|
|
|
|
onLoad(e) {
|
|
// 第三方平台配置颜色
|
|
var gbConfig = this.$cookieStorage.get('globalConfig') || '';
|
|
this.setData({
|
|
config: gbConfig
|
|
});
|
|
var id = e.id;
|
|
var coupon_id = e.coupon_id;
|
|
var agent_code = e.agent_code || '';
|
|
var is_coupon = e.is_coupon || '';
|
|
const timeMap = {
|
|
y: 31536000000,
|
|
m: 2592000000,
|
|
d: 86400000,
|
|
h: 3600000,
|
|
n: 60000,
|
|
s: 1000
|
|
}; // 默认有效期为7天
|
|
|
|
var valid_time = "";
|
|
|
|
if (e.scene) {
|
|
var scene = decodeURIComponent(e.scene);
|
|
var sceneArr = scene.split('_');
|
|
|
|
if (sceneArr.length > 0) {
|
|
id = sceneArr[0];
|
|
agent_code = sceneArr[1];
|
|
is_coupon = 1;
|
|
}
|
|
}
|
|
|
|
if (!this.$cookieStorage.get('distribution_valid_time')) {
|
|
valid_time = 10080;
|
|
} else {
|
|
valid_time = this.$cookieStorage.get('distribution_valid_time');
|
|
}
|
|
|
|
let timeStamp = new Date().getTime();
|
|
timeStamp += timeMap.n * valid_time;
|
|
|
|
if (agent_code) {
|
|
this.$cookieStorage.set('coupon_agent_code', agent_code, valid_time + 'n');
|
|
}
|
|
|
|
this.setData({
|
|
agent_code: agent_code
|
|
});
|
|
this.queryCouponDetail(id, coupon_id);
|
|
|
|
if (is_coupon) {
|
|
if (is_coupon != 1) {
|
|
wx.setNavigationBarTitle({
|
|
title: '线下折扣券详情'
|
|
});
|
|
} else {
|
|
wx.setNavigationBarTitle({
|
|
title: '线下优惠券详情'
|
|
});
|
|
}
|
|
|
|
this.setData({
|
|
is_coupon: is_coupon
|
|
});
|
|
} else {
|
|
wx.setNavigationBarTitle({
|
|
title: '线下优惠券详情'
|
|
});
|
|
}
|
|
},
|
|
methods: {
|
|
jumpList(e) {
|
|
wx.navigateTo({
|
|
url: '/pages/coupon/goods/goods?id=' + this.detail.coupon_id
|
|
});
|
|
},
|
|
|
|
jumpHome() {
|
|
wx.switchTab({
|
|
url: '/pages/index/index/index'
|
|
});
|
|
},
|
|
|
|
getCoupon() {
|
|
var token = this.$cookieStorage.get('user_token');
|
|
|
|
if (token) {
|
|
this.convertCoupon(this.detail.code);
|
|
} else {
|
|
wx.showModal({
|
|
content: '请先登录',
|
|
showCancel: false,
|
|
success: res => {
|
|
if (res.confirm || !res.cancel && !res.confirm) {
|
|
pageLogin(getUrl());
|
|
}
|
|
}
|
|
});
|
|
}
|
|
},
|
|
|
|
// 领取优惠券接口
|
|
convertCoupon(code) {
|
|
var token = this.$cookieStorage.get('user_token');
|
|
wx.showLoading({
|
|
title: "正在领取",
|
|
mask: true
|
|
});
|
|
this.$http.post({
|
|
api: 'api/coupon/convert',
|
|
header: {
|
|
Authorization: token
|
|
},
|
|
data: {
|
|
coupon_code: code,
|
|
agent_code: this.agent_code
|
|
}
|
|
}).then(res => {
|
|
wx.hideLoading();
|
|
|
|
if (res.statusCode == 200) {
|
|
res = res.data;
|
|
|
|
if (res.status) {
|
|
this.setData({
|
|
'detail.has_get': true
|
|
});
|
|
wx.showToast({
|
|
title: '领取成功'
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: res.message || '领取失败',
|
|
image: '../../../static/error.png'
|
|
});
|
|
}
|
|
} else {
|
|
wx.showToast({
|
|
title: '领取失败',
|
|
image: '../../../static/error.png'
|
|
});
|
|
}
|
|
}).catch(rej => {
|
|
wx.showToast({
|
|
title: '领取失败',
|
|
image: '../../../static/error.png'
|
|
});
|
|
wx.hideLoading();
|
|
});
|
|
},
|
|
|
|
// 查询优惠券详情
|
|
queryCouponDetail(id, coupon_id) {
|
|
wx.showLoading({
|
|
title: "加载中",
|
|
mask: true
|
|
});
|
|
var coupon_ids = coupon_id ? coupon_id : '';
|
|
var token = this.$cookieStorage.get('user_token');
|
|
this.$http.get({
|
|
api: 'api/discount/' + id + '/detail',
|
|
header: {
|
|
Authorization: token
|
|
},
|
|
data: {
|
|
coupon_id: coupon_ids
|
|
}
|
|
}).then(res => {
|
|
if (res.statusCode == 200) {
|
|
res = res.data;
|
|
|
|
if (res.status) {
|
|
this.setData({
|
|
detail: res.data,
|
|
init: true
|
|
});
|
|
} else {
|
|
wx.showModal({
|
|
content: res.message || '请求失败',
|
|
showCancel: false
|
|
});
|
|
}
|
|
} else {
|
|
wx.showModal({
|
|
content: "请求失败",
|
|
showCancel: false
|
|
});
|
|
}
|
|
|
|
wx.hideLoading();
|
|
}).catch(rej => {
|
|
wx.hideLoading();
|
|
wx.showModal({
|
|
content: '请求失败',
|
|
showCancel: false
|
|
});
|
|
});
|
|
},
|
|
|
|
setData: function (obj) {
|
|
let that = this;
|
|
let keys = [];
|
|
let val, data;
|
|
Object.keys(obj).forEach(function (key) {
|
|
keys = key.split('.');
|
|
val = obj[key];
|
|
data = that.$data;
|
|
keys.forEach(function (key2, index) {
|
|
if (index + 1 == keys.length) {
|
|
that.$set(data, key2, val);
|
|
} else {
|
|
if (!data[key2]) {
|
|
that.$set(data, key2, {});
|
|
}
|
|
}
|
|
|
|
data = data[key2];
|
|
});
|
|
});
|
|
}
|
|
},
|
|
computed: {},
|
|
watch: {}
|
|
};
|
|
</script>
|
|
<style rel="stylesheet/less" lang="less">
|
|
@import "offDetail";
|
|
</style>
|