mirror of
https://gitee.com/zongzhige/shopxo-uniapp.git
synced 2026-06-06 02:38:52 +08:00
1.支付优化
This commit is contained in:
24
App.vue
24
App.vue
@ -67,11 +67,11 @@
|
||||
// tabbar页面
|
||||
tabbar_pages: ['/pages/index/index', '/pages/goods-category/goods-category', '/pages/cart/cart', '/pages/user/user'],
|
||||
// 请求地址
|
||||
// request_url: "https://d1.shopxo.vip/",
|
||||
request_url: 'http://shopxo.com/',
|
||||
request_url: 'https://d1.shopxo.vip/',
|
||||
// request_url: 'http://shopxo.com/',
|
||||
// 静态资源地址(如系统根目录不在public目录下面请在静态地址后面加public目录、如:https://d1.shopxo.vip/public/)
|
||||
// static_url: "https://d1.shopxo.vip/",
|
||||
static_url: 'http://shopxo.com/',
|
||||
static_url: 'https://d1.shopxo.vip/',
|
||||
// static_url: 'http://shopxo.com/',
|
||||
// 系统类型(默认default、如额外独立小程序、可与程序分身插件实现不同主体小程序及支付独立)
|
||||
system_type: 'default',
|
||||
// 基础信息
|
||||
@ -1749,7 +1749,7 @@
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// 获取主题色值
|
||||
// is_light 是否获取浅主色(false, true)
|
||||
get_theme_color(is_light = false) {
|
||||
@ -1763,7 +1763,7 @@
|
||||
orange: '#fe6f04', // 橙色
|
||||
brown: '#8B4513', // 棕色
|
||||
purple: '#623cec', // 紫色
|
||||
|
||||
|
||||
// 浅主色
|
||||
yellow_light: '#ffebd2', // 黄色
|
||||
red_light: '#ffdbe2', // 红色
|
||||
@ -1816,25 +1816,25 @@
|
||||
|
||||
// 整体样式
|
||||
uni.setTabBarStyle({
|
||||
selectedColor: this.get_theme_color(),
|
||||
selectedColor: this.get_theme_color(),
|
||||
});
|
||||
|
||||
// 菜单
|
||||
uni.setTabBarItem({
|
||||
index: 0,
|
||||
selectedIconPath: 'static/images/'+theme+'/tabbar/home.png',
|
||||
selectedIconPath: 'static/images/' + theme + '/tabbar/home.png',
|
||||
});
|
||||
uni.setTabBarItem({
|
||||
index: 1,
|
||||
selectedIconPath: 'static/images/'+theme+'/tabbar/category.png',
|
||||
selectedIconPath: 'static/images/' + theme + '/tabbar/category.png',
|
||||
});
|
||||
uni.setTabBarItem({
|
||||
index: 2,
|
||||
selectedIconPath: 'static/images/'+theme+'/tabbar/cart.png',
|
||||
selectedIconPath: 'static/images/' + theme + '/tabbar/cart.png',
|
||||
});
|
||||
uni.setTabBarItem({
|
||||
index: 3,
|
||||
selectedIconPath: 'static/images/'+theme+'/tabbar/user.png',
|
||||
selectedIconPath: 'static/images/' + theme + '/tabbar/user.png',
|
||||
});
|
||||
},
|
||||
|
||||
@ -1889,7 +1889,7 @@
|
||||
} else {
|
||||
return uri + separator + key + '=' + value;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
// 初始化完成时触发(全局只触发一次)
|
||||
onLaunch(params) {},
|
||||
|
||||
@ -123,6 +123,16 @@
|
||||
return {};
|
||||
},
|
||||
},
|
||||
// 支付失败跳转页面
|
||||
propTofailPage: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
//
|
||||
propIsRedirectTo: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
components: {
|
||||
componentPopup,
|
||||
@ -242,8 +252,11 @@
|
||||
// 是否直接支付成功
|
||||
if ((res.data.data.is_success || 0) == 1) {
|
||||
// 数据设置
|
||||
this.order_item_pay_success_handle(data, order_id);
|
||||
this.order_item_pay_success_handle(data, order_id, false);
|
||||
app.globalData.showToast('支付成功', 'success');
|
||||
setTimeout(() => {
|
||||
this.to_success_page_event();
|
||||
}, 2000);
|
||||
} else {
|
||||
// 支付方式类型
|
||||
let payment_type = Number(res.data.data.is_payment_type || 0);
|
||||
@ -266,6 +279,7 @@
|
||||
break;
|
||||
// 线下支付
|
||||
case 1:
|
||||
// 现金支付
|
||||
uni.showModal({
|
||||
content: res.data.msg,
|
||||
success(res) {
|
||||
@ -281,7 +295,6 @@
|
||||
// 钱包支付
|
||||
case 2:
|
||||
this.order_item_pay_success_handle(data, order_id);
|
||||
app.globalData.showToast('支付成功', 'success');
|
||||
break;
|
||||
// 默认
|
||||
default:
|
||||
@ -317,14 +330,6 @@
|
||||
success: (res) => {
|
||||
// 数据设置
|
||||
self.order_item_pay_success_handle(data, order_id);
|
||||
let url_data = {
|
||||
code: '9000',
|
||||
};
|
||||
url_data = Object.assign({}, url_data, this.propToPage);
|
||||
// 跳转支付页面
|
||||
uni.navigateTo({
|
||||
url: '/pages/paytips/paytips?params=' + encodeURIComponent(base64.encode(JSON.stringify(url_data))),
|
||||
});
|
||||
},
|
||||
fail: (res) => {
|
||||
app.globalData.showToast('支付失败');
|
||||
@ -366,14 +371,6 @@
|
||||
// #endif
|
||||
// 数据设置
|
||||
self.order_item_pay_success_handle(data, order_id);
|
||||
let url_data = {
|
||||
code: '9000',
|
||||
};
|
||||
url_data = Object.assign({}, url_data, this.propToPage);
|
||||
// 跳转支付页面
|
||||
uni.navigateTo({
|
||||
url: '/pages/paytips/paytips?params=' + base64.encode(JSON.stringify(url_data)),
|
||||
});
|
||||
},
|
||||
fail: (res) => {
|
||||
app.globalData.showToast('支付失败');
|
||||
@ -430,14 +427,6 @@
|
||||
if (res.err_msg == 'get_brand_wcpay_request:ok') {
|
||||
// 数据设置
|
||||
self.order_item_pay_success_handle(data, order_id);
|
||||
let url_data = {
|
||||
code: '9000',
|
||||
};
|
||||
url_data = Object.assign({}, url_data, this.propToPage);
|
||||
// 跳转支付页面
|
||||
uni.navigateTo({
|
||||
url: '/pages/paytips/paytips?params=' + base64.encode(JSON.stringify(url_data)),
|
||||
});
|
||||
} else {
|
||||
self.order_item_pay_fail_handle(data, order_id);
|
||||
}
|
||||
@ -484,14 +473,6 @@
|
||||
});
|
||||
// 数据设置
|
||||
self.order_item_pay_success_handle(data, order_id);
|
||||
let url_data = {
|
||||
code: '9000',
|
||||
};
|
||||
url_data = Object.assign({}, url_data, this.propToPage);
|
||||
// 跳转支付页面
|
||||
uni.navigateTo({
|
||||
url: '/pages/paytips/paytips?params=' + base64.encode(JSON.stringify(url_data)),
|
||||
});
|
||||
} else {
|
||||
// -300支付中、其它状态则提示错误
|
||||
if (res.data.code != -300) {
|
||||
@ -530,21 +511,54 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
// 支付成功数据设置
|
||||
order_item_pay_success_handle(data, order_id) {
|
||||
// 支付成功数据设置 bool:成功是否需要跳转页面
|
||||
order_item_pay_success_handle(data, order_id, is_to_page = true) {
|
||||
let newData = {
|
||||
data: data,
|
||||
order_id: order_id,
|
||||
is_to_page: is_to_page,
|
||||
};
|
||||
this.$emit('pay-success', newData, this.propTempPayIndex, this.propPaymentId);
|
||||
if (is_to_page) {
|
||||
this.to_success_page_event();
|
||||
}
|
||||
},
|
||||
// 支付成功数据设置
|
||||
// 支付失败数据设置 bool:失败是否需要跳转页面
|
||||
order_item_pay_fail_handle(data, order_id) {
|
||||
let newData = {
|
||||
data: data,
|
||||
order_id: order_id,
|
||||
is_to_page: is_to_page,
|
||||
temp_pay_index: this.propTempPayIndex,
|
||||
payment_id: this.propPaymentId,
|
||||
};
|
||||
this.$emit('pay-fail', newData, this.propTempPayIndex, this.propPaymentId);
|
||||
this.$emit('pay-fail', newData);
|
||||
this.to_fail_page_event();
|
||||
},
|
||||
to_success_page_event() {
|
||||
let url_data = {
|
||||
code: '9000',
|
||||
};
|
||||
url_data = Object.assign({}, url_data, this.propToPage);
|
||||
if (this.propIsRedirectTo) {
|
||||
// 跳转支付页面
|
||||
uni.redirectTo({
|
||||
url: '/pages/paytips/paytips?params=' + encodeURIComponent(base64.encode(JSON.stringify(url_data))),
|
||||
});
|
||||
} else {
|
||||
// 跳转支付页面
|
||||
uni.navigateTo({
|
||||
url: '/pages/paytips/paytips?params=' + encodeURIComponent(base64.encode(JSON.stringify(url_data))),
|
||||
});
|
||||
}
|
||||
},
|
||||
to_fail_page_event() {
|
||||
if (this.propTofailPage) {
|
||||
// 跳转支付页面
|
||||
uni.navigateTo({
|
||||
url: this.propTofailPage + '?data=' + data.order_id,
|
||||
});
|
||||
}
|
||||
},
|
||||
// 页面卸载
|
||||
onUnload(e) {
|
||||
|
||||
@ -88,7 +88,6 @@
|
||||
data_bottom_line_status: false,
|
||||
data_is_loading: 0,
|
||||
params: null,
|
||||
load_status: 0,
|
||||
payment_id: 0,
|
||||
nav_status_list: [
|
||||
{ name: '全部', value: '-1' },
|
||||
@ -217,28 +216,6 @@
|
||||
if (res.data.data.data.length > 0) {
|
||||
if (this.data_page <= 1) {
|
||||
var temp_data_list = res.data.data.data;
|
||||
// 下订单支付处理
|
||||
if (this.load_status == 0) {
|
||||
var ck = app.globalData.data.cache_page_pay_key;
|
||||
var pay_data = uni.getStorageSync(ck) || null;
|
||||
if (pay_data != null) {
|
||||
uni.removeStorageSync(ck);
|
||||
this.setData({ payment_id: parseInt(pay_data.payment_id || 0) });
|
||||
for (var i in temp_data_list) {
|
||||
if (pay_data.order_ids == temp_data_list[i]['id']) {
|
||||
if (this.payment_id == 0) {
|
||||
this.setData({
|
||||
is_show_payment_popup: true,
|
||||
temp_pay_value: temp_data_list[i]['id'],
|
||||
pay_price: temp_data_list[i]['money'],
|
||||
temp_pay_index: i,
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var temp_data_list = this.data_list || [];
|
||||
var temp_data = res.data.data.data;
|
||||
@ -254,7 +231,6 @@
|
||||
data_page_total: res.data.data.page_total,
|
||||
data_list_loding_status: 3,
|
||||
data_page: this.data_page + 1,
|
||||
load_status: 1,
|
||||
data_is_loading: 0,
|
||||
});
|
||||
|
||||
@ -265,7 +241,6 @@
|
||||
} else {
|
||||
this.setData({
|
||||
data_list_loding_status: 0,
|
||||
load_status: 1,
|
||||
data_list: [],
|
||||
data_bottom_line_status: false,
|
||||
data_is_loading: 0,
|
||||
@ -274,7 +249,6 @@
|
||||
} else {
|
||||
this.setData({
|
||||
data_list_loding_status: 0,
|
||||
load_status: 1,
|
||||
data_is_loading: 0,
|
||||
});
|
||||
if (app.globalData.is_login_check(res.data, this, 'get_data_list')) {
|
||||
@ -287,7 +261,6 @@
|
||||
uni.stopPullDownRefresh();
|
||||
this.setData({
|
||||
data_list_loding_status: 2,
|
||||
load_status: 1,
|
||||
data_is_loading: 0,
|
||||
});
|
||||
app.globalData.showToast('服务器请求出错');
|
||||
@ -321,6 +294,7 @@
|
||||
this.setData({
|
||||
data_list: temp_data_list,
|
||||
});
|
||||
this.$emit('pay-success');
|
||||
},
|
||||
|
||||
// 删除
|
||||
|
||||
@ -258,7 +258,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</component-popup>
|
||||
<component-payment ref="payment" :prop-pay-url="pay_url" :prop-qrcode-url="qrcode_url" prop-pay-data-key="ids" :prop-payment-list="payment_list" :prop-to-page="to_page"></component-payment>
|
||||
<component-payment ref="payment" :prop-pay-url="pay_url" :prop-qrcode-url="qrcode_url" prop-pay-data-key="ids" :prop-payment-list="payment_list" :prop-to-page="to_page" :prop-to-fail-page="to_fail_page"></component-payment>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
@ -322,10 +322,11 @@
|
||||
qrcode_url: app.globalData.get_request_url('paycheck', 'order'),
|
||||
// 前往页面携带的参数
|
||||
to_page: {
|
||||
title: '前往订单页',
|
||||
title: '进入我的订单',
|
||||
page: 'user-order/user-order',
|
||||
msg: '支付成功',
|
||||
},
|
||||
// 支付失败跳转的页面
|
||||
to_fail_page: 'page/user-order/user-order',
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<view class="content tc">
|
||||
<image class="pay-icon dis-block" v-if="params.code == '9000'" mode="widthFix" :src="default_round_success_icon"></image>
|
||||
<image class="pay-icon dis-block" v-else mode="widthFix" :src="default_round_error_icon"></image>
|
||||
<view class="text-size-lg cr-base">{{ params.msg }}</view>
|
||||
<view class="text-size-lg cr-base">{{ params.msg || '支付成功' }}</view>
|
||||
</view>
|
||||
<view class="btn-box tc">
|
||||
<view>
|
||||
@ -39,7 +39,7 @@
|
||||
*/
|
||||
onLoad(options) {
|
||||
if (options) {
|
||||
let url_params = JSON.parse(decodeURIComponent(base64.decode(options.params)));
|
||||
let url_params = JSON.parse(base64.decode(decodeURIComponent(options.params)));
|
||||
var msg = null;
|
||||
switch (url_params.code) {
|
||||
// 支付成功
|
||||
|
||||
@ -70,6 +70,8 @@
|
||||
:prop-temp-pay-value="temp_pay_value"
|
||||
:prop-temp-pay-index="temp_pay_index"
|
||||
:prop-pay-price="pay_price"
|
||||
:prop-to-page="to_page"
|
||||
:prop-to-fail-page="to_fail_page"
|
||||
:prop-is-show-payment="is_show_payment_popup"
|
||||
@close-payment-poupon="payment_popup_event_close"
|
||||
></component-payment>
|
||||
@ -100,6 +102,13 @@
|
||||
temp_pay_index: 0,
|
||||
is_show_payment_popup: false,
|
||||
pay_price: 0,
|
||||
// 前往页面携带的参数
|
||||
to_page: {
|
||||
title: '进入我的会员列表',
|
||||
page: 'pages/plugins/membershiplevelvip/user/user',
|
||||
},
|
||||
// 支付失败跳转的页面
|
||||
to_fail_page: 'pages/plugins/membershiplevelvip/order/order',
|
||||
};
|
||||
},
|
||||
components: {
|
||||
@ -256,6 +265,11 @@
|
||||
url_event(e) {
|
||||
app.globalData.url_event(e);
|
||||
},
|
||||
payment_popup_event_close() {
|
||||
this.setData({
|
||||
is_show_payment_popup: false,
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -1,17 +1,30 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="form-container padding-main">
|
||||
<view class="form-gorup padding-vertical-main">
|
||||
<view class="form-gorup padding-vertical-main border-radius-main">
|
||||
<input type="digit" name="money" :value="recharge_money_value || ''" placeholder-class="cr-grey" class="cr-base text-size-xxl" placeholder="请输入充值金额" @input="recharge_money_value_input_event" maxlength="6" />
|
||||
</view>
|
||||
<view class="form-gorup form-gorup-submit">
|
||||
<button class="round cr-white bg-main br-main text-size" type="default" hover-class="none" :disabled="form_submit_disabled_status" @tap="form_submit_event">提交</button>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 支付弹窗 -->
|
||||
<component-payment
|
||||
:prop-pay-url="pay_url"
|
||||
:prop-qrcode-url="qrcode_url"
|
||||
prop-pay-data-key="recharge_id"
|
||||
:prop-payment-list="payment_list"
|
||||
:prop-temp-pay-value="temp_pay_value"
|
||||
:prop-pay-price="pay_price"
|
||||
:propIsRedirectTo="true"
|
||||
:prop-is-show-payment="is_show_payment_popup"
|
||||
@close-payment-poupon="payment_popup_event_close"
|
||||
></component-payment>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
const app = getApp();
|
||||
import componentPayment from '@/components/payment/payment';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@ -22,10 +35,23 @@
|
||||
data_list_loding_msg: '',
|
||||
recharge_money_value: '',
|
||||
form_submit_disabled_status: false,
|
||||
|
||||
// 支付弹窗参数
|
||||
pay_url: app.globalData.get_request_url('pay', 'recharge', 'wallet'),
|
||||
qrcode_url: app.globalData.get_request_url('paycheck', 'recharge', 'wallet'),
|
||||
payment_list: [],
|
||||
temp_pay_value: '',
|
||||
is_show_payment_popup: false,
|
||||
pay_price: 0,
|
||||
// 支付失败跳转的页面
|
||||
to_fail_page: '/pages/plugins/wallet/user/user',
|
||||
};
|
||||
},
|
||||
|
||||
components: {},
|
||||
components: {
|
||||
componentPayment,
|
||||
},
|
||||
|
||||
props: {},
|
||||
|
||||
onLoad(params) {
|
||||
@ -99,9 +125,12 @@
|
||||
});
|
||||
uni.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
uni.setStorageSync(app.globalData.data.cache_page_pay_key, { order_ids: res.data.data.recharge_id });
|
||||
uni.redirectTo({
|
||||
url: '/pages/plugins/wallet/user/user?type=1',
|
||||
uni.setStorageSync(app.globalData.data.cache_page_pay_key, { type: 1 });
|
||||
this.setData({
|
||||
is_show_payment_popup: true,
|
||||
pay_price: res.data.data.money,
|
||||
temp_pay_value: res.data.data.recharge_id,
|
||||
payment_list: res.data.data.payment_list,
|
||||
});
|
||||
} else {
|
||||
if (app.globalData.is_login_check(res.data)) {
|
||||
@ -120,6 +149,11 @@
|
||||
},
|
||||
});
|
||||
},
|
||||
order_item_pay_success_handle() {
|
||||
this.setData({
|
||||
is_show_payment_popup: false,
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -65,7 +65,7 @@
|
||||
<component-wallet-log :prop-pull-down-refresh="propPullDownRefresh" :prop-scroll-lower="scroll_lower_bool"></component-wallet-log>
|
||||
</view>
|
||||
<view v-if="current === 1">
|
||||
<component-user-recharge :prop-pull-down-refresh="propPullDownRefresh" :prop-scroll-lower="scroll_lower_bool"></component-user-recharge>
|
||||
<component-user-recharge :prop-pull-down-refresh="propPullDownRefresh" :prop-scroll-lower="scroll_lower_bool" @pay-success="pay_success_event"></component-user-recharge>
|
||||
</view>
|
||||
<view v-if="current === 2">
|
||||
<component-user-cash :prop-pull-down-refresh="propPullDownRefresh" :prop-scroll-lower="scroll_lower_bool"></component-user-cash>
|
||||
@ -139,6 +139,17 @@
|
||||
current: Number(params.type),
|
||||
});
|
||||
}
|
||||
|
||||
var ck = app.globalData.data.cache_page_pay_key;
|
||||
var pay_data = uni.getStorageSync(ck) || null;
|
||||
if (pay_data) {
|
||||
this.setData({
|
||||
current: pay_data.type || 0,
|
||||
});
|
||||
var newurl = app.globalData.updateQueryStringParameter(window.location.href.split('?')[0], 'type', pay_data.type + '');
|
||||
//向当前url添加参数,没有历史记录
|
||||
window.history.replaceState({ path: newurl }, '', newurl);
|
||||
}
|
||||
this.init();
|
||||
},
|
||||
|
||||
@ -252,6 +263,10 @@
|
||||
uni.navigateBack();
|
||||
}
|
||||
},
|
||||
// 支付成功回调
|
||||
pay_success_event() {
|
||||
this.get_data();
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -12,14 +12,17 @@
|
||||
min-height: 160rpx;
|
||||
margin-left: 180rpx;
|
||||
}
|
||||
|
||||
.goods-image {
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
}
|
||||
|
||||
.warehouse-group-icon {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
}
|
||||
|
||||
.orderaftersale-btn-text {
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
@ -32,9 +35,11 @@
|
||||
.payment-list .item {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.payment-list .item-content {
|
||||
padding: 20rpx 10rpx;
|
||||
}
|
||||
|
||||
.payment-list .item-content image {
|
||||
width: 50rpx;
|
||||
height: 50rpx !important;
|
||||
|
||||
@ -103,7 +103,6 @@
|
||||
:prop-pay-url="pay_url"
|
||||
:prop-qrcode-url="qrcode_url"
|
||||
:prop-payment-list="payment_list"
|
||||
:prop-to-page="to_page"
|
||||
prop-pay-data-key="ids"
|
||||
:prop-temp-pay-value="temp_pay_value"
|
||||
:prop-temp-pay-index="temp_pay_index"
|
||||
@ -157,11 +156,6 @@
|
||||
// 页面从其他页面跳转过来携带的参数
|
||||
params: '',
|
||||
// 前往页面携带的参数
|
||||
to_page: {
|
||||
title: '前往订单页',
|
||||
page: 'user-order/user-order',
|
||||
msg: '支付成功',
|
||||
},
|
||||
pay_price: 0,
|
||||
pay_url: app.globalData.get_request_url('pay', 'order'),
|
||||
qrcode_url: app.globalData.get_request_url('paycheck', 'order'),
|
||||
@ -399,7 +393,7 @@
|
||||
// 支付成功数据设置
|
||||
// 订单完成回调
|
||||
order_item_pay_success_handle(data, index, order_ids) {
|
||||
var order_ids_arr = order_ids.split(',');
|
||||
var order_ids_arr = data.order_id.split(',');
|
||||
var temp_data_list = this.data_list;
|
||||
|
||||
// 数据设置
|
||||
@ -676,6 +670,6 @@
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
<style scoped>
|
||||
@import './user-order.css';
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user