作者 “关晓峰”

feat: 新页面加入

  1 +<template>
  2 + <view>
  3 + <image src="http://equiphappy.shs.broing.cn/assets/miniprogram/Frame3007@2x.png" style="width: 100vw;height: 100vh;" mode=""></image>
  4 + <view class="btn">
  5 + <u-button @click="go" style="width: 30%;" text="点击进入" shape="circle" type="primary" ></u-button>
  6 + </view>
  7 + <view class="btn1">
  8 + <u-button @click="go" text="跳过" shape="circle" type="info" :plain="true" ></u-button>
  9 + </view>
  10 + </view>
  11 +</template>
  12 +
  13 +<script>
  14 + export default {
  15 + data() {
  16 + return {
  17 + flag:''
  18 + }
  19 + },
  20 + methods: {
  21 + go(){
  22 + if(this.flag == 'buy'){
  23 + uni.reLaunch({
  24 + url:'/pages/index/buy'
  25 + })
  26 + }else{
  27 + uni.reLaunch({
  28 + url:'/pages/index/sell'
  29 + })
  30 + }
  31 + }
  32 + },
  33 + onLoad(option) {
  34 + console.log(option);
  35 + this.flag = option.val
  36 +
  37 + }
  38 + }
  39 +</script>
  40 +
  41 +<style scoped lang="scss">
  42 +.btn{
  43 + width: 100%;
  44 + position: absolute;
  45 + bottom: 94rpx;
  46 + /deep/ .u-button{
  47 + width: 30%!important;
  48 + }
  49 +}
  50 +.btn1{
  51 + width: 15%;
  52 + position: absolute;
  53 + top: 130rpx;
  54 + right: 32rpx;
  55 +}
  56 +
  57 +</style>
@@ -146,9 +146,12 @@ @@ -146,9 +146,12 @@
146 category_id: this.model1.userInfo.category_id, 146 category_id: this.model1.userInfo.category_id,
147 brand_id: this.model1.userInfo.brand_id, 147 brand_id: this.model1.userInfo.brand_id,
148 xinghao_id: this.model1.userInfo.xinghao_id, 148 xinghao_id: this.model1.userInfo.xinghao_id,
149 - province: this.model1.userInfo.province,  
150 day: this.model1.userInfo.day, 149 day: this.model1.userInfo.day,
151 - price: this.model1.userInfo.price 150 + price: this.model1.userInfo.price,
  151 + region:this.model1.userInfo.region,
  152 + province :this.model1.userInfo.region.slice(0,3),
  153 + city : this.model1.userInfo.region.slice(3,6),
  154 + address : this.model1.userInfo.region
152 } 155 }
153 uni.$u.http.post(this.nav == '发布求购' ? '/api/equip/add_equip_buy' : '/api/equip/add_equip_zu', p).then( 156 uni.$u.http.post(this.nav == '发布求购' ? '/api/equip/add_equip_buy' : '/api/equip/add_equip_zu', p).then(
154 res => { 157 res => {
@@ -158,18 +161,21 @@ @@ -158,18 +161,21 @@
158 icon:'none' 161 icon:'none'
159 }) 162 })
160 if(res.code == 1){ 163 if(res.code == 1){
161 - let pagearr = getCurrentPages(); //获取应用页面栈  
162 - let currentPage = pagearr[pagearr.length - 1]; //获取当前页面信息  
163 - console.log('option:', currentPage) //获取页面传递的信息  
164 - currentPage.$vm.category_id = ''  
165 - currentPage.$vm.name = ''  
166 - currentPage.$vm.brand_id = ''  
167 - currentPage.$vm.brand_name = ''  
168 - currentPage.$vm.xh_id = ''  
169 - currentPage.$vm.xh_name = ''  
170 - uni.redirectTo({  
171 - url: '/pages/index/buy'  
172 - }) 164 + setTimeout(() => {
  165 + let pagearr = getCurrentPages(); //获取应用页面栈
  166 + let currentPage = pagearr[pagearr.length - 1]; //获取当前页面信息
  167 + console.log('option:', currentPage) //获取页面传递的信息
  168 + currentPage.$vm.category_id = ''
  169 + currentPage.$vm.name = ''
  170 + currentPage.$vm.brand_id = ''
  171 + currentPage.$vm.brand_name = ''
  172 + currentPage.$vm.xh_id = ''
  173 + currentPage.$vm.xh_name = ''
  174 + uni.redirectTo({
  175 + url: '/pages/index/buy'
  176 + })
  177 + }, 1000)
  178 +
173 } 179 }
174 180
175 }).catch(err => { 181 }).catch(err => {
@@ -191,7 +197,10 @@ @@ -191,7 +197,10 @@
191 xh_name: '', 197 xh_name: '',
192 region: '', 198 region: '',
193 price: '', 199 price: '',
194 - day: '' 200 + day: '',
  201 + province:'',
  202 + city:'',
  203 + address:''
195 } 204 }
196 }, 205 },
197 goChoose() { 206 goChoose() {
@@ -116,7 +116,8 @@ @@ -116,7 +116,8 @@
116 p.province = p.region.slice(0,3) 116 p.province = p.region.slice(0,3)
117 p.city = p.region.slice(3,6) 117 p.city = p.region.slice(3,6)
118 p.address = p.region 118 p.address = p.region
119 - uni.$u.http.post( this.flag == 'sale' ?'/api/equip/add_equip_sale' : '/api/equip/add_equip_hire' , { 119 + console.log('sdadasds', this.flag);
  120 + uni.$u.http.post( this.flag === "sale" ?'/api/equip/add_equip_sale' : '/api/equip/add_equip_hire' , {
120 ...p, 121 ...p,
121 images_json: JSON.stringify(this.fileList) 122 images_json: JSON.stringify(this.fileList)
122 }).then(res => { 123 }).then(res => {
  1 +<template>
  2 + <view style="background-color: white;padding: 24rpx;">
  3 + <u--form
  4 + labelPosition="left"
  5 + :model="model1"
  6 + :rules="rules"
  7 + ref="uForm"
  8 + >
  9 + <u-form-item
  10 + labelWidth="200rpx"
  11 + label="姓名"
  12 + prop="userInfo.nickname"
  13 + borderBottom
  14 + ref="item1"
  15 + >
  16 + <u--input
  17 + v-model="model1.userInfo.nickname"
  18 + border="none"
  19 + ></u--input>
  20 + </u-form-item>
  21 + </u--form>
  22 +
  23 + <view class="" style="margin-top: 60rpx;">
  24 + <u-button text="保存" type="primary" @click="submit"></u-button>
  25 + </view>
  26 + </view>
  27 +</template>
  28 +
  29 +<script>
  30 + export default {
  31 + data() {
  32 + return {
  33 + model1:{
  34 + userInfo:{
  35 + nickname:''
  36 + }
  37 + },
  38 + rules: {
  39 + 'userInfo.nickname': {
  40 + type: 'string',
  41 + required: true,
  42 + message: '请填写姓名',
  43 + trigger: ['blur', 'change']
  44 + },
  45 + },
  46 + }
  47 + },
  48 + methods: {
  49 + submit(){
  50 + this.$refs.uForm.validate().then(res => {
  51 + console.log(res);
  52 + uni.$u.http.post('/api/user/profile',this.model1.userInfo).then(res => {
  53 + uni.showToast({
  54 + title:res.msg
  55 + })
  56 + setTimeout(() => {
  57 + uni.navigateBack({
  58 + delta:1
  59 + })
  60 + },1500)
  61 + })
  62 + }).catch(errors => {
  63 + uni.$u.toast('校验失败')
  64 + })
  65 +
  66 + }
  67 + },
  68 + onLoad(option) {
  69 + console.log(option);
  70 + this.model1.userInfo.nickname = option.name
  71 + },
  72 +
  73 + onReady() {
  74 + //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  75 + this.$refs.uForm.setRules(this.rules)
  76 + },
  77 + }
  78 +</script>
  79 +
  80 +<style>
  81 +
  82 +</style>
  1 +<template>
  2 + <view style="background-color: white;padding: 24rpx;">
  3 + <u--form labelPosition="left" :model="model1" :rules="rules" ref="uForm">
  4 + <u-form-item labelWidth="200rpx" label="原手机号" prop="userInfo.mobile" borderBottom ref="item1">
  5 + <u--input v-model="model1.userInfo.mobile" border="none"></u--input>
  6 + </u-form-item>
  7 + <u-form-item labelWidth="200rpx" label="新手机号" prop="userInfo.mobile" borderBottom ref="item1">
  8 + <u--input v-model="model1.userInfo.newmobile" border="none"></u--input>
  9 + </u-form-item>
  10 + <u-form-item labelWidth="200rpx" label="验证码" prop="userInfo.mobile" borderBottom ref="item1">
  11 + <view class="" style="display: flex; align-items: center; justify-content: space-between;">
  12 + <u--input v-model="model1.userInfo.code" placeholder="" style="width: 70vw;"></u--input>
  13 + <u-button text="获取验证码" @click="code" style="width: 20vw;">></u-button>
  14 + </view>
  15 +
  16 + </u-form-item>
  17 + </u--form>
  18 +
  19 + <view class="" style="margin-top: 60rpx;">
  20 + <u-button text="保存" type="primary" @click="submit"></u-button>
  21 + </view>
  22 + </view>
  23 +</template>
  24 +
  25 +<script>
  26 + export default {
  27 + data() {
  28 + return {
  29 + model1: {
  30 + userInfo: {
  31 + mobile: '',
  32 + newmobile: '',
  33 + code: ''
  34 + }
  35 + },
  36 + tips: '获取验证码',
  37 + rules: {
  38 + 'userInfo.mobile': [{
  39 + type: 'string',
  40 + required: true,
  41 + message: '请填写手机号',
  42 + trigger: ['blur', 'change']
  43 + },
  44 + {
  45 + // 自定义验证函数,见上说明
  46 + validator: (rule, value, callback) => {
  47 + // 上面有说,返回true表示校验通过,返回false表示不通过
  48 + // uni.$u.test.mobile()就是返回true或者false的
  49 + return uni.$u.test.mobile(value);
  50 + },
  51 + message: '手机号码不正确',
  52 + // 触发器可以同时用blur和change
  53 + trigger: ['change', 'blur'],
  54 + }
  55 + ]
  56 + },
  57 + }
  58 + },
  59 + methods: {
  60 + submit() {
  61 + let p = {
  62 + mobile: this.model1.userInfo.newmobile,
  63 + captcha: this.model1.userInfo.code || 8888
  64 + }
  65 + uni.$u.http.post('/api/user/changemobile', p).then(res => {
  66 + uni.showToast({
  67 + title: res.msg,
  68 + icon: 'none'
  69 + })
  70 + if (res.code == 1) {
  71 + setTimeout(() => {
  72 + uni.navigateBack({
  73 + delta: 1
  74 + })
  75 + }, 1500)
  76 + }
  77 +
  78 +
  79 + })
  80 + },
  81 + code() {
  82 + uni.showLoading({
  83 + title: '正在获取验证码'
  84 + })
  85 + uni.$u.http.post('/api/sms/send', {
  86 + mobile: this.model1.userInfo.newmobile,
  87 + event: 'changemobile'
  88 + }).then(res => {
  89 + console.log(res);
  90 + uni.hideLoading()
  91 + uni.showToast({
  92 + title: res.msg
  93 + })
  94 + })
  95 + },
  96 + codeChange(text) {
  97 + this.tips = text;
  98 + },
  99 + getCode() {
  100 + if (this.$refs.uCode.canGetCode) {
  101 + // 模拟向后端请求验证码
  102 + uni.showLoading({
  103 + title: '正在获取验证码'
  104 + })
  105 + uni.$u.http.post('/api/sms/send', {
  106 + mobile: this.model1.userInfo.newmobile,
  107 + event: 'changemobile'
  108 + }).then(res => {
  109 + console.log(res);
  110 + })
  111 + // setTimeout(() => {
  112 + // uni.hideLoading();
  113 + // // 这里此提示会被this.start()方法中的提示覆盖
  114 + // uni.$u.toast('验证码已发送');
  115 + // // 通知验证码组件内部开始倒计时
  116 + // this.$refs.uCode.start();
  117 + // }, 2000);
  118 + } else {
  119 + uni.$u.toast('倒计时结束后再发送');
  120 + }
  121 + },
  122 + },
  123 + onLoad(option) {
  124 + this.model1.userInfo.mobile = option.mobile
  125 + },
  126 +
  127 + onReady() {
  128 + //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  129 + // this.$refs.uForm.setRules(this.rules)
  130 + },
  131 + }
  132 +</script>
  133 +
  134 +<style>
  135 +
  136 +</style>
  1 +<template>
  2 + <view style="padding: 24rpx">
  3 + <u-parse :content="list"></u-parse>
  4 + </view>
  5 +</template>
  6 +
  7 +<script>
  8 + export default {
  9 + data() {
  10 + return {
  11 + list:null
  12 + }
  13 + },
  14 + methods: {
  15 +
  16 + },
  17 + onLoad() {
  18 + uni.$u.http.get('/api/common/get_agreement').then(res => {
  19 + console.log(res);
  20 + this.list = res.data.agreement
  21 + })
  22 + }
  23 + }
  24 +</script>
  25 +
  26 +<style>
  27 +
  28 +</style>
  1 +<template>
  2 + <view style="padding: 24rpx">
  3 + <u-parse :content="list"></u-parse>
  4 + </view>
  5 +</template>
  6 +
  7 +<script>
  8 + export default {
  9 + data() {
  10 + return {
  11 + list:null
  12 + }
  13 + },
  14 + methods: {
  15 +
  16 + },
  17 + onLoad() {
  18 + uni.$u.http.get('/api/common/get_agreement').then(res => {
  19 + console.log(res);
  20 + this.list = res.data.policy
  21 + })
  22 + }
  23 + }
  24 +</script>
  25 +
  26 +<style>
  27 +
  28 +</style>