This article example shares the specific code for the small program to achieve the sliding block effect for your reference. The specific content is as follows When you copy, just make sure to change the list data of the js logic. CSS style of the applet .box { width: 100vw; background: #F2F2F2; transition: all 3s; } .box-b { height: 8vh; width: 100%; display: flex; justify-content: space-between; background-color: #FAFAFA; align-items: center; padding: 0 30rpx; box-sizing: border-box; } .box-r1 { font-size: 24rpx; color: red; } .box-r2 { font-size: 28rpx; padding: 20rpx 50rpx; border-radius: 50rpx; color: #fff; background-color: #FF6C3B; } .box-t { height: 92vh; overflow-y: auto; overflow-x:hidden; padding: 0 25rpx; } .box-top { width: 90vw; height: 22vw; margin-top: 20rpx; display: flex; flex-direction: column; justify-content: space-around; } .boxs { width: 105vw; height: 20vw; margin-top: 20rpx; display: flex; flex-direction: row; justify-content: space-around; } .boxs-1 { width: 100vw; height: 20vw; background: white; display: flex; flex-direction: row; justify-content: space-around; padding: 10rpx 0; border-radius: 10px; margin-left: 20px; } .boxs-1 > view:first-child { width: 10vw; line-height: 18vw; text-align: center; /* background: #ccc; */ height: 20vw; } .boxs-1 > view:nth-child(2) { width: 20vw; /* background: #ccc; */ height: 100%; border-radius: 20rpx; } image { width: 100%; height: 100%; border-radius: 20rpx; } .boxs-1 > view:last-child { width: 60vw; /* background: #ccc; */ height: 100%; display: flex; flex-direction: column; justify-content: space-around; } .boxs-1 > view:last-child>view{ display: flex; flex-direction: row; justify-content: space-around; position: relative; left: 30rpx; } text { width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .boxs-2 { width: 120rpx; height: 170rpx; text-align: center; line-height: 170rpx; background: #e64340; font-size: 24rpx; color: #fff; border-top-right-radius: 10px; border-bottom-right-radius: 10px; } .red_cart{ color: red; position: relative; right: 40px; } wxml style of applet <view class="box"> <view class="box-t"> <movable-area class="box-top" wx:for="{{list}}" wx:key="index"> <movable-view class="boxes" direction="horizontal" animation="{{true}}" inertia="true" out-of-bounds="false" > <view class="boxs-1"> <view> <checkbox checked="{{selected}}" wx:key="index" bindtap="chec" data-selected="{{item}}"></checkbox> </view> <view> <image src="{{item.pic}}"></image> </view> <view class="cart_list"> <text>{{item.name}}</text> <view> <view class="red_cart">¥{{item.price}}</view> <view> <van-stepper class="cart_vant" value="{{ item.number }}" bind:change="onChange" data-key="{{item.key}}"/> </view> </view> </view> </view> <view class="boxs-2" bindtap="del" data-key="{{item.key}}">Delete</view> </movable-view> </movable-area> </view> <view class="box-b"> <view class="box-r1">Total:¥{{price}}</view> <view class="box-r2">Go to checkout</view> </view> </view> Mini Program js // pages/sales/sales.js let { getShop, getRemove, modifyNumber, getSelected } = require('../../http/api') Page({ onShareAppMessage() { return { title: 'movable-view', path: 'page/component/pages/movable-view/movable-view' } }, data: { x: 0, scale: 2, list: [], //You can now define the list data test using price: 0, selected: [] }, del(e) { console.log(e.currentTarget.dataset.key) var keys = e.currentTarget.dataset.key var token = wx.getStorageSync('token') getRemove(token, keys).then(res => { // console.log(res) }) this.getShop() }, onChange(e) { console.log(e.currentTarget.dataset.key) console.log(e.detail) var token = wx.getStorageSync('token') var key = e.currentTarget.dataset.key var number = e.detail modifyNumber(token, key, number).then(res => { // console.log(res) }) this.getShop() }, tap() { this.setData({ x: 0, }) }, getShop() { getShop().then(res => { this.setData({ list: res.items }) }) }, chec(e) { this.getShop() }, onLoad: function (options) { getShop().then(res => { this.setData({ list: res.items }) this.data.list.forEach(i => { var token = wx.getStorageSync('token') var key = i.key var selected = i.selected this.setData({ selected: selected }) getSelected(token, key, selected).then(res => { this.setData({ price: res.data.price }) }) }) }) }, onShow: function () { this.getShop() if (wx.getStorageSync('token')) { wx.hideLoading() } else { wx.showLoading({ title: 'Please log in', }) } }, /** * Life cycle function--listen for page hiding*/ onHide: function () { }, /** * Life cycle function--monitor page uninstallation*/ onUnload: function () { }, onReady: function () { }, /** * Page related event processing function - listen to user pull-down action */ onPullDownRefresh: function () { }, /** * The function that handles the bottoming event on the page*/ onReachBottom: function () { }, /** * User clicks on the upper right corner to share*/ }) The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: How to view the storage location of MySQL data files
>>: Solution to the problem of being unable to access the Internet after Ubuntu restarts in VMWare
Preface Recently, I took over a client's nati...
This article example shares the specific code for...
This article shares the specific code of js to im...
MySQL full text search Chinese solution Recently,...
This article shares the specific code of JavaScri...
1. Command method Run the nginx service in the cr...
Introduction Do you really know the difference be...
Root directory and index file The root directive ...
This article example shares the specific code of ...
Preface Let me share with you how I deployed a Sp...
After setting the table width in the page to width...
mysql permissions and indexes The highest user of...
Stored Functions What is a stored function: It en...
Today, let's introduce several common text pr...
1. Introduction tr is used to convert or delete a...