作者 “关晓峰”

feat: 新页面加入

<template>
<view>
<image src="http://equiphappy.shs.broing.cn/assets/miniprogram/Frame3007@2x.png" style="width: 100vw;height: 100vh;" mode=""></image>
<view class="btn">
<u-button @click="go" style="width: 30%;" text="点击进入" shape="circle" type="primary" ></u-button>
</view>
<view class="btn1">
<u-button @click="go" text="跳过" shape="circle" type="info" :plain="true" ></u-button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
flag:''
}
},
methods: {
go(){
if(this.flag == 'buy'){
uni.reLaunch({
url:'/pages/index/buy'
})
}else{
uni.reLaunch({
url:'/pages/index/sell'
})
}
}
},
onLoad(option) {
console.log(option);
this.flag = option.val
}
}
</script>
<style scoped lang="scss">
.btn{
width: 100%;
position: absolute;
bottom: 94rpx;
/deep/ .u-button{
width: 30%!important;
}
}
.btn1{
width: 15%;
position: absolute;
top: 130rpx;
right: 32rpx;
}
</style>
... ...
... ... @@ -146,9 +146,12 @@
category_id: this.model1.userInfo.category_id,
brand_id: this.model1.userInfo.brand_id,
xinghao_id: this.model1.userInfo.xinghao_id,
province: this.model1.userInfo.province,
day: this.model1.userInfo.day,
price: this.model1.userInfo.price
price: this.model1.userInfo.price,
region:this.model1.userInfo.region,
province :this.model1.userInfo.region.slice(0,3),
city : this.model1.userInfo.region.slice(3,6),
address : this.model1.userInfo.region
}
uni.$u.http.post(this.nav == '发布求购' ? '/api/equip/add_equip_buy' : '/api/equip/add_equip_zu', p).then(
res => {
... ... @@ -158,18 +161,21 @@
icon:'none'
})
if(res.code == 1){
let pagearr = getCurrentPages(); //获取应用页面栈
let currentPage = pagearr[pagearr.length - 1]; //获取当前页面信息
console.log('option:', currentPage) //获取页面传递的信息
currentPage.$vm.category_id = ''
currentPage.$vm.name = ''
currentPage.$vm.brand_id = ''
currentPage.$vm.brand_name = ''
currentPage.$vm.xh_id = ''
currentPage.$vm.xh_name = ''
uni.redirectTo({
url: '/pages/index/buy'
})
setTimeout(() => {
let pagearr = getCurrentPages(); //获取应用页面栈
let currentPage = pagearr[pagearr.length - 1]; //获取当前页面信息
console.log('option:', currentPage) //获取页面传递的信息
currentPage.$vm.category_id = ''
currentPage.$vm.name = ''
currentPage.$vm.brand_id = ''
currentPage.$vm.brand_name = ''
currentPage.$vm.xh_id = ''
currentPage.$vm.xh_name = ''
uni.redirectTo({
url: '/pages/index/buy'
})
}, 1000)
}
}).catch(err => {
... ... @@ -191,7 +197,10 @@
xh_name: '',
region: '',
price: '',
day: ''
day: '',
province:'',
city:'',
address:''
}
},
goChoose() {
... ...
... ... @@ -116,7 +116,8 @@
p.province = p.region.slice(0,3)
p.city = p.region.slice(3,6)
p.address = p.region
uni.$u.http.post( this.flag == 'sale' ?'/api/equip/add_equip_sale' : '/api/equip/add_equip_hire' , {
console.log('sdadasds', this.flag);
uni.$u.http.post( this.flag === "sale" ?'/api/equip/add_equip_sale' : '/api/equip/add_equip_hire' , {
...p,
images_json: JSON.stringify(this.fileList)
}).then(res => {
... ...
<template>
<view style="background-color: white;padding: 24rpx;">
<u--form
labelPosition="left"
:model="model1"
:rules="rules"
ref="uForm"
>
<u-form-item
labelWidth="200rpx"
label="姓名"
prop="userInfo.nickname"
borderBottom
ref="item1"
>
<u--input
v-model="model1.userInfo.nickname"
border="none"
></u--input>
</u-form-item>
</u--form>
<view class="" style="margin-top: 60rpx;">
<u-button text="保存" type="primary" @click="submit"></u-button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
model1:{
userInfo:{
nickname:''
}
},
rules: {
'userInfo.nickname': {
type: 'string',
required: true,
message: '请填写姓名',
trigger: ['blur', 'change']
},
},
}
},
methods: {
submit(){
this.$refs.uForm.validate().then(res => {
console.log(res);
uni.$u.http.post('/api/user/profile',this.model1.userInfo).then(res => {
uni.showToast({
title:res.msg
})
setTimeout(() => {
uni.navigateBack({
delta:1
})
},1500)
})
}).catch(errors => {
uni.$u.toast('校验失败')
})
}
},
onLoad(option) {
console.log(option);
this.model1.userInfo.nickname = option.name
},
onReady() {
//如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
this.$refs.uForm.setRules(this.rules)
},
}
</script>
<style>
</style>
... ...
<template>
<view style="background-color: white;padding: 24rpx;">
<u--form labelPosition="left" :model="model1" :rules="rules" ref="uForm">
<u-form-item labelWidth="200rpx" label="原手机号" prop="userInfo.mobile" borderBottom ref="item1">
<u--input v-model="model1.userInfo.mobile" border="none"></u--input>
</u-form-item>
<u-form-item labelWidth="200rpx" label="新手机号" prop="userInfo.mobile" borderBottom ref="item1">
<u--input v-model="model1.userInfo.newmobile" border="none"></u--input>
</u-form-item>
<u-form-item labelWidth="200rpx" label="验证码" prop="userInfo.mobile" borderBottom ref="item1">
<view class="" style="display: flex; align-items: center; justify-content: space-between;">
<u--input v-model="model1.userInfo.code" placeholder="" style="width: 70vw;"></u--input>
<u-button text="获取验证码" @click="code" style="width: 20vw;">></u-button>
</view>
</u-form-item>
</u--form>
<view class="" style="margin-top: 60rpx;">
<u-button text="保存" type="primary" @click="submit"></u-button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
model1: {
userInfo: {
mobile: '',
newmobile: '',
code: ''
}
},
tips: '获取验证码',
rules: {
'userInfo.mobile': [{
type: 'string',
required: true,
message: '请填写手机号',
trigger: ['blur', 'change']
},
{
// 自定义验证函数,见上说明
validator: (rule, value, callback) => {
// 上面有说,返回true表示校验通过,返回false表示不通过
// uni.$u.test.mobile()就是返回true或者false的
return uni.$u.test.mobile(value);
},
message: '手机号码不正确',
// 触发器可以同时用blur和change
trigger: ['change', 'blur'],
}
]
},
}
},
methods: {
submit() {
let p = {
mobile: this.model1.userInfo.newmobile,
captcha: this.model1.userInfo.code || 8888
}
uni.$u.http.post('/api/user/changemobile', p).then(res => {
uni.showToast({
title: res.msg,
icon: 'none'
})
if (res.code == 1) {
setTimeout(() => {
uni.navigateBack({
delta: 1
})
}, 1500)
}
})
},
code() {
uni.showLoading({
title: '正在获取验证码'
})
uni.$u.http.post('/api/sms/send', {
mobile: this.model1.userInfo.newmobile,
event: 'changemobile'
}).then(res => {
console.log(res);
uni.hideLoading()
uni.showToast({
title: res.msg
})
})
},
codeChange(text) {
this.tips = text;
},
getCode() {
if (this.$refs.uCode.canGetCode) {
// 模拟向后端请求验证码
uni.showLoading({
title: '正在获取验证码'
})
uni.$u.http.post('/api/sms/send', {
mobile: this.model1.userInfo.newmobile,
event: 'changemobile'
}).then(res => {
console.log(res);
})
// setTimeout(() => {
// uni.hideLoading();
// // 这里此提示会被this.start()方法中的提示覆盖
// uni.$u.toast('验证码已发送');
// // 通知验证码组件内部开始倒计时
// this.$refs.uCode.start();
// }, 2000);
} else {
uni.$u.toast('倒计时结束后再发送');
}
},
},
onLoad(option) {
this.model1.userInfo.mobile = option.mobile
},
onReady() {
//如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
// this.$refs.uForm.setRules(this.rules)
},
}
</script>
<style>
</style>
\ No newline at end of file
... ...
<template>
<view style="padding: 24rpx">
<u-parse :content="list"></u-parse>
</view>
</template>
<script>
export default {
data() {
return {
list:null
}
},
methods: {
},
onLoad() {
uni.$u.http.get('/api/common/get_agreement').then(res => {
console.log(res);
this.list = res.data.agreement
})
}
}
</script>
<style>
</style>
... ...
<template>
<view style="padding: 24rpx">
<u-parse :content="list"></u-parse>
</view>
</template>
<script>
export default {
data() {
return {
list:null
}
},
methods: {
},
onLoad() {
uni.$u.http.get('/api/common/get_agreement').then(res => {
console.log(res);
this.list = res.data.policy
})
}
}
</script>
<style>
</style>
... ...