1、如何實(shí)現(xiàn)點(diǎn)擊返回頂層? 最近在研究微信小程序,被這個(gè)返回頂層給坑了一波,下面貼代碼 wxml代碼: <scroll-view scroll-y style="height: 1000rpx;" scroll-top="50" enable-back-to-top="true" scroll-top="{{scrollTop.scroll_top}}" bindscroll="scrollTopFun"> <block wx:for="{{sortArr}}"> <template is="spL" data="{{item}}">template> block> scroll-view> <view class="findOur fliexBox"><contact-button type="default-light" size="15" session-from="weapp">contact-button>客服view> <view class="callOur fliexBox" bindtap="call">電話view> <view class="fliexBox" style=" bottom: 150rpx; border: solid 1px green;" wx:if="{{scrollTop.goTop_show}}" catchtap="goTopFun">頂層view> js代碼: var app = getApp(); Page({ data: { hidden: true, list: [], scrollTop: { scroll_top: 0, goTop_show: false }, scrollHeight: 0, floorstatus:true, sortArr:[ { id: 1, img: "../../images/2.jpg", title: "君御豪園住宅", introduction: "杭州不限購(gòu)不限貸口住宅", money: 5000, vperson: 115, tperson: 0 } ], }, scrollTopFun: function (e) { console.log(e.detail); if (e.detail.scrollTop > 300) {//觸發(fā)gotop的顯示條件 this.setData({ 'scrollTop.goTop_show': true }); } else { this.setData({ 'scrollTop.goTop_show': false }); } }, goTopFun: function (e) { var _top = this.data.scrollTop.scroll_top;//發(fā)現(xiàn)設(shè)置scroll-top值不能和上一次的值一樣,否則無效,所以這里加了個(gè)判斷 if (_top == 0) { _top = 1; } else { _top = 0; } this.setData({ 'scrollTop.scroll_top': _top }); }, /** * 生命周期函數(shù)--監(jiān)聽頁面加載 */ onLoad: function (options) { var that = this; wx.getSystemInfo({ success: function (res) { that.setData({ scrollHeight: res.windowHeight }); } }); }, }) wxss代碼: .fliexBox{ width: 100rpx; height: 50rpx; background-color: #5db13b; color: #ffffff; text-align: center; position: fixed; right: 0rpx; bottom: 85rpx; border-radius: 20rpx 0rpx 0rpx 20rpx; font-size: 26rpx; line-height: 50rpx; opacity: .6; } .callOur{ bottom: 20rpx; } contact-button{ opacity: 0; position: absolute; } 主要是需要把scroll-view 組件的高度設(shè)置起來而且不能是百分比 如100%這樣,可以是rpx,這樣才可以監(jiān)測(cè)到滑動(dòng)的距離。
2、微信小程序md5加密 /* * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. * Version 1.1 Copyright (C) Paul Johnston 1999 - 2002. * Code also contributed by Greg Holt * See http://pajhome.org.uk/site/legal.html for details. */ /* * Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters. */ function safe_add(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF) var msw = (x >> 16) + (y >> 16) + (lsw >> 16) return (msw << 16) | (lsw & 0xFFFF) } /* * Bitwise rotate a 32-bit number to the left. */ function rol(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)) } /* * These functions implement the four basic operations the algorithm uses. */ function cmn(q, a, b, x, s, t) { return safe_add(rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b) } function ff(a, b, c, d, x, s, t) { return cmn((b & c) | ((~b) & d), a, b, x, s, t) } function gg(a, b, c, d, x, s, t) { return cmn((b & d) | (c & (~d)), a, b, x, s, t) } function hh(a, b, c, d, x, s, t) { return cmn(b ^ c ^ d, a, b, x, s, t) } function ii(a, b, c, d, x, s, t) { return cmn(c ^ (b | (~d)), a, b, x, s, t) } /* * Calculate the MD5 of an array of little-endian words, producing an array * of little-endian words. */ function coreMD5(x) { var a = 1732584193 var b = -271733879 var c = -1732584194 var d = 271733878 for(var i = 0; i < x.length; i += 16) { var olda = a var oldb = b var oldc = c var oldd = d a = ff(a, b, c, d, x[i+ 0], 7 , -680876936) d = ff(d, a, b, c, x[i+ 1], 12, -389564586) c = ff(c, d, a, b, x[i+ 2], 17, 606105819) b = ff(b, c, d, a, x[i+ 3], 22, -1044525330) a = ff(a, b, c, d, x[i+ 4], 7 , -176418897) d = ff(d, a, b, c, x[i+ 5], 12, 1200080426) c = ff(c, d, a, b, x[i+ 6], 17, -1473231341) b = ff(b, c, d, a, x[i+ 7], 22, -45705983) a = ff(a, b, c, d, x[i+ 8], 7 , 1770035416) d = ff(d, a, b, c, x[i+ 9], 12, -1958414417) c = ff(c, d, a, b, x[i+10], 17, -42063) b = ff(b, c, d, a, x[i+11], 22, -1990404162) a = ff(a, b, c, d, x[i+12], 7 , 1804603682) d = ff(d, a, b, c, x[i+13], 12, -40341101) c = ff(c, d, a, b, x[i+14], 17, -1502002290) b = ff(b, c, d, a, x[i+15], 22, 1236535329) a = gg(a, b, c, d, x[i+ 1], 5 , -165796510) d = gg(d, a, b, c, x[i+ |
工作日 8:30-12:00 14:30-18:00
周六及部分節(jié)假日提供值班服務(wù)