feat 添加申请开店

This commit is contained in:
lwh 2023-06-15 15:16:42 +08:00
parent ae7383d5b8
commit 6ad52eb2c6
8 changed files with 171 additions and 17 deletions

View File

@ -1,4 +1,5 @@
// components/upload/index.js
import { ServerBasePath } from '~/services/_utils/request'
Component({
/**
* 组件的属性列表
@ -39,8 +40,10 @@ Component({
// this.triggerEvent('customEvent', dataToPass); // 触发自定义事件,并传递值
// },
handleAdd(e) {
console.log(111);
const {
fileList
@ -73,7 +76,7 @@ Component({
} = fileList;
const task = wx.uploadFile({
url: 'http://192.168.1.102:8888/api/Common/UploadFile', // 仅为示例,非真实的接口地址
url: ServerBasePath + '/Common/UploadFile', // 仅为示例,非真实的接口地址
filePath: file.url,
name: 'file',
formData: {

View File

@ -1,10 +1,24 @@
// pages/usercenter/apply-shop/index.js
import {
ServerBasePath
} from '~/services/_utils/request'
import {
getFirstGoodsCategoryList
} from '~/services/usercenter/apply-shop/getFirstGoodsCategoryList'
import {
addOrUpdateShop
} from '~/services/usercenter/apply-shop/addOrUpdateShop'
import Toast from 'tdesign-miniprogram/toast/index';
Page({
/**
* 页面的初始数据
*/
data: {
shopBusinessCategoryText: '',
shopBusinessCategoryVisible: false,
shopBusinessCategoryList: [],
shopInfo: {
ShopBusinessCategoryGuid: "",
ShopName: "",
@ -17,11 +31,91 @@ Page({
// 提交
submit() {
console.log(this.data.shopInfo);
let data = this.data.shopInfo
data.ShopBusinessCategoryGuid = data.ShopBusinessCategoryGuid[0]
data.ShopLogo = data.ShopLogo.map(item => item.url).join(',')
data.ShopBusinessLicense = data.ShopBusinessLicense.map(item => item.url).join(',')
console.log(data);
addOrUpdateShop(data).then((res) => {
if (res.code === 200) {
Toast({
context: this,
selector: '#t-toast',
message: res.data,
theme: 'success',
})
this.setData({
shopInfo: null
})
// 返回上一页
setTimeout(() => {
const pages = getCurrentPages(); //获取小程序页面栈
const beforePage = pages[pages.length - 1]; //获取上个页面的实例对象 -2是上上一个页面
wx.navigateBack({
delta: 1,
});
beforePage.onLoad();
}, 1000);
} else {
Toast({
context: this,
selector: '#t-toast',
message: res.Msg,
theme: 'error',
})
}
})
},
init() {
// 获取经营类目
getFirstGoodsCategoryList().then((res) => {
this.setData({
shopBusinessCategoryList: res.data
})
})
},
onLoad(options) {
this.init()
},
// 选项切换
onColumnChange(e) {},
// 选中
onPickerChange(e) {
const {
key
} = e.currentTarget.dataset;
const {
value,
label
} = e.detail;
this.setData({
[`${key}Visible`]: false,
[`shopInfo.ShopBusinessCategoryGuid`]: value,
[`${key}Text`]: label.join(' '),
});
},
// 选项取消
onPickerCancel(e) {
const {
key
} = e.currentTarget.dataset;
this.setData({
[`${key}Visible`]: false,
});
},
// 选择经营类目
onshopBusinessCategoryPicker() {
this.setData({
shopBusinessCategoryVisible: true
});
},
onChangeShopName(e) {
@ -80,7 +174,7 @@ Page({
const {
ShopBusinessLicense
} = this.data.shopInfo;
ShopBusinessLicense.splice(index, 1);
this.setData({
"shopInfo.ShopBusinessLicense": ShopBusinessLicense,
@ -105,7 +199,7 @@ Page({
} = ShopLogo;
const task = wx.uploadFile({
url: 'http://192.168.1.102:8888/api/Common/UploadFile', // 仅为示例,非真实的接口地址
url: ServerBasePath + 'Common/UploadFile', // 仅为示例,非真实的接口地址
filePath: file.url,
name: 'file',
formData: {
@ -144,7 +238,7 @@ Page({
} = ShopBusinessLicense;
const task = wx.uploadFile({
url: 'http://192.168.1.102:8888/api/Common/UploadFile', // 仅为示例,非真实的接口地址
url: ServerBasePath + 'Common/UploadFile', // 仅为示例,非真实的接口地址
filePath: file.url,
name: 'file',
formData: {
@ -174,12 +268,6 @@ Page({
// // });
// },
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成

View File

@ -4,7 +4,12 @@
"t-textarea": "tdesign-miniprogram/textarea/textarea",
"t-button": "tdesign-miniprogram/button/button",
"t-upload": "tdesign-miniprogram/upload/upload",
"van-button": "@vant/weapp/button/index"
"van-button": "@vant/weapp/button/index",
"t-picker": "tdesign-miniprogram/picker/picker",
"t-picker-item": "tdesign-miniprogram/picker-item/picker-item",
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
"t-cell": "tdesign-miniprogram/cell/cell",
"t-toast": "tdesign-miniprogram/toast/toast"
},
"navigationBarTitleText": "申请开店"
}

View File

@ -2,7 +2,7 @@
<view class="apply-shop-container">
<t-input value="{{shopInfo.ShopBusinessCategoryGuid}}" label="经营类目" maxlength="10" placeholder="请输入店铺名称" align="right" />
<t-cell class="mb-16" title="经营类目" arrow hover note="{{shopBusinessCategoryText}}" bind:click="onshopBusinessCategoryPicker" />
<t-input value="{{shopInfo.ShopName}}" bindchange="onChangeShopName" label="店铺名称" maxlength="10" placeholder="请输入店铺名称" align="right" />
<t-textarea
value="{{shopInfo.ShopIntro}}"
@ -47,3 +47,19 @@
</view>
</view>
<t-picker
visible="{{shopBusinessCategoryVisible}}"
value="{{shopInfo.ShopBusinessCategoryGuid}}"
data-key="shopBusinessCategory"
title="经营类目"
cancelBtn="取消"
confirmBtn="确认"
bindchange="onPickerChange"
bindpick="onColumnChange"
bindcancel="onPickerCancel"
>
<t-picker-item options="{{shopBusinessCategoryList}}"></t-picker-item>
</t-picker>
<t-toast id="t-toast" />

View File

@ -8,6 +8,7 @@ import {
phoneEncryption
} from '~/utils/util';
import Toast from 'tdesign-miniprogram/toast/index';
import { ServerBasePath } from '~/services/_utils/request'
Page({
data: {
@ -150,7 +151,7 @@ Page({
let tempFilePath = tempFilePaths[0];
// 上传图片到服务器
wx.uploadFile({
url: 'http://192.168.1.102:8888/api/Common/UploadFile', // 上传接口地址
url: ServerBasePath + 'Common/UploadFile', // 上传接口地址
filePath: tempFilePath, // 要上传的文件的临时路径
name: 'file', // 上传文件对应的字段名
success: function (uploadRes) {

View File

@ -3,7 +3,7 @@ import {
getStorage
} from '~/utils/storage'
const ServerBasePath = 'http://192.168.1.102:8888/api/';
export const ServerBasePath = 'http://localhost:8888/api/';
// 网络请求封装
export function request(option) {

View File

@ -0,0 +1,22 @@
import {
request
} from '~/services/_utils/request';
/** 提交店铺审核 */
export function addOrUpdateShop(data) {
return new Promise((resolve, reject) => {
request({
url: `ShopApi/addOrUpdateShop`,
method: 'POST',
data: data,
success: function (res) {
resolve(res);
},
fail: function (error) {
reject(error);
}
});
});
}

View File

@ -0,0 +1,19 @@
import {
request
} from '~/services/_utils/request';
/** 获取经营类目列表 */
export function getFirstGoodsCategoryList() {
return new Promise((resolve, reject) => {
request({
url: `ShopApi/getFirstGoodsCategoryList`,
method: 'GET',
success: function (res) {
resolve(res);
},
fail: function (error) {
reject(error);
}
});
});
}