需求发布

This commit is contained in:
”chenxuelian“
2023-01-10 09:26:31 +08:00
parent e561054b6f
commit 7b474b06ef
4 changed files with 114 additions and 31 deletions

View File

@@ -24,7 +24,10 @@
cityList: [],
cityLevel1: [],
cityLevel2: [],
cityLevel3: []
cityLevel3: [],
cityLevelCode1: [],
cityLevelCode2: [],
cityLevelCode3: []
};
},
watch: {
@@ -41,7 +44,10 @@
this.cityList = [],
this.cityLevel1 = [],
this.cityLevel2 = [],
this.cityLevel3 = []
this.cityLevel3 = [],
this.cityLevelCode1 = []
this.cityLevelCode2 = []
this.cityLevelCode3 = []
this.initCityData();
}
},
@@ -57,29 +63,42 @@
// 遍历城市js
this.cityData.forEach((item1, index1) => {
let temp2 = [];
let code2 = [];
this.cityLevel1.push(item1.provinceName);
this.cityLevelCode1.push(item1.provinceCode);
let temp4 = [];
let temp3 = [];
let code4 = [];
let code3 = [];
// 遍历市
item1.cities.forEach((item2, index2) => {
temp2.push(item2.cityName);
code2.push(item2.cityCode);
// 遍历区
item2.counties.forEach((item3, index3) => {
temp3.push(item3.countyName);
code3.push(item3.countyCode);
})
temp4[index2] = temp3;
temp3 = [];
code4[index2] = code3;
code3 = [];
})
this.cityLevel3[index1] = temp4;
this.cityLevelCode3[index1] = code4;
this.cityLevel2[index1] = temp2;
this.cityLevelCode2[index1] = code2;
})
// 选择器默认城市
this.cityList.push(this.cityLevel1, this.cityLevel2[0], this.cityLevel3[0][0]);
},
// 选中时执行
changeHandler(e) {
console.log(e)
const {
columnIndex,
index,
@@ -102,8 +121,12 @@
// 单击确认按钮时执行
confirm(e) {
// 输出数组 [省, 市, 区]
console.log(e.value);
this.$emit('confirm', e.value)
console.log(e);
console.log(this.cityLevelCode3);
console.log(this.cityLevel3);
const code = this.cityLevelCode3[e.indexs[0]][e.indexs[1]][e.indexs[2]];
console.log(code);
this.$emit('confirm', [e.value, code]);
// 隐藏城市选择器
this.show = false;
},

View File

@@ -73,7 +73,7 @@
<view style="background-color: #fff;">
<u-form-item label="手机" borderBottom>
<u--input placeholder="请输入手机号" :border="false" v-model="needsPublishForm.phone"
<u--input placeholder="请输入手机号" :border="false" v-model="needsPublishForm.mobile"
placeholder-style="color:#CCCCCC"></u--input>
</u-form-item>
<!-- <u-form-item label="验证" borderBottom>
@@ -95,7 +95,7 @@
</view>
</view>
</u--form>
<view>
<view style="margin:0 20rpx;">
<u-overlay :show="!isLoad">
<login @success="reOnLoad()" @fail="failToLoad()"></login>
</u-overlay>
@@ -105,7 +105,8 @@
</template>
<script>
import login from '../my/login/login.vue'
import { apiService } from '../../service/request'
import login from '../my/login/login.vue'
export default {
components: {
login
@@ -171,8 +172,10 @@
this.needsPublishForm = {}
},
getCityValue(data) {
console.log(data)
this.showCityPicker = false
this.needsPublishForm.area_name = data.join('/')
this.needsPublishForm.area_name = data[0].join('-')
this.needsPublishForm.area_code = data[1]
},
getProductValue(data) {
this.showProductPicker = false
@@ -223,6 +226,7 @@
})
})
for (let i = 0; i < lists.length; i++) {
console.log(lists[i])
const result = await this.uploadFilePromise(lists[i].url)
let item = this[`fileList${event.name}`][fileListLen]
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
@@ -234,24 +238,48 @@
}
},
uploadFilePromise(url) {
// return new Promise((resolve, reject) => {
// let a = uni.uploadFile({
// url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
// filePath: url,
// name: 'file',
// formData: {
// user: 'test'
// },
// success: (res) => {
// setTimeout(() => {
// resolve(res.data.data)
// }, 1000)
// }
// });
// })
return new Promise((resolve, reject) => {
const data = {
file: new File
}
let a = apiService.postImage(data).then(res => {
console.log(res)
})
// let a = uni.uploadFile({
// url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
// filePath: url,
// name: 'file',
// formData: {
// user: 'test'
// },
// success: (res) => {
// setTimeout(() => {
// resolve(res.data.data)
// }, 1000)
// }
// });
})
},
//BlobUrl转blob数据
objectURLToBlob(blodurl) {
return new Promise((resolve, reject) => {
var http = new XMLHttpRequest();
http.open('GET', blodurl, true);
http.responseType = 'blob';
http.onload = function(e) {
if (this.status == 200 || this.status === 0) {
// console.log('blod数据',this.response);
// 在将blod数据转为file
let files = new window.File([this.response], 'file.name', { type: 'image' });
// console.log('blod数据转换file',files);
resolve(files);
}
};
http.send();
});
},
submitForm() {
if (!/^1[3456789]\d{9}$/.test(this.needsPublishForm.phone)) {
if (!/^1[3456789]\d{9}$/.test(this.needsPublishForm.mobile)) {
this.$toast.warn('请输入正确的手机号')
return false
}

View File

@@ -1,7 +1,11 @@
<template>
<view style="width: 100%;position: absolute;bottom: 0; padding-top: 30rpx; background-color: #fff;">
<view style="padding-left: 30rpx;padding-right: 30rpx;">
<u-button open-type="getPhoneNumber" size="medium" class="custom-style" @getphonenumber="getphonenumber"
<view class="login-content">
<view style="text-align: center;margin-bottom:30rpx;">
<text>请登录后查看</text>
</view>
<view style="padding-left: 30rpx;padding-right: 30rpx;display: flex;">
<u-button type="info" :plain="true" size="nomal" @click="$emit('fail')">取消</u-button>
<u-button open-type="getPhoneNumber" size="nomal" @getphonenumber="getphonenumber"
color='#12CA64'>登录</u-button>
</view>
</view>
@@ -9,6 +13,7 @@
<script>
import {
apiService,
loginSys
} from '@/service/request.js'
export default {
@@ -36,6 +41,14 @@
uni.setStorageSync('token', data.token);
that.$toast.success('登录成功')
that.$emit('success')
//登录完成后使用手机code换取手机号,调用/user/getMobileByMnp接口
//接口详细链接 https://docs.apipost.cn/preview/468be606f65cae75/3f2f988ddf82dd8e
const codeData = {
code: e.detail.code
}
apiService.postMobileByMnp(codeData).then(res => {
console.log(res)
})
})
},
fail: function(err) {
@@ -85,9 +98,16 @@
</script>
<style lang="less" scoped>
.custom-style {
width: 200rpx;
padding-left: 30rpx;
padding-right: 30rpx;
/deep/.u-button {
width: 40% !important;
}
.login-content {
width: 100%;
position:absolute;
top:50%;
left: 50%;
padding: 50rpx 30rpx;
background-color: #fff;
transform:translate(-50%,-50%);
}
</style>

View File

@@ -320,6 +320,18 @@ const apiService = {
resolve(service.post(url, data))
})
},
postMobileByMnp(data) {
const url = `/user/getMobileByMnp`
return new Promise((resolve, reject) => {
resolve(service.post(url, data))
})
},
postImage(data) {
const url = `/upload/image/`
return new Promise((resolve, reject) => {
resolve(service.post(url, data))
})
},
// 解密
decrypt(data) {
const url = `/api`