| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- const { buildConversationWebViewPath } = require('../../../utils/web-view-target');
- Component({
- properties: {},
- data: {
- loading: false,
- webViewPath: '',
- slides: [1, 2, 3, 5],
- activeSlide: 0,
- },
- lifetimes: {
- attached: function () {
- this.preloadCommonSubpackage();
- this.prepareWebViewPath();
- },
- },
- methods: {
- /**
- * 点击「立即体验」按钮
- * 直接跳转到 H5,不依赖 Parse/fm-plugin,让 H5 自行处理鉴权
- */
- onEnter() {
- if (this.data.loading) return;
- this.setData({ loading: true });
- try {
- const webViewPath = this.data.webViewPath || this.buildWebViewPath();
- wx.navigateTo({
- url: webViewPath,
- fail: (err) => {
- console.error('❌ 跳转失败:', err);
- wx.showToast({ title: '跳转失败,请重试', icon: 'none' });
- },
- complete: () => this.setData({ loading: false }),
- });
- } catch (err) {
- console.error('❌ onEnter 异常:', err);
- this.setData({ loading: false });
- wx.showToast({ title: '加载失败,请重试', icon: 'none' });
- }
- },
- onOpenServiceDesk() {
- wx.navigateTo({ url: '/yuban/pages/service-desk/index' });
- },
- onSwiperChange(e) {
- const current = Number(e?.detail?.current ?? 0);
- this.setData({ activeSlide: current });
- },
- preloadCommonSubpackage() {
- if (typeof wx.loadSubpackage !== 'function') return;
- wx.loadSubpackage({
- name: 'common'
- });
- },
- prepareWebViewPath() {
- const webViewPath = this.buildWebViewPath();
- this.setData({ webViewPath });
- },
- buildWebViewPath() {
- // H5 maintains its own SMS session. Native account data stays in the mini program.
- return buildConversationWebViewPath();
- },
- }
- })
|