Commit 71e13af9 by chenwq

地图,车品牌,登陆页面样式

1 parent 2edf04b9
...@@ -93,5 +93,25 @@ class mineApi { ...@@ -93,5 +93,25 @@ class mineApi {
} }
) )
} }
/** 获取车品牌列表 */
getCarBrandList() {
return api.post({
method: 'scrm.api.busassistant.serviceCenter.getCarbrandTree'
})
}
/** 获取车系列表 */
getCarSeriesList(data) {
return api.post({
method: 'scrm.api.carlife.common.getCarSeriesList',
...data
})
}
/** 获取车型 */
getCarTypeList(carSeriesId) {
return api.post({
method: 'scrm.api.carlife.common.getCarTypeList',
carSeriesId
})
}
} }
export default mineApi export default mineApi
...@@ -96,6 +96,16 @@ const getReviewList = data => { ...@@ -96,6 +96,16 @@ const getReviewList = data => {
) )
} }
// 查询商户详情
const getMerchantInfo = data => {
return api.post(
{
method: 'scrm.api.busassistant.serviceCenter.merchantInfo',
...data
}
)
}
export default { export default {
getAllServiceList, getAllServiceList,
getServiceList, getServiceList,
...@@ -105,5 +115,6 @@ export default { ...@@ -105,5 +115,6 @@ export default {
addTechnician, addTechnician,
updateTechnician, updateTechnician,
deleteTechnician, deleteTechnician,
getReviewList getReviewList,
getMerchantInfo
} }
\ No newline at end of file \ No newline at end of file
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
"packagesList/activityDetail/activityDetail" "packagesList/activityDetail/activityDetail"
], ],
"requiredPrivateInfos": [ "requiredPrivateInfos": [
"getLocation" "getLocation",
"chooseLocation"
], ],
"lazyCodeLoading": "requiredComponents", "lazyCodeLoading": "requiredComponents",
"window": { "window": {
......
/* login/index/components/LoginBox.wxss */ /* login/index/components/LoginBox.wxss */
.wx { .wx {
height: 922rpx; // height: 922rpx;
height: 63vh;
.title { .title {
font-weight: 600; font-weight: 600;
font-size: 60rpx; font-size: 60rpx;
color: #323436; color: #323436;
padding: 216rpx 0 24rpx; // padding: 216rpx 0 24rpx;
padding: 13vh 0 24rpx;
} }
.subtitle { .subtitle {
...@@ -18,7 +20,7 @@ ...@@ -18,7 +20,7 @@
width: 378rpx; width: 378rpx;
height: 364rpx; height: 364rpx;
display: block; display: block;
margin: 0 auto; margin: 0 auto 40rpx;
} }
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
position: fixed; position: fixed;
width: 100%; width: 100%;
left: 0; left: 0;
bottom: 60rpx; bottom: 40rpx;
font-size: 24rpx; font-size: 24rpx;
color: #999; color: #999;
letter-spacing: 2rpx; letter-spacing: 2rpx;
......
// packageMine/components/CarBrand/CarBrand.js
import mineApi from '~/api/mineApi/index'
import Util from '~/utils/util'
Component({
/**
* 组件的属性列表
*/
properties: {
popupShow: {
type: Boolean,
value: false,
observer: function (n) {
if (n) {
this.getBrandList()
}
}
},
selectedList: {
type: Array,
value: []
}
},
/**
* 组件的初始数据
*/
data: {
selectingList: []
},
/**
* 组件的方法列表
*/
methods: {
dealSelectedList(brandList) {
return new Promise(resolve => {
let { selectedList } = this.data
selectedList.forEach((item, idx) => {
let brandIdx = brandList.findIndex(k => k.id == item.id)
let brandChildList = brandList[brandIdx].children
item.label = item.name
item.children.forEach((subItem, subIdx) => {
let cIdx = brandChildList.findIndex(k => k.id == subItem.id)
brandList[brandIdx].children[cIdx].active = true
subItem.active = true
subItem.label = subItem.name
})
})
this.setData({
selectingList: Util.deepClone(selectedList)
})
resolve(brandList)
})
},
getBrandList() {
let data = wx.$storage.get('car_brand_list')
if (data) {
this.dealSelectedList(Util.deepClone(data)).then(brandlist => {
this.formatData(brandlist)
})
} else {
mineApi.getCarBrandList().then(data => {
wx.$storage.set('car_brand_list', data)
this.dealSelectedList(Util.deepClone(data)).then(brandlist => {
this.formatData(brandlist)
})
})
}
},
formatData(data) {
let letterList = Array.from(new Set([...data.map(e => e.letter)]))
let brandList = letterList.map(e => {
let list = []
data.map(i => {
if (e === i.letter) {
list.push(i)
}
})
return {
letter: e,
list
}
})
this.setCarData(brandList)
},
setCarData(brandList) {
wx.$api.showLoading('加载中...')
let count = 0
let settime = setInterval(() => {
if (null != brandList[count].list && brandList[count].list.length > 0) {
this.setData({
[`brandList[${count}]`]: brandList[count]
})
}
count++
if (count >= brandList.length) {
clearInterval(settime)
this.getLetter()
}
}, 10)
},
getLetter() {
wx.hideLoading()
let { brandList, letter } = this.data
let arr = []
if (brandList.length > 0) {
brandList.forEach(e => {
arr.push(e.letter)
})
this.setData({
arr,
letter,
flag: true
})
}
setTimeout(() => {
this.getSideBarInfo()
}, 500)
},
getSideBarInfo() {
let _this = this
wx.$api.getViewInfo('#letter-A', res => {
wx.$api.getViewInfo('#side-bar', _res => {
_this.setData({
letterHeight: res.height,
toTop: res.height + _res.top,
height: _res.bottom
})
})
})
},
dealSelectList(index, pidx, cidx) {
let { selectingList } = this.data
let pItem = Util.deepClone(this.data.brandList[index].list[pidx])
// 已选列表中,当前选中的品牌是否存在
let selectPItemId = selectingList.findIndex(item => item.id == pItem.id)
// 不存在该品牌,插入;存在该品牌,替换
if (selectPItemId == -1) {
selectingList.push(pItem)
this.setData({
selectingList
})
return true
}
this.setData({
[`selectingList[${selectPItemId}]`]: pItem
})
},
// 选中/取消子品牌
clickChild(e) {
let { index, pidx, cidx } = e.currentTarget.dataset
let childItem = this.data.brandList[index].list[pidx].children[cidx]
this.setData({
[`brandList[${index}].list[${pidx}].children[${cidx}].active`]: !childItem.active
})
this.dealSelectList(index, pidx, cidx)
},
handleConfirm() {
let { selectingList } = this.data
let _list = []
let idx = 0
selectingList.forEach(item => {
if (item.children.some(k => k.active == true)) {
_list.push({
id: item.id,
name: item.label,
logoUrl: item.logoUrl,
children: []
})
item.children.forEach(k => {
if (k.active) {
_list[idx].children.push({
id: k.id,
name: k.label
})
}
})
idx = idx + 1
}
})
console.log(_list, '_list处理后---')
return _list
},
start(e) {
let { letter } = e.target.dataset
this.setData({
showTip: true,
letter
})
},
move(e) {
let { letterHeight, showTip, height, toTop, arr } = this.data
let { y, num, isNum } = this
if (showTip) {
y = e.touches[0].clientY
num = Math.ceil((y - toTop) / letterHeight)
if (num < 0) num = 0
if (y < height && isNum != num) {
clearTimeout(this.time)
isNum = num
this.time = setTimeout(() => {
this.setData({
letter: arr[num]
})
}, 1000 / 60)
}
}
},
end(e) {
clearTimeout(this.time)
this.setData({
showTip: false
})
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* packageMine/components/CarBrand/CarBrand.wxss */
.y-center {
display: flex;
align-items: center;
transform: translateY(0);
}
.car-brands-box {
width: 100%;
height: calc(100% - 120rpx);
background: #FFFFFF;
// padding-top: 20rpx;
}
.car-brands {
height: 100%;
position: relative;
}
.box-title {
height: 112rpx;
line-height: 112rpx;
font-size: 32rpx;
font-weight: 600;
color: #323436;
text-align: center;
}
.car-brands .title {
position: sticky;
top: 0;
z-index: 2;
background: #F7F8FA;
font-size: 24rpx;
color: #969799;
padding-left: 24rpx;
height: 64rpx;
line-height: 64rpx;
}
.pBrand {
display: flex;
align-items: center;
width: 100%;
height: 88rpx;
line-height: 88rpx;
margin-right: 24rpx;
background: #F8F9FC;
}
.list {
height: 88rpx;
padding-left: 32rpx;
font-weight: 500;
}
.logo {
width: 40rpx;
height: 40rpx;
margin: 0 14rpx 0 20rpx;
}
.child {
font-weight: normal;
// padding-left: 82rpx;
font-size: 28rpx;
color: #323436;
position: relative;
animation: show-child .25s forwards;
}
.child.active {
box-sizing: border-box;
display: flex;
justify-content: space-between;
color: #3666FE;
padding-right: 44rpx;
.icon {
width: 32rpx;
height: 32rpx;
}
}
@keyframes show-child {
0% {
height: 0;
}
100% {
height: 88rpx;
}
}
.side-bar {
z-index: 999;
position: fixed;
top: 50%;
transform: translateY(-50%);
font-size: 24rpx;
color: #4c4c4c;
width: 10%;
opacity: 0;
animation: show-side-bar .5s forwards;
}
@keyframes show-side-bar {
0% {
opacity: 0;
right: -100%;
}
100% {
opacity: 1;
right: 0;
}
}
.side-bar .view {
width: 100%;
text-align: center;
}
.tips {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 140rpx;
height: 140rpx;
border-radius: 50%;
color: #fff;
background: rgba(153, 153, 153, 0.7);
z-index: 9999;
font-size: 60rpx;
font-weight: 500;
display: flex;
align-items: center;
justify-content: center;
}
.nothing {
padding: 100rpx;
text-align: center;
color: #999;
}
.car-type-box {
position: fixed;
left: 0;
top: 0;
width: 100vw;
height: 100vh;
font-size: 28rpx;
color: #333;
z-index: 9999;
}
.car-type-box .bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
}
.car-type-box .brands-box {
position: absolute;
top: 0;
right: 0;
width: 60.5%;
height: 100%;
overflow-y: scroll;
background: #fff;
-webkit-overflow-scrolling: touch;
animation: move 0.4s;
box-sizing: border-box;
padding-bottom: 40rpx;
}
.car-type-box .title {
width: 100%;
height: 64rpx;
box-sizing: border-box;
padding-left: 32rpx;
color: #969799;
background: #F7F8FA;
top: 0;
}
.car-type-box .brands-box .brands-list {
width: 100%;
box-sizing: border-box;
padding-left: 32rpx;
border-bottom: 1rpx solid #e9e9e9;
animation: show-car-type .25s forwards;
}
@keyframes show-car-type {
0% {
min-height: 0;
opacity: 0;
}
100% {
min-height: 100rpx;
opacity: 1;
}
}
@keyframes move {
from {
right: -60.5%;
}
to {
right: 0;
}
}
.btn-box {
width: 100%;
position: fixed;
bottom: 0;
display: flex;
padding: 8rpx 32rpx 16rpx;
background: #FFFFFF;
.btn {
box-sizing: border-box;
width: calc((100% - 78rpx) / 2);
height: 88rpx;
line-height: 88rpx;
text-align: center;
font-size: 28rpx;
color: #FFFFFF;
background: #3666FE;
border-radius: 12rpx;
border: 2rpx solid #3666FE;
}
.btn-cancel {
color: #8A8C90;
border: 2rpx solid #EEEEEE;
background: #FFFFFF;
margin-right: 14rpx;
}
}
\ No newline at end of file \ No newline at end of file
<!--packageMine/components/CarBrand/CarBrand.wxml-->
<view class="car-brands-box">
<view class="box-title">选择品牌</view>
<view class="car-brands">
<scroll-view style="height:100%;" scroll-y scroll-into-view="{{letter}}">
<block wx:if="{{flag}}">
<block wx:if="{{brandList.length > 0}}">
<block wx:for="{{brandList}}" wx:key="index">
<view id="{{item.letter}}">
<!-- <view class="title y-center">{{item.letter}}</view> -->
<view class="box">
<block wx:for="{{item.list}}" wx:for-item="i" wx:key="ind" wx:for-index="ind">
<!-- <view class="brands" catchtap="showChilds" data-index='{{index}}' data-ind='{{ind}}'> -->
<view class="brands" data-index='{{index}}' data-ind='{{ind}}'>
<view class="list y-center">
<view class="pBrand">
<image class="logo" src="{{i.logoUrl}}"></image>
{{i.label}}
</view>
</view>
<!-- <block wx:if="{{i.active && i.childs}}"> -->
<block wx:if="{{i.children}}">
<block wx:for="{{i.children}}" wx:key="cind" wx:for-item="c" wx:for-index="cind">
<!-- <view class="list y-center child" catchtap="showCarSeriesList" data-item="{{i}}" data-that="{{c}}"> -->
<view class="list y-center child {{c.active ? 'active' : ''}}" catchtap="clickChild" data-index="{{index}}" data-pidx="{{ind}}" data-cidx="{{cind}}" data-pitem="{{i}}" data-that="{{c}}">
{{c.label}}
<glsx-image src="personal/checked.png" class="icon" />
</view>
</block>
</block>
</view>
</block>
</view>
</view>
</block>
</block>
<block wx:else>
<view class="nothing">暂无数据</view>
</block>
</block>
</scroll-view>
<view class="side-bar" id="side-bar">
<block wx:for="{{brandList}}" wx:key="index">
<view data-letter="{{item.letter}}" class="view {{item.active?'active':''}}" capture-catch:touchstart="start" id="letter-{{item.letter}}" data-index="{{index}}" capture-catch:touchmove="move" capture-catch:touchend="end">{{item.letter}}
</view>
</block>
</view>
<!-- 提示 -->
<view class='tips' hidden='{{!showTip}}'>{{letter}}</view>
</view>
<!-- 车系车型 -->
<!-- <block wx:if="{{carSeriesList.length}}">
<view class="car-type-box">
<view class="bg" bindtap="cancel" catchtouchmove="noScroll"></view>
<view class="brands-box">
<block wx:for="{{carSeriesList}}" wx:key="index">
<view class="title y-center" bindtap="toggle" data-index="{{index}}" data-id="{{item.id}}">{{item.name}}
</view>
<view class="box" hidden="{{!item.active}}">
<block wx:for="{{item.list}}" wx:for-item="i" wx:key="id">
<view class="brands-list y-center" bindtap="choose" data-item="{{item}}" data-that="{{i}}">{{i.name}}
</view>
</block>
</view>
</block>
</view>
</view>
</block> -->
</view>
<!-- <view class="btn-box">
<view class="btn btn-cancel">取消</view>
<view class="btn" bindtap="handleConfirm">确定</view>
</view> -->
\ No newline at end of file \ No newline at end of file
...@@ -10,7 +10,9 @@ const formRule = { ...@@ -10,7 +10,9 @@ const formRule = {
return !phoneRex.test(value) ? { message: '请输入正确的手机号' } : null return !phoneRex.test(value) ? { message: '请输入正确的手机号' } : null
} }
} }
] ],
longitude: [{ required: true, message: '地址不能为空' }],
merchantAddress: [{ required: true, message: '详细地址不能为空' }],
} }
const formItems = [{ const formItems = [{
...@@ -40,6 +42,16 @@ const formItems = [{ ...@@ -40,6 +42,16 @@ const formItems = [{
placeholder: '请输入手机号码', placeholder: '请输入手机号码',
maxlength: 11 maxlength: 11
}, { }, {
label: '地址',
props: '',
type: 'map',
detailAddr: {
props: 'merchantAddress',
maxlength: 50
}
}]
const formItemsThird = [{
label: '业务开通', label: '业务开通',
props: '', props: '',
type: 'business' type: 'business'
...@@ -47,5 +59,6 @@ const formItems = [{ ...@@ -47,5 +59,6 @@ const formItems = [{
export default { export default {
formRule, formRule,
formItems formItems,
formItemsThird
} }
\ No newline at end of file \ No newline at end of file
...@@ -5,6 +5,7 @@ import { IMG_URL } from '~/utils/constantData' ...@@ -5,6 +5,7 @@ import { IMG_URL } from '~/utils/constantData'
import mineServiceApi from '~/api/mineApi/mineService' import mineServiceApi from '~/api/mineApi/mineService'
import mineCustomerApi from '~/api/mineApi/mineCustomer' import mineCustomerApi from '~/api/mineApi/mineCustomer'
import outputApi from '~/api/outputApi/index' import outputApi from '~/api/outputApi/index'
import mapApi from '~/utils/mapapi/mapapi'
const sceneCodeList = ['SC002', 'SC003', 'SC004', 'SC001'] const sceneCodeList = ['SC002', 'SC003', 'SC004', 'SC001']
Page({ Page({
...@@ -16,6 +17,7 @@ Page({ ...@@ -16,6 +17,7 @@ Page({
addOrEdit: '', addOrEdit: '',
formData: {}, formData: {},
formItems: constantData.formItems, formItems: constantData.formItems,
formItemsThird: constantData.formItemsThird,
apiNameObj: { apiNameObj: {
'add': 'saveCustomer', 'add': 'saveCustomer',
'edit': 'updateCustomer' 'edit': 'updateCustomer'
...@@ -29,7 +31,120 @@ Page({ ...@@ -29,7 +31,120 @@ Page({
isConfirm: false, isConfirm: false,
baseData: { baseData: {
proList: [] proList: []
},
// 车品牌popup
popupShow: false,
selectedBrandList: []
},
// 地址解析(地址转坐标)https://apis.map.qq.com/ws/geocoder/v1/?address=
getGeocoder() {
let { formData } = this.data
// let address = formData.provinceName || '' + formData.cityName || '' + formData.merchantAddress || ''
let address = (formData.provinceName || '') + (formData.cityName || '')
mapApi.geocoder(address).then(res => {
this.setData({
['formData.longitude']: res?.location?.lng,
['formData.latitude']: res?.location?.lat,
})
})
},
// 省市改变
bindRegionChange(e) {
let { detail } = e
this.setData({
['formData.provinceName']: detail?.value[0],
['formData.provinceCode']: detail?.code[0],
['formData.cityName']: detail?.value[1],
['formData.cityCode']: detail?.code[1],
['formData.latitude']: '',
['formData.longitude']: '',
['formData.merchantAddress']: '',
region: detail?.value
})
this.getGeocoder()
},
brandConfirm() {
let brandMoudle = this.selectComponent('#car-brand')
this.setData({
selectedBrandList: brandMoudle && brandMoudle.handleConfirm() || []
})
this.hideBrandPopup()
},
hideBrandPopup() {
this.setData({
popupShow: !this.data.popupShow
})
},
handleChooseBrand() {
// wx.$router.go('packageMine.carBrandList')
this.hideBrandPopup()
},
deleteBrand(e) {
let { pidx, cidx } = e.currentTarget.dataset
let { selectedBrandList } = this.data
selectedBrandList[pidx].children.splice(cidx, 1)
if (!selectedBrandList[pidx].children.length) {
selectedBrandList.splice(pidx, 1)
} }
this.setData({
selectedBrandList
})
},
// 经纬度存在与否,不存在则通过ip获取
getLngLat(obj) {
return new Promise(resolve => {
if (obj.longitude && obj.latitude) {
resolve(obj)
}
mapApi.getLocationByIp().then(res => {
let { location } = res
resolve({
longitude: location.lng,
latitude: location.lat
})
})
})
},
// 地图
handleMap() {
const _this = this
let { formData } = this.data
// wx.$router.go('packageMine.map', formData)
this.getLngLat(formData).then(location => {
this.setData({
['formData.latitude']: location.latitude,
['formData.longitude']: location.longitude,
})
wx.chooseLocation({
latitude: parseFloat(location.latitude),
longitude: parseFloat(location.longitude),
address: formData.merchantAddress || '',
success: function (res) {
// 逆地址解析
// 代码共6位,前两位代表省(一级)、中间两位为市/地区(二级),最后两位为区县(三级),区code获取省code和市code
mapApi.detailedAdrress([res.latitude, res.longitude]).then(obj => {
_this.setData({
['formData.latitude']: obj?.location?.lat,
['formData.longitude']: obj?.location?.lng,
['formData.provinceName']: obj?.ad_info?.province,
['formData.provinceCode']: obj?.ad_info?.adcode.slice(0, 2) + '0000',
['formData.cityName']: obj?.ad_info?.city,
['formData.cityCode']: obj?.ad_info?.adcode.slice(0, 4) + '00',
['formData.merchantAddress']: res?.name,
region: [obj?.ad_info?.province, obj?.ad_info?.city]
})
})
}
})
})
}, },
getProList(sceneCode) { getProList(sceneCode) {
...@@ -44,7 +159,7 @@ Page({ ...@@ -44,7 +159,7 @@ Page({
let target = scenceList.find(k => k.sceneCode == item) let target = scenceList.find(k => k.sceneCode == item)
if (addOrEdit == 'edit') { if (addOrEdit == 'edit') {
proList.forEach(k => { proList.forEach(k => {
if(proActList.includes(k.productCode)) { if (proActList.includes(k.productCode)) {
k.isCheck = true k.isCheck = true
} }
}) })
...@@ -65,7 +180,6 @@ Page({ ...@@ -65,7 +180,6 @@ Page({
} }
let proActList = [] let proActList = []
outputApi.getSceneProStatus(params).then(res => { outputApi.getSceneProStatus(params).then(res => {
console.log(res)
res.forEach(item => { res.forEach(item => {
item.productList.forEach(k => { item.productList.forEach(k => {
if (k.productStatus == 2) { if (k.productStatus == 2) {
...@@ -147,9 +261,26 @@ Page({ ...@@ -147,9 +261,26 @@ Page({
return { sceneList: sceneArr, productCodeList: arr } return { sceneList: sceneArr, productCodeList: arr }
}, },
dealBrandList() {
let { formData, selectedBrandList } = this.data
formData.merchantBrandList = []
selectedBrandList.forEach(item => {
formData.merchantBrandList.push({
merchantFirstBrandDetail: {
id: item.id,
name: item.name
},
merchantSecondBrandDetailList: item.children
})
})
this.setData({
formData
})
},
handleConfirm() { handleConfirm() {
let { userInfo } = wx.$storage.get() let { userInfo } = wx.$storage.get()
let { apiNameObj, addOrEdit, formData, isConfirm } = this.data let { apiNameObj, addOrEdit, formData, isConfirm, selectedBrandList } = this.data
let _this = this let _this = this
if (isConfirm) { if (isConfirm) {
return true return true
...@@ -162,10 +293,15 @@ Page({ ...@@ -162,10 +293,15 @@ Page({
wx.$api.showToast(validObj.message) wx.$api.showToast(validObj.message)
return return
} }
if(!selectedBrandList.length) {
wx.$api.showToast('至少选择一个主营品牌')
return
}
if (!formData.productCodeList.length) { if (!formData.productCodeList.length) {
wx.$api.showToast('请至少选择一个产品') wx.$api.showToast('请至少选择一个产品')
return return
} }
this.dealBrandList()
let message = addOrEdit == 'add' ? '是否确定提交客户开通申请?' : '是否确定修改客户?' let message = addOrEdit == 'add' ? '是否确定提交客户开通申请?' : '是否确定修改客户?'
delete formData.serviceCenterMerchantName delete formData.serviceCenterMerchantName
wx.showModal({ wx.showModal({
...@@ -190,7 +326,15 @@ Page({ ...@@ -190,7 +326,15 @@ Page({
productCodeList: formData.productCodeList, productCodeList: formData.productCodeList,
oldPhone: formData?.oldPhone, oldPhone: formData?.oldPhone,
oldMerchantName: formData.oldMerchantName, oldMerchantName: formData.oldMerchantName,
serviceMerchantName: userInfo.merchantName serviceMerchantName: userInfo.merchantName,
merchantBrandList: _this.data.formData.merchantBrandList,
longitude: formData.longitude,
latitude: formData.latitude,
provinceCode: formData.provinceCode,
provinceName: formData.provinceName,
cityCode: formData.cityCode,
cityName: formData.cityName,
merchantAddress: formData.merchantAddress,
} }
if (addOrEdit == 'edit') { if (addOrEdit == 'edit') {
params.merchantId = formData.merchantId params.merchantId = formData.merchantId
...@@ -226,6 +370,40 @@ Page({ ...@@ -226,6 +370,40 @@ Page({
}) })
}, },
infoToBrandList(list) {
let brandList = []
if (!list.length) {
return brandList
}
list.forEach(item => {
brandList.push({
id: item.id,
name: item.name,
logoUrl: item.logoUrl,
children: item.subList
})
})
return brandList
},
getMerchantInfo() {
let { formData } = this.data
let params = {
merchantId: formData.merchantId
}
const attrList = [{ name: 'provinceCode' }, { name: 'provinceName' }, { name: 'cityCode' }, { name: 'cityName' }, { name: 'merchantAddress' }, { name: 'latitude', attrName: 'lat' }, { name: 'longitude', attrName: 'lng' }]
mineServiceApi.getMerchantInfo(params).then(res => {
attrList.forEach(item => {
formData[item.name] = res[item.attrName || item.name]
})
this.setData({
formData,
selectedBrandList: this.infoToBrandList(res.brandTreeList || []),
region: [res?.provinceName, res?.cityName]
})
})
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
...@@ -253,6 +431,7 @@ Page({ ...@@ -253,6 +431,7 @@ Page({
yqMerchantName: target.serviceCenterMerchantName yqMerchantName: target.serviceCenterMerchantName
} }
}) })
this.getMerchantInfo()
this.getSceneProStatus() this.getSceneProStatus()
} else { } else {
this.getProList() this.getProList()
......
{ {
"navigationBarTitleText": "创建客户", "navigationBarTitleText": "创建客户",
"usingComponents": { "usingComponents": {
"select-service-confirm": "../../../components/selectServiceConfirm/selectServiceConfirm" "select-service-confirm": "../../../components/selectServiceConfirm/selectServiceConfirm",
"car-brand": "../../../components/CarBrand/CarBrand"
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
.form-content { .form-content {
background: #FFFFFF; background: #FFFFFF;
border-radius: 16rpx; border-radius: 16rpx;
padding: 44rpx 40rpx 200rpx; padding: 44rpx 40rpx;
margin-bottom: 16rpx;
.label { .label {
font-size: 28rpx; font-size: 28rpx;
...@@ -53,11 +54,113 @@ ...@@ -53,11 +54,113 @@
} }
} }
.addr {
.row {
height: 40rpx;
background: #F8F9FC;
border-radius: 12rpx;
padding: 28rpx 32rpx;
}
.province {
display: flex;
justify-content: space-between;
margin-bottom: 16rpx;
.placeholder {
color: #CCCED1;
}
.icon {
width: 36rpx;
height: 36rpx;
}
}
}
.disabled { .disabled {
background: #E1E2E6; background: #E1E2E6;
} }
} }
.brand {
// margin: 16rpx 0 200rpx;
padding: 32rpx 40rpx 40rpx;
.label {
display: flex;
justify-content: space-between;
align-items: center;
}
.label-btn {
font-size: 24rpx;
color: #3666FE;
}
.pBrand {
display: flex;
align-items: center;
width: 100%;
height: 40rpx;
line-height: 40rpx;
margin-bottom: 12rpx;
color: #6C737A;
.logo {
width: 40rpx;
height: 40rpx;
margin: 0 14rpx 0 0;
}
}
.cBrand {
display: flex;
flex-wrap: wrap;
.item {
position: relative;
display: flex;
align-items: center;
box-sizing: border-box;
flex-shrink: 1;
height: 64rpx;
background: #F0F7FF;
border-radius: 8rpx;
margin: 0 16rpx 16rpx 0;
padding: 10rpx 60rpx 10rpx 20rpx;
.logo {
position: absolute;
width: 28rpx;
height: 28rpx;
right: 10rpx;
top: 10rpx;
}
}
}
.add {
padding: 32rpx 0 8rpx;
text-align: center;
font-weight: 400;
font-size: 26rpx;
color: #3666FE;
.icon {
width: 56rpx;
height: 56rpx;
margin-bottom: 16rpx;
}
}
}
.bussiness {
padding-bottom: 200rpx;
}
.btn { .btn {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
......
...@@ -12,6 +12,59 @@ ...@@ -12,6 +12,59 @@
<view class="placeholder-text" wx:else>{{item.placeholder}}</view> <view class="placeholder-text" wx:else>{{item.placeholder}}</view>
<glsx-image src="personal/arrow_right.png" class="arrow_right" /> <glsx-image src="personal/arrow_right.png" class="arrow_right" />
</view> </view>
<view wx:if="{{item.type == 'map'}}" class="addr">
<picker mode="region" level="city" bindchange="bindRegionChange" value="{{region}}">
<!-- <picker mode="region" bindchange="bindRegionChange" value="{{region}}"> -->
<view class="row province">
<view wx:if="{{formData.provinceCode}}">{{region[0]}} {{region[1]}}</view>
<view class="placeholder" wx:else>请选择省市</view>
<glsx-image webp src="personal/icon-point.png" class="icon" catchtap="handleMap" />
</view>
</picker>
<input placeholder="请输入详细地址" maxlength="{{item.detailAddr.maxlength}}" class="row" value="{{formData[item.detailAddr.props]}}" disabled="{{item.detailAddr.disabled}}" data-attr="{{item.detailAddr.props}}" bindinput="handleInput" />
</view>
<view wx:if="{{item.type == 'business'}}">
<view wx:for="{{scenceList}}" wx:key="index" class="scene">
<view class="scene-item">
<image webp class="scene-img" src="{{IMGURL}}output/caracticon0{{item.sceneid + 1}}.png?v={{img_version}}"></image>
<view>{{item.name}}</view>
</view>
<view class="pro-box">
<view wx:for="{{item.proList}}" wx:for-item="subItem" wx:for-index="idx" wx:key="idx" class="pro-item {{subItem.isCheck ? 'active' : ''}}" bindtap="handleProClick" data-sceneIdx="{{index}}" data-proIdx="{{idx}}">
<glsx-image wx:if="{{subItem.isCheck}}" src="personal/scene-check.png" class="check-icon" />
{{subItem.productName}}
</view>
</view>
</view>
</view>
</block>
</view>
<view class="form-content brand">
<view class="label">主营品牌<text class="label-btn" wx:if="{{selectedBrandList.length}}" bindtap="handleChooseBrand">选择</text></view>
<view class="add" wx:if="{{!selectedBrandList.length}}" bindtap="handleChooseBrand">
<glsx-image src="index/apply.png" class="icon" />
<view>添加主营品牌</view>
</view>
<view wx:for="{{selectedBrandList}}" wx:key="index">
<view class="pBrand">
<image class="logo" src="{{item.logoUrl}}"></image>
{{item.name}}
</view>
<view class="cBrand">
<view wx:for="{{item.children}}" wx:for-item="subItem" wx:for-index="subIndex" wx:key="subIndex">
<view class="item">
{{subItem.name}}
<glsx-image src="personal/icon-delete.png" class="logo" catchtap="deleteBrand" data-pidx="{{index}}" data-cidx="{{subIndex}}" />
</view>
</view>
</view>
</view>
</view>
<view class="form-content bussiness">
<block wx:for="{{formItemsThird}}" wx:key="index">
<view class="label">{{item.label}}<text class="tips">{{item.tips}}</text></view>
<view wx:if="{{item.type == 'business'}}"> <view wx:if="{{item.type == 'business'}}">
<view wx:for="{{scenceList}}" wx:key="index" class="scene"> <view wx:for="{{scenceList}}" wx:key="index" class="scene">
<view class="scene-item"> <view class="scene-item">
...@@ -32,4 +85,8 @@ ...@@ -32,4 +85,8 @@
<view class="btn-blue" bindtap="handleConfirm">{{addOrEdit == 'add' ? '提交' : '保存'}}</view> <view class="btn-blue" bindtap="handleConfirm">{{addOrEdit == 'add' ? '提交' : '保存'}}</view>
</view> </view>
</view> </view>
<select-service-confirm show="{{showServiceConfirm}}" tabBarStyle="{{tabBarStyle}}" serviceList="{{serviceList}}" selectInfo="{{formData.selectInfo}}" bind:hiddenSelectConfirm="hiddenSelectConfirm"></select-service-confirm>
\ No newline at end of file \ No newline at end of file
<select-service-confirm show="{{showServiceConfirm}}" tabBarStyle="{{tabBarStyle}}" serviceList="{{serviceList}}" selectInfo="{{formData.selectInfo}}" bind:hiddenSelectConfirm="hiddenSelectConfirm"></select-service-confirm>
<!-- 车品牌 -->
<popup show="{{popupShow}}" bind:hidePopup="hideBrandPopup" bindconfirm="brandConfirm" height="95%">
<car-brand id="car-brand" popupShow="{{popupShow}}" selectedList="{{selectedBrandList}}"></car-brand>
</popup>
\ No newline at end of file \ No newline at end of file
...@@ -18,6 +18,8 @@ const formRule = { ...@@ -18,6 +18,8 @@ const formRule = {
} }
} }
], ],
longitude: [{ required: true, message: '地址不能为空' }],
merchantAddress: [{ required: true, message: '详细地址不能为空' }],
} }
var formItems = [{ var formItems = [{
...@@ -53,7 +55,15 @@ var formItems = [{ ...@@ -53,7 +55,15 @@ var formItems = [{
showPwd: false, showPwd: false,
placeholder: '请输入登录密码(6-20位字母+数字)', placeholder: '请输入登录密码(6-20位字母+数字)',
maxlength: 20 maxlength: 20
}] }, {
label: '地址',
props: '',
type: 'map',
detailAddr: {
props: 'merchantAddress',
maxlength: 50
}
},]
export default { export default {
formRule, formRule,
......
// packageMine/pages/serviceManage/editService/editService.js // packageMine/pages/serviceManage/editService/editService.js
import constantData from './constant/data' import constantData from './constant/data'
import mineServiceApi from '~/api/mineApi/mineService' import mineServiceApi from '~/api/mineApi/mineService'
import mapApi from '~/utils/mapapi/mapapi'
Page({ Page({
/** /**
...@@ -8,13 +9,79 @@ Page({ ...@@ -8,13 +9,79 @@ Page({
*/ */
data: { data: {
addOrEdit: '', addOrEdit: '',
formData: {}, formData: {
merchantBrandList: []
},
formItems: constantData.formItems, formItems: constantData.formItems,
apiNameObj: { apiNameObj: {
'add': 'saveService', 'add': 'saveService',
'edit': 'updateService' 'edit': 'updateService'
}, },
isConfirm: false region: [],
isConfirm: false,
// 车品牌popup
popupShow: false,
selectedBrandList: []
},
// 地址解析(地址转坐标)https://apis.map.qq.com/ws/geocoder/v1/?address=
getGeocoder() {
let { formData } = this.data
// let address = formData.provinceName || '' + formData.cityName || '' + formData.merchantAddress || ''
let address = (formData.provinceName || '') + (formData.cityName || '')
mapApi.geocoder(address).then(res => {
this.setData({
['formData.longitude']: res?.location?.lng,
['formData.latitude']: res?.location?.lat,
})
})
},
// 省市改变
bindRegionChange(e) {
let { detail } = e
this.setData({
['formData.provinceName']: detail?.value[0],
['formData.provinceCode']: detail?.code[0],
['formData.cityName']: detail?.value[1],
['formData.cityCode']: detail?.code[1],
['formData.latitude']: '',
['formData.longitude']: '',
['formData.merchantAddress']: '',
region: detail?.value
})
this.getGeocoder()
},
brandConfirm() {
let brandMoudle = this.selectComponent('#car-brand')
this.setData({
selectedBrandList: brandMoudle && brandMoudle.handleConfirm() || []
})
this.hideBrandPopup()
},
hideBrandPopup() {
this.setData({
popupShow: !this.data.popupShow
})
},
handleChooseBrand() {
// wx.$router.go('packageMine.carBrandList')
this.hideBrandPopup()
},
deleteBrand(e) {
let { pidx, cidx } = e.currentTarget.dataset
let { selectedBrandList } = this.data
selectedBrandList[pidx].children.splice(cidx, 1)
if (!selectedBrandList[pidx].children.length) {
selectedBrandList.splice(pidx, 1)
}
this.setData({
selectedBrandList
})
}, },
handleInput(e) { handleInput(e) {
...@@ -32,6 +99,56 @@ Page({ ...@@ -32,6 +99,56 @@ Page({
}) })
}, },
// 经纬度存在与否,不存在则通过ip获取
getLngLat(obj) {
return new Promise(resolve => {
if (obj.longitude && obj.latitude) {
resolve(obj)
}
mapApi.getLocationByIp().then(res => {
let { location } = res
resolve({
longitude: location.lng,
latitude: location.lat
})
})
})
},
// 地图
handleMap() {
const _this = this
let { formData } = this.data
// wx.$router.go('packageMine.map', formData)
this.getLngLat(formData).then(location => {
this.setData({
['formData.latitude']: location.latitude,
['formData.longitude']: location.longitude,
})
wx.chooseLocation({
latitude: parseFloat(location.latitude),
longitude: parseFloat(location.longitude),
address: formData.merchantAddress || '',
success: function (res) {
// 逆地址解析
// 代码共6位,前两位代表省(一级)、中间两位为市/地区(二级),最后两位为区县(三级),区code获取省code和市code
mapApi.detailedAdrress([res.latitude, res.longitude]).then(obj => {
_this.setData({
['formData.latitude']: obj?.location?.lat,
['formData.longitude']: obj?.location?.lng,
['formData.provinceName']: obj?.ad_info?.province,
['formData.provinceCode']: obj?.ad_info?.adcode.slice(0, 2) + '0000',
['formData.cityName']: obj?.ad_info?.city,
['formData.cityCode']: obj?.ad_info?.adcode.slice(0, 4) + '00',
['formData.merchantAddress']: res?.name,
region: [obj?.ad_info?.province, obj?.ad_info?.city]
})
})
}
})
})
},
// 密码清空 // 密码清空
handlePwdClear(e) { handlePwdClear(e) {
let { attr } = e.currentTarget.dataset let { attr } = e.currentTarget.dataset
...@@ -40,9 +157,26 @@ Page({ ...@@ -40,9 +157,26 @@ Page({
}) })
}, },
dealBrandList() {
let { formData, selectedBrandList } = this.data
formData.merchantBrandList = []
selectedBrandList.forEach(item => {
formData.merchantBrandList.push({
merchantFirstBrandDetail: {
id: item.id,
name: item.name
},
merchantSecondBrandDetailList: item.children
})
})
this.setData({
formData
})
},
handleConfirm() { handleConfirm() {
let { userInfo } = wx.$storage.get() let { userInfo } = wx.$storage.get()
let { apiNameObj, addOrEdit, formData, isConfirm } = this.data let { apiNameObj, addOrEdit, formData, isConfirm, selectedBrandList } = this.data
let _this = this let _this = this
if (isConfirm) { if (isConfirm) {
return true return true
...@@ -52,6 +186,11 @@ Page({ ...@@ -52,6 +186,11 @@ Page({
wx.$api.showToast(validObj.message) wx.$api.showToast(validObj.message)
return return
} }
if(!selectedBrandList.length) {
wx.$api.showToast('至少选择一个主营品牌')
return
}
this.dealBrandList()
let message = addOrEdit == 'add' ? '是否确定提交服务中心开通申请?' : '是否确定修改服务中心信息?' let message = addOrEdit == 'add' ? '是否确定提交服务中心开通申请?' : '是否确定修改服务中心信息?'
wx.showModal({ wx.showModal({
title: '提示', title: '提示',
...@@ -67,7 +206,7 @@ Page({ ...@@ -67,7 +206,7 @@ Page({
wx.$api.showLoading('加载中...') wx.$api.showLoading('加载中...')
// 创建/编辑接口 // 创建/编辑接口
mineServiceApi[apiNameObj[addOrEdit]]({ mineServiceApi[apiNameObj[addOrEdit]]({
...formData, ..._this.data.formData,
serviceMerchantName: userInfo.merchantName serviceMerchantName: userInfo.merchantName
}).then(res => { }).then(res => {
let { code, message } = res let { code, message } = res
...@@ -94,6 +233,40 @@ Page({ ...@@ -94,6 +233,40 @@ Page({
}) })
}, },
infoToBrandList(list) {
let brandList = []
if (!list.length) {
return brandList
}
list.forEach(item => {
brandList.push({
id: item.id,
name: item.name,
logoUrl: item.logoUrl,
children: item.subList
})
})
return brandList
},
getMerchantInfo() {
let { formData } = this.data
let params = {
merchantId: formData.merchantId
}
const attrList = [{ name: 'provinceCode' }, { name: 'provinceName' }, { name: 'cityCode' }, { name: 'cityName' }, { name: 'merchantAddress' }, { name: 'latitude', attrName: 'lat' }, { name: 'longitude', attrName: 'lng' }, { name: 'password', attrName: 'merchantLoginPassword' }]
mineServiceApi.getMerchantInfo(params).then(res => {
attrList.forEach(item => {
formData[item.name] = res[item.attrName || item.name]
})
this.setData({
formData,
selectedBrandList: this.infoToBrandList(res.brandTreeList || []),
region: [res?.provinceName, res?.cityName]
})
})
},
dealFormItem() { dealFormItem() {
let { formItems } = this.data let { formItems } = this.data
if (this.data.addOrEdit == 'add') { if (this.data.addOrEdit == 'add') {
...@@ -102,6 +275,7 @@ Page({ ...@@ -102,6 +275,7 @@ Page({
formItems formItems
}) })
} else { } else {
this.getMerchantInfo()
wx.setNavigationBarTitle({ title: '编辑服务中心' }) wx.setNavigationBarTitle({ title: '编辑服务中心' })
} }
}, },
......
{ {
"navigationBarTitleText": "创建服务中心", "navigationBarTitleText": "创建服务中心",
"usingComponents": { "usingComponents": {
"input-icon": "/login/index/components/InputIcon/InputIcon" "input-icon": "/login/index/components/InputIcon/InputIcon",
"car-brand": "../../../components/CarBrand/CarBrand"
} }
} }
\ No newline at end of file \ No newline at end of file
/* packageMine/pages/serviceManage/editService/editService.wxss */ /* packageMine/pages/serviceManage/editService/editService.wxss */
.create-service-page { .create-service-page {
margin: 20rpx; margin: 20rpx;
overflow: scroll;
.tips { .tips {
padding: 12rpx; padding: 12rpx;
...@@ -69,6 +70,102 @@ ...@@ -69,6 +70,102 @@
white-space: nowrap; white-space: nowrap;
} }
} }
.addr {
.row {
height: 40rpx;
background: #F8F9FC;
border-radius: 12rpx;
padding: 28rpx 32rpx;
}
.province {
display: flex;
justify-content: space-between;
margin-bottom: 16rpx;
.placeholder {
color: #CCCED1;
}
.icon {
width: 36rpx;
height: 36rpx;
}
}
}
}
.brand {
margin: 16rpx 0 200rpx;
padding: 32rpx 40rpx 40rpx;
.label {
display: flex;
justify-content: space-between;
align-items: center;
}
.label-btn {
font-size: 24rpx;
color: #3666FE;
}
.pBrand {
display: flex;
align-items: center;
width: 100%;
height: 40rpx;
line-height: 40rpx;
margin-bottom: 12rpx;
color: #6C737A;
.logo {
width: 40rpx;
height: 40rpx;
margin: 0 14rpx 0 0;
}
}
.cBrand {
display: flex;
flex-wrap: wrap;
.item {
position: relative;
display: flex;
align-items: center;
box-sizing: border-box;
flex-shrink: 1;
height: 64rpx;
background: #F0F7FF;
border-radius: 8rpx;
margin: 0 16rpx 16rpx 0;
padding: 10rpx 60rpx 10rpx 20rpx;
.logo {
position: absolute;
width: 28rpx;
height: 28rpx;
right: 10rpx;
top: 10rpx;
}
}
}
.add {
padding: 32rpx 0 8rpx;
text-align: center;
font-weight: 400;
font-size: 26rpx;
color: #3666FE;
.icon {
width: 56rpx;
height: 56rpx;
margin-bottom: 16rpx;
}
}
} }
.btn { .btn {
......
...@@ -19,9 +19,44 @@ ...@@ -19,9 +19,44 @@
<view class="placeholder-text" wx:else>{{item.placeholder}}</view> <view class="placeholder-text" wx:else>{{item.placeholder}}</view>
<glsx-image src="personal/arrow_right.png" class="arrow_right" /> <glsx-image src="personal/arrow_right.png" class="arrow_right" />
</view> </view>
<view wx:if="{{item.type == 'map'}}" class="addr">
<picker mode="region" level="city" bindchange="bindRegionChange" value="{{region}}">
<!-- <picker mode="region" bindchange="bindRegionChange" value="{{region}}"> -->
<view class="row province">
<view wx:if="{{formData.provinceCode}}">{{region[0]}} {{region[1]}}</view>
<view class="placeholder" wx:else>请选择省市</view>
<glsx-image webp src="personal/icon-point.png" class="icon" catchtap="handleMap" />
</view>
</picker>
<input placeholder="请输入详细地址" maxlength="{{item.detailAddr.maxlength}}" class="row" value="{{formData[item.detailAddr.props]}}" disabled="{{item.detailAddr.disabled}}" data-attr="{{item.detailAddr.props}}" bindinput="handleInput" />
</view>
</block> </block>
</view> </view>
<view class="form-content brand">
<view class="label">主营品牌<text class="label-btn" wx:if="{{selectedBrandList.length}}" bindtap="handleChooseBrand">选择</text></view>
<view class="add" wx:if="{{!selectedBrandList.length}}" bindtap="handleChooseBrand">
<glsx-image src="index/apply.png" class="icon" />
<view>添加主营品牌</view>
</view>
<view wx:for="{{selectedBrandList}}" wx:key="index">
<view class="pBrand">
<image class="logo" src="{{item.logoUrl}}"></image>
{{item.name}}
</view>
<view class="cBrand">
<view wx:for="{{item.children}}" wx:for-item="subItem" wx:for-index="subIndex" wx:key="subIndex">
<view class="item">
{{subItem.name}}
<glsx-image src="personal/icon-delete.png" class="logo" catchtap="deleteBrand" data-pidx="{{index}}" data-cidx="{{subIndex}}" />
</view>
</view>
</view>
</view>
</view>
<view class="isFullSucreen btn"> <view class="isFullSucreen btn">
<view class="btn-blue" bindtap="handleConfirm">{{addOrEdit == 'add' ? '提交' : '保存'}}</view> <view class="btn-blue" bindtap="handleConfirm">{{addOrEdit == 'add' ? '提交' : '保存'}}</view>
</view> </view>
</view>
\ No newline at end of file \ No newline at end of file
</view>
<popup show="{{popupShow}}" bind:hidePopup="hideBrandPopup" bindconfirm="brandConfirm" height="95%">
<car-brand id="car-brand" popupShow="{{popupShow}}" selectedList="{{selectedBrandList}}"></car-brand>
</popup>
\ No newline at end of file \ No newline at end of file
...@@ -18,7 +18,8 @@ export const STORAGE_OBJECTkEY = { ...@@ -18,7 +18,8 @@ export const STORAGE_OBJECTkEY = {
disLikeRecordFlag: 'disLikeRecordFlag', disLikeRecordFlag: 'disLikeRecordFlag',
fileList: 'fileList', fileList: 'fileList',
posterId: 'posterId', posterId: 'posterId',
mock_data: 'mock_data' mock_data: 'mock_data',
car_brand_list: 'car_brand_list'
} }
export const IMG_VERSION = () => { export const IMG_VERSION = () => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!