| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390 |
- <template>
- <view class="page">
- <view class="content">
- <mescroll-body ref="mescrollRef" @init="mescrollInit" :up="upOption" :down="downOption" @down="downCallback" @up="upCallback">
- <view class="logs-item" v-for="(item,index) in dataList" :key="index">
- <view class="left">
- <text class="title">
- 提现金额:
- <text class="origin">{{item.amount}}</text>
- </text>
- <view class="time">{{item.createTime}}</view>
- </view>
- <view class="right">
- <text :class="item.status==1?'money green':item.status==4||item.status==5?'money orange':'money red'">{{item.status==1?'已领取':item.status==4||item.status==5?'领取中':'领取失败'}}</text>
- <text v-if="item.status==4||item.status==5" class="remark" @click="confirmReceipt(item)">点击确认收款</text>
- </view>
- </view>
- </mescroll-body>
- </view>
- </view>
- </template>
- <script>
- import {getDictByKey} from '@/api/common.js'
- import {getUserIntegralLogsList,getRedPacketLogList} from '@/api/integral.js'
- import {getUserInfo,exchangDetail} from '@/api/user'
- import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
- export default {
- mixins: [MescrollMixin], // 使用mixin
- data() {
- return {
- typeOptions:[],
- mescroll:null,
- downOption: {
- auto:false//不要自动加载
- },
- upOption: {
- onScroll:false,
- use: true, // 是否启用上拉加载; 默认true
- page: {
- num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
- size: 20 // 每页数据的数量,默认10
- },
- noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
- textNoMore:"已经到底了",
- empty: {
- icon:'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
- tip: '暂无数据'
- }
- },
- dataList: []
-
- }
- },
- onLoad() {
- //this.getDictByKey("sys_integral_log_type");
- this.user = this.$getUserInfo();
- //this.getWalletList(this.user.userId);
- },
- onShow() {
- this.mescroll.resetUpScroll()
- },
- methods: {
- getWxMerchantTransferPlugin() {
- const pluginIds = ['wxMerchantTransfer'];
- for (let i = 0; i < pluginIds.length; i++) {
- const pluginId = pluginIds[i];
- try {
- const plugin = uni.requireNativePlugin(pluginId);
- if (plugin && typeof plugin.open === 'function') {
- return plugin;
- }
- } catch (error) {}
- }
- return null;
- },
- encodeWechatTransferPackage(value) {
- return encodeURIComponent(String(value || '')).replace(/[!'()*]/g, ch => {
- return '%' + ch.charCodeAt(0).toString(16).toUpperCase();
- });
- },
- resolveWxUniversalLink() {
- const app = typeof getApp === 'function' ? getApp() : null;
- const fromGlobal = app && app.globalData ? app.globalData.wxUniversalLink : '';
- const candidates = [
- fromGlobal,
- 'https://rtlink.ylrzcloud.com/uni-universallinks/__UNI__33EAA2D/',
- 'https://yjf.runtzh.com/'
- ];
- for (let i = 0; i < candidates.length; i++) {
- const link = String(candidates[i] || '')
- .replace(/[`'"]/g, '')
- .trim();
- if (link && /^https?:\/\//i.test(link)) {
- return link;
- }
- }
- return '';
- },
- openWxMerchantTransferByPlusIos(params, callback) {
- try {
- if (typeof plus === 'undefined' || !plus.ios || plus.os.name !== 'iOS') {
- return false;
- }
- let WXApi = null;
- try {
- WXApi = plus.ios.importClass('WXApi');
- } catch (error) {
- WXApi = plus.ios.import('WXApi');
- }
- const req = plus.ios.newObject('WXOpenBusinessViewReq');
- if (!WXApi || !req) {
- return false;
- }
- const universalLink = this.resolveWxUniversalLink();
- let registerState = 'skip';
- let installedState = 'unknown';
- let supportState = 'unknown';
- let apiVersion = '';
- if (params.appId) {
- try {
- if (universalLink) {
- registerState = String(!!plus.ios.invoke(WXApi, 'registerApp:universalLink:', String(params.appId), universalLink));
- } else {
- registerState = String(!!plus.ios.invoke(WXApi, 'registerApp:', String(params.appId)));
- }
- } catch (error) {
- registerState = 'error';
- }
- }
- try {
- installedState = String(!!plus.ios.invoke(WXApi, 'isWXAppInstalled'));
- } catch (error) {}
- try {
- supportState = String(!!plus.ios.invoke(WXApi, 'isWXAppSupportApi'));
- } catch (error) {}
- try {
- apiVersion = String(plus.ios.invoke(WXApi, 'getApiVersion') || '');
- } catch (error) {}
- plus.ios.invoke(req, 'setBusinessType:', 'requestMerchantTransfer');
- const encodedPackage = this.encodeWechatTransferPackage(params.package);
- const query = `mchId=${params.mchId}&appId=${params.appId}&package=${encodedPackage}`;
- plus.ios.invoke(req, 'setQuery:', query);
- const sent = plus.ios.invoke(WXApi, 'sendReq:', req);
- plus.ios.deleteObject(req);
- if (typeof callback === 'function') {
- const failMessage = `微信唤起失败,请确认微信可用后重试(appId=${params.appId}, universalLink=${universalLink || 'empty'}, registered=${registerState}, installed=${installedState}, supportApi=${supportState}, apiVersion=${apiVersion || 'unknown'},请检查 universalLink 域名证书是否过期)`;
- callback(sent ? { code: 0, message: 'Request sent successfully' } : { code: -2, message: failMessage });
- }
- return true;
- } catch (error) {
- console.error('openWxMerchantTransferByPlusIos failed', error);
- if (typeof callback === 'function') {
- callback({ code: -2, message: error && error.message ? error.message : 'Failed to send request' });
- }
- return true;
- }
- },
- openWxMerchantTransfer(params, callback) {
- if (typeof plus !== 'undefined' && plus.os && plus.os.name === 'iOS') {
- const iosHandled = this.openWxMerchantTransferByPlusIos(params, callback);
- if (iosHandled) {
- return;
- }
- }
- const wxMerchantTransfer = this.getWxMerchantTransferPlugin();
- if (wxMerchantTransfer && typeof wxMerchantTransfer.open === 'function') {
- wxMerchantTransfer.open(params, callback);
- return;
- }
- if (typeof callback === 'function') {
- callback({ code: -5, message: '微信转账功能未正确初始化,请检查基座插件配置。' });
- }
- },
- getDictByKey(key){
- var data={key:key}
- getDictByKey(data).then(
- res => {
- if(res.code==200){
- this.typeOptions=res.data;
- }
- },
- err => {
- }
- );
-
- },
- getUserInfo(){
- let that=this;
- getUserInfo().then(res => {
- if(res.code==200){
- if(res.user!=null){
- uni.setStorageSync('userInfo',JSON.stringify(res.user));
- this.user=res.user;
- }
- else{
- uni.showToast({
- icon:'none',
- title: res.msg,
- });
- }
- }
- },
- rej => {}
- );
- },
- mescrollInit(mescroll) {
- this.mescroll = mescroll;
- },
- /*下拉刷新的回调 */
- downCallback(mescroll) {
- mescroll.resetUpScroll()
- },
- upCallback(page) {
- //联网加载数据
- var that = this;
- var data = {
- pageNum: page.num,
- pageSize: page.size
- };
- uni.showLoading({
- title:"加载中..."
- })
- getRedPacketLogList(data).then(res => {
- uni.hideLoading()
- if(res.code==200){
- //设置列表数据
- if (page.num == 1) {
- that.dataList = res.rows;
-
- } else {
- that.dataList = that.dataList.concat(res.rows);
-
- }
- that.mescroll.endBySize(res.rows.length, res.total);
-
- }else{
- uni.showToast({
- icon:'none',
- title: "请求失败",
- });
- that.dataList = null;
- that.mescroll.endErr();
- }
- });
- },
- // 确认收款(拉起微信收款确认页面)
- confirmReceipt(item) {
- if (!item) {
- uni.showToast({
- title: '订单信息不完整',
- icon: 'none'
- });
- return;
- }
-
- const appId = item.appId;
- const mchId = item.mchId;
- const packageValue = item.packageInfo;
-
- if (!appId || !mchId || !packageValue) {
- uni.showToast({
- title: '缺少必要参数,无法确认收款',
- icon: 'none'
- });
- return;
- }
-
- // #ifdef APP-PLUS
- const params = {
- appId: String(appId),
- mchId: String(mchId),
- package: String(packageValue)
- };
- console.log('拉起微信收款确认页面,参数:', params);
- this.openWxMerchantTransfer(params, (res) => {
- console.log('确认收款回调结果:', res);
- if (res.code === 0) {
- // 确认收款成功,重新查询订单状态
- if (item.outBatchNo) {
- setTimeout(() => {
- uni.navigateTo({
- url: '/pages/user/wallet/success?orderCode=' + item.outBatchNo
- });
- }, 1000);
- }
- } else if (res.code === -3) {
- const resultMessage = (res.message || '').toLowerCase();
- if (resultMessage.includes('not installed') || resultMessage.includes('未安装')) {
- uni.showModal({
- title: '提示',
- content: '请先安装微信客户端',
- showCancel: false
- });
- } else {
- uni.showModal({
- title: '提示',
- content: res.message || '当前微信版本不支持,请升级后重试',
- showCancel: false
- });
- }
- } else {
- uni.showModal({
- title: '确认收款失败',
- content: res.message || '请稍后重试',
- showCancel: false
- });
- }
- });
- // #endif
-
- // #ifndef APP-PLUS
- uni.showToast({
- icon: 'none',
- title: '此功能仅在 APP 中可用',
- });
- // #endif
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .page{
- background-color: #fff;
- }
- .origin{
- color: #FF5030;
- font-weight: 600;
- }
- .content{
- .logs-item{
- width: 100%;
- background-color: #fff;
- padding:24rpx;
- display: flex;
- align-items: flex-start;
- justify-content: space-between;
- border-top: 1rpx solid #efefef;
- .left{
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: flex-start;
- .title{
- font-size: 28rpx;
- color: #111;
- }
- .time{
- margin-top: 20rpx;
- font-size: 24rpx;
- color: #a5a5a5;
- }
- }
- .right{
- display: flex;
- flex-direction: column;
- align-items: flex-end;
- justify-content: flex-end;
- .money{
- font-size: 28rpx;
- font-weight: bold;
- color: #111;
- }
- .green{
- color: green;
- }
- .red{
- color:#ff0000;
- }
- .orange{
- color:#FF5030;
- }
- .remark{
- margin-top: 20rpx;
- font-size: 24rpx;
- color: #a5a5a5;
- .green{
- color: green;
- }
- .red{
- color: red;
- }
- }
- }
- }
-
- }
-
- </style>
|