Commit 3d5871bc by 王志慧

Merge branch 'v2.3.3' of http://192.168.3.233:8090/glsx/dj-scrm-wx-work-attachme…

…nt-customer into wangzh_dev_2.3.3
2 parents 26b711e9 b7489a03
...@@ -14,3 +14,23 @@ ...@@ -14,3 +14,23 @@
.icon-identifier { width: 20px; height: 20px; background-position: -138px 0px;} .icon-identifier { width: 20px; height: 20px; background-position: -138px 0px;}
.icon-open-arrow { width: 8px; height: 7px; background-position: -138px -107px;} .icon-open-arrow { width: 8px; height: 7px; background-position: -138px -107px;}
.icon-succeed { width: 24px; height: 24px; background-position: 0px -96px;} .icon-succeed { width: 24px; height: 24px; background-position: 0px -96px;}
.sprite-icon { background-image: url(../images/sprite.png);background-size: 158px 144px;}
.icon-active { width: 20px; height: 20px; background-position: 0px -96px;}
.icon-append { width: 32px; height: 32px; background-position: -54px 0px;}
.icon-appoint { width: 32px; height: 32px; background-position: 0px -54px;}
.icon-arrow { width: 7px; height: 11px; background-position: -96px -72px;}
.icon-avatar { width: 44px; height: 44px; background-position: 0px 0px;}
.icon-customer-active { width: 16px; height: 16px; background-position: -56px -126px;}
.icon-customer-add { width: 28px; height: 20px; background-position: -96px -42px;}
.icon-customer-copy { width: 18px; height: 20px; background-position: -138px -30px;}
.icon-customer-phone { width: 20px; height: 20px; background-position: -30px -96px;}
.icon-factory { width: 32px; height: 32px; background-position: -42px -54px;}
.icon-fllow { width: 18px; height: 18px; background-position: -138px -88px;}
.icon-follow { width: 32px; height: 32px; background-position: -96px 0px;}
.icon-identifier { width: 20px; height: 20px; background-position: -60px -96px;}
.icon-maintant { width: 20px; height: 20px; background-position: -90px -96px;}
.icon-message { width: 18px; height: 18px; background-position: 0px -126px;}
.icon-open-arrow { width: 8px; height: 7px; background-position: -113px -72px;}
.icon-sendwechat { width: 20px; height: 18px; background-position: -138px -60px;}
.icon-tel { width: 18px; height: 18px; background-position: -28px -126px;}
.icon-followRecord { width: 20px; height: 20px; background-position: -138px 0px;}
<template>
<div>
<div class="customer-box" v-for="item in customerInfo" :key="item.id">
<div class="customer-title">
<div class="customer-name">{{ item.name }}</div>
<div class="customer-carnumber">{{ item.carNumber }}</div>
</div>
<div class="customer-info">
<div class="customer-info-left">
<div class="customer-info-label">
<div class="customer-info-name">车系:</div>
<div class="customer-info-message">{{ item.carBrand }}</div>
</div>
<div class="customer-info-label">
<div class="customer-info-name">招揽结果:</div>
<div class="customer-info-message">{{ item.result }}</div>
</div>
<div class="customer-info-label">
<div class="customer-info-name">企微营销:</div>
<div class="customer-info-message">{{ item.wechatMarketing }}</div>
</div>
</div>
<div class="customer-info-right">
<div class="customer-info-label">
<div class="customer-info-name">企微账号:</div>
<div class="customer-info-message customer-info-wechat">@{{ item.joinWechat }}</div>
</div>
<div class="customer-info-label">
<div class="customer-info-name">招揽日期:</div>
<div class="customer-info-message">{{ item.date }}</div>
</div>
<div class="customer-info-label">
<div class="customer-info-name">更新日期:</div>
<div class="customer-info-message">{{ item.updateDate }}</div>
</div>
</div>
</div>
<div class="customer-marketing">
<div class="sprite-icon icon-tel" @click="callCustomer(item)"></div>
<div class="sprite-icon icon-fllow" @click="followCustomer(item)"></div>
<div class="sprite-icon icon-message" @click="sendMessage(item)"></div>
<div class="sprite-icon icon-sendwechat" @click="sendWechat(item)"></div>
</div>
</div>
<!-- 跟进弹窗 -->
<customer-follow-popup ref="customerFollowRef"></customer-follow-popup>
<!-- 客户信息弹窗 -->
<customer-info-popup ref="customerInfoRef"></customer-info-popup>
</div>
</template>
<script>
import { Toast } from 'vant'
import CustomerInfoPopup from './CustomerInfoPopup.vue'
import CustomerFollowPopup from './CustomerFollowPopup.vue'
export default {
components: { CustomerInfoPopup, CustomerFollowPopup },
name: 'CustomerCard',
props: {
customerInfo: {
type: Array,
default: () => {
return []
}
}
},
data() {
return {}
},
methods: {
changeTab(index) {
console.log(index)
this.isShow = false
if (index === 0) {
this.isShow = true
}
},
// 电话招揽
callCustomer(val) {
console.log(val)
if (!val.telNumber) {
Toast('系统尚未查询到该用户的电话号码')
}
},
// 招揽跟进
followCustomer(val) {
console.log(val)
this.$refs.customerFollowRef.init()
},
// 客户详情
sendMessage(val) {
console.log(val)
this.$refs.customerInfoRef.init()
},
// 企微沟通
sendWechat(val) {
console.log(val)
}
}
}
</script>
<style lang="scss" scoped>
.customer-box {
// width: 100%;
background: #ffffff;
box-shadow: 0px 2px 10px 0px rgba(224, 224, 224, 0.8);
border-radius: 4px;
margin: 0 16px 12px 16px;
}
.customer-title {
display: flex;
justify-content: space-between;
padding: 10px 12px;
}
.customer-name {
font-size: 14px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #282829;
line-height: 20px;
}
.customer-carnumber {
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #999999;
line-height: 16px;
}
.customer-info {
display: flex;
padding: 12px;
border-top: 1px solid #c3c3c3;
border-bottom: 1px solid #c3c3c3;
}
.customer-info-left,
.customer-info-right {
width: 50%;
}
.customer-marketing {
display: flex;
justify-content: space-around;
padding: 11px 0;
}
.customer-info-label {
display: flex;
}
.customer-info-name {
font-size: 12px;
width: 40%;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #999999;
line-height: 18px;
}
.customer-info-message {
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
line-height: 18px;
}
.customer-info-wechat {
color: #3975c6;
}
</style>
<template>
<div>
<van-popup v-model:show="show" round position="bottom">
<div class="name-title">
<div class="name-title-text">{{ selectFollowForm.name }}</div>
</div>
<van-form class="dialog-follow">
<van-cell-group inset>
<van-field name="跟进结果" label="跟进结果">
<template #input>
<div class="follow-list">
<div class="follow-list-item" v-for="item in followResultList" :key="item.id" @click="selectFollow(item)">
<div :class="item.id == selectFollowForm.followResultId ? 'follow-list-item-select' : ''">{{ item.title }}</div>
</div>
</div>
</template>
</van-field>
<van-field name="跟进备注" label="跟进备注" v-model="selectFollowForm.followTips" placeholder="输入备注" maxlength="200" />
<van-field name="switch" label="继续跟进">
<template #input>
<van-switch v-model="checked" size="24px" />
</template>
</van-field>
<van-field
v-show="selectFollowForm.followResultId == 1"
v-model="selectFollowForm.appointmentTime"
is-link
readonly
name="datetimePicker"
label="预约到店"
placeholder="请选择到店时间"
@click="showDate"
/>
<div v-show="showPicker">
<div class="datetime-box">
<div class="datetime-picker">
<div v-for="item in datePickList" :key="item.index" :class="['item', tabIndex == item.index ? 'active' : '']">
<div @click="selectDatetime(item)">{{ item.date }}</div>
</div>
</div>
<div @click="confirmAppointmentTime">确定</div>
</div>
<van-calendar v-show="!tabIndex" color="#3975C6" :show-title="false" :show-mark="false" :poppable="false" :show-confirm="false" :style="{ height: '500px' }" @select="selectDate" />
<van-datetime-picker v-show="tabIndex" type="time" @confirm="confirmTime" :min-hour="minHour" />
</div>
</van-cell-group>
<div class="btn-group">
<van-button block native-type="cancel" @click="cancel">取消</van-button>
<van-button block type="primary">提交</van-button>
</div>
</van-form>
</van-popup>
</div>
</template>
<script>
export default {
name: 'CustomerFollowPopup',
data() {
return {
// 招揽跟进弹框显示
isShow: false,
show: false,
tabIndex: 0,
followResultList: [
{
id: 1,
title: '预约到店'
},
{
id: 2,
title: '价格高'
},
{
id: 3,
title: '已保养'
},
{
id: 4,
title: '未接听'
},
{
id: 5,
title: '不感兴趣'
},
{
id: 6,
title: '空号'
},
{
id: 7,
title: '距离远'
},
{
id: 8,
title: '非本人'
},
{
id: 9,
title: '其他'
}
],
datePickList: [
{
index: 0,
date: ''
},
{
index: 2,
date: ''
}
],
selectFollowForm: {
name: '',
followResultId: '',
followTips: '',
appointmentTime: ''
},
// 展示预约到店时间
showPicker: false,
// 继续跟进按钮
checked: true,
// 当前日期
dayNow: '',
// 时间标签可选最小时间
minHour: ''
}
},
methods: {
init() {
this.show = true
// 获取当前时间
const date = new Date(new Date().getTime() + (parseInt(new Date().getTimezoneOffset() / 60) + 8) * 3600 * 1000)
this.formatterDate(date)
},
// 选择跟进结果
selectFollow(val) {
console.log(val)
this.selectFollowForm.followResultId = val.id
},
// 展示日历表
showDate() {
this.showPicker = !this.showPicker
},
// 时间选择tab切换
selectDatetime(item) {
console.log(item)
this.tabIndex = item.index
},
// 选择日期
selectDate(val) {
console.log(val)
this.formatterDate(val, 2)
},
// 选择时间
confirmTime(val) {
console.log(val)
this.datePickList[1].date = val
},
// 确定选择的日期和时间
confirmAppointmentTime() {
this.selectFollowForm.appointmentTime = this.datePickList[0].date + ' ' + this.datePickList[1].date
console.log(this.selectFollowForm.appointmentTime)
},
// 取消按钮
cancel() {
this.show = false
},
// 提交按钮
primary() {
// 如果选择标签为预约到店,判断日期和时间是否填了
},
// 日期格式转化
formatterDate(val, type) {
let date = new Date(val)
let y = date.getFullYear()
let m = date.getMonth() + 1
m = m < 10 ? '0' + m : m
let h = date.getHours()
h = h < 10 ? '0' + h : h
let d = date.getDate()
d = d < 10 ? '0' + d : d
const time = y + '-' + m + '-' + d
if (!type) {
this.dayNow = time
}
this.datePickList[0].date = time
if (this.dayNow == time) {
this.datePickList[1].date = h + 1 + ':00'
this.minHour = h + 1
return
}
this.datePickList[1].date = '09:00'
this.minHour = ''
}
}
}
</script>
<style lang="scss" scoped>
.name-title {
height: 48px;
&-text {
font-size: 16px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #333333;
line-height: 48px;
margin-left: 16px;
}
}
.follow-list {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
&-item {
width: 80px;
height: 28px;
margin-bottom: 8px;
background: #ffffff;
border-radius: 14px;
border: 1px solid #dadde0;
text-align: center;
line-height: 28px;
}
&-item-select {
color: #3975c6;
border-radius: 14px;
background: rgba(57, 117, 198, 0.1);
border: none;
}
}
.item {
width: 98px;
height: 24px;
font-size: 14px;
font-weight: 400;
color: #3975c6;
line-height: 24px;
flex: 1;
text-align: center;
margin: 1px;
}
.active {
background: #ffffff;
box-shadow: 0px 1px 2px 0px rgba(94, 97, 102, 0.2);
border-radius: 4px;
border: 1px solid rgba(0, 0, 0, 0.04);
color: #3975c6;
}
.van-button {
display: inline-block;
}
.datetime-box {
display: flex;
justify-content: space-around;
}
.datetime-picker {
height: 28px;
width: 202px;
display: flex;
background: #f7f7f7;
border-radius: 6px;
box-sizing: border-box;
}
.dialog-follow /deep/ .van-field__label {
width: 60px !important;
}
.dialog-follow /deep/ .van-field__control {
text-align: right;
}
.dialog-follow /deep/ .van-cell-group--inset {
margin: 0;
}
.btn-group /deep/ .van-button--block {
width: 50%;
}
.calender-tab /deep/ .van-tabs__nav--card {
width: 202px;
height: 28px;
background: #f7f7f7;
border-radius: 6px;
margin: 0;
}
/deep/ .van-field__control--custom {
justify-content: flex-end;
}
</style>
<template>
<div>
<van-action-sheet v-model:show="showCustomerDetail" cancel-text="关闭详情" close-on-click-action @cancel="onCancel">
<div class="popup-card">
<div class="name-title">
<div class="name-title-text">{{ customerList.name }}</div>
</div>
<!-- 客户信息 -->
<div class="customer-message">
<div class="customer-info-title">客户信息</div>
<div class="customer-info-box">
<div class="customer-info-item">
<div class="customer-info-item-title">VIN码</div>
<div class="customer-info-item-content">{{ customerList.vinCode }}</div>
</div>
<div class="customer-info-item">
<div class="customer-info-item-title">车系</div>
<div class="customer-info-item-content">{{ customerList.carBrand }}</div>
</div>
<div class="customer-info-item">
<div class="customer-info-item-title">车牌号码</div>
<div class="customer-info-item-content">{{ customerList.carNumber }}</div>
</div>
<div class="customer-info-item">
<div class="customer-info-item-title">购车日期</div>
<div class="customer-info-item-content">{{ customerList.buyCarDate }}</div>
</div>
<div class="customer-info-item">
<div class="customer-info-item-title">最近保养</div>
<div class="customer-info-item-content">{{ customerList.recentCare }}</div>
</div>
<div class="customer-info-item">
<div class="customer-info-item-title">人群分组</div>
<div class="customer-info-item-content">{{ customerList.customerGroup }}</div>
</div>
<div class="customer-info-item">
<div class="customer-info-item-title">企微账号</div>
<div class="customer-info-item-content">{{ customerList.wechatNumber }}</div>
</div>
</div>
</div>
<!-- 维保记录 -->
<div class="customer-message">
<div class="customer-info-title">维保记录</div>
<div class="stepItem" v-for="(item, index) in maintennceList" :key="index">
<div class="sprite-icon icon-maintant"></div>
<div class="stepBox">
<div class="stepBox-left">
<div class="stepBox-left-name">{{ item.name }}</div>
<div class="stepBox-left-title">
费用:
<span class="stepBox-left-content">{{ item.price }}</span>
</div>
<div class="stepBox-left-title">
跟进人:
<span class="stepBox-left-content">{{ item.followStaff }}</span>
</div>
</div>
<div class="stepBox-right">{{ item.date }}</div>
</div>
</div>
</div>
<!-- 跟进记录 -->
<div class="record">
<div class="customer-info-title">跟进记录</div>
<div class="stepItem" v-for="(item, index) in recordList" :key="index">
<div class="sprite-icon icon-followRecord"></div>
<div class="stepBox">
<div class="stepBox-left">
<div class="stepBox-left-name">{{ item.name }}</div>
<div class="stepBox-left-title">
预约时间:
<span class="stepBox-left-content">{{ item.recordDate ? item.recordDate : '-' }}</span>
</div>
<div class="stepBox-left-title">
备注:
<span class="stepBox-left-content">{{ item.tips ? item.tips : '-' }}</span>
</div>
</div>
<div class="stepBox-right">{{ item.date }}</div>
</div>
</div>
</div>
</div>
</van-action-sheet>
</div>
</template>
<script>
export default {
name: 'CustomerInfoPopup',
data() {
return {
// 客户信息弹出层展示
showCustomerDetail: false,
// 客户信息表
customerList: {
id: 1,
name: '徐妹妹',
vinCode: 'LFMAYACC5M029512',
carBrand: '兰博基尼',
carNumber: '粤B 88888',
buyCarDate: '2021-04-20',
recentCare: '2022-05-16',
customerGroup: '定保招揽 N-6',
wechatNumber: '未添加',
careRecord: [
{
type: '保养项目保养项目AAA',
cost: '240元',
followStaff: 'kuangge',
date: '05-28 16:00'
},
{
type: '保养项目保养项目保养项目BB',
cost: '240元',
followStaff: 'kuangge',
date: '05-28 16:00'
}
],
followRecord: [
{
type: '预约到店',
oppointmentTime: '2022-05-21',
tips: '',
date: '05-28 16:00'
},
{
type: '未接听',
oppointmentTime: '',
tips: '',
date: '05-28 16:00'
}
]
},
// 维保记录表
maintennceList: [
{
name: '保养项目A',
price: '240元',
followStaff: '续梅厄米',
date: '05-28 16:00'
},
{
name: '保养项目B',
price: '240元',
followStaff: '续梅厄米',
date: '05-28 16:00'
}
],
// 跟进记录表
recordList: [
{
name: '预约到店',
recordDate: '2022-05-21',
tips: '续梅厄米',
date: '05-28 16:00'
},
{
name: '未接听',
recordDate: '',
tips: '续梅厄米',
date: '05-28 16:00'
}
]
}
},
methods: {
init() {
this.showCustomerDetail = true
},
// 关闭弹窗
onCancel() {
this.showCustomerDetail = false
}
}
}
</script>
<style lang="scss" scoped>
.popup-card {
padding: 16px;
}
.name-title {
padding-bottom: 12px;
&-text {
font-size: 16px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #333333;
line-height: 24px;
}
}
.customer-message {
padding: 16px 0;
border-bottom: 1px solid #c3c3c3;
}
.customer-info-title {
font-size: 16px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
line-height: 22px;
}
.customer-info-item {
display: flex;
justify-content: space-between;
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
line-height: 22px;
padding-top: 8px;
&-title {
color: #666666;
}
&-content {
color: #333333;
}
}
.record {
margin-top: 16px;
}
.stepItem {
display: flex;
justify-content: space-between;
position: relative;
padding-bottom: 5px;
margin-top: 17px;
}
.stepItem:not(:last-of-type):after {
content: '';
font-size: 0;
height: 80px;
width: 1px;
background: #e6e8eb;
position: absolute;
left: 8px;
top: 4px;
}
.stepBox {
width: 90%;
display: flex;
justify-content: space-between;
}
.stepBox-left {
&-name {
font-size: 14px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #333333;
line-height: 22px;
}
&-title {
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #999999;
line-height: 18px;
}
&-content {
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #330000;
line-height: 18px;
}
}
.stepBox-right {
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #999999;
line-height: 18px;
}
/deep/ .van-action-sheet {
max-height: 100%;
}
</style>
...@@ -48,7 +48,10 @@ import { ...@@ -48,7 +48,10 @@ import {
ShareSheet, ShareSheet,
Overlay, Overlay,
loading, loading,
DatetimePicker DatetimePicker,
Toast,
Switch,
Form
} from 'vant' } from 'vant'
export const components = [ export const components = [
Button, Button,
...@@ -91,5 +94,8 @@ export const components = [ ...@@ -91,5 +94,8 @@ export const components = [
ShareSheet, ShareSheet,
Overlay, Overlay,
loading, loading,
DatetimePicker DatetimePicker,
Toast,
Switch,
Form
] ]
...@@ -95,14 +95,14 @@ const pages = { ...@@ -95,14 +95,14 @@ const pages = {
{ {
name: 'index', name: 'index',
meta: { meta: {
title: '招揽跟进', title: '查看客户详情',
backgroundColor: '#F7F7F7' backgroundColor: '#F7F7F7'
} }
}, },
{ {
name: 'lookCustomer', name: 'customer',
meta: { meta: {
title: '查看客户', title: '查看客户详情',
backgroundColor: '#F7F7F7' backgroundColor: '#F7F7F7'
} }
}, },
...@@ -114,13 +114,6 @@ const pages = { ...@@ -114,13 +114,6 @@ const pages = {
} }
}, },
{ {
name: 'customer',
meta: {
title: '一键营销',
backgroundColor: '#F7F7F7'
}
},
{
name: 'succeed', name: 'succeed',
meta: { meta: {
title: '招揽跟进', title: '招揽跟进',
...@@ -133,6 +126,7 @@ const pages = { ...@@ -133,6 +126,7 @@ const pages = {
const redirect = '' const redirect = ''
let routes = [] let routes = []
const keepAlives = [] const keepAlives = []
console.log(Object.keys(pages))
Object.keys(pages).map(parent => { Object.keys(pages).map(parent => {
pages[parent].map(val => { pages[parent].map(val => {
const isIndex = parent == redirect && val.name == 'index' const isIndex = parent == redirect && val.name == 'index'
......
<template>
<div>
<van-tabs v-model="tabIndex" sticky>
<van-tab :title="'未送达(' + customerInfo.length + ')'">
<div class="reason">
<div>未送达可能原因:</div>
<div>1. 客户开启消息免打扰,消息发送失败;</div>
<div>2. 群发次数达到上限,上限次数为每个客户每天仅可接收1条群发消息。(系统将连续重试3天)</div>
</div>
<customer-card :customerInfo="customerInfo"></customer-card>
</van-tab>
<van-tab :title="'已送达(' + deliveredNum + ')'">
<div class="statistic-pic"></div>
<select-bar :index="3" :list="selectBarList"></select-bar>
<customer-card :customerInfo="customerInfo"></customer-card>
</van-tab>
</van-tabs>
</div>
</template>
<script>
import SelectBar from '../../components/SelectBar.vue'
export default {
components: { SelectBar },
data() {
return {
tabIndex: 0,
deliveredNum: 0,
selectBarList: ['已送达', '已查看', '已领取', '已到店'],
customerInfo: [
{
id: 1,
name: '林先生',
carNumber: '月A8888',
carBrand: 'BMW',
result: '未接听',
wechatMarketing: '一查看',
joinWechat: '美女',
date: '05-07 15:30',
updateDate: '05-07 15:30',
telNumber: ''
},
{
id: 2,
name: 'kuang先生',
carNumber: '',
carBrand: 'BMW',
result: '未接听',
wechatMarketing: '一查看',
joinWechat: '美女',
date: '05-07 15:30',
updateDate: '05-07 15:30',
telNumber: '18818188989'
},
{
id: 3,
name: 'xu先生',
carNumber: '粤B 8888',
carBrand: '兰博基尼',
result: '未接听',
wechatMarketing: '一查看',
joinWechat: '美女',
date: '05-07 15:30',
updateDate: '05-07 15:30',
telNumber: '18818188989'
}
]
}
}
}
</script>
<style lang="scss" scoped>
.reason {
padding: 16px;
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(47, 64, 86, 0.7);
line-height: 18px;
}
.statistic-pic {
width: 100%;
height: 172px;
background: #ffffff;
box-shadow: 0px 1px 0px 0px rgba(233, 233, 233, 1);
}
/deep/ .van-tabs__line {
background-color: #3975c6;
}
</style>
...@@ -4,52 +4,54 @@ const defaultSettings = require('./src/config/conf.js') ...@@ -4,52 +4,54 @@ const defaultSettings = require('./src/config/conf.js')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const resolve = dir => path.join(__dirname, dir) const resolve = dir => path.join(__dirname, dir)
// page title // page title
const name = defaultSettings.title || 'vue mobile template' const name = defaultSettings.title || 'vue mobile template'
// 生产环境,测试和正式 // 生产环境,测试和正式
const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV) const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV)
// externals // externals
// const externals = { // const externals = {
// vue: 'Vue', // vue: 'Vue',
// 'vue-router': 'VueRouter', // 'vue-router': 'VueRouter',
// vuex: 'Vuex', // vuex: 'Vuex',
// vant: 'vant', // vant: 'vant',
// axios: 'axios' // axios: 'axios'
// } // }
// CDN外链,会插入到index.html中 // CDN外链,会插入到index.html中
// const cdn = { // const cdn = {
// // 开发环境 // // 开发环境
// dev: { // dev: {
// css: [], // css: [],
// js: [] // js: []
// }, // },
// // 生产环境 // // 生产环境
// build: { // build: {
// css: ['https://cdn.jsdelivr.net/npm/vant@2.4.7/lib/index.css'], // css: ['https://cdn.jsdelivr.net/npm/vant@2.4.7/lib/index.css'],
// js: [ // js: [
// 'https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js', // 'https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js',
// 'https://cdn.jsdelivr.net/npm/vue-router@3.1.5/dist/vue-router.min.js', // 'https://cdn.jsdelivr.net/npm/vue-router@3.1.5/dist/vue-router.min.js',
// 'https://cdn.jsdelivr.net/npm/axios@0.19.2/dist/axios.min.js', // 'https://cdn.jsdelivr.net/npm/axios@0.19.2/dist/axios.min.js',
// 'https://cdn.jsdelivr.net/npm/vuex@3.1.2/dist/vuex.min.js', // 'https://cdn.jsdelivr.net/npm/vuex@3.1.2/dist/vuex.min.js',
// 'https://cdn.jsdelivr.net/npm/vant@2.4.7/lib/index.min.js' // 'https://cdn.jsdelivr.net/npm/vant@2.4.7/lib/index.min.js'
// ] // ]
// } // }
// } // }
/** /**
* 雪碧图插件 * 雪碧图插件
*/ */
const SpritesmithPlugin = require('webpack-spritesmith') const SpritesmithPlugin = require('webpack-spritesmith')
const spritesmithFunction = data => { const spritesmithFunction = data => {
let { spritesheet, sprites } = data let { spritesheet, sprites } = data
let shared = `.sprite-icon { background-image: url(${data.sprites[0].image});background-size: ${spritesheet.width / 2}px ${spritesheet.height / 2}px;}` let shared = `.sprite-icon { background-image: url(${data.sprites[0].image});background-size: ${spritesheet.width / 2}px ${spritesheet.height / 2}px;}`
let perSprite = sprites.map(sprite => { let perSprite = sprites
.map(sprite => {
let { name, width, height, offset_x, offset_y } = sprite let { name, width, height, offset_x, offset_y } = sprite
return `.icon-${name} { width: ${width / 2}px; height: ${height / 2}px; background-position: ${offset_x / 2}px ${offset_y / 2}px;}` return `.icon-${name} { width: ${width / 2}px; height: ${height / 2}px; background-position: ${offset_x / 2}px ${offset_y / 2}px;}`
}).join('\n') })
.join('\n')
return `${shared}\n${perSprite}` return `${shared}\n${perSprite}`
} }
module.exports = { module.exports = {
publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-main-test/', // 署应用包时的基本 URL。 vue-router hash 模式使用 publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-main-kuangyq/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-main/', // 署应用包时的基本 URL。 vue-router hash 模式使用 // publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-main/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-attachment-customer/', // 署应用包时的基本 URL。 vue-router hash 模式使用 // publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-attachment-customer/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: '/dj-scrm-wx-work-attachment-customer/', // 署应用包时的基本 URL。 vue-router history模式使用 // publicPath: '/dj-scrm-wx-work-attachment-customer/', // 署应用包时的基本 URL。 vue-router history模式使用
...@@ -106,13 +108,16 @@ module.exports = { ...@@ -106,13 +108,16 @@ module.exports = {
image: path.resolve(__dirname, './src/assets/images/sprite.png'), image: path.resolve(__dirname, './src/assets/images/sprite.png'),
// 生成SCSS // 生成SCSS
css: [ css: [
[path.resolve(__dirname, './src/assets/css/sprite.scss'), { [
path.resolve(__dirname, './src/assets/css/sprite.scss'),
{
format: 'function_based_template' format: 'function_based_template'
}] }
]
] ]
}, },
customTemplates: { customTemplates: {
'function_based_template': spritesmithFunction, function_based_template: spritesmithFunction
}, },
//background引用路径 //background引用路径
apiOptions: { apiOptions: {
...@@ -174,9 +179,11 @@ module.exports = { ...@@ -174,9 +179,11 @@ module.exports = {
* 打包分析 * 打包分析
*/ */
if (IS_PROD) { if (IS_PROD) {
config.plugin('webpack-report').use(BundleAnalyzerPlugin, [{ config.plugin('webpack-report').use(BundleAnalyzerPlugin, [
{
analyzerMode: 'static' analyzerMode: 'static'
}]) }
])
} }
config config
// https://webpack.js.org/configuration/devtool/#development // https://webpack.js.org/configuration/devtool/#development
...@@ -186,10 +193,12 @@ module.exports = { ...@@ -186,10 +193,12 @@ module.exports = {
config config
.plugin('ScriptExtHtmlWebpackPlugin') .plugin('ScriptExtHtmlWebpackPlugin')
.after('html') .after('html')
.use('script-ext-html-webpack-plugin', [{ .use('script-ext-html-webpack-plugin', [
{
// 将 runtime 作为内联引入不单独存在 // 将 runtime 作为内联引入不单独存在
inline: /runtime\..*\.js$/ inline: /runtime\..*\.js$/
}]) }
])
.end() .end()
config.optimization.splitChunks({ config.optimization.splitChunks({
chunks: 'all', chunks: 'all',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!