微信小程序页面迁移校验之前 P5任务处理之前
This commit is contained in:
45
apps/miniprogram - 副本/miniprogram/pages/mvp/mvp.ts
Normal file
45
apps/miniprogram - 副本/miniprogram/pages/mvp/mvp.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
// MVP 全链路验证页面
|
||||
// 从后端 API 读取 test."xcx-test" 表 ti 列第一行并显示
|
||||
|
||||
import { API_BASE } from "../../utils/config"
|
||||
|
||||
Page({
|
||||
data: {
|
||||
tiValue: "加载中...",
|
||||
error: "",
|
||||
loading: true,
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.fetchData()
|
||||
},
|
||||
|
||||
fetchData() {
|
||||
this.setData({ loading: true, error: "" })
|
||||
|
||||
wx.request({
|
||||
url: `${API_BASE}/api/xcx-test`,
|
||||
method: "GET",
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200 && res.data) {
|
||||
const data = res.data as { ti: string }
|
||||
this.setData({
|
||||
tiValue: data.ti,
|
||||
loading: false,
|
||||
})
|
||||
} else {
|
||||
this.setData({
|
||||
error: `请求失败: ${res.statusCode}`,
|
||||
loading: false,
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
this.setData({
|
||||
error: `网络错误: ${err.errMsg}`,
|
||||
loading: false,
|
||||
})
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user