作者 kangaroo125

111111111111

/.hbuilderx
/unpackage
... ...
<template name="head">
<!-- 头部内容 -->
<view class="headBoxBox" :style="{height: headHeight + 'px'}">
<view class="headBox" :style="{height: headHeight + 'px',background:'#'+ bgColor}">
<!-- 状态栏 -->
<view class="state" :style="{height: statusHeight + 'px'}"></view>
<!-- 导航栏 -->
<view class="nav" :style="{height: navHeight + 'px'}">
<!-- 返回按钮 -->
<view :class="[backBtnColor ? 'backBtnWhite' : 'backBtnBlack']" v-if="backBtn" @click="backDefault">
</view>
<!-- 定位 -->
<view class="address" v-if="bottomBtn" @click="toAddress">
<view class="addressText">
{{address}}
</view>
<view class="bottomBtn"></view>
</view>
<!-- 首页搜索框 -->
<view class="search" :style="{height: ellipse + 'px'}" v-if="search" @click="toNewPage">
<image class="searchImg" src="/static/mine/ic_search.png" mode="widthFix"></image>
<input type="text" :focus="true" placeholder="搜索" placeholder-class="placeholder" />
</view>
<!-- 地址搜索框 -->
<view class="searchTwo" :style="{height: ellipse + 'px'}" v-if="addressSearch" @click="toNewPage">
<image class="searchImg" src="/static/mine/ic_search.png" mode="widthFix"></image>
<input class="overdian" type="text" :value="searchContent" :placeholder="placeholder" placeholder-class="placeholderTwo" @input="iptContent"/>
</view>
<!-- 顶部标题 -->
<view class="title" v-if="showTitle">
{{title}}
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: "head",
data() {
return {
headHeight: '',
//状态栏高度
statusHeight: '',
//导航栏高度
navHeight: '',
// 胶囊高度
ellipse: '',
};
},
props: {
//背景色
bgColor: String,
// 标题
title: String, //内容
showTitle: Boolean, //显隐
// 返回按钮
backBtnColor: Boolean, //颜色 默认黑色 true为白色
backBtn: Boolean, // 按钮显隐
howBack: Boolean, //返回方式 默认返回上一页 true为自定义返回页面
customURL: String, //自定义返回路径 绝对路径
// 搜索框
search: Boolean, //首页搜索框显隐
addressSearch: Boolean, //普通搜索框显隐
searchContent: String, // 搜索值
placeholder: String, //输入框提示信息
toNewUrl: String, //点击跳转页面路径
// 地址
bottomBtn: Boolean, //显隐
address: String, //地址信息
newAddress: String, //地址跳转
// 定位搜索
showSearhcInput: Boolean
},
mounted() {
// 设备信息
let detail = uni.getSystemInfoSync()
// 获取设备的系统
let system = detail.system
//获取状态栏高度
this.statusHeight = detail.statusBarHeight
// 胶囊信息
let ellipse = uni.getMenuButtonBoundingClientRect()
//获取胶囊高度
this.ellipse = ellipse.height
//获取胶囊距顶部距离
let absTop = ellipse.top
//计算导航栏高度 = (胶囊距顶部距离 - 状态栏高度) * 2 + 胶囊高度
this.navHeight = (absTop - this.statusHeight) * 2 + this.ellipse
//计算整体高度
let cheack = /iOS/
//判断设备型号
if (cheack.test(system)) {
// iOS
this.headHeight = this.statusHeight + this.navHeight + 4
} else {
//Android
this.headHeight = this.statusHeight + this.navHeight
}
},
methods: {
//返回上一页
backDefault() {
if (this.howBack) {
uni.reLaunch({
url: this.customURL
})
console.log("请填写指定路径");
console.log(this.customURL);
} else {
uni.navigateBack({
delta: 1
})
}
},
// 搜索框点击
toNewPage() {
uni.navigateTo({
url: this.toNewUrl
})
},
//地址跳转
toAddress() {
let that = this
uni.authorize({
scope: 'scope.userLocation',
success() {
uni.navigateTo({
url: that.newAddress
})
},
fail(err){
console.log(err)
that.$emit('alertModel',true)
}
})
},
//监听输入内容
iptContent(e){
// console.log(e)
this.$emit('getChild',e)
let val = e.detail.value
if(/^[\x00-\xff]/.test(val)){
let v = {
first:val
}
this.$myRequest('/api/index/cit',v).then(res =>{
this.$emit('getRes',res)
})
}else{
let v = {
shortname:val
}
this.$myRequest('/api/index/keywords',v).then(res =>{
this.$emit('getRes',res)
})
}
}
},
}
</script>
<style>
.headBoxBox {
width: 100%;
}
.headBox,
.state,
.nav {
width: 750rpx;
}
/* 头部整体内容 */
.headBox {
position: fixed;
top: 0;
left: 0;
z-index: 100;
}
/* 状态栏 */
.state {
position: relative;
}
/* 导航栏 */
.nav {
display: flex;
align-items: center;
position: relative;
}
/* 搜索框 */
.search {
width: 400rpx;
border-radius: 200rpx;
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-55%, -50%);
background: rgba(255, 255, 255, 0.8);
}
.searchTwo {
padding-left: 32rpx;
width: 448rpx;
border-radius: 200rpx;
display: flex;
justify-content: flex-start;
align-items: center;
position: absolute;
top: 50%;
left: 48%;
transform: translate(-60%, -50%);
background: rgba(247, 248, 250, 0.8);
}
.searchImg {
width: 32rpx;
height: 32rpx;
}
.search>input {
width: 60rpx;
color: #323233;
}
.searchTwo>input {
color: #323233;
margin-left: 8rpx;
}
.placeholder {
color: #969799;
text-align: center;
font-size: 28rpx;
}
.placeholderTwo {
font-size: 28rpx;
color: #C8C9CC;
}
.backBtnBlack {
margin-left: 32rpx;
right: 50rpx;
top: 150rpx;
content: "";
display: inline-block;
height: 20rpx;
width: 20rpx;
border-width: 0 0 2px 2px;
border-color: #000;
border-style: solid;
transform: matrix(0.71, 0.71, -.71, 0.71, 0, 0);
-webkit-transform: matrix(0.71, 0.71, -.71, 0.71, 0, 0);
}
.backBtnWhite {
margin-left: 32rpx;
right: 50rpx;
top: 150rpx;
content: "";
display: inline-block;
height: 20rpx;
width: 20rpx;
border-width: 0 0 2px 2px;
border-color: #fff;
border-style: solid;
transform: matrix(0.71, 0.71, -.71, 0.71, 0, 0);
-webkit-transform: matrix(0.71, 0.71, -.71, 0.71, 0, 0);
}
.bottomBtn {
right: 50rpx;
top: 150rpx;
content: "";
display: inline-block;
height: 16rpx;
width: 16rpx;
border-width: 0 2px 2px 0;
border-color: #fff;
border-style: solid;
transform: matrix(0.71, 0.71, -.71, 0.71, 0, 0);
-webkit-transform: matrix(0.71, 0.71, -.71, 0.71, 0, 0);
}
.address {
display: flex;
align-items: center;
margin-left: 32rpx;
}
.addressText {
color: #fff;
font-weight: 600;
width: 96rpx;
overflow: hidden;
white-space: nowrap;
}
.title {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.overdian{
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
}
</style>
... ...
<template>
<view class="inactive">
<u-navbar :back-icon-color="'#FFFFFF'" :is-back="true" title="邀请好友" :title-color="'#FFFFFF'" :background="background"></u-navbar>
<view class="invitationContainer flex flexColumn justifyC alignC">
<image src="/static/evering/ic_img_invitatio.png" class="invitationContainerImage"></image>
<view class="firstBox flex flexColumn alignC">
<view class="firstBoxTitle">已邀请人数</view>
<view class="firstBoxText">100人</view>
</view>
<view class="twoBox flex flexColumn justifyBetween">
<view class="twoBoxContainer flex">
<image src="/static/evering/ic_icon.png" mode="widthFix"></image>
<view class="twoBoxContainerText">生成专属邀请码</view>
</view>
<view class="line1" style="width: 574rpx;height: 1rpx; background-color: #8F939C;"></view>
<view class="twoBoxContainer flex">
<image src="/static/evering/ic_List.png" mode="widthFix"></image>
<view class="twoBoxContainerText">查看邀请列表</view>
</view>
</view>
<view class="thirdBox flex flexColumn justifyBetween alignC">
<image src="/static/evering/yaoqingshuoming.png" mode=""></image>
<view class="thirdContainerBox">1.邀请列表</view>
<view class="thirdContainerBox">2.邀请列表</view>
<view class="thirdContainerBoxT">3.邀请列表</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
background: {
// 渐变色
backgroundImage: 'linear-gradient(135deg, rgba(255, 148, 48, 1) 0%, rgba(254, 206, 51, 1) 100%)'
}
};
},
methods: {}
};
</script>
<style>
.inactive {
background: linear-gradient(60deg, rgba(255, 148, 48, 1) 0%, rgba(254, 206, 51, 1) 100%);
padding: 0 32rpx;
}
.invitationContainerImage {
margin-top: 20rpx;
width: 612rpx;
height: 490rpx;
}
.firstBox {
width: 686rpx;
height: 346rpx;
border-radius: 12rpx;
opacity: 1;
margin-top: -16rpx;
padding-top: 80rpx;
background: rgba(255, 255, 255, 1);
box-shadow: 0 16rpx 32rpx 0 rgba(94, 119, 156, 0.08);
}
.firstBoxTitle {
height: 44rpx;
color: rgba(0, 0, 0, 1);
font-size: 32rpx;
font-weight: 400;
font-family: 'PingFang SC';
text-align: center;
line-height: 44rpx;
letter-spacing: 0.6rpx;
}
.firstBoxText {
margin-top: 72rpx;
height: 78rpx;
opacity: 1;
color: rgba(25, 24, 51, 0.9);
font-size: 72rpx;
font-weight: 700;
font-family: 'D-DIN';
text-align: center;
}
.twoBox {
padding: 28rpx 56rpx;
width: 686rpx;
height: 210rpx;
margin-top: 36rpx;
border-radius: 12rpx;
opacity: 1;
background: rgba(255, 255, 255, 1);
box-shadow: 0 16rpx 32rpx 0 rgba(94, 119, 156, 0.08);
}
.twoBoxContainer image {
width: 40rpx;
height: 40rpx;
}
.twoBoxContainerText {
margin-left: 16rpx;
width: 196rpx;
height: 40rpx;
opacity: 1;
color: rgba(50, 50, 51, 1);
font-size: 28rpx;
font-weight: 400;
font-family: 'PingFang SC';
text-align: center;
line-height: 40rpx;
}
.thirdBox {
width: 686rpx;
height: 406rpx;
margin-top: 28rpx;
margin-bottom: 46rpx;
padding-top: 34rpx;
border-radius: 12rpx;
opacity: 1;
background: rgba(255, 255, 255, 1);
box-shadow: 0 16rpx 32rpx 0 rgba(94, 119, 156, 0.08);
}
.thirdBox image {
width: 244rpx;
height: 54rpx;
margin-bottom: 44rpx;
}
.thirdContainerBox {
width: 574rpx;
height: 70rpx;
color: rgba(50, 50, 51, 1);
font-size: 26rpx;
font-weight: 400;
margin-bottom: 32rpx;
border-bottom: 1rpx solid rgba(235, 237, 240, 1);
}
.thirdContainerBoxT{
width: 574rpx;
height: 70rpx;
color: rgba(50, 50, 51, 1);
font-size: 26rpx;
font-weight: 400;
margin-bottom: 32rpx;
}
</style>
... ...
<template>
<view>
<u-navbar :back-icon-color="'#FFFFFF'" :is-back="true" title="邀请好友" :title-color="'#FFFFFF'" :background="background"></u-navbar>
<view class="invitationContainer flex flexColumn justifyC alignC">
<image :src="erweima" mode="widthFix" :show-menu-by-longpress="true"></image>
<view class="invitationContainerText">保存图片</view>
</view>
<view class="invitationContainerButten" @click="getImage">保存相册</view>
</view>
</template>
<script>
export default {
data() {
return {
background: {
// 渐变色
backgroundImage: 'linear-gradient(135deg, rgba(255, 148, 48, 1) 0%, rgba(254, 206, 51, 1) 100%)'
},
erweima:'/static/evering/ic_18.png'
};
},
methods: {
getImage() {
uni.showToast({
icon: 'loading',
title: '正在保存...'
});
uni.saveImageToPhotosAlbum({
filePath: this.erweima,
success: () => {
console.log('保存成功');
uni.showToast({
icon: 'success',
title: '保存成功'
});
},
fail: () => {
console.log('保存失败');
uni.showToast({
icon: 'error',
title: '保存失败'
});
}
});
},
}
};
</script>
<style>
page {
width: 100%;
height: 100%;
background: linear-gradient(60deg, rgba(255, 148, 48, 1) 0%, rgba(254, 206, 51, 1) 100%);
padding: 0 32rpx;
}
.invitationContainer {
width: 686rpx;
height: 830rpx;
margin-top: 90rpx;
background-image: url(https://s4.ax1x.com/2022/02/08/H15uwQ.png);
background-size: cover;
}
.invitationContainer image {
width: 338rpx;
height: 338rpx;
}
.invitationContainerText {
width: 128rpx;
height: 32rpx;
margin-top: 92rpx;
color: rgba(0, 0, 0, 1);
font-size: 32rpx;
font-weight: 700;
font-family: 'PingFang SC';
text-align: left;
line-height: 32rpx;
}
.invitationContainerButten {
width: 456rpx;
height: 88rpx;
border-radius: 44rpx;
opacity: 1;
color: rgba(255, 149, 49, 1);
font-size: 32rpx;
font-weight: 700;
font-family: 'PingFang SC';
text-align: center;
line-height: 88rpx;
margin: 178rpx auto 0;
background: linear-gradient(135deg, rgba(255, 227, 145, 1) 0%, rgba(255, 223, 124, 1) 100%);
}
</style>
... ...