后端使用随便一个php站点,服务器使用阿里云、腾讯云、百度云都可以。
推荐使用宝塔搭建,使能ssl.
代码下载: https://gitee.com/tui.guige/once/tree/master
backend 后端php代码
前端使用uni-app ,新建一个项目,模板使用默认即可:
基本目录结构
文件:config.js
export default{ baseUrl: "填写你自己站点的路径" }
文件: index.vue
<template>
<view class="content">
<image class="logo" :src=img_url></image>
<view class="text-area">
<text class="title">{{title}}</text>
</view>
<view class="text-area">
<text class="source">{{source}}</text>
</view>
</view>
</template>
<script>
import config from '@/common/config.js';
export default {
data() {
return {
title: 'ONCE-DEMO',
img_url: '',
source: '作者'
}
},
onLoad() {
uni.request({
url: config.baseUrl + 'site.php',
data: {
'id': 'Your ID 推荐使用QQ号 或者手机号'
},
header: {
'content-type': "application/x-www-form-urlencoded"
},
method:"POST",
success: (res) => {
//console.log(res.data)
var res_data = res.data.data;
if(res_data.code !== 1) { //如果请求失败,不等于1状态码
this.title = res_data.msg;
return uni.showToast({
title:"请求失败!"
})
}
//数据请求成功
this.title = res_data.content;
this.img_url = res_data.img;
this.source = res_data.source;
}
})
},
methods: {
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 320rpx;
width: 480rpx;
margin-top: 150rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
.source {
font-size: 30rpx;
color: #8f8f94;
text-align: right;
}
</style>
如果您发现该资源为电子书等存在侵权的资源或对该资源描述不正确等,可点击“私信”按钮向作者进行反馈;如作者无回复可进行平台仲裁,我们会在第一时间进行处理!
加入交流群
请使用微信扫一扫!