diff --git a/http/yskApi/http.js b/http/yskApi/http.js index b4cdda3..db1a980 100644 --- a/http/yskApi/http.js +++ b/http/yskApi/http.js @@ -24,7 +24,8 @@ let baseUrl = 'https://pre-cashieradmin.sxczgkj.cn' // 王伟本地测 // let baseUrl = '/ww' // let baseUrl = 'http://192.168.1.15:8000' - + // 巩 + // let baseUrl = 'http://192.168.1.9:8000' // 多少 ms 以内, 不提示loading const loadingShowTime = 200 @@ -75,7 +76,6 @@ function commonsProcess(showLoading, httpReqCallback) { } = httpData // 避免混淆重新命名 let bodyData = data - console.log(statusCode,1111111111) if (statusCode == 500) { isShowErrorToast = true return Promise.reject(bodyData) // 跳转到catch函数 @@ -125,12 +125,18 @@ function commonsProcess(showLoading, httpReqCallback) { return Promise.resolve(bodyData) }).catch(res => { - if(res.status==401||res.status==400){ + if(res.status==401){ storageManage.token(null, true) infoBox.showErrorToast('请登录').then(() => { go.to("PAGES_LOGIN", {}, go.GO_TYPE_RELAUNCH) }) } + // if(res.status==400){ + // storageManage.token(null, true) + // infoBox.showErrorToast('').then(() => { + // go.to("PAGES_LOGIN", {}, go.GO_TYPE_RELAUNCH) + // }) + // } if(res.status==500){ storageManage.token(null, true) infoBox.showErrorToast('请登录').then(() => { diff --git a/http/yskApi/requestAll.js b/http/yskApi/requestAll.js index 54a2d5f..049300b 100644 --- a/http/yskApi/requestAll.js +++ b/http/yskApi/requestAll.js @@ -213,7 +213,24 @@ export function midfiyAccount(data) { } }) } - +// 新增会员 +export function member(data) { + return request({ + url: '/api/member', + method: 'post', + data: { + ...data + } + }) +} +// 修改会员 +export function tbShopUser(data) { + return request({ + url: `/api/tbShopUser`, + method: "put", + data + }); +} export function callTablecallRecord(params) { return request({ url: '/callTable/callRecord', diff --git a/pageUser/add-user/add-user.vue b/pageUser/add-user/add-user.vue index 3840b47..90bec2d 100644 --- a/pageUser/add-user/add-user.vue +++ b/pageUser/add-user/add-user.vue @@ -5,9 +5,9 @@ - + + v-model="userForm.nickName" placeholder="填写用户名" /> --> - + - - {{userForm.birthday||'选择日期'}} + {{userForm.birthDay||'选择日期'}} - + + + + + + + + + + + + - + @@ -67,6 +84,13 @@ import infoBox from '@/commons/utils/infoBox.js'; import mySwitch from '@/components/my-components/my-switch.vue' import myButton from '@/components/my-components/my-button.vue' + import { + member, + tbShopUser + } from '@/http/yskApi/requestAll.js'; + + + import { onLoad, onReady @@ -87,7 +111,7 @@ const bottom = ref(null) //表单验证 const rules = { - name: { + nickName: { rules: [{ required: true, errorMessage: '请填写用户名' @@ -140,20 +164,22 @@ function bindDateChange(e) { console.log(e); - userForm.birthday = e.detail.value + userForm.birthDay = e.detail.value } function onFieldChange(e) { console.log(e); } // 用户表单 - const userForm = reactive({ - name: '', + let userForm = reactive({ + nickName: '', phone: '', - birthday: '', + birthDay: '', balance: '', integral: '', isVip: false, + level: 1, + sex: 1 }) @@ -173,23 +199,48 @@ onLoad(params => { - - if (isEmpty(params)) { - option.type = params.type ? params.type : 'add' + if (params.item) { + let items = JSON.parse(params.item) + uni.setNavigationBarTitle({ + title: '编辑用户' + }) + items.phone = items.telephone + items.sex = items.sex == '男' ? 1 : 2 + userForm = items + option.type = 'edit' + } else { + uni.setNavigationBarTitle({ + title: '新增用户' + }) + option.type = 'add' } - console.log(option.type); - uni.setNavigationBarTitle({ - title: option.type === 'add' ? '添加用户' : '编辑用户' - }) }) - + function sizeChange(e, name) { + userForm[name] = e.detail.value + } function save() { - form.value.validate().then(res => { - console.log(res) + form.value.validate().then(async res => { + let obj = { + ...userForm, + name: userForm.nickName, + telephone: userForm.phone, + birthday:userForm.birthDay, + status:1, + levelConsume:0, + shopId: uni.getStorageSync("shopId"), + } + if (res) { + if (option.type == 'add') { + const ele = await member(obj) + } else { + const ele = await tbShopUser(obj) + } + go.back() + } }) } diff --git a/pageUser/index/index.vue b/pageUser/index/index.vue index dc31ab3..0b821c0 100644 --- a/pageUser/index/index.vue +++ b/pageUser/index/index.vue @@ -290,7 +290,6 @@ go.to('PAGES_USER_ADD') } let callTabletakeNumberEvent = async () => { - console.log(datas.form, '调试1') let res = await midfiyAccount({ id: datas.activeUser.id, ...datas.form @@ -334,9 +333,8 @@ } else if (i == 1) { hasPermission('允许管理会员信息').then(ele => { if (ele) { - toUrl('PAGES_SALES_WAREHOUSEENTRY', { - consId: actionSheet.activeId, - item: JSON.stringify(actionSheet.active) + go.to('PAGES_USER_ADD', { + item: JSON.stringify(datas.activeUser) }) } })