洛阳学员端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.9 KiB

  1. <template>
  2. <view class="">
  3. <web-view :src="$store.state.webViewUrl" @onPostMessage="postMessage" @message="postMessage"></web-view>
  4. <!-- <web-view src="http://192.168.1.44:92/vue/wxStudentCertificate3" @onPostMessage="postMessage" @message="postMessage"></web-view> -->
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. onLoad() {
  10. this.initWx()
  11. },
  12. methods: {
  13. postMessage(res) {
  14. console.log('监听到了')
  15. let item = res.detail.data[0]
  16. console.log(res)
  17. console.log('监听到的发送事件')
  18. console.log(item)
  19. if(item.action=='lyxc-wxPay') {
  20. this.$u.toast('用户点击了微信支付')
  21. this.wxPay(item)
  22. }else if(item.action=='lyxc-paySuccess') {
  23. this.$u.toast('支付完成,app跳转页面吧')
  24. }
  25. },
  26. // "action": "lyxc-wxPay",
  27. // "miniProgramType": 2,
  28. // "miniAppId": "gh_89b377cbc340",
  29. // "path": "/pages/wxPayOnly/wxPayOnly?channelNo=QD202404083509&orderNo=20240423170705024771&inpartNo=820198016000045&merchantName=中原智慧新校园&amount=1&redMsg=&payType=04"
  30. wxPay(item) {
  31. console.log(item)
  32. // #ifdef APP-PLUS
  33. this.sweixin ? this.sweixin.launchMiniProgram({
  34. path: item.path, //跳转小程序页面路径 pages/index/index
  35. type: item.miniProgramType, //可取值: 0-正式版; 1-测试版; 2-体验版。 默认值为0。
  36. id: item.miniAppId //小程序的原始id
  37. }) : plus.nativeUI.alert('当前环境不支持微信操作!');
  38. // #endif
  39. },
  40. initWx() {
  41. // #ifdef APP-PLUS
  42. plus.share.getServices((s) => {
  43. var shares = {};
  44. for (var i = 0; i < s.length; i++) {
  45. var t = s[i];
  46. console.log("...........", t);
  47. shares[t.id] = t;
  48. }
  49. var sweixin = shares['weixin'];
  50. this.sweixin = sweixin
  51. }, function(e) {
  52. console.log("获取分享服务列表失败:" + e.message);
  53. });
  54. // #endif
  55. },
  56. }
  57. }
  58. </script>
  59. <style>
  60. </style>