Browse Source

1、客户收藏逻辑

2、页面优化
master
chenxuhui 7 years ago
parent
commit
522e8d2fc3
4 changed files with 100 additions and 21 deletions
  1. +72
    -17
      pages/customerChooseTemplate/customerChooseTemplate.js
  2. +17
    -1
      pages/customerChooseTemplate/customerChooseTemplate.wxml
  3. +9
    -1
      pages/customerChooseTemplate/customerChooseTemplate.wxss
  4. +2
    -2
      pages/goodaNameChooseTemplate/goodaNameChooseTemplate.wxss

+ 72
- 17
pages/customerChooseTemplate/customerChooseTemplate.js View File

@ -17,6 +17,7 @@ Page({
collectionArray: [], collectionArray: [],
customerArray: [], customerArray: [],
checkBoxArray: [], checkBoxArray: [],
storageCheckBoxArray: [],
}, },
getCustomerBySearchString:function(event){ getCustomerBySearchString:function(event){
@ -80,18 +81,44 @@ Page({
}, },
// 点击了收藏按钮
// 收藏夹点击添加客户 存数据进入global
storageAddCustomerArrayBack: function () {
let choseCheck = []
// 对比原有数组和选中的数组 存在,将数组包含的其他值也取出加载
for (var i = 0; i < this.data.collectionArray.length; i++) {
for (var j = 0; j < this.data.storageCheckBoxArray.length; j++) {
if (Number(this.data.collectionArray[i].ID) == this.data.storageCheckBoxArray[j]) {
choseCheck.push(this.data.collectionArray[i])
}
}
}
app.globalData.customerArray = choseCheck;
var pages = getCurrentPages();
var currPage = pages[pages.length - 1]; //当前页面
var prevPage = pages[pages.length - 2]; //上一个页面
//直接调用上一个页面对象的setData()方法,把数据存到上一个页面中去
prevPage.setData({
backPage: "customerChoosePage",
});
wx.navigateBack({
delta: 1,
})
},
// 点击了收藏按钮 (参数数组为定义)
storegeBtnClick: function () { storegeBtnClick: function () {
var that = this; var that = this;
// 获取收藏的存货信息 // 获取收藏的存货信息
var oldCollectionArr = this.data.collectionArray; var oldCollectionArr = this.data.collectionArray;
var waitStorageArr = this.data.checkBoxArray; var waitStorageArr = this.data.checkBoxArray;
var goodsNameArrayAll = this.data.goodsArray;
var customerArrayAll = this.data.customerArray;
if (waitStorageArr.length <= 0) { if (waitStorageArr.length <= 0) {
wx.showToast({ wx.showToast({
title: '请选择存货',
title: '请选择客户',
}) })
return; return;
} else { } else {
@ -99,7 +126,7 @@ Page({
// 对比所选存货是否已经存在于收藏中 有:不重复添加 返回未添加过的数组 // 对比所选存货是否已经存在于收藏中 有:不重复添加 返回未添加过的数组
for (var i = 0; i < waitStorageArr.length; i++) { for (var i = 0; i < waitStorageArr.length; i++) {
for (var j = 0; j < oldCollectionArr.length; j++) { for (var j = 0; j < oldCollectionArr.length; j++) {
if (Number(waitStorageArr[i]) == Number(oldCollectionArr[j].SaleGoods_ID)) {
if (Number(waitStorageArr[i]) == Number(oldCollectionArr[j].ID)) {
waitStorageArr.splice(i, 1); waitStorageArr.splice(i, 1);
} }
} }
@ -107,10 +134,10 @@ Page({
// 对比原有数组和选中的数组 存在,将数组包含的其他值也取出加载 // 对比原有数组和选中的数组 存在,将数组包含的其他值也取出加载
let choseCheck = []; let choseCheck = [];
for (var i = 0; i < that.data.goodsArray.length; i++) {
for (var i = 0; i < that.data.customerArray.length; i++) {
for (var j = 0; j < waitStorageArr.length; j++) { for (var j = 0; j < waitStorageArr.length; j++) {
if (Number(goodsNameArrayAll[i].SaleGoods_ID) == waitStorageArr[j]) {
choseCheck.push(goodsNameArrayAll[i])
if (Number(customerArrayAll[i].ID) == waitStorageArr[j]) {
choseCheck.push(customerArrayAll[i])
} }
} }
} }
@ -120,7 +147,7 @@ Page({
currentTab: 1, currentTab: 1,
}); });
wx.setStorage({ wx.setStorage({
key: "storageGoodsKey",
key: "storageCustomerKey",
data: oldCollectionArr, data: oldCollectionArr,
success: function () { success: function () {
wx.showToast({ wx.showToast({
@ -131,6 +158,43 @@ Page({
} }
}, },
// 收藏夹页面多选框值变化
storageCheckboxValueChange: function (e) {
// 新建预报页面只允许选取一位客户
if (fromPage == "newForecast" && e.detail.value.length > 0) {
this.setData({
checkBoxArray: e.detail.value,
})
this.storageAddCustomerArrayBack();
}
this.setData({
storageCheckBoxArray: e.detail.value,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that =this;
fromPage = options.fromePage;
this.GetCustomer();
// 获取收藏的客户信息
wx.getStorage({
key: 'storageCustomerKey',
success(res) {
console.log(res.data);
if (res.data.length > 0) {
that.setData({
collectionArray: res.data,
})
}
}
})
},
/** /**
* 滑动切换tab * 滑动切换tab
*/ */
@ -156,13 +220,4 @@ Page({
} }
}, },
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
fromPage = options.fromePage;
this.GetCustomer();
},
}) })

+ 17
- 1
pages/customerChooseTemplate/customerChooseTemplate.wxml View File

@ -24,13 +24,29 @@
<view class='addGoodsName' catchtap='addCustomerName'>添加客户</view> <view class='addGoodsName' catchtap='addCustomerName'>添加客户</view>
</swiper-item> </swiper-item>
<!-- 收藏夹 -->
<swiper-item class="swiper-items2">
<scroll-view scroll-x="false" scroll-y="true" class='storage-scroll-views' bindscrolltoupper="checkedScrollUpper" bindscrolltolower="CheckedScrollLower">
<view class='listBackGroundView'>
<checkbox-group bindchange="storageCheckboxValueChange">
<block wx:for="{{collectionArray}}" wx:key="item" wx:for-index="idx">
<template is="customerChoiceTemplate" data="{{item}}" />
</block>
</checkbox-group>
</view>
</scroll-view>
<view class='addGoodsName' catchtap='storageAddCustomerArrayBack'>添加客户</view>
</swiper-item>
</swiper> </swiper>
<template name="customerChoiceTemplate"> <template name="customerChoiceTemplate">
<view class='listItem'> <view class='listItem'>
<view class='itemClass'>{{item.Name}}</view> <view class='itemClass'>{{item.Name}}</view>
<checkbox value="{{item.ID}}"/>
<checkbox value="{{item.ID}}" />
</view> </view>
<view class='horizontallineView'></view> <view class='horizontallineView'></view>
</template> </template>

+ 9
- 1
pages/customerChooseTemplate/customerChooseTemplate.wxss View File

@ -76,7 +76,15 @@ page{
.scroll-views { .scroll-views {
position: absolute; position: absolute;
margin-top: 25rpx; margin-top: 25rpx;
height: calc(100% - 97px);
height: calc(100%-97px);
width: 100%;
display: flex;
flex-direction: column;
}
.storage-scroll-views {
margin-top: 25rpx;
height: calc(100%-45px);
width: 100%; width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;


+ 2
- 2
pages/goodaNameChooseTemplate/goodaNameChooseTemplate.wxss View File

@ -74,7 +74,7 @@ page{
.scroll-views { .scroll-views {
margin-top: 25rpx; margin-top: 25rpx;
height: calc(100% - 97px);
height: calc(100%-97px);
width: 100%; width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -82,7 +82,7 @@ page{
.storage-scroll-views { .storage-scroll-views {
margin-top: 25rpx; margin-top: 25rpx;
height: calc(100% - 45px);
height: calc(100%-45px);
width: 100%; width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;


Loading…
Cancel
Save