|
@@ -0,0 +1,975 @@
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+const T_PAY_ORDER = 'T_PAY_ORDER'
|
|
|
+import { gotoOrderH5PayApi } from '@/api/table'
|
|
|
+const isInWx = () => {
|
|
|
+
|
|
|
+ var ua = navigator.userAgent.toLowerCase()
|
|
|
+ if (ua.match(/MicroMessenger/i) == 'micromessenger') return true
|
|
|
+
|
|
|
+ return false
|
|
|
+}
|
|
|
+import {
|
|
|
+ MessageBox,
|
|
|
+ Message
|
|
|
+} from 'element-ui'
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 普通H5处理
|
|
|
+ * @param payInfo 结算返回的支付信息
|
|
|
+ */
|
|
|
+
|
|
|
+async function payH5InEquipment(payInfo) {
|
|
|
+ try {
|
|
|
+ const res = await gotoOrderH5PayApi(payInfo)
|
|
|
+ location.replace(res.data.mwebUrl)
|
|
|
+ } catch (e) {
|
|
|
+ uni.showToast({ title: '支付失败', icon: 'none' })
|
|
|
+ setTimeout(() => {
|
|
|
+ if ([1, 2].includes(payInfo.purchaseMode)) {
|
|
|
+ uni.switchTab({ url: '/pages/order/order' })
|
|
|
+ } else if ([3, 4, 5].includes(payInfo.purchaseMode)) {
|
|
|
+ uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' })
|
|
|
+ }
|
|
|
+ }, 2000)
|
|
|
+ } finally {
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ * 微信内H5处理
|
|
|
+ * @param payInfo 结算返回的支付信息
|
|
|
+ * @param orderId 订单ID
|
|
|
+ */
|
|
|
+
|
|
|
+async function payH5InWechat(payInfo) {
|
|
|
+ const res = await gotoOrderPayApi(payInfo)
|
|
|
+ jweixin.config({
|
|
|
+ debug: false,
|
|
|
+ appId: res.data.appId,
|
|
|
+ timestamp: res.data.timeStamp,
|
|
|
+ nonceStr: res.data.nonceStr,
|
|
|
+ signature: res.data.paySign,
|
|
|
+ jsApiList: [ 'chooseWXPay' ]
|
|
|
+ })
|
|
|
+ if ([1, 2].includes(payInfo.purchaseMode)) {
|
|
|
+ jweixin.ready(function () {
|
|
|
+ jweixin.checkJsApi({
|
|
|
+ jsApiList: [ 'chooseWXPay' ],
|
|
|
+ success(res) {},
|
|
|
+ fail(res) {}
|
|
|
+ })
|
|
|
+ jweixin.chooseWXPay({
|
|
|
+ timestamp: res.data.timeStamp,
|
|
|
+ nonceStr: res.data.nonceStr,
|
|
|
+ package: res.data.package,
|
|
|
+ signType: res.data.signType,
|
|
|
+ paySign: res.data.paySign,
|
|
|
+ success(res) {
|
|
|
+
|
|
|
+ uni.showToast({ icon: 'none', title: '支付成功' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/another-tf/another-serve/paySuccessful/index?orderId=' + payInfo.orderId }) }, 2000)
|
|
|
+ },
|
|
|
+ cancel(r) {
|
|
|
+ uni.showToast({ icon: 'none', title: '用户取消支付' })
|
|
|
+ setTimeout(() => { uni.switchTab({ url: '/pages/order/order' }) }, 2000)
|
|
|
+ },
|
|
|
+ fail(res) {
|
|
|
+ uni.showToast({ icon: 'none', title: '微信内支付错误' })
|
|
|
+ setTimeout(() => { uni.switchTab({ url: '/pages/order/order' }) }, 2000)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ jweixin.error(function (res) {
|
|
|
+ uni.showToast({ icon: 'none', title: '微信内支付加载失败', duration: 3000 })
|
|
|
+ setTimeout(() => { uni.switchTab({ url: '/pages/order/order' }) }, 2000)
|
|
|
+ })
|
|
|
+ } else if ([3, 4, 5].includes(payInfo.purchaseMode)) {
|
|
|
+ jweixin.ready(function () {
|
|
|
+ jweixin.checkJsApi({
|
|
|
+ jsApiList: [ 'chooseWXPay' ],
|
|
|
+ success(res) {},
|
|
|
+ fail(res) {}
|
|
|
+ })
|
|
|
+ jweixin.chooseWXPay({
|
|
|
+ timestamp: res.data.timeStamp,
|
|
|
+ nonceStr: res.data.nonceStr,
|
|
|
+ package: res.data.package,
|
|
|
+ signType: res.data.signType,
|
|
|
+ paySign: res.data.paySign,
|
|
|
+ success(res) {
|
|
|
+
|
|
|
+ uni.showToast({ icon: 'none', title: '支付成功' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/user/otherServe/payment-completed/index' }) }, 2000)
|
|
|
+ },
|
|
|
+ cancel(r) {
|
|
|
+ uni.showToast({ icon: 'none', title: '用户取消支付' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' }) }, 2000)
|
|
|
+ },
|
|
|
+ fail(res) {
|
|
|
+ uni.showToast({ icon: 'none', title: '微信内支付错误' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' }) }, 2000)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ jweixin.error(function (res) {
|
|
|
+ uni.showToast({ icon: 'none', title: '微信内支付加载失败', duration: 3000 })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' }) }, 2000)
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 支付宝小程序拉起支付
|
|
|
+ * @param payInfo 结算返回的支付信息
|
|
|
+ * @return {Promise<void>}
|
|
|
+ */
|
|
|
+
|
|
|
+async function zhiAliPay(payInfo) {
|
|
|
+ if ([1, 2].includes(payInfo.purchaseMode)) {
|
|
|
+ try {
|
|
|
+ const res = await gotoOrderPayApi(payInfo)
|
|
|
+ uni.requestPayment({
|
|
|
+ provider: 'alipay',
|
|
|
+ orderInfo: res.data.tradeNo,
|
|
|
+ success(payRes) {
|
|
|
+ if (payRes.resultCode == '6001') {
|
|
|
+ uni.showToast({ icon: 'none', title: '取消支付' })
|
|
|
+ setTimeout(() => { uni.switchTab({ url: '/pages/order/order' }) }, 2000)
|
|
|
+ } else if (payRes.resultCode == '9000') {
|
|
|
+ uni.showToast({ icon: 'none', title: '支付成功' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/another-tf/another-serve/paySuccessful/index?orderId=' + payInfo.orderId }) }, 2000)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail(err) {
|
|
|
+ uni.showToast({ icon: 'none', title: '支付取消' })
|
|
|
+ setTimeout(() => { uni.switchTab({ url: '/pages/order/order' }) }, 2000)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (e) {
|
|
|
+ uni.showToast({ title: '支付宝支付异常', icon: 'none' })
|
|
|
+ setTimeout(() => { uni.switchTab({ url: '/pages/order/order' }) }, 2000)
|
|
|
+ } finally {
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
+ } else if ([3, 4, 5].includes(payInfo.purchaseMode)) {
|
|
|
+ try {
|
|
|
+ const res = await gotoOrderPayApi(payInfo)
|
|
|
+ uni.requestPayment({
|
|
|
+ provider: 'alipay',
|
|
|
+ orderInfo: res.data.tradeNo,
|
|
|
+ success(payRes) {
|
|
|
+ if (payRes.resultCode == '6001') {
|
|
|
+ uni.showToast({ icon: 'none', title: '取消支付' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' }) }, 2000)
|
|
|
+ } else if (payRes.resultCode == '9000') {
|
|
|
+ uni.showToast({ icon: 'none', title: '支付成功' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/user/otherServe/payment-completed/index' }) }, 2000)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail(err) {
|
|
|
+ uni.showToast({ icon: 'none', title: '支付取消' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' }) }, 2000)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (e) {
|
|
|
+ uni.showToast({ title: '支付宝支付异常', icon: 'none' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' }) }, 2000)
|
|
|
+ } finally {
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ * 微信小程序拉起支付
|
|
|
+ * @param payInfo
|
|
|
+ * @return {Promise<void>}
|
|
|
+ */
|
|
|
+
|
|
|
+async function mpWechatPay(payInfo) {
|
|
|
+ if ([1, 2].includes(payInfo.purchaseMode)) {
|
|
|
+ try {
|
|
|
+ const res = await gotoOrderPayApi(payInfo)
|
|
|
+ uni.requestPayment({
|
|
|
+ provider: 'wxpay',
|
|
|
+ timeStamp: res.data.timeStamp,
|
|
|
+ nonceStr: res.data.nonceStr,
|
|
|
+ package: res.data.package,
|
|
|
+ signType: res.data.signType,
|
|
|
+ paySign: res.data.paySign,
|
|
|
+ success: async (payRes) => {
|
|
|
+
|
|
|
+ if (payInfo.collageId) await payOrderSuccessApi({ orderId: payInfo.orderId, collageId: payInfo.collageId })
|
|
|
+ uni.showToast({ icon: 'none', title: '支付成功' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/another-tf/another-serve/paySuccessful/index?orderId=' + payInfo.orderId }) }, 2000)
|
|
|
+ },
|
|
|
+ fail(err) {
|
|
|
+ uni.showToast({ icon: 'none', title: '用户取消支付' })
|
|
|
+ setTimeout(() => { uni.switchTab({ url: '/pages/order/order' }) }, 2000)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (e) {
|
|
|
+ uni.showToast({ title: '微信支付拉起失败', icon: 'none' })
|
|
|
+ setTimeout(() => { uni.switchTab({ url: '/pages/order/order' }) }, 2000)
|
|
|
+ }
|
|
|
+ } else if ([3, 4, 5].includes(payInfo.purchaseMode)) {
|
|
|
+ try {
|
|
|
+ const res = await gotoOrderPayApi(payInfo)
|
|
|
+ uni.requestPayment({
|
|
|
+ provider: 'wxpay',
|
|
|
+ timeStamp: res.data.timeStamp,
|
|
|
+ nonceStr: res.data.nonceStr,
|
|
|
+ package: res.data.package,
|
|
|
+ signType: res.data.signType,
|
|
|
+ paySign: res.data.paySign,
|
|
|
+ success: async (payRes) => {
|
|
|
+
|
|
|
+ if (payInfo.collageId) await payOrderSuccessApi({ orderId: payInfo.orderId, collageId: payInfo.collageId })
|
|
|
+ uni.showToast({ icon: 'none', title: '支付成功' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/user/otherServe/payment-completed/index' }) }, 2000)
|
|
|
+ },
|
|
|
+ fail(err) {
|
|
|
+ uni.showToast({ icon: 'none', title: '用户取消支付' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' }) }, 2000)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (e) {
|
|
|
+ uni.showToast({ title: '微信支付拉起失败', icon: 'none' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' }) }, 2000)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ * App拉起微信支付
|
|
|
+ * @param payInfo
|
|
|
+ * @return {Promise<void>}
|
|
|
+ */
|
|
|
+
|
|
|
+async function appWechatPay(payInfo) {
|
|
|
+ if ([1, 2].includes(payInfo.purchaseMode)) {
|
|
|
+ try {
|
|
|
+ const res = await gotoOrderAppPayApi(payInfo)
|
|
|
+ const obj = {
|
|
|
+ appid: res.data.appId,
|
|
|
+ noncestr: res.data.nonceStr,
|
|
|
+ package: 'Sign=WXPay',
|
|
|
+ prepayid: res.data.prepayId,
|
|
|
+ timestamp: res.data.timeStamp,
|
|
|
+ sign: res.data.paySign,
|
|
|
+ partnerid: res.data.partnerId
|
|
|
+ }
|
|
|
+ uni.requestPayment({
|
|
|
+ provider: 'wxpay',
|
|
|
+ orderInfo: obj,
|
|
|
+ success(payRes) {
|
|
|
+ uni.showToast({ icon: 'none', title: '支付成功' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/another-tf/another-serve/paySuccessful/index?orderId=' + payInfo.orderId }) }, 2000)
|
|
|
+ },
|
|
|
+ fail(err) {
|
|
|
+ uni.showToast({ icon: 'none', title: '用户取消支付' })
|
|
|
+ setTimeout(() => { uni.switchTab({ url: '/pages/order/order' }) }, 2000)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (e) {
|
|
|
+ uni.showToast({ title: 'APP拉起微信支付失败', icon: 'none' })
|
|
|
+ setTimeout(() => { uni.switchTab({ url: '/pages/order/order' }) }, 2000)
|
|
|
+ } finally {
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
+ } else if ([3, 4, 5].includes(payInfo.purchaseMode)) {
|
|
|
+ try {
|
|
|
+ const res = await gotoOrderAppPayApi(payInfo)
|
|
|
+ const obj = {
|
|
|
+ appid: res.data.appId,
|
|
|
+ noncestr: res.data.nonceStr,
|
|
|
+ package: 'Sign=WXPay',
|
|
|
+ prepayid: res.data.prepayId,
|
|
|
+ timestamp: res.data.timeStamp,
|
|
|
+ sign: res.data.paySign,
|
|
|
+ partnerid: res.data.partnerId
|
|
|
+ }
|
|
|
+ uni.requestPayment({
|
|
|
+ provider: 'wxpay',
|
|
|
+ orderInfo: obj,
|
|
|
+ success(payRes) {
|
|
|
+ uni.showToast({ icon: 'none', title: '支付成功' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/user/otherServe/payment-completed/index' }) }, 2000)
|
|
|
+ },
|
|
|
+ fail(err) {
|
|
|
+ uni.showToast({ icon: 'none', title: '用户取消支付' })
|
|
|
+ uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (e) {
|
|
|
+ uni.showToast({ title: 'APP拉起微信支付失败', icon: 'none' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' }) }, 2000)
|
|
|
+ } finally {
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ * 银行卡支付处理
|
|
|
+ * @param data 结算返回的支付信息
|
|
|
+ */
|
|
|
+
|
|
|
+async function bankCardPay(data, payType, type, otherArgs) {
|
|
|
+ try {
|
|
|
+ let res
|
|
|
+ if ([1, 2].includes(payType)) {
|
|
|
+ } else if (payType === 3) {
|
|
|
+
|
|
|
+
|
|
|
+ } else if (payType === 4) {
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ uni.showToast({ title: '银行卡支付失败', icon: 'none' })
|
|
|
+ setTimeout(() => {
|
|
|
+ if ([1, 2].includes(payType)) {
|
|
|
+ } else if ([3, 4, 5].includes(payType)) {
|
|
|
+ uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' })
|
|
|
+ }
|
|
|
+ }, 2000)
|
|
|
+ } finally {
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ * 通联支付H5处理
|
|
|
+ * @param data 结算返回的支付信息
|
|
|
+ */
|
|
|
+
|
|
|
+async function h5TonglianPay(data, payType, type, otherArgs) {
|
|
|
+ if (isInWx()) {
|
|
|
+ await gotoOrderH5PayApi({
|
|
|
+ ...data,
|
|
|
+ purchaseMode: payType,
|
|
|
+ ...otherArgs
|
|
|
+ }).then((res) => {
|
|
|
+ console.log(JSON.stringify(res.data))
|
|
|
+ if (type) {
|
|
|
+ localStorage.removeItem(T_PAY_ORDER)
|
|
|
+ localStorage.setItem(T_PAY_ORDER, {
|
|
|
+ type,
|
|
|
+ TL_ORDER_NO: data.orderSn
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (!res.data.package) {
|
|
|
+ MessageBox.alert('支付成功', '提示', {
|
|
|
+ confirmButtonText: '确定'
|
|
|
+ }).then(() => {
|
|
|
+ location.reload()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ const payData = JSON.parse(res.data.package)
|
|
|
+ const form = document.createElement('form')
|
|
|
+ form.setAttribute('action', res.data.mwebUrl)
|
|
|
+ form.setAttribute('method', 'POST')
|
|
|
+ let input
|
|
|
+ for (const key in payData) {
|
|
|
+ input = document.createElement('input')
|
|
|
+ input.name = key
|
|
|
+ input.value = payData[key]
|
|
|
+ form.appendChild(input)
|
|
|
+ }
|
|
|
+ document.body.appendChild(form)
|
|
|
+ form.submit()
|
|
|
+ document.body.removeChild(form)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ console.log(e)
|
|
|
+ MessageBox.alert('支付失败', '提示', {
|
|
|
+ confirmButtonText: '确定'
|
|
|
+ }).then(() => {
|
|
|
+ location.reload()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .finally((e) => {
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ MessageBox.alert('通联支付只支持微信环境!', '提示', {
|
|
|
+ confirmButtonText: '确定'
|
|
|
+ })
|
|
|
+ await getPayMiniProgramQueryApi({
|
|
|
+ orderNo: data.orderSn,
|
|
|
+ purchaseMode: payType,
|
|
|
+ paymentMode: data.paymentMode,
|
|
|
+ ...otherArgs
|
|
|
+ }).then((res) => {
|
|
|
+ console.log(JSON.stringify(res.data))
|
|
|
+ if (res.code == 200) {
|
|
|
+ if (type) {
|
|
|
+ uni.removeStorageSync(T_PAY_ORDER)
|
|
|
+ uni.setStorageSync(T_PAY_ORDER, {
|
|
|
+ type,
|
|
|
+ TL_ORDER_NO: data.orderSn
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (res.data.isZeroOrder === '1') {
|
|
|
+ uni.redirectTo({ url: '/user/otherServe/payment-completed/index' })
|
|
|
+ } else {
|
|
|
+ delete res.data.isZeroOrder
|
|
|
+ let query = ''
|
|
|
+ for (const key in res.data) {
|
|
|
+ query += key + '=' + res.data[key] + '&'
|
|
|
+ }
|
|
|
+ location.href = `weixin://dl/business/?appid=wx3cef6c7325c38a45&path=pages/loading/loading&query=${query}orderNo=${data.orderSn}&userId=${getUserId()}`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally((e) => {
|
|
|
+ uni.hideLoading()
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ * 通联支付webview套壳处理
|
|
|
+ * @param data 结算返回的支付信息
|
|
|
+ */
|
|
|
+
|
|
|
+async function wvTonglianPay(data, payType, type, otherArgs) {
|
|
|
+ await getPayMiniProgramQueryApi({
|
|
|
+ orderNo: data.orderSn,
|
|
|
+ purchaseMode: payType,
|
|
|
+ paymentMode: data.paymentMode,
|
|
|
+ ...otherArgs
|
|
|
+ }).then((res) => {
|
|
|
+ console.log(JSON.stringify(res.data))
|
|
|
+ if (res.code == 200) {
|
|
|
+ if (type) {
|
|
|
+ uni.removeStorageSync(T_PAY_ORDER)
|
|
|
+ uni.setStorageSync(T_PAY_ORDER, {
|
|
|
+ type,
|
|
|
+ TL_ORDER_NO: data.orderSn
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (res.data.isZeroOrder === '1') {
|
|
|
+ uni.redirectTo({ url: '/user/otherServe/payment-completed/index' })
|
|
|
+ } else {
|
|
|
+ delete res.data.isZeroOrder
|
|
|
+ let query = ''
|
|
|
+ for (const key in res.data) {
|
|
|
+ query += key + '=' + res.data[key] + '&'
|
|
|
+ }
|
|
|
+ wx.miniProgram.navigateTo({
|
|
|
+ url: '/pages/loading/loading?' + query + 'orderNo=' + data.orderSn + '&userId=' + getUserId(),
|
|
|
+ fail: () => {
|
|
|
+ uni.switchTab({
|
|
|
+ url: '/pages/order/order'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally((e) => {
|
|
|
+ uni.hideLoading()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ * 通联支付APP处理
|
|
|
+ * @param data 结算返回的支付信息
|
|
|
+ */
|
|
|
+
|
|
|
+async function appTonglianPay(data, payType, type, otherArgs) {
|
|
|
+ await getPayMiniProgramQueryApi({
|
|
|
+ orderFormid: data.orderFormid,
|
|
|
+ orderNo: data.orderSn,
|
|
|
+ purchaseMode: payType,
|
|
|
+ paymentMode: data.paymentMode,
|
|
|
+ ...otherArgs
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ if (type) {
|
|
|
+ uni.removeStorageSync(T_PAY_ORDER)
|
|
|
+ uni.setStorageSync(T_PAY_ORDER, {
|
|
|
+ type,
|
|
|
+ TL_ORDER_NO: data.orderSn
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (res.data.isZeroOrder === '1') {
|
|
|
+ uni.redirectTo({ url: '/user/otherServe/payment-completed/index' })
|
|
|
+ } else {
|
|
|
+ delete res.data.isZeroOrder
|
|
|
+ let query = ''
|
|
|
+ for (const key in res.data) {
|
|
|
+ query += key + '=' + res.data[key] + '&'
|
|
|
+ }
|
|
|
+ plus.share.getServices(function (result) {
|
|
|
+ let sweixin = null
|
|
|
+ for (const i in result) {
|
|
|
+ if (result[i].id == 'weixin') {
|
|
|
+ sweixin = result[i]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sweixin) {
|
|
|
+ sweixin.launchMiniProgram({
|
|
|
+ id: 'gh_e64a1a89a0ad',
|
|
|
+ type: 0,
|
|
|
+ path: 'pages/orderDetail/orderDetail?' + query
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.showToast({ title: '请先安装微信', icon: 'none' })
|
|
|
+ }
|
|
|
+ }, function (e) {
|
|
|
+ uni.showToast({ title: '获取分享服务列表失败', icon: 'none' })
|
|
|
+ console.log('获取分享服务列表失败:' + e.message)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally((e) => {
|
|
|
+ uni.hideLoading()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ * 惠市宝支付H5处理
|
|
|
+ * @param data 结算返回的支付信息
|
|
|
+ */
|
|
|
+
|
|
|
+async function h5HuiShiBaoPay(data, payType, type, otherArgs) {
|
|
|
+ await gotoOrderH5PayApi({
|
|
|
+ ...data,
|
|
|
+ purchaseMode: payType,
|
|
|
+ ...otherArgs
|
|
|
+ }).then((res) => {
|
|
|
+ console.log(JSON.stringify(res.data))
|
|
|
+ if (type) {
|
|
|
+ uni.removeStorageSync(T_PAY_ORDER)
|
|
|
+ uni.setStorageSync(T_PAY_ORDER, {
|
|
|
+ type,
|
|
|
+ TL_ORDER_NO: data.orderSn
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (!res.data.Cshdk_Url) {
|
|
|
+ uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' })
|
|
|
+ } else {
|
|
|
+ const payData = res.data
|
|
|
+ const form = document.createElement('form')
|
|
|
+ form.setAttribute('action', res.data.Cshdk_Url)
|
|
|
+ form.setAttribute('method', 'POST')
|
|
|
+ let input
|
|
|
+ for (const key in payData) {
|
|
|
+ input = document.createElement('input')
|
|
|
+ input.name = key
|
|
|
+ input.value = payData[key]
|
|
|
+ form.appendChild(input)
|
|
|
+ }
|
|
|
+ document.body.appendChild(form)
|
|
|
+ form.submit()
|
|
|
+ document.body.removeChild(form)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ console.log(e)
|
|
|
+ uni.showToast({ title: '支付失败', icon: 'none' })
|
|
|
+ setTimeout(() => {
|
|
|
+ if ([1, 2].includes(payType)) {
|
|
|
+ uni.switchTab({ url: '/pages/order/order' })
|
|
|
+ } else if ([3, 4, 5].includes(payType)) {
|
|
|
+ uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' })
|
|
|
+ }
|
|
|
+ }, 2000)
|
|
|
+ })
|
|
|
+ .finally((e) => {
|
|
|
+ uni.hideLoading()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ * 惠市宝支付webview套壳处理
|
|
|
+ * @param data 结算返回的支付信息
|
|
|
+ */
|
|
|
+
|
|
|
+async function wvHuiShiBaoPay(data, payType, type, otherArgs) {
|
|
|
+
|
|
|
+ if (typeof otherArgs.isSuccess === 'number') {
|
|
|
+ if (otherArgs.isSuccess) {
|
|
|
+ if ([1, 2, 3, 4, 5].includes(payType)) {
|
|
|
+ if (data.collageId) await payOrderSuccessApi({ orderId: data.orderId, collageId: data.collageId })
|
|
|
+ uni.redirectTo({ url: '/user/otherServe/payment-completed/index' })
|
|
|
+ }
|
|
|
+ } else if ([1, 2, 3, 4, 5].includes(payType)) {
|
|
|
+ uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (type) {
|
|
|
+ uni.removeStorageSync(T_PAY_ORDER)
|
|
|
+ uni.setStorageSync(T_PAY_ORDER, {
|
|
|
+ type,
|
|
|
+ TL_ORDER_NO: data.orderSn
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const res = uni.getStorageSync(T_STORAGE_KEY) || {}
|
|
|
+ if (res.token) res.Authorization = res.token
|
|
|
+ if (res.ssoUserInfo && res.ssoUserInfo.token) res['satoken-user'] = res.ssoUserInfo.token
|
|
|
+ jumpToOtherProject({
|
|
|
+ isInMiniProgram: store.state.app.isInMiniProgram,
|
|
|
+ id: 'gh_c5b32d0f9bc9',
|
|
|
+ appId: 'wx3cef6c7325c38a45',
|
|
|
+ url: `pages/skip/skip`,
|
|
|
+ programUrl: `pages/skip/skip`,
|
|
|
+ toType: 'MP',
|
|
|
+ query: `?type=wvHuiShiBaoPay&data=${encodeURIComponent(JSON.stringify({ data, payType, type, otherArgs, jumpType: `wvHuiShiBaoPayTurn`, Authorization: res.Authorization || '', satokenUser: res['satoken-user'] || '', baseUrl: ANOTHER_TF_INTERFACE }))}`,
|
|
|
+ montageTerminal: [6, 5, 1, 2, 4]
|
|
|
+ })
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ * 惠市宝支付微信小程序处理
|
|
|
+ * @param data 结算返回的支付信息
|
|
|
+ */
|
|
|
+
|
|
|
+function mpHuiShiBaoPay(data, payType, type, otherArgs) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ const failOperation = (failText = '支付失败') => {
|
|
|
+ uni.showToast({ title: failText, icon: 'none' })
|
|
|
+ setTimeout(() => {
|
|
|
+ if ([1, 2].includes(payType)) {
|
|
|
+ uni.switchTab({ url: '/pages/order/order' })
|
|
|
+ } else if ([3, 4, 5].includes(payType)) {
|
|
|
+ uni.redirectTo({ url: '/user/otherServe/payment-completed/index?state=fail' })
|
|
|
+ }
|
|
|
+ }, 2000)
|
|
|
+ }
|
|
|
+ uni.login({
|
|
|
+ provider: 'weixin',
|
|
|
+ success: (res) => {
|
|
|
+ getSessionKeyAppApi({ code: res.code, _isShowToast: false })
|
|
|
+ .then(async (res1) => {
|
|
|
+ await gotoOrderH5PayApi({
|
|
|
+ ...data,
|
|
|
+ purchaseMode: payType,
|
|
|
+ ...otherArgs,
|
|
|
+ hsbSubPayType: '05',
|
|
|
+ extJsonStr: JSON.stringify({
|
|
|
+ 'Sub_Appid': 'wx3cef6c7325c38a45',
|
|
|
+ 'Sub_Openid': res1.data.wechatOpenId
|
|
|
+ }),
|
|
|
+ _isShowToast: false
|
|
|
+ }).then((res2) => {
|
|
|
+ if (type) {
|
|
|
+ uni.removeStorageSync(T_PAY_ORDER)
|
|
|
+ uni.setStorageSync(T_PAY_ORDER, {
|
|
|
+ type,
|
|
|
+ TL_ORDER_NO: data.orderSn
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (res2.data.Rtn_Par_Data) {
|
|
|
+ const paymentObj = JSON.parse(res2.data.Rtn_Par_Data)
|
|
|
+ uni.requestPayment({
|
|
|
+ provider: 'wxpay',
|
|
|
+ timeStamp: paymentObj.timeStamp,
|
|
|
+ nonceStr: paymentObj.nonceStr,
|
|
|
+ package: paymentObj.package,
|
|
|
+ signType: paymentObj.signType,
|
|
|
+ paySign: paymentObj.paySign,
|
|
|
+ success: async (res3) => {
|
|
|
+ if (data.collageId) await payOrderSuccessApi({ orderId: data.orderId, collageId: data.collageId })
|
|
|
+ uni.showToast({ icon: 'none', title: '支付成功' })
|
|
|
+ setTimeout(() => { uni.redirectTo({ url: '/user/otherServe/payment-completed/index' }) }, 2000)
|
|
|
+ resolve('支付成功')
|
|
|
+ },
|
|
|
+ fail(e) {
|
|
|
+ console.log(e)
|
|
|
+ failOperation('支付失败!' + e)
|
|
|
+ reject('支付失败!' + e)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.hideLoading()
|
|
|
+ failOperation('缺少支付信息')
|
|
|
+ reject('缺少支付信息')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ uni.hideLoading()
|
|
|
+ if (e.data) failOperation(`${e.data.message}-${e.data.errorData}`)
|
|
|
+ else failOperation(`请求:${e.errMsg}`)
|
|
|
+ reject(e)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ uni.hideLoading()
|
|
|
+ if (e.data) failOperation(`${e.data.message}-${e.data.errorData}`)
|
|
|
+ else failOperation(`请求:${e.errMsg}`)
|
|
|
+ reject(e)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ uni.hideLoading()
|
|
|
+ failOperation('鉴权失败!')
|
|
|
+ reject('鉴权失败!')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ * 处理支付
|
|
|
+ * @param submitResult 结算结果
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+export async function handleDoPay(submitResult, purchaseMode, type = 'DEFAULT', otherArgs = {}) {
|
|
|
+ uni.showLoading({
|
|
|
+ mask: true,
|
|
|
+ title: '支付中...'
|
|
|
+ })
|
|
|
+ console.log(JSON.stringify(submitResult))
|
|
|
+ if (purchaseMode) {
|
|
|
+ const submitInfo = { ...submitResult, purchaseMode }
|
|
|
+ if (submitInfo.paymentMode === 999) {
|
|
|
+ await bankCardPay(submitResult, purchaseMode, type, otherArgs)
|
|
|
+ } else if ([ 1 ].includes(submitInfo.paymentMode)) {
|
|
|
+ if (isInWx()) {
|
|
|
+ if (store.state.app.isInMiniProgram) {
|
|
|
+ await payH5InWechat(submitInfo)
|
|
|
+ } else {
|
|
|
+ await payH5InWechat(submitInfo)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ await payH5InEquipment(submitInfo)
|
|
|
+
|
|
|
+
|
|
|
+ await appWechatPay(submitInfo)
|
|
|
+
|
|
|
+
|
|
|
+ await mpWechatPay(submitInfo)
|
|
|
+
|
|
|
+
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showToast({ title: '暂不支持在支付宝小程序使用微信支付', icon: 'none' })
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ([2, 3].includes(submitInfo.paymentMode)) {
|
|
|
+ if (isInWx()) {
|
|
|
+ if (store.state.app.isInMiniProgram) {
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showToast({ title: '暂不支持在此端使用支付宝支付', icon: 'none' })
|
|
|
+ } else {
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showToast({ title: '暂不支持在此端使用支付宝支付', icon: 'none' })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showToast({ title: '暂不支持在此端使用支付宝支付', icon: 'none' })
|
|
|
+
|
|
|
+
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showToast({ title: '暂不支持在此端使用支付宝支付', icon: 'none' })
|
|
|
+
|
|
|
+
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showToast({ title: '暂不支持在此端使用支付宝支付', icon: 'none' })
|
|
|
+
|
|
|
+
|
|
|
+ await zhiAliPay(submitInfo)
|
|
|
+ throw new Error('支付宝相关支付暂时只支持支付宝小程序')
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ([ 4 ].includes(submitInfo.paymentMode)) {
|
|
|
+ if (isInWx()) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ await h5TonglianPay(submitResult, purchaseMode, type, otherArgs)
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ await h5TonglianPay(submitResult, purchaseMode, type, otherArgs)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ([5, 6, 7, 8].includes(submitInfo.paymentMode)) {
|
|
|
+ if (isInWx()) {
|
|
|
+ if (store.state.app.isInMiniProgram) {
|
|
|
+ await h5TonglianPay(submitResult, purchaseMode, type, otherArgs)
|
|
|
+ } else {
|
|
|
+ await h5TonglianPay(submitResult, purchaseMode, type, otherArgs)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ await h5TonglianPay(submitResult, purchaseMode, type, otherArgs)
|
|
|
+
|
|
|
+
|
|
|
+ await h5TonglianPay(submitResult, purchaseMode, type, otherArgs)
|
|
|
+
|
|
|
+
|
|
|
+ await h5TonglianPay(submitResult, purchaseMode, type, otherArgs)
|
|
|
+
|
|
|
+
|
|
|
+ await h5TonglianPay(submitResult, purchaseMode, type, otherArgs)
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ([ 9 ].includes(submitInfo.paymentMode)) {
|
|
|
+ if (isInWx()) {
|
|
|
+ if (store.state.app.isInMiniProgram) {
|
|
|
+ await wvHuiShiBaoPay(submitResult, purchaseMode, type, otherArgs)
|
|
|
+ } else {
|
|
|
+ await h5HuiShiBaoPay(submitResult, purchaseMode, type, otherArgs)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ await h5HuiShiBaoPay(submitResult, purchaseMode, type, otherArgs)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ await wvHuiShiBaoPay(submitResult, purchaseMode, type, otherArgs)
|
|
|
+
|
|
|
+
|
|
|
+ await mpHuiShiBaoPay(submitResult, purchaseMode, type, otherArgs)
|
|
|
+
|
|
|
+
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showToast({ title: '暂不支持在支付宝小程序使用惠市宝支付', icon: 'none' })
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|