fanp 6 years ago
parent
commit
a4d0a59ac9
  1. 1
      app.wxss
  2. 4
      components/card/index.wxml
  3. 4
      components/card/index.wxss
  4. 1
      components/cell/index.wxss
  5. 34
      components/empty/index.js
  6. 4
      components/empty/index.json
  7. 10
      components/empty/index.wxml
  8. 50
      components/empty/index.wxss
  9. 2
      components/focus/index.wxml
  10. 0
      components/image-button/images/btn_bg_disable.png
  11. 4
      components/image-button/index.js
  12. 2
      components/image-button/index.wxml
  13. 2
      components/swiper/index.wxml
  14. 2
      config.js
  15. BIN
      images/billboard/3.png
  16. BIN
      images/common/btn_bg.png
  17. 2
      models/artice.js
  18. 39
      models/auth.js
  19. 14
      pages/article/index.js
  20. 2
      pages/article/index.wxml
  21. 3
      pages/article/index.wxss
  22. 7
      pages/billboards/index.js
  23. BIN
      pages/billboards/park/images/1.png
  24. BIN
      pages/billboards/park/images/2.png
  25. BIN
      pages/billboards/park/images/3.png
  26. BIN
      pages/billboards/park/images/4.png
  27. 8
      pages/billboards/park/index.wxml
  28. 27
      pages/billboards/park/park-list/index.js
  29. 4
      pages/billboards/park/park-list/index.wxml
  30. 2
      pages/billboards/park/park-list/index.wxss
  31. 3
      pages/billboards/policy/policy-list/index.js
  32. 11
      pages/home/index.js
  33. 5
      pages/home/index.json
  34. 1
      pages/home/index.wxml
  35. 78
      pages/register/index.js
  36. 2
      pages/register/index.wxml
  37. 11
      utils/http.js

1
app.wxss

@ -2,4 +2,5 @@
page{
font-family: PingFangSC-Regular;
/* background-color: #f7f7f7; */
}

4
components/card/index.wxml

@ -1,5 +1,5 @@
<!--components/card/index.wxml-->
<view class="card tag-class" bindtap="onTap">
<image class="card_logo" src="/images/temp_1.png"/>
<view class="card_title">橡胶谷园区</view>
<image class="card_logo" src="{{image.length > 0 ? image : '/images/temp_1.png'}}"/>
<view class="card_title">{{title}}</view>
</view>

4
components/card/index.wxss

@ -1,5 +1,6 @@
/* components/card/index.wxss */
.card {
background-color: white;
border: 1px solid #e7e7e7;
box-shadow: 1px 1px 1px #eee;
}
@ -8,11 +9,12 @@
height: 106px;
}
.card_title {
padding: 0 10px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
height: 41px;
min-height: 41px;
color: #373737;
font-size: 12px;
}

1
components/cell/index.wxss

@ -1,5 +1,6 @@
/* components/cell/index.wxss */
.cell {
background-color: white;
border-bottom: 1px solid #E7E7E7;
display: flex;
flex-direction: column;

34
components/empty/index.js

@ -0,0 +1,34 @@
// components/empty/index.js
Component({
/**
* 组件的属性列表
*/
properties: {
loading: {
type: Boolean,
value: true,
},
empty: {
type: Boolean,
value: false,
},
message: {
type: Boolean,
value: '页面迷路了!'
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})

4
components/empty/index.json

@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

10
components/empty/index.wxml

@ -0,0 +1,10 @@
<!--components/empty/index.wxml-->
<view class="empty">
<view class="empty-loading" wx:if="{{loading && !empty}}">
<view class="load-indicator">加载中<dot></dot></view>
</view>
<view class="empty-bd" wx:if="{{empty}}">
<view class="empty-logo">{{message}}</view>
<view class="empty-refresh"></view>
</view>
</view>

50
components/empty/index.wxss

@ -0,0 +1,50 @@
/* components/empty/index.wxss */
.empty {
position: relative;
width: 100%;
}
.empty-loading {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
}
.empty-bd {
padding: 10px 0;
text-align: center;
font-size: 17px;
color: #888;
}
.load-indicator {
font-size: 16px;
color: #888;
text-align: center;
}
dot {
display: inline-block;
overflow: hidden;
height: 1em;
line-height: 1;
vertical-align: -.25em;
}
dot::after {
display: block;
white-space: pre-wrap;
content: "...\A..\A.";
animation: loading 3s infinite step-start both;
}
@keyframes loading {
33% {
transform: translate3d(0, -2em, 0);
}
66% {
transform: translate3d(0, -1em, 0);
}
}

2
components/focus/index.wxml

@ -1,5 +1,5 @@
<!--components/focus/index.wxml-->
<view class="focus">
<view class="focus" wx:if="{{items.length > 0}}">
<view class="focus_icon">
<image src="images/focus.png" style="width: 40px; height: 20px"></image>
</view>

0
images/common/btn_bg_disable.png → components/image-button/images/btn_bg_disable.png

Before

Width:  |  Height:  |  Size: 247 B

After

Width:  |  Height:  |  Size: 247 B

4
components/image-button/index.js

@ -5,6 +5,10 @@ Component({
*/
properties: {
title: String,
disable: {
type: Boolean,
value: false,
}
},
/**

2
components/image-button/index.wxml

@ -1,5 +1,5 @@
<!--components/image-botton/index.wxml-->
<view class="image-button" bindtap="onTap">
<image class="image-btn-bg" src="images/btn_bg.png"></image>
<image class="image-btn-bg" src="{{disable ? 'images/btn_bg_disable.png':'images/btn_bg.png'}}"></image>
{{title}}
</view>

2
components/swiper/index.wxml

@ -1,5 +1,5 @@
<!--components/swiper/index.wxml-->
<view class="e-swiper">
<view class="e-swiper" wx:if="{{images.length > 0}}">
<swiper autoplay="{{true}}"
interval="{{2000}}"
duration="{{500}}"

2
config.js

@ -1,5 +1,5 @@
const config = {
// api_url: 'https://nei.netease.com/api/apimock/8290e3893033966572547b03f2ef3dbb/', // 服务器地址
// api_url: 'http://192.168.42.44:8083/fqsb', // 服务器地址
api_url: 'http://121.42.41.42:8092/fqsb'
}
export { config }

BIN
images/billboard/3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 12 KiB

BIN
images/common/btn_bg.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

2
models/artice.js

@ -37,7 +37,7 @@ class ArticeModel extends HTTP {
this.request(params)
}
// 在线报名
onlineSign(aId, type, success) {
onlineSign(aId, success) {
let params = {
url: ArticeConst.artice_online_url,
success: success,

39
models/auth.js

@ -1,37 +1,54 @@
import { HTTP, Method, HTTPConst } from '../utils/http.js'
const token_url = 'oas-admin/screen/user/ageAndSex'
const AuthConst = {
token_url: '/api/user/getToken', // 获取token
check_register_url: '/api/miniuser/isRegister',
mobile_code_url: '/api/miniuser/getSmsCode', // 获取验证码
verify_update_phone_url: '/api/miniuser/updateMiniUser' // mobile 验证
}
class AuthModel extends HTTP {
constructor() {
super()
}
// 获取短信验证码
getMsgCode (phone) {
getMsgCode (phone, success) {
let params = {
url: '',
method: Method.POST,
url: AuthConst.mobile_code_url,
method: Method.GET,
data: {
phone: phone,
},
success: (data)=> {
wx.showToast({
title: '短信验证码已发送!',
icon: 'none'
})
success(data)
}
}
this.request(params)
}
// 验证和注册
register (phone, name, vscode, success) {
checkRegister (success) {
let params = {
url: '',
url: AuthConst.check_register_url,
method: Method.POST,
success: success,
}
this.request(params)
}
// 提交验证和注册
mobileRegister (phone, name, vscode, success) {
let params = {
url: AuthConst.verify_update_phone_url,
method: Method.POST,
data: {
isRegister: 1,
phone: phone,
realName: name,
verificationCode: vscode,
},
success: (data) => {
console.log(data)
if (data) {
success(data)
} else {
@ -51,7 +68,7 @@ class AuthModel extends HTTP {
this._fetchWXCode().then(res => {
if (!res) return
let params = {
url: token_url,
url: AuthConst.token_url,
method: Method.GET,
data: {
code: res

14
pages/article/index.js

@ -11,13 +11,14 @@ Page({
data: {
nodes: '',
isStar: true, // 是否
showBtn: true,
showBtn: false,
aId: '',
title: '',
date: '',
origin: '',
unStar: '/images/common/star.png',
star: '/images/common/star_light.png',
disable: true,
},
onClickCollect () {
// 收藏功能
@ -50,7 +51,8 @@ Page({
date: date,
origin: data.source,
isStar: data.isCollection ? true : false,
showBtn: data.typeFlag == 0 ? false : true
showBtn: data.typeFlag >= 2 ? true : false,
disable: data.typeFlag == 3 ? true : false,
})
})
},
@ -71,6 +73,14 @@ Page({
onlineSignApi () {
artice.onlineSign(this.data.aId, res => {
console.log(res)
wx.showToast({
title: res.message,
icon: 'none'
})
this.setData({
disable: true
})
// this.fetchArticeApi()
})
},

2
pages/article/index.wxml

@ -12,6 +12,6 @@
<rich-text nodes="{{nodes}}"></rich-text>
</view>
<view class="page_footer" wx:if="{{showBtn}}">
<e-ibutton title="在线报名" bind:onTap="onlineSubmit"/>
<e-ibutton title="{{disable ? '已报名' : '在线报名'}}" bind:onTap="onlineSubmit" disable="{{disable}}"/>
</view>
</view>

3
pages/article/index.wxss

@ -1,4 +1,7 @@
/* pages/article/index.wxss */
.contianer {
overflow: hidden;
}
.page_hd {
padding: 0 15px;
display: flex;

7
pages/billboards/index.js

@ -1,6 +1,6 @@
// pages/billboards/index.js
import {AuthModel} from '../../models/auth.js'
let auth = new AuthModel()
// import {AuthModel} from '../../models/auth.js'
// let auth = new AuthModel()
Page({
@ -15,9 +15,6 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
auth.fetchAuthToken(res => {
console.log(res)
})
},
onClickItem (e) {
const {index} = e.currentTarget.dataset

BIN
pages/billboards/park/images/1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
pages/billboards/park/images/2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
pages/billboards/park/images/3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
pages/billboards/park/images/4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

8
pages/billboards/park/index.wxml

@ -1,7 +1,7 @@
<!--pages/billboards/park/index.wxml-->
<view class="container">
<image bindtap="onClickItem" data-code="park-cbd" class="billboard_item" src="/images/billboard/1.png"></image>
<image bindtap="onClickItem" data-code="park-bhxq" class="billboard_item" src="/images/billboard/2.png"></image>
<image bindtap="onClickItem" data-code="park-cxzy" class="billboard_item" src="/images/billboard/3.png"></image>
<image bindtap="onClickItem" data-code="park-lswh" class="billboard_item" src="/images/billboard/3.png"></image>
<image bindtap="onClickItem" data-code="park-cbd" class="billboard_item" src="images/1.png"></image>
<image bindtap="onClickItem" data-code="park-bhxq" class="billboard_item" src="images/2.png"></image>
<image bindtap="onClickItem" data-code="park-cxzy" class="billboard_item" src="images/3.png"></image>
<image bindtap="onClickItem" data-code="park-lswh" class="billboard_item" src="images/4.png"></image>
</view>

27
pages/billboards/park/park-list/index.js

@ -7,6 +7,7 @@ Page({
* 页面的初始数据
*/
data: {
loading: true,
list: [],
curCode: '',
curPage:1,
@ -34,8 +35,34 @@ Page({
const {curCode} = this.data
const page = this.data.curPage
billboard.fetchBailList(curCode, page, res => {
this.setData({
loading:false,
})
console.log(res)
const list = res.list
if (page == 1) {
this.setData({
list: list
})
} else {
if (list.length > 0) {
const list = [...this.data.list, ...list]
this.setData({
list: list
})
} else {
const page = this.data.currPage - 1
this.setData({
currPage: page
})
wx.showToast({
title: '已加载全部',
icon: 'none'
})
}
}
})
wx.stopPullDownRefresh()
},
/**
* 页面相关事件处理函数--监听用户下拉动作

4
pages/billboards/park/park-list/index.wxml

@ -1,7 +1,9 @@
<!--pages/billboards/park/index.wxml-->
<view class="container">
<block wx:for="{{list}}" wx:key="park-list-{{index}}">
<e-card cId="{{index}}"
<e-card cId="{{item.id}}"
title="{{item.title}}"
image="{{item.titlePic}}"
tag-class="e_card"
bind:clickCardItem="clickCardItem"/>
</block>

2
pages/billboards/park/park-list/index.wxss

@ -13,7 +13,7 @@
.page_empty {
width: 100%;
height: 100px;
margin-top: 100px;
margin-top: 20px;
font-size: 14px;
color: #aaa;
text-align: center;

3
pages/billboards/policy/policy-list/index.js

@ -42,9 +42,8 @@ Page({
fetchPolicyArtice () {
policy.fetchPolicyArtice(this.data.curCode, res => {
console.log(res)
const list = res.list
this.setData({
nodes: list[0].content
nodes: res.data.content || ''
})
})
}

11
pages/home/index.js

@ -6,6 +6,7 @@ import { HomeModel } from '../../models/home.js'
let homeModel = new HomeModel()
Page({
data: {
loading: true,
currPage: 1,
banners: [],
hots: [],
@ -26,6 +27,11 @@ Page({
currPage: 1,
})
this.fetchHomeList()
wx.vibrateShort({
success () {
console.log('震动')
}
})
},
/**
@ -42,6 +48,9 @@ Page({
fetchHomeList() {
let page = this.data.currPage
homeModel.getHomeList(page, res => {
this.setData({
loading: false
})
console.log('啦啦啦')
const datas = res.list
let tempDatas = []
@ -89,7 +98,7 @@ Page({
console.log(item)
tempBanners.push({
id: item.id,
image: 'http://m.360buyimg.com/mobilecms/s700x280_jfs/t1/45210/40/7669/143615/5d53b19dEc9559d0a/cd9eade239533517.jpg!cr_1125x445_0_171!q70.jpg.dpg'
image: item.titlePic
})
})
this.setData({

5
pages/home/index.json

@ -1,8 +1,11 @@
{
"enablePullDownRefresh": true,
"backgroundColor": "#f7f7f7",
"backgroundTextStyle": "dark",
"usingComponents": {
"e-swiper": "/components/swiper/index",
"e-focus": "/components/focus/index",
"e-cell": "/components/cell/index"
"e-cell": "/components/cell/index",
"e-empty": "/components/empty/index"
}
}

1
pages/home/index.wxml

@ -11,4 +11,5 @@
showTop="{{item.showTop}}"
bind:clickListItem="clickListItem"/>
</block>
<e-empty loading="{{loading}}" empty="{{list.length == 0}}"/>
</view>

78
pages/register/index.js

@ -1,4 +1,7 @@
// pages/register/index.js
import {AuthModel} from '../..//models/auth.js'
let auth = new AuthModel()
Page({
/**
@ -18,9 +21,11 @@ Page({
rules: { required: true, message: '验证码必填' },
},
],
formData: {
}
formData: {},
time: 60,
fetchCode: true,
interval: null,
btnTitle: '获取验证码'
},
/**
@ -28,6 +33,68 @@ Page({
*/
onLoad: function (options) {
},
onHide () {
clearInterval(this.data.interval)
},
// 重新获取Code
refetchCodeDownTime () {
this.data.interval = setInterval(() => {
const time = this.data.time - 1
const title = `${time}s 重新发送`
this.setData({
fetchCode: false,
time: time,
btnTitle: title
})
if (time == 0) {
this.setData({
fetchCode: true,
time: 60,
btnTitle: '重新发送'
})
clearInterval(this.data.interval)
}
}, 1000)
},
// 调用获取 Code 接口
onGetMsgCode () {
this.selectComponent('#form').validate((valid, errors) => {
if (!valid) {
let emptyPhone = false
errors.forEach(item => {
if (item.name === 'mobile') {
emptyPhone = true
wx.showToast({
title: item.message,
icon: 'none'
})
}
})
if (!emptyPhone) {
// console.log(this.data.formData)
this.fetchMsgCodeApi()
}
}
})
},
fetchMsgCodeApi () {
auth.getMsgCode(this.data.formData.mobile, res => {
console.log(res)
this.refetchCodeDownTime()
})
},
registerApi () {
const {mobile, name, vcode} = this.data.formData
console.log(mobile,name, vcode)
auth.mobileRegister(mobile, name, vcode, res => {
console.log(res)
wx.reLaunch({
url: '/pages/home/index',
})
})
},
formInputChange (e) {
const { field } = e.currentTarget.dataset
@ -40,6 +107,7 @@ Page({
console.log('valid', valid, errors)
if (!valid) {
const firstError = Object.keys(errors)
console.log(firstError)
if (firstError.length) {
const error = errors[firstError[0]].message
wx.showToast({
@ -48,9 +116,7 @@ Page({
})
}
} else {
wx.showToast({
title: '校验通过'
})
this.registerApi()
}
})
}

2
pages/register/index.wxml

@ -15,7 +15,7 @@
</mp-cell>
<mp-cell prop="vcode" ext-class="weui-cell_vcode">
<input bindinput="formInputChange" data-field="vcode" class="weui-input" placeholder="请输入验证码"/>
<view slot="footer" class="weui-vcode-btn">获取验证码</view>
<view slot="footer" class="weui-vcode-btn" bindtap="{{fetchCode ? 'onGetMsgCode' : ''}}">{{btnTitle}}</view>
</mp-cell>
</mp-cells>
</mp-form>

11
utils/http.js

@ -36,7 +36,7 @@ class HTTP {
let code = res.statusCode.toString()
let startCode = code.charAt(0)
if (startCode == '2') {
if (res.data.code == 200) {
if (res.data.code == 200 || res.data.code == 0) {
params.success && params.success(res.data)
} else {
console.log('数据请求失败')
@ -47,11 +47,18 @@ class HTTP {
}
} else {
console.log('请求错误')
wx.showToast({
title: '服务器错误!',
icon: 'none'
})
params.error && params.error(res)
}
},
fail: function (res) {
console.log('服务器错误')
wx.showToast({
title: '网络连接错误,请求失败!',
icon: 'none'
})
params.fail && params.fail(res)
},
})

Loading…
Cancel
Save