Merge pull request '需求发布' (#49) from chenxuelian into dev

Reviewed-on: http://git.hchyun.com/feashow/pupil/pulls/49
This commit is contained in:
1171906056
2023-01-10 01:27:14 +00:00
4 changed files with 114 additions and 31 deletions

View File

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

View File

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

View File

@@ -1,7 +1,11 @@
<template> <template>
<view style="width: 100%;position: absolute;bottom: 0; padding-top: 30rpx; background-color: #fff;"> <view class="login-content">
<view style="padding-left: 30rpx;padding-right: 30rpx;"> <view style="text-align: center;margin-bottom:30rpx;">
<u-button open-type="getPhoneNumber" size="medium" class="custom-style" @getphonenumber="getphonenumber" <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> color='#12CA64'>登录</u-button>
</view> </view>
</view> </view>
@@ -9,6 +13,7 @@
<script> <script>
import { import {
apiService,
loginSys loginSys
} from '@/service/request.js' } from '@/service/request.js'
export default { export default {
@@ -36,6 +41,14 @@
uni.setStorageSync('token', data.token); uni.setStorageSync('token', data.token);
that.$toast.success('登录成功') that.$toast.success('登录成功')
that.$emit('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) { fail: function(err) {
@@ -85,9 +98,16 @@
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.custom-style { /deep/.u-button {
width: 200rpx; width: 40% !important;
padding-left: 30rpx; }
padding-right: 30rpx; .login-content {
width: 100%;
position:absolute;
top:50%;
left: 50%;
padding: 50rpx 30rpx;
background-color: #fff;
transform:translate(-50%,-50%);
} }
</style> </style>

View File

@@ -349,6 +349,18 @@ const apiService = {
resolve(service.post(url, data)) 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) { decrypt(data) {
const url = `/api` const url = `/api`