123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733 |
- <template>
- <view class="pages">
- <u-navbar
- title="团购订单"
- :placeholder="true"
- :autoBack="false"
- @leftClick="leftClick"
- :safeAreaInsetTop="true"
- >
- </u-navbar>
- <view class="tabs-wrap">
- <u-tabs
- :list="tabsList"
- lineColor="#EE0D0D"
- :current="tabsCurrent"
- :activeStyle="{color:'#EE0D0D','font-weight': '600','font-size':'30rpx'}"
- :inactiveStyle="{color:'#7F7F7F'}"
- itemStyle="width:20%;box-sizing:border-box;padding:24rpx"
- @click="tabsClick"></u-tabs>
- </view>
- <view class="page-wrap">
- <mescroll-body class="" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
- <view class="order">
- <view v-for="(item,index) in orderListWithClass" class="order-item"
- :class="item.class"
- @click="goOrderDetails(item)" :key="item.id">
- <view class="top u-flex u-row-between">
- <text>{{item.theatreName}}</text>
- <text>{{item.status|filterOrderState}}</text>
- </view>
- <view class="info u-flex u-col-top">
- <image class="img" :src="item.performImg"></image>
- <view class="text">
- <view class="name">{{item.performName}} - {{item.goodsName}}</view>
- <view class="time">{{item.performDate}} {{item.performTimeStart}}</view>
- {{item.performDate}}
- <view class="statistics">
- <text>共{{item.viewerNum}}张</text>
- <text class="label">合计:</text>
- <text class="price">¥{{item.realPrice}}</text>
- </view>
- </view>
- </view>
- <view class="btn-wrap u-flex u-row-right">
- <view
- class="btn"
- :class="btn.class"
- @click.stop="clickEven(btn.fun,item)"
- v-for="(btn,index) in statusBtn[item.status]" :key="index">
- {{btn.name}}
- </view>
- </view>
- </view>
- </view>
- </mescroll-body>
- </view>
- <u-toast ref="uToast"></u-toast>
- <u-picker
- :show="showPayTeamModal"
- :columns="[bindList]"
- keyName="bindTeamName"
- @confirm="onPickerConfirm"
- @cancel="cancelPayTeam"
- title="请选择支付团队"
- ></u-picker>
- <tabbar :tabbarIndexProps="1" />
- </view>
- </template>
- <script>
- import tabbar from "../components/tabbar.vue";
-
- import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
-
- import wxH5 from "weixin-jsapi";
-
- export default {
- mixins: [MescrollMixin],
- components:{
- tabbar
- },
- data() {
- return {
- downOption: {
- },
-
- upOption: {
-
-
-
-
-
-
-
- },
- staticUrl:this.$commonConfig.staticUrl,
- goodsKey:1,
- hasfetch:false,
- tabsCurrent:1,
- tabsList:[
- {name:'全部',status:null,},
- {name:'待支付',status:'0',badge:{isDot:false,value:null}},
- {name:'待使用',status:'3',badge:{isDot:false,value:null}},
- {name:'已完成',status:'7',badge:{isDot:false,value:null}},
- {name:'售后',status:'4,5,6',badge:{isDot:false,value:null}}
- ],
- status:'',
- dataList:[],
- statusBtn:{
-
- 0:[{name:'取消订单',fun:'cancelOrder',class:''},{name:'去支付',fun:'pay',class:'red'}],
- 1:[],
- 2:[],
- 3:[{name:'出示二维码',fun:'goOrderDetails',class:'red'}],
-
- 4:[],
- 5:[],
- 6:[],
-
- 7:[],
- 8:[],
- 9:[]
- },
- orderBadge:{
- noPayNum:0,
- deliverNum:0,
- collectNum:0,
- commentNum:0,
- refundNum:0,
- },
- templateIdList:[],
- bindList:[],
- showPayTeamModal: false,
- selectedTeamId: '',
- selectedOrderId: '',
- }
- },
- computed: {
- orderListWithClass() {
- return this.dataList.map(order => {
-
-
-
-
-
-
-
- return {
- ...order,
-
-
-
- class: {
- 0: 'status-0',
- 1: 'status-1',
- 2: 'status-2',
- 3: 'status-3',
- 4: 'status-4',
- 5: 'status-5',
- 6: 'status-6',
- 7: 'status-7',
- 8: 'status-8'
- }[order.status] || ''
- }
- })
- }
- },
- onLoad(page) {
-
- const status = page.status;
- const index = this.tabsList.findIndex(item => item.status === status);
- this.tabsCurrent = index>=0?index:0;
-
-
-
- },
- onShow() {
- setTimeout(()=>{
- this.hasfetch&&this.reloadList()
- },500);
-
- },
- methods: {
- leftClick(){
- uni.reLaunch({url: '/center/center'});
- },
-
- upCallback(page) {
-
-
-
-
-
-
-
-
-
-
-
-
- let pageNum = page.num;
- let pageSize = page.size;
-
- let params = {
- source:5,
- pageNum : page.num,
- pageSize : page.size,
- statusIn : this.tabsList[this.tabsCurrent]?.status||'',
- userid:this.vuex_member_info.id
-
- }
-
- this.$u.api.orderList(params).then(data => {
- this.hasfetch = true;
- console.log('data',JSON.parse(JSON.stringify(data)));
-
- let curPageData = data.data.rows;
-
-
- let curPageLen = curPageData.length;
-
-
-
- let totalSize = data.data.total;
-
-
-
-
- if(page.num == 1) this.dataList = [];
- this.dataList = this.dataList.concat(curPageData);
-
-
-
-
- this.mescroll.endBySize(curPageLen, totalSize);
- }).catch(err => {
- this.mescroll.endErr()
- console.log(err)
- });
-
- },
-
- reloadList() {
- this.mescroll.resetUpScroll();
- },
- tabsClick(item){
-
- this.tabsCurrent = item.index;
- this.reloadList()
-
- },
- goOrderDetails(item){
- uni.$u.route('/center/orderdetails', {
- id: item.id
- });
- },
- toggleMore(item,index){
-
- this.orderListWithClass[index].showMore = !this.orderListWithClass[index].showMore
- this.goodsKey++;
- },
- clickEven(fun,item){
-
- let funObj = {
- pay: this.pay,
- goOrderDetails:this.goOrderDetails,
- evaluate:this.evaluate,
- refund:this.refund,
- cancelOrder:this.cancelOrder,
- viewRefund:this.viewRefund,
- confirmReceipt:this.confirmReceipt,
- viewEvaluate:this.viewEvaluate
- };
-
- if (fun in funObj) {
- funObj[fun](item);
- }
- },
- getTemplateIdList(){
- this.$u.api.templateIdList({templateLabel:'order_pay'}).then(res=>{
- console.log('getTemplateIdList',res.data);
- this.templateIdList = res.data.list.map(item=>{
- return item.templateId
- });
-
-
-
- }).catch(err=>{
- console.log('getTemplateIdList',err);
- })
- },
- async pay(item){
- console.log('pay',item);
- let bindListData = await this.$u.api.getBindList();
- let bindList = bindListData.data?.list;
- this.bindList = bindList;
- this.selectedOrderId = item.id;
-
-
- if(bindList.length>1){
- this.showPayTeamModal = true;
- this.selectedTeamId = bindList[0].bindTeamId;
- } else if(bindList.length === 1) {
-
- this.goToPayPage(item.id, bindList[0].bindTeamId, item.orderPrice);
- } else {
- uni.showToast({
- title: '没有可用的支付团队',
- icon: 'none'
- });
- }
- },
- evaluate(item){
-
- uni.$u.route('/shopping/evaluate', {
- id: item.id
- });
- },
- comment(orderId,orderDetailId,goodsId){
- uni.$u.route('/shopping/addcomment', {
- orderId,
- orderDetailId,
- goodsId
- });
- },
- viewComment(orderDetailId,goodsId,goods){
- uni.$u.route('/shopping/viewcomment', {
- orderDetailId,
- goodsId,
- goods:JSON.stringify(goods)
- });
- },
- refund(item){
-
- uni.$u.route('/shopping/refund', {
- id: item.id
- });
- },
- cancelOrder(item){
- let that = this;
- uni.showModal({
- title: '提示',
- content: '确认取消吗!',
- success: res => {
- if (res.confirm) {
- this.$u.api.cancelOrder({orderId:item.id}).then(res=>{
- this.$refs.uToast.show({
- message:res.msg,
- complete() {
- that.reloadList();
- }
- });
-
- console.log('res',res.data);
- }).catch(err=>{
- console.log('cancelOrder',err);
- })
- }
- }
- });
-
-
- },
- viewRefund(item){
- uni.$u.route('/center/viewRefund', {
- orderId: item.id
- });
- },
- confirmReceipt(item){
- let that = this;
- uni.showModal({
- title: '提示',
- content: '确认收货吗!',
- success: res => {
- if (res.confirm) {
- this.$u.api.confirmReceipt({orderId:item.id}).then(res=>{
- uni.showToast({
- title:res.msg,
- duration:2000,
- complete() {
- that.reloadList();
- }
- });
- console.log('res',res.data);
- }).catch(err=>{
- console.log('confirmReceipt',err);
- })
- }
- }
- })
- },
- viewEvaluate(item){
- uni.$u.route('/shopping/orderdetails', {
- id: item.id
- });
- },
-
- setTemplate(orderId) {
- let that = this;
- console.log('templateIdList',this.templateIdList);
- uni.requestSubscribeMessage({
- tmplIds: that.templateIdList,
- success (res) {
-
- console.log("success:",res);
- },
- fail (res) {
- console.log("fail:",res);
- },
- complete (res) {
- that.gotoPay(orderId);
- console.log("complete:",res);
- }
- })
- },
- gotoPay(orderId){
- this.$u.api.gotoPay({orderId:orderId,openid:''}).then(res=>{
- this.payResult = res.data.payInfo;
- this.payResult.package = res.data.payInfo.packageValue;
-
- this.initConfig(this.payResult)
-
-
- this.wxPay()
-
-
-
-
-
-
- console.log('gotoPayres',res.data);
- }).catch(err=>{
- this.paypass = '';
- this.checkPassShow = false;
- console.log('gotoPay',err);
- })
- },
- wxPay(){
- let that = this;
- uni.requestPayment({
- ... this.payResult,
- "provider": "wxpay",
- "orderInfo": {
-
-
-
-
-
-
-
- },
- success(res) {
- setTimeout(()=>{
- this.tabsCurrent = 2;
- this.reloadList();
- },1500)
-
- },
- fail(e) {
- console.log('wxPayfail',e);
- }
- })
- },
- payQuery(){
- let that = this;
- let retryCount = 0;
- let maxRetryCount = 5;
- let interval = 2000;
- let timeout = 10000;
- let timer;
- uni.showLoading({
- title:'支付结果查询中'
- })
- timer = setInterval(() => {
- retryCount++;
- if (retryCount > maxRetryCount || retryCount * interval > timeout) {
- clearInterval(timer);
- uni.hideLoading();
- console.log("支付查询超时或达到最大重试次数");
-
- this.reloadList()
- } else {
- console.log("第" + retryCount + "次查询");
-
-
-
- this.$u.api.payQuery({orderId:this.orderId}).then(res=>{
-
- let payStatus = res.data.payStatus;
- if(payStatus===1){
- uni.$u.route('/center/paysuccess');
- }else if(payStatus===0||payStatus===2){
- this.payQuery()
- }else if(payStatus===3){
- uni.toast('支付失败')
- }
- clearInterval(timer);
- }).catch(err=>{
- console.log('payQuery',err);
- }).finally(()=>{
- uni.hideLoading()
- })
- }
- }, interval);
- },
- statisticsOrder(){
- this.$u.api.statisticsOrder().then(res=>{
- let data = res.data || {};
- this.orderBadge = Object.assign(this.orderBadge,data);
- let {noPayNum,deliverNum,collectNum,commentNum,refundNum} = res.data;
- let noPayNumindex = this.tabsList.findIndex(item => item.status == 0);
- this.tabsList[1].badge.isDot = false;
- this.tabsList[1].badge.value = noPayNum;
- this.tabsList[2].badge.isDot = false;
- this.tabsList[2].badge.value = deliverNum;
- this.tabsList[3].badge.isDot = false;
- this.tabsList[3].badge.value = collectNum;
- this.tabsList[4].badge.isDot = false;
- this.tabsList[4].badge.value = commentNum;
- this.tabsList[5].badge.isDot = false;
- this.tabsList[5].badge.value = refundNum;
-
-
- }).catch(err=>{
- console.log('memberInfo',err.data);
- })
- },
-
- initConfig() {
-
- let that = this
- wxH5.config({
- debug: false,
- appId: that.payResult.appId,
- timestamp: that.payResult.timeStamp,
- nonceStr: that.payResult.nonceStr,
- signature: that.payResult.paySign,
- jsApiList: ['chooseWXPay', 'checkJsApi']
- })
- wxH5.ready(() => {
- wxH5.chooseWXPay({
- timestamp: that.payResult.timeStamp,
- nonceStr: that.payResult.nonceStr,
- package: that.payResult.packageValue,
- signType: 'SHA1',
- paySign: that.payResult.paySign,
- success: () => {
- setTimeout(()=>{
- that.tabsCurrent = 2;
- that.reloadList();
- },1500)
-
- },
- fail: (e) => {
- uni.$u.route('/center/order', {
- status: 0
- });
- console.log('wxPayfail', e);
- },
- cancel: () => {
- uni.$u.route('/center/order', {
- status: 0
- });
- that.cansubmit = true;
- }
- })
- })
-
- },
- confirmPayTeam() {
- if(!this.selectedTeamId) {
- uni.showToast({
- title: '请选择支付团队',
- icon: 'none'
- });
- return;
- }
- this.showPayTeamModal = false;
- this.goToPayPage(this.selectedOrderId, this.selectedTeamId, this.dataList.find(item => item.id === this.selectedOrderId)?.orderPrice);
- },
- cancelPayTeam() {
- this.showPayTeamModal = false;
- this.selectedTeamId = '';
- this.selectedOrderId = '';
- },
- onPickerConfirm(e) {
- const selectedTeam = e.value[0];
- this.selectedTeamId = selectedTeam.bindTeamId;
- this.showPayTeamModal = false;
- this.goToPayPage(this.selectedOrderId, this.selectedTeamId, this.dataList.find(item => item.id === this.selectedOrderId)?.orderPrice);
- },
- goToPayPage(orderId, payerId, payAmount) {
- uni.$u.route('/center/pay', {
- orderId: orderId,
- payAmount: payAmount,
- payerId: payerId
- });
- },
- }
- }
- </script>
- <style>
- page{
- background-color: #F5F5F5;
- }
- </style>
- <style lang="scss" scoped>
- .tabs-wrap{
- background-color: #fff;
- margin-bottom: 10rpx;
- }
- .list-item{
- overflow: hidden;
- width: 48%;
- margin-bottom: 30rpx;
- background-color: #fff;
- .image-wrap{
- margin-bottom: 20rpx;
- }
- }
- .order-item{
- margin-bottom: 20rpx;
- background: #FFFFFF;
- box-shadow: 0rpx 2rpx 12rpx 0rpx rgba(221,221,221,0.5);
- border-radius: 20rpx;
- padding: 32rpx;
- content-visibility: auto;
- contain-intrinsic-size: 346rpx;
- .top{
- font-size: 24rpx;
- font-weight: 400;
- color: #7F7F7F;
- line-height: 36rpx;
- margin-bottom: 36rpx;
- }
- .info{
- margin-bottom: 30rpx;
- .img{
- width: 180rpx;
- height: 160rpx;
- }
- .text{
- font-size: 24rpx;
- font-weight: 400;
- color: #7F7F7F;
- padding-left: 26rpx;
- flex: 1;
- .name{
- font-size: 28rpx;
- font-weight: bold;
- color: #363636;
- margin-bottom: 20rpx;
- }
- .time{
- margin-bottom: 20rpx;
- }
- .position{
- margin-bottom: 20rpx;
- }
- .statistics{
- text-align: right;
- }
- .label{
- font-size: 24rpx;
- font-weight: 400;
- color: #363636;
- margin-left: 10rpx;
- }
- .price{
- font-size: 32rpx;
- font-weight: bold;
- color: #ED0000;
- }
- }
- }
- .btn-wrap{
-
- }
- .btn{
- padding: 12rpx 40rpx;
- border: 1px solid #E5E5E5;
- color: #7F7F7F;
- text-align: center;
- border-radius: 8rpx;
- font-size: 24rpx;
- &.red{border-color: #ED0000;color: #ED0000;}
- &.red.solid{border-color: #ED0000;background-color:#ED0000;color: #fff;}
- &.green{color: #00A447;border-color: #00A447;}
- &:not(:first-child){
- margin-left: 20rpx;
- }
- }
- &.status-0{.status{color:#FF3C3F;}}
- &.status-1{.status{color:#FF3C3F;}}
- &.status-2{.status{color:#0099EB;}}
- &.status-3{.status{color:#00A447;}}
- &.status-4{.status{color:#FF3C3F;}}
- &.status-5{.status{color:#FF3C3F;}}
- &.status-6{.status{color:#FF3C3F;}}
- &.status-7{.status{color:#FFB100;}}
- }
- .pay-team-content {
- padding: 20rpx;
-
- .radio-item {
- display: flex;
- align-items: center;
- padding: 20rpx 0;
-
- .radio-text {
- margin-left: 20rpx;
- font-size: 28rpx;
- color: #363636;
- }
- }
- }
- </style>
|