代码更新
This commit is contained in:
@@ -13,13 +13,6 @@
|
||||
<uni-easyinput paddingNone :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||
v-model="userForm.phone" placeholder="填写号码" />
|
||||
</uni-forms-item>
|
||||
<!-- <uni-forms-item label="生日" required name="birthday">
|
||||
<uni-easyinput paddingNone :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="userForm.birthday" placeholder="选择日期" />
|
||||
|
||||
|
||||
</uni-forms-item> -->
|
||||
|
||||
<uni-forms-item label="生日" required >
|
||||
<view style="display: none;">
|
||||
<uni-easyinput paddingNone :inputBorder="inputBorder" v-model="userForm.birthDay"
|
||||
@@ -47,9 +40,6 @@
|
||||
</radio-group>
|
||||
</uni-forms-item>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <uni-forms-item label="用户余额" required name="balance">
|
||||
<uni-easyinput paddingNone :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||
v-model="userForm.balance" placeholder="填写余额" />
|
||||
@@ -80,28 +70,13 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onLoad, onReady } from '@dcloudio/uni-app';
|
||||
import { reactive, nextTick, ref } from 'vue';
|
||||
import go from '@/commons/utils/go.js';
|
||||
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 { shopUserAdd, shopUserPut } from '@/api/shopUser.js';
|
||||
|
||||
|
||||
|
||||
import {
|
||||
onLoad,
|
||||
onReady
|
||||
} from '@dcloudio/uni-app';
|
||||
import {
|
||||
onMounted,
|
||||
reactive,
|
||||
nextTick,
|
||||
ref,
|
||||
onBeforeMount
|
||||
} from 'vue';
|
||||
// 表单样式
|
||||
const placeholderStyle = ref('font-size:28rpx;')
|
||||
const paddingNone = true
|
||||
@@ -112,6 +87,21 @@
|
||||
const props = defineProps({
|
||||
item:{type:''}
|
||||
})
|
||||
|
||||
const startDate = getDate('start')
|
||||
let date = getDate()
|
||||
const endDate = getDate('end')
|
||||
|
||||
let userForm = reactive({
|
||||
nickName: '',
|
||||
phone: '',
|
||||
birthDay: '',
|
||||
balance: '',
|
||||
integral: '',
|
||||
isVip: true,
|
||||
level: 1,
|
||||
sex: 1
|
||||
})
|
||||
//表单验证
|
||||
const rules = {
|
||||
nickName: {
|
||||
@@ -137,21 +127,86 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const option = reactive({
|
||||
type: 'add'
|
||||
})
|
||||
onReady(() => {
|
||||
form.value.setRules(rules)
|
||||
})
|
||||
onLoad(params => {
|
||||
if (params.id) {
|
||||
let items = params
|
||||
uni.setNavigationBarTitle({
|
||||
title: '编辑用户'
|
||||
})
|
||||
userForm.nickName=items.nickName
|
||||
userForm.birthDay=items.birthDay
|
||||
userForm.id=items.id
|
||||
userForm.phone = items.phone
|
||||
userForm.sex = items.sex
|
||||
option.type = 'edit'
|
||||
} else {
|
||||
uni.setNavigationBarTitle({
|
||||
title: '新增用户'
|
||||
})
|
||||
option.type = 'add'
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 生日监听
|
||||
* @param {Object} e
|
||||
*/
|
||||
function bindDateChange(e) {
|
||||
userForm.birthDay = e.detail.value
|
||||
}
|
||||
|
||||
/**
|
||||
* 性别监听
|
||||
* @param {Object} e
|
||||
* @param {Object} name
|
||||
*/
|
||||
function sizeChange(e, name) {
|
||||
userForm[name] = e.detail.value
|
||||
}
|
||||
|
||||
const startDate = getDate('start')
|
||||
let date = getDate()
|
||||
const endDate = getDate('end')
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
function save() {
|
||||
form.value.validate().then(async res => {
|
||||
let obj = {
|
||||
...userForm,
|
||||
name: userForm.nickName,
|
||||
telephone: userForm.phone,
|
||||
birthday:userForm.birthDay,
|
||||
status:1,
|
||||
levelConsume:0,
|
||||
sex:userForm.sex==1?1:2
|
||||
}
|
||||
if (res) {
|
||||
if (option.type == 'add') {
|
||||
const ele = await shopUserAdd(obj)
|
||||
} else {
|
||||
const ele = await shopUserPut(obj)
|
||||
}
|
||||
go.back()
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期格式化
|
||||
* @param {Object} type
|
||||
*/
|
||||
function getDate(type) {
|
||||
const date = new Date();
|
||||
let year = date.getFullYear();
|
||||
let month = date.getMonth() + 1;
|
||||
let day = date.getDate();
|
||||
|
||||
|
||||
if (type === 'start') {
|
||||
year = year - 60;
|
||||
} else if (type === 'end') {
|
||||
@@ -163,95 +218,6 @@
|
||||
day = day > 9 ? day : '0' + day;
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
|
||||
|
||||
function bindDateChange(e) {
|
||||
console.log(e);
|
||||
userForm.birthDay = e.detail.value
|
||||
}
|
||||
|
||||
function onFieldChange(e) {
|
||||
console.log(e);
|
||||
}
|
||||
// 用户表单
|
||||
let userForm = reactive({
|
||||
nickName: '',
|
||||
phone: '',
|
||||
birthDay: '',
|
||||
balance: '',
|
||||
integral: '',
|
||||
isVip: true,
|
||||
level: 1,
|
||||
sex: 1
|
||||
})
|
||||
|
||||
|
||||
function triggerEvent(emitName, data) {
|
||||
if (emitName) {
|
||||
uni.$emit(emitName, data)
|
||||
}
|
||||
}
|
||||
const option = reactive({
|
||||
type: 'add'
|
||||
})
|
||||
|
||||
function isEmpty(obj) {
|
||||
return obj && JSON.stringify(obj) !== '{}'
|
||||
}
|
||||
|
||||
|
||||
|
||||
onLoad(params => {
|
||||
if (params.id) {
|
||||
let items = params
|
||||
uni.setNavigationBarTitle({
|
||||
title: '编辑用户'
|
||||
})
|
||||
// userForm = items
|
||||
userForm.nickName=items.nickName
|
||||
userForm.birthDay=items.birthDay
|
||||
userForm.id=items.id
|
||||
userForm.phone = items.telephone
|
||||
userForm.sex = items.sex == '男' ? 1 : 2
|
||||
option.type = 'edit'
|
||||
console.log(userForm,'调试111')
|
||||
} else {
|
||||
uni.setNavigationBarTitle({
|
||||
title: '新增用户'
|
||||
})
|
||||
option.type = 'add'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
function sizeChange(e, name) {
|
||||
userForm[name] = e.detail.value
|
||||
}
|
||||
|
||||
|
||||
function save() {
|
||||
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"),
|
||||
sex:userForm.sex==1?1:2
|
||||
}
|
||||
if (res) {
|
||||
if (option.type == 'add') {
|
||||
const ele = await member(obj)
|
||||
} else {
|
||||
const ele = await tbShopUser(obj)
|
||||
}
|
||||
go.back()
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
page {
|
||||
|
||||
Reference in New Issue
Block a user