Merge branch 'feature/mall_product' of http://117.33.142.185:3000/zenghuapei/cyywl_server into feature/mall_product
commit
dd3c95971d
|
@ -37,8 +37,8 @@ public class TenantContextHolder {
|
||||||
public static Long getRequiredTenantId() {
|
public static Long getRequiredTenantId() {
|
||||||
Long tenantId = getTenantId();
|
Long tenantId = getTenantId();
|
||||||
if (tenantId == null) {
|
if (tenantId == null) {
|
||||||
throw new NullPointerException("TenantContextHolder 不存在租户编号!可参考文档:"
|
throw new NullPointerException("商户id不存在"
|
||||||
+ DocumentEnum.TENANT.getUrl());
|
);
|
||||||
}
|
}
|
||||||
return tenantId;
|
return tenantId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1262,11 +1262,11 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
|
||||||
RechargeGearDO rechargeGearDO = rechargeGearService.getRechargeGear(rechargeGearId.toString());
|
RechargeGearDO rechargeGearDO = rechargeGearService.getRechargeGear(rechargeGearId.toString());
|
||||||
PhoneRecordDO phoneRecordDO = new PhoneRecordDO();
|
PhoneRecordDO phoneRecordDO = new PhoneRecordDO();
|
||||||
PhoneRecordAdd phoneRecordAdd = new PhoneRecordAdd();
|
PhoneRecordAdd phoneRecordAdd = new PhoneRecordAdd();
|
||||||
phoneRecordDO.setUserId(Long.valueOf(orderDO.getUid()));
|
phoneRecordDO.setUserId(orderDO.getUid());
|
||||||
phoneRecordDO.setRechargeOrderId(Long.valueOf(orderDO.getId()));
|
phoneRecordDO.setRechargeOrderId(orderDO.getId());
|
||||||
phoneRecordDO.setPhone(orderDO.getUserPhone());
|
phoneRecordDO.setPhone(orderDO.getUserPhone());
|
||||||
phoneRecordDO.setRefundFeeAmount(replace(info.getPrice()));
|
phoneRecordDO.setRefundFeeAmount(replace(info.getPrice()));
|
||||||
phoneRecordDO.setRechargeGearId(Long.valueOf(info.getRechargeGearId()));
|
phoneRecordDO.setRechargeGearId(info.getRechargeGearId());
|
||||||
LocalDateTime localDateTime = LocalDateTime.now();
|
LocalDateTime localDateTime = LocalDateTime.now();
|
||||||
LocalDateTime newLocalDateTime = LocalDateTimeUtil.offset(localDateTime, 12, ChronoUnit.MONTHS);
|
LocalDateTime newLocalDateTime = LocalDateTimeUtil.offset(localDateTime, 12, ChronoUnit.MONTHS);
|
||||||
phoneRecordDO.setRefundFeeEndDate(newLocalDateTime);
|
phoneRecordDO.setRefundFeeEndDate(newLocalDateTime);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
import cn.iocoder.yudao.module.shop.controller.app.recharge.vo.PhoneRecordAdd;
|
import cn.iocoder.yudao.module.shop.controller.app.recharge.vo.PhoneRecordAdd;
|
||||||
|
@ -18,10 +19,12 @@ import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*;
|
import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*;
|
||||||
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.PhoneRecordDO;
|
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.PhoneRecordDO;
|
||||||
|
@ -81,16 +84,13 @@ public class PhoneRecordServiceImpl implements PhoneRecordService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@TenantIgnore
|
||||||
|
@Transactional
|
||||||
public Boolean deletePhoneGearByOrderId(Long orderId) {
|
public Boolean deletePhoneGearByOrderId(Long orderId) {
|
||||||
log.info("-------------------------orderId{}",orderId);
|
|
||||||
List<PhoneRecordDO> recordDOS = phoneRecordMapper.selectList(Wrappers.<PhoneRecordDO>lambdaQuery().eq(PhoneRecordDO::getRechargeOrderId, orderId));
|
List<PhoneRecordDO> recordDOS = phoneRecordMapper.selectList(Wrappers.<PhoneRecordDO>lambdaQuery().eq(PhoneRecordDO::getRechargeOrderId, orderId));
|
||||||
log.info("-------------------------recordDOS{},{}",recordDOS,recordDOS.size());
|
|
||||||
if (!CollectionUtils.isEmpty(recordDOS)) {
|
if (!CollectionUtils.isEmpty(recordDOS)) {
|
||||||
recordDOS.forEach(e->{
|
Set<Long> ids = recordDOS.stream().map(PhoneRecordDO::getId).collect(Collectors.toSet());
|
||||||
e.setDeleted(Boolean.TRUE);
|
phoneRecordMapper.deleteBatchIds(ids);
|
||||||
int i = phoneRecordMapper.updateById(e);
|
|
||||||
log.info("-------------------------i{}---------------------",i);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
FROM
|
FROM
|
||||||
eb_shipping_templates_free
|
eb_shipping_templates_free
|
||||||
where
|
where
|
||||||
temp_id = #{tempId, jdbcType=INTEGER} AND `status` = true
|
temp_id = #{tempId, jdbcType=INTEGER} AND `status` = 1
|
||||||
GROUP BY
|
GROUP BY
|
||||||
`uniqid`
|
`uniqid`
|
||||||
ORDER BY id ASC
|
ORDER BY id ASC
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
FROM
|
FROM
|
||||||
eb_shipping_templates_no_delivery
|
eb_shipping_templates_no_delivery
|
||||||
where
|
where
|
||||||
temp_id = #{tempId, jdbcType=INTEGER} AND `status` = true
|
temp_id = #{tempId, jdbcType=INTEGER}
|
||||||
GROUP BY
|
GROUP BY
|
||||||
`uniqid`
|
`uniqid`
|
||||||
ORDER BY id ASC
|
ORDER BY id ASC
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
FROM
|
FROM
|
||||||
eb_shipping_templates_region
|
eb_shipping_templates_region
|
||||||
where
|
where
|
||||||
temp_id = #{tempId, jdbcType=INTEGER} AND `status` = true
|
temp_id = #{tempId, jdbcType=INTEGER} AND `status` = 1
|
||||||
GROUP BY
|
GROUP BY
|
||||||
`uniqid`
|
`uniqid`
|
||||||
ORDER BY id ASC
|
ORDER BY id ASC
|
||||||
|
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.util.IdUtil;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||||
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||||
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.user.dto.AdminUserQueryDTO;
|
import cn.iocoder.yudao.module.member.controller.admin.user.dto.AdminUserQueryDTO;
|
||||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserUpdateMobileReqVO;
|
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserUpdateMobileReqVO;
|
||||||
|
@ -104,6 +105,7 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||||
user.setPassword(encodePassword("123456")); // 加密密码
|
user.setPassword(encodePassword("123456")); // 加密密码
|
||||||
user.setRegisterIp(registerIp);
|
user.setRegisterIp(registerIp);
|
||||||
user.setPromoterId(promoterId);
|
user.setPromoterId(promoterId);
|
||||||
|
user.setTenantId(TenantContextHolder.getRequiredTenantId());
|
||||||
memberUserMapper.insert(user);
|
memberUserMapper.insert(user);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,5 +240,5 @@ wx:
|
||||||
database: 16 # 数据库索引
|
database: 16 # 数据库索引
|
||||||
password: 20221122@dev # 密码,建议生产环境开启
|
password: 20221122@dev # 密码,建议生产环境开启
|
||||||
phone:
|
phone:
|
||||||
query-url: http://phone.cyywl.top/cyywl-phone-query-api/
|
query-url: http://cy-phone-bill-inquiry-server:4006/cyywl-phone-query-api/
|
||||||
token: eyIwLnR5cCI6IkpXVCIsImFsZyI6IkhTNTEyIn0
|
token: eyIwLnR5cCI6IkpXVCIsImFsZyI6IkhTNTEyIn0
|
|
@ -222,3 +222,7 @@ wx:
|
||||||
port: 6369 # 端口
|
port: 6369 # 端口
|
||||||
database: 16 # 数据库索引
|
database: 16 # 数据库索引
|
||||||
password: 20221122@dev # 密码,建议生产环境开启
|
password: 20221122@dev # 密码,建议生产环境开启
|
||||||
|
|
||||||
|
phone:
|
||||||
|
query-url: https://cmx.bskies.cc:8000/cyywl-phone-query-api/
|
||||||
|
token: eyIwLnR5cCI6IkpXVCIsImFsZyI6IkhTNTEyIn0
|
||||||
|
|
|
@ -75,14 +75,14 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- 社交登录 -->
|
<!-- 社交登录 -->
|
||||||
<el-form-item style="width:100%;">
|
<!-- <el-form-item style="width:100%;">-->
|
||||||
<div class="oauth-login" style="display:flex">
|
<!-- <div class="oauth-login" style="display:flex">-->
|
||||||
<div class="oauth-login-item" v-for="item in SysUserSocialTypeEnum" :key="item.type" @click="doSocialLogin(item)">
|
<!-- <div class="oauth-login-item" v-for="item in SysUserSocialTypeEnum" :key="item.type" @click="doSocialLogin(item)">-->
|
||||||
<img :src="item.img" height="25px" width="25px" alt="登录" >
|
<!-- <img :src="item.img" height="25px" width="25px" alt="登录" >-->
|
||||||
<span>{{item.title}}</span>
|
<!-- <span>{{item.title}}</span>-->
|
||||||
</div>
|
<!-- </div>-->
|
||||||
</div>
|
<!-- </div>-->
|
||||||
</el-form-item>
|
<!-- </el-form-item>-->
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -132,8 +132,8 @@ export default {
|
||||||
mobileCodeTimer: 0,
|
mobileCodeTimer: 0,
|
||||||
loginForm: {
|
loginForm: {
|
||||||
loginType: "uname",
|
loginType: "uname",
|
||||||
username: "admin",
|
username: "",
|
||||||
password: "admin123",
|
password: "",
|
||||||
captchaVerification: "",
|
captchaVerification: "",
|
||||||
mobile: "",
|
mobile: "",
|
||||||
mobileCode: "",
|
mobileCode: "",
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
<el-input v-model="form.title" placeholder="请输入标题"/>
|
<el-input v-model="form.title" placeholder="请输入标题"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="缩略图" prop="picUrl">
|
<el-form-item label="缩略图" prop="picUrl">
|
||||||
<imageUpload v-model="form.picUrl" :limit="5"/>
|
<imageUpload v-model="form.picUrl" :limit="1"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="跳转链接" prop="url">
|
<el-form-item label="跳转链接" prop="url">
|
||||||
<el-input v-model="form.url" placeholder="请输入跳转链接"/>
|
<el-input v-model="form.url" placeholder="请输入跳转链接"/>
|
||||||
|
|
|
@ -65,10 +65,10 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
<!-- <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"-->
|
||||||
v-hasPermi="['member:user:update']">查看</el-button>
|
<!-- v-hasPermi="['member:user:update']">查看</el-button>-->
|
||||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
<!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"-->
|
||||||
v-hasPermi="['member:user:delete']">删除</el-button>
|
<!-- v-hasPermi="['member:user:delete']">删除</el-button>-->
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
|
@ -20,8 +20,7 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="mask" @click='close' v-if="pay_close"></view>
|
<view class="mask" @click='close' v-if="pay_close"></view>
|
||||||
<button style="cursor: pointer;display:none;" class="clipboard"
|
<button style="cursor: pointer;display:none;" class="clipboard" :data-clipboard-text="alipayLink">
|
||||||
:data-clipboard-text="alipayLink">
|
|
||||||
</button>
|
</button>
|
||||||
<!-- 支付宝支付界面 -->
|
<!-- 支付宝支付界面 -->
|
||||||
<u-modal :show="alipayShow" title="支付宝支付" @confirm="handleConfirm">
|
<u-modal :show="alipayShow" title="支付宝支付" @confirm="handleConfirm">
|
||||||
|
@ -38,6 +37,7 @@
|
||||||
wechatOrderPay,
|
wechatOrderPay,
|
||||||
wechatQueryPayResult
|
wechatQueryPayResult
|
||||||
} from '@/api/order.js';
|
} from '@/api/order.js';
|
||||||
|
import uniPay from '@/libs/pay.js'
|
||||||
import {
|
import {
|
||||||
memberTopUp
|
memberTopUp
|
||||||
} from '@/api/member.js';
|
} from '@/api/member.js';
|
||||||
|
@ -82,126 +82,32 @@
|
||||||
this.alipayShow = false
|
this.alipayShow = false
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
},
|
},
|
||||||
// 复制操作
|
|
||||||
_copy(context) {
|
|
||||||
// 创建输入框元素
|
|
||||||
let oInput = document.createElement('input');
|
|
||||||
// 将想要复制的值
|
|
||||||
oInput.value = context;
|
|
||||||
// 页面底部追加输入框
|
|
||||||
document.body.appendChild(oInput);
|
|
||||||
// 选中输入框
|
|
||||||
oInput.select();
|
|
||||||
// 执行浏览器复制命令
|
|
||||||
document.execCommand('Copy');
|
|
||||||
// 弹出复制成功信息
|
|
||||||
this.$util.Tips({
|
|
||||||
title: '复制链接成功'
|
|
||||||
})
|
|
||||||
this.alipayShow = true
|
|
||||||
// 复制后移除输入框
|
|
||||||
oInput.remove();
|
|
||||||
},
|
|
||||||
close: function() {
|
close: function() {
|
||||||
this.$emit('onChangeFun', {
|
this.$emit('onChangeFun', {
|
||||||
action: 'payClose'
|
action: 'payClose'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 微信支付JSAPI调起
|
// 微信支付JSAPI调起
|
||||||
wxPayJSAPI(payData) {
|
|
||||||
function onBridgeReady() {
|
|
||||||
WeixinJSBridge.invoke('getBrandWCPayRequest', {
|
|
||||||
"appId": payData.appId, //公众号ID,由商户传入
|
|
||||||
"timeStamp": payData.timeStamp, //时间戳,自1970年以来的秒数
|
|
||||||
"nonceStr": payData.nonceStr, //随机串
|
|
||||||
"package": payData.packageValue,
|
|
||||||
"signType": payData.signType, //微信签名方式:
|
|
||||||
"paySign": payData.paySign //微信签名
|
|
||||||
},
|
|
||||||
function(res) {
|
|
||||||
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
|
||||||
window.location.reload()
|
|
||||||
// uni.switchTab({
|
|
||||||
// url: '/pages/member_application/index'
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (typeof WeixinJSBridge == "undefined") {
|
|
||||||
if (document.addEventListener) {
|
|
||||||
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
|
|
||||||
} else if (document.attachEvent) {
|
|
||||||
document.attachEvent('WeixinJSBridgeReady', onBridgeReady)
|
|
||||||
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
onBridgeReady()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
goPay: function(paytype) {
|
goPay: function(paytype) {
|
||||||
let that = this;
|
let that = this;
|
||||||
if (that.payInfo.orderInfos.length === 0) return that.$util.Tips({
|
if (that.payInfo.orderInfos.length === 0) return that.$util.Tips({
|
||||||
title: '请选择要支付的订单'
|
title: '请选择要支付的订单'
|
||||||
});
|
});
|
||||||
uni.showLoading({
|
uniPay({
|
||||||
title: '支付中',
|
payInfo: that.payInfo,
|
||||||
mask: true
|
payType: paytype,
|
||||||
});
|
createOrderFun: memberTopUp,
|
||||||
if(paytype === 'WXPAY' && that.openId) {
|
wxPaySuccess: () => {
|
||||||
that.payInfo.openid = that.openId
|
window.location.reload()
|
||||||
|
},
|
||||||
} else if(paytype === 'WXPAY' && !that.openId){
|
aliPaySuccess: (link) => {
|
||||||
return that.$util.Tips({
|
that.alipayLink = link
|
||||||
title: '请在微信客户端进行支付操作'
|
setTimeout(() => {
|
||||||
});
|
document.querySelector(".clipboard").click();
|
||||||
}
|
that.alipayShow = true
|
||||||
memberTopUp({
|
}, 500)
|
||||||
...that.payInfo,
|
|
||||||
payType: paytype
|
|
||||||
}).then(res => {
|
|
||||||
let jsConfig = res.data
|
|
||||||
switch (paytype) {
|
|
||||||
case 'WXPAY':
|
|
||||||
uni.hideLoading();
|
|
||||||
that.wxPayJSAPI(jsConfig.jsapiResult)
|
|
||||||
break;
|
|
||||||
case 'ALIPAY':
|
|
||||||
uni.hideLoading();
|
|
||||||
this.alipayLink = jsConfig.body
|
|
||||||
// this._copy(jsConfig.body)
|
|
||||||
setTimeout(()=>{
|
|
||||||
document.querySelector(".clipboard").click();
|
|
||||||
this.alipayShow = true
|
|
||||||
}, 500)
|
|
||||||
// const div = document.createElement('div')
|
|
||||||
// /* 下面的data.content就是后台返回接收到的数据 */
|
|
||||||
// div.innerHTML = jsConfig.body
|
|
||||||
// document.body.appendChild(div)
|
|
||||||
// document.forms[0].submit()
|
|
||||||
break;
|
|
||||||
case 'weixinh5':
|
|
||||||
uni.hideLoading();
|
|
||||||
location.replace(jsConfig.mwebUrl + '&redirect_url=' + window.location.protocol +
|
|
||||||
'//' + window.location.host + goPages + '&status=1');
|
|
||||||
return that.$util.Tips({
|
|
||||||
title: "支付中",
|
|
||||||
icon: 'success'
|
|
||||||
}, () => {
|
|
||||||
that.$emit('onChangeFun', {
|
|
||||||
action: 'pay_complete'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
|
||||||
uni.hideLoading();
|
|
||||||
return that.$util.Tips({
|
|
||||||
title: err
|
|
||||||
}, () => {
|
|
||||||
that.$emit('onChangeFun', {
|
|
||||||
action: 'pay_fail'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
import util from 'utils/util'
|
||||||
|
import store from '@/store'
|
||||||
|
|
||||||
|
const payTypes = ['WXPAY', 'ALIPAY']
|
||||||
|
/**
|
||||||
|
* 统一支付处理方法
|
||||||
|
* @param payInfo // 支付下单信息
|
||||||
|
* @param payType // 支付类型
|
||||||
|
* @param createOrderFun // 预下单方法
|
||||||
|
* @param wxPaySuccess // 微信支付成功回调
|
||||||
|
* @param aliPaySuccess // 支付宝支付成功回调
|
||||||
|
*/
|
||||||
|
const unityPay = (options) => {
|
||||||
|
let _options = {
|
||||||
|
payInfo: {},
|
||||||
|
payType: '',
|
||||||
|
createOrderFun: () => {},
|
||||||
|
wxPaySuccess: () => {},
|
||||||
|
aliPaySuccess: () => {}
|
||||||
|
}
|
||||||
|
Object.assign(_options, options)
|
||||||
|
if (!_options.payType) {
|
||||||
|
return util.Tips({
|
||||||
|
title: '请选择支付方式'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (!payTypes.includes(_options.payType)) {
|
||||||
|
throw new Error('支付方式参数值为 WXPAY、ALIPAY')
|
||||||
|
}
|
||||||
|
// 目前微信只支持JSAPI,h5支付开通后取消该验证
|
||||||
|
const openId = store.state.app.openId || ''
|
||||||
|
if (_options.payType === 'WXPAY' && !openId) {
|
||||||
|
return util.Tips({
|
||||||
|
title: '请在微信客户端进行支付操作'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
_options.payInfo.openid = openId
|
||||||
|
uni.showLoading({
|
||||||
|
title: '支付中',
|
||||||
|
mask: true
|
||||||
|
})
|
||||||
|
_options.createOrderFun({
|
||||||
|
..._options.payInfo,
|
||||||
|
payType: _options.payType
|
||||||
|
}).then(res => {
|
||||||
|
const payConfig = res.data
|
||||||
|
switch (_options.payType) {
|
||||||
|
// 微信JSAPI支付
|
||||||
|
case 'WXPAY':
|
||||||
|
wxPayJSAPI(payConfig.jsapiResult)
|
||||||
|
break
|
||||||
|
case 'ALIPAY':
|
||||||
|
_options.aliPaySuccess(payConfig.body)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
util.Tips({
|
||||||
|
title: '预下单失败'
|
||||||
|
})
|
||||||
|
}).finally(uni.hideLoading)
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxPayJSAPI = (payData) => {
|
||||||
|
function onBridgeReady() {
|
||||||
|
WeixinJSBridge.invoke('getBrandWCPayRequest', {
|
||||||
|
"appId": payData.appId, //公众号ID,由商户传入
|
||||||
|
"timeStamp": payData.timeStamp, //时间戳,自1970年以来的秒数
|
||||||
|
"nonceStr": payData.nonceStr, //随机串
|
||||||
|
"package": payData.packageValue,
|
||||||
|
"signType": payData.signType, //微信签名方式:
|
||||||
|
"paySign": payData.paySign //微信签名
|
||||||
|
},
|
||||||
|
function(res) {
|
||||||
|
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
||||||
|
_options.wxPaySuccess()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (typeof WeixinJSBridge == "undefined") {
|
||||||
|
if (document.addEventListener) {
|
||||||
|
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
|
||||||
|
} else if (document.attachEvent) {
|
||||||
|
document.attachEvent('WeixinJSBridgeReady', onBridgeReady)
|
||||||
|
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
onBridgeReady()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default unityPay
|
Binary file not shown.
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 2.2 KiB |
Loading…
Reference in New Issue