Authored by 黄敬囿

优化我的收入 review by 李其昌

// src/components/order/orderButton.js
import OrderActionService from './orderActionService.js';
const DEL_ORDER = 'del_order';
const BUY_AGAIN = 'buy_again';
const CANCEL_ORDER = 'cancel_order';
const NOW_BUY = 'now_buy';
//订单操作接口
const UFO_BUYER_DELETE_ORDER = 'ufo.buyer.delete';
const UFO_BUYER_CANCEL_ORDER = 'ufo.buyer.cancel';
const api = new OrderActionService();
Component({
/**
* 组件的属性列表
*/
properties: {
button: Object,
cIndex: Number,
lastIndex: Number,
isLast: Boolean,
orderCode: String,
},
/**
* 组件的初始数据
*/
data: {
isSelected: false,
},
lifetimes: {
},
attached: function () {
let that = this;
// let buttonInfo = that.button;
// let code = buttonInfo.code;
console.log(that.cIndex + "====orderCode===" + that.orderCode + "===" +that.isLast);
// let sum = that.id + 1;
// if (that.length === sum){
// that.setData({isSelected : true});
// }
},
/**
* 组件的方法列表
*/
methods: {
onButtonClick: function (e) {
let actionCode = e.currentTarget.dataset.buttonCode;
let orderCode = e.currentTarget.dataset.orderCode;
let productId = e.currentTarget.dataset.productId;
if (actionCode == BUY_AGAIN) {
wx.navigateTo({
url: '/pages/productDetail/index?id=' + productId,
})
} else if (actionCode == NOW_BUY) {
console.log("== 去支付页面===")
wx.navigateTo({
//todo:
//url: '/pages/productDetail/index?id=' + productId,
})
} else {
this.triggerEvent('buttonClick', actionCode)
// this.showDialog(orderCode, actionCode);
}
},
/**
* 订单操作
*/
actionOrder: function (orderCode, method) {
let that = this;
wx.showLoading({
title: '加载中...',
})
let params = {
uid: '500031132',
method: method,
orderCode: orderCode,
debug: 'XYZ',
}
api.actionOrder(params, () => {
wx.hideLoading();
}).then(data => {
event.emit('refresh-order');
});
},
/**
* 确认Dialog
*/
showDialog: function (orderCode, actionType, ) {
let that = this;
let content = '';
let method = '';
if (actionType == DEL_ORDER) {
content = '您确定删除订单?';
method = UFO_BUYER_DELETE_ORDER;
} else if (actionType == CANCEL_ORDER) {
content = '您确定取消订单?';
method = UFO_BUYER_CANCEL_ORDER;
}
wx.showModal({
// title: title,
content: content,
showCancel: true,
cancelText: "确定",
cancelColor: '#000000',
confirmText: "取消",
confirmColor: '#E0E0E0',
success: function (res) {
if (res.cancel) {
that.actionOrder(orderCode, method);
} else {
//点击取消,默认隐藏弹框
}
},
fail: function (res) { },
complete: function (res) { },
})
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<!--src/components/order/orderButton.wxml-->
<!-- <block wx:for="buttons" wx:key="{{index}}"> -->
<button class='order-action-unselected-button' bind:buttonClick='onButtonClick' data-button-code='{{button.code}}'>{{button.text}}</button>
<!-- </block> -->
/* src/components/order/orderButton.wxss */
.order-action-selected-button {
/* display: flex; */
/* align-items: center; */
font-family: PingFang-SC-Medium;
font-size: 24rpx;
color: #FFFFFF;
background-color: #002B47;
border-radius: 0;
margin-left: 20rpx;
/* padding-top: 20rpx; */
/* padding-bottom: 20rpx; */
/* padding-left: 40rpx; */
/* padding-right: 40rpx; */
}
.order-action-unselected-button::after {
/* border-style: none; */
border-radius: 0;
}
.order-action-unselected-button {
width: 224rpx;
/* display: flex; */
/* align-items: center; */
font-family: PingFang-SC-Regular;
/* font-size: 24rpx; */
color: #999999;
background-color: #FFFFFF;
border: 2rpx solid #CCCCCC;
border-radius: 0;
margin-left: 20rpx;
/* padding-top: 20rpx;
padding-bottom: 20rpx;
padding-left: 40rpx;
padding-right: 40rpx; */
/* border-style: none; */
/* margin-left: 20rpx; */
/* padding-left: 40rpx;
padding-right: 40rpx; */
}
.order-action-left-view {
display: flex;
flex-direction: row;
align-items: center;
}
\ No newline at end of file
{
"component": true,
"usingComponents": {
"orderbutton":"./orderButton"
}
}
\ No newline at end of file
... ...
... ... @@ -130,7 +130,7 @@ Page({
goodsIncome: '0.00',
compensateIncome: '0.00',
}
let summary = constSummary;//data.summary ? data.summary : constSummary;
let summary = data.summary ? data.summary : constSummary;
if(detail){
detail = that.data.data.concat(detail);
} else {
... ...
... ... @@ -9,7 +9,7 @@
</view>
</view>
<view class='assets-record-right-view'>
<text class='assets-record-income-txt'>{{item.amount}}</text>
<text class='assets-record-income-txt'>+{{item.amount}}</text>
<text class='assets-record-income-tip-txt' wx:if="{{!item.normalFlag}}">打款失败</text>
</view>
</view>
... ...