kaiguan-zfb/page_components/peizhi.vue

615 lines
14 KiB
Vue
Raw Normal View History

<template>
<view class="page">
<u-navbar title="店铺配置" :border-bottom="false" :background="bgc" title-color='#fff' back-icon-color="#fff"
title-size='36' height='50'></u-navbar>
<view class="box">
<view class="list">
<view class="listval">
<view class="tit"> 营业时间</view>
<view class="but"
style="display: flex;justify-content: space-between;padding: 15rpx 26rpx;box-sizing: border-box;">
2024-11-11 18:01:14 +08:00
<!-- #ifdef MP-ALIPAY -->
<view class="" style="font-size: 28rpx;color: #666;padding-top: 10rpx;" @click="btnyinye(1)">{{ksyy}}</view>
--
<view class="" style="font-size: 28rpx;color: #666;padding-top: 10rpx;" @click="btnyinye(2)">{{jsyy}}</view>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<view class="" style="font-size: 28rpx;color: #666;" @click="btnyinye(1)">{{ksyy}}</view>
--
<view class="" style="font-size: 28rpx;color: #666;" @click="btnyinye(2)">{{jsyy}}</view>
2024-11-11 18:01:14 +08:00
<!-- #endif -->
</view>
</view>
2024-11-11 18:01:14 +08:00
<!-- #ifdef MP-ALIPAY -->
<view class="listval">
<view class="tit"> 是否展示店铺</view>
<switch checked color="#8883F0"/>
</view>
<view class="listval">
<view class="tit"> 是否允许在非营业时间使用</view>
<switch checkeds color="#8883F0"/>
</view>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<view class="listval">
<view class="tit"> 是否展示店铺</view>
<u-switch v-model="checked" active-color="#8883F0"></u-switch>
</view>
<view class="listval">
<view class="tit"> 是否允许在非营业时间使用</view>
<u-switch v-model="checkeds" active-color="#8883F0"></u-switch>
</view>
<!-- #endif -->
<view class="baocun" @click="btncreat">
配置
</view>
</view>
<!-- 店铺类型 -->
<u-select v-model="selectorshow" :list="selector" @confirm="btnselector"></u-select>
<!-- 选择省市区 -->
<u-picker v-model="regionshow" mode="region" @confirm="btnregions"></u-picker>
<!-- 营业时间 -->
<u-picker mode="time" v-model="show" default-time="00:00" :params="params" @confirm="btnyy"></u-picker>
<view v-if="btnmsk" style="width: 100%;height: 100vh;position: fixed;top: 0;left: 0;background-color: #000;opacity: .1;z-index: 999;"></view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
btnmsk:false,
checked:false,
params: {
hour: true,
minute: true,
},
show: false,
checkeds:false,
imglist: '',
token: '',
userImgs: '',
imgflag: true,
selectorshow: false,
selectortext: '请选择商铺类型',
selectorvalue: '',
regionshow: false,
regiontext: '请选择省市区',
regionvalue: '',
selector: [{
value: 1,
label: '商场'
},
{
value: 2,
label: '学校'
},
{
value: 3,
label: '娱乐场所'
},
{
value: 4,
label: '出租房'
},
{
value: 5,
label: '其他'
},
],
latitude: '请输入纬度',
longitude: '请输入经度',
shopname: '',
yetime: '',
lxname: '',
lxphone: '',
xqdz: '',
ksyy: '开始营业时间',
jsyy: '结束营业时间',
yynum: 0,
province: '',
city: '',
area: '',
listobj: {},
storeId: '',
url:'',
jtdz:''
}
},
onLoad(option) {
let obj = JSON.parse(option.obj)
this.listobj = obj
console.log(this.listobj);
this.shopname = this.listobj.name
this.ksyy = this.listobj.businessTimeStart
this.jsyy = this.listobj.businessTimeEnd
this.regiontext = this.listobj.province + this.listobj.city + this.listobj.county
this.lxname = this.listobj.contactName
this.lxphone = this.listobj.contactMobile
this.latitude = this.listobj.lat
this.longitude = this.listobj.lng
this.xqdz = this.listobj.address
this.selectorvalue = this.listobj.type
this.imglist = this.listobj.picture
this.province = this.listobj.province
this.city = this.listobj.city
this.area = this.listobj.county
this.storeId = this.listobj.storeId
this.checked = this.listobj.show
this.checkeds = this.listobj.useOutTime
if (this.selectorvalue == 1) {
this.selectortext = '商场'
this.updateTime = this.listobj.updateTime
} else if (this.selectorvalue == 2) {
this.selectortext = '学校'
} else if (this.selectorvalue == 3) {
this.selectortext = '娱乐场所'
} else if (this.selectorvalue == 4) {
this.selectortext = '出租房'
} else {
this.selectortext = '其他'
}
this.getQiniuToken()
},
// 分享到好友(会话)
onShareAppMessage: function () {
return {
title: '创想物联',
path: '/pages/shouye/index'
}
},
// 分享到朋友圈
onShareTimeline: function () {
return {
title: '创想物联',
query: '',
path: '/pages/shouye/index'
}
},
methods: {
getImage() {
uni.chooseImage({
count: 1,
success: (rst) => {
this.url = rst.tempFilePaths[0];
}
})
},
onok(ev) {
this.url = "";
this.path = ev.path;
let _this = this
let math = 'static/' + _this.$u.guid(20)
wx.uploadFile({
url: 'https://up-z2.qiniup.com',
name: 'file',
filePath: _this.path,
formData: {
token: _this.token, //后端返回的token
key: 'smartmeter/img/' + math
},
success: function(res) {
let str = JSON.parse(res.data)
_this.userImgs = 'https://api.ccttiot.com/' + str.key
_this.imglist = _this.userImgs
_this.imgflag = false
}
})
},
oncancel() {
// url设置为空隐藏控件
this.url = ""
},
btnyinye(num) {
this.show = true
this.yynum = num
},
btnyy(e) {
if (this.yynum == 1) {
this.ksyy = e.hour + ':' + e.minute
} else {
this.jsyy = e.hour + ':' + e.minute
}
},
btncreat(){
let data = {
storeId:this.storeId,
businessTimeStart: this.ksyy,
businessTimeEnd: this.jsyy,
show:this.checked,
useOutTime:this.checkeds
}
this.$u.put("/app/store/config", data).then(res => {
if(res.code == 200){
uni.showToast({
title: '配置成功',
icon: 'success',
duration: 1000
})
setTimeout(() => {
this.btnmsk = false
uni.navigateBack({
delta: 2
})
}, 1000)
}else{
uni.showToast({
title: res.msg,
icon: 'success',
duration: 1000
})
}
})
},
// btncreat() {
// let phoneRegex = /^1[3-9]\d{9}$/ //判断手机号码格式
// if (this.shopname == '') {
// uni.showToast({
// title: '请输入店铺名称',
// icon: 'none',
// duration: 1000
// })
// } else if (this.selectortext == '请选择商铺类型') {
// uni.showToast({
// title: '请选择商铺类型',
// icon: 'none',
// duration: 1000
// })
// } else if (this.ksyy == '开始营业时间') {
// uni.showToast({
// title: '请选择开始营业时间',
// icon: 'none',
// duration: 2000
// })
// } else if (this.jsyy == '结束营业时间') {
// uni.showToast({
// title: '请选择结束营业时间',
// icon: 'none',
// duration: 2000
// })
// } else if (this.lxname == '') {
// uni.showToast({
// title: '请输入联系人',
// icon: 'none',
// duration: 1000
// })
// } else if (this.lxphone == '') {
// uni.showToast({
// title: '请输入联系电话',
// icon: 'none',
// duration: 1000
// })
// }else if (this.longitude == '请输入经度') {
// uni.showToast({
// title: '请点击地图图标选择地址',
// icon: 'none',
// duration: 1000
// })
// } else if (this.xqdz == '') {
// uni.showToast({
// title: '请输入详细地址',
// icon: 'none',
// duration: 1000
// })
// } else if (this.imglist == '') {
// uni.showToast({
// title: '请上传一张商铺门面照',
// icon: 'none',
// duration: 1000
// })
// } else {
// this.btnmsk = true
// let data = {
// name: this.shopname,
// picture: this.imglist,
// address: this.xqdz,
// lng: this.longitude,
// lat: this.latitude,
// businessTimeStart: this.ksyy,
// businessTimeEnd: this.jsyy,
// province: this.province,
// city: this.city,
// county: this.area,
// specificAddress: this.jtdz,
// contactName: this.lxname,
// contactMobile: this.lxphone,
// type: this.selectorvalue,
// storeId: this.storeId,
// show:this.checked,
// useOutTime:this.checkeds
// }
// this.$u.put("/app/store", data).then(res => {
// if (res.code == 500) {
// uni.showToast({
// title: res.msg,
// icon: 'success',
// duration: 1000
// })
// this.btnmsk = false
// } else {
// uni.showToast({
// title: '提交修改成功',
// icon: 'success',
// duration: 1000
// })
// setTimeout(() => {
// this.btnmsk = false
// uni.navigateBack({
// delta: 2
// })
// }, 1000)
// }
// })
// }
// },
btnlx() {
this.selectorshow = true
},
btnselector(e) {
this.selectorvalue = e[0].value
this.selectortext = e[0].label
},
btnregion() {
this.regionshow = true
},
btnregions(e) {
this.regiontext = e.province.label + e.city.label + e.area.label
this.province = e.province.label
this.city = e.city.label
this.area = e.area.label
},
btnjwd() {
uni.chooseLocation({
success: (res) => {
this.latitude = res.latitude;
this.longitude = res.longitude;
this.xqdz = res.name
this.jtdz = res.address
},
fail: function(err) {
console.log('选择位置失败', err);
},
complete: (res) => {
if (res.errMsg === 'chooseLocation:ok') {} else if (res.errMsg.indexOf(
'chooseLocation:cancel') === 0) {
uni.showToast({
title: '您取消了位置选择',
icon: 'none'
});
}
}
})
},
getQiniuToken() {
this.$u.get("/common/qiniu/uploadInfo").then((res) => {
if (res.code == 200) {
this.token = res.token
}
})
},
btn() {
let _this = this
let math = 'static/' + _this.$u.guid(20)
uni.chooseImage({
count: 1,
type: 'all',
success(res) {
const tempFilePaths = res.tempFiles
wx.uploadFile({
url: 'https://up-z2.qiniup.com',
name: 'file',
filePath: tempFilePaths[0].path,
formData: {
token: _this.token, //后端返回的token
key: 'smartmeter/img/' + math
},
success: function(res) {
let str = JSON.parse(res.data)
console.log(str.key)
_this.userImgs = 'https://api.ccttiot.com/' + str.key
_this.imglist = _this.userImgs
_this.imgflag = false
}
})
}
})
},
}
}
</script>
<style lang="scss">
/deep/ .panel{
position: fixed;
width: 100%;
height: 100%;
top: 0;
bottom: 0;
left: 0;
z-index: 99 !important;
overflow: hidden;
}
/deep/ .u-title {
padding-bottom: 22rpx;
}
/deep/ .u-icon__icon {
padding-bottom: 22rpx;
}
page {
background: linear-gradient(180deg, #8883F0 0%, rgba(255, 255, 255, 0) 100%);
}
.page {
width: 750rpx;
position: fixed;
top: 0;
left: 0;
color: #666;
.box {
width: 750rpx;
height: 1440rpx;
background: #F4F5F7;
border-radius: 0rpx 0rpx 0rpx 0rpx;
padding-top: 40rpx;
.list {
width: 680rpx;
height: 400rpx;
background: #FFFFFF;
border-radius: 24rpx 24rpx 24rpx 24rpx;
margin: auto;
padding-top: 44rpx;
padding-left: 38rpx;
padding-right: 38rpx;
box-sizing: border-box;
.baocun {
width: 584rpx;
height: 90rpx;
background: linear-gradient(90deg, #8883F0 0%, #A29EFF 100%);
border-radius: 54rpx 54rpx 54rpx 54rpx;
margin: auto;
text-align: center;
line-height: 90rpx;
position: fixed;
left: 50%;
transform: translateX(-50%);
bottom: 60rpx;
font-weight: 500;
font-size: 40rpx;
color: #FFFFFF;
}
.icon {
display: flex;
flex-wrap: wrap;
align-items: center;
margin-top: 40rpx;
width: 680rpx;
.list_box {
width: 100%;
display: flex;
justify-content: space-between;
padding-right: 45rpx;
.lt {
padding-top: 40rpx;
.tit {
font-size: 32rpx;
color: #3D3D3D;
}
.wz {
font-size: 26rpx;
color: #3D3D3D;
margin-top: 20rpx;
}
}
.imgbox {
width: 33%;
image {
width: 142rpx;
height: 142rpx;
}
}
}
}
.jinwei {
display: flex;
justify-content: space-between;
margin-top: 34rpx;
.tit {
margin-top: 10rpx;
font-size: 32rpx;
color: #3D3D3D;
}
.but {
width: 462rpx;
height: 70rpx;
background: #F0F0F0;
border-radius: 12rpx 12rpx 12rpx 12rpx;
position: relative;
input {
height: 70rpx;
line-height: 70rpx;
padding-left: 22rpx;
padding-right: 72rpx;
}
}
}
.listvals {
display: flex;
justify-content: space-between;
margin-top: 34rpx;
.tit {
margin-top: 12rpx;
font-size: 32rpx;
color: #3D3D3D;
}
.but {
width: 462rpx;
height: 70rpx;
background: #F0F0F0;
border-radius: 12rpx 12rpx 12rpx 12rpx;
position: relative;
input {
height: 70rpx;
line-height: 70rpx;
padding-left: 22rpx;
}
}
}
.listval {
display: flex;
justify-content: space-between;
margin-top: 34rpx;
.tit {
margin-top: 12rpx;
font-size: 32rpx;
color: #3D3D3D;
}
.but {
width: 462rpx;
height: 70rpx;
background: #F0F0F0;
border-radius: 12rpx 12rpx 12rpx 12rpx;
input {
height: 70rpx;
line-height: 70rpx;
padding-left: 22rpx;
}
}
}
}
}
}
</style>