forked from opengaussexamples/examples
commit
56d3fbde64
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* @Author: Lamdaer
|
||||
* @Date: 2020-10-24 00:51:57
|
||||
* @LastEditTime: 2020-10-24 02:15:58
|
||||
* @Description:
|
||||
* @FilePath: /opengauss/app.js
|
||||
*/
|
||||
//app.js
|
||||
App({
|
||||
onLaunch: function () {
|
||||
wx.getSystemInfo({
|
||||
success: (e) => {
|
||||
this.globalData.StatusBar = e.statusBarHeight
|
||||
let capsule = wx.getMenuButtonBoundingClientRect()
|
||||
if (capsule) {
|
||||
this.globalData.Custom = capsule
|
||||
this.globalData.CustomBar =
|
||||
capsule.bottom + capsule.top - e.statusBarHeight
|
||||
} else {
|
||||
this.globalData.CustomBar = e.statusBarHeight + 50
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
globalData: {
|
||||
ColorList: [
|
||||
{
|
||||
title: '嫣红',
|
||||
name: 'red',
|
||||
color: '#e54d42',
|
||||
},
|
||||
{
|
||||
title: '桔橙',
|
||||
name: 'orange',
|
||||
color: '#f37b1d',
|
||||
},
|
||||
{
|
||||
title: '明黄',
|
||||
name: 'yellow',
|
||||
color: '#fbbd08',
|
||||
},
|
||||
{
|
||||
title: '橄榄',
|
||||
name: 'olive',
|
||||
color: '#8dc63f',
|
||||
},
|
||||
{
|
||||
title: '森绿',
|
||||
name: 'green',
|
||||
color: '#39b54a',
|
||||
},
|
||||
{
|
||||
title: '天青',
|
||||
name: 'cyan',
|
||||
color: '#1cbbb4',
|
||||
},
|
||||
{
|
||||
title: '海蓝',
|
||||
name: 'blue',
|
||||
color: '#0081ff',
|
||||
},
|
||||
{
|
||||
title: '姹紫',
|
||||
name: 'purple',
|
||||
color: '#6739b6',
|
||||
},
|
||||
{
|
||||
title: '木槿',
|
||||
name: 'mauve',
|
||||
color: '#9c26b0',
|
||||
},
|
||||
{
|
||||
title: '桃粉',
|
||||
name: 'pink',
|
||||
color: '#e03997',
|
||||
},
|
||||
{
|
||||
title: '棕褐',
|
||||
name: 'brown',
|
||||
color: '#a5673f',
|
||||
},
|
||||
{
|
||||
title: '玄灰',
|
||||
name: 'grey',
|
||||
color: '#8799a3',
|
||||
},
|
||||
{
|
||||
title: '草灰',
|
||||
name: 'gray',
|
||||
color: '#aaaaaa',
|
||||
},
|
||||
{
|
||||
title: '墨黑',
|
||||
name: 'black',
|
||||
color: '#333333',
|
||||
},
|
||||
{
|
||||
title: '雅白',
|
||||
name: 'white',
|
||||
color: '#ffffff',
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"pages": [
|
||||
"pages/index/index"
|
||||
],
|
||||
"window": {
|
||||
"backgroundTextStyle": "light",
|
||||
"navigationBarBackgroundColor": "#fff",
|
||||
"navigationBarTitleText": "Weixin",
|
||||
"navigationBarTextStyle": "black"
|
||||
},
|
||||
"style": "v2",
|
||||
"sitemapLocation": "sitemap.json"
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
/**app.wxss**/
|
||||
@import "colorui/main.wxss";
|
||||
@import "colorui/icon.wxss";
|
||||
|
||||
.scrollPage {
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.nav-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding: 0px 40rpx 0px;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.nav-li {
|
||||
padding: 30rpx;
|
||||
border-radius: 12rpx;
|
||||
width: 45%;
|
||||
margin: 0 2.5% 40rpx;
|
||||
background-image: url(https://image.weilanwl.com/color2.0/cardBg.png);
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.nav-li::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
z-index: -1;
|
||||
background-color: inherit;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
left: 0;
|
||||
bottom: -10%;
|
||||
border-radius: 10rpx;
|
||||
opacity: 0.2;
|
||||
transform: scale(0.9, 0.9);
|
||||
}
|
||||
|
||||
.nav-li.cur {
|
||||
color: #fff;
|
||||
background: rgb(94, 185, 94);
|
||||
box-shadow: 4rpx 4rpx 6rpx rgba(94, 185, 94, 0.4);
|
||||
}
|
||||
|
||||
.nav-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.nav-title::first-letter {
|
||||
font-size: 40rpx;
|
||||
margin-right: 4rpx;
|
||||
}
|
||||
|
||||
.nav-name {
|
||||
font-size: 28rpx;
|
||||
text-transform: Capitalize;
|
||||
margin-top: 20rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.nav-name::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
display: block;
|
||||
width: 40rpx;
|
||||
height: 6rpx;
|
||||
background: #fff;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.nav-name::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
display: block;
|
||||
width: 100rpx;
|
||||
height: 1px;
|
||||
background: #fff;
|
||||
bottom: 0;
|
||||
right: 40rpx;
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
.nav-name::first-letter {
|
||||
font-weight: bold;
|
||||
font-size: 36rpx;
|
||||
margin-right: 1px;
|
||||
}
|
||||
|
||||
.nav-li text {
|
||||
position: absolute;
|
||||
right: 30rpx;
|
||||
top: 30rpx;
|
||||
font-size: 52rpx;
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
text-align: center;
|
||||
line-height: 60rpx;
|
||||
}
|
||||
|
||||
.text-light {
|
||||
font-weight: 300;
|
||||
}
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
Animation 微动画
|
||||
基于ColorUI组建库的动画模块 by 文晓港 2019年3月26日19:52:28
|
||||
*/
|
||||
|
||||
/* css 滤镜 控制黑白底色gif的 */
|
||||
.gif-black{
|
||||
mix-blend-mode: screen;
|
||||
}
|
||||
.gif-white{
|
||||
mix-blend-mode: multiply;
|
||||
}
|
||||
|
||||
|
||||
/* Animation css */
|
||||
[class*=animation-] {
|
||||
animation-duration: .5s;
|
||||
animation-timing-function: ease-out;
|
||||
animation-fill-mode: both
|
||||
}
|
||||
|
||||
.animation-fade {
|
||||
animation-name: fade;
|
||||
animation-duration: .8s;
|
||||
animation-timing-function: linear
|
||||
}
|
||||
|
||||
.animation-scale-up {
|
||||
animation-name: scale-up
|
||||
}
|
||||
|
||||
.animation-scale-down {
|
||||
animation-name: scale-down
|
||||
}
|
||||
|
||||
.animation-slide-top {
|
||||
animation-name: slide-top
|
||||
}
|
||||
|
||||
.animation-slide-bottom {
|
||||
animation-name: slide-bottom
|
||||
}
|
||||
|
||||
.animation-slide-left {
|
||||
animation-name: slide-left
|
||||
}
|
||||
|
||||
.animation-slide-right {
|
||||
animation-name: slide-right
|
||||
}
|
||||
|
||||
.animation-shake {
|
||||
animation-name: shake
|
||||
}
|
||||
|
||||
.animation-reverse {
|
||||
animation-direction: reverse
|
||||
}
|
||||
|
||||
@keyframes fade {
|
||||
0% {
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes scale-up {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: scale(.2)
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: scale(1)
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes scale-down {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: scale(1.8)
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: scale(1)
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slide-top {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(-100%)
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0)
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slide-bottom {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%)
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0)
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes shake {
|
||||
|
||||
0%,
|
||||
100% {
|
||||
transform: translateX(0)
|
||||
}
|
||||
|
||||
10% {
|
||||
transform: translateX(-9px)
|
||||
}
|
||||
|
||||
20% {
|
||||
transform: translateX(8px)
|
||||
}
|
||||
|
||||
30% {
|
||||
transform: translateX(-7px)
|
||||
}
|
||||
|
||||
40% {
|
||||
transform: translateX(6px)
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: translateX(-5px)
|
||||
}
|
||||
|
||||
60% {
|
||||
transform: translateX(4px)
|
||||
}
|
||||
|
||||
70% {
|
||||
transform: translateX(-3px)
|
||||
}
|
||||
|
||||
80% {
|
||||
transform: translateX(2px)
|
||||
}
|
||||
|
||||
90% {
|
||||
transform: translateX(-1px)
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slide-left {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateX(-100%)
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateX(0)
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slide-right {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateX(100%)
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateX(0)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
const app = getApp();
|
||||
Component({
|
||||
/**
|
||||
* 组件的一些选项
|
||||
*/
|
||||
options: {
|
||||
addGlobalClass: true,
|
||||
multipleSlots: true
|
||||
},
|
||||
/**
|
||||
* 组件的对外属性
|
||||
*/
|
||||
properties: {
|
||||
bgColor: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
isCustom: {
|
||||
type: [Boolean, String],
|
||||
default: false
|
||||
},
|
||||
isBack: {
|
||||
type: [Boolean, String],
|
||||
default: false
|
||||
},
|
||||
bgImage: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
},
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
StatusBar: app.globalData.StatusBar,
|
||||
CustomBar: app.globalData.CustomBar,
|
||||
Custom: app.globalData.Custom
|
||||
},
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
BackPage() {
|
||||
wx.navigateBack({
|
||||
delta: 1
|
||||
});
|
||||
},
|
||||
toHome(){
|
||||
wx.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<view class="cu-custom" style="height:{{CustomBar}}px">
|
||||
<view class="cu-bar fixed {{bgImage!=''?'none-bg text-white bg-img':''}} {{bgColor}}" style="height:{{CustomBar}}px;padding-top:{{StatusBar}}px;{{bgImage?'background-image:url(' + bgImage+')':''}}">
|
||||
<view class="action" bindtap="BackPage" wx:if="{{isBack}}">
|
||||
<text class="cuIcon-back"></text>
|
||||
<slot name="backText"></slot>
|
||||
</view>
|
||||
<view class="action border-custom" wx:if="{{isCustom}}" style="width:{{Custom.width}}px;height:{{Custom.height}}px;margin-left:calc(750rpx - {{Custom.right}}px)">
|
||||
<text class="cuIcon-back" bindtap="BackPage"></text>
|
||||
<text class="cuIcon-homefill" bindtap="toHome"></text>
|
||||
</view>
|
||||
<view class="content" style="top:{{StatusBar}}px">
|
||||
<slot name="content"></slot>
|
||||
</view>
|
||||
<slot name="right"></slot>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -0,0 +1 @@
|
|||
/* colorui/components/cu-custom.wxss */
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* @Author: Lamdaer
|
||||
* @Date: 2020-10-24 01:54:38
|
||||
* @LastEditTime: 2020-10-24 02:41:40
|
||||
* @Description:
|
||||
* @FilePath: /opengauss/components/info/index.js
|
||||
*/
|
||||
// components/info/index.js
|
||||
Component({
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
jobList: {
|
||||
type: Array,
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
index: null,
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
jobChange(e) {
|
||||
console.log(e)
|
||||
this.setData({
|
||||
index: e.detail.value,
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<!-- components/info/index.wxml -->
|
||||
<view class="cu-form-group margin-top">
|
||||
<view class="title">岗位</view>
|
||||
<picker bindchange="jobChange" value="{{index}}" range="{{jobList}}" range-key="name">
|
||||
<view class="picker">{{index?jobList[index].name:"请选择岗位"}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="cu-form-group">
|
||||
<view class="title">多列选择</view>
|
||||
<picker mode="multiSelector" bindchange="MultiChange" bindcolumnchange="MultiColumnChange" value="{{multiIndex}}" range="{{multiArray}}">
|
||||
<view class="picker">{{multiArray[0][multiIndex[0]]}},{{multiArray[1][multiIndex[1]]}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
/* components/info/index.wxss */
|
||||
@import '/colorui/main.wxss';
|
||||
@import '/colorui/icon.wxss';
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* @Author: Lamdaer
|
||||
* @Date: 2020-10-24 02:08:13
|
||||
* @LastEditTime: 2020-10-24 10:36:37
|
||||
* @Description:
|
||||
* @FilePath: /opengauss/config.js
|
||||
*/
|
||||
export const config = {
|
||||
API_BASE_URL: '',
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* @Author: Lamdaer
|
||||
* @Date: 2020-10-24 02:56:28
|
||||
* @LastEditTime: 2020-10-24 03:27:02
|
||||
* @Description:
|
||||
* @FilePath: /opengauss/model/hobby-parent.js
|
||||
*/
|
||||
import { HTTP } from '../utils/http'
|
||||
export class HobbyParentModel extends HTTP {
|
||||
getHobbyList() {
|
||||
return this.request({
|
||||
url: '/gauss/hobby_parent/with_children',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* @Author: Lamdaer
|
||||
* @Date: 2020-10-24 02:18:15
|
||||
* @LastEditTime: 2020-10-24 02:30:08
|
||||
* @Description:
|
||||
* @FilePath: /opengauss/model/job.js
|
||||
*/
|
||||
import { HTTP } from '../utils/http'
|
||||
export class JobModel extends HTTP {
|
||||
getJobList() {
|
||||
return this.request({
|
||||
url: '/gauss/job',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* @Author: Lamdaer
|
||||
* @Date: 2020-10-24 01:58:20
|
||||
* @LastEditTime: 2020-10-24 03:28:07
|
||||
* @Description:
|
||||
* @FilePath: /opengauss/pages/index/index.js
|
||||
*/
|
||||
// pages/index/index.js
|
||||
import { JobModel } from '../../model/job'
|
||||
import { HobbyParentModel } from '../../model/hobby-parent'
|
||||
const jobModel = new JobModel()
|
||||
const hobbyParentModel = new HobbyParentModel()
|
||||
Page({
|
||||
getJobList() {
|
||||
jobModel.getJobList().then((response) => {
|
||||
this.setData({
|
||||
jobList: response.data.jobList,
|
||||
})
|
||||
console.log(response)
|
||||
})
|
||||
},
|
||||
getHobbyList() {
|
||||
hobbyParentModel.getHobbyList().then((res) => {
|
||||
console.log(res)
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
jobList: [],
|
||||
hobbyParentList: [],
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
this.getJobList()
|
||||
this.getHobbyList()
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {},
|
||||
})
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"usingComponents": {
|
||||
"l-info":"/components/info/index"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<!-- pages/index/index.wxml -->
|
||||
<l-info jobList="{{jobList}}"></l-info>
|
||||
|
|
@ -0,0 +1 @@
|
|||
/* pages/index/index.wxss */
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"description": "项目配置文件",
|
||||
"packOptions": {
|
||||
"ignore": []
|
||||
},
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
"es6": true,
|
||||
"enhance": false,
|
||||
"postcss": true,
|
||||
"preloadBackgroundData": false,
|
||||
"minified": true,
|
||||
"newFeature": false,
|
||||
"coverView": true,
|
||||
"nodeModules": false,
|
||||
"autoAudits": false,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"scopeDataCheck": false,
|
||||
"uglifyFileName": false,
|
||||
"checkInvalidKey": true,
|
||||
"checkSiteMap": true,
|
||||
"uploadWithSourceMap": true,
|
||||
"compileHotReLoad": false,
|
||||
"useMultiFrameRuntime": false,
|
||||
"useApiHook": true,
|
||||
"babelSetting": {
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
},
|
||||
"enableEngineNative": false,
|
||||
"useIsolateContext": true,
|
||||
"useCompilerModule": true,
|
||||
"userConfirmedUseCompilerModuleSwitch": false,
|
||||
"packNpmManually": false,
|
||||
"packNpmRelationList": [],
|
||||
"minifyWXSS": true
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "2.13.2",
|
||||
"appid": "wxac62479e0acd98df",
|
||||
"projectname": "opengauss",
|
||||
"debugOptions": {
|
||||
"hidedInDevtools": []
|
||||
},
|
||||
"scripts": {},
|
||||
"isGameTourist": false,
|
||||
"simulatorType": "wechat",
|
||||
"simulatorPluginLibVersion": {},
|
||||
"condition": {
|
||||
"search": {
|
||||
"list": []
|
||||
},
|
||||
"conversation": {
|
||||
"list": []
|
||||
},
|
||||
"game": {
|
||||
"list": []
|
||||
},
|
||||
"plugin": {
|
||||
"list": []
|
||||
},
|
||||
"gamePlugin": {
|
||||
"list": []
|
||||
},
|
||||
"miniprogram": {
|
||||
"list": []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
|
||||
"rules": [{
|
||||
"action": "allow",
|
||||
"page": "*"
|
||||
}]
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* @Author: Lamdaer
|
||||
* @Date: 2020-10-24 02:07:32
|
||||
* @LastEditTime: 2020-10-24 02:11:05
|
||||
* @Description:
|
||||
* @FilePath: /opengauss/utils/http.js
|
||||
*/
|
||||
import { config } from '../config'
|
||||
const tips = {
|
||||
1: '抱歉出现了一个错误',
|
||||
}
|
||||
export class HTTP {
|
||||
request({ url, data = {}, method = 'GET' }) {
|
||||
return new Promise((resolve, resject) => {
|
||||
this._request(url, resolve, resject, data, method)
|
||||
})
|
||||
}
|
||||
_request(url, resolve, reject, data = {}, method = 'GET') {
|
||||
wx.request({
|
||||
url: config.API_BASE_URL + url,
|
||||
method: method,
|
||||
data: data,
|
||||
success: (res) => {
|
||||
const code = res.statusCode.toString()
|
||||
if (code.startsWith('2')) {
|
||||
resolve(res.data)
|
||||
} else {
|
||||
reject()
|
||||
const error_code = res.data.code
|
||||
this._show_error(error_code)
|
||||
}
|
||||
},
|
||||
fail: (res) => {
|
||||
reject()
|
||||
console.log(res)
|
||||
this._show_error(1)
|
||||
},
|
||||
})
|
||||
}
|
||||
_show_error(error_code) {
|
||||
if (!error_code) {
|
||||
error_code = 1
|
||||
}
|
||||
wx.showToast({
|
||||
title: tips[error_code],
|
||||
icon: 'none',
|
||||
duration: 2000,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
const formatTime = date => {
|
||||
const year = date.getFullYear()
|
||||
const month = date.getMonth() + 1
|
||||
const day = date.getDate()
|
||||
const hour = date.getHours()
|
||||
const minute = date.getMinutes()
|
||||
const second = date.getSeconds()
|
||||
|
||||
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
|
||||
}
|
||||
|
||||
const formatNumber = n => {
|
||||
n = n.toString()
|
||||
return n[1] ? n : '0' + n
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatTime: formatTime
|
||||
}
|
||||
Loading…
Reference in New Issue