获取AppID
用邮箱登录微信公众平台,进入【设置】→【账号信息】可以看到AppID
然后将小程序的AppID输入到项目的配置中
{
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"style": {}
}
,{
"path" : "pages/login/login",
"style" : {}
}
,{
"path" : "pages/center/center",
"style" : {}
}
,{
"path" : "pages/me/me",
"style" : {}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "新中街网格化数据助手",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
},
"tabBar" : {
"color" : "black",
"selectedColor" : "#1296db",
"borderStyle" : "black",
"backgroundColor" : "white",
"list" : [
{
"pagePath" : "pages/index/index",
"iconPath" : "static/home.png",
"selectedIconPath" : "static/home.png",
"text" : "首页"
},
{
"pagePath" : "pages/center/center",
"iconPath" : "static/type.png",
"selectedIconPath" : "static/type.png",
"text" : "操作"
},
{
"pagePath" : "pages/me/me",
"iconPath" : "static/me.png",
"selectedIconPath" : "static/me.png",
"text" : "个人中心"
}
]
}
}
const host = 'http://127.0.0.1:8000';
export {
host
}
function request(url, method, data, header = {}) {
wx.showLoading({
title: '加载中' //数据请求前loading
})
return new Promise((resolve, reject) => {
wx.request({
url: host + url, //仅为示例,并非真实的接口地址
method: method,
data: data,
header: {
// 'content-type': 'application/json' ,// 默认值
'content-type' : "application/x-www-form-urlencoded"
},
success: function (res) {
resolve(res.data)
},
fail: function (error) {
reject(error)
},
complete: function () {
wx.hideLoading();
}
})
})
}
export function get(url, data) {
return request(url, 'GET', data)
}
export function post(url, data) {
return request(url, 'POST', data)
}
https://ext.dcloud.net.cn/plugin?id=239
将zip包下载以后解压后,将文件夹colorui复制到newapp目录下,然后在App.vue中的样式中导入:
/*每个页面公共css */
@import "colorui/icon.css";
@import "colorui/main.css";