From 6378764ccf1c72254a47c8cc02012c910ad7b6cf Mon Sep 17 00:00:00 2001 From: Esdese <2114339600@qq.com> Date: Tue, 16 Aug 2022 15:49:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=93=81=E7=89=8C=E5=AF=B9=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/varComm/pages/brand/index.js | 7 +- pages/varComm/pages/brandRatio/filter.wxs | 8 ++ pages/varComm/pages/brandRatio/index.js | 117 +++++++++++++++++++--- pages/varComm/pages/brandRatio/index.wxml | 31 +++++- pages/varComm/pages/brandRatio/index.wxss | 31 +++++- 5 files changed, 173 insertions(+), 21 deletions(-) create mode 100644 pages/varComm/pages/brandRatio/filter.wxs diff --git a/pages/varComm/pages/brand/index.js b/pages/varComm/pages/brand/index.js index e10b611..3c3fba6 100644 --- a/pages/varComm/pages/brand/index.js +++ b/pages/varComm/pages/brand/index.js @@ -34,8 +34,11 @@ Component({ const {detail} = event const result = [] if(detail.length>6){ - console.log('至多六个'); - return + Dialog.alert({ + message: '至多六个', + context:this + }) + return } for(let i of detail){ result.push(JSON.parse(i)) diff --git a/pages/varComm/pages/brandRatio/filter.wxs b/pages/varComm/pages/brandRatio/filter.wxs new file mode 100644 index 0000000..35a7df3 --- /dev/null +++ b/pages/varComm/pages/brandRatio/filter.wxs @@ -0,0 +1,8 @@ +var method = { + stringify: function (val) { + return JSON.stringify(val) + } +} +module.exports = { + stringify: method.stringify +} \ No newline at end of file diff --git a/pages/varComm/pages/brandRatio/index.js b/pages/varComm/pages/brandRatio/index.js index 177cb37..0d42b05 100644 --- a/pages/varComm/pages/brandRatio/index.js +++ b/pages/varComm/pages/brandRatio/index.js @@ -1,23 +1,55 @@ -// pages/varComm/pages/brandRatio/index.js +import Dialog from '../../../../miniprogram_npm/@vant/weapp/dialog/dialog'; +const app = getApp() Page({ /** * 页面的初始数据 */ data: { - boxArr:new Array(6), - tabActive:0, - sonCom:true + boxArr: new Array(6), + tabActive: 0, + result: [], + sonCom: true, + popupShow: false, + mockData:[], }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { - this.setData({ - boxArr:wx.getStorageSync('brandData') - }) - wx.setStorageSync('brandRatioTime', {sTimeType:'34'}) + this.setData({ + boxArr: wx.getStorageSync('brandData'), + result:wx.getStorageSync('brandData').map(ele=>{ + return JSON.stringify(ele) + }) + }) + wx.setStorageSync('brandRatioTime', { + sTimeType: '34' + }) + this.brandReq() + }, + onChange(event) { + const {detail} = event + const result = [] + for(let i=0;i<=detail.length;i++){ + if(detail[i]=='null') detail.splice(i,1),i-- + } + if(detail.length>6){ + Dialog.alert({ + message: '至多六个', + context:this + }) + return + } + for(let i of detail){ + result.push(JSON.parse(i)) + } + result.length = 6 + this.setData({ + result:detail, + boxArr:result + }) }, changeTab(val) { let n = val.detail.index; @@ -25,14 +57,73 @@ Page({ tabActive: n }) }, - changeTime(event){ - let {detail} = event - wx.setStorageSync('brandRatioTime', detail) + addBrand() { + this.setData({ + popupShow: true + }) + }, + popupClose() { + this.setData({ + popupShow: false + }) + wx.setStorageSync('brandData', this.data.boxArr) + this.reLoad() + }, + del(e) { + let index = e.currentTarget.dataset.index + let result = [...this.data.result] + let boxArr = [] + result.splice(index, 1) + for (let i of result) { + boxArr.push(JSON.parse(i)) + } + boxArr.length = 6 + this.setData({ + result: result, + boxArr: boxArr + }) + wx.setStorageSync('brandData', this.data.boxArr) + this.reLoad() + }, + changeTime(event) { + let { + detail + } = event + wx.setStorageSync('brandRatioTime', detail) + this.reLoad() + }, + //获取品牌 + brandReq() { + app.globalData.request({ + action: 'getUserBrand', + token: wx.getStorageSync('token'), + }).then(res => { + let arr = [] + for (let i = 65; i <= 90; i++) { + arr.push({ + name: String.fromCharCode(i), + data: [] + }); + } + for (let i of res) { + for (let j of arr) { + if (i.firstword == j.name) { + j.data.push(i) + } + } + } + console.log(arr); + this.setData({ + mockData: arr + }) + }) + }, + reLoad() { this.setData({ - sonCom:false + sonCom: false }) this.setData({ - sonCom:true + sonCom: true }) } }) \ No newline at end of file diff --git a/pages/varComm/pages/brandRatio/index.wxml b/pages/varComm/pages/brandRatio/index.wxml index cb3cae5..2e275a1 100644 --- a/pages/varComm/pages/brandRatio/index.wxml +++ b/pages/varComm/pages/brandRatio/index.wxml @@ -1,18 +1,20 @@ + + - + 添加品牌一 - + × - 删除 + 删除 @@ -23,7 +25,7 @@ - + @@ -37,4 +39,23 @@ - \ No newline at end of file + + + + + + + + + + + + + {{item2.brandname}} + + + + + + \ No newline at end of file diff --git a/pages/varComm/pages/brandRatio/index.wxss b/pages/varComm/pages/brandRatio/index.wxss index 7499a25..0a97894 100644 --- a/pages/varComm/pages/brandRatio/index.wxss +++ b/pages/varComm/pages/brandRatio/index.wxss @@ -88,6 +88,7 @@ page { height: 96rpx; background: white; display: flex; + margin-left: 16rpx; align-items: center; } .van-checkbox{ @@ -189,4 +190,32 @@ page { padding: 15px 0px; color: #909497; text-align: center; -} \ No newline at end of file +} + +.van-index-anchor text { + font-size: 24rpx; + color: rgba(153, 153, 153, 1); +} + +.event_recom1 .van-cell .van-cell__title { + font-size: 28rpx; +} + +.my_cell { + width: 718rpx; + padding-left: 32rpx; + height: 96rpx; + background: white; + display: flex; + align-items: center; +} + +.van-checkbox { + display: inline-block !important; + margin-left: 32rpx; +} + +.my_cell text { + font-size: 28rpx; + margin-left: 24rpx; +}