| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- keyword: '',
- list:[],
- status:[{statu:'已入库',type:'00'},{statu:'已出库',type:'10'},{statu:'已结束',type:'20'}],
- text:'已入库',
- isStatus:false,
- type:'00',
- scrollHeight: 0, // scroll-view高度
- startX: 0, // 开始X坐标
- startY: 0, // 开始Y坐标
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- searchList(){
- this.getChainList();
- },
- getChainList() {
- var that = this;
- wx.showLoading({
- title: '正在加载...',
- mask: true
- })
- app.requestP({
- url: "/chain/pageChain",
- method: "post",
- contentType: ' application/json',
- data: {
- pageNum: 1,
- pageSize: 1000,
- parentId: 0,
- transportStatus: that.data.type,
- keyword: that.data.keyword || ''
- }
- }).catch(err => {
- app.showToptip(that, "error", "数据获取失败,请稍后再试")
- // 隐藏导航栏加载框
- wx.hideNavigationBarLoading();
- // 停止下拉动作
- wx.stopPullDownRefresh();
- }).then(res => {
- var data = res.data.data.rows
- that.setData({
- list: data,
- page: '1',
- })
- // 隐藏导航栏加载框
- wx.hideNavigationBarLoading();
- // 停止下拉动作
- wx.stopPullDownRefresh();
- wx.hideLoading()
- })
- },
- setKeyword(e) {
- this.setData({
- keyword: e.detail.value
- })
- },
- allStatus(){
- if(this.data.isStatus){
- this.setData({
- isStatus:false
- })
- }else{
- this.setData({
- isStatus:true
- })
- }
- },
- setStatus(e){
- var type = e.currentTarget.dataset.type;
- for(var i in this.data.status){
- if(this.data.status[i].type == type){
- this.setData({
- text:this.data.status[i].statu,
- isStatus:false,
- type:type + '',
- })
- this.getChainList()
- break;
- }
- }
- },
- addLabel(){
- wx.removeStorageSync('orderSelect')
- wx.navigateTo({
- url: '/pages/workbench/tempList/addChain/addChain?pid=0',
- })
- },
- editList(e){
- var item = e.currentTarget.dataset.item;
- wx.navigateTo({
- url: '/pages/workbench/tempList/addChain/addChain?item='+JSON.stringify(item),
- })
- },
- delList(e){
- var that = this;
- wx.showModal({
- title: '提示',
- content: '该冷链内有可能会包含子冷链,删除后不可恢复,请确认是否删除',
- success (res) {
- if (res.confirm) {
- var id = e.currentTarget.dataset.id;
- app.requestP({
- url:'/chain/del',
- method:'post',
- data:{
- chainId:id
- }
- }).then(res=>{
- app.showToptip(that,'success',res.data.msg);
- that.getChainList();
- }).catch(err=>{
- app.showToptip(that,'error',err.data.msg);
- })
- } else if (res.cancel) {
- //点击取消
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getChainList();
- this.setData({
- scrollHeight: wx.getSystemInfoSync().screenHeight
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- goChainInfo(e){
- const id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/query/details?id='+id,
- })
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- // 手指触摸动作开始
- touchStart: function (e) {
- let that = this;
- //开始触摸时 重置所有删除
- that.data.list.forEach(function (v, i) {
- if (v.isTouchMove) v.isTouchMove = false; // 只操作为true的
- })
- // 记录手指触摸开始坐标
- that.setData({
- startX: e.changedTouches[0].clientX, // 开始X坐标
- startY: e.changedTouches[0].clientY, // 开始Y坐标
- list: that.data.list
- })
- },
- // 手指触摸后移动
- touchMove: function (e) {
- let that = this,
- index = e.currentTarget.dataset.index, // 当前下标
- startX = that.data.startX, // 开始X坐标
- startY = that.data.startY, // 开始Y坐标
- touchMoveX = e.changedTouches[0].clientX, // 滑动变化坐标
- touchMoveY = e.changedTouches[0].clientY, // 滑动变化坐标
- // 获取滑动角度
- angle = that.angle({
- X: startX,
- Y: startY
- }, {
- X: touchMoveX,
- Y: touchMoveY
- });
- // 判断滑动角度
- that.data.list.forEach(function (v, i) {
- v.isTouchMove = false
- // 滑动超过30度角 return
- if (Math.abs(angle) > 30) return;
- if (i == index) {
- // 右滑
- if (touchMoveX > startX)
- v.isTouchMove = false
- // 左滑
- else
- v.isTouchMove = true
- }
- })
- // 更新数据
- that.setData({
- list: that.data.list
- })
- },
- // 计算滑动角度
- angle: function (start, end) {
- let that = this,
- _X = end.X - start.X,
- _Y = end.Y - start.Y;
- // 返回角度 /Math.atan()返回数字的反正切值
- return 360 * Math.atan(_Y / _X) / (2 * Math.PI);
- },
- })
|