shark1100913
//test.wxml
<
view class=\'h_ctr4 bc_white\'> <view bindtap=\'xuan\' data-num="1" data-id=\'zuijin\' class="{{_num == 1 ? \'isxuan\':\'xuan\'}}">全部</view> <view bindtap=\'xuan\' data-num="2" data-id=\'zuigao\' class="{{_num == 2 ? \'isxuan\':\'xuan\'}}">未使用</view> <view bindtap=\'xuan\' data-num="3" data-id=\'quanbu\' class="{{_num == 3 ? \'isxuan\':\'xuan\'}}">已使用</view> </view>
//test.wxss
/*
选项卡*/ .h_ctr4 { width: 100%; height: 75rpx; line-height: 75rpx; font-size: 30rpx; margin-top: 0rpx; display: flex; } .xuan{ width: 250rpx; text-align: center; color: #333333; } .isxuan{ text-align: center; width: 250rpx; border-bottom: 10rpx solid #b4282d; color: #b4282d; }
//test.js
Page({
/** * 页面的初始数据 */ data: { _num: 1, //这是点击选项卡参数,不是接口不需要传值 }, //点击切换距离、销量、全部店铺 xuan: function (e) { var that = this; this.setData({ _num: e.target.dataset.num }) var id = e.currentTarget.dataset.id; if (id == "zuijin") { wx.request({ // url: \'https://ceshi23.acorntimes.com/a/gongsi_zuijin.json\', // url: \'http://192.168.199.181/a/gongsi_zuijin.json\', url: rootDocment + \'/a/gongsi_zuijin.json\', data: { id: id }, method: \'POST\', header: {}, success: function (res) { that.setData({ shops: res.data.data.shops }); } }) } if (id == "zuigao") { wx.request({ // url: \'https://ceshi23.acorntimes.com/a/gongsi_zuijin.json\', // url: \'http://192.168.199.181/a/gongsi_zuijin.json\', url: rootDocment + \'/a/gongsi_zuigao.json\', data: { id: id }, method: \'POST\', header: {}, success: function (res) { that.setData({ shops: res.data.data.shops }); } }) } if (id == "quanbu") { wx.request({ // url: \'https://ceshi23.acorntimes.com/a/gongsi_zuijin.json\', // url: \'http://192.168.199.181/a/gongsi_zuijin.json\', url: rootDocment + \'/a/gongsi_quanbu.json\', data: { id: id }, method: \'POST\', header: {}, success: function (res) { that.setData({ shops: res.data.data.shops }); } }) } }, })

 

分类:

技术点:

相关文章: