|
@@ -0,0 +1,440 @@
|
|
|
+$(function () {
|
|
|
+ $('.header-title.title-left').on('click', function () {
|
|
|
+ history.back()
|
|
|
+ })
|
|
|
+})
|
|
|
+var vm = new Vue({
|
|
|
+ delimiters: ['${', '}'],
|
|
|
+ el: '#app',
|
|
|
+ data: function () {
|
|
|
+ return {
|
|
|
+ platform: assetsConf.platform,
|
|
|
+ orderCode: '',
|
|
|
+ // 订单接口返回的原始数据
|
|
|
+ reqOrder: {},
|
|
|
+ reqTime: {},
|
|
|
+ orderStateMap: {
|
|
|
+ 0: {
|
|
|
+ text: '待付款',
|
|
|
+ bgcColor: '',
|
|
|
+ bgcClassName: 'orange',
|
|
|
+ surplusTimeShow: true,
|
|
|
+ bottomButtonShow: {
|
|
|
+ pay: true,
|
|
|
+ invoke: false,
|
|
|
+ buyAgain: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 1: {
|
|
|
+ text: '已完成',
|
|
|
+ bgcColor: '',
|
|
|
+ bgcClassName: 'blue',
|
|
|
+ surplusTimeShow: false,
|
|
|
+ bottomButtonShow: {
|
|
|
+ pay: false,
|
|
|
+ invoke: true,
|
|
|
+ buyAgain: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ '-2': {
|
|
|
+ text: '已取消',
|
|
|
+ bgcColor: '',
|
|
|
+ bgcClassName: 'grey',
|
|
|
+ surplusTimeShow: false,
|
|
|
+ bottomButtonShow: {
|
|
|
+ pay: false,
|
|
|
+ invoke: false,
|
|
|
+ buyAgain: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ '-3': {
|
|
|
+ text: '已取消',
|
|
|
+ bgcColor: '',
|
|
|
+ bgcClassName: 'grey',
|
|
|
+ surplusTimeShow: false,
|
|
|
+ bottomButtonShow: {
|
|
|
+ pay: false,
|
|
|
+ invoke: false,
|
|
|
+ buyAgain: false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ productTypeList: assetsConf.productionTypeList,
|
|
|
+ prodConf: {
|
|
|
+ // 支持再次购买的产品product_type
|
|
|
+ canBuyAgain: assetsConf.cabBuyAgainProductions,
|
|
|
+ // 支持开发票的产品product_type
|
|
|
+ canInvoke: assetsConf.canInvokeProductions
|
|
|
+ },
|
|
|
+ payWayMap: {
|
|
|
+ wx_js: '微信支付',
|
|
|
+ wx_app: '微信支付',
|
|
|
+ ali_app: '支付宝支付',
|
|
|
+ wx_pc: '微信支付',
|
|
|
+ ali_pc: '支付宝支付'
|
|
|
+ },
|
|
|
+ // 页面内容展示数组
|
|
|
+ orderInfo: {
|
|
|
+ state: 0, // 订单状态: 0:待支付 1:已完成 -2:已取消 -3:已退款
|
|
|
+ surplusTime: 0, // 取消订单倒计时
|
|
|
+ headerImg: '', // 头图地址
|
|
|
+ payWay: '',
|
|
|
+ productType: '',
|
|
|
+ orderMoney: '', // 订单金额
|
|
|
+ payMoney: '', // 实付金额
|
|
|
+
|
|
|
+ applybillStatus: 1,
|
|
|
+ ordercode: '',
|
|
|
+ createTime: '',
|
|
|
+ payTime: 0,
|
|
|
+ paymentId: '',
|
|
|
+ // 单位: 秒(s)
|
|
|
+ surplusTime: 0,
|
|
|
+ productInfoList: [],
|
|
|
+ orderInfoList: []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ invokeButtonText: function () {
|
|
|
+ return this.orderInfo.applybillStatus === 0 ? '开发票' : '查看发票'
|
|
|
+ },
|
|
|
+ buttonGroupShow: function () {
|
|
|
+ var state = this.orderInfo.state
|
|
|
+ var payShow = this.orderStateMap[state].bottomButtonShow.pay
|
|
|
+ var invokeShow = this.orderStateMap[state].bottomButtonShow.invoke
|
|
|
+ var buyAgainShow = this.orderStateMap[state].bottomButtonShow.buyAgain
|
|
|
+ return payShow || invokeShow || buyAgainShow
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created: function () {
|
|
|
+ this.orderCode = utils.getParam('order_code')
|
|
|
+ this.getOrderDetail()
|
|
|
+ },
|
|
|
+ mounted: function () {
|
|
|
+ utils.iosBackRefresh()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ showLoading: function () {
|
|
|
+ return this.$toast.loading({
|
|
|
+ duration: 0,
|
|
|
+ forbidClick: true,
|
|
|
+ message: 'loading...',
|
|
|
+ })
|
|
|
+ },
|
|
|
+ showToast: function (message) {
|
|
|
+ return this.$toast({
|
|
|
+ duration: 1500,
|
|
|
+ forbidClick: true,
|
|
|
+ message: message,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ showDialog: function (conf) {
|
|
|
+ var defaultConf = {
|
|
|
+ title: '提示',
|
|
|
+ message: 'message',
|
|
|
+ className: 'j-confirm-dialog',
|
|
|
+ showConfirmButton: true,
|
|
|
+ showCancelButton: true,
|
|
|
+ confirmButtonColor: '#2abed1'
|
|
|
+ }
|
|
|
+ if (conf) {
|
|
|
+ Object.assign(defaultConf, conf)
|
|
|
+ }
|
|
|
+ return this.$dialog.confirm(defaultConf)
|
|
|
+ },
|
|
|
+ getOrderDetail: function () {
|
|
|
+ var _this = this
|
|
|
+ var loading = this.showLoading()
|
|
|
+ var data = {
|
|
|
+ orderCode: this.orderCode
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ type: 'POST',
|
|
|
+ url: '/subscribepay/orderListDetails/getOrderPayAllMsg',
|
|
|
+ data, data,
|
|
|
+ success: function (res) {
|
|
|
+ loading && loading.clear()
|
|
|
+ if (res.success) {
|
|
|
+ if (res.data) {
|
|
|
+ if (res.data.order) {
|
|
|
+ if (res.data.order.order_status === -3) {
|
|
|
+ res.data.order.order_status = -2
|
|
|
+ }
|
|
|
+ Object.assign(_this.reqOrder, res.data.order)
|
|
|
+ }
|
|
|
+ if (res.data.time) {
|
|
|
+ Object.assign(_this.reqTime, res.data.time)
|
|
|
+ }
|
|
|
+ _this.calcOrderInfo(res.data)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ _this.showToast(res.errMsg)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function (err) {
|
|
|
+ loading && loading.clear()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onCountdownFinish: function () {
|
|
|
+ console.log('onCountdownFinish')
|
|
|
+ this.orderInfo.state = -2
|
|
|
+ },
|
|
|
+ calcOrderInfo: function (info) {
|
|
|
+ var order = info.order
|
|
|
+ this.orderInfo.state = order.order_status
|
|
|
+ try {
|
|
|
+ this.orderInfo.headerImg = this.getHeaderImg(order)
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.orderInfo.state === 0) {
|
|
|
+ // 取消订单倒计时
|
|
|
+ this.orderInfo.surplusTime = this.getSurplusTimeTime(order)
|
|
|
+ }
|
|
|
+
|
|
|
+ this.orderInfo.applybillStatus = order.applybill_status
|
|
|
+ this.orderInfo.ordercode = order.order_code
|
|
|
+ this.orderInfo.createTime = this.time2Stamp(order.create_time)
|
|
|
+ this.orderInfo.payTime = order.pay_time ? this.time2Stamp(order.pay_time) : ''
|
|
|
+ this.orderInfo.payWay = order.pay_way
|
|
|
+ this.orderInfo.productType = order.product_type
|
|
|
+
|
|
|
+ // 订单金额
|
|
|
+ this.orderInfo.orderMoney = this.moneyFormat(order.order_money)
|
|
|
+ // 实付金额
|
|
|
+ this.orderInfo.payMoney = this.moneyFormat(order.order_money)
|
|
|
+
|
|
|
+ if (info.transaction_id) {
|
|
|
+ this.orderInfo.paymentId = info.transaction_id // 支付单号
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果是可再次购买的产品,则显示再次购买
|
|
|
+ if (this.prodConf.canBuyAgain.indexOf(this.orderInfo.productType)) {
|
|
|
+ this.orderStateMap[1].bottomButtonShow.buyAgain = true
|
|
|
+ }
|
|
|
+
|
|
|
+ this.orderInfo.productInfoList = this.getProductInfoList(info)
|
|
|
+ this.orderInfo.orderInfoList = this.getOrderInfoListList(info)
|
|
|
+ },
|
|
|
+ getHeaderImg: function (order) {
|
|
|
+ var productType = order.product_type
|
|
|
+ var platform = this.platform
|
|
|
+ var headerImgUrl = ''
|
|
|
+ if (productType === '数据流量包') {
|
|
|
+ headerImgUrl = assetsConf.dataPackLink.imgMap.headerImg[platform]
|
|
|
+ }
|
|
|
+
|
|
|
+ return headerImgUrl
|
|
|
+ },
|
|
|
+ getSurplusTimeTime: function (order) {
|
|
|
+ var lastTime = order.order_countdown.split('h')[0]
|
|
|
+ var lastTimeStamp = lastTime * 60 * 60 * 1000
|
|
|
+ var createTime = order.create_time.replace(/-/g, '/')
|
|
|
+ var createTimeStamp = +new Date(createTime)
|
|
|
+ var nowStamp = Date.now()
|
|
|
+ // surplusTime = createTime + lastTime - +new Date()
|
|
|
+ var surplusTime = createTimeStamp + lastTimeStamp - nowStamp
|
|
|
+
|
|
|
+ if (surplusTime > 0) {
|
|
|
+ return surplusTime
|
|
|
+ } else {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ moneyFormat: function (m) {
|
|
|
+ return utils.formatMoney(m / 100)
|
|
|
+ },
|
|
|
+ time2Stamp: function (time) {
|
|
|
+ if (!time) return ''
|
|
|
+ var t = time.replace(/(-|\.)/g, '/')
|
|
|
+ return +new Date(t)
|
|
|
+ },
|
|
|
+ getOrderInfoListList: function (info) {
|
|
|
+ var order = info.order
|
|
|
+ var createTime = this.time2Stamp(order.create_time)
|
|
|
+ var payTime = order.pay_time ? this.time2Stamp(order.pay_time) : ''
|
|
|
+ var payWay = order.pay_way ? order.pay_way : ''
|
|
|
+
|
|
|
+ var infoList = [
|
|
|
+ {
|
|
|
+ label: '订单编号',
|
|
|
+ split: ':',
|
|
|
+ text: this.orderCode
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '下单时间',
|
|
|
+ split: ':',
|
|
|
+ text: new Date(createTime).pattern('yyyy.MM.dd HH:mm')
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '支付时间',
|
|
|
+ split: ':',
|
|
|
+ text: payTime ? new Date(payTime).pattern('yyyy.MM.dd HH:mm') : ''
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '支付方式',
|
|
|
+ split: ':',
|
|
|
+ text: this.payWayMap[payWay]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '支付单号',
|
|
|
+ split: ':',
|
|
|
+ text: this.orderInfo.paymentId
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '产品类型',
|
|
|
+ split: ':',
|
|
|
+ text: order.product_type
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '实付金额',
|
|
|
+ split: ':',
|
|
|
+ text: order.pay_money ? '¥' + this.moneyFormat(order.pay_money) : ''
|
|
|
+ }
|
|
|
+ ]
|
|
|
+
|
|
|
+ return infoList
|
|
|
+ },
|
|
|
+ // 开发票逻辑,和订单详情相同
|
|
|
+ lookInvoke: function () {
|
|
|
+ var _this = this
|
|
|
+ var platform = this.platform
|
|
|
+ var order = this.reqOrder
|
|
|
+ var orderCode = order.order_code
|
|
|
+ // 发票状态 1:已开线上发票 2:已开线下发票
|
|
|
+ var applybill_status = order.applybill_status
|
|
|
+
|
|
|
+ // 已开发票情况(查看发票)
|
|
|
+ if (applybill_status === 1) {
|
|
|
+ var href = assetsConf.invokeLink.lookInvoice[platform]
|
|
|
+ if (href) {
|
|
|
+ _this.goToLink(`${href}?order_code=${orderCode}`)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ } else if (applybill_status === 2) {
|
|
|
+ return this.showDialog({
|
|
|
+ title: '',
|
|
|
+ message: '您已开具发票<br>如有问题请联系客服<br>400-108-6670',
|
|
|
+ className: 'j-confirm-dialog text-center',
|
|
|
+ showCancelButton: false,
|
|
|
+ confirmButtonText: '我知道了'
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ var loading = this.showLoading()
|
|
|
+ $.ajax({
|
|
|
+ type: 'POST',
|
|
|
+ url: '/subscribepay/orderListDetails/isOver',
|
|
|
+ data: {
|
|
|
+ order_code: orderCode
|
|
|
+ },
|
|
|
+ success: function (res) {
|
|
|
+ loading && loading.clear()
|
|
|
+ if (res.status === 1) {
|
|
|
+ // 开发票跳转
|
|
|
+ var href = assetsConf.invokeLink.invoke[platform]
|
|
|
+ if (href) {
|
|
|
+ _this.goToLink(`${href}?order_code=${orderCode}`)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 不能开发票跳转
|
|
|
+ var href = assetsConf.invokeLink.cantInvoke[platform]
|
|
|
+ if (href) {
|
|
|
+ _this.goToLink(`${href}?order_code=${orderCode}`)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function (err) {
|
|
|
+ loading && loading.clear()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onConfirmPay: function () {
|
|
|
+ var order = this.reqOrder
|
|
|
+ var productType = order.product_type
|
|
|
+ var orderCode = order.order_code
|
|
|
+ var platform = this.platform
|
|
|
+ switch (productType) {
|
|
|
+ case '数据流量包': {
|
|
|
+ var href = assetsConf.dataPackLink.pay[platform]
|
|
|
+ if (href) {
|
|
|
+ this.goToLink(`${href}?orderCode=${orderCode}`)
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ default: {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ buyAgain: function () {
|
|
|
+ var _this = this
|
|
|
+ var order = this.reqOrder
|
|
|
+ var productType = order.product_type
|
|
|
+ var orderCode = order.order_code
|
|
|
+ var platform = this.platform
|
|
|
+
|
|
|
+ switch (productType) {
|
|
|
+ case '数据流量包': {
|
|
|
+ var href = assetsConf.dataPackLink.buyAgain[platform]
|
|
|
+ if (href) {
|
|
|
+ this.goToLink(`${href}?orderCode=${orderCode}`)
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ default: {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getProductInfoList: function (info) {
|
|
|
+ var order = info.order
|
|
|
+ var productType = order.product_type
|
|
|
+ var platform = this.platform
|
|
|
+ var infoList = []
|
|
|
+
|
|
|
+ switch (productType) {
|
|
|
+ case '数据流量包': {
|
|
|
+ infoList = this.getDataPackInfo(order)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ default: {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return infoList
|
|
|
+ },
|
|
|
+ getDataPackInfo: function (order) {
|
|
|
+ var filterInfo = JSON.parse(order.filter)
|
|
|
+ var specMap = {
|
|
|
+ 1: '标准字段包',
|
|
|
+ 2: '高级字段包'
|
|
|
+ }
|
|
|
+
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ label: '充值条数',
|
|
|
+ split: ':',
|
|
|
+ text: filterInfo.pNum + '条'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '有效期',
|
|
|
+ split: ':',
|
|
|
+ text: filterInfo.validYear + '年'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '数据规格',
|
|
|
+ split: ':',
|
|
|
+ text: specMap[filterInfo.pType]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ goToLink: function (href) {
|
|
|
+ location.href = href
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|