|
@@ -1,9 +1,10 @@
|
|
|
<template>
|
|
|
<view class="pages">
|
|
|
<view class="status-bar">
|
|
|
- <view class="status-bar-item" :class="params.status == -1?'active':''" @click="changestatus(-1)">全部</view>
|
|
|
- <view class="status-bar-item" :class="params.status == 0?'active':''" @click="changestatus(0)">未完成</view>
|
|
|
- <view class="status-bar-item" :class="params.status == 1?'active':''" @click="changestatus(1)">已完成</view>
|
|
|
+ <view class="status-bar-item" :class="params.orderStatus != 1&¶ms.orderStatus != 5&¶ms.orderStatus != 2?'active':''" @click="changestatus()">全部</view>
|
|
|
+ <view class="status-bar-item" :class="params.orderStatus == 1?'active':''" @click="changestatus(1)">未支付</view>
|
|
|
+ <view class="status-bar-item" :class="params.orderStatus == 2?'active':''" @click="changestatus(2)">已支付</view>
|
|
|
+ <view class="status-bar-item" :class="params.orderStatus == 5?'active':''" @click="changestatus(5)">已完成</view>
|
|
|
</view>
|
|
|
<mescroll-body class="" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
|
|
|
<view class="orders">
|
|
@@ -14,13 +15,12 @@
|
|
|
<view class="order-info-text-item">订单时间:{{item.createTime}}</view>
|
|
|
</view>
|
|
|
<view class="order-info-status">
|
|
|
- <view class="status" v-if="item.status == 0" @click="cancelOrder(item)">取消订单</view>
|
|
|
- <view class="status topay" v-if="item.status == 0">待付款</view>
|
|
|
- <view class="status" v-if="item.orderStatus == 1">待发货</view>
|
|
|
- <view class="status" v-if="item.orderStatus == 2">已发货</view>
|
|
|
- <view class="status" v-if="item.orderStatus == 3">已完成</view>
|
|
|
- <view class="status" v-if="item.orderStatus == 4">已关闭</view>
|
|
|
- <view class="status" v-if="item.orderStatus == 5">失效</view>
|
|
|
+ <view class="status" v-if="item.orderStatus == 1" @click="cancelOrder(item)">取消订单</view>
|
|
|
+ <!-- <view class="status" v-if="item.orderStatus == 1">待支付</view> -->
|
|
|
+ <view class="status" v-if="item.orderStatus == 2">已支付</view>
|
|
|
+ <view class="status" v-if="item.orderStatus == 3">未审核</view>
|
|
|
+ <view class="status" v-if="item.orderStatus == 4">已审核</view>
|
|
|
+ <view class="status" v-if="item.orderStatus == 5">已完成</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- order-info end -->
|
|
@@ -35,8 +35,9 @@
|
|
|
<text class="amount">{{item.orderAmount}}</text>
|
|
|
</view>
|
|
|
<view class="order-product-carbon">共{{item.orderCarbonAmount}}kg碳汇量</view>
|
|
|
- <view class="order-btn topay" v-if="item.status == 0" @click.stop="pay(item)">立即支付</view>
|
|
|
- <view class="order-btn" v-if="item.status == 3" @click.stop="$api.href('/pages/usercenter/certificateList/certificate?id='+item.id)">查看证书</view>
|
|
|
+ <view class="order-btn topay" v-if="item.orderStatus == 1" @click.stop="pay(item)">立即支付</view>
|
|
|
+ <view class="order-btn" v-if="item.orderStatus == 2" @click.stop="$api.href('/pages/usercenter/certificateList/certificate?id='+item.id)">查看证书</view>
|
|
|
+ <view class="order-btn" v-if="item.orderStatus == 5" @click.stop="$api.href('/pages/usercenter/certificateList/certificate?id='+item.id)">查看证书</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -82,18 +83,14 @@
|
|
|
tip: '暂无相关数据'
|
|
|
}
|
|
|
},
|
|
|
- tokenhead:'',
|
|
|
- token:this.config.testToken,
|
|
|
+ tokenhead:'Bearer',
|
|
|
+ token:'',
|
|
|
params:{
|
|
|
- status:-1,
|
|
|
+ orderStatus:'',
|
|
|
// tokenhead:'',
|
|
|
// token:'',
|
|
|
},
|
|
|
- orderlist:[
|
|
|
- {orderNo:'10383902903920',time:'2020-5-14 09:00',image:'http://placekitten.com/202/202',amount:'55555',tyepNum:'3',saleNum:'60',status:'0'},
|
|
|
- {orderNo:'10383902903920',time:'2020-5-14 09:00',image:'http://placekitten.com/202/202',amount:'55555',tyepNum:'3',saleNum:'60',status:'3'},
|
|
|
- {orderNo:'10383902903920',time:'2020-5-14 09:00',image:'http://placekitten.com/202/202',amount:'55555',tyepNum:'3',saleNum:'60',status:'5'}
|
|
|
- ],
|
|
|
+ orderlist:[],
|
|
|
cancelId:null,
|
|
|
receiveId:null,
|
|
|
popupContent:'',
|
|
@@ -102,29 +99,9 @@
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
|
- let serf = this;
|
|
|
- //检查登录,获取token
|
|
|
- // let loginRes = this.checkLogin('/pages/index/index', '2');
|
|
|
- // if(!loginRes){return false;}
|
|
|
- // serf.params.token=loginRes[0];
|
|
|
+ this.token = this.$store.state.token;
|
|
|
},
|
|
|
onLoad() {
|
|
|
- let self = this;
|
|
|
- uni.getStorage({
|
|
|
- key:'token',
|
|
|
- success: function (res) {
|
|
|
- self.token = res.data;
|
|
|
- // console.log(res.data);
|
|
|
- }
|
|
|
- });
|
|
|
- uni.getStorage({
|
|
|
- key:'tokenhead',
|
|
|
- success: function (res) {
|
|
|
- self.tokenhead = res.data;
|
|
|
- // console.log(res.data);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
},
|
|
|
methods: {
|
|
|
/*mescroll组件初始化的回调,可获取到mescroll对象 (此处可删,mixins已默认)*/
|
|
@@ -136,13 +113,53 @@
|
|
|
// 第2种: 下拉刷新和上拉加载调同样的接口, 那么不用第1种方式, 直接mescroll.resetUpScroll()即可
|
|
|
this.mescroll.resetUpScroll(); // 重置列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
|
|
|
},
|
|
|
+ getList(page,token){
|
|
|
+ this.$api.http.post(this.config.apiBaseurl + '/carbon-h5/wap/order/searchByPage',this.params,{
|
|
|
+ header: {
|
|
|
+ Accept:'application/json',
|
|
|
+ Authorization: 'Bearer '+ token, //注意Bearer后面有一空格
|
|
|
+ },
|
|
|
+ }).then(data => {
|
|
|
+ // console.log(data);
|
|
|
+ // 接口返回的当前页数据列表 (数组)
|
|
|
+ let curPageData = data.data.retBody;
|
|
|
+ // console.log('curPageData',curPageData);
|
|
|
+ // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
|
|
|
+ let curPageLen = curPageData.length;
|
|
|
+ // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
|
|
|
+ // let totalPage = data.xxx;
|
|
|
+ // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
|
|
|
+ let totalSize = data.data.retHead.total;
|
|
|
+ // this.mescrollList = curPageData;
|
|
|
+ // 接口返回的是否有下一页 (true/false)
|
|
|
+ // let hasNext = data.xxx;
|
|
|
+
|
|
|
+ //设置列表数据
|
|
|
+ if(page.num == 1) this.orderlist = []; //如果是第一页需手动置空列表
|
|
|
+ this.orderlist = this.orderlist.concat(curPageData); //追加新数据
|
|
|
+ // console.log('page.num',page.num);
|
|
|
+ console.log('this.orderlist',JSON.parse(JSON.stringify(this.orderlist)));
|
|
|
+
|
|
|
+ //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
|
|
|
+ this.mescroll.endBySize(curPageLen, totalSize);
|
|
|
+
|
|
|
+ // setTimeout(()=>{
|
|
|
+ // this.mescroll.endSuccess(curPageLen)
|
|
|
+ // },20)
|
|
|
+
|
|
|
+ }).catch(err => {
|
|
|
+ this.mescroll.endErr()
|
|
|
+ console.log(err)
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
/*上拉加载的回调*/
|
|
|
upCallback(page) {
|
|
|
+ let self = this;
|
|
|
let pageNum = page.num; // 页码, 默认从1开始
|
|
|
let pageSize = page.size; // 页长, 默认每页10条
|
|
|
- this.params = Object.assign(this.params,{pageNum:pageNum,pageSize:pageSize});
|
|
|
- let thetoken = 'Bearer ' + this.token;
|
|
|
- // console.log('thetoken',thetoken);
|
|
|
+ this.params = Object.assign(this.params,{pageNum:pageNum,pageSize:pageSize});
|
|
|
this.$api.http.post(this.config.apiBaseurl + '/carbon-h5/wap/order/searchByPage',this.params,{
|
|
|
header: {
|
|
|
Accept:'application/json',
|
|
@@ -171,7 +188,7 @@
|
|
|
|
|
|
//方法二(推荐): 后台接口有返回列表的总数据量 totalSize
|
|
|
this.mescroll.endBySize(curPageLen, totalSize);
|
|
|
-
|
|
|
+
|
|
|
// setTimeout(()=>{
|
|
|
// this.mescroll.endSuccess(curPageLen)
|
|
|
// },20)
|
|
@@ -232,7 +249,7 @@
|
|
|
done()
|
|
|
},
|
|
|
changestatus(status){
|
|
|
- this.params.status = status;
|
|
|
+ this.params.orderStatus = status;
|
|
|
this.downCallback();
|
|
|
},
|
|
|
goOrderDetails(id){
|
|
@@ -242,17 +259,44 @@
|
|
|
});
|
|
|
},
|
|
|
pay(item){
|
|
|
+ console.log('pay item',item);
|
|
|
let userInfo = uni.getStorageSync("userInfo");
|
|
|
- let params = {
|
|
|
- orderId:item.id,
|
|
|
- payType:item.payType,
|
|
|
- openid:userInfo.wxUsers.openid,
|
|
|
- "tradeType":"test"
|
|
|
- }
|
|
|
- this.$pay.wxPay(params).then(res =>{
|
|
|
- this.downCallback();
|
|
|
- // console.log('payres',res);
|
|
|
- }).catch(err =>{console.log('err',err);});
|
|
|
+ console.log('userInfo',userInfo);
|
|
|
+ // return
|
|
|
+ let params = {
|
|
|
+ orderId:item.guid,
|
|
|
+ // payType:item.payType,
|
|
|
+ openid:userInfo.wxId,
|
|
|
+ "tradeType":"test"
|
|
|
+ };
|
|
|
+ this.$api.http.post(this.config.apiBaseurl + "/carbon-h5/wechat/pay",params,{
|
|
|
+ header: {
|
|
|
+ Accept:'application/json',
|
|
|
+ Authorization: 'Bearer '+ this.token, //注意Bearer后面有一空格
|
|
|
+ },
|
|
|
+ }).then(res=>{
|
|
|
+ uni.requestPayment({
|
|
|
+ provider: 'wxpay',
|
|
|
+ timeStamp:res.data.retBody.timeStamp,
|
|
|
+ nonceStr: res.data.retBody.nonceStr,
|
|
|
+ package: res.data.retBody.packageValue,
|
|
|
+ signType: 'MD5',
|
|
|
+ paySign: res.data.retBody.paySign,
|
|
|
+ success: function (res) {
|
|
|
+ console.log('success:' + JSON.stringify(res));
|
|
|
+ },
|
|
|
+ fail: function (err) {
|
|
|
+ console.log('fail:' + JSON.stringify(err));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }).catch( err =>{
|
|
|
+ console.log('pay err',err)
|
|
|
+ })
|
|
|
+
|
|
|
+ // this.$pay.wxPay(params).then(res =>{
|
|
|
+ // this.downCallback();
|
|
|
+ // // console.log('payres',res);
|
|
|
+ // }).catch(err =>{console.log('err',err);});
|
|
|
},
|
|
|
|
|
|
}
|