fix 修改登录bug

This commit is contained in:
lwh 2023-06-12 21:58:21 +08:00
parent 05416bc573
commit ae7383d5b8
4 changed files with 182 additions and 18 deletions

View File

@ -5,22 +5,175 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
logo: [], shopInfo: {
ShopBusinessCategoryGuid: "",
ShopName: "",
ShopIntro: "",
ShopLogo: [],
ShopBusinessLicense: [],
},
}, },
submit(){ // 提交
console.log(this.data.logo); submit() {
console.log(this.data.shopInfo);
let data = this.data.shopInfo
data.ShopLogo = data.ShopLogo.map(item => item.url).join(',')
data.ShopBusinessLicense = data.ShopBusinessLicense.map(item => item.url).join(',')
console.log(data);
}, },
onCustomEvent(event) { onChangeShopName(e) {
// console.log(event.detail,"获取子组件传递的值"); this.setData({
// const receivedData = event.detail; // 获取子组件传递的值 "shopInfo.ShopName": e.detail.value
// this.setData({ })
// fileList: receivedData // 将子组件传递的值绑定到父组件的 data 属性 fileList 上
// });
}, },
onChangeShopIntro(e) {
this.setData({
"shopInfo.ShopIntro": e.detail.value
})
},
// 上传Logo
handleAddLogo(e) {
const {
files
} = e.detail;
// 每次选择图片都上传,展示每次上传图片的进度
files.forEach(file => this.onUploadLogo(file))
},
// 移除Logo
handleRemoveLogo(e) {
const {
index
} = e.detail;
const {
ShopLogo
} = this.data.shopInfo;
ShopLogo.splice(index, 1);
this.setData({
"shopInfo.ShopLogo": ShopLogo,
});
},
// 上传ShopBusinessLicense
handleAddShopBusinessLicense(e) {
const {
files
} = e.detail;
// 每次选择图片都上传,展示每次上传图片的进度
files.forEach(file => this.onUploadShopBusinessLicense(file, this.data.shopInfo.ShopBusinessLicense))
},
// 移除营业执照
handleRemoveShopBusinessLicense(e) {
const {
index
} = e.detail;
const {
ShopBusinessLicense
} = this.data.shopInfo;
ShopBusinessLicense.splice(index, 1);
this.setData({
"shopInfo.ShopBusinessLicense": ShopBusinessLicense,
});
},
// 上传Logo方法
onUploadLogo(file) {
let {
ShopLogo
} = this.data.shopInfo
this.setData({
"shopInfo.ShopLogo": [...ShopLogo, {
...file,
status: 'loading'
}],
});
const {
length
} = ShopLogo;
const task = wx.uploadFile({
url: 'http://192.168.1.102:8888/api/Common/UploadFile', // 仅为示例,非真实的接口地址
filePath: file.url,
name: 'file',
formData: {
fileDir: 'Shops'
},
success: (res) => {
this.setData({
[`shopInfo.ShopLogo[${length}].url`]: JSON.parse(res.data).data.url,
[`shopInfo.ShopLogo[${length}].status`]: 'done',
});
// this.triggerEventToParent()
},
});
task.onProgressUpdate((res) => {
this.setData({
[`shopInfo.ShopLogo[${length}].percent`]: res.progress,
});
});
},
// 上传营业执照方法
onUploadShopBusinessLicense(file) {
let {
ShopBusinessLicense
} = this.data.shopInfo
this.setData({
"shopInfo.ShopBusinessLicense": [...ShopBusinessLicense, {
...file,
status: 'loading'
}],
});
const {
length
} = ShopBusinessLicense;
const task = wx.uploadFile({
url: 'http://192.168.1.102:8888/api/Common/UploadFile', // 仅为示例,非真实的接口地址
filePath: file.url,
name: 'file',
formData: {
fileDir: 'Shops'
},
success: (res) => {
this.setData({
[`shopInfo.ShopBusinessLicense[${length}].url`]: JSON.parse(res.data).data.url,
[`shopInfo.ShopBusinessLicense[${length}].status`]: 'done',
});
// this.triggerEventToParent()
},
});
task.onProgressUpdate((res) => {
this.setData({
[`shopInfo.ShopBusinessLicense[${length}].percent`]: res.progress,
});
});
},
// onCustomEvent(event) {
// // console.log(event.detail,"获取子组件传递的值");
// // const receivedData = event.detail; // 获取子组件传递的值
// // this.setData({
// // fileList: receivedData // 将子组件传递的值绑定到父组件的 data 属性 fileList 上
// // });
// },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */

View File

@ -2,8 +2,8 @@
"usingComponents": { "usingComponents": {
"t-input": "tdesign-miniprogram/input/input", "t-input": "tdesign-miniprogram/input/input",
"t-textarea": "tdesign-miniprogram/textarea/textarea", "t-textarea": "tdesign-miniprogram/textarea/textarea",
"upload": "/components/upload/index",
"t-button": "tdesign-miniprogram/button/button", "t-button": "tdesign-miniprogram/button/button",
"t-upload": "tdesign-miniprogram/upload/upload",
"van-button": "@vant/weapp/button/index" "van-button": "@vant/weapp/button/index"
}, },
"navigationBarTitleText": "申请开店" "navigationBarTitleText": "申请开店"

View File

@ -3,30 +3,41 @@
<view class="apply-shop-container"> <view class="apply-shop-container">
<t-input value="{{shopInfo.ShopBusinessCategoryGuid}}" label="经营类目" maxlength="10" placeholder="请输入店铺名称" align="right" /> <t-input value="{{shopInfo.ShopBusinessCategoryGuid}}" label="经营类目" maxlength="10" placeholder="请输入店铺名称" align="right" />
<t-input value="{{shopInfo.ShopName}}" label="店铺名称" maxlength="10" placeholder="请输入店铺名称" align="right" /> <t-input value="{{shopInfo.ShopName}}" bindchange="onChangeShopName" label="店铺名称" maxlength="10" placeholder="请输入店铺名称" align="right" />
<t-textarea <t-textarea
value="{{shopInfo.ShopIntro}}" value="{{shopInfo.ShopIntro}}"
t-class="external-class" t-class="external-class"
label="店铺简介" label="店铺简介"
placeholder="设置最大字符个数" placeholder="设置最大字符个数"
maxlength="50" maxlength="50"
bindchange="onChangeShopIntro"
disableDefaultPadding="{{true}}" disableDefaultPadding="{{true}}"
indicator indicator
/> />
<!-- <view class="wrapper"> <view class="wrapper">
<view class="wrapper-title">店铺Logo</view> <view class="wrapper-title">店铺Logo</view>
<t-upload <t-upload
mediaType="{{['image']}}" mediaType="{{['image']}}"
max="{{1}}" max="{{1}}"
files="{{fileList}}" files="{{shopInfo.ShopLogo}}"
bind:add="handleAdd" bind:add="handleAddLogo"
bind:remove="handleRemove" bind:remove="handleRemoveLogo"
> >
</t-upload> </t-upload>
</view> --> </view>
<upload lable="店铺Logo" fileList="{{logo}}" ></upload> <view class="wrapper">
<view class="wrapper-title">营业执照</view>
<t-upload
mediaType="{{['image']}}"
max="{{1}}"
files="{{shopInfo.ShopBusinessLicense}}"
bind:add="handleAddShopBusinessLicense"
bind:remove="handleRemoveShopBusinessLicense"
>
</t-upload>
</view>
<!-- 提交按钮 --> <!-- 提交按钮 -->
<view class="sub-btn-pos-box"> <view class="sub-btn-pos-box">

View File

@ -4,10 +4,10 @@ import {
import { import {
getStorage getStorage
} from '~/utils/storage' } from '~/utils/storage'
const userData = getStorage('userInfo');
/** 获取个人中心信息 */ /** 获取个人中心信息 */
export function fetchUserCenter() { export function fetchUserCenter() {
const userData = getStorage('userInfo');
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
request({ request({
url: `CustomerApi/getCustomerDetails?CustomerGuid=` + userData?.customerGuid, url: `CustomerApi/getCustomerDetails?CustomerGuid=` + userData?.customerGuid,