46 lines
946 B
TypeScript
46 lines
946 B
TypeScript
// 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,
|
|
})
|
|
},
|
|
})
|
|
},
|
|
})
|