class h5 点击后样式变化_人人都可写代码-H5零基础编程-活动订单界面实操08

欢迎来到人人都可写代码,大家好,我是杨晓华,今天我们的课程内容是,项目实操,开发一个活动订单界面的H5。

这是要实现的H5活动订单界面展示效果,下面就是教大家如何制作的步骤:

49c3d5918c181d64cafafd6296f65839.png

1、在views的项目smart-zgw目录下,新建can-jia.vue文件。这个文件由三部分style、template、script组成。stytle用于绑定样式、template用于设计标签界面、script用于数据交互操作。

2、template部分里编写的代码是:

<template>

<div class="tpl-page">

<div class="order-navbar ui-border-b">

<!--<div class="order-navbar-item" @click="link(1)" :class="queryType == 1 || queryType == null ? 'active' : ''">待付款<div v-if="countData && countData.wait_pay > 0" class="badge-info">{{countData.wait_pay}}</div></div>-->

<div class="order-navbar-item" @click="link(2)" :class="queryType == 2 ? 'active' : ''">待参加<div v-if="countData && countData.wait_use > 0" class="badge-info">{{countData.wait_use}}</div></div>

<div class="order-navbar-item" @click="link(3)" :class="queryType == 3 ? 'active' : ''">已结束</div>

<div class="order-navbar-item" @click="link(0)" :class="queryType == 0 ? 'active' : ''">全部</div>

</div>

<div class="article-list" v-if="msgList.length > 0">

<li v-for="v in msgList" v-if="queryType == v.query_st || queryType == 0">

<div class="line"></div>

<div v-if="queryType == 1 || queryType == 2 ">

<p class="tj-name" style="float:left;">{{v.hdType}} - {{v.city}}</p>

<p class="tj-dec" v-if="queryType == 1">去付款</p>

<p class="tj-dec" v-if="queryType == 2" @click="toCancel(v.id)">取消参加</p>

</div>

<div v-else>

<p class="tj-name">{{v.hdType}} - {{v.city}}</p>

</div>

<div class="article-item clearfix" v-on:click="openNews(v.id)">

<div class="pull-left">

<img :src="v.banner" :alt="v.title">

</div>

<div class="item-intro">

<div class="item-title">{{v.title}}</div>

<p class="item-desc">{{v.price | price_st}},{{v.endTime}}</p>

</div>

</div>

</li>

</div>

<p class="order-list-empty" v-else>

<span></span>

暂无数据!

</p>

<mt-button class="btn-more" size="large" type="primary" v-if="hasNext > 0" @click="loadingList">点击加载更多</mt-button>

<tabbar></tabbar>

</div>

</template>

3、style部分里编写的代码是:

<style lang="scss">

@import '../../assets/css/fn';

.tpl-page{

padding-bottom: 0.829rem;

.order-navbar {

z-index: 100;

position: fixed;

left: 0;

top: 0;

width: 100%;

height: 0.512rem;

background-color: #fff;

.order-navbar-item {

position: relative;

font-size: 0.170667rem;

float: left;

width: 33.33%;

height: 100%;

line-height: 0.512rem;

text-align: center;

color: #999;

&.active {

color: #333;

position: relative;

&:before {

content: "";

width: 50%;

height: 0.022756rem;

background: #ff004f;

position: absolute;

bottom: 0;

left: 50%;

transform: translateX(-50%);

}

}

}

}

.badge-info {

position: absolute;

top: 0.022756rem;

right: 0.011378rem;

color: #fff;

font-size: 0.113778rem;

font-weight: normal;

-webkit-transform: scale(0.8);

transform: scale(0.8);

text-align: center;

box-sizing: border-box;

padding: 0 0.068267rem;

min-width: 0.2048rem;

line-height: 0.2048rem;

border-radius: 0.1024rem;

background-color: #f44;

}

.article-list{

//width: 900px;

margin-top: 0.52rem;

.line{

background: #ced0d2;

height: 1px;

width: 100%;

}

.article-item{

position: relative;

padding: 5px;

background: #fff;

margin-bottom: 5px;

box-shadow: 1px 1px 1px #e7e7e7;

transition: all 0.2s;

img{

overflow: hidden;

height: 80px;

width: 130px;

margin-right: 15px;

}

.pull-left{

float: left;

}

.item-intro{

height: 80px;

overflow: hidden;

position: relative;

.item-title{

display: block;

font-size: 16px;

line-height: 1.5;

color: #333333;

width: 230px;

}

a{

text-decoration: none;

}

.item-desc{

font-size: 14px;

color: #1b8d9c;

line-height: 1.5;

position:absolute;

bottom:0px;

}

}

}

.tj-name{

font-size: 15px;

padding:6px 15px;

//float:left;

}

.tj-dec{

margin-left:3.2rem;

font-size: 15px;

padding:6px 10px;

width: 90px;

font-weight: bold;

background: #4ccddd;

//border-radius: 1rem;

text-align: center;

color: #fff;

}

.clearfi{

display: block

}

}

.order-list-empty{

margin-top: 1.422222rem;

color: $desc;

text-align: center;

font-size: 0.159289rem;

span{

display: block;

width: 1.109333rem;

height: 1.109333rem;

background: url("../../assets/img/no_data.png") no-repeat 0 0;

background-size: cover;

margin: 0 auto 0.113778rem;

}

}

.btn-more{

margin-bottom: 0.133333rem;

text-align: center;

color: #333;

background-color: #ecf2f7;

}

}

</style>

4、script部分里编写的代码是:

<script>

import Tabbar from '../../components/tabbar'

import Cell from '../../components/cell'

import api from '../../api'

import Toast from '../../components/toast'

import Indicator from '../../components/indicator'

import Button from '../../components/button'

import { getAllParam, setCookie, getCookie, clearCookie } from '../../utils/other.js'

export default {

components: [Tabbar,Cell,Button],

data () {

return {

name: '',

mobile: '',

hasNext: 0,

page: 0,

queryType: 2,

countData: {

"wait_pay": 0,

"wait_use": 0

},

msgList: []

}

},

route: {

data (transition) {

if (process.env.NODE_ENV === 'production') {

this.name = getCookie('prod_zhu_bf')

this.mobile = getCookie('prod_zhu_bf_phone')

} else {

this.name = getCookie('dev_zhu_bf')

this.mobile = getCookie('dev_zhu_bf_phone')

}

if(this.$route.query.type){

this.queryType = this.$route.query.type

}

this.getData()

}

},

methods: {

openNews(id)

{

window.location.href = "#!/smart-zgw/can-jia-detail?id=" + id + "&bao_ming=0"

},

toCancel (id) {

let params = {}

params.huo_dong_id = id

params.mobile = this.mobile

api.huodongCancel.save(params).then(res => {

let data = res.data.message

Toast(data)

location.reload()

}, res => {

Toast('取消失败')

})

},

getData() {

Indicator.open()

this.page = 0

let params = {}

params.mobile = this.mobile

params.page = this.page

params.pageSize = 20

api.canJiaOrderList.get(params).then(res => {

let data = res.data.data

this.msgList = data.list

this.countData = data.countData

this.hasNext = data.page.pageCount - this.page - 1

Indicator.close()

}, res => {

console.log('读取失败')

Indicator.close()

})

},

loadingList () {

Indicator.open()

this.page = this.page + 1

let params = {}

params.mobile = this.mobile

params.page = this.page

params.pageSize = 20

api.canJiaOrderList.get(params).then(res => {

let data = res.data.data.list

this.msgList = this.msgList.concat(data)

this.countData = data.countData

this.hasNext = res.data.data.page.pageCount - this.page -1

Indicator.close()

}, res => {

//console.log('读取失败')

Indicator.close()

})

},

link(index) {

this.$route.router.go({path: 'can-jia', query: {type: index}})

}

},

filters: {

price_st: function (value) {

if (value == 0) {

return '免费'

}

else {

return '¥'+value + '元'

}

}

}

}

</script>

5、活动订单界面用到取消参加活动和读取参加活动订单列表数据的接口,在script里可以看到api.huodongCancel和api.canJiaOrderList,在api目录的index.js文件里需设置这两个接口。

export default {

login: init(appHost, '/v2/topic/login?appid=zgw'),

getVerifyCode: init(appHost, ‘/v2/login/get-verify-code?appid=zgw’),

homeIndex: init(appHost, '/v2/topic/home-index?appid=zgw'),

commitHuoDong: init(appHost, '/v2/topic/fabu-huodong?appid=zgw'),

myHuoDong: init(appHost, '/v2/topic/my-huodong?appid=zgw'),

huodongCancel: init(appHost, ‘/v2/topic/huodong-cancel?appid=zgw'),

canJiaOrderList: init(appHost, '/v2/topic/can-jia-order-list?appid=zgw'),

}

6、编写界面和数据交互后,还需要设置页面的访问路由,在route目录的index

.js文件里添加下面代码,在开发环境,输入http://localhost:8087/?#!/smart-zgw/can-jia就可访问活动订单H5。

export function configRouter (router) {

router.map({

'/smart-zgw': {

component: require('../views/smart-zgw/wrap.vue'),

subRoutes: {

'home': {

component: require('../views/smart-zgw/home.vue'),

title: '这个娃亲子活动服务平台',

name: 'smartzgwhome'

},

'login': {

component: require('../views/smart-zgw/login.vue'),

title: '登录'

},

'xie-yi': {

component: require('../views/smart-zgw/xie-yi.vue'),

title: '《用户服务协议》'

},

'fa-bu': {

component: require('../views/smart-zgw/fa-bu.vue'),

title: '发布',

name: 'fabu'

},

'can-jia': {

component: require('../views/smart-zgw/can-jia.vue'),

title: '参加活动的订单',

name: 'canjia'

}

}

开头:人人都可写代码-H5零基础编程-序言01

下一篇:人人都可写代码-H5零基础编程-个人中心界面实操09

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CLPHP订单系统2016 WEB、WAP自适应版主要功能: 1.颠覆传统,增加产品型号、产品尺寸、产品颜色等产品多选项选择,满足亲们多样需求 2.超乎想象,自带十六种可自适应电脑站和手机站的样式,一套源码解决亲PC端、WAP端使用订单系统问题,全部为全新界面,更加美观、大气 3.带邮件提醒+手机短信提醒{手机邮箱开启短信提示功能即可},特别增强对将QQ邮箱设置为订单发件箱的支持;邮件标题进一步优化,显示订单编号、姓名、联系电话 4.产品套餐选择支持单选、复选、下拉选择,迎合亲们的各种喜好 5.带订单来路页面和下单页面地址检测 6.支持下单人IP追踪 7.支持设置同一IP下单间隔时间,防重复提交;增强恶意空单拦截,有效应对恶意客户拦截传递过程中的订单信息后提交空单行为 8.升级优化邮件系统内核到最新 9.对空间要求更宽泛,fsockopen、pfsockopen和stream_socket_client三个函数只需要开一个即可使用,支持绝大多数的PHP空间 10.相关提示更加人性化,拥有本订单系统的亲们能根据错误提示快速明了订单系统无法正常工作的原因,方便对症下药,迅速安装配置 11、增强支付宝付款接口,在支付宝业务调整,免签接口失效后,本店第一时间升级了订单系统,提供了收款码收款(支付宝收款码获取方法及替换方法见附送的WORD文档)及支付宝商户(即时到账、担保交易)双接口,方便买家根据自己的需求切换使用 12、新增微信付款接口,客户无需加好友,直接扫描二维码(微信支付付款二维码获取方法及替换方法见附送的WORD文档)完成支付。 13、加入伪数据库功能,订单提交失败自动入设置好的数据文件中,确保不漏一单

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值