| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- import { getEnumList, saveDiamondFilters } from "../../../services/utils"
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- /// 底部安全区域
- safeBottom: getApp().globalData.safeBottom,
- /// tabs
- tabs: [{id: 2, name: '单颗裸钻'}, {id: 5, name: '单颗彩钻'}],
- /// tab索引
- active: 0,
- /// 形状
- shapes: [{ id: 1, name: '圆明亮形', isCheck: false }],
- /// 选中形状
- zsshapetype: [],
- /// 颜色
- colors: [{id: 1, name: 'D', isCheck: false}],
- /// 选中形状
- zscolortype: [],
- /// 净度
- neatness: [{ id: 1, name: 'FL', isCheck: false }],
- /// 选中净度
- zsclaritytype: [],
- /// 切工
- qiegongs: [{ id: 1, name: 'EX', isCheck: false }],
- /// 选中切工
- zscuttype: [],
- /// 对称
- duichengs: [{ id: 1, name: 'EX', isCheck: false }],
- zssymmetrytype: [],
- /// 抛光
- paoguangs: [{ id: 1, name: 'EX', isCheck: false }],
- zspolishtype: [],
- /// 莹光
- yingguangs: [{ id: 1, name: '无', isCheck: false }],
- /// 选中莹光
- zsfluorescencetype: [],
- /// 证书
- certificates: [{ id: 1, name: 'GIA', isCheck: false }],
- /// 选中证书
- zscerttype: [],
- /// 币种
- currencys: [{id: 1, name: '人民币(¥)', isCheck: false},
- {id: 2, name: '美元($)', isCheck: false}],
- zscurrencytype: [],
- /// 最小重量
- minweight: '0.00',
- /// 最大重量
- maxweight: '0.00'
- },
- /**
- * tab触发事件
- */
- onTabChange(e: any) {
- /// 设置激活项
- this.setData({ active: e.detail.index })
- },
- /**
- * 返回上层视图
- */
- backToParent() {
- /// 返回上层视图
- wx.navigateBack()
- },
- /// 按钮点击事件
- onButtonPressed(e: any) {
- /// 数据拼接
- const ids = (<string> e.target.id).split(' ')
- const id = (<string> e.target.id).split(' ')[0]
- const index = <number> <unknown>ids[1]
- switch (id) {
- case 'shape': /// 形状
- this.setData({ shapes: this.data.shapes.map(item => {
- if (item.id == index) { item.isCheck = !item.isCheck }
- return item
- }) })
- this.setData({ zsshapetype: this.data.shapes.filter(obj => {
- return obj.isCheck === true
- }).map(item => {
- return item.id.toString()
- }) })
- break;
- case 'currency':
- this.setData({ currencys: this.data.currencys.map(item => {
- if (item.id == index) { item.isCheck = !item.isCheck }
- return item
- }) })
- this.setData({ zscurrencytype: this.data.currencys.filter(obj => {
- return obj.isCheck === true
- }).map(item => { return item.id.toString() }) })
- break;
- case 'color': /// 颜色
- this.setData({ colors: this.data.colors.map(item => {
- if (item.id == index) { item.isCheck = !item.isCheck }
- return item
- }) })
- this.setData({ zscolortype: this.data.colors.filter(obj => {
- return obj.isCheck === true
- }).map(item => { return item.id }) })
- break;
- case 'neatness': /// 净度
- this.setData({ neatness: this.data.neatness.map(item => {
- if (item.id == index) { item.isCheck = !item.isCheck }
- return item
- })
- })
- this.setData({ zsclaritytype: this.data.neatness.filter(obj => {
- return obj.isCheck === true
- }).map(item => { return item.id }) })
- break;
- case 'qiegong': /// 切工
- this.setData({ qiegongs: this.data.qiegongs.map(item => {
- if (item.id == index) { item.isCheck = !item.isCheck }
- return item
- }) })
- this.setData({ zscuttype: this.data.qiegongs.filter(obj => {
- return obj.isCheck === true
- }).map(item => { return item.id }) })
- break;
- case 'duicheng': /// 对称
- this.setData({ duichengs: this.data.duichengs.map(item => {
- if (item.id == index) { item.isCheck = !item.isCheck }
- return item
- }) })
- this.setData({ zssymmetrytype: this.data.duichengs.filter(obj => {
- return obj.isCheck === true
- }).map(item => { return item.id }) })
- break;
- case 'polishing': /// 抛光
- this.setData({ paoguangs: this.data.paoguangs.map(item => {
- if (item.id == index) { item.isCheck = !item.isCheck }
- return item
- }) })
- this.setData({ zspolishtype: this.data.paoguangs.filter(obj => {
- return obj.isCheck === true
- }).map(item => { return item.id }) })
- break;
- case 'yingguang': /// 荧光
- this.setData({ yingguangs: this.data.yingguangs.map(item => {
- if (item.id == index) { item.isCheck = !item.isCheck }
- return item
- }) })
- this.setData({ zsfluorescencetype: this.data.yingguangs.filter(obj => {
- return obj.isCheck === true
- }).map(item => { return item.id }) })
- break;
- case 'certificate': /// 证书
- this.setData({ certificates: this.data.certificates.map(item => {
- if (item.id == index) { item.isCheck = !item.isCheck }
- return item
- }) })
- this.setData({ zscerttype: this.data.certificates.filter(obj => {
- return obj.isCheck === true
- }).map(item => { return item.id.toString() }) })
- break;
- case 'search': /// 搜索页面跳转
- this.goToSearch()
- break;
- case 'clear': break
- default: break;
- }
- },
- /// 重量范围值更改
- syncNumRange(e: any) {1234
- this.setData({
- minweight: e.detail.value[0],
- maxweight: e.detail.value[1],
- })
- },
- /// 搜索页面跳转
- goToSearch() {
- /// 数据拼接
- const info = {
- zscategory: this.data.tabs[this.data.active].id,
- zsshapetype: this.data.zsshapetype,
- zsclaritytype: this.data.zsclaritytype,
- zscuttype: this.data.zscuttype,
- zssymmetrytype: this.data.zssymmetrytype,
- zspolishtype: this.data.zspolishtype,
- zsfluorescencetype: this.data.zsfluorescencetype,
- zscurrencytype: this.data.zscurrencytype,
- zscerttype: this.data.zscerttype,
- zscolortype: this.data.zscolortype,
- weight1: Number(this.data.minweight),
- weight2: Number(this.data.maxweight)
- }
- /// 页面跳转
- wx.switchTab({
- url: '/pages/trade/index',
- /// 加载成功
- success: () => {
- /// 缓存数据
- saveDiamondFilters(info)
- }
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad() {
-
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- /// 显示默认数据
- this.setData({
- /// 形状
- shapes: getEnumList('ZSShapeType').map(obj => {
- return { id: obj.enumitemname, name: obj.enumdicname, isCheck: false }
- }),
- /// 颜色
- colors: getEnumList('ZSColorType').map(obj => {
- return { id: obj.enumitemname, name: obj.enumdicname, isCheck: false }
- }),
- /// 净度
- neatness: getEnumList('ZSClarityType').map(obj => {
- return { id: obj.enumitemname, name: obj.enumdicname, isCheck: false }
- }),
- /// 切工
- qiegongs: getEnumList('ZSCutType').map(obj => {
- return { id: obj.enumitemname, name: obj.enumdicname, isCheck: false }
- }),
- /// 对称
- duichengs: getEnumList('ZSSymmetryType').map(obj => {
- return { id: obj.enumitemname, name: obj.enumdicname, isCheck: false }
- }),
- /// 抛光
- paoguangs: getEnumList('ZSPolishType').map(obj => {
- return { id: obj.enumitemname, name: obj.enumdicname, isCheck: false }
- }),
- /// 荧光
- yingguangs: getEnumList('ZSFluorescenceType').map(obj => {
- return { id: obj.enumitemname, name: obj.enumdicname, isCheck: false }
- }),
- /// 证书
- certificates: getEnumList('ZSCertType').map(obj => {
- return { id: obj.enumitemname, name: obj.enumdicname, isCheck: false }
- }),
- })
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
-
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|