diff --git a/main.js b/main.js
index 320b0f4..c545382 100644
--- a/main.js
+++ b/main.js
@@ -10,6 +10,8 @@ const baseURL = 'http://localhost:7010'
Vue.prototype.$baseURL = baseURL;
+Vue.prototype.$uploadURL = "/file/upload"; // ”/file/uploadBatch“
+Vue.prototype.$uploadType = "file"; // files
Vue.prototype.$noMultipleClicks = common.noMultipleClicks;
// #ifndef VUE3
diff --git a/pages-userInfo/extends/extends.vue b/pages-userInfo/extends/extends.vue
index 6963b32..b73d618 100644
--- a/pages-userInfo/extends/extends.vue
+++ b/pages-userInfo/extends/extends.vue
@@ -85,7 +85,7 @@
}
return {
title: '邀请更多',
- path: '/pages/register/register',
+ path: `/pages/register/register?inviteCode=${this.userInfo.inviteCode}`,
}
},
methods:{
diff --git a/pages/index/upload/upload.vue b/pages/index/upload/upload.vue
index 263c6d6..159d0dd 100644
--- a/pages/index/upload/upload.vue
+++ b/pages/index/upload/upload.vue
@@ -231,8 +231,8 @@
for (var i = 0; i < tempFilePaths.length; i++) {
//const tempFile = e.tempFiles[i];
const [error, res] = await uni.uploadFile({
- url: 'http://8tiis2.natappfree.cc/file/upload',
- name: 'file',
+ url: `${that.$baseURL}${that.$uploadURL}`,
+ name: `${that.$uploadType}`,
// url: 'http://pc2zer.natappfree.cc/file/uploadBatch',
// name: 'files',
header:{
diff --git a/pages/register/register.vue b/pages/register/register.vue
index f8be375..847d8f4 100644
--- a/pages/register/register.vue
+++ b/pages/register/register.vue
@@ -1,34 +1,54 @@
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+ @success="imgUploadSuccess" @fail="imgUploadFail" @select="selectImage" @delete="deleteImg">
-
+
@@ -61,7 +81,8 @@
url: '',
img: ''
},
-
+ fileList: [],
+ noClick:true, //防止重复提交
rules: {
name: {
rules: [{
@@ -132,7 +153,7 @@
scanCode: this.formData.scanCode
}
checkScanCode(params).then(res => {
- console.log('请求scanCode')
+ // console.log('请求scanCode')
if (res.data.code === 105003) {
// 如果验证不通过,需要在callback()抛出new Error('错误提示信息')
this.scanCodeFlag = false;
@@ -162,7 +183,7 @@
inviteCode: this.formData.inviteCode
}
checkInviteCode(params).then(res => {
- console.log('请求inviteCode')
+ // console.log('请求inviteCode')
if (res.data.code === 105002) {
// 如果验证不通过,需要在callback()抛出new Error('错误提示信息')
this.inviteCodeFlag = false;
@@ -190,66 +211,67 @@
rules: [{
required: true,
errorMessage: '请选择一张头像图片上传'
- }]
+ }
+ ]
}
}
}
},
+ onLoad(option) {
+ if (option.inviteCode) {
+ this.formData.inviteCode = option.inviteCode;
+ }
+ },
mounted(){
//设置校验规则
this.$refs.form.setRules(this.rules);
},
methods: {
+ selectImage(e) {
+ if (!e.tempFiles) {
+ return;
+ }
+ let that = this;
+ that.fileList = [...that.fileList, ...e.tempFilePaths];
+ that.formData.img = e.tempFilePaths[0];
+ },
//图片上传
- uploadImg(e) {
- console.log('选择了文件', e)
- let that = this
- uni.showLoading({
- title: "上传中",
- success() {
- const tempFilePaths = e.tempFilePaths;
- for (var i = 0; i < tempFilePaths.length; i++) {
- const tempFile = e.tempFiles[i];
- uni.uploadFile({
- url: `${Vue.prototype.$baseURL}/file/uploadBatch`,
- filePath: tempFilePaths[i],
- name: 'files',
- success: (uploadFileRes) => {
- uni.hideLoading();
- 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();
- }
- });
- }
- }
- });
+ uploadImg: async function (e) {
+ // console.log('选择了文件', e)
+ let that = this;
+ uni.showLoading({
+ title: "上传中"
+ });
+ const tempFilePaths = e;
+ for (var i = 0; i < tempFilePaths.length; i++) {
+ const [error, res] = await uni.uploadFile({
+ url: `${that.$baseURL}${that.$uploadURL}`,
+ filePath: tempFilePaths[i],
+ name: `${that.$uploadType}`,
+ header:{
+ "Content-Type": "multipart/form-data"
+ },
+ })
+ const back = JSON.parse(res.data);
+ if (back.code == 200) {
+ that.formData.img = back.data;
+ }
+ }
+ uni.hideLoading()
+ that.register();
},
//删除图片
deleteImg(e) {
- console.log('e',this.formData.img)
- const param = {
+ let that = this
+ that.fileList = [];
+ that.formData.img = ''
+ // console.log('e',this.formData.img)
+ /*const param = {
url : this.formData.img
}
deleteFile(param).then(response =>{
- console.log('response',response)
+ // console.log('response',response)
if(response.data.code === 200){
uni.showToast({
title: '图片删除成功',
@@ -264,7 +286,7 @@
})
}
});
- console.log('图片删除成功')
+ console.log('图片删除成功')*/
},
// 上传成功
imgUploadSuccess(e) {
@@ -275,75 +297,115 @@
imgUploadFail(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) {
- console.log(e)
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({
- title: '艺术家注册中!',
- duration: 3000,
- success() {
- let pwd = md5(that.formData.password)
- const param = {
- name: that.formData.name,
- scanCode: that.formData.scanCode,
- phone: that.formData.phone,
- password: pwd,
- img: that.formData.img,
- intro: that.formData.intro,
- inviteCode: that.formData.inviteCode,
- url: that.formData.url
- }
- console.log('form', param)
- insertCreator(param).then(response => {
- if (response.data.code === 200) {
- //注册成功,页面跳转到登录页
- uni.redirectTo({
- url: '../login/login',
- success() {
- uni.showToast({
- title: '艺术家注册成功!请耐心等待审核或联系客服',
- icon: 'none',
- duration: 4000
- })
- }
- });
- } else {
- uni.showToast({
- title: response.data.msg,
- icon: 'none'
- })
- }
- })
- },
- fail: () => {
- uni.hideLoading();
- uni.showToast("注册失败")
- },
- complete: function() {
- uni.hideLoading();
- }
- })
+ uni.showLoading({
+ title: '艺术家注册中!',
+ });
+ let pwd = md5(that.formData.password)
+ const param = {
+ name: that.formData.name,
+ scanCode: that.formData.scanCode,
+ phone: that.formData.phone,
+ password: pwd,
+ img: that.formData.img,
+ intro: that.formData.intro,
+ inviteCode: that.formData.inviteCode,
+ url: that.formData.url
+ }
+ // console.log('form', param)
+ insertCreator(param).then(response => {
+ if (response.data.code === 200) {
+ //注册成功,页面跳转到登录页
+ uni.redirectTo({
+ url: '../login/login',
+ success() {
+ uni.showToast({
+ title: '艺术家注册成功!请耐心等待审核或联系客服',
+ icon: 'none',
+ duration: 4000
+ })
+ }
+ });
+ } else {
+ uni.hideLoading()
+ }
+ }).catch(error => {
+ uni.hideLoading()
+ uni.showToast({
+ title: error,
+ icon: 'none'
+ })
+ })
+
+ // 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{
- console.log('尚未全部达成')
+ // console.log('尚未全部达成')
uni.showToast({
title: '注册验证尚未全部通过,请更正后提交!',
icon: 'none',
duration: 3000
})
- }
+ }*/
}
}
}
-