作者 lihongjuan

2345234

1 { 1 {
2 "pages": [ 2 "pages": [
3 -  
4 "pages/homapage/homepage", 3 "pages/homapage/homepage",
5 "pages/login/login", 4 "pages/login/login",
6 "pages/forgetmima/forgetmima", 5 "pages/forgetmima/forgetmima",
@@ -56,7 +55,8 @@ @@ -56,7 +55,8 @@
56 "pages/homeblock/bofangexample/bofangexample", 55 "pages/homeblock/bofangexample/bofangexample",
57 "pages/myblock/jiudan/jiudan", 56 "pages/myblock/jiudan/jiudan",
58 "pages/myblock/yonghufankui/yonghufankui", 57 "pages/myblock/yonghufankui/yonghufankui",
59 - "pages/myblock/xiugaimima/xiugaimima" 58 + "pages/myblock/xiugaimima/xiugaimima",
  59 + "pages/yonghuxieyi/yonghuxieyi"
60 ], 60 ],
61 "window": { 61 "window": {
62 "backgroundTextStyle": "light", 62 "backgroundTextStyle": "light",
  1 +// component/zyslider/zyslider.js
  2 +var util = require('../utils/util')
  3 +const app=getApp()
  4 +Component({
  5 + /**
  6 + * 组件的属性列表
  7 + */
  8 + properties: {
  9 + /** slider 最小值 */
  10 + min: {
  11 + type: Number
  12 + },
  13 + /** slider 最大值 */
  14 + max: {
  15 + type: Number
  16 + },
  17 + /** 步进 (没做,有时间再说,项目里没用到撒) */
  18 + step: {
  19 + type: Number
  20 + },
  21 + /** 预选选择的小值*/
  22 + minValue: {
  23 + type: Number
  24 + },
  25 + /** 预选选择的大值 */
  26 + maxValue: {
  27 + type: Number
  28 + },
  29 + /** 滑块颜色 */
  30 + blockColor:{
  31 + type: String
  32 + },
  33 + /** 未选择进度条颜色 */
  34 + backgroundColor:{
  35 + type: String
  36 + },
  37 + /** 已选择进度条颜色 */
  38 + selectedColor:{
  39 + type: String
  40 + }
  41 + },
  42 +
  43 +
  44 + /**
  45 + * 组件的初始数据
  46 + */
  47 + data: {
  48 + min: 0,
  49 + max: 100,
  50 + leftValue: 0,
  51 + rightValue: 100,
  52 + ppvalue:100,
  53 + ppleft:0,
  54 + totalLength: 0,
  55 + bigLength: 0,
  56 + ratio: 0.5,
  57 + sliderLength: 20,
  58 + containerLeft: 0, //标识整个组件,距离屏幕左边的距离
  59 + hideOption: '', //初始状态为显示组件
  60 +
  61 + },
  62 +
  63 + /**
  64 + * 组件的方法列表
  65 + */
  66 + methods: {
  67 +
  68 + /**
  69 + * 设置左边滑块的值
  70 + */
  71 + _propertyLeftValueChange: function () {
  72 + console.log(this.data.minValue);
  73 + console.log(this.data.max);
  74 + console.log(this.data.bigLength)
  75 +
  76 + let minValue = this.data.minValue / this.data.max * this.data.bigLength;
  77 + console.log(minValue)
  78 + let min = this.data.min / this.data.max * this.data.bigLength;
  79 + console.log(min)
  80 + this.setData({
  81 + leftValue: minValue - min,
  82 + ppleft: minValue - min
  83 + })
  84 +
  85 + console.log(this.data.leftValue)
  86 + },
  87 +
  88 + /**
  89 + * 设置右边滑块的值
  90 + */
  91 + _propertyRightValueChange: function () {
  92 + let right = this.data.maxValue / this.data.max * this.data.bigLength + this.data.sliderLength
  93 + this.setData({
  94 + rightValue: right,
  95 + ppvalue:right
  96 + })
  97 +
  98 + console.log(this.data.rightValue)
  99 + },
  100 +
  101 + /**
  102 + * 左边滑块滑动
  103 + */
  104 + _minMove: function (e) {
  105 + let pagex = e.changedTouches[0].pageX / this.data.ratio - this.data.containerLeft - this.data.sliderLength / 2
  106 +
  107 + if (pagex + this.data.sliderLength >= this.data.rightValue) {
  108 + pagex = this.data.rightValue - this.data.sliderLength
  109 + } else if (pagex <= 0) {
  110 + pagex = 0
  111 + }
  112 +
  113 + this.setData({
  114 + leftValue: pagex
  115 + })
  116 +
  117 + let lowValue = parseInt(pagex / this.data.bigLength * parseInt(this.data.max - this.data.min) + this.data.min)
  118 + var myEventDetail = { lowValue: lowValue }
  119 + this.triggerEvent('lowValueChange', myEventDetail)
  120 + },
  121 +
  122 + /**
  123 + * 右边滑块滑动
  124 + */
  125 + _maxMove: function (e) {
  126 +
  127 + let pagex = e.changedTouches[0].pageX / this.data.ratio - this.data.containerLeft - this.data.sliderLength / 2
  128 + if (pagex <= this.data.leftValue + this.data.sliderLength) {
  129 + pagex = this.data.leftValue + this.data.sliderLength
  130 + } else if (pagex >= this.data.totalLength) {
  131 + pagex = this.data.totalLength
  132 + }
  133 +
  134 + this.setData({
  135 + rightValue: pagex
  136 + })
  137 +
  138 + pagex = pagex - this.data.sliderLength
  139 + let heighValue = parseInt(pagex / this.data.bigLength * (this.data.max - this.data.min) + this.data.min)
  140 +
  141 + var myEventDetail = { heighValue: heighValue }
  142 + this.triggerEvent('heighValueChange', myEventDetail)
  143 + },
  144 +
  145 + /**
  146 + * 隐藏组件
  147 + */
  148 + hide: function () {
  149 + this.setData({
  150 + hideOption: 'hide',
  151 + })
  152 + },
  153 + /**
  154 + * 显示组件
  155 + */
  156 + show: function () {
  157 + this.setData({
  158 + hideOption: '',
  159 + })
  160 + },
  161 + /**
  162 + * 重置
  163 + */
  164 + reset: function () {
  165 + this.setData({
  166 + rightValue: this.data.totalLength,
  167 + leftValue: 0,
  168 + })
  169 + },
  170 +
  171 +
  172 +
  173 +
  174 +
  175 + },
  176 +
  177 + ready: function () {
  178 + let that = this;
  179 + const getSystemInfo = util.wxPromisify(wx.getSystemInfo)
  180 + const queryContainer = util.wxPromisify(wx.createSelectorQuery().in(this).select(".container").boundingClientRect)
  181 + util.wxPromisify(wx.getSystemInfo)()
  182 + .then(res => {
  183 + let ratio = res.windowWidth / 750
  184 + that.setData({
  185 + ratio: ratio,
  186 + })
  187 + })
  188 + .then(() => {
  189 + var query = wx.createSelectorQuery().in(this)
  190 + query.select(".container").boundingClientRect(function (res) {
  191 + that.setData({
  192 + totalLength: res.width / that.data.ratio - that.data.sliderLength,
  193 + bigLength: res.width / that.data.ratio - that.data.sliderLength * 2,
  194 + rightValue: res.width / that.data.ratio - that.data.sliderLength,
  195 + containerLeft: res.left / that.data.ratio,
  196 + })
  197 +
  198 +
  199 + /**
  200 + * 设置初始滑块位置
  201 + */
  202 +
  203 + setTimeout(function(){
  204 + that._propertyLeftValueChange()
  205 + that._propertyRightValueChange()
  206 +
  207 + },350)
  208 +
  209 + }).exec()
  210 + })
  211 + },
  212 +
  213 +
  214 +
  215 +
  216 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
  1 +<!--component/zyslider.wxml-->
  2 +
  3 +<view class="container {{hideOption}}">
  4 + <!-- <view class="slider-item min" style="left:{{leftValue}}rpx;background-color:#E81825;" catchtouchmove="_minMove">
  5 +
  6 +</view> -->
  7 + <view class="slider-item min" style="left:{{leftValue}}rpx;" catchtouchmove="_minMove">
  8 + <image src="/img/aicon_17.png"></image>
  9 + </view>
  10 + <!-- <view class="slider-item max" style="left:{{rightValue}}rpx;background-color:#E81825;" catchtouchmove="_maxMove"></view> -->
  11 + <view class="slider-item max" style="left:{{rightValue}}rpx;" catchtouchmove="_maxMove">
  12 + <image src="/img/aicon_17.png"></image>
  13 + </view>
  14 + <view class="slider-body left" style="left:{{sliderLength}}rpx; width:{{leftValue}}rpx;"></view>
  15 +
  16 + <view class="slider-body body" style="left:{{leftValue}}rpx; width:{{rightValue-leftValue}}rpx;background-color:{{selectedColor}};">
  17 +
  18 +
  19 + </view>
  20 +
  21 +
  22 + <view class="slider-body right" style="left:{{rightValue}}rpx; width:{{totalLength - rightValue}}rpx;"></view>
  23 + <!-- <view class="pp" style="left:{{ppleft}}rpx; width:{{ppvalue-ppleft}}rpx">
  24 + <view class="item"></view>
  25 + <view class="item"></view>
  26 + <view class="item"></view>
  27 + <view class="item"></view>
  28 + </view> -->
  29 + <slot></slot>
  30 +</view>
  1 +/* component/zyslider.wxss */
  2 +.container {
  3 + /*height: 100%;*/
  4 + width: 100%;
  5 + position: relative;
  6 +
  7 +}
  8 +
  9 +.slider-body {
  10 + height: 2rpx;
  11 + background-color: #ddd;
  12 + position: relative;
  13 +}
  14 +
  15 +.body {
  16 + bottom: 28rpx;
  17 + background-color: #19896f;
  18 + z-index: 0.3;
  19 +
  20 +}
  21 +
  22 +.left {
  23 + bottom: 26rpx;
  24 + z-index: 0.1;
  25 +}
  26 +
  27 +.right {
  28 + z-index: 0.2;
  29 + bottom: 30rpx;
  30 +}
  31 +
  32 +.slider-item {
  33 + border-radius: 50%;
  34 + width: 35rpx;
  35 + height: 35rpx;
  36 + /* background-color: #E81825; */
  37 + font-size: 0;
  38 + z-index: 2;
  39 +}
  40 +
  41 +.min {
  42 + position: relative;
  43 + top: 27rpx;
  44 + /*left: 100rpx;*/
  45 +}
  46 +
  47 +.max {
  48 + position: relative;
  49 + bottom:9rpx;
  50 + /*left: 600rpx;*/
  51 +}
  52 +
  53 +.hide{
  54 + display: none;
  55 +}
  56 +.item{
  57 + height:20rpx;
  58 + width:2rpx;
  59 + background: #E81825;
  60 + margin-left:20rpx;
  61 +}
  62 +.pp{
  63 + display:flex;
  64 + justify-content: space-around;
  65 + align-items: center;
  66 + margin:0 auto;
  67 +}
  68 +.item{
  69 + width:2rpx;
  70 + height:20rpx;
  71 + background: #E81825;
  72 +
  73 +}
@@ -49,7 +49,7 @@ @@ -49,7 +49,7 @@
49 "list": [] 49 "list": []
50 }, 50 },
51 "miniprogram": { 51 "miniprogram": {
52 - "current": 46, 52 + "current": 47,
53 "list": [ 53 "list": [
54 { 54 {
55 "id": -1, 55 "id": -1,
@@ -377,6 +377,13 @@ @@ -377,6 +377,13 @@
377 "id": -1, 377 "id": -1,
378 "name": "账号与安全", 378 "name": "账号与安全",
379 "pathName": "pages/myblock/zhanghaoyuanquan/zhanghaoyuanquan", 379 "pathName": "pages/myblock/zhanghaoyuanquan/zhanghaoyuanquan",
  380 + "query": "",
  381 + "scene": null
  382 + },
  383 + {
  384 + "id": -1,
  385 + "name": "用户协议",
  386 + "pathName": "pages/yonghuxieyi/yonghuxieyi",
380 "scene": null 387 "scene": null
381 } 388 }
382 ] 389 ]