Authored by hongyong.zhao

支付成功页添加

... ... @@ -39,6 +39,7 @@ class App extends Component {
'pages/userCenter/addressManager/addressEditer/addressEditer',
'pages/userCenter/addressManager/addressEditer/addressPicker',
'pages/order/orderConfirm/orderConfirm',
'pages/order/orderSuccess/orderSuccess',
],
window: {
backgroundTextStyle: 'light',
... ...
... ... @@ -46,8 +46,9 @@ export default class SelectSize extends Component {
}
onClickBuy() {
Taro.navigateTo({
url: `/pages/order/orderConfirm/orderConfirm?skup=${this.state.selectedskup}`,
let {product_id} = this.props;
this.state.canBuy && Taro.navigateTo({
url: `/pages/order/orderConfirm/orderConfirm?skup=${this.state.selectedskup}&&product_id=${product_id}`,
})
}
... ...
... ... @@ -11,16 +11,8 @@ Component({
type:Boolean,
value: false
},
userName: {
type: String,
value: ''
},
addressDetail: {
type: String,
value: ''
},
userPhone: {
type: String,
address: {
type: Object,
value: ''
}
},
... ... @@ -33,11 +25,11 @@ Component({
},
ready() {
console.log(this.properties)
},
methods: {
chooseAddress: function(){
this.triggerEvent('addressevent',{})
}
}
... ...
... ... @@ -4,9 +4,9 @@
<image class="addressHasIcon" src="{{addressIcon}}"></image>
</view>
<view class="addressRightContainer">
<text class="addressUserName">{{userName}}</text>
<text class="addressUserAddress">{{addressDetail}}</text>
<text class="addressUserPhone">{{userPhone}}</text>
<text class="addressUserName">{{address.consignee}}</text>
<text class="addressUserAddress">{{address.area + address.address}}</text>
<text class="addressUserPhone">{{address.mobile}}</text>
</view>
</view>
... ...
... ... @@ -22,7 +22,6 @@ Component({
allPriceLabel: '实付金额:',
},
ready() {
console.log(this.properties)
},
methods: {
//一个自定义方法
... ...
... ... @@ -5,45 +5,193 @@
*@description 订单支付确认界面
*/
import orderService from '../orderService'
import {getImgUrl} from '../../../utils';
Page({
data: {
productInfo: {
"colorId": 1,
"colorName": "红色",
"goodImg": "http://img11.static.yhbimg.com/goodsimg/2018/10/18/17/01699014e8981a532f27abc74730e40bbd.jpg?imageMogr2/thumbnail/90x90/background/d2hpdGU=/position/center/quality/80",
"goodPrice": "9.00",
"productName": "Air Jordan XX9 Low “Chicago Bulls”",
"sizeId": 2,
"sizeName": "M111",
"skup": 1468
},
"damagesDesc": "如卖家原因导致交易失败,您将获得赔偿金¥0.80元",
"promotionFormulaList": [{
"promotion": "商品金额",
"promotionAmount": "¥9.00"
}, {
"promotion": "运费",
"promotionAmount": "+ ¥0.0"
}, {
"promotion": "实付金额",
"promotionAmount": "¥9.00"
}],
"deliveryWay": {
"deliveryWayCost": "¥0.0",
"deliveryWayId": 2,
"deliveryWayName": "顺丰速运"
},
"paymentWay": {
"paymentType": 1,
"paymentTypeName": "在线支付"
},
payLabel: '待支付:',
payButton: '去支付',
amount: '9.00',
},
onLoad: function (option) {
console.log(option)
this.setData({
skup: option && option.skup ? option.skup : '',
product_id: option && option.product_id ? option.product_id : '',
hasAddress: false
})
this.fetchData()
this.fetchAddress()
},
fetchData() {
let api = new orderService();
wx.showLoading({
title: '',
});
let params = {
uid: '500031182',
skup: this.data.skup,
debug: 'XYZ'
}
api.createPaymentInfo(params, () => wx.hideLoading())
.then(data => {
if (data) {
if (data.good && data.good.goodImg) {
data.good.goodImg = getImgUrl(data.good.goodImg,90,90)
}
this.setData(data)
}
})
.catch(error => {
console.log(error)
})
},
fetchAddress() {
let api = new orderService().yohoApi()
wx.showLoading({
title: '',
})
let params = {
uid: '500031182',
debug: 'XYZ'
}
api.buyerGetAddress(params, () => wx.hideLoading())
.then(data => {
if (Array.isArray(data)){
for (let item of data) {
let index = data.indexOf(item)
if (item.is_default === 'Y') {
this.setData({
address: item,
hasAddress: true,
})
break
}
if (index == data.length - 1){
this.setData({
address: item,
hasAddress: true,
})
}
}
}
})
.catch(error => {
console.log(error)
})
},
submit() {
if (!this.data.hasAddress) {
wx.showToast({
title:'请选择地址'
})
return
}
let addressId = this.data.hasAddress && this.data.address && this.data.address.address_id
let skup = this.data.skup
let channelNo = ''
let uid = '500031182'
let api = new orderService()
wx.showLoading({
title: '',
})
api.buyerSubmit(uid,skup,channelNo,addressId, () => wx.hideLoading())
.then(data => {
if (data && data.orderCode) {
this.prePay(data.orderCode)
}
})
.catch(error => {
console.log(error)
})
},
prePay(orderCode) {
this.setData({
orderCode: orderCode
})
// return wx.navigateTo({
// url: `./orderSuccess?product_id=${this.data.product_id}&orderCode=${this.data.orderCode}`
// })
let uid = '500031182'
let api = new orderService()
wx.showLoading({
title: '',
})
api.prePay(uid,orderCode, () => wx.hideLoading())
.then(data => {
if (data && data.prePayData) {
this.callWxPay(data.prePayData)
}
})
.catch(error => {
console.log(error)
})
},
callWxPay(data) {
data.paySign = data.sign;
data.timeStamp = data.timestamp
data.nonceStr = data.noncestr
data.signType = 'MD5'
data.package = 'prepay_id=' + data.prepayid
wx.requestPayment({
...data,
success: function (res) {
wx.navigateTo({
url: `./orderSuccess?product_id=${this.data.product_id}&orderCode=${this.data.orderCode}`
})
},
fail: function (res) {
console.log(res)
if(res.errMsg=='requestPayment:fail cancel'){
// wx.redirectTo({
// url: '../orders/orders'
// })
}else{
wx.showModal({
content: res.errMsg,
showCancel: false,
confirmText: "确定",
complete: function(res) {
// wx.redirectTo({
// url: '../orders/orders'
// })
}
})
}
}
})
},
chooseAddress: function(){
// var pages = getCurrentPages();
// var prevPage = pages[pages.length - 2]; //上一个页面
// prevPage.setData({
// })
//
// wx.navigateBack();
wx.navigateTo({
url: '../../userCenter/addressManager/addressManager'
})
}
})
... ...
<view class="orderContainer">
<scroll-view scroll-x="false">
<addressCell hasAddress="{{true}}" userName="{{'哇哈哈'}}" addressDetail="{{'江苏省南京市建邺区嘉陵江东街国家广告产业园5栋17楼yoho有货'}}" userPhone="{{'1521045443'}}"></addressCell>
<productCell productInfo="{{productInfo}}"></productCell>
<addressCell hasAddress="{{hasAddress}}" address="{{address}}" bindaddressevent="chooseAddress"></addressCell>
<productCell productInfo="{{good}}"></productCell>
<priceCell promotionFormulaList="{{promotionFormulaList}}" damagesDesc="{{damagesDesc}}"></priceCell>
<payDeliveryCell paymentWay="{{paymentWay}}" deliveryWay="{{deliveryWay}}"></payDeliveryCell>
</scroll-view>
... ... @@ -14,7 +14,7 @@
<text class="payAmount">¥{{amount}}</text>
</view>
</view>
<view class="payBottomRight">
<view class="payBottomRight" bindtap="submit">
<text class="payButton">{{payButton}}</text>
</view>
... ...
/**
* orderService.js
*@author dennis
*@createtime 2018/10/29
*@description 订单相关网络请求
*/
import BaseService from '../../libs/services/baseService'
const CREATE_PAYMENTINFO = 'ufo.order.payment'
const BUYER_GETADDRESS = 'app.address.gethidden'
const BUYER_SUBMIT = 'ufo.order.submit'
const BUYER_PREPAY = 'ufo.order.pay'
const COMPUTE_COMPENSATE = 'ufo.buyer.computeCompensate'
const PRODUCT_RECOMMEND = 'ufo.product.data.search.recommend'
export default class orderService extends BaseService {
constructor(options) {
super(options)
}
async createPaymentInfo(params, complete) {
return await this.GET(
{
...params,
method: CREATE_PAYMENTINFO,
},
{
path: '/shopping',
complete
}
)
}
async buyerGetAddress(params, complete) {
return await this.GET({
...params,
method:BUYER_GETADDRESS
},{
complete
})
}
async buyerSubmit(uid,skup,channelNo='2919',addressId, complete) {
return await this.GET({
method: BUYER_SUBMIT,
uid,
skup,
channelNo,
addressId,
debug: 'XYZ'
},{
path: '/shopping',
complete
})
}
async prePay(uid, orderCode, complete) {
return await this.GET({
uid,
orderCode,
payment: 1,
method:BUYER_PREPAY,
debug: 'XYZ'
},{
path: '/payment',
complete
})
}
async getComputeCompensate(uid,orderCode, complete) {
return await this.GET({
uid,
orderCode,
method:COMPUTE_COMPENSATE,
debug: 'XYZ'
}, {
complete
})
}
async getRecommendList(product_id, complete) {
return await this.GET({
product_id,
method: PRODUCT_RECOMMEND,
debug: 'XYZ'
},{
complete
})
}
}
... ...
/**
* orderSuccess.js
*@author dennis
*@createtime 2018/10/30
*@description
*/
import orderService from '../orderService'
Page({
data: {
checkOrderButtonText: '查看订单',
lookAround: '随便逛逛',
recommendText: '买了此商品您可能喜欢',
paySuccessText: '支付成功!',
compensale: '',
_triggerObserer: true,
},
onLoad: function (option) {
option && this.setData({
product_id: option.product_id,
orderCode: option.orderCode
})
this.fetchComputeCompensate()
this.fetchRecommend()
},
fetchRecommend() {
let api = new orderService()
wx.showLoading({
title: '',
})
let product_id = this.data.product_id
api.getRecommendList(product_id, () => wx.hideLoading())
.then(data => {
data && data.product_list && this.setData({
product_list: data.product_list
})
let _triggerObserer = this.data._triggerObserer;
this.setData({
_triggerObserer: !_triggerObserer,
})
})
.catch(error => {
console.log(error)
})
},
fetchComputeCompensate() {
let api = new orderService()
wx.showLoading({
title: '',
})
let uid = '500031182' ;
let orderCode = this.data.orderCode;
api.getComputeCompensate(uid,orderCode, () => wx.hideLoading())
.then(data => {
this.setData({
compensale: data
})
})
.catch(error => {
console.log(error)
})
}
})
... ...
{
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTitleText": "",
"usingComponents": {
"product-list": "../../../components/product-list/index"
}
}
... ...
<view class="successContainer">
<view class="successTopContainer">
<view class="successIconContainer">
<image class="successIcon" src="../../../assets/images/success@3x.png"></image>
</view>
<text class="successText">{{paySuccessText}}</text>
<view>
<text class="compensateText"> 如卖家原因导致交易失败,您可获赔付{{compensale}}元保证金,建议您设置支付宝账号作为赔偿收款账户,如未绑定支付宝账号则视为放弃赔偿。</text>
</view>
<view class="checkOrderContainer">
<text class="checkOrderText">{{checkOrderButtonText}}</text>
</view>
<view>
<text class="lookAround">{{lookAround}}</text>
</view>
<view>
<text class="mayLike">{{recommendText}}</text>
</view>
</view>
<view class='collection-list'>
<product-list list="{{product_list}}" __triggerObserer="{{ _triggerObserer }}"></product-list>
</view>
</view>
... ...
.successContainer {
}
.successTopContainer {
margin-left: 76rpx;
margin-right: 76rpx;
}
.successIconContainer {
display: flex;
width: 100%;
justify-content: center;
align-items: center;
}
.successIcon {
width: 120rpx;
height: 120rpx;
}
.successText {
font-family: PingFang-SC-Semibold;
font-size: 40rpx;
color: #000000;
letter-spacing: 0;
text-align: center;
margin-top: 20rpx;
display: block;
}
.compensateText {
font-family: PingFang-SC-Regular;
font-size: 24rpx;
color: #999999;
letter-spacing: 0;
text-align: center;
line-height: 40rpx;
margin-top: 30rpx;
}
.checkOrderContainer {
background: #002B47;
display: flex;
width: 100%;
justify-content: center;
align-items: center;
height: 100rpx;
margin-top: 60rpx;
}
.checkOrderText {
font-family: PingFang-SC-Regular;
font-size: 32rpx;
color: #FFFFFF;
letter-spacing: 0;
text-align: center;
}
.lookAround {
font-family: PingFang-SC-Regular;
font-size: 28rpx;
color: #000000;
letter-spacing: 0;
text-align: center;
width: 100%;
margin-top: 40rpx;
display: block;
}
.mayLike {
font-family: PingFang-SC-Medium;
font-size: 40rpx;
color: #000000;
letter-spacing: 0;
margin-top: 112rpx;
margin-bottom: 32rpx;
width: 100%;
display: block;
text-align: center;
}
.collection-list {
width: 100%;
}
... ...
... ... @@ -126,7 +126,7 @@ export default class ProductDetail extends Component {
}
render() {
let {productInfo, recommendList, goodsList, productDec} = this.state;
let {productInfo, recommendList, goodsList, productDec, id} = this.state;
let imageList = goodsList.image_list || [];
return (
... ... @@ -184,9 +184,9 @@ export default class ProductDetail extends Component {
{
this.props.productDetail.showSizeBox &&
<SelectSize sizeList={goodsList.size_list}></SelectSize>
<SelectSize sizeList={goodsList.size_list} product_id={id}></SelectSize>
}
</View>
)
}
}
\ No newline at end of file
}
... ...