recordList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <view class="page">
  3. <view class="content">
  4. <mescroll-body ref="mescrollRef" @init="mescrollInit" :up="upOption" :down="downOption" @down="downCallback" @up="upCallback">
  5. <view class="logs-item" v-for="(item,index) in dataList" :key="index">
  6. <view class="left">
  7. <text class="title">
  8. 提现金额:
  9. <text class="origin">{{item.amount}}</text>
  10. </text>
  11. <view class="time">{{item.createTime}}</view>
  12. </view>
  13. <view class="right">
  14. <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>
  15. <text v-if="item.status==4||item.status==5" class="remark" @click="confirmReceipt(item)">点击确认收款</text>
  16. </view>
  17. </view>
  18. </mescroll-body>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import {getDictByKey} from '@/api/common.js'
  24. import {getUserIntegralLogsList,getRedPacketLogList} from '@/api/integral.js'
  25. import {getUserInfo,exchangDetail} from '@/api/user'
  26. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  27. export default {
  28. mixins: [MescrollMixin], // 使用mixin
  29. data() {
  30. return {
  31. typeOptions:[],
  32. mescroll:null,
  33. downOption: {
  34. auto:false//不要自动加载
  35. },
  36. upOption: {
  37. onScroll:false,
  38. use: true, // 是否启用上拉加载; 默认true
  39. page: {
  40. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  41. size: 20 // 每页数据的数量,默认10
  42. },
  43. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  44. textNoMore:"已经到底了",
  45. empty: {
  46. icon:'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  47. tip: '暂无数据'
  48. }
  49. },
  50. dataList: []
  51. }
  52. },
  53. onLoad() {
  54. //this.getDictByKey("sys_integral_log_type");
  55. this.user = this.$getUserInfo();
  56. //this.getWalletList(this.user.userId);
  57. },
  58. onShow() {
  59. this.mescroll.resetUpScroll()
  60. },
  61. methods: {
  62. getWxMerchantTransferPlugin() {
  63. const pluginIds = ['wxMerchantTransfer'];
  64. for (let i = 0; i < pluginIds.length; i++) {
  65. const pluginId = pluginIds[i];
  66. try {
  67. const plugin = uni.requireNativePlugin(pluginId);
  68. if (plugin && typeof plugin.open === 'function') {
  69. return plugin;
  70. }
  71. } catch (error) {}
  72. }
  73. return null;
  74. },
  75. encodeWechatTransferPackage(value) {
  76. return encodeURIComponent(String(value || '')).replace(/[!'()*]/g, ch => {
  77. return '%' + ch.charCodeAt(0).toString(16).toUpperCase();
  78. });
  79. },
  80. resolveWxUniversalLink() {
  81. const app = typeof getApp === 'function' ? getApp() : null;
  82. const fromGlobal = app && app.globalData ? app.globalData.wxUniversalLink : '';
  83. const candidates = [
  84. fromGlobal,
  85. 'https://rtlink.ylrzcloud.com/uni-universallinks/__UNI__33EAA2D/',
  86. 'https://yjf.runtzh.com/'
  87. ];
  88. for (let i = 0; i < candidates.length; i++) {
  89. const link = String(candidates[i] || '')
  90. .replace(/[`'"]/g, '')
  91. .trim();
  92. if (link && /^https?:\/\//i.test(link)) {
  93. return link;
  94. }
  95. }
  96. return '';
  97. },
  98. openWxMerchantTransferByPlusIos(params, callback) {
  99. try {
  100. if (typeof plus === 'undefined' || !plus.ios || plus.os.name !== 'iOS') {
  101. return false;
  102. }
  103. let WXApi = null;
  104. try {
  105. WXApi = plus.ios.importClass('WXApi');
  106. } catch (error) {
  107. WXApi = plus.ios.import('WXApi');
  108. }
  109. const req = plus.ios.newObject('WXOpenBusinessViewReq');
  110. if (!WXApi || !req) {
  111. return false;
  112. }
  113. const universalLink = this.resolveWxUniversalLink();
  114. let registerState = 'skip';
  115. let installedState = 'unknown';
  116. let supportState = 'unknown';
  117. let apiVersion = '';
  118. if (params.appId) {
  119. try {
  120. if (universalLink) {
  121. registerState = String(!!plus.ios.invoke(WXApi, 'registerApp:universalLink:', String(params.appId), universalLink));
  122. } else {
  123. registerState = String(!!plus.ios.invoke(WXApi, 'registerApp:', String(params.appId)));
  124. }
  125. } catch (error) {
  126. registerState = 'error';
  127. }
  128. }
  129. try {
  130. installedState = String(!!plus.ios.invoke(WXApi, 'isWXAppInstalled'));
  131. } catch (error) {}
  132. try {
  133. supportState = String(!!plus.ios.invoke(WXApi, 'isWXAppSupportApi'));
  134. } catch (error) {}
  135. try {
  136. apiVersion = String(plus.ios.invoke(WXApi, 'getApiVersion') || '');
  137. } catch (error) {}
  138. plus.ios.invoke(req, 'setBusinessType:', 'requestMerchantTransfer');
  139. const encodedPackage = this.encodeWechatTransferPackage(params.package);
  140. const query = `mchId=${params.mchId}&appId=${params.appId}&package=${encodedPackage}`;
  141. plus.ios.invoke(req, 'setQuery:', query);
  142. const sent = plus.ios.invoke(WXApi, 'sendReq:', req);
  143. plus.ios.deleteObject(req);
  144. if (typeof callback === 'function') {
  145. const failMessage = `微信唤起失败,请确认微信可用后重试(appId=${params.appId}, universalLink=${universalLink || 'empty'}, registered=${registerState}, installed=${installedState}, supportApi=${supportState}, apiVersion=${apiVersion || 'unknown'},请检查 universalLink 域名证书是否过期)`;
  146. callback(sent ? { code: 0, message: 'Request sent successfully' } : { code: -2, message: failMessage });
  147. }
  148. return true;
  149. } catch (error) {
  150. console.error('openWxMerchantTransferByPlusIos failed', error);
  151. if (typeof callback === 'function') {
  152. callback({ code: -2, message: error && error.message ? error.message : 'Failed to send request' });
  153. }
  154. return true;
  155. }
  156. },
  157. openWxMerchantTransfer(params, callback) {
  158. if (typeof plus !== 'undefined' && plus.os && plus.os.name === 'iOS') {
  159. const iosHandled = this.openWxMerchantTransferByPlusIos(params, callback);
  160. if (iosHandled) {
  161. return;
  162. }
  163. }
  164. const wxMerchantTransfer = this.getWxMerchantTransferPlugin();
  165. if (wxMerchantTransfer && typeof wxMerchantTransfer.open === 'function') {
  166. wxMerchantTransfer.open(params, callback);
  167. return;
  168. }
  169. if (typeof callback === 'function') {
  170. callback({ code: -5, message: '微信转账功能未正确初始化,请检查基座插件配置。' });
  171. }
  172. },
  173. getDictByKey(key){
  174. var data={key:key}
  175. getDictByKey(data).then(
  176. res => {
  177. if(res.code==200){
  178. this.typeOptions=res.data;
  179. }
  180. },
  181. err => {
  182. }
  183. );
  184. },
  185. getUserInfo(){
  186. let that=this;
  187. getUserInfo().then(res => {
  188. if(res.code==200){
  189. if(res.user!=null){
  190. uni.setStorageSync('userInfo',JSON.stringify(res.user));
  191. this.user=res.user;
  192. }
  193. else{
  194. uni.showToast({
  195. icon:'none',
  196. title: res.msg,
  197. });
  198. }
  199. }
  200. },
  201. rej => {}
  202. );
  203. },
  204. mescrollInit(mescroll) {
  205. this.mescroll = mescroll;
  206. },
  207. /*下拉刷新的回调 */
  208. downCallback(mescroll) {
  209. mescroll.resetUpScroll()
  210. },
  211. upCallback(page) {
  212. //联网加载数据
  213. var that = this;
  214. var data = {
  215. pageNum: page.num,
  216. pageSize: page.size
  217. };
  218. uni.showLoading({
  219. title:"加载中..."
  220. })
  221. getRedPacketLogList(data).then(res => {
  222. uni.hideLoading()
  223. if(res.code==200){
  224. //设置列表数据
  225. if (page.num == 1) {
  226. that.dataList = res.rows;
  227. } else {
  228. that.dataList = that.dataList.concat(res.rows);
  229. }
  230. that.mescroll.endBySize(res.rows.length, res.total);
  231. }else{
  232. uni.showToast({
  233. icon:'none',
  234. title: "请求失败",
  235. });
  236. that.dataList = null;
  237. that.mescroll.endErr();
  238. }
  239. });
  240. },
  241. // 确认收款(拉起微信收款确认页面)
  242. confirmReceipt(item) {
  243. if (!item) {
  244. uni.showToast({
  245. title: '订单信息不完整',
  246. icon: 'none'
  247. });
  248. return;
  249. }
  250. const appId = item.appId;
  251. const mchId = item.mchId;
  252. const packageValue = item.packageInfo;
  253. if (!appId || !mchId || !packageValue) {
  254. uni.showToast({
  255. title: '缺少必要参数,无法确认收款',
  256. icon: 'none'
  257. });
  258. return;
  259. }
  260. // #ifdef APP-PLUS
  261. const params = {
  262. appId: String(appId),
  263. mchId: String(mchId),
  264. package: String(packageValue)
  265. };
  266. console.log('拉起微信收款确认页面,参数:', params);
  267. this.openWxMerchantTransfer(params, (res) => {
  268. console.log('确认收款回调结果:', res);
  269. if (res.code === 0) {
  270. // 确认收款成功,重新查询订单状态
  271. if (item.outBatchNo) {
  272. setTimeout(() => {
  273. uni.navigateTo({
  274. url: '/pages/user/wallet/success?orderCode=' + item.outBatchNo
  275. });
  276. }, 1000);
  277. }
  278. } else if (res.code === -3) {
  279. const resultMessage = (res.message || '').toLowerCase();
  280. if (resultMessage.includes('not installed') || resultMessage.includes('未安装')) {
  281. uni.showModal({
  282. title: '提示',
  283. content: '请先安装微信客户端',
  284. showCancel: false
  285. });
  286. } else {
  287. uni.showModal({
  288. title: '提示',
  289. content: res.message || '当前微信版本不支持,请升级后重试',
  290. showCancel: false
  291. });
  292. }
  293. } else {
  294. uni.showModal({
  295. title: '确认收款失败',
  296. content: res.message || '请稍后重试',
  297. showCancel: false
  298. });
  299. }
  300. });
  301. // #endif
  302. // #ifndef APP-PLUS
  303. uni.showToast({
  304. icon: 'none',
  305. title: '此功能仅在 APP 中可用',
  306. });
  307. // #endif
  308. }
  309. }
  310. }
  311. </script>
  312. <style lang="scss" scoped>
  313. .page{
  314. background-color: #fff;
  315. }
  316. .origin{
  317. color: #FF5030;
  318. font-weight: 600;
  319. }
  320. .content{
  321. .logs-item{
  322. width: 100%;
  323. background-color: #fff;
  324. padding:24rpx;
  325. display: flex;
  326. align-items: flex-start;
  327. justify-content: space-between;
  328. border-top: 1rpx solid #efefef;
  329. .left{
  330. display: flex;
  331. flex-direction: column;
  332. align-items: flex-start;
  333. justify-content: flex-start;
  334. .title{
  335. font-size: 28rpx;
  336. color: #111;
  337. }
  338. .time{
  339. margin-top: 20rpx;
  340. font-size: 24rpx;
  341. color: #a5a5a5;
  342. }
  343. }
  344. .right{
  345. display: flex;
  346. flex-direction: column;
  347. align-items: flex-end;
  348. justify-content: flex-end;
  349. .money{
  350. font-size: 28rpx;
  351. font-weight: bold;
  352. color: #111;
  353. }
  354. .green{
  355. color: green;
  356. }
  357. .red{
  358. color:#ff0000;
  359. }
  360. .orange{
  361. color:#FF5030;
  362. }
  363. .remark{
  364. margin-top: 20rpx;
  365. font-size: 24rpx;
  366. color: #a5a5a5;
  367. .green{
  368. color: green;
  369. }
  370. .red{
  371. color: red;
  372. }
  373. }
  374. }
  375. }
  376. }
  377. </style>