Files
xdd-uniapp-new/v4/views/attract/attract.vue
T

371 lines
9.5 KiB
Vue

<template>
<view class="page-v4">
<image class="header-img img" :src="investmentTopImage" mode="widthFix"></image>
<view class="body flex flex-col flex-wrap jc-center ai-center">
<view class="h1">{{ investmentTitle }}</view>
<view class="red-box flex jc-center ai-center">
<image class="icon-fire" :src="webUrl+'/20221118092713277343.png'" mode="scaleToFill"></image>
<view>目前已有
<text>{{ total }}</text>
人参加活动
</view>
</view>
<view class="form-box">
<view class="title tc">申请资料填写</view>
<text class="label">选择省市区</text>
<view class="custom-input">
<CitySelect ref="cityselect" :defaultValue="addressText" @callback="result" :items="district"/>
</view>
<text class="label">姓名</text>
<input class="custom-input" type="text" :value="businessApply.realName" @input="inputKey($event,'realName')"/>
<text class="label">电话</text>
<input class="custom-input" type="number" :value="businessApply.phone" @input="inputKey($event,'phone')"/>
<!-- <text class="label">身份证号码</text>-->
<!-- <input class="custom-input" type="idcard" :value="businessApply.idcard" @input="inputKey($event,'idcard')"/>-->
<button class="submit-btn" type="default" @click="sumbit">提交申请</button>
<image class="footer-img img" style="margin-top:30rpx" :src="investmentMainImage" mode="widthFix"
@click="goList"></image>
</view>
<view class="people-box" v-if="businessApplyList.length">
<view class="title tc">最新参与客户</view>
<view class="list">
<view class="item flex ai-center" :class="{'selected':index==1}" v-for="(item,index) in businessApplyList" :key="item" v-show="index<3">
<view class="grid-1 flex ai-center">
<image class="icon-horn" :src="webUrl+'/20220218225707839596.png'" mode="scaleToFill"></image>
<text>{{ item.realName }}</text>
</view>
<view class="grid-2">{{ item.phone }}</view>
<view>{{ item.disTime }}</view>
</view>
</view>
</view>
</view>
<image class="footer-img img" :src="investmentBottomImage" mode="widthFix"></image>
</view>
</template>
<script>
import CitySelect from "@/components/CitySelect";
import {getCity} from "@/api/user";
import {getAttract, investment, saveAttract} from "@/api/shop.js";
// import {
// queryByType
// } from "@/api/public";
import { pageListenMixins } from '@/mixins/pageListenMixins'
export default {
components: {
CitySelect
},
mixins: [pageListenMixins],
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
district: [],
address: {},
addressText: "",
total: 0,
businessApply: {
realName: "",
phone: "",
idcard: ""
},
businessApplyList: [],
headerImg: null,
footerImg: null,
investmentTopImage: null,
investmentMainImage: null,
investmentBottomImage: null,
investmentTitle: "",
pageKeyId: Object.freeze('investmentIndex')
}
},
onLoad: function () {
this.init()
this.getCityList()
const localData = uni.getStorageSync('investmentIndex')
if (localData) {
this.businessApply = localData
}
},
onUnload() {
uni.setStorageSync('investmentIndex', this.businessApply)
},
methods: {
init() {
// queryByType("business_info").then(({data}) => {
// data.map(item => {
// switch (item.label) {
// case "招商banner图上":
// this.headerImg = item.value;
// break;
// case "招商banner图下":
// this.footerImg = item.value;
// break;
// case "招商标题":
// this.title = item.value;
// break;
// }
// })
// });
investment().then(({data}) => {
this.investmentTitle = data.investmentTitle;
this.investmentTopImage = data.investmentTopImage;
this.investmentMainImage = data.investmentMainImage;
this.investmentBottomImage = data.investmentBottomImage;
});
getAttract().then(({data}) => {
this.total = data.total
this.businessApplyList = data.businessApplyList
if (data.businessApply) {
// this.businessApply = data.businessApply
this.address = {
province: data.businessApply.provinceName || "",
city: data.businessApply.cityName || "",
district: data.businessApply.areaName || "",
provinceId: data.businessApply.provinceId,
cityId: data.businessApply.cityId,
areaId: data.businessApply.areaId
};
this.addressText = `${this.address.province} ${this.address.city} ${this.address.district}`;
}
})
},
inputKey(e, key) {
this.businessApply[key] = e.detail.value
},
sumbit() {
if (this.address.areaId) {
this.businessApply.provinceId = this.address.provinceId
this.businessApply.cityId = this.address.cityId
this.businessApply.areaId = this.address.areaId
this.businessApply.uid = uni.getStorageSync("uid")
} else {
this.$dialog.error("请选择你的地址")
return
}
// || this.businessApply.idcard.length == 0
if (this.businessApply.realName.length == 0 || this.businessApply.phone.length == 0) {
this.$dialog.error("请完整填写后再提交申请")
return
}
saveAttract(this.businessApply).then(res => {
this.$dialog.error(res.msg)
}).catch(err => this.$dialog.error(err.msg))
},
result(values) {
this.address = {
province: values.province.name || "",
city: values.city.name || "",
district: values.district.name || "",
provinceId: values.province.id,
cityId: values.city.id,
areaId: values.district.id
};
this.addressText = `${this.address.province} ${this.address.city} ${this.address.district}`;
},
getCityList: function () {
let that = this;
getCity()
.then(res => {
that.district = res.data;
that.ready = true;
if (this.id) {
//设置city_id
var pIdx = that.getIndex(that.address.province, that.district);
if (pIdx > -1) {
var citys = that.district[pIdx].c;
var cIdx = that.getIndex(that.address.city, citys);
if (cIdx > -1) {
var city = citys[cIdx];
that.address.city_id = city.v;
console.log('city_id:' + city.v);
}
}
}
})
.catch(err => {
that.$dialog.error(err.msg);
});
},
goList() {
uni.navigateTo({
url: './projectList'
})
}
}
}
</script>
<style lang="scss">
.page-v4 {
background: #fff;
}
.img {
vertical-align: middle;
}
.header-img {
width: 100%;
}
.footer-img {
width: 100%;
}
.icon-fire {
width: 32rpx;
height: 32rpx;
margin-right: 18rpx;
}
.body {
.h1 {
margin-top: 40rpx;
font-size: 32rpx;
font-weight: bold;
line-height: 48rpx;
color: #FF0000;
}
.red-box {
width: 480rpx;
height: 60rpx;
margin: 20rpx 0 28rpx;
background: rgba(253, 104, 93, .15);
border-radius: 32px;
font-size: 24rpx;
color: #FD685D;
text {
margin: 0 4rpx;
padding: 4rpx 10rpx;
background: #FF005E;
color: #fff;
font-size: 24rpx;
opacity: 1;
border-radius: 12rpx;
}
}
.form-box {
width: 620rpx;
box-sizing: border-box;
margin: 28rpx 0 64rpx;
padding: 36rpx 39rpx;
border: 2rpx solid #D6808D;
box-shadow: 3px 3px 0 #D6808D;
opacity: 1;
border-radius: 40rpx;
.title {
margin-bottom: 20rpx;
font-weight: bold;
font-size: 32rpx;
line-height: 48rpx;
color: #FF0000;
}
.label {
margin-bottom: 8rpx;
color: #333333;
font-size: 26rpx;
font-weight: bold;
line-height: 46rpx;
}
.custom-input {
height: 64rpx;
line-height: 64rpx;
box-sizing: border-box;
margin-bottom: 16rpx;
padding: 0 20rpx;
border: 2rpx solid #E2E2E2;
border-radius: 12rpx;
color: #333333;
font-size: 26rpx;
}
.submit-btn {
margin-top: 40rpx;
height: 64rpx;
line-height: 64rpx;
border-radius: 12rpx;
background: #FF005E;
color: #fff;
font-size: 26rpx;
}
// .address {
// text {
// width: 100%;
// display: block;
// }
// }
}
.people-box {
width: 628rpx;
height: 300rpx;
background: rgba(253, 104, 93, 0.05);
border-radius: 32rpx;
margin-bottom: 58rpx;
.icon-horn {
width: 32rpx;
height: 32rpx;
margin-right: 20rpx;
}
.title {
margin: 18rpx 0 20rpx;
font-size: 28rpx;
font-weight: bold;
line-height: 40rpx;
color: #FF005E;
}
.list {
.item {
margin: 0 44rpx 4rpx;
padding: 14rpx 30rpx;
color: #FD685D;
font-size: 24rpx;
opacity: .5;
}
.selected {
background: rgba(253, 104, 93, 0.2);
border-radius: 30px;
opacity: 1;
}
.grid-1 {
width: 200rpx;
}
.grid-2 {
width: 182rpx;
}
}
}
}
</style>