[内网]文化云交易前端H5
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.
 
 
 
 
 
 

677 lines
22 KiB

<template>
<view class="container">
<mescroll-body ref="mescrollRef" :sticky="true" @init="mescrollInit" :down="{ native: true }" @down="downCallback" :up="upOption" @up="upCallback">
<!-- tab栏 -->
<u-tabs :list="tabs" :is-scroll="false" :barWidth="110" :current="curTab" active-color="#26587b" :duration="0.2" @change="onChangeTab" />
<!-- 订单列表 -->
<view class="order-list">
<view class="order-item" v-for="(item, index) in list.data" :key="index">
<view class="item-top">
<view class="item-top-left">
<text class="order-time">订单号:{{ item.batchcode }}</text>
</view>
<view class="item-top-right">
<text class="state-text">{{item.state_text}}</text>
</view>
</view>
<!-- 商品列表 -->
<view class="goods-list" >
<view class="goods-item" v-for="(goods, idx) in item.order_detail" :key="idx">
<!-- 商品图片 -->
<view class="goods-image">
<image class="image" :src="goods.goods_image" mode="scaleToFill"></image>
</view>
<!-- 商品信息 -->
<view class="goods-content">
<view class="goods-title">
<view class="twoline-hide">
<text class="twoline-hide-name">{{ goods.goods_name }}</text>
</view>
<view class="twoline-hide-info">
<text class="twoline-hide-price">
单价
<view class="twoline-hide-icon"></view>
{{ goods.price }}
</text>
<text class="twoline-hide-price">
购买年限 {{ goods.transaction_count }}
</text>
<text class="twoline-hide-price">
交易佣金
<view class="twoline-hide-icon"></view>
{{ goods.service_charge }}
<view class="twoline-hide-sum">
合计{{goods.money}}
</view>
</text>
</view>
</view>
</view>
<!-- 委托方等信息 -->
<view class="goods-props clearfix">
<view class="goods-props-item">委托方{{goods.entrust_name}}</view>
<view class="goods-props-item">
<text>交易方式{{goods.goods_entrust=="1"?'转让':'授权'}}</text>
</view>
<view class="goods-props-item" v-if="item.status == 2 || item.status == '3' || item.status == '4'">
<text>交易ISLI编码:{{goods.contract_code ? goods.contract_code :'--'}}</text>
</view>
<view class="goods-props-item" v-if="item.status == 2 || item.status == '3' || item.status == '4'">
<text>提取期限:{{item.paymenttimeStr}}</text>
</view>
<view class="goods-props-bt" v-if="item.status == 2 || item.status == '3' || item.status == '4'">
<view class="goods-props-bt-down" @click="handelDownload(idx,item.batchcode,goods)">
下载
</view>
</view>
</view>
</view>
<view class="goods-sum">
<view class="goods-sum-date">
提交时间:{{item.createtime}}
</view>
<view class="goods-sum-time" v-if="item.status == 1">
付款倒计时:{{item.createDateTime}}
</view>
<view class="goods-sum-time" v-if="item.status == 2 || item.status == '3' || item.status == '4'">
支付时间:{{item.paymenttime}}
</view>
<view class="goods-sum-amount">
订单金额:¥{{item.total_money_str}}
</view>
<view v-if="item.status == 1" class="goods-sum-bt">
<view class="goods-sum-bt-pay" @click="onGoodsPayment(item.batchcode)">
支付
</view>
</view>
</view>
</view>
</view>
</view>
</mescroll-body>
<view>
<!-- 普通弹窗 -->
<uni-popup ref="alertDialog" type="dialog">
<uni-popup-dialog :type="msgType" cancelText="取消" title="下载" content=""
@close="dialogClose">
<view class="popup-item" v-for="pItem in downList" style="border-bottom: 1px #e8e8e8 solid;margin-top: 5px">
<view>{{pItem.target_name}}</view>
<view>{{pItem.metadataFileFormat}}</view>
<view>{{pItem.metadataFileSize}}</view>
<view>{{pItem.status_name}}</view>
<view v-if="pItem.show_down"
class="popup-item-bt"
@click="handelTable(pItem.isliCode,pItem.metadataFileFormat)"
style="float: right;width: 60px;height: 25px;margin-top: -25px;background-color: #26587b;color: white;border-radius: 25px;"
>
<view class="popup-item-bt-down" style="text-align: center; margin-top: 3px;">下载</view>
<a ref="downloadLink" :href="downloadUrl" style="display:none" download></a>
</view>
</view>
</uni-popup-dialog>
</uni-popup>
</view>
</view>
</template>
<script>
import * as OrderApi from '@/api/order'
import * as Comment from '@/api/order/comment'
import { checkLogin } from '@/core/app'
import { getEmptyPaginateObj, getMoreListData } from '@/core/app'
import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue'
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
import uniPopup from '../../../uni_modules/uni-popup/components/uni-popup/uni-popup';
import uniPopupDialog from '../../../uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog';
// 每页记录数量
const pageSize = 10
// tab栏数据
const tabs = [
{name: `全部订单`,value: 'all',key: ''},
{name: `待付款`,value: 'payment',key: 1},
{name: `待交付`,value: 'delivery',key: 2},
{name: `已终止`,value: 'hasabort',key: '3,4'},
{name: `已关闭`,value: 'hasclosed',key: 5},
]
export default {
name: "buyOrder",
components: {
MescrollBody,
uniPopup,
uniPopupDialog,
},
mixins: [MescrollMixin],
data() {
return {
// 当前页面参数
options: { dataType: 'all' },
// tab栏数据
tabs,
// 当前标签索引
curTab: 0,
// 订单列表数据
list: getEmptyPaginateObj(),
// 上拉加载配置
upOption: {
// 首次自动执行
auto: true,
// 每页数据的数量; 默认10
page: { size: pageSize },
// 数量要大于4条才显示无更多数据
noMoreSize: 4,
// 空布局
empty: {
tip: '暂无订单记录'
}
},
// 控制onShow事件是否刷新订单列表
canReset: false,
downList: [
{
target_name: 'target_name',
metadataFileFormat: 'metadataFileFormat',
metadataFileSize: 'metadataFileSize',
status_name: 'status_name',
show_down: 0,
},
{
target_name: 'target_name',
metadataFileFormat: 'metadataFileFormat',
metadataFileSize: 'metadataFileSize',
status_name: 'status_name',
isliCode: 'isliCode',
show_down: 1,
},
{
target_name: 'target_name',
metadataFileFormat: 'metadataFileFormat',
metadataFileSize: 'metadataFileSize',
status_name: 'status_name',
isliCode: 'isliCode',
show_down: 1,
}
],// 下载列表数据收集
msgType: 'success',
source_download: [],
order_number: '', // 订单下载记录接口需要订单号
downloadUrl: '', // 临时下载链接
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 初始化当前选中的标签
this.initCurTab(options)
// 注册全局事件订阅: 是否刷新订单列表
uni.$on('syncRefresh', canReset => {
this.canReset = canReset
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.canReset && this.onRefreshList()
this.canReset = false
},
/**
* 生命周期函数--监听页面的卸载
*/
onUnload() {
// 卸载全局事件订阅
uni.$off('syncRefresh')
},
methods: {
// 初始化当前选中的标签
initCurTab(options) {
// 判断是否已登录
this.isLogin = checkLogin()
if(!this.isLogin){
uni.navigateTo({
url:"/pages/login/index"
})
}
// 登录成功后才可以操作
const app = this
if (options.dataType) {
const index = app.tabs.findIndex(item => item.value == options.dataType)
app.curTab = index > -1 ? index : 0
}
},
/**
* 上拉加载的回调 (页面初始化时也会执行一次)
* 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
* @param {Object} page
*/
upCallback(page) {
const app = this
// 设置列表数据
app.getOrderList(page.num)
.then(list => {
const curPageLen = list.data.length
const totalSize = list.data.total
app.mescroll.endBySize(curPageLen, totalSize)
})
.catch(() => app.mescroll.endErr())
},
// 获取订单列表
getOrderList(pageNo = 1) {
const app = this
return new Promise((resolve, reject) => {
let status = app.tabs[app.curTab].key
let isliCode = uni.getStorageSync("isliCode")
let data = {
offset:0,
limit:pageSize,
order_status: status,
user_role: 1,
user_isli: isliCode,
page:pageNo,
pageSize:pageSize,
}
OrderApi.ordquery(data)
.then(result => {
// 按格式封装
let nlist = {data:result.data,total:result.count,current_page:pageNo}
// 合并新数据
const newList = app.initList(nlist)
app.list.data = getMoreListData(newList, app.list, pageNo)
resolve(newList)
})
})
},
// 初始化订单列表数据
initList(newList) {
newList.data.forEach(item => {
item.total_num = item.order_detail.length
item.state_text = this.showStateText(item.status)
item.createDateTime = Comment.getDateTime(item.createtime,item.status)
item.total_money_str = Comment.formatAmount(item.total_money)
item.paymenttimeStr = Comment.getDateTerm(item.paymenttime,item.status)
})
return newList
},
// 订单状态
showStateText(state){
let state_txt="";
if(state=="1"){
state_txt="待付款"
}else if(state =="2" ){
state_txt="待付款"
} else if(state=="3"){
state_txt="已终止"
} else if(state == "4"){
state_txt="已终止"
}else{
state_txt="已关闭"
}
return state_txt;
},
// 跳转支付页面
onGoodsPayment(batchcode) {
this.list.data.forEach(item => {
if (batchcode == item.batchcode) {
let newdaimg = Comment.getDefaultImage()
this.$navTo('pages/goods/payment/orderPayment', { batchcode: batchcode, img: newdaimg })
}
})
},
// 下载
handelDownload (index,batchcode,goods) {
let app = this
let source_download = goods.source_download
app.source_download = JSON.parse(source_download);
let isliCode = uni.getStorageSync("isliCode")
OrderApi.getSourceNewList(batchcode,isliCode,goods.goods_islicode).then(res => {
if (res.resultCode === "00000000") {
let sourceData = [],targetData = [],targetData2 = []
if (res.data.length > 0) {
res.data[0].singleResource.myForEach(function (item, index, arr) {
sourceData.push(JSON.parse(item.source_data))
});
res.data[0].moreResources.myForEach(function (item, index, arr) {
if (targetData2.indexOf(JSON.parse(item.source_data).isliCode) == -1) {
targetData2.push(JSON.parse(item.source_data).isliCode);
targetData.push([]);
}
targetData[targetData2.indexOf(JSON.parse(item.source_data).isliCode)].push(item);
});
app.order_number = batchcode
app.query_type(source_download,targetData,sourceData);
} else {
app.$error('无资源下载')
}
} else {
app.$error(res.resultMsg)
}
})
},
query_type(source_download,targetData,sourceData) {
const app = this
let sumSourceData = []; //合并后的数组
let unitSource = []; //处理后的单资源数组
let bothSource = []; //处理后的资源集
if (targetData.length > 0) {
targetData.myForEach(function (v, index, arr) {
v.myForEach(function (item, index) {
item.copyTarget_data = JSON.parse(item.target_data);
bothSource.push(item);
})
});
}
sourceData.myForEach(function (item, index, arr) {
item.copyTarget_data = item;
unitSource.push(item);
});
sumSourceData = unitSource.concat(bothSource);
let new_sumDate = JSON.parse(source_download);
let obj = [];
sumSourceData.myForEach(function (item, index, arr) {
let new_obj = {};
for (let attr in item) {
new_obj[attr] = item[attr];
}
for (let attr in new_sumDate[index]) {
new_obj[attr] = new_sumDate[index][attr];
}
return obj.push(new_obj);
})
obj.myForEach(function (v, index, arr) {
let status_name = "";
if (v.status == 1) {
status_name = "解密中,请稍后再试"
} else if (v.status == 2) {
status_name = "获取下载地址失败"
} else if (v.status == 3) {
status_name = "获取解密资源地址失败"
} else if (v.status == 4) {
status_name = "获取解密资源地址成功"
} else if (v.status == 5) {
status_name = "没有解密资源地址"
} else if (v.status == 6) {
status_name = "获取资源下载状态失败"
} else if (v.status == 7) {
status_name = "资源下载成功"
} else if (v.status == 8) {
status_name = "资源下载失败"
} else if (v.status == 9) {
status_name = "获取资源下载状态异常"
}
if (v.isliCode != "undefined" && v.isliCode != undefined && v.isliCode != null) {
v.isliCode = v.isliCode;
} else if (v.linkcode != "undefined" && v.linkcode != undefined && v.linkcode != null) {
v.isliCode = v.linkcode;
} else if (v.identifier != "undefined" && v.identifier != undefined && v.identifier != null) {
v.isliCode = v.identifier;
}
if (v.target_data != "undefined" && v.target_data != undefined) {
v.target_name = v.target_name
} else {
v.target_name = v.titleName
}
let tempArr = {}
tempArr.target_name = v.target_name
tempArr.metadataFileFormat = v.copyTarget_data.metadataFileFormat
tempArr.status_name = status_name
tempArr.metadataFileSize = FileSize(v.copyTarget_data.metadataFileSize)
if (v.status == 4 || v.status == 7) {
tempArr.isliCode = v.isliCode
tempArr.show_down = 1
} else {
tempArr.show_down = 0
}
app.downList.push(tempArr)
})
app.msgType = 'success'
app.$refs.alertDialog.open()
},
// 二次点击下载
handelTable(islicode, copyTarget) {
const app = this
if (islicode != undefined) {
let DemoArray = app.source_download
DemoArray.myForEach(function (v, index, arr) {
if (v.islicode == islicode) {
if (v.url) {
app.downloadUrl = v.url
const downloadLink = app.$refs.downloadLink;
downloadLink.click();
downloadFile(v.url, '资源下载', v.islicode);
} else {
app.$error('解密中')
}
}
})
}
},
// 最终下载后
downloadFile(url, name, islicode) {
const app = this
let data = {
batchcode: app.order_number, //订单编号
dowUrl: url, //下载链接
isliCode: islicode, //资源ISLI码
sourceStatus: 0, //下载状态:0:已下载 1:未下载 2: 下载失败 3:状态异常
userId: uni.getStorageSync("isliCode") //购买方用户ISLI码
}
OrderApi.getDownsAddress(data).then(res => {
if (res.resultCode === "00000000") {
app.$success("下载成功");
} else {
app.app.error(res.resultMsg);
}
})
},
dialogClose() {console.log('点击关闭')},
// 获取当前标签项的值
getTabValue() {
return this.tabs[this.curTab].value
},
// 切换标签项
onChangeTab(index) {
const app = this
// 设置当前选中的标签
app.curTab = index
// 刷新订单列表
app.onRefreshList()
},
// 刷新订单列表
onRefreshList() {
this.list = getEmptyPaginateObj()
setTimeout(() => {
this.mescroll.resetUpScroll()
}, 120)
},
}
}
</script>
<style lang="scss" scoped>
.u-tabs {
font-weight: bold;
}
// 项目内容
.order-item {
margin: 20rpx auto 20rpx auto;
padding: 30rpx 30rpx;
width: 94%;
box-shadow: 0 1rpx 5rpx 0px rgba(0, 0, 0, 0.05);
border-radius: 16rpx;
background: #fff;
}
// 项目顶部
.item-top {
display: flex;
justify-content: space-between;
font-size: 28rpx;
margin-bottom: 20rpx;
padding-bottom: 20rpx;
.order-time {
color: #777;
font-weight: 600;
}
.state-text {
color: #26587b;
font-weight: 600;
}
}
// 商品列表
.goods-list {
// 商品项
.goods-item {
display: flex;
flex-wrap: wrap;
margin-bottom: 20rpx;
margin-top: -20rpx;
border-top: 1rpx #e8e8e8 solid;
// 商品图片
.goods-image {
width: 180rpx;
height: 180rpx;
flex-basis: calc(33.33% - 10rpx);
margin-right: 10rpx;
.image {
display: block;
width: 100%;
height: 100%;
border-radius: 8rpx;
}
}
// 商品内容
.goods-content {
padding-left: 16rpx;
padding-top: 10rpx;
flex-basis: calc(66.66% - 10rpx);
margin-right: 10rpx;
.goods-title {
font-size: 26rpx;
max-height: 76rpx;
}
.twoline-hide {
height: 70rpx;
}
.twoline-hide-name {
font-size: 28rpx;
font-weight: bold;
display: -webkit-box;
-webkit-line-clamp: 2; /* 控制显示的行数 */
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.twoline-hide-info {
margin-top: 10rpx;
position: absolute;
.twoline-hide-price{
display: block;
font-size: 24rpx;
color: #767285;
.twoline-hide-icon{
display: inline-block;
color: #0b0b0b;
font-weight: bold;
}
.twoline-hide-sum{
width: 250rpx;
color: #c1382d;
text-align: right;
font-weight: bold;
display: inline-block;
}
}
}
}
// 委托方等信息
.goods-props {
float: left;
font-size: 20rpx;
margin-top: 10rpx;
flex-basis: 100%;
color: #767285;
.goods-props-item {
margin-top: 10rpx;
}
.goods-props-bt {
float: right;
width: 120rpx;
height: 50rpx;
margin-top: -50rpx;
background-color: #26587b;
color: white;
border-radius: 50rpx;
.goods-props-bt-down {
text-align: center;
margin-top: 14rpx;
}
}
}
}
.goods-sum {
border-top: 1rpx #e8e8e8 solid;
font-size: 20rpx;
color: #767285;
font-weight: 600;
.goods-sum-date {
margin-top: 20rpx;
}
.goods-sum-time {
margin-top: 5rpx;
}
.goods-sum-amount {
color: #c1382d;
font-size: 28rpx;
margin-top: 40rpx;
}
.goods-sum-bt {
float: right;
width: 120rpx;
height: 50rpx;
margin-top: -50rpx;
background-color: #26587b;
color: white;
border-radius: 50rpx;
.goods-sum-bt-pay {
text-align: center;
margin-top: 14rpx;
}
}
}
}
</style>