Commit 2d5a4f8d authored by Facius's avatar Facius

feat: 创建订单前店铺检查

parent 07da82e6
Pipeline #3948 canceled with stages
import request from "@/utils/request.js" import request from "@/utils/request.js"
export function getShopInfo() { export async function getShopInfo() {
return request({ return request({
url: `/rest/user/shop`, url: `/rest/user/shop`,
method: 'GET', method: 'GET',
}) })
} }
export function updateShopInfo(data) { export async function updateShopInfo(data) {
return request({ return request({
url: `/rest/user/shop`, url: `/rest/user/shop`,
method: 'POST', method: 'POST',
......
...@@ -29,28 +29,32 @@ ...@@ -29,28 +29,32 @@
</scroll-view> </scroll-view>
<!-- #endif --> <!-- #endif -->
</view> </view>
<!-- <submit-button @handleClick="submit" text="下一步"></submit-button> -->
<view class="bottom-view"> <view class="bottom-view">
<u-button type="success" :custom-style="customCreate" @click="submit"> <u-button type="success" :loading="loading" :custom-style="customCreate" @click="handleClickSubmit">
<view class="create-view">下一步</view> <view class="create-view">下一步</view>
</u-button> </u-button>
</view> </view>
<PopShop :visible.sync="showPop" :info="info" @cancel="handleClickCancel" @confirm="handleClickConfirm"/>
</view> </view>
</template> </template>
<script> <script>
import NavbarRight from '@/components/navbar-right'; import NavbarRight from '@/components/navbar-right';
// import SubmitButton from '@/components/submit-button/index.vue'; import PopShop from './components/pop-shop.vue';
import { billBaseUrl,mineBaseUrl } from '@/utils/config.js'; import { billBaseUrl,mineBaseUrl } from '@/utils/config.js';
import { setMaintainBillType, getMaintainBillType } from '@/utils/common.js'; import { setMaintainBillType, getMaintainBillType } from '@/utils/common.js';
import {reportEvent} from '@/api/bill/index.js' import {reportEvent} from '@/api/bill/index.js'
import {getShopInfo,updateShopInfo} from "@/api/mine/shop.js"
export default { export default {
components: { components: {
NavbarRight, NavbarRight,
// SubmitButton PopShop
}, },
data() { data() {
return { return {
showPop: false,
loading: false,
backText:'收据记账', backText:'收据记账',
rightImage:mineBaseUrl+'dianpushezhi@3x.png', rightImage:mineBaseUrl+'dianpushezhi@3x.png',
previewIcon: billBaseUrl + 'yulanicon@3x.png', previewIcon: billBaseUrl + 'yulanicon@3x.png',
...@@ -93,10 +97,13 @@ export default { ...@@ -93,10 +97,13 @@ export default {
'border-radius': '16rpx', 'border-radius': '16rpx',
width: '686rpx' width: '686rpx'
}, },
}; info: {},
infoKeys: ['name','address','phone','lister']
}
}, },
onReady() { onReady() {
this.type = getMaintainBillType() || 'receipt'; this.type = getMaintainBillType() || 'receipt';
this.getShopInfo()
}, },
methods: { methods: {
handleClick(item) { handleClick(item) {
...@@ -115,6 +122,14 @@ export default { ...@@ -115,6 +122,14 @@ export default {
} }
}); });
}, },
handleClickSubmit() {
this.loading = true
if (!this.checkValue()) {
this.showPop = true
} else {
this.submit()
}
},
submit() { submit() {
setMaintainBillType(this.type) setMaintainBillType(this.type)
if (this.type == 'collection') { if (this.type == 'collection') {
...@@ -128,15 +143,52 @@ export default { ...@@ -128,15 +143,52 @@ export default {
url: `/pages/maintain-bill/create?type=${this.type}` url: `/pages/maintain-bill/create?type=${this.type}`
}); });
} }
this.loading = false
// #ifdef MP-WEIXIN
// 上报选择类型 // 上报选择类型
reportEvent(`selected_bill_${this.type}_type`); reportEvent(`selected_bill_${this.type}_type`);
// #endif
}, },
handlClickRight() { handlClickRight() {
this.$u.route({ this.$u.route({
url: '/pages/mine/shop-setting/shop-setting', url: '/pages/mine/shop-setting/shop-setting',
params: {} params: {}
}); });
},
getShopInfo() {
getShopInfo({})
.then(res => {
this.info = res.data || {}
})
.catch(err => {
console.log(err);
});
},
updateShopInfo(info) {
updateShopInfo(info)
.then(res => {
this.info = res.data || {}
this.submit()
})
.catch(err => {
this.loading = false
console.log(err);
});
},
handleClickConfirm(info) {
this.info = info
this.updateShopInfo(info)
},
handleClickCancel() {
this.submit()
},
checkValue () {
for (var item of this.infoKeys) {
if (!this.info[item]) return false
} }
return true
},
} }
}; };
</script> </script>
......
<template>
<u-popup v-model="show" safe-area-inset-bottom border-radius="24" mode="center" width="86%" :closeable="false"
@close="handleClose" :mask-close-able="false">
<view class="pop-shop">
<view class="title-view">完善店铺信息</view>
<view class="tip-view">为了更好的体验,请先完善以下信息:</view>
<view class="content-view">
<view class="part-view" v-for="(item, key) in infoKeys" :key="key" hover-class="u-hover-class"
@click="handleClick(key)">
<view class="label-view">{{ item.name }}</view>
<view class="value-view">
<view v-if="shopInfo[key]">{{ key == 'phone' ? showText(shopInfo[key]) : shopInfo[key] }}</view>
<view class="no-value" v-else>{{ shopInfo[key] || item.placeholder }}</view>
<u-icon class="icon-view" name="arrow-right" color="#CCCCCC" size="24"></u-icon>
</view>
</view>
</view>
<view class="bottom-view">
<view class="left-view">
<u-button :custom-style="customCancel" @click="handleClickCancel">
<view class="cancel-view">下次完善</view>
</u-button>
</view>
<view class="right-view">
<u-button :loading="loading" :type="customConFirm.type" :custom-style="customConFirm"
@click="handleClickConfirm">
<view class="confirm-view">保存</view>
</u-button>
</view>
</view>
</view>
</u-popup>
</template>
<script>
export default {
props: {
visible: {
type: Boolean,
default: false,
},
info: {
type: Object,
default () {
return {}
}
}
},
data () {
return {
show: false,
shopInfo: {}
}
},
computed: {
infoKeys () {
return {
name: {
name: "店铺名称",
placeholder: '填写店铺名称20字以内',
},
address: {
name: '店铺地址',
placeholder: '填写店铺地址信息',
},
phone: {
name: '联系电话',
placeholder: '填写联系电话',
},
lister: {
name: '收款人',
placeholder: '填写收款人',
},
}
},
customCancel () {
return {
color: 'transparent',
height: '96rpx',
width: '264rpx',
border: '2rpx solid #8D8D8D',
'border-radius': '16rpx',
}
},
customConFirm () {
return {
type: 'success',
color: 'transparent',
'background-color': '#02A074',
height: '96rpx',
width: '264rpx',
}
},
},
watch: {
visible (val) {
this.show = val
this.loading = false
if (val) {
this.shopInfo = {...this.info}
}
},
},
methods: {
handleClick (key) {
let type = `pop-shop-${key}`
this.$u.route({
url: '/pages/mine/input/input',
params: {
type: type,
value: this.shopInfo[key],
}
});
uni.$once(`input-sure-${type}`, res => {
this.shopInfo[key] = res.content
});
},
handleClickConfirm () {
if (!this.checkValue()) {
return
}
this.loading = true
this.changeVisibleValue(false)
this.$emit('confirm', { ...this.shopInfo })
},
checkValue () {
for (var item in this.infoKeys) {
if (!this.shopInfo[item]) return false
}
return true
},
handleClickCancel () {
this.changeVisibleValue(false)
this.$emit('cancel')
},
changeVisibleValue (val) {
this.show = val
this.$emit('update:visible', val)
},
handleClose () {
this.changeVisibleValue(false)
},
showText(string) {
var mobile = string? (string.substring(0, 3) + ' ' + string.substring(3, 7) + ' ' + string.substring(7, 11)) : ''
return mobile
}
},
}
</script>
<style lang="scss" scoped>
.pop-shop {
text-align: center;
padding: 24rpx 32rpx;
background-image: linear-gradient(to bottom, #f4fffc 0%, #ffffff 50%);
.title-view {
color: #333333;
font-weight: bold;
font-size: 40rpx;
margin: 32rpx 0 24rpx 0;
}
.tip-view {
color: #8D8D8D;
font-size: 28rpx;
text-align: left;
margin-bottom: 24rpx;
}
.content-view {
margin-bottom: 32rpx;
.part-view {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 28rpx;
color: #333333;
padding: 20rpx 0;
.label-view {
height: 70rpx;
line-height: 70rpx;
}
.value-view {
display: flex;
align-items: center;
justify-content: flex-end;
height: 70rpx;
line-height: 70rpx;
font-weight: bold;
.no-value {
color: #CCCCCC,
}
.icon-view {
margin-left: 16rpx;
}
}
}
}
.bottom-view {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16rpx;
.left-view {
.cancel-view {
color: #8D8D8D;
height: 96rpx;
line-height: 96rpx;
font-weight: bold;
font-size: 32rpx;
display: flex;
justify-content: center;
align-items: center;
}
}
.right-view {
margin-left: 30rpx;
.confirm-view {
color: #ffffff;
height: 96rpx;
line-height: 96rpx;
font-weight: bold;
font-size: 32rpx;
}
}
}
}
</style>
...@@ -187,6 +187,42 @@ export default { ...@@ -187,6 +187,42 @@ export default {
height: 240, height: 240,
empty: true empty: true
}; };
case 'pop-shop-name':
return {
title: '店铺名称',
type: 'textarea',
placeholder: '填写店铺名称20字以内',
maxlength: 20,
height: 240,
empty: true
};
case 'pop-shop-address':
return {
title: '店铺地址',
type: 'textarea',
placeholder: '填写店铺地址信息',
maxlength: 30,
height: 240,
empty: true
};
case 'pop-shop-phone':
return {
title: '联系电话',
type: 'number',
placeholder: '填写联系电话',
maxlength: 11,
height: 240,
empty: true
};
case 'pop-shop-phone':
return {
title: '收款人',
type: 'textarea',
placeholder: '填写收款人',
maxlength: 10,
height: 240,
empty: true
};
} }
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment