vue-cli init

This commit is contained in:
2025-08-15 16:25:44 +08:00
parent e81805b4c0
commit 8e22afd798
590 changed files with 103286 additions and 213 deletions
@@ -0,0 +1,223 @@
<template>
<view>
<scroll-view scroll-y="true" :style="{height: scrollHeight}" @scrolltolower="" refresher-enabled
:refresher-threshold="200" :refresher-triggered="triggered" refresher-background="gray"
@refresherrefresh="" @refresherrestore="">
<view v-if="list.length > 0">
<view v-for="(item, index) in list" :key="index" @click="CardClickFun(item)">
<BillBusinessCard :item="item" :isSelect="isSelect" :index="index" @cxGetDataFun=""> </BillBusinessCard>
</view>
<getMore :isMore="isMore" nullMsg="已加载全部~"></getMore>
<view class="h200"></view>
</view>
</scroll-view>
</view>
</template>
<script>
let that = this;
import dataNull from '@/components/dataNull/dataNull.vue'
import BillBusinessCard from '../../../components/card/baseDataBillBusinessList.vue'
import util from '../../../common/util.js';
export default {
components: {
dataNull,
BillBusinessCard
},
data() {
return {
triggered: false,
TypeStatus: 0,
TypeNo: '',
isMore: true,
pageIndex: 1,
scrollHeight: '667px',
pageType: '',
isSelect: false
}
},
onLoad(e) {
that = this;
let khsxList = JSON.stringify(khsxData);
that.sxList = JSON.parse(khsxList);
let obj = {};
this.CustomerTypes = e.type;
this.pageType = e.type;
console.log(">>>" + e.type);
if (e.type) {
that.isSelect = true;
}
this.selectBillBusinessFun();
},
onBackPress() {
uni.$off('deleteKhFun', that.deleteKhFun)
uni.$off('updateListByIndex', that.updateListByIndex)
uni.$off('addItemInListFun', that.addItemInListFun)
uni.$off('cxGetDataFun', that.cxGetDataFun)
},
methods: {
selectBillBusinessFun: function() {
uni.request({
url: util.apiurl + 'rest/db/opensql',
data: {
token: getApp().globalData.Token,
format: 'json',
data: {
db_name: getApp().globalData.AppDBName,
sql_command_id: 'APP.GetBillBusinessList',
params: [{
name: 'TypeStatus',
value: this.TypeStatus
}, {
name: 'TypeNo',
value: this.this
}]
},
},
success: (res) => {
this.triggered = false;
let data = res.data.data;
if (that.pageIndex == 1) {
that.list = [];
}
if (res.data == 20) {
that.pageIndex += 1;
that.isMore = true;
} else {
that.isMore = false;
}
that.list = that.list.concat(data);
},
})
},
//点击方法
CardClickFun: function(item) {
uni.$emit('bjdKehuBindFun', {
CustomerID: item.CustomerID,
CustomerName: item.CustomerName,
PlanDepartmentID: item.PlanDepartmentID,
PlanDepartmentName: item.PlanDepartmentName,
SaleUserID: item.SaleUserID,
SaleUserName: item.SaleUserName,
Remark: item.Remark,
CustomerAddress: item.CustomerAddress,
CustomerPhone: item.CustomerPhone,
CustomerLinkName: item.CustomerLinkName,
})
uni.navigateBack();
},
}
}
</script>
<style>
page {
background-color: #F8F8F8;
}
.card {
width: 698rpx;
padding: 26rpx 26rpx 10rpx;
margin: 32rpx 26rpx;
box-sizing: border-box;
border-radius: 8rpx;
box-shadow: #d8d8d8 0px 0px 16rpx;
position: relative;
background-color: #FFFFFF;
}
.genjinBtn {
position: absolute;
right: 26rpx;
top: 26rpx;
background-color: #007AFF;
color: #FFFFFF;
text-align: center;
padding: 6rpx 16rpx;
border-radius: 6rpx;
font-size: 14px;
}
.genjinBtn:active {
background-color: #13B8FF;
}
.topRow {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.txView {
width: 128rpx;
height: 128rpx;
border-radius: 50%;
overflow: hidden;
margin-right: 26rpx;
}
.txViewImg {
width: 100%;
height: 100%;
}
.info {
width: 492rpx;
font-size: 15px;
color: #000;
}
.name {
font-size: 16px;
margin-bottom: 8rpx;
color: #000000;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: bold;
}
.bottomRow {
width: 100%;
padding-top: 16rpx;
display: flex;
align-items: center;
justify-content: space-between;
border-top: 1rpx solid #f0f0f0;
font-size: 15px;
color: #007AFF;
}
.lxRow {
display: flex;
align-items: center;
}
.lxRow>image {
width: 52rpx;
height: 52rpx;
margin-right: 26rpx;
}
.bqRow {
display: flex;
align-items: center;
flex-wrap: wrap;
}
.bqRow>text {
font-size: 14px;
color: #888888;
}
.bqRow>view {
padding: 6rpx 16rpx;
font-size: 14px;
background-color: rgba(255, 85, 127, 0.1);
color: #ff5500;
border-radius: 10rpx;
margin: 6rpx 26rpx 20rpx 0;
}
</style>
+475
View File
@@ -0,0 +1,475 @@
<template>
<view>
<view class="flex-white-plr26 ptb10 mt32 bdb_f5">
<text class="mr26">产品名称
<text class="redXingh">*</text>
</text>
<u-input v-model="pName" placeholder="请在此输入产品名称" />
</view>
<view @click="pickerSelectFun('产品单位')" class="flex-white-plr26 ptb10 bdb_f5">
<text class="mr26">产品单位
<text class="redXingh">*</text>
</text>
<u-input v-model="unit" placeholder="请在此输入产品单位" />
</view>
<view class="flex-white-plr26 ptb10 bdb_f5">
<text class="mr26">产品价格
<text class="redXingh">*</text>
</text>
<u-input v-model="price" type="number" placeholder="请在此输入产品价格" />
</view>
<view @click="pickerSelectFun('产品类型')" class="flex-white-plr26 ptb20 bdb_f5">
<text class="mr26">产品类型
<text class="redXingh">*</text>
</text>
<view :class="flName ? '' : 'cBlack'">
{{flName ? flName : '请选择'}}
<u-icon class="ml26" name="arrow-right" size="40" color="#888888"></u-icon>
</view>
</view>
<view @click="pickerSelectFun('上下架')" class="flex-white-plr26 ptb20 bdb_f5">
<text class="mr26">是否上下架
<text class="redXingh">*</text>
</text>
<view :class="isSxJ ? '' : 'cBlack'">
{{isSxJ ? isSxJ : '请选择'}}
<u-icon class="ml26" name="arrow-right" size="40" color="#888888"></u-icon>
</view>
</view>
<view class="flex-white-plr26 ptb10 bdb_f5">
<text class="mr26">产品销量</text>
<u-input v-model="salesNum" type="number" placeholder="请在此输入产品销量" />
</view>
<view class="flex-white-plr26 ptb10 bdb_f5">
<text class="mr26">产品库存</text>
<u-input v-model="stock" type="number" placeholder="请在此输入产品库存" />
</view>
<view class="flex-white-plr26 ptb10 bdb_f5">
<text class="mr26">产品编码</text>
<u-input v-model="code" placeholder="请在此输入产品编码" />
<u-icon @click="scanFun" class="ml26" name="scan" size="44" color="#007aff"></u-icon>
</view>
<view class="flex-white-plr26-column ptb20 mt32 bdb_f5">
<view style="margin-bottom: 8rpx;">
<text>产品简述</text>
</view>
<u-input v-model="describe" type="textarea" :border="true" :height="100" :auto-height="true" />
</view>
<view class="flex-white-plr26-column ptb20 mt32 bdb_f5">
<view style="margin-bottom: 8rpx; display: flex; align-items: center;">
<text>产品参数</text>
<u-icon @click="addCsFun" name="plus-circle-fill" color="#007aff" size="50" style="margin-left: 16rpx;">
</u-icon>
</view>
<view class="canshuInputRow" v-for="(item, index) in cpCsList" :key="index">
<view class="csInput1">
<u-input v-model="item.csName" :border="true" placeholder="参数名称" />
</view>
<view class="csInput2">
<u-input v-model="item.csJieShao" :border="true" placeholder="请在此输入参数介绍" />
</view>
<u-icon @click="deleteCpCsFun(index)" name="close-circle-fill" size="50" color="#ff0000"></u-icon>
</view>
</view>
<view class="flex-white-plr26-column ptb20 mt32">
<view style="margin-bottom: 8rpx;">产品封面图(1张)</view>
<u-upload @on-choose-complete="uploadFmChangeFun" @on-remove="fmtRemoeFun" :size-type="siziType" :show-progress="false"
:file-list="cpFmtList" :max-size="5 * 1024 * 1024" max-count="1" :auto-upload="false"></u-upload>
</view>
<view class="flex-white-plr26-column ptb20 mt32">
<view style="margin-bottom: 8rpx;">产品轮播图(最多上传5张)</view>
<u-upload @on-choose-complete="uploadLbtChangeFun" @on-list-change="fileChangeFun" @on-remove="lbtRemoeFun" :size-type="siziType" :show-progress="false"
:file-list="cpLbtList" :max-size="5 * 1024 * 1024" max-count="5" :auto-upload="false"></u-upload>
</view>
<view class="flex-white-plr26-column ptb20 mt32">
<view style="margin-bottom: 8rpx;">产品详情图(最多上传9张)</view>
<u-upload @on-choose-complete="uploadXqChangeFun" @on-remove="xqtRemoeFun" :size-type="siziType" :show-progress="false"
:file-list="cpXqtList" :max-size="5 * 1024 * 1024" max-count="9" :auto-upload="false"></u-upload>
</view>
<!--提交按钮-->
<view class="submitView">
<u-button v-if="!pageType" type="primary" class="submitBtn" :ripple="true" ripple-bg-color="#909399"
@click="addXgFun">提交</u-button>
<u-button v-if="pageType == 'update'" type="primary" class="submitBtn" :ripple="true"
ripple-bg-color="#909399" @click="addXgFun">保存</u-button>
</view>
<!--组件-->
<u-select v-model="selectShow" :list="selectList" @confirm="selectConfirmFun"></u-select>
<!--图片上传方法组件-->
<uploadImg v-if="ppImgShow" :ppList="ppList" :ppUrls="ppUrls" @confirmPopupFun="confirmPopupFun"></uploadImg>
</view>
</template>
<script>
let that = '';
import {
getNowDate
} from '@/static/utils/date.js'
import {
uploadImgFun
} from '@/static/utils/upload.js'
import uploadImg from '@/components/upload/uploadImg'
import { crmChanpinApi, crmCpClassifyApi, fileApi } from '@/static/utils/api.js'
export default {
components: {
uploadImg
},
data() {
return {
selectShow: false,
selectList: [],
selectType: '',
pName: '',
price: '',
salesNum: '',
stock: '',
code: '',
flName: '',
cpFlId: '',
unit: '',
isSxJ: '上架',
describe: '',
action: 'http://www.example.com/upload',
fileList: [],
classify: [],
cpLbt: [],
cpXqt: [],
cpFmt: [],
cpLbtList: [],
cpXqtList: [],
cpFmtList: [],
cpCsList: [],
pageType: '',
siziType: ['compressed'],
ppImgShow: false,
uploadType: '',
ppList: [],
ppUrls: [],
xgCpInfo: {}
}
},
onLoad(e) {
that = this;
if (e.type == 'update') {
uni.setNavigationBarTitle({
title: '修改产品信息'
})
that.pageType = e.type;
that.setDataFun();
}
that.getClassifyFun();
},
methods: {
// 查询分类方法
getClassifyFun: function() {
uni.showLoading({
title: '加载中...',
mask: true
})
let reqData = {
action: 'getFlList',
params: {
matchObj: {
isShow: true
}
}
}
crmCpClassifyApi(reqData)
.then(res => {
let data = res.result.data;
if (data && data.length > 0) {
if(that.pageType != 'update') {
that.flName = data[0].flName;
that.cpFlId = data[0]._id;
}
that.classify = data;
} else {
uni.showModal({
title: '提示',
content: '当前暂未设置产品分类,请先添加产品分类!',
success(res) {
if (res.confirm) {
uni.redirectTo({
url: './classify?pageType=add'
})
}
}
})
}
})
},
// 选择定位地点
chooseAddrFun: function() {
uni.chooseLocation({
success: function(res) {
that.gjAddr = res.address;
}
});
},
// 展示相应数据选择框
pickerSelectFun: function(str) {
if (str == '产品类型') {
let classify = that.classify;
let arr = [];
for (var i = 0; i < classify.length; i++) {
arr.push({
value: classify[i]._id,
_id: classify[i]._id,
label: classify[i].flName
})
}
that.selectList = arr;
} else if (str == '上下架') {
that.selectList = [{
value: 0,
b: true,
label: '上架'
},
{
value: 1,
b: false,
label: '下架'
}
]
}
that.selectShow = true;
that.selectType = str;
},
// 选择框选中事件
selectConfirmFun: function(e) {
if (that.selectType == '产品类型') {
that.flName = e[0].label;
that.cpFlId = e[0]._id || e[0].value;
} else if (that.selectType == '上下架') {
that.isSxJ = e[0].label;
}
},
// 当内部文件列表被加入文件、移除文件,或手动调用clear方法时触发
uploadFmChangeFun: function(list) {
that.uploadType = 'fmt';
that.ppList = list;
that.ppUrls = that.cpFmt;
that.ppImgShow = true;
},
// 封面图删除
fmtRemoeFun: function(e) {
let arr = that.cpFmt.splice(e, 1);
that.deleteFun(arr)
},
fileChangeFun: function(e) {
},
// 上传轮播图
uploadLbtChangeFun: function(list) {
that.uploadType = 'lbt';
that.ppList = list;
that.ppUrls = that.cpLbt;
that.ppImgShow = true;
},
// 轮播图删除
lbtRemoeFun: function(e) {
let arr = that.cpLbt.splice(e, 1);
that.deleteFun(arr)
},
// 上传详情图
uploadXqChangeFun: function(list) {
that.uploadType = 'xqt';
that.ppList = list;
that.ppUrls = that.cpXqt;
that.ppImgShow = true;
},
// 详情图删除
xqtRemoeFun: function(e) {
let arr = that.cpXqt.splice(e, 1);
that.deleteFun(arr)
},
// popup图片上传完成回调
confirmPopupFun: function(e) {
that.ppImgShow = false;
if (that.uploadType == 'lbt') {
that.cpLbt = e;
} else if (that.uploadType == 'xqt') {
that.cpXqt = e;
} else {
that.cpFmt = e;
}
},
// 删除文件云函数
deleteFun: function(list) {
let reqData = {
action: 'delete',
params: {
fileList: [list[0].fileId]
}
}
fileApi(reqData)
.then(res => {
})
},
scanFun: function() {
uni.scanCode({
success(res) {
that.code = res.result;
}
})
},
// 产品添加方法
addXgFun: function() {
let reqObj = {
req: {
pName: that.pName,
price: that.price,
unit: that.unit,
cpFlId: that.cpFlId,
isSxJ: that.isSxJ == '上架' ? true : false,
code: that.code,
describe: that.describe,
cpCsList: that.cpCsList,
cpLbtList: that.cpLbt,
cpXqtList: that.cpXqt,
cpFmtList: that.cpFmt,
salesNum: that.salesNum,
stock: that.stock
}
}
if (!that.pName) {
uni.$myModalFun('产品名称不能为空,请输入!')
return
}
if (!that.price) {
uni.$myModalFun('产品价格不能为空,请输入!')
return
}
if (!that.unit) {
uni.$myModalFun('产品单位不能为空,请输入!')
return
}
let action = 'add';
let time = new Date().getTime();
if (that.pageType == 'update') {
action = 'update'
reqObj._id = that.xgCpInfo._id;
reqObj.req.update_date = time;
reqObj.req.updateUid = uni.$userInfo._id;
uni.showLoading({
title: '修改中...'
})
} else {
reqObj.req.create_date = time;
reqObj.req.update_date = time;
reqObj.req.cjRenId = uni.$userInfo._id;
reqObj.req.updateUid = uni.$userInfo._id;
uni.showLoading({
title: '提交中...'
})
}
let reqData = {
action: action,
params: reqObj
}
crmChanpinApi(reqData)
.then(res => {
if (action == 'update') {
uni.showToast({
title: '产品修改成功',
icon: 'none',
duration: 1000
})
} else {
that.pageType = 'update';
that.xgCpInfo._id = res.result.id;
let item = reqObj.req;
item._id = res.result.id;
uni.$cpDetail = item;
uni.showToast({
mask: true,
title: '产品新增成功',
duration: 1000
})
setTimeout(() => {
uni.redirectTo({
url: './cpDetail'
})
}, 1000)
}
})
},
// 新增产品参数
addCsFun: function() {
that.cpCsList = that.cpCsList.concat({
csName: '',
csJieShao: ''
})
},
// 删除产品参数
deleteCpCsFun: function(iii) {
that.cpCsList.splice(iii, 1)
},
// 设置信息
setDataFun: function() {
let obj = uni.$cpDetail;
that.xgCpInfo = obj;
that.pName = obj.pName
that.price = obj.price;
that.unit = obj.unit;
that.flName = obj.flName;
that.cpFlId = obj.cpFlId;
that.isSxJ = obj.isSxJ ? '上架' : '下架';
that.code = obj.code;
that.describe = obj.describe;
that.cpCsList = obj.cpCsList;
that.cpLbtList = obj.cpLbtList || [];
that.cpXqtList = obj.cpXqtList || [];
that.cpFmtList = obj.cpFmtList || [];
that.cpLbt = obj.cpLbtList || [];
that.cpXqt = obj.cpXqtList || [];
that.cpFmt = obj.cpFmtList || [];
that.salesNum = obj.salesNum || '';
that.stock = obj.stock || '';
}
}
}
</script>
<style>
page {
background-color: #F8F8F8;
padding-bottom: 260rpx;
}
.u-radio {
width: 200rpx !important;
}
.submitView {
width: 100%;
padding: 16rpx 0 26rpx;
background-color: #FFFFFF;
position: fixed;
bottom: 0;
left: 0;
border-top: 1rpx solid #f1f1f1;
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
}
.submitBtn {
width: 666rpx;
}
.canshuInputRow {
display: flex;
justify-content: space-between;
margin-top: 16rpx;
}
.canshuInputRow>.csInput1 {
width: 36%;
}
.canshuInputRow>.csInput2 {
width: 50%;
}
</style>
+512
View File
@@ -0,0 +1,512 @@
<template>
<view>
<topDropdown :isSxShow="true" :dropdown1="dropdown1" dropdown2="上架中" :options1="options1" :options2="isSjList" :optionsSx="sxList" searchUrl="./searchAdmin" @dropDownFun1="dropDownFun1" @dropDownFun2="dropDownFun2" @optionSxFun="optionSxFun">
</topDropdown>
<dataNull v-if="list.length == 0" src="/static/img/chahua/dataNullXz.png" title="暂无相关产品"
title1="请添加或者更换查询条件"></dataNull>
<scroll-view v-else scroll-y="true" :style="{height: scrollHeight}" @scrolltolower="getChanPinFun"
refresher-enabled :refresher-threshold="200" :refresher-triggered="triggered" refresher-background="gray"
@refresherrefresh="onRefresh" @refresherrestore="onRestore">
<view v-for="(item, index) in list" :key="index" @click="cardClick(item)">
<view v-if="item.cpFmtList && item.cpFmtList.length > 0" class="myCard2">
<view class="leftImg">
<u-image height="160" width="160" border-radius="26" :src="item.cpFmtList[0].url"></u-image>
</view>
<view class="rightView">
<view class="cardTopName1">{{item.pName}}</view>
<view v-if="item.salesNum || item.stock" class="xlKcClass">
<text v-if="item.salesNum">销量: {{item.salesNum}}</text>
<text v-if="item.stock">库存: {{item.stock}}</text>
</view>
<view class="cardRow1">
<text class="redColor">¥{{item.price}}</text>/{{item.unit}}
</view>
<view class="rowBtn">
<u-button type="primary" :plain="true" class="cpBtn" size="mini" @tap.stop="setCpFun(item)">
编辑产品
</u-button>
<u-button type="warning" :plain="true" class="cpBtn" size="mini"
@click="cpsxjFun(item, index)">{{item.isSxJ == true ? '下架' : '上架'}}</u-button>
<u-button type="error" :plain="true" class="cpBtn" size="mini"
@tap.stop="deleteCpFun(item, index)">
删除</u-button>
</view>
</view>
</view>
<view v-else class="myCard">
<view class="cardTopName">产品名称:{{item.pName}}</view>
<view class="cardRow">
<view>产品状态:</view>
<view>{{item.isSxJ ? '上架中' : '下架'}}</view>
</view>
<view class="cardRow">
<view>产品价格:</view>
<view><text class="redColor">¥{{item.price}}</text>/{{item.unit}}</view>
</view>
<view class="cardRow">
<view>产品类型:</view>
<view>{{item.flName}}</view>
</view>
<view class="cardRow" v-if="item.salesNum">
<view>产品销量:</view>
<view>{{item.salesNum}}</view>
</view>
<view class="cardRow" v-if="item.stock">
<view>产品库存:</view>
<view>{{item.stock}}</view>
</view>
<view class="cardRow" v-if="item.describe">
<view>产品简述:</view>
<view>{{item.describe}}</view>
</view>
<view class="rowBtn">
<u-button type="primary" :plain="true" class="cpBtn" size="mini" @tap.stop="setCpFun(item)">编辑产品
</u-button>
<u-button type="warning" :plain="true" class="cpBtn" size="mini" @click="cpsxjFun(item, index)">
{{item.isSxJ == true ? '下架' : '上架'}}</u-button>
<u-button type="error" :plain="true" class="cpBtn" size="mini"
@tap.stop="deleteCpFun(item, index)">
删除</u-button>
</view>
</view>
</view>
<getMore :isMore="isMore" class="h200"></getMore>
</scroll-view>
<addBtn url="./addCp"></addBtn>
</view>
</template>
<script>
let that = '';
import dataNull from '@/components/dataNull/dataNull.vue'
import addBtn from '@/components/addBtn/addBtn.vue'
import getMore from '@/components/getMore/getMore.vue'
import topDropdown from '@/components/topDropdown/topDropdown.vue'
import { crmChanpinApi, crmCpClassifyApi, fileApi } from '@/static/utils/api.js'
export default {
components: {
dataNull,
addBtn,
getMore,
topDropdown
},
data() {
return {
triggered: false,
pageIndex: 1,
list: [],
classify: [],
dropdown1: '产品分类',
cpClassify: '',
cpFlId: '',
isMore: true,
scrollHeight: '667px',
sjType: '上架中',
options1: [],
isSjList: [{
value: 0,
label: '上架中'
},
{
value: 1,
label: '下架'
},
],
isSxJ: true,
sxList: [{
title: '创建时间排序',
field: 'create_date',
current: '',
arr: [
'降序',
'升序'
]
},
{
title: '修改时间排序',
field: 'update_date',
current: '',
arr: [
'降序',
'升序'
]
},
{
title: '销量排序',
field: 'salesNum',
current: '',
arr: [
'降序',
'升序'
]
},
{
title: '库存排序',
field: 'stock',
current: '',
arr: [
'降序',
'升序'
]
},
],
sortObj: {
update_date: -1
}
}
},
onLoad() {
that = this;
uni.getSystemInfo({
success(res) {
that.scrollHeight = res.windowHeight - 40 + 'px';
}
})
that.getClassifyFun();
},
methods: {
// 查询分类方法
getClassifyFun: function() {
uni.showLoading({
title: '加载中...',
mask: true
})
let reqData = {
action: 'get',
params: {
isShow: true
}
}
crmCpClassifyApi(reqData)
.then(res => {
let data = res.result.data;
if (data && data.length > 0) {
that.classify = data;
that.cpClassify = data[0].flName;
that.cpFlId = data[0]._id;
that.setDropDownFun();
that.getChanPinFun();
} else {
uni.showModal({
title: '提示',
content: '当前暂未设置产品分类,请先添加产品分类!',
success(res) {
if (res.confirm) {
uni.redirectTo({
url: './classify?pageType=add'
})
}
}
})
}
})
},
// 查询产品方法
getChanPinFun: function() {
if (!that.isMore) {
return
}
uni.showLoading({
title: '加载中...',
mask: true
})
let reqObj = {
matchObj: {
cpFlId: that.cpFlId,
isSxJ: that.isSxJ,
},
pageIndex: that.pageIndex,
sortObj: that.sortObj
}
let reqData = {
action: 'getCpList',
params: reqObj
}
console.log(reqData)
crmChanpinApi(reqData)
.then(res => {
let data = res.result.data
if (that.pageIndex == 1) {
that.list = [];
}
if (data.length == 20) {
that.pageIndex += 1;
that.isMore = true;
} else {
that.isMore = false;
}
that.triggered = false;
that.list = that.list.concat(data);
})
},
// 设置下拉菜单数据
setDropDownFun: function() {
let list = that.classify;
let arr = [];
for (var i = 0; i < list.length; i++) {
arr.push({
value: i,
_id: list[i]._id,
label: list[i].flName
})
}
that.options1 = arr;
that.dropdown1 = arr[0].label;
},
// 下拉菜单回调1
dropDownFun1: function(e) {
that.cpClassify = e.label;
that.cpFlId = e._id;
that.pageIndex = 1;
that.isMore = true;
that.getChanPinFun();
},
// 下拉菜单回调2
dropDownFun2: function(e) {
if (e.label == '上架中') {
that.isSxJ = true
} else {
that.isSxJ = false
}
that.pageIndex = 1;
that.isMore = true;
that.getChanPinFun();
},
// 筛选框回调
optionSxFun: function(arr) {
let sortObj = {
update_date: -1
}
for (var i = 0; i < arr.length; i++) {
if (arr[i].current !== '') {
if (arr[i].field == 'create_date') {
sortObj.create_date = arr[i].current == 1 ? 1 : -1
}
if (arr[i].field == 'update_date') {
sortObj.update_date = arr[i].current == 1 ? 1 : -1
}
if (arr[i].field == 'salesNum') {
sortObj.salesNum = arr[i].current == 1 ? 1 : -1
}
if (arr[i].field == 'stock') {
sortObj.stock = arr[i].current == 1 ? 1 : -1
}
that.sortObj = sortObj;
break;
}
}
that.pageIndex = 1;
that.isMore = true;
that.getChanPinFun();
},
// 卡片点击方法
cardClick: function(item) {
uni.$cpDetail = item;
uni.navigateTo({
url: './cpDetail'
})
},
// 编辑产品
setCpFun: function(item) {
uni.$cpDetail = item;
uni.navigateTo({
url: './addCp?type=update'
})
},
// 删除产品
deleteCpFun: function(item, index) {
uni.showModal({
title: '提示',
content: '是否确认删除产品:' + item.pName,
success(rrr) {
if (rrr.confirm) {
uni.showLoading({
title: '删除中...'
})
let arr = item.cpFmtList;
arr = arr.concat(item.cpLbtList);
arr = arr.concat(item.cpXqtList);
if (arr.length > 0) {
that.deleteCpFileFun(item._id, index, arr)
} else {
that.deleteCpApiFun(item._id, index);
}
}
}
})
},
// 删除产品云函数api
deleteCpApiFun: function(_id, index) {
let reqData = {
action: 'deleteById',
params: {
_id
}
}
crmChanpinApi(reqData)
.then(res => {
uni.showToast({
title: '删除成功!',
icon: 'none',
duration: 1000
})
that.list.splice(index, 1);
})
},
// 删除产品图片api
deleteCpFileFun: function(_id, index, arr) {
let fileList = [];
for (var i = 0; i < arr.length; i++) {
fileList.push(arr[i].fileId);
}
let reqData = {
action: 'delete',
params: {
fileList
}
}
fileApi(reqData)
.then(res => {
that.deleteCpApiFun(_id, index);
})
},
// 产品上下架
cpsxjFun: function(item, index) {
let str = '上架中...';
let sxj = true
if (item.isSxJ) {
sxj = false;
str = '下架中...'
}
uni.showLoading({
title: str,
mask: true
})
let reqObj = {
_id: item._id,
req: {
isSxJ: sxj
}
}
let reqData = {
action: 'update',
params: reqObj
}
crmChanpinApi(reqData)
.then(res => {
let showTitle = '上架成功'
if (sxj == false) {
showTitle = '下架成功!'
}
uni.showToast({
title: showTitle,
icon: 'none',
duration: 2000
})
that.list.splice(index, 1);
})
},
onRefresh: function() {
if(that.triggered) return
that.triggered = true;
that.pageIndex = 1;
that.isMore = true;
that.getChanPinFun();
},
onRestore: function(e) {
that.triggered = false; // 需要重置
}
}
}
</script>
<style>
page {
background-color: #F8F8F8;
}
.rowBtn {
display: flex;
align-items: center;
flex-wrap: wrap;
margin: 26rpx 16rpx 16rpx 0;
justify-content: flex-end;
}
.cpBtn {
margin: 0 0 0 26rpx;
font-size: 15px !important;
height: 60rpx !important;
line-height: 60rpx !important;
}
.gdCz {
width: 60rpx;
height: 60rpx;
padding: 6rpx 12rpx;
}
.myCard2 {
width: 698rpx;
padding: 26rpx;
margin: 32rpx 26rpx;
box-sizing: border-box;
border-radius: 16rpx;
box-shadow: #d8d8d8 0px 0px 16rpx;
position: relative;
background-color: #FFFFFF;
display: flex;
}
.cardTopName1 {
font-size: 16px;
margin-bottom: 8rpx;
color: #000000;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
font-weight: bold;
padding-bottom: 8rpx;
}
.cardRow1 {
display: flex;
align-items: center;
font-size: 16px;
margin-bottom: 8rpx;
}
.cardRow1>view:first-child {
width: 176rpx;
color: #ADADAD;
}
.cardRow1>view:last-child {
color: #000000;
}
.leftImg {
width: 160rpx;
height: 160rpx;
margin-right: 26rpx;
border-radius: 26rpx;
overflow: hidden;
border: 1rpx solid #DDDDDD;
}
.rightView {
width: 460rpx;
}
.xlKcClass {
font-size: 14px;
color: #888888;
margin-bottom: 8rpx;
}
.xlKcClass>text {
margin-right: 26rpx;
}
</style>
+366
View File
@@ -0,0 +1,366 @@
<template>
<view>
<dataNull v-if="list.length == 0" src="/static/img/chahua/dataNullXz.png" title="暂无相关分类"
title1="点击添加按钮添加相关分类"></dataNull>
<view v-else class="content">
<view class="row" v-for="(row, index) in list" :key="index">
<text class="text">{{row.flName}}</text>
<view class="rightMenuRow">
<u-switch v-model="row.isShow" inactive-color="#f00" @change="changeClassFun(row)">
</u-switch>
<view class="menuBtn primaryBtn" @click="updateNameFun(row)">修改</view>
<view class="menuBtn errorBtn" @click="deleteFun(row)">删除</view>
</view>
</view>
</view>
<view @click="popupShow = true">
<addBtn></addBtn>
</view>
<!--新增分类-->
<u-popup v-model="popupShow" mode="center" border-radius="14" width="500rpx">
<view class="popupTitle">新增分类</view>
<view class="popupInput">
<text>分类名称:</text>
<input v-model="flName" class="uInput" type="text" placeholder="请输入分类名称" style="font-size: 16px;">
</view>
<view class="popupInput">
<text>分类排序:</text>
<input v-model="sort" class="uInput" type="number" placeholder="数值越小越靠前" style="font-size: 16px;">
</view>
<view class="btnRow">
<view class="popupBtn errorBtn" @click="popupShow = false">取消</view>
<view class="popupBtn primaryBtn" @click="addClassifyFun">确认</view>
</view>
</u-popup>
<!--修改分类名称-->
<u-popup v-model="popupXgShow" mode="center" border-radius="14" width="500rpx">
<view class="popupTitle">修改名称</view>
<view class="popupInput">
<text>分类名称:</text>
<input v-model="flName" class="uInput" type="text" placeholder="请输入分类名称" style="font-size: 16px;">
</view>
<view class="popupInput">
<text>分类排序:</text>
<input v-model="sort" class="uInput" type="number" placeholder="数值越小越靠前" style="font-size: 16px;">
</view>
<view class="btnRow">
<view class="popupBtn errorBtn" @click="popupXgShow = false">取消</view>
<view class="popupBtn primaryBtn" @click="updateConfirmFun">确认</view>
</view>
</u-popup>
</view>
</template>
<script>
let that = '';
import dataNull from '@/components/dataNull/dataNull.vue'
import addBtn from '@/components/addBtn/addBtn.vue'
import {
crmCpClassifyApi
} from '@/static/utils/api.js'
export default {
components: {
dataNull,
addBtn
},
data() {
return {
popupShow: false,
popupXgShow: false,
addName: '',
flName: '',
sort: '',
flData: {},
list: [],
xgObj: {},
ispush: false,
pageType: ''
}
},
onLoad(e) {
that = this;
if (e.pageType) {
that.pageType = e.pageType;
that.popupShow = true;
}
that.getClassifyFun();
},
methods: {
// 查询分类方法
getClassifyFun: function() {
uni.showLoading({
title: '加载中...',
mask: true
})
let reqData = {
action: 'getFlList',
params: {}
}
crmCpClassifyApi(reqData)
.then(res => {
let data = res.result.data;
console.log(data)
that.list = data;
// if (data) {
// that.list = data.list;
// uni.setStorageSync('classifyList', data.list);
// }
})
},
// 新增和修改分类方法
addClassifyFun: function() {
if (!that.flName) {
uni.showToast({
title: '请输入分类名称!',
icon: 'none'
})
return
}
if (!that.sort) {
uni.showToast({
title: '请输入分类排序数值!',
icon: 'none'
})
return
}
uni.showLoading({
title: '提交中...',
mask: true
})
let obj = {
flName: that.flName,
sort: parseFloat(that.sort),
isShow: true
}
let time = new Date().getTime()
obj.create_date = time;
obj.update_date = time;
obj.cjRenId = uni.$userInfo._id;
obj.updateUid = uni.$userInfo._id;
let reqData = {
action: 'add',
params: {
req: obj
}
}
crmCpClassifyApi(reqData)
.then(res => {
that.flName = '';
that.sort = '';
that.popupShow = false;
uni.showToast({
title: '新增成功!',
icon: 'none',
duration: 2000
})
that.getClassifyFun()
})
},
// 修改产品分类名称
updateNameFun: function(item) {
that.popupXgShow = true;
that.xgObj = item;
that.sort = item.sort;
that.flName = item.flName;
},
// 修改产品分类确认方法
updateConfirmFun: function() {
if (!that.flName) {
uni.showToast({
title: '请输入分类名称!',
icon: 'none'
})
return
}
if (!that.sort) {
uni.showToast({
title: '请输入分类排序数值!',
icon: 'none'
})
return
}
uni.showLoading({
title: '更新中...',
mask: true
})
let obj = {
flName: that.flName,
sort: parseFloat(that.sort)
};
let time = new Date().getTime()
obj.update_date = time;
obj.updateUid = uni.$userInfo._id;
let reqData = {
action: 'updateFl',
params: {
_id: that.xgObj._id,
updateObj: obj
}
}
crmCpClassifyApi(reqData)
.then(res => {
that.flName = '';
that.sort = '';
that.popupXgShow = false;
uni.showToast({
title: '修改成功!',
icon: 'none',
duration: 2000
})
that.getClassifyFun()
})
},
// 是否显示分类按钮方法
changeClassFun: function(e) {
let reqData = {
action: 'updateFl',
params: {
_id: e._id,
updateObj: {
isShow: e.isShow
}
}
}
crmCpClassifyApi(reqData)
.then(res => {
that.getClassifyFun();
})
},
// 删除产品分类
deleteFun: function(item) {
uni.showModal({
title: '提示',
content: '是否确认要删除该产品分类:' + item.flName + '?',
success(res) {
if(res.confirm) {
uni.showLoading({
title: '删除中,请稍等...',
mask: true
})
let reqData = {
action: 'deleteFlById',
params: {
_id: item._id
}
}
crmCpClassifyApi(reqData)
.then(res => {
that.getClassifyFun();
})
}
}
})
}
}
}
</script>
<style lang="scss" scoped>
page {
background-color: #efeff4 !important;
}
.content {
background-color: #FFFFFF;
padding: 26rpx;
.row {
display: flex;
flex-direction: row;
align-items: center;
width: 100%;
height: 100rpx;
border-bottom: 1rpx solid #CDCDCD;
.icon {
width: 30px;
height: 30px;
border-radius: 6px;
margin-right: 13px;
}
.text {
font-size: 16px;
font-weight: bold;
}
}
}
.popupTitle {
font-size: 16px;
font-weight: bold;
width: 100%;
text-align: center;
margin: 16rpx 0;
}
.popupInput {
font-size: 16px !important;
display: flex;
align-items: center;
margin-left: 26rpx;
margin: 32rpx 0 26rpx 26rpx;
}
.popupInput .uInput {
width: 280rpx !important;
border-bottom: 1rpx solid #AAAAAA;
padding-bottom: 8rpx;
font-size: 16px;
}
.btnRow {
width: 100%;
box-sizing: border-box;
display: flex;
justify-content: space-between;
padding: 26rpx;
}
.btnRow>.btn {
width: 160rpx;
height: 60rpx;
margin: 0;
}
.rightMenuRow {
display: flex;
align-items: center;
position: absolute;
right: 26rpx;
}
.rightMenuRow .menuBtn {
border-radius: 12rpx;
color: #FFFFFF;
margin: 0 0 0 26rpx;
width: 100rpx;
height: 50rpx;
text-align: center;
line-height: 50rpx;
}
.popupBtn {
border-radius: 12rpx;
color: #FFFFFF;
width: 150rpx;
height: 60rpx;
text-align: center;
line-height: 60rpx;
}
.primaryBtn {
background-color: #007AFF;
}
.primaryBtn:active {
background-color: #55aaff;
}
.errorBtn {
background-color: #ff0000;
}
.errorBtn:active {
background-color: #ff6e0e;
}
.uni-input-input {
font-size: 16px !important;
}
.arrowIcon {
margin-right: 26rpx;
}
</style>
+318
View File
@@ -0,0 +1,318 @@
<template>
<view>
<u-navbar back-icon-color="#FFFFFF" title="产品详情" title-color="#FFFFFF" :title-bold="true"
:background="background">
</u-navbar>
<u-swiper v-if="detail.cpLbtList && detail.cpLbtList.length > 0" :list="detail.cpLbtList" name="url" :effect3d="true" height="320" class="swiperClass" @click="swiperClickFun"></u-swiper>
<view class="myCard">
<view class="cardTopName">产品名称:{{detail.pName}}</view>
<view class="cardRow" v-if="detail.code">
<view>产品编码:</view>
<view>{{detail.code}}</view>
</view>
<view class="cardRow">
<view>产品状态:</view>
<view>{{detail.isSxJ ? '上架中' : '下架'}}</view>
</view>
<view class="cardRow">
<view>产品价格:</view>
<view>{{detail.price}}元/{{detail.unit}}</view>
</view>
<view class="cardRow">
<view>产品类型:</view>
<view>{{detail.flName}}</view>
</view>
<view class="cardRow" v-if="detail.describe">
<view>产品简述:</view>
<view>{{detail.describe}}</view>
</view>
<view class="cardRow" v-if="detail.cpFmtList && detail.cpFmtList.length > 0">
<view>封面图:</view>
<u-image width="160rpx" height="160rpx" border-radius="26" :src="detail.cpFmtList[0].url" @click="previewImageFun(detail.cpFmtList[0].url, [detail.cpFmtList[0].url])"></u-image>
</view>
</view>
<view class="xiangqing">
— 详情 —
</view>
<view class="xqTitle">产品参数介绍</view>
<view class="spXQBox" v-if="detail.cpCsList && detail.cpCsList.length > 0">
<view style="font-size: 30rpx;">产品参数说明</view>
<view class="table">
<view class="row" v-for="(item, index) in detail.cpCsList" :key="index">
<view>{{item.csName}}</view>
<view>{{item.csJieShao}}</view>
</view>
</view>
</view>
<dataNull v-else src="/static/img/chahua/dataNullXz.png" title="暂无产品参数说明"></dataNull>
<view class="xqTitle">产品详情图</view>
<view class="imgXQ" v-if="detail.cpXqtList && detail.cpXqtList.length > 0">
<u-image width="100%" mode="widthFix" v-for="(item, index) in detail.cpXqtList" :key="index" :src="item.url"
:lazy-load="true" @click="xqtClickFun(item.url, detail.cpXqtList)"></u-image>
</view>
<dataNull v-else src="/static/img/chahua/dataNullXz.png" title="暂无产品详情图"></dataNull>
<!--提交按钮-->
<view v-if="!pageType" class="submitView">
<u-button type="primary" class="submitBtn" :ripple="true" ripple-bg-color="#909399" @click="updateCpFun">修改产品</u-button>
</view>
<!--商城按钮-->
<button v-if="pageType" @click="gotoShopFun" class="shopBtn">商城</button>
<!--分享按钮-->
<button v-if="pageType" open-type="share" class="addBtn">
<u-icon name="zhuanfa" color="#ffffff" size="40"></u-icon>
</button>
</view>
</template>
<script>
let that = '';
import { crmChanpinApi } from '@/static/utils/api.js'
import dataNull from '@/components/dataNull/dataNull.vue'
export default {
components: {
dataNull
},
data() {
return {
detail: {},
background: {
'background-image': 'linear-gradient(45deg, #007aff, rgb(12, 168, 234))'
},
customStyle: {
backgroundColor: 'rgb(13, 159, 224)',
color: '#FFFFFF',
border: '0',
fontSize: '32',
outline: 'none'
},
lbt: [],
pageType: ''
}
},
onLoad(e) {
that = this;
that.pageType = e.type || ''
if(e.id) {
that.getGoodDetailByIdFun(e.id)
} else {
that.detail = uni.$cpDetail;
uni.setNavigationBarTitle({
title: that.detail.pName
})
}
},
onShareAppMessage(res) {
if (res.from === 'button') { // 来自页面内分享按钮
console.log(res.target)
}
return {
title: '您好,这是产品:' + that.detail.pName + '的详情,快来查看吧!',
path: '/chanpin/view/cpDetail?id=' + that.detail._id + '&type=client'
}
},
methods: {
// 轮播点击方法
swiperClickFun: function(e) {
let list = that.detail.cpLbtList;
let str = list[e].url;
let arr = [];
for (var i = 0; i < list.length; i++) {
arr.push(list[i].url);
}
that.previewImageFun(str, arr);
},
// 详情图点击方法
xqtClickFun: function(str, list) {
let arr = [];
for (var i = 0; i < list.length; i++) {
arr.push(list[i].url);
}
that.previewImageFun(str, arr);
},
// 预览图片
previewImageFun: function(str, list) {
uni.previewImage({
urls: list,
indicator: 'number',
current: str
})
},
// 跳转编辑页面
updateCpFun: function() {
uni.navigateTo({
url: './addCp?type=update'
})
},
// 根据商品id查询商品详情
getGoodDetailByIdFun: function(_id) {
let reqData = {
action: 'getDetailById',
params: {
_id
}
}
crmChanpinApi(reqData)
.then(res => {
let data = res.result.data;
if(data.length > 0) {
that.detail = data[0];
uni.setNavigationBarTitle({
title: that.detail.pName
})
} else {
uni.showModal({
title: '提示',
content: '当前商品不存在或已被删除,点击确定跳往首页!',
showCancel: false,
success() {
uni.reLaunch({
url: '/pages/index/index'
})
}
})
}
})
},
// 跳往商城页面
gotoShopFun: function() {
uni.redirectTo({
url: 'shop?id=' + that.detail.cjRenId
})
}
}
}
</script>
<style lang='scss'>
page {
background-color: #F8F8F8;
padding-bottom: 100rpx;
}
.swiperClass {
margin-top: 16rpx;
}
.xiangqing {
text-align: center;
font-size: 32rpx;
font-weight: bold;
margin: 16rpx 0;
}
.spXQBox {
width: 698rpx;
margin: 0 26rpx;
background-color: #FFFFFF;
padding: 26rpx;
box-sizing: border-box;
border-radius: 16rpx;
box-shadow: #d8d8d8 0px 0px 16rpx;
}
.table {
width: 100%;
border: 1rpx solid #E7E7E7;
margin: 32rpx 0;
}
.row {
display: flex;
align-items: center;
width: 100%;
border-bottom: 1rpx solid #E7E7E7;
}
.row>view:first-child {
width: 180rpx;
height: 100%;
font-size: 28rpx;
padding: 0 16rpx;
box-sizing: border-box;
}
.row>view:last-child {
width: 506rpx;
height: 100%;
font-size: 28rpx;
padding: 16rpx;
box-sizing: border-box;
border-left: 1rpx solid #E7E7E7;
}
.imgXQ {
width: 100%;
background-color: #FFFFFF;
margin-top: 32rpx;
}
.imgXqtp {
width: 100%;
}
.flexRow {
display: flex;
}
.xqTitle {
font-size: 16px;
font-weight: bold;
margin: 26rpx;
}
.addBtn {
width: 88rpx;
height: 88rpx;
border-radius: 50%;
background-image: linear-gradient(45deg, #007aff, #00aaff);
display: flex;
align-items: center;
justify-content: center;
position: fixed;
bottom: 80rpx;
right: 26rpx;
z-index: 100;
}
.addBtn:active {
background-image: linear-gradient(45deg, #00aaff, #007aff);
}
.shopBtn {
width: 88rpx;
height: 88rpx;
border-radius: 50%;
background-image: linear-gradient(45deg, #007aff, #00aaff);
display: flex;
align-items: center;
font-size: 26rpx;
padding: 0;
color: #FFFFFF;
font-weight: bold;
justify-content: center;
position: fixed;
bottom: 190rpx;
right: 26rpx;
z-index: 100;
}
.shopBtn:active {
background-image: linear-gradient(45deg, #00aaff, #007aff);
}
.nameCardBtn {
width: 88rpx;
height: 88rpx;
border-radius: 50%;
background-image: linear-gradient(45deg, #007aff, #00aaff);
display: flex;
align-items: center;
font-size: 26rpx;
padding: 0;
color: #FFFFFF;
font-weight: bold;
justify-content: center;
position: fixed;
bottom: 300rpx;
right: 26rpx;
z-index: 100;
}
.nameCardBtn:active {
background-image: linear-gradient(45deg, #00aaff, #007aff);
}
</style>
+248
View File
@@ -0,0 +1,248 @@
<template>
<view>
<searchView placeholderStr="请输入产品名称" @searchViewClickFun="searchEventsFun($event)"></searchView>
<dataNull v-if="list.length == 0" src="/static/img/chahua/dataNullXz.png" title="暂无相关产品"
title1="请更换查询条件"></dataNull>
<scroll-view v-else scroll-y="true" :style="{height: scrollHeight}" @scrolltolower="getChanPinFun"
refresher-enabled :refresher-threshold="200" :refresher-triggered="triggered" refresher-background="gray"
@refresherrefresh="onRefresh" @refresherrestore="onRestore">
<view v-for="(item, index) in list" :key="index" @click="cardClick(item)">
<view v-if="item.cpFmtList && item.cpFmtList.length > 0" class="myCard2">
<view class="leftImg">
<u-image height="160" width="160" border-radius="26" :src="item.cpFmtList[0].url"></u-image>
</view>
<view class="rightView">
<view class="cardTopName1">{{item.pName}}</view>
<view v-if="item.salesNum || item.stock" class="xlKcClass">
<text v-if="item.salesNum">销量: {{item.salesNum}}</text>
<text v-if="item.stock">库存: {{item.stock}}</text>
</view>
<view class="cardRow1">
<text class="redColor">¥{{item.price}}</text>/{{item.unit}}
</view>
</view>
</view>
<view v-else class="myCard">
<view class="cardTopName">产品名称:{{item.pName}}</view>
<view class="cardRow">
<view>产品状态:</view>
<view>{{item.isSxJ}}</view>
</view>
<view class="cardRow">
<view>产品价格:</view>
<view><text class="redColor">¥{{item.price}}</text>/{{item.unit}}</view>
</view>
<view class="cardRow">
<view>产品类型:</view>
<view>{{item.cpClassify}}</view>
</view>
<view class="cardRow" v-if="item.salesNum">
<view>产品销量:</view>
<view>{{item.salesNum}}</view>
</view>
<view class="cardRow" v-if="item.stock">
<view>产品库存:</view>
<view>{{item.stock}}</view>
</view>
<view class="cardRow" v-if="item.describe">
<view>产品简述:</view>
<view>{{item.describe}}</view>
</view>
</view>
</view>
<getMore :isMore="isMore" class="h100"></getMore>
</scroll-view>
</view>
</template>
<script>
let that = '';
import dataNull from '@/components/dataNull/dataNull.vue'
import addBtn from '@/components/addBtn/addBtn.vue'
import getMore from '@/components/getMore/getMore.vue'
import searchView from '@/components/searchView/searchView.vue'
import { crmChanpinApi } from '@/static/utils/api.js'
export default {
components: {
searchView,
dataNull,
getMore,
addBtn
},
data() {
return {
pageIndex: 1,
searchValue: '',
list: [],
scrollHeight: '667px',
triggered: false,
isMore: true,
sortObj: {
update_date: -1
}
}
},
onLoad(e) {
that = this;
uni.getSystemInfo({
success(res) {
that.scrollHeight = res.windowHeight - 40 + 'px';
}
})
},
methods: {
// 获取产品列表
getChanPinFun: function() {
if (!that.isMore) {
return
}
uni.showLoading({
title: '加载中...',
mask: true
})
let reqObj = {
matchObj: {
isSxJ: true
},
pageIndex: that.pageIndex,
searchValue: that.searchValue,
sortObj: that.sortObj,
}
let reqData = {
action: 'getCpList',
params: reqObj
}
crmChanpinApi(reqData)
.then(res => {
let data = res.result.data
if (that.pageIndex == 1) {
that.list = [];
}
if (data.length == 20) {
that.pageIndex += 1;
that.isMore = true;
} else {
that.isMore = false;
}
that.triggered = false;
that.list = that.list.concat(data);
})
},
// 卡片点击方法
cardClick: function(item) {
uni.$cpDetail = item;
uni.navigateTo({
url: './cpDetail?type=client'
})
},
// 搜索框回调函数
searchEventsFun: function(e) {
that.searchValue = e;
that.isMore = true;
that.pageIndex = 1;
that.getChanPinFun();
},
// 下拉刷新回调
onRefresh: function() {
if(that.triggered) return
that.triggered = true;
that.pageIndex = 1;
that.isMore = true;
that.getChanPinFun();
},
onRestore: function(e) {
that.triggered = false; // 需要重置
}
}
}
</script>
<style>
page {
background-color: #F8F8F8;
}
.rowBtn {
display: flex;
align-items: center;
flex-wrap: wrap;
margin: 26rpx 16rpx 16rpx 0;
justify-content: flex-end;
}
.cpBtn {
margin: 0 0 0 26rpx;
font-size: 15px !important;
height: 60rpx !important;
line-height: 60rpx !important;
}
.gdCz {
width: 60rpx;
height: 60rpx;
padding: 6rpx 12rpx;
}
.myCard2 {
width: 698rpx;
padding: 26rpx;
margin: 32rpx 26rpx;
box-sizing: border-box;
border-radius: 16rpx;
box-shadow: #d8d8d8 0px 0px 16rpx;
position: relative;
background-color: #FFFFFF;
display: flex;
}
.cardTopName1 {
font-size: 16px;
margin-bottom: 8rpx;
color: #000000;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
font-weight: bold;
padding-bottom: 8rpx;
}
.cardRow1 {
display: flex;
align-items: center;
font-size: 16px;
margin-bottom: 8rpx;
}
.cardRow1>view:first-child {
width: 176rpx;
color: #ADADAD;
}
.cardRow1>view:last-child {
color: #000000;
}
.leftImg {
width: 160rpx;
height: 160rpx;
margin-right: 26rpx;
border-radius: 26rpx;
overflow: hidden;
border: 1rpx solid #DDDDDD;
}
.rightView {
width: 480rpx;
}
.xlKcClass {
font-size: 14px;
color: #888888;
margin-bottom: 8rpx;
}
.xlKcClass>text {
margin-right: 26rpx;
}
</style>
+264
View File
@@ -0,0 +1,264 @@
<template>
<view>
<searchView placeholderStr="请输入产品名称" @searchViewClickFun="searchEventsFun($event)"></searchView>
<dataNull v-if="list.length == 0" src="/static/img/chahua/dataNullXz.png" title="暂无相关产品"
title1="请添加或者更换查询条件"></dataNull>
<scroll-view v-else scroll-y="true" :style="{height: scrollHeight}" @scrolltolower="getChanPinFun"
refresher-enabled :refresher-threshold="200" :refresher-triggered="triggered" refresher-background="gray"
@refresherrefresh="onRefresh" @refresherrestore="onRestore">
<view v-for="(item, index) in list" :key="index" @click="cardClick(item)">
<view v-if="item.cpFmtList && item.cpFmtList.length > 0" class="myCard2">
<view class="leftImg">
<u-image height="160" width="160" border-radius="26" :src="item.cpFmtList[0].url"></u-image>
</view>
<view class="rightView">
<view class="cardTopName1">{{item.pName}}</view>
<view v-if="item.salesNum || item.stock" class="xlKcClass">
<text v-if="item.salesNum">销量: {{item.salesNum}}</text>
<text v-if="item.stock">库存: {{item.stock}}</text>
</view>
<view class="cardRow1">
<text class="redColor">¥{{item.price}}</text>/{{item.unit}}
</view>
<view class="rowBtn">
<u-button type="primary" :plain="true" class="cpBtn" size="mini" @tap.stop="setCpFun(item)">
编辑产品
</u-button>
<u-button type="warning" :plain="true" class="cpBtn" size="mini"
@click="cpsxjFun(item, index)">{{item.isSxJ == '上架' ? '下架' : '上架'}}</u-button>
<u-button type="error" :plain="true" class="cpBtn" size="mini"
@tap.stop="deleteCpFun(item, index)">
删除</u-button>
</view>
</view>
</view>
<view v-else class="myCard">
<view class="cardTopName">产品名称:{{item.pName}}</view>
<view class="cardRow">
<view>产品状态:</view>
<view>{{item.isSxJ}}</view>
</view>
<view class="cardRow">
<view>产品价格:</view>
<view><text class="redColor">¥{{item.price}}</text>/{{item.unit}}</view>
</view>
<view class="cardRow">
<view>产品类型:</view>
<view>{{item.cpClassify}}</view>
</view>
<view class="cardRow" v-if="item.salesNum">
<view>产品销量:</view>
<view>{{item.salesNum}}</view>
</view>
<view class="cardRow" v-if="item.stock">
<view>产品库存:</view>
<view>{{item.stock}}</view>
</view>
<view class="cardRow" v-if="item.describe">
<view>产品简述:</view>
<view>{{item.describe}}</view>
</view>
<view class="rowBtn">
<u-button type="primary" :plain="true" class="cpBtn" size="mini" @tap.stop="setCpFun(item)">编辑产品
</u-button>
<u-button type="warning" :plain="true" class="cpBtn" size="mini" @click="cpsxjFun(item, index)">
{{item.isSxJ == '上架' ? '下架' : '上架'}}</u-button>
<u-button type="error" :plain="true" class="cpBtn" size="mini"
@tap.stop="deleteCpFun(item, index)">
删除</u-button>
</view>
</view>
</view>
<getMore :isMore="isMore" class="h100"></getMore>
</scroll-view>
</view>
</template>
<script>
let that = '';
import dataNull from '@/components/dataNull/dataNull.vue'
import addBtn from '@/components/addBtn/addBtn.vue'
import getMore from '@/components/getMore/getMore.vue'
import searchView from '@/components/searchView/searchView.vue'
import { crmChanpinApi } from '@/static/utils/api.js'
export default {
components: {
searchView,
dataNull,
getMore,
addBtn
},
data() {
return {
pageIndex: 1,
searchValue: '',
list: [],
scrollHeight: '667px',
triggered: false,
isMore: true,
sortObj: {
update_date: -1
}
}
},
onLoad() {
that = this;
uni.getSystemInfo({
success(res) {
that.scrollHeight = res.windowHeight - 40 + 'px';
}
})
},
methods: {
// 获取产品列表
getChanPinFun: function() {
if (!that.isMore) {
return
}
uni.showLoading({
title: '加载中...',
mask: true
})
let reqObj = {
pageIndex: that.pageIndex,
searchValue: that.searchValue,
sortObj: that.sortObj
}
let reqData = {
action: 'get',
params: reqObj
}
crmChanpinApi(reqData)
.then(res => {
let data = res.result.data
if (that.pageIndex == 1) {
that.list = [];
}
if (data.length == 10) {
that.pageIndex += 1;
that.isMore = true;
} else {
that.isMore = false;
}
that.triggered = false;
that.list = that.list.concat(data);
})
},
// 卡片点击方法
cardClick: function(item) {
uni.$cpDetail = item;
uni.navigateTo({
url: './cpDetail'
})
},
// 搜索框回调函数
searchEventsFun: function(e) {
that.searchValue = e;
that.isMore = true;
that.pageIndex = 1;
that.getChanPinFun();
},
// 下拉刷新回调
onRefresh: function() {
if(that.triggered) return
that.triggered = true;
that.pageIndex = 1;
that.isMore = true;
that.getChanPinFun();
},
onRestore: function(e) {
that.triggered = false; // 需要重置
}
}
}
</script>
<style>
page {
background-color: #F8F8F8;
}
.rowBtn {
display: flex;
align-items: center;
flex-wrap: wrap;
margin: 26rpx 16rpx 16rpx 0;
justify-content: flex-end;
}
.cpBtn {
margin: 0 0 0 26rpx;
font-size: 15px !important;
height: 60rpx !important;
line-height: 60rpx !important;
}
.gdCz {
width: 60rpx;
height: 60rpx;
padding: 6rpx 12rpx;
}
.myCard2 {
width: 698rpx;
padding: 26rpx;
margin: 32rpx 26rpx;
box-sizing: border-box;
border-radius: 16rpx;
box-shadow: #d8d8d8 0px 0px 16rpx;
position: relative;
background-color: #FFFFFF;
display: flex;
}
.cardTopName1 {
font-size: 16px;
margin-bottom: 8rpx;
color: #000000;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
font-weight: bold;
padding-bottom: 8rpx;
}
.cardRow1 {
display: flex;
align-items: center;
font-size: 16px;
margin-bottom: 8rpx;
}
.cardRow1>view:first-child {
width: 176rpx;
color: #ADADAD;
}
.cardRow1>view:last-child {
color: #000000;
}
.leftImg {
width: 160rpx;
height: 160rpx;
margin-right: 26rpx;
border-radius: 26rpx;
overflow: hidden;
border: 1rpx solid #DDDDDD;
}
.rightView {
width: 460rpx;
}
.xlKcClass {
font-size: 14px;
color: #888888;
margin-bottom: 8rpx;
}
.xlKcClass>text {
margin-right: 26rpx;
}
</style>
+709
View File
@@ -0,0 +1,709 @@
<template>
<view>
<view class="top-box">
<navigator url="./search" class="top" :class="pageNum == 0 ? 'duanwidth' : ''">
<view class="search">
<u-icon class="searchIcon" name="search"></u-icon>
<text>搜索你要找的产品</text>
</view>
</navigator>
</view>
<view class="scrollF" :style="{ height: (wHeight - 50) + 'px' }">
<scroll-view scroll-y="true" class="leftScrollV">
<view v-for="(item, index) in tabBars" :key="index" class="leftCardView">
<view v-if="item.isShow" class="leftCard" :class="{ leftActive: leftA == index }" @click="selectLeftFl(index)">{{item.flName}}</view>
</view>
</scroll-view>
<view class="rightSv">
<view style="height: 100%; width: 100%;" v-if="tabBars.length > 0">
<scroll-view v-for="(tabItem, iii) in tabBars" :key="iii" v-show="leftA == iii" scroll-y="true"
style="height: 100%; width: 100%;" @scrolltolower="loadMore" refresher-enabled
:refresher-triggered="tabItem.triggered" :refresher-threshold="200" refresher-background="gray" @refresherrefresh="onRefresh" @refresherrestore="onRestore" >
<skeleton SkelttionType="classify" v-if="!tabItem.isjz"></skeleton>
<view v-else>
<view v-if="tabItem.arr.length > 0">
<view v-for="(item, index) in tabItem.arr" :key="index" @click="cardClick(item)">
<view v-if="item.cpFmtList && item.cpFmtList.length > 0" class="myCard2">
<view class="leftImg">
<u-image height="160" width="160" :src="item.cpFmtList[0].url"></u-image>
</view>
<view class="rightView">
<view class="cardTopName1">{{item.pName}}</view>
<view v-if="item.salesNum || item.stock" class="xlKcClass">
<text v-if="item.salesNum">销量: {{item.salesNum}}</text>
<text v-if="item.stock">库存: {{item.stock}}</text>
</view>
<view class="cardRow1">
<text class="redColor">¥{{item.price}}</text>/{{item.unit}}
</view>
</view>
</view>
<view v-else class="myCard1">
<view class="cardTopName">{{item.pName}}</view>
<view class="cardRow1">
<view>产品价格:</view>
<view><text class="redColor">¥{{item.price}}</text>/{{item.unit}}</view>
</view>
<view v-if="item.salesNum" class="cardRow1">
<view>产品销量:</view>
<view>{{item.salesNum}}</view>
</view>
<view v-if="item.stock" class="cardRow1">
<view>产品库存:</view>
<view>{{item.stock}}</view>
</view>
</view>
</view>
<getMore :isMore="tabBars[tabCurrentIndex].isMore" style="margin-bottom: 16px;"></getMore>
<view style="height: 36rpx;"></view>
</view>
<dataNull v-else src="/static/img/chahua/dataNullXz.png" title="暂无相关产品" title1="请先添加">
</dataNull>
</view>
</scroll-view>
</view>
<dataNull v-else src="/static/img/chahua/dataNullXz.png" title="暂无相关产品">
</dataNull>
</view>
</view>
<!--排序-->
<u-popup v-model="popupShow" width="568rpx" mode="right" border-radius="14" :safe-area-inset-bottom="true">
<view class="popupCard" v-for="(obj, index) in sxArr" :key="index">
<view class="popupTitle">{{obj.title}}</view>
<view class="popupItem">
<view v-for="(item, iii) in obj.arr" :key="iii" :class="obj.current === iii ? 'activeClass' : ''" @click="sxItemClickFun(index, iii)">{{item}}</view>
</view>
<view class="flexJs" v-if="obj.judge">
<text>等于</text>
<u-icon name="arrow-right"></u-icon>
</view>
</view>
<view class="h200"></view>
<view class="popupBottomBtn">
<view class="popupBtn warning" @click="resetFun">重置</view>
<view class="popupBtn primary" @click="confirmFun">确定</view>
</view>
</u-popup>
</view>
</template>
<script>
let that = '';
let windowWidth = 0;
import dataNull from '@/components/dataNull/dataNull.vue'
import getMore from '@/components/getMore/getMore.vue'
import skeleton from '@/components/skeleton/skeleton.vue'
export default {
components: {
skeleton,
getMore,
dataNull
},
data() {
return {
cpClassify: '',
cpFlId: '',
list: [],
pageNum: 0,
scrollLeft: 0, //顶部选项卡左滑距离
enableScroll: true,
tabCurrentIndex: 0,
tabBars: [],
wHeight: 623,
leftA: 0,
triggered: false,
freshing: false,
sortObj: {
update_date: -1,
salesNum: -1,
stock: 1,
create_date: -1
},
popupShow: false,
sxArr: [{
title: '创建日期排序',
field: 'create_date',
current: '',
isPx: true,
arr: [
'降序',
'升序'
]
},
{
title: '修改日期排序',
field: 'update_date',
current: '',
isPx: true,
arr: [
'降序',
'升序'
]
},
{
title: '销量排序',
field: 'salesNum',
current: '',
isPx: true,
arr: [
'降序',
'升序'
]
},
{
title: '库存排序',
field: 'stock',
current: '',
isPx: true,
arr: [
'降序',
'升序'
]
}],
tabList: [{
iconPath: "photo-fill",
selectedIconPath: "photo-fill",
text: '名片',
customIcon: false,
},
{
iconPath: "shopping-cart-fill",
selectedIconPath: "shopping-cart-fill",
text: '商城',
customIcon: false,
}
],
current: 1
}
},
onLoad(e) {
that = this;
that.pageType = e.type ? e.type : '';
windowWidth = uni.getSystemInfoSync().windowWidth;
that.wHeight = uni.getSystemInfoSync().windowHeight;
// let tabBars = uni.getStorageSync('classifyList');
// if (tabBars.length > 0) {
// for (var i = 0; i < tabBars.length; i++) {
// tabBars[i].pageIndex = 1;
// tabBars[i].arr = [];
// tabBars[i].isMore = false;
// tabBars[i].triggered = false;
// }
// tabBars[0].loaded = true;
// that.tabBars = tabBars;
// that.cpClassify = tabBars[0].name;
// that.getChanPinFun();
// } else {
// that.getClassifyFun();
// }
if(e.id) {
that.userId = e.id;
} else {
that.userId = uni.$userInfo._id;
that.getClassifyFun();
}
},
onShow() {
uni.$userInfo = uni.getStorageSync('userInfo') || {};
if (!uni.$userInfo || !uni.$userInfo._id) {
// #ifdef MP-WEIXIN
uni.navigateTo({
url: '../../pages/regLogin/wxLogin?pageUrl=true'
})
// #endif
// #ifdef H5
uni.navigateTo({
url: '../../pages/regLogin/login'
})
// #endif
} else {
that.getClassifyFun();
}
},
onShareAppMessage(res) {
if (res.from === 'button') { // 来自页面内分享按钮
console.log(res.target)
}
return {
title: '您好,这是我的微信小商城,快来查看吧!',
path: '/chanpin/view/shop?id=' + that.cardInfo.u_id
}
},
onShareTimeline() {
return {
title: '您好,这是我的微信小商城,快来查看吧!',
imageUrl: '', // 图片 URL
query: 'id=' + that.cardInfo.u_id
}
},
methods: {
tabbarChangeFun: function(e) {
if(e == 0) {
uni.redirectTo({
url: '../../nameCard/view/previewCard?id=' + that.userId
})
}
},
// 查询用户crmUser方法
getuserInfoFun: function(id) {
let reqData = {
action: 'getUserCrmUid',
params: {
uid: id
}
}
console.log(reqData)
uni.showLoading({
title: '加载中...'
})
crmMyAppUserApi(reqData)
.then(res => {
that.getClassifyFun();
})
},
// 查询分类方法
getClassifyFun: function() {
uni.showLoading({
title: '加载中...',
mask: true
})
let reqData = {
action: 'getFlList',
params: {
matchObj: {
isShow: true
}
}
}
crmCpClassifyApi(reqData)
.then(res => {
console.log(res)
let list = res.result.data;
console.log(list)
if (list) {
for (var i = 0; i < list.length; i++) {
list[i].pageIndex = 1;
list[i].arr = [];
list[i].isMore = false;
list[i].triggered = false;
}
list[0].loaded = true;
that.tabBars = list;
that.cpClassify = list[0].flName;
that.cpFlId = list[0]._id;
// uni.setStorageSync('classifyList', data.list);
that.getChanPinFun();
}
})
},
// 查询产品方法
getChanPinFun: function() {
uni.showLoading({
title: '加载中...',
mask: true
})
let iii = that.leftA;
let reqObj = {
matchObj: {
cpFlId: that.tabBars[iii]._id,
isSxJ: true,
},
pageIndex: that.tabBars[iii].pageIndex,
sortObj: that.sortObj
}
let loadPi = reqObj.pageIndex;
let reqData = {
action: 'getCpList',
params: reqObj
}
console.log(reqData)
crmChanpinApi(reqData)
.then(res => {
let list = res.result.data;
let item = that.tabBars[iii];
let arr = that.tabBars[iii].arr;
if (item.triggered) {
item.triggered = false;
that.freshing = false;
}
if (list.length == 20) {
item.isMore = true;
item.pageIndex += 1;
} else {
item.isMore = false;
}
if (loadPi == 1) {
item.arr = list;
} else {
arr = arr.concat(list);
item.arr = arr;
}
item.isjz = true;
that.$set(that.tabBars, iii, item);
})
},
selectLeftFl: function(i) {
this.leftA = i;
this.tabCurrentIndex = i;
let tabItem = this.tabBars[i];
if (tabItem.loaded !== true) {
uni.showLoading({
title: '加载中...',
mask: true
})
this.getChanPinFun();
tabItem.loaded = true;
}
},
// 上拉加载更多
loadMore: function(e) {
if (this.tabBars[this.leftA].isMore) {
this.getChanPinFun();
}
},
onRefresh() {
let item = this.tabBars[this.leftA];
if (this.freshing) return;
this.freshing = true;
if (!item.triggered) //界面下拉触发,triggered可能不是true,要设为true
item.triggered = true;
item.isMore = true;
item.pageIndex = 1;
this.$set(this.tabBars, this.leftA, item);
this.getChanPinFun();
},
onRestore() {
let item = this.tabBars[this.leftA];
item.triggered = false; // 需要重置
this.$set(this.tabBars, this.leftA, item);
},
// 卡片点击方法
cardClick: function(item) {
if(that.pageType !== '') {
uni.$emit('chanpinBindFun', item)
uni.navigateBack()
} else {
uni.$cpDetail = item;
uni.navigateTo({
url: './cpDetail?type=client'
})
}
},
sxItemClickFun: function(index, iii) {
let item = that.sxArr[index];
let list = that.sxArr;
for(var i = 0; i < list.length; i++) {
if(list[i].isPx) {
list[i].current = '';
}
}
item.current = iii;
that.$set(that.sxArr, index, item)
},
// 重置筛选项方法
resetFun: function() {
let list = that.sxArr;
for(var i = 0; i < list.length; i++) {
list[i].current = '';
}
that.sxArr = list;
},
// 确定筛选项方法
confirmFun: function() {
that.popupShow = false;
let arr = that.sxArr;
for (var i = 0; i < arr.length; i++) {
if (arr[i].isPx && arr[i].current !== '') {
console.log(arr[i])
let sortObj = {}
if (arr[i].field == 'create_date') {
sortObj.create_date = arr[i].current == 1 ? 1 : -1
}
if (arr[i].field == 'update_date') {
sortObj.update_date = arr[i].current == 1 ? 1 : -1
}
if (arr[i].field == 'salesNum') {
sortObj.salesNum = arr[i].current == 1 ? 1 : -1
}
if (arr[i].field == 'stock') {
sortObj.stock = arr[i].current == 1 ? 1 : -1
}
that.sortObj = sortObj;
break;
}
}
that.pageIndex = 1;
that.isMore = true;
that.getChanPinFun();
// that.$emit('optionSxFun', that.sxArr);
}
}
}
</script>
<style>
.top-box {
width: 100%;
height: 50px;
display: flex;
align-items: center;
background-color: #FFFFFF;
border-bottom: 1rpx solid #EBEEF5;
}
.chuangjian {
color: #007AFF;
}
.chuangjian>text:first-child {
font-size: 36rpx;
font-weight: bold;
}
.chuangjian>text:last-child {
font-size: 30rpx;
}
.top {
height: 80rpx;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
margin: 0 20rpx;
width: 580rpx;
}
.duanwidth {
width: 600rpx !important;
}
.searchIcon {
width: 40rpx;
height: 40rpx;
margin: 0 18rpx 0 12rpx;
}
.search {
flex: 1;
height: 60rpx;
background-color: #f5f5f5;
border-radius: 40rpx;
padding: 0 20rpx;
font-size: 28rpx;
display: flex;
align-items: center;
}
.rightBtn image {
width: 56rpx;
height: 56rpx;
}
.scrollF {
display: flex;
}
.leftScrollV {
width: 160rpx;
height: 100%;
background-color: #f8f8f8;
}
.rightSv {
width: 590rpx;
padding: 0 16rpx;
box-sizing: border-box;
height: 100%;
background-color: #FFFFFF;
}
.leftCard {
width: 100%;
height: 88rpx;
line-height: 88rpx;
font-size: 30rpx;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.leftCardView:last-child {
margin-bottom: 100rpx;
}
.leftActive {
background-color: #FFFFFF;
color: #007AFF;
font-weight: bold;
}
.tishi {
width: 590rpx;
}
.centerF26 {
font-size: 28rpx;
width: 100%;
text-align: center;
margin-bottom: 100rpx;
color: #696969;
}
.myCard1 {
padding: 26rpx 26rpx 10rpx;
margin: 32rpx 16rpx;
box-sizing: border-box;
border-radius: 16rpx;
box-shadow: #d8d8d8 0px 0px 16rpx;
position: relative;
background-color: #FFFFFF;
}
.myCard2 {
padding: 26rpx;
margin: 32rpx 16rpx;
box-sizing: border-box;
border-radius: 16rpx;
box-shadow: #d8d8d8 0px 0px 16rpx;
position: relative;
background-color: #FFFFFF;
display: flex;
}
.cardTopName1 {
font-size: 16px;
margin-bottom: 8rpx;
color: #000000;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
font-weight: bold;
padding-bottom: 8rpx;
}
.cardRow1 {
display: flex;
align-items: center;
font-size: 16px;
margin-bottom: 8rpx;
}
.cardRow1>view:first-child {
width: 176rpx;
color: #ADADAD;
}
.cardRow1>view:last-child {
color: #000000;
}
.leftImg {
width: 160rpx;
height: 160rpx;
margin-right: 26rpx;
border-radius: 26rpx;
overflow: hidden;
border: 1rpx solid #DDDDDD;
}
.rightView {
width: 288rpx;
}
.xlKcClass {
font-size: 14px;
color: #888888;
display: flex;
justify-content: space-between;
margin-bottom: 8rpx;
}
/*************************弹窗层******************************/
.popupCard {
width: 100%;
padding: 26rpx 16rpx;
border-bottom: 1rpx solid #efefef;
}
.popupTitle {
font-size: 16px;
font-weight: bold;
margin-bottom: 26rpx;
}
.popupItem {
font-size: 15px;
color: #666666;
display: flex;
align-items: center;
flex-wrap: wrap;
}
.popupItem>view {
width: 160rpx;
text-align: center;
padding: 12rpx 20rpx;
background-color: #e6e6e6;
margin-bottom: 26rpx;
border-radius: 16rpx;
margin-right: 28rpx;
}
.mr0 {
margin-right: 0 !important;
}
.flexJs {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
.popupBottomBtn {
width: 100%;
height: 100rpx;
background-color: #FFFFFF;
display: flex;
align-items: center;
position: fixed;
bottom: 0;
font-size: 15px;
}
.settingView {
width: 128rpx;
height: 100% !important;
display: flex;
align-items: center;
justify-content: center;
}
.popupBtn {
width: 50%;
height: 100% !important;
line-height: 100rpx;
text-align: center;
color: #FFFFFF;
border-radius: 0 !important;
}
.activeClass {
background-image: linear-gradient(45deg, #007AFF, #00aaff);
color: #FFFFFF;
}
.warning {
background-color: #ff9900;
}
.warning:active {
background-color: #ffaa00;
}
.primary {
background-color: #2979ff;
}
.primary:active {
background-color: #55aaff;
}
</style>
+683
View File
@@ -0,0 +1,683 @@
<template>
<view>
<!--基础信息-->
<view class="btName">基础信息</view>
<view @click="pickerSelectFun('客户性质')" class="flex-white-plr26 ptb20 mt32 bdb_f5">
<text class="mr26">客户性质<text class="redXingh">*</text></text>
<view :class="xingZhi ? '' : 'cBlack'">
{{xingZhi ? xingZhi : '请选择'}}
<u-icon class="ml26" name="arrow-right" size="40" color="#888888"></u-icon>
</view>
</view>
<view class="flex-white-plr26 ptb10 bdb_f5">
<text class="mr26">
<text>客户名称</text>
<text class="redXingh">*</text>
</text>
<u-input v-model="clientName" placeholder="请输入客户名称" />
</view>
<view v-if="xingZhi != '个人客户'" class="flex-white-plr26 ptb10 bdb_f5">
<text class="mr26">
<text>联系人</text>
<text class="redXingh">*</text>
</text>
<u-input v-model="lxRen" placeholder="请输入客户联系人" />
</view>
<view class="flex-white-plr26 ptb10 bdb_f5">
<text class="mr26">联系方式
<text class="redXingh">*</text>
</text>
<u-input v-model="phone" placeholder="请输入联系方式" />
</view>
<view @click="pickerSelectFun('客户来源')" class="flex-white-plr26 ptb20 bdb_f5">
<text class="mr26">客户来源
<text class="redXingh">*</text>
</text>
<view :class="laiYuan ? '' : 'cBlack'">
{{laiYuan ? laiYuan : '请选择'}}
<u-icon class="ml26" name="arrow-right" size="40" color="#888888"></u-icon>
</view>
</view>
<view @click="pickerShowFun('地区')" class="flex-white-plr26 ptb20 bdb_f5">
<text class="mr26">地区</text>
<view :class="region ? '' : 'cBlack'">
{{region ? region : '请选择'}}
<u-icon class="ml26" name="arrow-right" size="40" color="#888888"></u-icon>
</view>
</view>
<view class="flex-white-plr26 ptb20 bdb_f5" @click="chooseAddrFun">
<text class="mr26">地址</text>
<view class="width276" :class="address ? 'blackColor' : 'cBlack'">{{address ? address : '请在此选择详细地址'}}</view>
<u-icon class="ml26" name="map-fill" size="40" color="#007aff"></u-icon>
</view>
<!-- <view @click="pickerSelectFun('客户状态')" class="flex-white-plr26 ptb20 bdb_f5">
<text class="mr26">客户状态</text>
<view :class="companyState ? '' : 'cBlack'">
{{companyState ? companyState : '请选择'}}
<u-icon class="ml26" name="arrow-right" size="40" color="#888888"></u-icon>
</view>
</view> -->
<view @click="pickerSelectFun('客户阶段')" class="flex-white-plr26 ptb20 bdb_f5">
<text class="mr26">客户阶段</text>
<view :class="jieDuan ? '' : 'cBlack'">
{{jieDuan ? jieDuan : '请选择'}}
<u-icon class="ml26" name="arrow-right" size="40" color="#888888"></u-icon>
</view>
</view>
<view @click="pickerSelectFun('客户分级')" class="flex-white-plr26 ptb20 bdb_f5">
<text class="mr26">客户分级</text>
<view :class="fenJi ? '' : 'cBlack'">
{{fenJi ? fenJi : '请选择'}}
<u-icon class="ml26" name="arrow-right" size="40" color="#888888"></u-icon>
</view>
</view>
<view @click="pickerSelectFun('客户行业')" class="flex-white-plr26 ptb20 bdb_f5">
<text class="mr26">客户行业</text>
<view :class="hangYe ? '' : 'cBlack'">
{{hangYe ? hangYe : '请选择'}}
<u-icon class="ml26" name="arrow-right" size="40" color="#888888"></u-icon>
</view>
</view>
<!--关联信息-->
<!-- <view class="btName">关联信息</view>
<view class="flex-white-plr26 ptb20 bdb_f5 mt32">
<text class="mr26">添加联系人</text>
<view :class="lxRen ? '' : 'cBlack'">
{{lxRen ? lxRen : '请选择'}}
<u-icon class="ml26" name="arrow-right" size="40" color="#888888"></u-icon>
</view>
</view> -->
<u-picker :params="pickerParams" :safe-area-inset-bottom="true" end-year="2100" v-model="pickerShow" @confirm="pickerConfirmFun" :mode="pickerMode" :default-time="birthday"></u-picker>
<u-select v-model="selectShow" :list="selectList" @confirm="selectConfirmFun"></u-select>
<!--扩展信息-->
<view class="btName">扩展信息</view>
<view class="flex-white-plr26 ptb20 bdb_f5 mt32">
<text class="mr26">重要程度</text>
<u-rate :count="5" v-model="zycdNum" active-color="#ffaa00" size="36"></u-rate>
</view>
<view @click="pickerSelectFun('客户类型')" class="flex-white-plr26 ptb20 bdb_f5">
<text class="mr26">客户类型</text>
<view :class="type ? '' : 'cBlack'">
{{type ? type : '请选择'}}
<u-icon class="ml26" name="arrow-right" size="40" color="#888888"></u-icon>
</view>
</view>
<view class="flex-white-plr26 ptb10 bdb_f5">
<text class="mr26">客户官网</text>
<u-input v-model="guanWang" placeholder="请输入" />
</view>
<view class="flex-white-plr26 ptb10 bdb_f5">
<text class="mr26">客户简介</text>
<u-input v-model="jianJie" placeholder="请输入" />
</view>
<view class="flex-white-plr26 ptb20 mt32">
<u-input v-model="remark" placeholder="备注" maxlength="500" placeholderStyle="color: #303133;" type="textarea" />
</view>
<!-- <view class="btName">系统信息</view>
<view class="flex-white-plr26 ptb20 mt32 bdb_f5">
<text class="mr26">负责人</text>
<view :class="fuZeRen ? '' : 'cBlack'">
{{fuZeRen ? fuZeRen : '请选择'}}
<u-icon class="ml26" name="arrow-right" size="40" color="#888888"></u-icon>
</view>
</view>
<view class="flex-white-plr26 ptb20 bdb_f5">
<text class="mr26">协同人</text>
<view :class="xtRen ? '' : 'cBlack'">
{{xtRen ? xtRen : '请选择'}}
<u-icon class="ml26" name="arrow-right" size="40" color="#888888"></u-icon>
</view>
</view> -->
<!--提交按钮-->
<view class="submitView">
<u-button type="primary" class="submitBtn" :ripple="true" ripple-bg-color="#909399" @click="submitBtn">{{pageType =='' ? '提交' : '保存'}}</u-button>
</view>
</view>
</template>
<script>
let that = '';
import { crmKeHuApi, threadApi, czjlApi, threadGjApi } from '../../../static/utils/api.js'
export default {
data() {
return {
xsName: '',
clientName: '',
phone: '',
company: '',
position: '',
weChat: '',
mailbox: '',
radioList: [{
name: '男'
},
{
name: '女'
}
],
gender: '男',
birthday: '',
region: '',
remark: '',
pickerParams: {},
pickerShow: false,
pickerMode: 'time',
selectShow: false,
selectList: [],
selectType: '',
province: '',
city: '',
area: '',
address: '',
latitude: '',
longitude: '',
companyState: '潜在客户',
jieDuan: '初步接洽',
fuZeRenId: uni.$userInfo._id,
fuZeRen: uni.$userInfo.xingMing,
xtRen: '',
lxRen: '',
type: '',
xingZhi: '企业客户',
fenJi: '',
hangYe: '',
zycdNum: 0,
laiYuan: '公司资源',
guanWang: '',
jianJie: '',
pageType: '',
xgInfoObj: {},
isAdd: 0,
fkId: '',
zhuanWeiClientId: ''
}
},
onLoad(e) {
that = this;
if(e.type == 'update' || e.type == 'zhuanClient') {
that.setDataFun();
that.pageType = e.type;
if(e.type == 'update') {
uni.setNavigationBarTitle({
title: '修改客户信息'
})
} else {
uni.setNavigationBarTitle({
title: '线索转为客户'
})
}
}
if(e.isAdd) {
that.isAdd = e.isAdd;
if(uni.$addInfo) {
that.lxRen = uni.$addInfo.lxRen;
that.phone = uni.$addInfo.phone;
that.clientName = uni.$addInfo.clientName;
that.region = uni.$addInfo.region || '';
that.address = uni.$addInfo.address || '';
that.latitude = uni.$addInfo.latitude || '';
that.longitude = uni.$addInfo.longitude || '';
if(that.region) {
let regionArr = (that.region).split(" ");
that.province = regionArr[0];
that.city = regionArr[1];
that.area = regionArr[2];
}
if(uni.$addInfo.fkId) {
that.fkId = uni.$addInfo.fkId;
}
}
}
},
methods: {
// 单选框
radioGroupChange(e) {
that.gender = e;
},
pickerSelectFun: function(str) {
if(str == '客户状态') {
that.selectList = [
{ value: 0, label: '潜在客户'},
{ value: 1, label: '初步接触'},
{ value: 2, label: '持续跟进'},
{ value: 3, label: '成交客户'},
{ value: 4, label: '忠诚客户'},
{ value: 5, label: '无效客户'}
]
} else if(str == '客户阶段') {
that.selectList = [
{ value: 0, label: '初步接洽'},
{ value: 1, label: '确认需求'},
{ value: 2, label: '解决方案'},
{ value: 3, label: '商务谈判'},
{ value: 4, label: '成交'},
{ value: 5, label: '流失'}
]
} else if(str == '客户类型') {
that.selectList = [
{ value: 0, label: '最终客户'},
{ value: 1, label: '渠道客户'},
{ value: 2, label: '竞争对手'}
]
} else if(str == '客户性质') {
that.selectList = [
{ value: 0, label: '企业客户'},
{ value: 1, label: '个人客户'},
{ value: 2, label: '政府单位'},
{ value: 3, label: '事业单位'}
]
} else if(str == '客户分级') {
that.selectList = [
{ value: 0, label: '大型'},
{ value: 1, label: '中型'},
{ value: 2, label: '小型'},
{ value: 3, label: '微型'},
]
} else if(str == '客户行业') {
that.selectList = [
{ value: 0, label: '金融'},
{ value: 1, label: '电信'},
{ value: 2, label: '教育'},
{ value: 3, label: '高科技'},
{ value: 4, label: '政府'},
{ value: 5, label: '制造业'},
{ value: 6, label: '服务业'},
{ value: 7, label: '能源'},
{ value: 8, label: '零售'},
{ value: 9, label: '媒体'},
{ value: 10, label: '娱乐'},
{ value: 11, label: '咨询'},
{ value: 12, label: '非盈利事业'},
{ value: 13, label: '公用事业'},
{ value: 14, label: '其他'}
]
} else if(str == '客户来源') {
that.selectList = [
{ value: 0, label: '电话咨询'},
{ value: 1, label: '自主开拓'},
{ value: 2, label: '公司资源'},
{ value: 3, label: '网络推广'},
{ value: 4, label: '渠道代理'},
{ value: 5, label: '其他方式'}
]
}
that.selectShow = true;
that.selectType = str;
},
selectConfirmFun: function(e) {
let str = e[0].label;
if(that.selectType == '客户状态') {
that.companyState = str;
} else if(that.selectType == '客户阶段') {
that.jieDuan = str;
} else if(that.selectType == '客户类型') {
that.type = str;
} else if(that.selectType == '客户性质') {
that.xingZhi = str;
} else if(that.selectType == '客户分级') {
that.fenJi = str;
} else if(that.selectType == '客户行业') {
that.hangYe = str;
} else if(that.selectType == '客户来源') {
that.laiYuan = str;
}
},
// 展示选择器
pickerShowFun: function(str) {
if(str == '生日') {
that.pickerMode = 'time';
that.pickerParams = {
year: true,
month: true,
day: true
};
} else if(str == '地区') {
that.pickerMode = 'region';
that.pickerParams = {
province: true,
city: true,
area: true
};
} else if(str == '客户阶段'){
that.pickerMode = 'selector';
}
that.pickerShow = true;
},
// 点击确定按钮,返回当前选择的值
pickerConfirmFun: function(e) {
if(that.pickerMode == 'time') {
that.birthday = e.year + '-' + e.month + '-' + e.day
} else {
that.province = e.province.label;
that.city = e.city.label;
that.area = e.area.label;
that.region = that.province + ' ' + that.city + ' ' + that.area;
}
},
// 选择定位地点
chooseAddrFun: function() {
uni.chooseLocation({
success: function (res) {
that.address = res.address;
that.latitude = res.latitude;
that.longitude = res.longitude;
}
});
},
// 提交按钮
submitBtn: function() {
if(that.clientName == '') {
uni.showModal({
title: '提示',
content: '客户名称不能为空,请输入!',
showCancel: false
})
return
}
if(that.xingZhi != '个人客户' && that.lxRen == '') {
uni.showModal({
title: '提示',
content: '客户联系人不能为空,请输入!',
showCancel: false
})
return
}
if(that.phone == '') {
uni.showModal({
title: '提示',
content: '客户联系方式不能为空,请输入!',
showCancel: false
})
return
}
let reqObj = {
req: {
clientName: that.clientName,
phone: that.phone,
region: that.region,
address: that.address,
latitude: that.latitude,
longitude: that.longitude,
// companyState: that.companyState,
jieDuan: that.jieDuan,
fuZeRenId: that.fuZeRenId,
lxRen: that.lxRen,
type: that.type,
xingZhi: that.xingZhi,
fenJi: that.fenJi,
hangYe: that.hangYe,
zycdNum: that.zycdNum,
laiYuan: that.laiYuan,
guanWang: that.guanWang,
jianJie: that.jianJie,
remark: that.remark
}
}
let action = 'addKeHu';
if (that.pageType == 'update') {
action = 'update'
reqObj._id = that.xgInfoObj._id;
reqObj.req.update_date = new Date().getTime();
uni.showLoading({
title: '修改中...'
})
} else if(that.pageType == 'zhuanClient') {
let obj = reqObj.req;
let time = new Date().getTime()
obj.create_date = time;
obj.update_date = time;
obj.recently_date = '';
obj.genjin_date = '';
obj.isDelete = 0;
obj.status = 1;
if(obj.next_gjDate) {
if(obj.next_gjDate < time) {
that.$confirm('下次联系时间不能小于当前时间,请修改!', '提示', {
confirmButtonText: '确定',
type: 'warning',
showCancelButton: false
})
return
}
obj.awaitFollowUp = 1;
} else {
obj.awaitFollowUp = 0;
}
obj.cjRenId = uni.$userInfo._id;
obj.fuZeRenId = uni.$userInfo._id;
obj.threadId = that.xgInfoObj._id;
reqObj.req = obj;
uni.showLoading({
title: '保存中...'
})
} else {
reqObj.req.create_date = new Date().getTime();
reqObj.req.update_date = new Date().getTime();
reqObj.req.cjRenId = uni.$userInfo._id;
reqObj.req.fuZeRenId = uni.$userInfo._id;
reqObj.req.isDelete = 0;
reqObj.req.status = 1;
if(that.fkId) {
reqObj.req.fkId = that.fkId;
}
uni.showLoading({
title: '提交中...'
})
}
let reqData = {
action: action,
params: reqObj
}
crmKeHuApi(reqData)
.then(res => {
if (action == 'update') {
uni.showToast({
title: '客户修改成功',
icon: 'none',
duration: 888,
mask: true
})
that.addCzjlFun('update')
setTimeout(()=> {
uni.navigateBack()
}, 888)
} else {
if(that.pageType == 'zhuanClient') {
that.zhuanWeiClientId = res.result.id;
}
uni.showToast({
title: '客户新增成功',
icon: 'none',
duration: 1000,
mask: true
})
that.addCzjlFun('add')
let addObj = reqObj.req;
addObj._id = res.result.id;
if(that.isAdd) {
uni.$emit('addItemInListFun', addObj)
}
setTimeout(()=> {
addObj.cjRenName = uni.$userInfo.nickname;
addObj.fuZeRenName = uni.$userInfo.nickname;
uni.$khInfo = addObj;
uni.redirectTo({
url: './khDetail?index=0'
})
}, 1000)
}
})
},
addCzjlFun: function(action, _id) {
let czjlObj = {
create_date: new Date().getTime(),
czRen: uni.$userInfo._id,
pageType: 'client'
}
if(action == 'update') {
let xgInfoObj = that.xgInfoObj;
czjlObj.dataId = xgInfoObj._id;
czjlObj.type = '编辑'
czjlObj.newUpdate = new Date().getTime();
czjlObj.oldUpdate = xgInfoObj.update_date;
let content = [];
let str = '';
if(that.remark != xgInfoObj.remark) {
str = '修改 备注 ,由 "' + xgInfoObj.remark + '" 变更为 "' + that.remark + '"'
content.push(str)
}
if(that.jianJie != xgInfoObj.jianJie) {
str = '修改 客户简介 ,由 "' + xgInfoObj.jianJie + '" 变更为 "' + that.jianJie + '"'
content.push(str)
}
if(that.guanWang != xgInfoObj.guanWang) {
str = '修改 客户官网 ,由 "' + xgInfoObj.guanWang + '" 变更为 "' + that.guanWang + '"'
content.push(str)
}
if(that.laiYuan != xgInfoObj.laiYuan) {
str = '修改 客户来源 ,由 "' + xgInfoObj.laiYuan + '" 变更为 "' + that.laiYuan + '"'
content.push(str)
}
if(that.zycdNum != xgInfoObj.zycdNum) {
str = '修改 重要程度 ,由 "' + xgInfoObj.zycdNum + '" 变更为 "' + that.zycdNum + '"'
content.push(str)
}
if(that.hangYe != xgInfoObj.hangYe) {
str = '修改 客户行业 ,由 "' + xgInfoObj.hangYe + '" 变更为 "' + that.hangYe + '"'
content.push(str)
}
if(that.fenJi != xgInfoObj.fenJi) {
str = '修改 客户分级 ,由 "' + xgInfoObj.fenJi + '" 变更为 "' + that.fenJi + '"'
content.push(str)
}
if(that.xingZhi != xgInfoObj.xingZhi) {
str = '修改 客户性质 ,由 "' + xgInfoObj.xingZhi + '" 变更为 "' + that.xingZhi + '"'
content.push(str)
}
if(that.type != xgInfoObj.type) {
str = '修改 客户类型 ,由 "' + xgInfoObj.type + '" 变更为 "' + that.type + '"'
content.push(str)
}
if(that.lxRen != xgInfoObj.lxRen) {
str = '修改 联系人 ,由 "' + xgInfoObj.lxRen + '" 变更为 "' + that.lxRen + '"'
content.push(str)
}
if(that.xtRen != xgInfoObj.xtRen) {
str = '修改 协同人 ,由 "' + xgInfoObj.xtRen + '" 变更为 "' + that.xtRen + '"'
content.push(str)
}
if(that.fuZeRenId != xgInfoObj.fuZeRenId) {
str = '修改 负责人 ,由 "' + xgInfoObj.fuZeRen + '" 变更为 "' + that.fuZeRen + '"'
content.push(str)
}
if(that.jieDuan != xgInfoObj.jieDuan) {
str = '修改 客户阶段 ,由 "' + xgInfoObj.jieDuan + '" 变更为 "' + that.jieDuan + '"'
content.push(str)
}
// if(that.companyState != xgInfoObj.companyState) {
// str = '修改 客户状态 ,由 "' + xgInfoObj.companyState + '" 变更为 "' + that.companyState + '"'
// content.push(str)
// }
if(that.address != xgInfoObj.address) {
str = '修改 地址 ,由 "' + xgInfoObj.address + '" 变更为 "' + that.address + '"'
content.push(str)
}
if(that.region != xgInfoObj.region) {
str = '修改 地区 ,由 "' + xgInfoObj.region + '" 变更为 "' + that.region + '"'
content.push(str)
}
if(that.phone != xgInfoObj.phone) {
str = '修改 联系方式 ,由 "' + xgInfoObj.phone + '" 变更为 "' + that.phone + '"'
content.push(str)
}
if(that.clientName != xgInfoObj.clientName) {
str = '修改 客户名称 ,由 "' + xgInfoObj.clientName + '" 变更为 "' + that.clientName + '"'
content.push(str)
}
czjlObj.content = content.reverse()
} else {
czjlObj.dataId = _id;
czjlObj.type = '添加';
if(that.pageType == 'zhuanClient' && that.zhuanWeiClientId) {
that.setThreadDataFun();
}
}
uni.$czjlApiAddFun(czjlObj);
},
setThreadDataFun: function() {
let jjj = {
action: 'update',
params: {
_id: that.xgInfoObj._id,
req: {
status: 2
}
}
}
threadApi(jjj)
.then(res => {
uni.$emit('threadListChangeFun');
})
let rrr = {
action: 'zhuanClientCz',
params: {
dataId: that.xgInfoObj._id,
clientId: that.zhuanWeiClientId
}
}
czjlApi(rrr)
let ooo = {
action: 'zhuanClientGj',
params: {
dataId: that.xgInfoObj._id,
clientId: that.zhuanWeiClientId
}
}
threadGjApi(ooo)
},
// 初始化修改数据
setDataFun: function() {
let obj = uni.$infoObj;
that.xgInfoObj = uni.$infoObj;
that.clientName = obj.clientName;
that.phone = obj.phone;
that.region = obj.region;
that.address = obj.address;
that.latitude = obj.latitude;
that.longitude = obj.longitude;
// that.companyState = obj.companyState;
that.jieDuan = obj.jieDuan;
that.fuZeRen = obj.fuZeRen;
that.fuZeRenId = obj.fuZeRenId;
that.xtRen = obj.xtRen;
that.lxRen = obj.lxRen;
that.type = obj.type;
that.xingZhi = obj.xingZhi;
that.fenJi = obj.fenJi;
that.hangYe = obj.hangYe;
that.zycdNum = obj.zycdNum;
that.laiYuan = obj.laiYuan;
that.guanWang = obj.guanWang;
that.jianJie = obj.jianJie;
that.remark = obj.remark;
if(obj.region) {
let regionArr = (obj.region).split(" ");
that.province = regionArr[0];
that.city = regionArr[1];
that.area = regionArr[2];
}
}
}
}
</script>
<style>
page {
background-color: #F8F8F8;
padding-bottom: 260rpx;
}
.u-radio {
width: 200rpx !important;
}
</style>
+519
View File
@@ -0,0 +1,519 @@
<template>
<view>
<view class="u-demo-block">
<view class="u-page__tag-item">
<u-search v-model="searchCustomerName" :show-action="false" @custom="selectKehuFun"
@search="selectKehuFun" placeholder="请输入客户名称"></u-search>
</view>
</view>
<scroll-view scroll-y="true" :style="{height: scrollHeight}" @scrolltolower="selectKehuFun" refresher-enabled
:refresher-threshold="200" :refresher-triggered="triggered" refresher-background="gray"
@refresherrefresh="onRefresh" @refresherrestore="onRestore">
<view v-if="list.length > 0">
<view v-for="(item, index) in list" :key="index" @click="khCardClickFun(item)">
<khCard :item="item" :isSelect="isSelect" :index="index" @cxGetDataFun="cxGetDataFun"></khCard>
</view>
<getMore :isMore="isMore" nullMsg="已加载全部~"></getMore>
<view class="h200"></view>
</view>
<dataNull v-else src="/static/img/dataNull.png" title="暂无相关客户哦~"></dataNull>
</scroll-view>
<u-action-sheet :list="sheetList" v-model="moreShow"></u-action-sheet>
</view>
</template>
<script>
let that = this;
import {
tyDropDown,
dropDownByUser,
khsxData,
datePxData
} from '../../../static/utils/dropdown.js'
import {
getDayFun,
getDayByNumFun
} from '@/static/utils/date.js'
import dataNull from '@/components/dataNull/dataNull.vue'
import addBtn from '@/components/addBtn/addBtn.vue'
import getMore from '@/components/getMore/getMore.vue'
import topDropdown from '../../../components/topDropdown/topDropdown.vue'
import lianxiRow from '../../../components/lianxiRow/lianxiRow.vue'
import khCard from '../../../components/card/kehu.vue'
import util, {
playSuccessAudio,
playErrorAudio
} from '../../../common/util.js';
export default {
components: {
dataNull,
addBtn,
getMore,
topDropdown,
lianxiRow,
khCard
},
data() {
return {
CustomerName: '',
triggered: false,
dropdown1: '全部',
options1: tyDropDown,
optionsPx: datePxData,
searchCustomerName: '',
CustomerTypes: '',
sxList: [],
list: [],
moreShow: false,
sheetList: [{
text: '添加跟进'
},
{
text: '添加标签'
}
],
isMore: true,
pageIndex: 1,
scrollHeight: '667px',
pageType: '',
sortObj: {
update_date: -1
},
optionsReq: {}, // 第一个下拉框请求参数
dateReq: [], // 日期相关请求参数
sxReq: JSON.stringify({}), // 筛选想请求参数
matchObj: {},
searchValue: '',
isSelect: false,
tabNoEqualArr: [], //标签页不等于数据
depId: undefined
}
},
onLoad(e) {
that = this;
let khsxList = JSON.stringify(khsxData);
that.sxList = JSON.parse(khsxList);
let obj = {};
this.CustomerTypes = e.type;
this.pageType = e.type;
console.log(">>>" + e.type);
if (e.type) {
that.isSelect = true;
}
this.selectKehuFun();
},
onBackPress() {
uni.$off('deleteKhFun', that.deleteKhFun)
uni.$off('updateListByIndex', that.updateListByIndex)
uni.$off('addItemInListFun', that.addItemInListFun)
uni.$off('cxGetDataFun', that.cxGetDataFun)
},
methods: {
// 查询用户
selectKehuFun: function() {
let aSaleUserID = 0;
if (getApp().globalData.IsSaleUserStatus == 1)
aSaleUserID = getApp().globalData.EmployeeID;
console.log("-->>>>>>" + this.searchCustomerName);
uni.request({
url: util.apiurl + 'rest/db/opensql',
data: {
token: getApp().globalData.Token,
format: 'json',
data: {
db_name: getApp().globalData.AppDBName,
sql_command_id: 'APP.BaseData.GetCustomerData',
params: [{
name: 'SUID',
value: aSaleUserID
}, {
name: 'MUID',
value: aSaleUserID
}, {
name: 'CName',
value: '%' + this.searchCustomerName + '%'
}, {
name: 'CustomerTypes',
value: '%' + this.CustomerTypes + '%'
}]
},
},
success: (res) => {
this.triggered = false;
let data = res.data.data;
if (that.pageIndex == 1) {
that.list = [];
}
if (res.data == 20) {
that.pageIndex += 1;
that.isMore = true;
} else {
that.isMore = false;
}
that.list = that.list.concat(data);
},
})
},
// 客户点击方法
khCardClickFun: function(item) {
if (that.pageType == '客户') {
uni.$emit('bjdKehuBindFun', {
CustomerID: item.CustomerID,
CustomerName: item.CustomerName,
PlanDepartmentID: item.PlanDepartmentID,
PlanDepartmentName: item.PlanDepartmentName,
SaleUserID: item.SaleUserID,
SaleUserName: item.SaleUserName,
Remark: item.Remark,
CustomerAddress: item.CustomerAddress,
CustomerPhone: item.CustomerPhone,
CustomerLinkName: item.CustomerLinkName,
})
uni.navigateBack();
}else if (that.pageType == '织厂') {
uni.$emit('bjdKehuBindFun', {
CustomerID: item.CustomerID,
CustomerName: item.CustomerName,
PlanDepartmentID: item.PlanDepartmentID,
PlanDepartmentName: item.PlanDepartmentName,
SaleUserID: item.SaleUserID,
SaleUserName: item.SaleUserName,
Remark: item.Remark,
CustomerAddress: item.CustomerAddress,
CustomerPhone: item.CustomerPhone,
CustomerLinkName: item.CustomerLinkName,
})
uni.navigateBack();
} else if (that.pageType == '染整厂') {
uni.$emit('bjdKehuBindFun', {
CustomerID: item.CustomerID,
CustomerName: item.CustomerName,
PlanDepartmentID: item.PlanDepartmentID,
PlanDepartmentName: item.PlanDepartmentName,
SaleUserID: item.SaleUserID,
SaleUserName: item.SaleUserName,
Remark: item.Remark,
CustomerAddress: item.CustomerAddress,
CustomerPhone: item.CustomerPhone,
CustomerLinkName: item.CustomerLinkName,
})
uni.navigateBack();
} else if (that.pageType == '成品供应商') {
uni.$emit('bjdKehuBindFun', {
CustomerID: item.CustomerID,
CustomerName: item.CustomerName,
PlanDepartmentID: item.PlanDepartmentID,
PlanDepartmentName: item.PlanDepartmentName,
SaleUserID: item.SaleUserID,
SaleUserName: item.SaleUserName,
Remark: item.Remark,
CustomerAddress: item.CustomerAddress,
CustomerPhone: item.CustomerPhone,
CustomerLinkName: item.CustomerLinkName,
})
uni.navigateBack();
} else if (that.pageType == '') {
uni.$emit('bjdKehuBindFun', {
CustomerID: item.CustomerID,
CustomerName: item.CustomerName,
PlanDepartmentID: item.PlanDepartmentID,
PlanDepartmentName: item.PlanDepartmentName,
SaleUserID: item.SaleUserID,
SaleUserName: item.SaleUserName,
Remark: item.Remark,
CustomerAddress: item.CustomerAddress,
CustomerPhone: item.CustomerPhone,
CustomerLinkName: item.CustomerLinkName,
})
uni.navigateBack();
}
else if (that.pageType == 'lxr') {
uni.$emit('kehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'addGjjl') {
uni.$emit('gjKehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'sj') {
uni.$emit('sjKehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'saleallocated') {
uni.$emit('bjdKehuBindFun', {
CustomerID: item.CustomerID,
CustomerName: item.CustomerName,
PlanDepartmentID: item.PlanDepartmentID,
PlanDepartmentName: item.PlanDepartmentName,
SaleUserID: item.SaleUserID,
SaleUserName: item.SaleUserName,
Remark: item.Remark,
CustomerAddress: item.CustomerAddress,
CustomerPhone: item.CustomerPhone,
CustomerLinkName: item.CustomerLinkName,
})
uni.navigateBack()
} else if (that.pageType == 'heTong') {
uni.$emit('heTongdKehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'topDropDown') {
uni.$emit('topDropDownBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType != '') {
uni.$emit('kehuBindFun', item)
uni.navigateBack()
}
// else {
// uni.$khInfo = item;
// uni.navigateTo({
// url: './khDetail'
// })
// }
},
// 下拉框回调函数
dropDownFun1: function(e) {
let optionsReq = {};
let tabNoEqualArr = [];
let userInfo = uni.$userInfo;
that.depId = undefined;
if (e.label == '全部') {
that.depId = userInfo.depManager_Id;
} else if (e.label == '我负责的') {
optionsReq.fuZeRenId = userInfo._id;
} else if (e.label == '我创建的') {
optionsReq.cjRenId = userInfo._id;
} else if (e.label == '下属负责') {
that.depId = userInfo.depManager_Id;
tabNoEqualArr = [{
field: 'fuZeRenId',
value: userInfo._id
}]
optionsReq.department = userInfo.departmentId;
} else if (e.label == '下属创建') {
that.depId = userInfo.depManager_Id;
tabNoEqualArr = [{
field: 'cjRenId',
value: userInfo._id
}]
}
that.tabNoEqualArr = tabNoEqualArr;
that.optionsReq = JSON.stringify(optionsReq);
that.matchObj = Object.assign(optionsReq, JSON.parse(that.sxReq));
that.cxGetDataFun();
},
// 筛选框回调函数
optionSxFun: function(arr) {
let matchReq = [];
let dateReq = [];
for (var i = 0; i < arr.length; i++) {
if (arr[i].current !== '' && !arr[i].isDate) {
matchReq.push({
field: arr[i].field,
value: arr[i].arr[arr[i].current]
})
} else if (arr[i].current !== '' && arr[i].isDate) {
dateReq.push({
field: arr[i].field,
sTime: arr[i].sTime,
eTime: arr[i].eTime
})
}
}
let reqObj = {};
// 动态生成请求对象
for (var i = 0; i < matchReq.length; i++) {
reqObj[matchReq[i].field] = matchReq[i].value
}
that.dateReq = dateReq;
that.sxReq = JSON.stringify(reqObj);
// 合并对象
that.matchObj = Object.assign(reqObj, JSON.parse(that.optionsReq));
that.cxGetDataFun();
},
// 排序筛选框回调函数
optionPxFun: function(arr) {
let sortObj = {
update_date: -1
}
for (var i = 0; i < arr.length; i++) {
if (arr[i].current !== '') {
sortObj = {}
if (arr[i].field == 'create_date') {
sortObj.create_date = arr[i].current == 1 ? 1 : -1
}
if (arr[i].field == 'update_date') {
sortObj.update_date = arr[i].current == 1 ? 1 : -1
}
if (arr[i].field == 'genjin_date') {
sortObj.genjin_date = arr[i].current == 1 ? 1 : -1
}
that.sortObj = sortObj;
break;
}
}
that.cxGetDataFun();
},
// 搜索框回调方法
searchBoxEmitFun: function(e) {
that.searchValue = e.searchValue1;
that.cxGetDataFun()
},
// 下拉刷新
onRefresh: function() {
if (that.triggered) return
that.triggered = true;
that.cxGetDataFun();
},
onRestore: function(e) {
that.triggered = false; // 需要重置
},
// 重新获取数据
cxGetDataFun: function() {
that.pageIndex = 1;
that.isMore = true;
that.selectKehuFun();
},
deleteKhFun: function(e) {
let arr = that.list;
arr.splice(e.index, 1);
that.list = arr;
},
// 通过下标更新list数据
updateListByIndex: function(e) {
that.$set(that.list, parseInt(e.index), e.obj)
},
// add页面新增数据
addItemInListFun: function(e) {
let arr = that.list;
arr.unshift(e);
that.list = arr;
uni.pageScrollTo({
scrollTop: 0
})
}
}
}
</script>
<style>
page {
background-color: #F8F8F8;
}
.card {
width: 698rpx;
padding: 26rpx 26rpx 10rpx;
margin: 32rpx 26rpx;
box-sizing: border-box;
border-radius: 8rpx;
box-shadow: #d8d8d8 0px 0px 16rpx;
position: relative;
background-color: #FFFFFF;
}
.genjinBtn {
position: absolute;
right: 26rpx;
top: 26rpx;
background-color: #007AFF;
color: #FFFFFF;
text-align: center;
padding: 6rpx 16rpx;
border-radius: 6rpx;
font-size: 14px;
}
.genjinBtn:active {
background-color: #13B8FF;
}
.topRow {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.txView {
width: 128rpx;
height: 128rpx;
border-radius: 50%;
overflow: hidden;
margin-right: 26rpx;
}
.txViewImg {
width: 100%;
height: 100%;
}
.info {
width: 492rpx;
font-size: 15px;
color: #000;
}
.name {
font-size: 16px;
margin-bottom: 8rpx;
color: #000000;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: bold;
}
.bottomRow {
width: 100%;
padding-top: 16rpx;
display: flex;
align-items: center;
justify-content: space-between;
border-top: 1rpx solid #f0f0f0;
font-size: 15px;
color: #007AFF;
}
.lxRow {
display: flex;
align-items: center;
}
.lxRow>image {
width: 52rpx;
height: 52rpx;
margin-right: 26rpx;
}
.bqRow {
display: flex;
align-items: center;
flex-wrap: wrap;
}
.bqRow>text {
font-size: 14px;
color: #888888;
}
.bqRow>view {
padding: 6rpx 16rpx;
font-size: 14px;
background-color: rgba(255, 85, 127, 0.1);
color: #ff5500;
border-radius: 10rpx;
margin: 6rpx 26rpx 20rpx 0;
}
</style>
@@ -0,0 +1,299 @@
<template>
<view>
<view class="u-demo-block">
<view class="u-page__tag-item">
<u-search v-model="searchCustomerName" :show-action="false" @custom="selectKehuFun"
@search="selectKehuFun" placeholder="请输入客户名称"></u-search>
</view>
</view>
<scroll-view scroll-y="true" :style="{height: scrollHeight}" @scrolltolower="selectKehuFun" refresher-enabled
:refresher-threshold="200" :refresher-triggered="triggered" refresher-background="gray"
@refresherrefresh="onRefresh" @refresherrestore="onRestore">
<view v-if="list.length > 0">
<view v-for="(item, index) in list" :key="index" @click="khCardClickFun(item)">
<khCard :item="item" :isSelect="isSelect" :index="index" @cxGetDataFun="cxGetDataFun"></khCard>
</view>
</view>
</scroll-view>
<u-action-sheet :list="sheetList" v-model="moreShow"></u-action-sheet>
</view>
</template>
<script>
let that = this;
import dataNull from '@/components/dataNull/dataNull.vue'
import addBtn from '@/components/addBtn/addBtn.vue'
import getMore from '@/components/getMore/getMore.vue'
import topDropdown from '../../../components/topDropdown/topDropdown.vue'
import lianxiRow from '../../../components/lianxiRow/lianxiRow.vue'
import khCard from '../../../components/card/kehu.vue'
import util, {
playSuccessAudio,
playErrorAudio
} from '../../../common/util.js';
export default {
components: {
dataNull,
addBtn,
getMore,
topDropdown,
lianxiRow,
khCard
},
data() {
return {
triggered: false,
searchCustomerName: '',
CustomerTypes: '',
list: [],
moreShow: false,
isMore: true,
pageIndex: 1,
scrollHeight: '667px',
sheetList: [{
text: '添加跟进'
},
{
text: '添加标签'
}
],
}
},
onLoad(e) {
that = this;
uni.getSystemInfo({
success(res) {
that.scrollHeight = res.windowHeight - 40 + 'px';
}
})
this.CustomerTypes = e.type;
console.log(">>>" + e.type);
if (e.type) {
that.isSelect = true;
}
this.selectKehuFun();
},
methods: {
// 查询用户
selectKehuFun: function() {
console.log("---->>>" + this.searchCustomerName);
let aSaleUserID = 0;
if (getApp().globalData.IsSaleUserStatus == 1)
aSaleUserID = getApp().globalData.EmployeeID;
uni.request({
url: util.apiurl + 'rest/db/opensql',
data: {
token: getApp().globalData.Token,
format: 'json',
data: {
db_name: getApp().globalData.AppDBName,
sql_command_id: 'APP.BaseData.GetCustomerData',
params: [{
name: 'SUID',
value: aSaleUserID
}, {
name: 'MUID',
value: aSaleUserID
}, {
name: 'CName',
value: '%' + this.searchCustomerName + '%'
}, {
name: 'CustomerTypes',
value: '%' + this.CustomerTypes + '%'
}]
},
},
success: (res) => {
let data = res.data.data;
console.log("---->>>" + JSON.stringify(res.data.data));
that.list = that.list.concat(data);
},
})
},
// 搜索框回调方法
searchBoxEmitFun: function(e) {
that.searchValue = e.searchValue1;
that.cxGetDataFun()
},
// 下拉刷新
onRefresh: function() {
if (that.triggered) return
that.triggered = true;
that.cxGetDataFun();
},
onRestore: function(e) {
that.triggered = false; // 需要重置
},
// 重新获取数据
cxGetDataFun: function() {
that.pageIndex = 1;
that.isMore = true;
that.selectKehuFun();
},
// 客户点击方法
khCardClickFun: function(item) {
if (that.pageType == 'lxr') {
uni.$emit('kehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'addGjjl') {
uni.$emit('gjKehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'sj') {
uni.$emit('sjKehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'saleallocated') {
uni.$emit('bjdKehuBindFun', {
CustomerID: item.CustomerID,
CustomerName: item.CustomerName,
PlanDepartmentID: item.PlanDepartmentID,
PlanDepartmentName: item.PlanDepartmentName,
SaleUserID: item.SaleUserID,
SaleUserName: item.SaleUserName,
Remark: item.Remark,
CustomerAddress: item.CustomerAddress,
CustomerPhone: item.CustomerPhone,
CustomerLinkName: item.CustomerLinkName,
})
uni.navigateBack()
} else if (that.pageType == 'heTong') {
uni.$emit('heTongdKehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'topDropDown') {
uni.$emit('topDropDownBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType != '') {
uni.$emit('kehuBindFun', item)
uni.navigateBack()
}
},
}
}
</script>
<style>
page {
background-color: #F8F8F8;
}
.card {
width: 698rpx;
padding: 26rpx 26rpx 10rpx;
margin: 32rpx 26rpx;
box-sizing: border-box;
border-radius: 8rpx;
box-shadow: #d8d8d8 0px 0px 16rpx;
position: relative;
background-color: #FFFFFF;
}
.genjinBtn {
position: absolute;
right: 26rpx;
top: 26rpx;
background-color: #007AFF;
color: #FFFFFF;
text-align: center;
padding: 6rpx 16rpx;
border-radius: 6rpx;
font-size: 14px;
}
.genjinBtn:active {
background-color: #13B8FF;
}
.topRow {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.txView {
width: 128rpx;
height: 128rpx;
border-radius: 50%;
overflow: hidden;
margin-right: 26rpx;
}
.txViewImg {
width: 100%;
height: 100%;
}
.info {
width: 492rpx;
font-size: 15px;
color: #000;
}
.name {
font-size: 16px;
margin-bottom: 8rpx;
color: #000000;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: bold;
}
.bottomRow {
width: 100%;
padding-top: 16rpx;
display: flex;
align-items: center;
justify-content: space-between;
border-top: 1rpx solid #f0f0f0;
font-size: 15px;
color: #007AFF;
}
.lxRow {
display: flex;
align-items: center;
}
.lxRow>image {
width: 52rpx;
height: 52rpx;
margin-right: 26rpx;
}
.bqRow {
display: flex;
align-items: center;
flex-wrap: wrap;
}
.bqRow>text {
font-size: 14px;
color: #888888;
}
.bqRow>view {
padding: 6rpx 16rpx;
font-size: 14px;
background-color: rgba(255, 85, 127, 0.1);
color: #ff5500;
border-radius: 10rpx;
margin: 6rpx 26rpx 20rpx 0;
}
</style>
+428
View File
@@ -0,0 +1,428 @@
<template>
<view>
<topDropdown :isSxShow="true" :isPaiXu="true" :dropdown1="dropdown1" :options1="options1" :optionsSx="sxList" :optionsPx="optionsPx" :isDuoXuan="true" searchLabel1="客户名称" searchPh1="请输入客户名称" @searchBoxEmitFun="searchBoxEmitFun" @dropDownFun1="dropDownFun1" @optionSxFun="optionSxFun" @optionPxFun="optionPxFun"></topDropdown> <!-- searchUrl="../search/search?type=客户搜索"-->
<scroll-view scroll-y="true" :style="{height: scrollHeight}" @scrolltolower="selectKehuFun"
refresher-enabled :refresher-threshold="200" :refresher-triggered="triggered" refresher-background="gray"
@refresherrefresh="onRefresh" @refresherrestore="onRestore">
<view v-if="list.length > 0">
<view v-for="(item, index) in list" :key="index" @click="khCardClickFun(item)">
<khCard :item="item" :isSelect="isSelect" :index="index" @cxGetDataFun="cxGetDataFun"></khCard>
</view>
<getMore :isMore="isMore" nullMsg="已加载全部~"></getMore>
<view class="h200"></view>
</view>
<dataNull v-else src="/static/img/dataNull.png" title="暂无相关客户哦~"></dataNull>
</scroll-view>
<u-action-sheet :list="sheetList" v-model="moreShow"></u-action-sheet>
</view>
</template>
<script>
let that = this;
import {
crmKeHuApi
} from '../../../static/utils/api.js'
import { cjDropDownData, cjDropDownData1, khsxData, datePxData } from '../../../static/utils/dropdown.js'
import dataNull from '@/components/dataNull/dataNull.vue'
import getMore from '@/components/getMore/getMore.vue'
import topDropdown from '../../../components/topDropdown/topDropdown.vue'
import lianxiRow from '../../../components/lianxiRow/lianxiRow.vue'
import khCard from '../../../components/card/kehu.vue'
export default {
components: {
dataNull,
getMore,
topDropdown,
lianxiRow,
khCard
},
data() {
return {
triggered: false,
dropdown1: '全部',
options1: [],
optionsPx: datePxData,
sxList: [],
list: [],
moreShow: false,
sheetList: [{
text: '添加跟进'
},
{
text: '添加标签'
}
],
isMore: true,
pageIndex: 1,
scrollHeight: '667px',
pageType: '',
sortObj: {
update_date: -1
},
optionsReq: {}, // 第一个下拉框请求参数
dateReq: [], // 日期相关请求参数
sxReq: JSON.stringify({}), // 筛选想请求参数
matchObj: {},
searchValue: '',
isSelect: false,
tabNoEqualArr: [], //标签页不等于数据
depId: undefined
}
},
onLoad(e) {
that = this;
let khsxList = JSON.stringify(khsxData);
that.sxList = JSON.parse(khsxList);
let obj = {
status: 0
};
if(uni.$userInfo.isDepManager) {
that.options1 = cjDropDownData;
that.depId = uni.$userInfo.depManager_Id;
} else {
that.options1 = cjDropDownData1;
obj.cjRenId = uni.$userInfo._id;
}
if(e.type) {
that.isSelect = true;
}
that.matchObj = obj;
that.optionsReq = JSON.stringify(obj);
that.pageType = e.type ? e.type : '';
uni.getSystemInfo({
success(res) {
that.scrollHeight = res.windowHeight - 40 + 'px';
}
})
that.selectKehuFun();
uni.$on('deleteKhFun', that.deleteKhFun)
uni.$on('updateListByIndex', that.updateListByIndex)
uni.$on('addItemInListFun', that.addItemInListFun)
uni.$on('cxGetDataFun', that.cxGetDataFun)
},
onBackPress() {
uni.$off('deleteKhFun', that.deleteKhFun)
uni.$off('updateListByIndex', that.updateListByIndex)
uni.$off('addItemInListFun', that.addItemInListFun)
uni.$off('cxGetDataFun', that.cxGetDataFun)
},
methods: {
// 查询用户
selectKehuFun: function() {
if (!that.isMore) {
return
}
uni.showLoading({
title: '加载中...',
mask: true
})
let matchObj = {
status: 0,
}
Object.assign(matchObj, that.matchObj);
let reqObj = {
matchObj,
dateReq: that.dateReq,
pageIndex: that.pageIndex,
depId: that.depId,
tabNoEqualArr: that.tabNoEqualArr,
sortObj: that.sortObj,
searchValue: that.searchValue,
isFzrLookup: "$cjRenId"
}
let reqData = {
action: 'selectKehu',
params: reqObj
}
console.log(reqData)
crmKeHuApi(reqData)
.then(res => {
this.triggered = false;
let data = res.result.data;
console.log(data)
if (that.pageIndex == 1) {
that.list = [];
}
if (data.length == 20) {
that.pageIndex += 1;
that.isMore = true;
} else {
that.isMore = false;
}
that.list = that.list.concat(data);
})
},
// 客户点击方法
khCardClickFun: function(item) {
if (that.pageType == 'lxr') {
uni.$emit('kehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'addGjjl') {
uni.$emit('gjKehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'sj') {
uni.$emit('sjKehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'bjd') {
uni.$emit('bjdKehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'heTong') {
uni.$emit('heTongdKehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if(that.pageType == 'topDropDown') {
uni.$emit('topDropDownBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if(that.pageType != '') {
uni.$emit('kehuBindFun', item)
uni.navigateBack()
}
// else {
// uni.$khInfo = item;
// uni.navigateTo({
// url: './khDetail'
// })
// }
},
// 下拉框回调函数
dropDownFun1: function(e) {
let optionsReq = {};
let tabNoEqualArr = [];
let userInfo = uni.$userInfo;
that.depId = undefined;
if(e.label == '全部') {
that.depId = userInfo.depManager_Id;
} else if(e.label == '我创建的') {
optionsReq.cjRenId = userInfo._id;
} else if(e.label == '下属创建') {
that.depId = userInfo.depManager_Id;
tabNoEqualArr = [{
field: 'cjRenId',
value: userInfo._id
}]
}
that.tabNoEqualArr = tabNoEqualArr;
that.optionsReq = JSON.stringify(optionsReq);
that.matchObj = Object.assign(optionsReq, JSON.parse(that.sxReq));
that.cxGetDataFun();
},
// 筛选框回调函数
optionSxFun: function(arr) {
let matchReq = [];
let dateReq = [];
for (var i = 0; i < arr.length; i++) {
if(arr[i].current !== '' && !arr[i].isDate) {
matchReq.push({
field: arr[i].field,
value: arr[i].arr[arr[i].current]
})
} else if(arr[i].current !== '' && arr[i].isDate) {
dateReq.push({
field: arr[i].field,
sTime: arr[i].sTime,
eTime: arr[i].eTime
})
}
}
let reqObj = {};
// 动态生成请求对象
for(var i = 0; i < matchReq.length; i++) {
reqObj[matchReq[i].field] = matchReq[i].value
}
that.dateReq = dateReq;
that.sxReq = JSON.stringify(reqObj);
// 合并对象
that.matchObj = Object.assign(reqObj, JSON.parse(that.optionsReq));
that.cxGetDataFun();
},
// 排序筛选框回调函数
optionPxFun: function(arr) {
let sortObj = {
update_date: -1
}
for (var i = 0; i < arr.length; i++) {
if (arr[i].current !== '') {
sortObj = {}
if (arr[i].field == 'create_date') {
sortObj.create_date = arr[i].current == 1 ? 1 : -1
}
if (arr[i].field == 'update_date') {
sortObj.update_date = arr[i].current == 1 ? 1 : -1
}
if (arr[i].field == 'genjin_date') {
sortObj.genjin_date = arr[i].current == 1 ? 1 : -1
}
that.sortObj = sortObj;
break;
}
}
that.cxGetDataFun();
},
// 搜索框回调方法
searchBoxEmitFun: function(e) {
that.searchValue = e.searchValue1;
that.cxGetDataFun()
},
// 下拉刷新
onRefresh: function() {
if(that.triggered) return
that.triggered = true;
that.cxGetDataFun();
},
onRestore: function(e) {
that.triggered = false; // 需要重置
},
// 重新获取数据
cxGetDataFun: function() {
that.pageIndex = 1;
that.isMore = true;
that.selectKehuFun();
},
deleteKhFun: function(e) {
let arr = that.list;
arr.splice(e.index, 1);
that.list = arr;
},
// 通过下标更新list数据
updateListByIndex: function(e) {
that.$set(that.list, parseInt(e.index), e.obj)
},
// add页面新增数据
addItemInListFun: function(e) {
let arr = that.list;
arr.unshift(e);
that.list = arr;
uni.pageScrollTo({
scrollTop: 0
})
}
}
}
</script>
<style>
page {
background-color: #F8F8F8;
}
.card {
width: 698rpx;
padding: 26rpx 26rpx 10rpx;
margin: 32rpx 26rpx;
box-sizing: border-box;
border-radius: 8rpx;
box-shadow: #d8d8d8 0px 0px 16rpx;
position: relative;
background-color: #FFFFFF;
}
.genjinBtn {
position: absolute;
right: 26rpx;
top: 26rpx;
background-color: #007AFF;
color: #FFFFFF;
text-align: center;
padding: 6rpx 16rpx;
border-radius: 6rpx;
font-size: 14px;
}
.genjinBtn:active {
background-color: #13B8FF;
}
.topRow {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.txView {
width: 128rpx;
height: 128rpx;
border-radius: 50%;
overflow: hidden;
margin-right: 26rpx;
}
.txViewImg {
width: 100%;
height: 100%;
}
.info {
width: 492rpx;
font-size: 15px;
color: #000;
}
.name {
font-size: 16px;
margin-bottom: 8rpx;
color: #000000;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: bold;
}
.bottomRow {
width: 100%;
padding-top: 16rpx;
display: flex;
align-items: center;
justify-content: space-between;
border-top: 1rpx solid #f0f0f0;
font-size: 15px;
color: #007AFF;
}
.lxRow {
display: flex;
align-items: center;
}
.lxRow>image {
width: 52rpx;
height: 52rpx;
margin-right: 26rpx;
}
.bqRow {
display: flex;
align-items: center;
flex-wrap: wrap;
}
.bqRow>text {
font-size: 14px;
color: #888888;
}
.bqRow>view {
padding: 6rpx 16rpx;
font-size: 14px;
background-color: rgba(255, 85, 127, 0.1);
color: #ff5500;
border-radius: 10rpx;
margin: 6rpx 26rpx 20rpx 0;
}
</style>
+792
View File
@@ -0,0 +1,792 @@
<template>
<view class="content">
<!-- 此处为了让reload时不自动滚动到顶部,需要设置auto-clean-list-when-reload和auto-scroll-to-top-when-reload为false,即在reload时关闭自动清空数组和自动滚动到顶部 -->
<z-paging ref="paging" :auto-clean-list-when-reload="false" :auto-scroll-to-top-when-reload="false" style="height: calc(100% - 55px);" @scrolltolower="scrollToBottomFun">
<!--客户基本信息-->
<khCard :item="khInfo" :isSelect="true"></khCard>
<!--客户阶段-->
<view class="myCard">
<view class="cardTopName disFlexJ">
<text>客户阶段</text>
<view v-if="khInfo.status == 1" style="color: #F29100;" @click="pickerSelectFun('客户阶段')">
更改
<u-icon name="edit-pen-fill" color="#F29100"></u-icon>
</view>
</view>
<u-steps class="width100" mode="number" active-color="#00aa00" :list="jieDuanList" :current="jieDuanIndex"></u-steps>
</view>
<!-- <view class="myCard">
<view class="cardTopName disFlexJ">
<text>客户状态</text>
<view style="color: #F29100;" @click="pickerSelectFun('客户状态')">
更改
<u-icon name="edit-pen-fill" color="#F29100"></u-icon>
</view>
</view>
<u-steps class="width100" active-color="#00aa00" mode="number" :list="stateList" :current="stateIndex"></u-steps>
</view> -->
<!--tab-->
<view class="uTabsView">
<u-tabs :list="tabList" :is-scroll="true" duration="0.08" :current="tabIndex" :show-bar="false" font-size="32" @change="tabChange"></u-tabs>
</view>
<!-- 自定义下拉刷新view -->
<!-- <custom-refresher slot="refresher" :status="refresherStatus"></custom-refresher> -->
<!-- list数据,建议像下方这样在item外层套一个view,而非直接for循环item,因为slot插入有数量限制 -->
<view class="contentView">
<!--详细信息-->
<view v-if="tabIndex == 0">
<khDetail :khInfo="khInfo"></khDetail>
</view>
<!--跟进记录-->
<view v-if="tabIndex == 1">
<view v-for="(item, index) in tabList[1].arr" :key="index">
<genjin :item="item"></genjin>
</view>
</view>
<!--联系人-->
<view v-if="tabIndex == 2">
<view v-for="(item, index) in tabList[2].arr" :key="index">
<lianXiRen :item="item" :isHideMore="true"></lianXiRen>
</view>
</view>
<!--商机-->
<view v-if="tabIndex == 3">
<view v-for="(item, index) in tabList[3].arr" :key="index">
<shangji :item="item"></shangji>
</view>
</view>
<!--报价单-->
<view v-if="tabIndex == 4">
<view v-for="(item, index) in tabList[4].arr" :key="index">
<baojiadan :item="item"></baojiadan>
</view>
</view>
<!--合同-->
<view v-if="tabIndex == 5">
<view v-for="(item, index) in tabList[5].arr" :key="index">
<hetong :item="item"></hetong>
</view>
</view>
<!--回款计划-->
<view v-if="tabIndex == 6">
<view v-for="(item, index) in tabList[6].arr" :key="index">
<huikuanJH :item="item"></huikuanJH>
</view>
</view>
<!--实际回款-->
<view v-if="tabIndex == 7">
<view v-for="(item, index) in tabList[7].arr" :key="index">
<shijiHK :item="item"></shijiHK>
</view>
</view>
<!--发票-->
<view v-if="tabIndex == 8">
<view v-for="(item, index) in tabList[8].arr" :key="index">
<fapiao :item="item"></fapiao>
</view>
</view>
<!--发票-->
<view v-if="tabIndex == 9">
<view v-for="(item, index) in tabList[9].arr" :key="index">
<fapiao :item="item"></fapiao>
</view>
</view>
<!--操作记录-->
<view v-if="tabIndex == 8">
<czjl :dataId="khInfo._id" pageType="client" :infoObj="khInfo" fl="客户"></czjl>
</view>
<!--加载更多-->
<getMore :isMore="tabList[tabIndex].isMore"></getMore>
</view>
</z-paging>
<bottomBox :sheetList="sheetList" :addSheetList="addSheetList" :item="khInfo" :isGhc="khInfo.status == 0" :isKh="khInfo.status == 1" @pageGenjinFun="pageGenjinFun" @pageDeleteShowFun="pageDeleteShowFun" @pageAddSheetFun="pageAddSheetFun" @pageBianjiFun="pageBianjiFun" @cxPGetDataFun="cxPGetDataFun"></bottomBox>
<u-select v-model="selectShow" :list="selectList" @confirm="selectConfirmFun"></u-select>
</view>
</template>
<script>
let that = '';
import { crmGenJinApi, crmLianXiRenApi, crmShangJiApi, crmBaoJiaDanApi, crmHeTongApi, crmHkjhApi, crmHkdApi, crmKeHuApi } from '../../../static/utils/api.js'
import khCard from '@/components/card/kehu.vue'
import bottomBox from '@/components/bottomBox/bottomBox'
import khDetail from '@/components/detail/kehuDetail'
import genjin from '@/components/card/genjin.vue'
import lianXiRen from '@/components/card/lianXiRen.vue'
import shangji from '@/components/card/shangji.vue'
import baojiadan from '@/components/card/baojiadan.vue'
import hetong from '@/components/card/hetong.vue'
import huikuanJH from '@/components/card/huikuanJH.vue'
import shijiHK from '@/components/card/shijiHK.vue'
import fapiao from '@/components/card/fapiao.vue'
import czjl from '@/components/detail/czjl.vue'
import getMore from '@/components/getMore/getMore.vue'
export default {
components: {
khCard,
bottomBox,
khDetail,
genjin,
lianXiRen,
shangji,
hetong,
baojiadan,
huikuanJH,
shijiHK,
fapiao,
czjl,
getMore
},
data() {
return {
selectList: [],
jieDuanIndex: 0,
jieDuanList: [
{ value: 0, name: '初步接洽'},
{ value: 1, name: '确认需求'},
{ value: 2, name: '解决方案'},
{ value: 3, name: '商务谈判'},
{ value: 4, name: '成交'}
],
stateList: [
{ value: 0, name: '潜在客户'},
{ value: 1, name: '初步接触'},
{ value: 2, name: '持续跟进'},
{ value: 3, name: '成交客户'},
{ value: 4, name: '忠诚客户'}
],
stateIndex: 0,
selectShow: false,
khInfo: {},
dataList: [],
tabList: [
{ name: '详细信息', arr: [], pageIndex: 1, isMore: false },
{ name: '跟进记录', arr: [], pageIndex: 1, isMore: true },
{ name: '联系人', arr: [], pageIndex: 1, isMore: true },
{ name: '商机', arr: [], pageIndex: 1, isMore: true },
{ name: '报价单', arr: [], pageIndex: 1, isMore: true },
{ name: '合同', arr: [], pageIndex: 1, isMore: true },
{ name: '回款计划', arr: [], pageIndex: 1, isMore: true },
{ name: '实际回款', arr: [], pageIndex: 1, isMore: true },
// { name: '发票', arr: [], pageIndex: 1, isMore: true },
// { name: '退货退款', arr: [], pageIndex: 1, isMore: true },
{ name: '操作记录', isMore: false },
],
hzList: [
{ name: '跟进次数', num: 1 },
{ name: '联系人', num: 1 },
{ name: '商机', num: 1 },
{ name: '报价单', num: 1 },
{ name: '合同', num: 1 },
{ name: '回款计划', num: 1 },
{ name: '实际回款', num: 1 },
{ name: '发票', num: 1 },
{ name: '操作记录', num: 1 },
],
sheetList: [
{ text: '更换负责人' },
{ text: '放入客户池' },
{ text: '删除' }
],
addSheetList: [
{ text: '跟进记录' },
{ text: '联系人' },
{ text: '商机' },
{ text: '报价单' },
{ text: '合同' },
{ text: '回款计划' },
{ text: '实际回款' },
{ text: '发票' },
{ text: '退货退款' }
],
tabIndex: 0,
refresherStatus: 0,
cardIndex: -1,
isLoadSelectKhById: false
}
},
onLoad(e) {
that = this;
that.cardIndex = e.index || -1;
that.khInfo = uni.$khInfo || {};
that.setJieduanAndStateFun()
uni.setNavigationBarTitle({
title: that.khInfo.clientName || '客户详情'
})
if(e.fromDetail) {
that.selectKhByIdFun(e._id)
}
},
onBackPress(e) {
if(e.from == 'backbutton' && this.cardIndex != -1) {
uni.$emit('updateListByIndex', { index: this.cardIndex, obj: this.khInfo})
}
},
onShow() {
if(that.isLoadSelectKhById) {
that.selectKhByIdFun();
}
},
methods: {
tabChange(index) {
this.tabIndex = index;
let item = that.tabList[index];
if(item.arr && item.arr.length > 0) {
return
}
if(index == 1) {
that.getGenJinFun()
} else if(index == 2) {
that.selectLxrFun()
} else if(index == 3) {
that.getShangjiFun()
} else if(index == 4) {
that.getBaojiaDanFun()
} else if(index == 5) {
that.getHeTongFun()
} else if(index == 6) {
that.getHuiKuanJhFun()
} else if(index == 7) {
that.getHuiKuanDanFun()
} else if(index == 8) {
} else if(index == 9) {
} else if(index == 10) {
}
},
scrollToBottomFun: function(e) {
let index = that.tabIndex;
let isMore = that.tabList[index].isMore;
if(!isMore) {
return
}
if(index == 1) {
that.getGenJinFun()
} else if(index == 2) {
that.selectLxrFun()
} else if(index == 3) {
that.getShangjiFun()
} else if(index == 4) {
that.getBaojiaDanFun()
} else if(index == 5) {
that.getHeTongFun()
} else if(index == 6) {
that.getHuiKuanJhFun()
} else if(index == 7) {
that.getHuiKuanDanFun()
} else if(index == 8) {
} else if(index == 9) {
} else if(index == 10) {
}
},
// 获取跟进记录
getGenJinFun: function() {
uni.showLoading({
title: '加载中...',
mask: true
})
let item = that.tabList[that.tabIndex];
let reqData = {
action: 'selectLGenjinJl',
params: {
matchObj: {
clientId: that.khInfo._id,
},
sortObj: {
update_date: -1
},
pageIndex: item.pageIndex,
pageSize: 10000
}
}
crmGenJinApi(reqData)
.then(res => {
that.setTabArrFun(res.result.data, item)
})
},
// 查询联系人
selectLxrFun: function() {
uni.showLoading({
title: '加载中...',
mask: true
})
let item = that.tabList[that.tabIndex];
let reqData = {
action: 'selectLianXiRen',
params: {
matchObj: {
clientId: that.khInfo._id,
},
sortObj: {
update_date: -1
},
pageIndex: item.pageIndex
}
}
crmLianXiRenApi(reqData)
.then(res => {
that.setTabArrFun(res.result.data, item);
})
},
// 查询商机
getShangjiFun: function() {
uni.showLoading({
title: '加载中...',
mask: true
})
let item = that.tabList[that.tabIndex];
let reqData = {
action: 'getShangji',
params: {
matchObj: {
clientId: that.khInfo._id,
},
sortObj: {
update_date: -1
},
pageIndex: item.pageIndex
}
}
crmShangJiApi(reqData)
.then(res => {
that.setTabArrFun(res.result.data, item);
})
},
// 查询报价单
getBaojiaDanFun: function() {
uni.showLoading({
title: '加载中...',
mask: true
})
let item = that.tabList[that.tabIndex];
let reqData = {
action: 'getBaoJiaDan',
params: {
matchObj: {
clientId: that.khInfo._id,
},
sortObj: {
update_date: -1
},
pageIndex: item.pageIndex
}
}
crmBaoJiaDanApi(reqData)
.then(res => {
that.setTabArrFun(res.result.data, item);
})
},
// 查询合同
getHeTongFun: function() {
uni.showLoading({
title: '加载中...',
mask: true
})
let item = that.tabList[that.tabIndex];
let reqData = {
action: 'getHeTong',
params: {
matchObj: {
clientId: that.khInfo._id,
},
sortObj: {
update_date: -1
},
pageIndex: item.pageIndex
}
}
crmHeTongApi(reqData)
.then(res => {
that.setTabArrFun(res.result.data, item);
})
},
// 查询回款计划
getHuiKuanJhFun: function() {
uni.showLoading({
title: '加载中...',
mask: true
})
let item = that.tabList[that.tabIndex];
let reqData = {
action: 'get',
params: {
matchObj: {
clientId: that.khInfo._id,
},
sortObj: {
update_date: -1
},
pageIndex: item.pageIndex
}
}
crmHkjhApi(reqData)
.then(res => {
that.setTabArrFun(res.result.data, item);
})
},
// 查询实际回款
getHuiKuanDanFun: function() {
uni.showLoading({
title: '加载中...',
mask: true
})
let item = that.tabList[that.tabIndex];
let reqData = {
action: 'get',
params: {
matchObj: {
clientId: that.khInfo._id,
},
sortObj: {
update_date: -1
},
pageIndex: item.pageIndex
}
}
crmHkdApi(reqData)
.then(res => {
that.setTabArrFun(res.result.data, item);
})
},
// 给tabList中的arr赋值
setTabArrFun: function(data, item) {
if (item.pageIndex == 1) {
item.arr = [];
}
if (data.length >= 10) {
item.pageIndex += 1;
item.isMore = true;
} else {
item.isMore = false;
}
item.arr = item.arr.concat(data);
that.$set(that.tabList, that.tabIndex, item)
},
pickerSelectFun: function(str) {
if(str == '客户状态') {
that.selectList = [
{ value: 0, label: '潜在客户'},
{ value: 1, label: '初步接触'},
{ value: 2, label: '持续跟进'},
{ value: 3, label: '成交客户'},
{ value: 4, label: '忠诚客户'},
{ value: 5, label: '无效客户'}
]
} else if(str == '客户阶段') {
that.selectList = [
{ value: 0, label: '初步接洽'},
{ value: 1, label: '确认需求'},
{ value: 2, label: '解决方案'},
{ value: 3, label: '商务谈判'},
{ value: 4, label: '成交'},
{ value: 5, label: '流失'}
]
}
that.selectShow = true;
that.selectType = str;
},
selectConfirmFun: function(e) {
let str = e[0].label;
let req = {
update_date: new Date().getTime()
}
if(that.selectType == '客户状态') {
req.companyState = str;
} else if(that.selectType == '客户阶段') {
req.jieDuan = str;
}
let reqData = {
action: 'update',
params: {
_id: that.khInfo._id,
req
}
}
uni.showLoading({
title: '修改中...',
mask: true
})
crmKeHuApi(reqData)
.then(res => {
let cstr = '';
// if(that.selectType == '客户状态') {
// that.stateIndex = e[0].value;
// cstr = '修改 客户状态 ,由 "' + that.khInfo.companyState + '" 变更为 "' + str + '"'
// }
// that.khInfo.companyState = str;
// that.khInfo.update_date = req.update_date;
if(that.selectType == '客户阶段') {
that.jieDuanIndex = e[0].value;
cstr = '修改 商机阶段 ,由 "' + that.khInfo.jieDuan + '" 变更为 "' + str + '"'
}
that.khInfo.jieDuan = str;
that.khInfo.update_date = req.update_date;
uni.showToast({
title: '修改成功!',
duration: 888,
icon: 'none'
})
let czjlObj = {
create_date: new Date().getTime(),
czRen: uni.$userInfo._id,
pageType: 'client',
dataId: that.khInfo._id,
type: '编辑',
content: [ cstr ]
}
uni.$czjlApiAddFun(czjlObj);
})
},
// 新增跟进信息
pageGenjinFun: function() {
},
// 修改客户信息
pageBianjiFun: function() {
that.recoverTabListFun();
uni.$infoObj = that.khInfo;
uni.navigateTo({
url: './addKeHu?type=update'
})
},
// 新增sheet回调方法
pageAddSheetFun: function(e) {
console.log(e)
that.recoverTabListFun();
let url = '/pages/crm/';
if(e == 0) {
url += 'genJin/add?clientName=' + that.khInfo.clientName + '&clientId=' + that.khInfo._id
} else if(e == 1) {
url += 'lianxiren/addLxr?clientName=' + that.khInfo.clientName + '&clientId=' + that.khInfo._id
} else if(e == 2) {
url += 'shangji/addSj?clientName=' + that.khInfo.clientName + '&clientId=' + that.khInfo._id
} else if(e == 3) {
url += 'baoJiaDan/addBjd?clientName=' + that.khInfo.clientName + '&clientId=' + that.khInfo._id
} else if(e == 4) {
url += 'hetong/addHt?clientName=' + that.khInfo.clientName + '&clientId=' + that.khInfo._id
} else if(e == 5) {
url += 'huikuanJH/addHkjh?clientName=' + that.khInfo.clientName + '&clientId=' + that.khInfo._id
} else if(e == 6) {
url += 'huikuan/addHk?clientName=' + that.khInfo.clientName + '&clientId=' + that.khInfo._id
} else if(e == 7) {
url += 'faPiao/addFp?clientName=' + that.khInfo.clientName + '&clientId=' + that.khInfo._id
} else if(e == 8) {
url += 'returnHk/add?clientName=' + that.khInfo.clientName + '&clientId=' + that.khInfo._id
}
uni.navigateTo({
url
})
},
// 更多回调方法
pageDeleteShowFun: function(e) {
uni.showModal({
title: '提示',
content: '是否确认删除客户名称为:' + that.khInfo.clientName + '的客户吗?',
success(res) {
if(res.confirm) {
uni.showLoading({
title: '删除中...',
mask: true
})
let reqData = {
action: 'update',
params: {
_id: that.khInfo._id,
req: {
isDelete: 1,
update_date: new Date().getTime()
}
}
}
crmKeHuApi(reqData)
.then(res => {
uni.showToast({
title: '删除成功!',
duration: 888,
icon: 'none'
})
if(that.cardIndex != -1) {
uni.$emit('deleteKhFun', {index: that.cardIndex})
}
that.addCzjlFun();
setTimeout(()=> {
uni.navigateBack()
}, 666)
})
}
}
})
},
addCzjlFun: function() {
let czjlObj = {
create_date: new Date().getTime(),
czRen: uni.$userInfo._id,
pageType: 'client',
dataId: this.khInfo._id,
type: '删除'
}
uni.$czjlApiAddFun(czjlObj);
},
// 设置客户阶段和状态
setJieduanAndStateFun: function() {
// let state = that.khInfo.companyState;
let jieduan = that.khInfo.jieDuan;
let sList = that.stateList;
let jList = that.jieDuanList;
// for(var i = 0; i < sList.length; i++) {
// if(sList[i].name == state) {
// that.stateIndex = i;
// break;
// }
// }
for(var i = 0; i < jList.length; i++) {
if(jList[i].name == jieduan) {
that.jieDuanIndex = i;
break;
}
}
},
// 根据id查询客户
selectKhByIdFun: function(_id) {
uni.showLoading({
title: '加载中...',
mask: true
})
let reqData = {
action: 'selectKhById',
params: {
_id: ''
}
}
if(_id) {
reqData.params._id = _id;
} else {
reqData.params._id = that.khInfo._id;
}
crmKeHuApi(reqData)
.then(res => {
let data = res.result.data;
if(data.length > 0) {
that.khInfo = data[0]
that.setJieduanAndStateFun()
} else {
uni.showModal({
title: '提示',
content: '相关内容不存在,或者已被删除!',
showCancel: false,
success() {
uni.navigateBack()
}
})
}
})
},
recoverTabListFun: function() {
that.isLoadSelectKhById = true;
that.tabIndex = 0;
that.tabList = [
{ name: '详细信息', isMore: false },
{ name: '跟进记录', arr: [], pageIndex: 1, isMore: true },
{ name: '联系人', arr: [], pageIndex: 1, isMore: true },
{ name: '商机', arr: [], pageIndex: 1, isMore: true },
{ name: '报价单', arr: [], pageIndex: 1, isMore: true },
{ name: '合同', arr: [], pageIndex: 1, isMore: true },
{ name: '回款计划', arr: [], pageIndex: 1, isMore: true },
{ name: '实际回款', arr: [], pageIndex: 1, isMore: true },
{ name: '发票', arr: [], pageIndex: 1, isMore: true },
{ name: '退货退款', arr: [], pageIndex: 1, isMore: true },
{ name: '操作记录', isMore: false },
]
},
cxPGetDataFun: function(e) {
uni.showToast({
title: e + 'i',
duration: 1000,
icon: 'none',
mask: true
})
uni.$emit('cxGetDataFun');
setTimeout(() => {
uni.navigateBack()
}, 1000)
}
}
}
</script>
<style>
/* 注意,1、父节点需要固定高度,z-paging的height:100%才会生效 */
/* 注意,2、请确保z-paging与同级的其他view的总高度不得超过屏幕宽度,以避免超出屏幕高度时页面的滚动与z-paging内部的滚动冲突 */
/*如果有scoped,page的css设置建议放在App.vue中 */
page {
height: 100%;
background-color: #F8F8F8;
}
.content {
height: 100%;
/* 父节点建议开启flex布局 */
display: flex;
flex-direction: column;
}
.uTabsView {
border-bottom: 1rpx solid #DDDDDD;
z-index: 100;
position: sticky;
top :0;
}
.contentView {
/* background-color: #FFFFFF; */
min-height: calc(100vh - 45px);
}
.flexRow {
display: flex;
font-size: 30rpx;
margin-bottom: 8rpx;
}
.flexRow>view {
width: 50%;
display: flex;
}
.flexRow>view>text:first-child {
width: 166rpx;
}
.item {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
}
.item-detail {
padding: 5rpx 15rpx;
border-radius: 10rpx;
font-size: 28rpx;
color: white;
background-color: #007AFF;
}
.item-line {
position: absolute;
bottom: 0rpx;
left: 0rpx;
height: 1px;
width: 100%;
background-color: #eeeeee;
}
.uTabsView {
top: -2px !important;
}
.width100 {
width: 100%;
margin: 26rpx 0;
}
.u-steps__item, .u-steps__item--row {
width: 200px !important;
}
</style>
@@ -0,0 +1,475 @@
<template>
<view>
<view class="u-demo-block">
<view class="u-page__tag-item">
<u-search v-model="searchPlanDepartmentName" :show-action="false" @custom="selectPlanDepartmentFun"
@search="selectPlanDepartmentFun" placeholder="请输入营销部门"></u-search>
</view>
</view>
<scroll-view scroll-y="true" :style="{height: scrollHeight}" @scrolltolower="selectPlanDepartmentFun" refresher-enabled
:refresher-threshold="200" :refresher-triggered="triggered" refresher-background="gray"
@refresherrefresh="onRefresh" @refresherrestore="onRestore">
<view v-if="list.length > 0">
<view v-for="(item, index) in list" :key="index" @click="khCardClickFun(item)">
<khCard :item="item" :isSelect="isSelect" :index="index" @cxGetDataFun="cxGetDataFun"></khCard>
</view>
<getMore :isMore="isMore" nullMsg="已加载全部~"></getMore>
<view class="h200"></view>
</view>
<dataNull v-else src="/static/img/dataNull.png" title="暂无相关营销部门哦~"></dataNull>
</scroll-view>
<u-action-sheet :list="sheetList" v-model="moreShow"></u-action-sheet>
</view>
</template>
<script>
let that = this;
import {
tyDropDown,
dropDownByUser,
khsxData,
datePxData
} from '../../../static/utils/dropdown.js'
import {
getDayFun,
getDayByNumFun
} from '@/static/utils/date.js'
import dataNull from '@/components/dataNull/dataNull.vue'
import addBtn from '@/components/addBtn/addBtn.vue'
import getMore from '@/components/getMore/getMore.vue'
import topDropdown from '../../../components/topDropdown/topDropdown.vue'
import lianxiRow from '../../../components/lianxiRow/lianxiRow.vue'
import khCard from '../../../components/card/kehu.vue'
import util, {
playSuccessAudio,
playErrorAudio
} from '../../../common/util.js';
export default {
components: {
dataNull,
addBtn,
getMore,
topDropdown,
lianxiRow,
khCard
},
data() {
return {
CustomerName: '',
triggered: false,
dropdown1: '全部',
options1: tyDropDown,
optionsPx: datePxData,
searchPlanDepartmentName: '',
CustomerTypes: '',
sxList: [],
list: [],
moreShow: false,
sheetList: [{
text: '添加跟进'
},
{
text: '添加标签'
}
],
isMore: true,
pageIndex: 1,
scrollHeight: '667px',
pageType: '',
sortObj: {
update_date: -1
},
optionsReq: {}, // 第一个下拉框请求参数
dateReq: [], // 日期相关请求参数
sxReq: JSON.stringify({}), // 筛选想请求参数
matchObj: {},
searchValue: '',
isSelect: false,
tabNoEqualArr: [], //标签页不等于数据
depId: undefined
}
},
onLoad(e) {
that = this;
let khsxList = JSON.stringify(khsxData);
that.sxList = JSON.parse(khsxList);
let obj = {};
this.CustomerTypes = e.type;
this.pageType = e.type;
console.log(">>>" + e.type);
if (e.type) {
that.isSelect = true;
}
this.selectPlanDepartmentFun();
},
onBackPress() {
uni.$off('deleteKhFun', that.deleteKhFun)
uni.$off('updateListByIndex', that.updateListByIndex)
uni.$off('addItemInListFun', that.addItemInListFun)
uni.$off('cxGetDataFun', that.cxGetDataFun)
},
methods: {
// 查询用户
selectPlanDepartmentFun: function() {
console.log("-->>>>>>" + this.searchPlanDepartmentName);
uni.request({
url: util.apiurl + 'rest/db/opensql',
data: {
token: getApp().globalData.Token,
format: 'json',
data: {
db_name: getApp().globalData.AppDBName,
sql_command_id: 'APP.BaseData.GetCustomerData',
params: [{
name: 'SUID',
value: aSaleUserID
}, {
name: 'MUID',
value: aSaleUserID
}, {
name: 'CName',
value: '%' + this.searchCustomerName + '%'
}, {
name: 'CustomerTypes',
value: '%' + this.CustomerTypes + '%'
}]
},
},
success: (res) => {
this.triggered = false;
let data = res.data.data;
if (that.pageIndex == 1) {
that.list = [];
}
if (res.data == 20) {
that.pageIndex += 1;
that.isMore = true;
} else {
that.isMore = false;
}
that.list = that.list.concat(data);
},
})
},
// 客户点击方法
khCardClickFun: function(item) {
if (that.pageType == '织厂') {
uni.$emit('bjdKehuBindFun', {
CustomerID: item.CustomerID,
CustomerName: item.CustomerName,
PlanDepartmentID: item.PlanDepartmentID,
PlanDepartmentName: item.PlanDepartmentName,
SaleUserID: item.SaleUserID,
SaleUserName: item.SaleUserName,
Remark: item.Remark,
CustomerAddress: item.CustomerAddress,
CustomerPhone: item.CustomerPhone,
CustomerLinkName: item.CustomerLinkName,
})
uni.navigateBack();
}
else if (that.pageType == '染整厂') {
uni.$emit('bjdKehuBindFun', {
CustomerID: item.CustomerID,
CustomerName: item.CustomerName,
PlanDepartmentID: item.PlanDepartmentID,
PlanDepartmentName: item.PlanDepartmentName,
SaleUserID: item.SaleUserID,
SaleUserName: item.SaleUserName,
Remark: item.Remark,
CustomerAddress: item.CustomerAddress,
CustomerPhone: item.CustomerPhone,
CustomerLinkName: item.CustomerLinkName,
})
uni.navigateBack();
}
else if (that.pageType == 'lxr') {
uni.$emit('kehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'addGjjl') {
uni.$emit('gjKehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'sj') {
uni.$emit('sjKehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'saleallocated') {
uni.$emit('bjdKehuBindFun', {
CustomerID: item.CustomerID,
CustomerName: item.CustomerName,
PlanDepartmentID: item.PlanDepartmentID,
PlanDepartmentName: item.PlanDepartmentName,
SaleUserID: item.SaleUserID,
SaleUserName: item.SaleUserName,
Remark: item.Remark,
CustomerAddress: item.CustomerAddress,
CustomerPhone: item.CustomerPhone,
CustomerLinkName: item.CustomerLinkName,
})
uni.navigateBack()
} else if (that.pageType == 'heTong') {
uni.$emit('heTongdKehuBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType == 'topDropDown') {
uni.$emit('topDropDownBindFun', {
clientName: item.clientName,
clientId: item._id
})
uni.navigateBack()
} else if (that.pageType != '') {
uni.$emit('kehuBindFun', item)
uni.navigateBack()
}
// else {
// uni.$khInfo = item;
// uni.navigateTo({
// url: './khDetail'
// })
// }
},
// 下拉框回调函数
dropDownFun1: function(e) {
let optionsReq = {};
let tabNoEqualArr = [];
let userInfo = uni.$userInfo;
that.depId = undefined;
if (e.label == '全部') {
that.depId = userInfo.depManager_Id;
} else if (e.label == '我负责的') {
optionsReq.fuZeRenId = userInfo._id;
} else if (e.label == '我创建的') {
optionsReq.cjRenId = userInfo._id;
} else if (e.label == '下属负责') {
that.depId = userInfo.depManager_Id;
tabNoEqualArr = [{
field: 'fuZeRenId',
value: userInfo._id
}]
optionsReq.department = userInfo.departmentId;
} else if (e.label == '下属创建') {
that.depId = userInfo.depManager_Id;
tabNoEqualArr = [{
field: 'cjRenId',
value: userInfo._id
}]
}
that.tabNoEqualArr = tabNoEqualArr;
that.optionsReq = JSON.stringify(optionsReq);
that.matchObj = Object.assign(optionsReq, JSON.parse(that.sxReq));
that.cxGetDataFun();
},
// 筛选框回调函数
optionSxFun: function(arr) {
let matchReq = [];
let dateReq = [];
for (var i = 0; i < arr.length; i++) {
if (arr[i].current !== '' && !arr[i].isDate) {
matchReq.push({
field: arr[i].field,
value: arr[i].arr[arr[i].current]
})
} else if (arr[i].current !== '' && arr[i].isDate) {
dateReq.push({
field: arr[i].field,
sTime: arr[i].sTime,
eTime: arr[i].eTime
})
}
}
let reqObj = {};
// 动态生成请求对象
for (var i = 0; i < matchReq.length; i++) {
reqObj[matchReq[i].field] = matchReq[i].value
}
that.dateReq = dateReq;
that.sxReq = JSON.stringify(reqObj);
// 合并对象
that.matchObj = Object.assign(reqObj, JSON.parse(that.optionsReq));
that.cxGetDataFun();
},
// 排序筛选框回调函数
optionPxFun: function(arr) {
let sortObj = {
update_date: -1
}
for (var i = 0; i < arr.length; i++) {
if (arr[i].current !== '') {
sortObj = {}
if (arr[i].field == 'create_date') {
sortObj.create_date = arr[i].current == 1 ? 1 : -1
}
if (arr[i].field == 'update_date') {
sortObj.update_date = arr[i].current == 1 ? 1 : -1
}
if (arr[i].field == 'genjin_date') {
sortObj.genjin_date = arr[i].current == 1 ? 1 : -1
}
that.sortObj = sortObj;
break;
}
}
that.cxGetDataFun();
},
// 搜索框回调方法
searchBoxEmitFun: function(e) {
that.searchValue = e.searchValue1;
that.cxGetDataFun()
},
// 下拉刷新
onRefresh: function() {
if (that.triggered) return
that.triggered = true;
that.cxGetDataFun();
},
onRestore: function(e) {
that.triggered = false; // 需要重置
},
// 重新获取数据
cxGetDataFun: function() {
that.pageIndex = 1;
that.isMore = true;
that.selectKehuFun();
},
deleteKhFun: function(e) {
let arr = that.list;
arr.splice(e.index, 1);
that.list = arr;
},
// 通过下标更新list数据
updateListByIndex: function(e) {
that.$set(that.list, parseInt(e.index), e.obj)
},
// add页面新增数据
addItemInListFun: function(e) {
let arr = that.list;
arr.unshift(e);
that.list = arr;
uni.pageScrollTo({
scrollTop: 0
})
}
}
}
</script>
<style>
page {
background-color: #F8F8F8;
}
.card {
width: 698rpx;
padding: 26rpx 26rpx 10rpx;
margin: 32rpx 26rpx;
box-sizing: border-box;
border-radius: 8rpx;
box-shadow: #d8d8d8 0px 0px 16rpx;
position: relative;
background-color: #FFFFFF;
}
.genjinBtn {
position: absolute;
right: 26rpx;
top: 26rpx;
background-color: #007AFF;
color: #FFFFFF;
text-align: center;
padding: 6rpx 16rpx;
border-radius: 6rpx;
font-size: 14px;
}
.genjinBtn:active {
background-color: #13B8FF;
}
.topRow {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.txView {
width: 128rpx;
height: 128rpx;
border-radius: 50%;
overflow: hidden;
margin-right: 26rpx;
}
.txViewImg {
width: 100%;
height: 100%;
}
.info {
width: 492rpx;
font-size: 15px;
color: #000;
}
.name {
font-size: 16px;
margin-bottom: 8rpx;
color: #000000;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: bold;
}
.bottomRow {
width: 100%;
padding-top: 16rpx;
display: flex;
align-items: center;
justify-content: space-between;
border-top: 1rpx solid #f0f0f0;
font-size: 15px;
color: #007AFF;
}
.lxRow {
display: flex;
align-items: center;
}
.lxRow>image {
width: 52rpx;
height: 52rpx;
margin-right: 26rpx;
}
.bqRow {
display: flex;
align-items: center;
flex-wrap: wrap;
}
.bqRow>text {
font-size: 14px;
color: #888888;
}
.bqRow>view {
padding: 6rpx 16rpx;
font-size: 14px;
background-color: rgba(255, 85, 127, 0.1);
color: #ff5500;
border-radius: 10rpx;
margin: 6rpx 26rpx 20rpx 0;
}
</style>