index.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view>
  3. <view class="main-btn" @click="toPage(courseUrl)">
  4. <image :src="`${FILE_URL}/edu-icon/course.png`"></image>
  5. <text>培训课程</text>
  6. </view>
  7. <view class="main-btn" @click="toOtherApp">
  8. <image :src="`${FILE_URL}/edu-icon/net.png`"></image>
  9. <text>网络教育</text>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. import configService from '@/utils/baseurl.js'
  15. export default {
  16. data() {
  17. return {
  18. FILE_URL: configService.FILE_URL,
  19. netAppid: "wx65323471c83da344",
  20. courseUrl: "/pages/goOnEdu/course/index"
  21. };
  22. },
  23. methods: {
  24. toOtherApp() {
  25. if (this.netAppid === "") {
  26. uni.showToast({
  27. title: "跳转其他小程序",
  28. icon: "none"
  29. })
  30. return;
  31. }
  32. uni.navigateToMiniProgram({
  33. appId: this.netAppid, // 替换为你要跳转的小程序的AppID
  34. path: 'pages/index/index', // 目标小程序的页面路径,留空则默认为首页
  35. envVersion: 'release', // 指定要打开的小程序版本: release 或 trial
  36. success(res) {
  37. console.log('成功跳转到小程序', res);
  38. },
  39. fail(err) {
  40. console.error('跳转失败', err);
  41. }
  42. });
  43. },
  44. toPage(url){
  45. uni.navigateTo({
  46. url:url
  47. })
  48. }
  49. }
  50. }
  51. </script>
  52. <style lang="scss">
  53. .main-btn {
  54. width: 85%;
  55. background-color: #006af4;
  56. border-radius: 20rpx;
  57. margin: 30rpx auto;
  58. padding: 40rpx 30rpx;
  59. display: flex;
  60. align-items: center;
  61. image {
  62. width: 100rpx;
  63. height: 100rpx;
  64. flex: 0 0 auto;
  65. }
  66. text {
  67. margin-left: 20rpx;
  68. color: #fff;
  69. font-size: 40rpx;
  70. }
  71. }
  72. </style>