Browse Source

邀请注册页面样式, 上传图片接口路径统一配置

feature-1.0
helming 3 years ago
parent
commit
b20d3aa89a
  1. 2
      main.js
  2. 2
      pages-userInfo/extends/extends.vue
  3. 4
      pages/index/upload/upload.vue
  4. 214
      pages/register/register.vue

2
main.js

@ -10,6 +10,8 @@ const baseURL = 'http://localhost:7010'
Vue.prototype.$baseURL = baseURL; Vue.prototype.$baseURL = baseURL;
Vue.prototype.$uploadURL = "/file/upload"; // ”/file/uploadBatch“
Vue.prototype.$uploadType = "file"; // files
Vue.prototype.$noMultipleClicks = common.noMultipleClicks; Vue.prototype.$noMultipleClicks = common.noMultipleClicks;
// #ifndef VUE3 // #ifndef VUE3

2
pages-userInfo/extends/extends.vue

@ -85,7 +85,7 @@
} }
return { return {
title: '邀请更多', title: '邀请更多',
path: '/pages/register/register', path: `/pages/register/register?inviteCode=${this.userInfo.inviteCode}`,
} }
}, },
methods:{ methods:{

4
pages/index/upload/upload.vue

@ -231,8 +231,8 @@
for (var i = 0; i < tempFilePaths.length; i++) { for (var i = 0; i < tempFilePaths.length; i++) {
//const tempFile = e.tempFiles[i]; //const tempFile = e.tempFiles[i];
const [error, res] = await uni.uploadFile({ const [error, res] = await uni.uploadFile({
url: 'http://8tiis2.natappfree.cc/file/upload', url: `${that.$baseURL}${that.$uploadURL}`,
name: 'file', name: `${that.$uploadType}`,
// url: 'http://pc2zer.natappfree.cc/file/uploadBatch', // url: 'http://pc2zer.natappfree.cc/file/uploadBatch',
// name: 'files', // name: 'files',
header:{ header:{

214
pages/register/register.vue

@ -1,34 +1,54 @@
<template> <template>
<view> <view class="container">
<uni-forms :modelValue="formData" validate-trigger='blur' ref="form"> <uni-forms :modelValue="formData"
validate-trigger='blur'
label-position="top"
label-width="335"
ref="form">
<uni-forms-item label="昵称" required name="name"> <uni-forms-item label="昵称" required name="name">
<uni-easyinput v-model="formData.name" placeholder="请输入昵称" /> <uni-easyinput v-model="formData.name" placeholder="请输入昵称"
:clearable="false"
:inputBorder="false" />
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="手机号" required name="phone"> <uni-forms-item label="手机号" required name="phone">
<uni-easyinput v-model="formData.phone" placeholder="请输入手机号" /> <uni-easyinput v-model="formData.phone" placeholder="请输入手机号"
:clearable="false"
:inputBorder="false" />
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="密码" required name="password"> <uni-forms-item label="密码" required name="password">
<uni-easyinput type="password" v-model="formData.password" placeholder="请输入密码" /> <uni-easyinput type="password" v-model="formData.password" placeholder="请输入密码"
:clearable="false"
:inputBorder="false"/>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="搜索码" required name="scanCode"> <uni-forms-item label="搜索码" required name="scanCode">
<uni-easyinput v-model="formData.scanCode" placeholder="请输入搜索码" /> <uni-easyinput v-model="formData.scanCode" placeholder="请输入搜索码"
:clearable="false"
:inputBorder="false" />
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="邀请码" required name="inviteCode"> <uni-forms-item label="邀请码" required name="inviteCode">
<uni-easyinput v-model="formData.inviteCode" placeholder="请输入邀请码" /> <uni-easyinput v-model="formData.inviteCode" placeholder="请输入邀请码"
:disabled="true"
:clearable="false"
:inputBorder="false" />
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="简介" name="intro"> <uni-forms-item label="简介" name="intro">
<uni-easyinput v-model="formData.intro" placeholder="请输入简介" /> <uni-easyinput v-model="formData.intro" placeholder="请输入简介"
type="textarea"
:clearable="false"
:inputBorder="false"/>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="第三方平台账号详情地址" required name="url"> <uni-forms-item label="第三方平台账号详情地址" required name="url">
<uni-easyinput v-model="formData.url" placeholder="请输入第三方平台账号详情地址" /> <uni-easyinput v-model="formData.url" placeholder="请输入第三方平台账号详情地址"
:clearable="false"
:inputBorder="false" />
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="头像" required name="img"> <uni-forms-item label="头像" required name="img">
<uni-file-picker limit="1" file-mediatype="image" title="选择一张头像图片上传吧!" file-extname="png,jpg,jpeg" <uni-file-picker limit="1" file-mediatype="image" title="选择一张头像图片上传吧!" file-extname="png,jpg,jpeg"
@success="imgUploadSuccess" @fail="imgUploadFail" @select="uploadImg" @delete="deleteImg"> @success="imgUploadSuccess" @fail="imgUploadFail" @select="selectImage" @delete="deleteImg">
</uni-file-picker> </uni-file-picker>
</uni-forms-item> </uni-forms-item>
</uni-forms> </uni-forms>
<button type="primary" @click="register(formData)">注册</button> <button class="confirmBtn" size="default" @click="$noMultipleClicks(submit)">注册</button>
</view> </view>
</template> </template>
@ -61,7 +81,8 @@
url: '', url: '',
img: '' img: ''
}, },
fileList: [],
noClick:true, //
rules: { rules: {
name: { name: {
rules: [{ rules: [{
@ -132,7 +153,7 @@
scanCode: this.formData.scanCode scanCode: this.formData.scanCode
} }
checkScanCode(params).then(res => { checkScanCode(params).then(res => {
console.log('请求scanCode') // console.log('scanCode')
if (res.data.code === 105003) { if (res.data.code === 105003) {
// callback()new Error('') // callback()new Error('')
this.scanCodeFlag = false; this.scanCodeFlag = false;
@ -162,7 +183,7 @@
inviteCode: this.formData.inviteCode inviteCode: this.formData.inviteCode
} }
checkInviteCode(params).then(res => { checkInviteCode(params).then(res => {
console.log('请求inviteCode') // console.log('inviteCode')
if (res.data.code === 105002) { if (res.data.code === 105002) {
// callback()new Error('') // callback()new Error('')
this.inviteCodeFlag = false; this.inviteCodeFlag = false;
@ -190,66 +211,67 @@
rules: [{ rules: [{
required: true, required: true,
errorMessage: '请选择一张头像图片上传' errorMessage: '请选择一张头像图片上传'
}] }
]
} }
} }
} }
}, },
onLoad(option) {
if (option.inviteCode) {
this.formData.inviteCode = option.inviteCode;
}
},
mounted(){ mounted(){
// //
this.$refs.form.setRules(this.rules); this.$refs.form.setRules(this.rules);
}, },
methods: { methods: {
selectImage(e) {
if (!e.tempFiles) {
return;
}
let that = this;
that.fileList = [...that.fileList, ...e.tempFilePaths];
that.formData.img = e.tempFilePaths[0];
},
// //
uploadImg(e) { uploadImg: async function (e) {
console.log('选择了文件', e) // console.log('', e)
let that = this let that = this;
uni.showLoading({ uni.showLoading({
title: "上传中", title: "上传中"
success() { });
const tempFilePaths = e.tempFilePaths; const tempFilePaths = e;
for (var i = 0; i < tempFilePaths.length; i++) { for (var i = 0; i < tempFilePaths.length; i++) {
const tempFile = e.tempFiles[i]; const [error, res] = await uni.uploadFile({
uni.uploadFile({ url: `${that.$baseURL}${that.$uploadURL}`,
url: `${Vue.prototype.$baseURL}/file/uploadBatch`,
filePath: tempFilePaths[i], filePath: tempFilePaths[i],
name: 'files', name: `${that.$uploadType}`,
success: (uploadFileRes) => { header:{
uni.hideLoading(); "Content-Type": "multipart/form-data"
const result = JSON.parse(uploadFileRes.data);
console.log('result', result)
if (result.code === 200) {
that.$set(result.data, "url", tempFile.url)
that.formData.img = result.data[0]
console.log('that.formDataInner',that.formData)
uni.showToast({
title: '上传成功',
icon: 'success',
duration: 1500
})
}
},
fail: () => {
uni.hideLoading();
uni.showToast("上传失败")
}, },
complete: function() { })
uni.hideLoading(); const back = JSON.parse(res.data);
} if (back.code == 200) {
}); that.formData.img = back.data;
} }
} }
}); uni.hideLoading()
that.register();
}, },
// //
deleteImg(e) { deleteImg(e) {
console.log('e',this.formData.img) let that = this
const param = { that.fileList = [];
that.formData.img = ''
// console.log('e',this.formData.img)
/*const param = {
url : this.formData.img url : this.formData.img
} }
deleteFile(param).then(response =>{ deleteFile(param).then(response =>{
console.log('response',response) // console.log('response',response)
if(response.data.code === 200){ if(response.data.code === 200){
uni.showToast({ uni.showToast({
title: '图片删除成功', title: '图片删除成功',
@ -264,7 +286,7 @@
}) })
} }
}); });
console.log('图片删除成功') console.log('图片删除成功')*/
}, },
// //
imgUploadSuccess(e) { imgUploadSuccess(e) {
@ -275,20 +297,26 @@
imgUploadFail(e) { imgUploadFail(e) {
console.log('上传失败:', e) console.log('上传失败:', e)
}, },
submit() {
let that = this;
that.$refs.form.validate([], (err, formData) => {
if (!err) {
that.uploadImg(that.fileList)
} else {
uni.showToast({
title: '注册验证尚未全部通过,请更正后提交!',
icon: 'none',
duration: 3000
})
}
})
},
// //
register(e) { register(e) {
console.log(e)
let that = this let that = this
console.log('that.phoneFlag',that.phoneFlag)
console.log('that.scanCodeFlag',that.scanCodeFlag)
console.log('that.inviteCodeFlag',that.inviteCodeFlag)
if(that.phoneFlag === true && that.scanCodeFlag === true && that.inviteCodeFlag === true){
console.log('全部达成')
uni.showLoading({ uni.showLoading({
title: '艺术家注册中!', title: '艺术家注册中!',
duration: 3000, });
success() {
let pwd = md5(that.formData.password) let pwd = md5(that.formData.password)
const param = { const param = {
name: that.formData.name, name: that.formData.name,
@ -300,7 +328,7 @@
inviteCode: that.formData.inviteCode, inviteCode: that.formData.inviteCode,
url: that.formData.url url: that.formData.url
} }
console.log('form', param) // console.log('form', param)
insertCreator(param).then(response => { insertCreator(param).then(response => {
if (response.data.code === 200) { if (response.data.code === 200) {
// //
@ -315,35 +343,69 @@
} }
}); });
} else { } else {
uni.hideLoading()
}
}).catch(error => {
uni.hideLoading()
uni.showToast({ uni.showToast({
title: response.data.msg, title: error,
icon: 'none' icon: 'none'
}) })
}
})
},
fail: () => {
uni.hideLoading();
uni.showToast("注册失败")
},
complete: function() {
uni.hideLoading();
}
}) })
// console.log('that.phoneFlag',that.phoneFlag)
// console.log('that.scanCodeFlag',that.scanCodeFlag)
// console.log('that.inviteCodeFlag',that.inviteCodeFlag)
/*if(that.phoneFlag === true && that.scanCodeFlag === true && that.inviteCodeFlag === true){
// console.log('')
}else{ }else{
console.log('尚未全部达成') // console.log('')
uni.showToast({ uni.showToast({
title: '注册验证尚未全部通过,请更正后提交!', title: '注册验证尚未全部通过,请更正后提交!',
icon: 'none', icon: 'none',
duration: 3000 duration: 3000
}) })
} }*/
} }
} }
} }
</script> </script>
<style> <style lang="scss" scoped>
.container {
width: 670rpx;
margin: 0 auto;
padding-bottom: 60rpx;
::v-deep .uni-forms-item__label {
color: $uni-white;
}
::v-deep input {
background: $uni-bg-base-color !important;
color: $uni-white !important;
border-radius: 10rpx;
}
::v-deep .uni-easyinput__content {
background: $uni-bg-base-color !important;
border-radius: 10rpx;
}
::v-deep textarea {
background: $uni-bg-base-color !important;
color: $uni-white !important;
border-radius: 10rpx;
}
::v-deep .file-title {
color: $uni-secondary-color !important;
}
.confirmBtn{
color: $uni-btn-text-color;
}
}
</style> </style>

Loading…
Cancel
Save