初始项目
This commit is contained in:
159
mallplusui-uniapp-wx/pages/order/payment/auth.vue
Normal file
159
mallplusui-uniapp-wx/pages/order/payment/auth.vue
Normal file
@@ -0,0 +1,159 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<view class="content-c">
|
||||
|
||||
<view class="load-text color-9">信息加载中.....</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
type: '',
|
||||
openid: '',
|
||||
orderId: '',
|
||||
state: ''
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
this.orderId = options.order_id
|
||||
this.money = Number(options.money)
|
||||
this.type = Number(options.type)
|
||||
this.uid = Number(options.uid)
|
||||
this.state = this.$common.getQueryString('state')
|
||||
this.getCode()
|
||||
},
|
||||
methods: {
|
||||
getCode() {
|
||||
var code = this.$common.getQueryString('code')
|
||||
code && this.getOpenId(code)
|
||||
},
|
||||
async getOpenId(code) {
|
||||
console.log(code)
|
||||
let params = {
|
||||
code: code,
|
||||
scope: 2,
|
||||
state: this.state
|
||||
}
|
||||
//模拟接口
|
||||
let res = await Api.apiCall('get',Api.order.authCodeToOpenid,params);
|
||||
console.log(res);
|
||||
if (res) {
|
||||
this.login(data);
|
||||
console.log(data);
|
||||
this.$db.set('userInfos', data.userInfo);
|
||||
this.$db.set('token', data.tokenHead+data.token);
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
|
||||
//this.openid = res.data
|
||||
// this.toPayHandler('wechatpay')
|
||||
} else {
|
||||
this.$common.errorToShow(res)
|
||||
}
|
||||
|
||||
},
|
||||
checkWXJSBridge(data) {
|
||||
let that = this
|
||||
let interval = setInterval(() => {
|
||||
if (typeof window.WeixinJSBridge != 'undefined') {
|
||||
clearTimeout(interval)
|
||||
that.onBridgeReady(data)
|
||||
}
|
||||
}, 200)
|
||||
},
|
||||
onBridgeReady(data) {
|
||||
var _this = this
|
||||
window.WeixinJSBridge.invoke(
|
||||
'getBrandWCPayRequest',
|
||||
{
|
||||
appId: data.appid, // 公众号名称,由商户传入
|
||||
timeStamp: data.timeStamp, // 时间戳,自1970年以来的秒数
|
||||
nonceStr: data.nonceStr, // 随机串
|
||||
package: data.package,
|
||||
signType: data.signType, // 微信签名方式:
|
||||
paySign: data.paySign // 微信签名
|
||||
},
|
||||
function(res) {
|
||||
if (res.err_msg === 'get_brand_wcpay_request:ok') {
|
||||
_this.$common.successToShow('支付成功')
|
||||
} else if (res.err_msg === 'get_brand_wcpay_request:cancel') {
|
||||
_this.$common.errorToShow('取消支付')
|
||||
} else {
|
||||
_this.$common.errorToShow('支付失败')
|
||||
}
|
||||
setTimeout(() => {
|
||||
_this.$common.redirectTo(
|
||||
'/pages/order/payment/result?id=' + data.id
|
||||
)
|
||||
},1000)
|
||||
}
|
||||
)
|
||||
},
|
||||
toPayHandler(code) {
|
||||
let data = {
|
||||
payment_code: code,
|
||||
payment_type: this.type
|
||||
}
|
||||
data['ids'] = (this.type == 1 || this.type == 5 || this.type == 6) ? this.orderId : this.uid
|
||||
//data['ids'] = this.type == 1 ? this.orderId : this.uid
|
||||
|
||||
if (this.type == 1 && this.orderId) {
|
||||
// 微信jsapi支付
|
||||
if (this.openid) {
|
||||
data['params'] = {
|
||||
trade_type: 'JSAPI_OFFICIAL',
|
||||
openid: this.openid
|
||||
}
|
||||
}
|
||||
} else if (this.type == 2 && this.money) {
|
||||
if (this.openid) {
|
||||
data['params'] = {
|
||||
trade_type: 'JSAPI_OFFICIAL',
|
||||
money: this.money,
|
||||
openid: this.openid
|
||||
}
|
||||
}
|
||||
}else if ((this.type == 5 || this.type == 6) && this.recharge) {
|
||||
data['params'] = {
|
||||
trade_type: 'JSAPI_OFFICIAL',
|
||||
openid: this.openid,
|
||||
formid: this.orderId
|
||||
}
|
||||
}
|
||||
this.$api.pay(data, res => {
|
||||
if (res.code == 200) {
|
||||
const data = res.data
|
||||
this.checkWXJSBridge(data)
|
||||
} else {
|
||||
this.$common.errorToShow(res.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.content {
|
||||
position: relative;
|
||||
height: 80vh;
|
||||
}
|
||||
.content-c {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
text-align: center;
|
||||
}
|
||||
.load-img {
|
||||
width: 100upx;
|
||||
height: 100upx;
|
||||
}
|
||||
.load-text {
|
||||
font-size: 26upx;
|
||||
}
|
||||
</style>
|
||||
231
mallplusui-uniapp-wx/pages/order/payment/index.vue
Normal file
231
mallplusui-uniapp-wx/pages/order/payment/index.vue
Normal file
@@ -0,0 +1,231 @@
|
||||
<template>
|
||||
<view class="app">
|
||||
|
||||
<view class="price-box">
|
||||
<text>支付金额</text>
|
||||
<text class="price">{{orderInfo.payAmount}}</text>
|
||||
</view>
|
||||
|
||||
<!-- #ifdef H5 -->
|
||||
<payments-by-h5
|
||||
:orderId="orderId"
|
||||
:recharge="recharge"
|
||||
:type="type"
|
||||
:uid="userInfo.id"
|
||||
></payments-by-h5>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<payments-by-wx
|
||||
:orderId="orderId"
|
||||
:recharge="recharge"
|
||||
:type="type"
|
||||
:uid="userInfo.id"
|
||||
></payments-by-wx>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifdef MP-ALIPAY -->
|
||||
<payments-by-ali
|
||||
:orderId="orderId"
|
||||
:recharge="recharge"
|
||||
:type="type"
|
||||
:uid="userInfo.id"
|
||||
></payments-by-ali>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifdef APP-PLUS||APP-PLUS-NVUE -->
|
||||
<payments-by-app
|
||||
:orderId="orderId"
|
||||
:recharge="recharge"
|
||||
:type="type"
|
||||
:uid="userInfo.id"
|
||||
></payments-by-app>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
// #ifdef H5
|
||||
import paymentsByH5 from '@/components/payments/paymentsByH5.vue'
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
import paymentsByWx from '@/components/payments/paymentsByWx.vue'
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-ALIPAY
|
||||
import paymentsByAli from '@/components/payments/paymentsByAli.vue'
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS||APP-PLUS-NVUE
|
||||
import paymentsByApp from '@/components/payments/paymentsByApp.vue'
|
||||
// #endif
|
||||
import mallplusCopyright from '@/components/mall-copyright/mallplusCopyright.vue';
|
||||
import Api from '@/common/api';
|
||||
|
||||
export default {
|
||||
|
||||
data () {
|
||||
return {
|
||||
orderId: 0,
|
||||
recharge: 0,
|
||||
type: 1, // 订单类型 1商品订单 2充值订单
|
||||
orderInfo: {}, // 订单详情
|
||||
userInfo: {}, // 用户信息
|
||||
form_id:0
|
||||
}
|
||||
},
|
||||
|
||||
components: {
|
||||
// #ifdef H5
|
||||
paymentsByH5,
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
paymentsByWx,
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
paymentsByAli,
|
||||
// #endif
|
||||
// #ifdef APP-PLUS||APP-PLUS-NVUE
|
||||
paymentsByApp,
|
||||
// #endif
|
||||
},
|
||||
|
||||
onLoad (options) {
|
||||
this.orderId = options.order_id
|
||||
this.recharge = Number(options.recharge)
|
||||
this.type = Number(options.type)
|
||||
this.form_id = Number(options.form_id)
|
||||
|
||||
if (this.orderId && this.type == 1) {
|
||||
// 商品订单
|
||||
this.getOrderInfo()
|
||||
} else if (this.recharge && this.type == 2) {
|
||||
// 充值订单 获取用户id
|
||||
this.getUserInfo()
|
||||
} else if (this.form_id && (this.type == 5 || this.type == 6)) {
|
||||
// 表单订单 id传到订单上
|
||||
this.orderId = ''+this.form_id;
|
||||
} else {
|
||||
this.$common.errorToShow('订单支付参数错误', () => {
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 获取订单详情
|
||||
async getOrderInfo () {
|
||||
|
||||
let params = {'id':this.orderId};
|
||||
this.orderInfo = await Api.apiCall('get',Api.order.orderDetail,params);
|
||||
if(this.orderInfo.pay_status == 2){
|
||||
this.$common.redirectTo(
|
||||
'/pages/order/payment/result?order_id=' + this.orderInfo.id
|
||||
)
|
||||
}
|
||||
},
|
||||
// 获取用户信息
|
||||
getUserInfo () {
|
||||
this.$api.userInfo({}, res => {
|
||||
if (res.code == 200) {
|
||||
this.userInfo = res.data
|
||||
|
||||
} else {
|
||||
this.$common.errorToShow(res.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
// 跳转我的余额页面
|
||||
toRecharge () {
|
||||
this.$common.navigateTo('/pages/member/balance/index')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang='scss'>
|
||||
.app {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.price-box {
|
||||
background-color: #fff;
|
||||
height: 265upx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 28upx;
|
||||
color: #909399;
|
||||
|
||||
.price{
|
||||
font-size: 50upx;
|
||||
color: #303133;
|
||||
margin-top: 12upx;
|
||||
&:before{
|
||||
content: '¥';
|
||||
font-size: 40upx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pay-type-list {
|
||||
margin-top: 20upx;
|
||||
background-color: #fff;
|
||||
padding-left: 60upx;
|
||||
|
||||
.type-item{
|
||||
height: 120upx;
|
||||
padding: 20upx 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-right: 60upx;
|
||||
font-size: 30upx;
|
||||
position:relative;
|
||||
}
|
||||
|
||||
.icon{
|
||||
width: 100upx;
|
||||
font-size: 52upx;
|
||||
}
|
||||
.icon-erjiye-yucunkuan {
|
||||
color: #fe8e2e;
|
||||
}
|
||||
.icon-weixinzhifu {
|
||||
color: #36cb59;
|
||||
}
|
||||
.icon-alipay {
|
||||
color: #01aaef;
|
||||
}
|
||||
.tit{
|
||||
font-size: $font-lg;
|
||||
color: $font-color-dark;
|
||||
margin-bottom: 4upx;
|
||||
}
|
||||
.con{
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-size: $font-sm;
|
||||
color: $font-color-light;
|
||||
}
|
||||
}
|
||||
.mix-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 630upx;
|
||||
height: 80upx;
|
||||
margin: 80upx auto 30upx;
|
||||
font-size: $font-lg;
|
||||
color: #fff;
|
||||
background-color: $base-color;
|
||||
border-radius: 10upx;
|
||||
box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
|
||||
}
|
||||
|
||||
</style>
|
||||
210
mallplusui-uniapp-wx/pages/order/payment/index1.vue
Normal file
210
mallplusui-uniapp-wx/pages/order/payment/index1.vue
Normal file
@@ -0,0 +1,210 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<view class='cell-group margin-cell-group'>
|
||||
<view class='cell-item'>
|
||||
<view class='cell-item-hd'>
|
||||
<view class='cell-hd-title'>订单类型</view>
|
||||
</view>
|
||||
<view class='cell-item-ft'>
|
||||
<text class="cell-ft-p" v-if="type == 1" @click="orderDetail(orderId)">商品订单</text>
|
||||
<text class="cell-ft-p" v-if="type == 2" @click="toRecharge()">充值订单</text>
|
||||
<text class="cell-ft-p" v-if="type == 5" >快捷下单</text>
|
||||
<text class="cell-ft-p" v-if="type == 6" >付款码</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="type == 1">
|
||||
<view class='cell-item'>
|
||||
<view class='cell-item-hd'>
|
||||
<view class='cell-hd-title'>订单编号</view>
|
||||
</view>
|
||||
<view class='cell-item-ft'>
|
||||
<text class="cell-ft-p" @click="orderDetail(orderId)">{{ orderId }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class='cell-item'>
|
||||
<view class='cell-item-hd'>
|
||||
<view class='cell-hd-title'>订单金额</view>
|
||||
</view>
|
||||
<view class='cell-item-ft'>
|
||||
<text class="cell-ft-p red-price">¥{{ orderInfo.payAmount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else-if="type == 2">
|
||||
<view class='cell-item'>
|
||||
<view class='cell-item-hd'>
|
||||
<view class='cell-hd-title'>充值金额</view>
|
||||
</view>
|
||||
<view class='cell-item-ft'>
|
||||
<text class="cell-ft-p red-price">¥ {{ recharge }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- #ifdef H5 -->
|
||||
<payments-by-h5
|
||||
:orderId="orderId"
|
||||
:recharge="recharge"
|
||||
:type="type"
|
||||
:uid="userInfo.id"
|
||||
></payments-by-h5>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<payments-by-wx
|
||||
:orderId="orderId"
|
||||
:recharge="recharge"
|
||||
:type="type"
|
||||
:uid="userInfo.id"
|
||||
></payments-by-wx>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifdef MP-ALIPAY -->
|
||||
<payments-by-ali
|
||||
:orderId="orderId"
|
||||
:recharge="recharge"
|
||||
:type="type"
|
||||
:uid="userInfo.id"
|
||||
></payments-by-ali>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifdef APP-PLUS||APP-PLUS-NVUE -->
|
||||
<payments-by-app
|
||||
:orderId="orderId"
|
||||
:recharge="recharge"
|
||||
:type="type"
|
||||
:uid="userInfo.id"
|
||||
></payments-by-app>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// #ifdef H5
|
||||
import paymentsByH5 from '@/components/payments/paymentsByH5.vue'
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
import paymentsByWx from '@/components/payments/paymentsByWx.vue'
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-ALIPAY
|
||||
import paymentsByAli from '@/components/payments/paymentsByAli.vue'
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS||APP-PLUS-NVUE
|
||||
import paymentsByApp from '@/components/payments/paymentsByApp.vue'
|
||||
// #endif
|
||||
import mallplusCopyright from '@/components/mall-copyright/mallplusCopyright.vue';
|
||||
import Api from '@/common/api';
|
||||
|
||||
export default {
|
||||
|
||||
data () {
|
||||
return {
|
||||
orderId: 0,
|
||||
recharge: 0,
|
||||
type: 1, // 订单类型 1商品订单 2充值订单
|
||||
orderInfo: {}, // 订单详情
|
||||
userInfo: {}, // 用户信息
|
||||
form_id:0
|
||||
}
|
||||
},
|
||||
|
||||
components: {
|
||||
// #ifdef H5
|
||||
paymentsByH5,
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
paymentsByWx,
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
paymentsByAli,
|
||||
// #endif
|
||||
// #ifdef APP-PLUS||APP-PLUS-NVUE
|
||||
paymentsByApp,
|
||||
// #endif
|
||||
},
|
||||
|
||||
onLoad (options) {
|
||||
this.orderId = options.order_id
|
||||
this.recharge = Number(options.recharge)
|
||||
this.type = Number(options.type)
|
||||
this.form_id = Number(options.form_id)
|
||||
|
||||
if (this.orderId && this.type == 1) {
|
||||
// 商品订单
|
||||
this.getOrderInfo()
|
||||
} else if (this.recharge && this.type == 2) {
|
||||
// 充值订单 获取用户id
|
||||
this.getUserInfo()
|
||||
} else if (this.form_id && (this.type == 5 || this.type == 6)) {
|
||||
// 表单订单 id传到订单上
|
||||
this.orderId = ''+this.form_id;
|
||||
} else {
|
||||
this.$common.errorToShow('订单支付参数错误', () => {
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 获取订单详情
|
||||
async getOrderInfo () {
|
||||
|
||||
let params = {'id':this.orderId};
|
||||
this.orderInfo = await Api.apiCall('get',Api.order.orderDetail,params);
|
||||
if(this.orderInfo.pay_status == 2){
|
||||
this.$common.redirectTo(
|
||||
'/pages/order/payment/result?order_id=' + this.orderInfo.id
|
||||
)
|
||||
}
|
||||
},
|
||||
// 获取用户信息
|
||||
getUserInfo () {
|
||||
this.$api.userInfo({}, res => {
|
||||
if (res.code == 200) {
|
||||
this.userInfo = res.data
|
||||
|
||||
} else {
|
||||
this.$common.errorToShow(res.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
// 跳转我的余额页面
|
||||
toRecharge () {
|
||||
this.$common.navigateTo('/pages/member/balance/index')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.margin-cell-group{
|
||||
margin-bottom: 20upx;
|
||||
}
|
||||
.cell-hd-title{
|
||||
color: #999;
|
||||
}
|
||||
.payment-method .cell-item-hd{
|
||||
min-width: 70upx;
|
||||
}
|
||||
.payment-method .cell-hd-icon{
|
||||
width: 70upx;
|
||||
height: 70upx;
|
||||
}
|
||||
.payment-method .cell-item-bd{
|
||||
border-left: 2upx solid #F0F0F0;
|
||||
padding-left: 30upx;
|
||||
}
|
||||
.payment-method .cell-bd-text{
|
||||
font-size: 28upx;
|
||||
color: #666;
|
||||
}
|
||||
.payment-method .address{
|
||||
font-size: 24upx;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
75
mallplusui-uniapp-wx/pages/order/payment/result.vue
Normal file
75
mallplusui-uniapp-wx/pages/order/payment/result.vue
Normal file
@@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<text class="success-icon yticon icon-xuanzhong2"></text>
|
||||
<text class="tit">支付成功</text>
|
||||
<view class="result-mid red-price">
|
||||
{{ paymentInfo.payAmount }}
|
||||
</view>
|
||||
<view class="btn-group">
|
||||
<navigator url="/pages/order/order?status=0" open-type="redirect" class="mix-btn">查看订单</navigator>
|
||||
<navigator url="/pages/index/index" open-type="switchTab" class="mix-btn hollow">返回首页</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import mallplusCopyright from '@/components/mall-copyright/mallplusCopyright.vue';
|
||||
import Api from '@/common/api';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
paymentId: 0,
|
||||
paymentInfo: {}, // 支付单详情
|
||||
orderId: 0,
|
||||
status: false
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options.order) {
|
||||
let order = JSON.parse(options.order)
|
||||
this.orderId = order.id
|
||||
this.paymentInfo = order
|
||||
}
|
||||
|
||||
},
|
||||
methods: {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.success-icon {
|
||||
font-size: 160upx;
|
||||
color: #fa436a;
|
||||
margin-top: 100upx;
|
||||
}
|
||||
.tit {
|
||||
font-size: 38upx;
|
||||
color: #303133;
|
||||
}
|
||||
.btn-group {
|
||||
padding-top: 100upx;
|
||||
}
|
||||
.mix-btn {
|
||||
margin-top: 30upx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 600upx;
|
||||
height: 80upx;
|
||||
font-size: $font-lg;
|
||||
color: #fff;
|
||||
background-color: $base-color;
|
||||
border-radius: 10upx;
|
||||
&.hollow {
|
||||
background: #fff;
|
||||
color: #303133;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user