feat: 小程序与管理端迭代(神仙AI、了解自己CRM、AI测试入口、报表与分润等)
Made-with: Cursor
This commit is contained in:
31
miniprogram/pages/webview/index.js
Normal file
31
miniprogram/pages/webview/index.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const analytics = require('../../utils/analytics.js')
|
||||
|
||||
Page({
|
||||
data: { url: '', loadedAt: 0 },
|
||||
onLoad(options) {
|
||||
let url = decodeURIComponent(options && options.url || '')
|
||||
if (!url) {
|
||||
wx.showToast({ title: '链接为空', icon: 'none' })
|
||||
return
|
||||
}
|
||||
// 仅允许 http/https
|
||||
if (!/^https?:\/\//.test(url)) {
|
||||
wx.showToast({ title: '链接非法', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ url, loadedAt: Date.now() })
|
||||
if (options && options.title) {
|
||||
wx.setNavigationBarTitle({ title: decodeURIComponent(options.title) })
|
||||
}
|
||||
},
|
||||
onLoad2() {},
|
||||
onError() {
|
||||
wx.showToast({ title: '页面加载失败', icon: 'none' })
|
||||
},
|
||||
onUnload() {
|
||||
const readMs = Date.now() - (this.data.loadedAt || Date.now())
|
||||
if (readMs > 5000) {
|
||||
analytics.track('ai_article_read', { readMs })
|
||||
}
|
||||
}
|
||||
})
|
||||
6
miniprogram/pages/webview/index.json
Normal file
6
miniprogram/pages/webview/index.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"navigationBarTitleText": "阅读",
|
||||
"navigationBarBackgroundColor": "#ffffff",
|
||||
"navigationBarTextStyle": "black",
|
||||
"usingComponents": {}
|
||||
}
|
||||
4
miniprogram/pages/webview/index.wxml
Normal file
4
miniprogram/pages/webview/index.wxml
Normal file
@@ -0,0 +1,4 @@
|
||||
<web-view wx:if="{{url}}" src="{{url}}" bindload="onLoad" binderror="onError"></web-view>
|
||||
<view wx:else class="placeholder">
|
||||
<view>链接为空或不可访问</view>
|
||||
</view>
|
||||
6
miniprogram/pages/webview/index.wxss
Normal file
6
miniprogram/pages/webview/index.wxss
Normal file
@@ -0,0 +1,6 @@
|
||||
.placeholder {
|
||||
padding: 120rpx 40rpx;
|
||||
text-align: center;
|
||||
color: #9CA3AF;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user