339 lines
14 KiB
HTML
339 lines
14 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport"
|
|
content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,viewport-fit=cover" />
|
|
<title>我的订单</title>
|
|
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/vue.min.js?v=1367936144322" type="text/javascript"
|
|
charset="utf-8"></script>
|
|
<script type="text/javascript" src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/axios.js?v=1367936144322">
|
|
</script>
|
|
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/api2_0.js"></script>
|
|
<link rel="stylesheet" href="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/css/myOrder.css" />
|
|
<link rel="stylesheet" href="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/css/tabbar.css">
|
|
<link rel="stylesheet" href="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/css/payPop.css">
|
|
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/tabbar.js"></script>
|
|
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/payPop.js"></script>
|
|
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/modelPop.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="app">
|
|
<!-- 弹出提示 -->
|
|
<img class="backPresTy" @click="backHandler" v-if="goodsCount<2"
|
|
src=" https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/backprepageBtn.png" alt="">
|
|
|
|
<div id="refresh" @touchstart="touchStart($event)" @touchmove="touchMove($event)"
|
|
@touchcancel="touchEnd($event)" style="height:100%;">
|
|
<img v-show='!!loadShowHeight' class='img-lodging'
|
|
src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/img-logding.png" alt="">
|
|
<div class="content" slot="content">
|
|
<div class="content-item" v-for="item in orderList" :key="item.order_number">
|
|
<div class="top">
|
|
<p class="time">{{item.update_time}}</p>
|
|
<p class="status" :style="{color:statusColor(item.status)}">{{item.status_text}}
|
|
</p>
|
|
</div>
|
|
<div class="middle">
|
|
<img :src="filterImgSrc(item)" alt="">
|
|
<div class="right">
|
|
<div class="title_originalPrice">
|
|
<p class="title">{{item.product_name}}</p>
|
|
<p class="originalPrice">¥{{item.official_price}}</p>
|
|
</div>
|
|
<p class="id">订单编号:{{item.order_number}}</p>
|
|
</div>
|
|
</div>
|
|
<div class="bottom">
|
|
<p class="money">实付金额:¥<span>{{item.pay_amount}}</span></p>
|
|
<p class="button" @click="immediatelyPay(item)" v-show="item.status===6">立即支付</p>
|
|
<!-- 立减金待领取 -->
|
|
<p class="button" @click="receiveFn(item)" v-show="item.status===0&&item.type===2">去兑换</p>
|
|
<!-- 立减金领取过期 -->
|
|
<p class="button filter" v-show="item.status===5&&item.type===2">去兑换</p>
|
|
</div>
|
|
</div>
|
|
<!-- 空状态 -->
|
|
<div class="empty" v-if="!orderList.length">
|
|
<img src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/order-empty.png" alt="">
|
|
<p>暂无订单</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<model-pop :show.sync="popShow" :title="popTitle" :status="popStatus" :text="popText" :bottom_text="bottomText"
|
|
@backFunction="backFunction">
|
|
</model-pop>
|
|
|
|
<!-- 单条弹出框 -->
|
|
<div class="prompt" :class="toastShow?'proactive':''">
|
|
{{this.toastTip}}
|
|
</div>
|
|
|
|
<tab-component :current="2" v-if="goodsCount>1"></tab-component>
|
|
|
|
<!-- 支付弹窗 -->
|
|
<pay-pop :show.sync="show" :active="active" @payFunction="payFunction" :money="activeOrder.pay_amount" />
|
|
|
|
|
|
</div>
|
|
|
|
<script>
|
|
new Vue({
|
|
el: "#app",
|
|
data () {
|
|
return {
|
|
active: 2, /* 选择支付方式 */
|
|
show: false, /* 支付弹窗状态 */
|
|
limit: 50,
|
|
page: 1,
|
|
orderList: [],
|
|
activeOrder: {},
|
|
|
|
/* 提示框状态 */
|
|
popShow: false,
|
|
popTitle: '',
|
|
popText: '',
|
|
popStatus: 1 /*1 成功 2提示 3失败 */,
|
|
bottomText: '' /*1 成功 2提示 3失败 */,
|
|
goodsCount: 0,/* 商品数量 */
|
|
href: '',/* 支付链接 */
|
|
|
|
/* toast */
|
|
toastShow: '',
|
|
toastTip: '',
|
|
redirect: false,
|
|
|
|
/* 加载 */
|
|
scrollTop: 0,
|
|
startY: 0,
|
|
loadShowHeight: 0
|
|
}
|
|
},
|
|
|
|
components: {
|
|
tabComponent,
|
|
payPop,
|
|
modelPop,
|
|
},
|
|
|
|
created () {
|
|
this.getOrderList()
|
|
this.goodsCount = localStorage.getItem('goodsCount');
|
|
this.scrollTop =
|
|
document.documentElement.scrollTop || document.body.scrollTop
|
|
},
|
|
|
|
methods: {
|
|
/* 根据不同状态展示 订单样式和表现 */
|
|
statusColor (status) {
|
|
const colorArray = ['#f28542', '#f28542', '#44D27D', '#fd553d', '#fd553d', '#aaaaaa', '#fd553d'];
|
|
return colorArray[status];
|
|
},
|
|
|
|
/* 以下三个方法是下拉刷新 */
|
|
touchStart (e) {
|
|
this.startY = e.targetTouches[0].pageY
|
|
},
|
|
|
|
|
|
touchMove (e) {
|
|
if (this.scrollTop == 0) {
|
|
let moveDistance = e.targetTouches[0].pageY - this.startY
|
|
if (moveDistance > 0 && moveDistance <= 80) {
|
|
this.loadShowHeight = moveDistance
|
|
}
|
|
}
|
|
},
|
|
|
|
touchEnd () {
|
|
if (this.loadShowHeight >= 60) {
|
|
this.getOrderList()
|
|
} else {
|
|
this.loadShowHeight = 0
|
|
}
|
|
},
|
|
|
|
/* 图标分流 */
|
|
filterImgSrc (item) {
|
|
if (item.type === 1) {
|
|
return item.show_url
|
|
} else {
|
|
const redirectType = item.goods.entity.channel
|
|
if (redirectType === 1) {
|
|
return 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/commonproductlogo/zfbreduce.png'
|
|
}
|
|
if (redirectType === 2) {
|
|
return 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/commonproductlogo/wxreduce.png'
|
|
}
|
|
}
|
|
},
|
|
|
|
/* 返回 */
|
|
backHandler () {
|
|
window.location.replace('./couponCollection.html');
|
|
},
|
|
|
|
/* 立即支付按钮 */
|
|
immediatelyPay (item) {
|
|
this.activeOrder = item;
|
|
this.show = true
|
|
this.active = item.pay_type === 5 ? 1 : 2
|
|
},
|
|
|
|
/* 去支付 */
|
|
payFunction ({ payType, isSupport }) {
|
|
/* payType 1:微信 2:支付宝 */
|
|
/* 后端 微信是5 */
|
|
this.active = payType === 2 ? 1 : 5
|
|
this.show = false
|
|
|
|
/* 设置支付类型 */
|
|
if (this.active !== this.activeOrder.pay_type) { /* 支付类型是否变化 */
|
|
req.axiosPut(`/key/order/setPayType/${this.activeOrder.order_number}/${this.active}`).then(({ code, message }) => {
|
|
if (code === -1) {
|
|
this.popFunction({ title: '温馨提示', text: message, status: 2, b_text: '我知道了', show: true })
|
|
return this.redirect = true
|
|
}
|
|
|
|
if (code === 200) {
|
|
this.getOrderList()
|
|
this.payRealFunction(isSupport)
|
|
}
|
|
})
|
|
} else {
|
|
this.payRealFunction(isSupport)
|
|
}
|
|
},
|
|
|
|
/* 调用支付 */
|
|
payRealFunction (isSupport) {
|
|
req.axiosGet(`/key/coupon/createPay/${this.activeOrder.order_number}`).then(({ code, data, message }) => {
|
|
if (code === -1) {
|
|
this.popFunction({ title: '温馨提示', text: message, status: 2, b_text: '我知道了', show: true })
|
|
return this.redirect = true
|
|
}
|
|
|
|
/* 支付宝跳转链接 */
|
|
if (code === 200) {
|
|
/* 判断浏览器 */
|
|
if (isSupport) {
|
|
this.popFunction({ title: '温馨提示', text: `请在其他浏览器打开链接`, status: 2, b_text: '点击复制', show: true })
|
|
this.href = data
|
|
return
|
|
} else {
|
|
window.location.href = data
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
/* 统一控制弹窗 */
|
|
popFunction ({ title, text, status, b_text, show }) {
|
|
this.popTitle = title
|
|
this.popText = text
|
|
this.popStatus = status
|
|
this.bottomText = b_text
|
|
this.popShow = show
|
|
},
|
|
|
|
/* 请求订单数据 */
|
|
getOrderList () {
|
|
this.orderList = []
|
|
this.loadShowHeight = true
|
|
const token = localStorage.getItem('token')
|
|
req.axiosGet(`/key/order/${token}`, { page: this.page, limit: this.limit }).then(({ data, code, message }) => {
|
|
if (code === -1) {
|
|
this.popFunction({ title: '温馨提示', text: message, status: 2, b_text: '我知道了', show: true })
|
|
return this.redirect = true
|
|
}
|
|
if (code === 200) {
|
|
setTimeout(() => {
|
|
this.loadShowHeight = 0;
|
|
this.orderList = data
|
|
}, 1 * 1000)
|
|
}
|
|
})
|
|
},
|
|
|
|
/*跳转起始页面*/
|
|
toPage () {
|
|
let entryLink = localStorage.getItem('entryLink');
|
|
setTimeout(() => {
|
|
window.location.replace(entryLink);
|
|
}, 1000);
|
|
},
|
|
|
|
/* 弹窗回调 */
|
|
backFunction (type) {
|
|
if (this.bottomText === '点击复制' && type) {
|
|
var aux = document.createElement("input");
|
|
aux.setAttribute("value", this.href);
|
|
document.body.appendChild(aux);
|
|
aux.select();
|
|
document.execCommand("copy");
|
|
document.body.removeChild(aux);
|
|
this.openDialog('复制成功')
|
|
}
|
|
|
|
if (this.redirect) {
|
|
this.toPage()
|
|
}
|
|
},
|
|
|
|
|
|
//支付宝H5跳转
|
|
toLinkAliPay (res) {
|
|
let banklink = encodeURIComponent(
|
|
window.location.origin +
|
|
"/alipay.html?orderNumber=" + res.orderNumber
|
|
);
|
|
let link = "http://openapi.1688sup.com/alipay/oauth?jump=" + banklink;
|
|
window.location.replace(link);
|
|
},
|
|
|
|
//领取立减金
|
|
receiveFn (res) {
|
|
let ua = navigator.userAgent.toLowerCase(); //判断用户打开链接环境
|
|
|
|
/* 支付宝 */
|
|
if (res.goods.entity.channel == 1) {
|
|
if (ua.indexOf("weixin") > -1) {
|
|
//在微信内置环境打开,不能唤起支付宝
|
|
this.popFunction({ title: '温馨提示', text: '请在其他浏览器打开', status: 2, show: true })
|
|
} else {
|
|
this.toLinkAliPay(res);
|
|
}
|
|
}
|
|
|
|
//微信
|
|
if (res.goods.entity.channel == 2) {
|
|
if (ua.indexOf("dingtalk") > -1) {
|
|
//在钉钉内置环境打开,不能唤起微信小程序
|
|
this.popFunction({ title: '温馨提示', text: '请在其他浏览器打开', status: 2, show: true })
|
|
} else {
|
|
//唤起微信福利官小程序
|
|
window.location.replace(this.redirect_url);
|
|
}
|
|
}
|
|
},
|
|
|
|
// 单条弹框
|
|
openDialog (tip) {
|
|
this.toastShow = true;
|
|
this.toastTip = tip;
|
|
setTimeout(() => {
|
|
this.toastShow = false;
|
|
this.toastTip = '';
|
|
}, 3000)
|
|
},
|
|
|
|
}
|
|
})
|
|
</script>
|
|
</body>
|
|
|
|
</html> |