123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import * as requestAPI from '../../models/dataModel'
- Page({
- data: {
- sampleList: [],
- sdDocument: '',
- pCode: '',
- current: 1,
- size: 5,
- total: 0
- },
- onLoad: function (options) {
- this.setData({
- pCode: options?options.pCode:this.data.pCode,
- sdDocument: options?options.sdDocument:this.data.sdDocument
- })
- this.getSampleList()
- },
- // 获取样品单列表
- getSampleList() {
- // wx.showLoading({title: '加载中', icon: 'loading'});
- let form = {
- current: this.data.current,
- size: this.data.size,
- sdDocument: this.data.sdDocument,
- pCode: this.data.pCode
- }
- requestAPI.getSampleList(form).then(res => {
- for (let i of res.data.data.records) {
- i.productImgUrl = i.pictures[0].bigPicture
- }
- this.setData({
- sampleList: res.data.data.records,
- total: res.data.data.total
- })
- })
- },
- // 获取样品单详情
- getDetail: function (event) {
- wx.navigateTo({
- url: `/pages/sample/detail?sdpId=${event.currentTarget.dataset.id}`,
- })
- },
- // 下拉刷新
- onPullDownRefresh: function () {
- wx.showNavigationBarLoading(); //在当前页面显示导航条加载动画
- this.onLoad(); //刷新页面
- setTimeout(function () {
- wx.hideNavigationBarLoading(); //在当前页面隐藏导航条加载动画
- wx.stopPullDownRefresh(); //停止下拉动作
- }, 2000)
- },
- // 下拉加载
- onReachBottom: function () {
- if (this.data.size > this.data.total) {
- return;
- } else {
- this.getSampleList();
- this.setData({
- size: this.data.size+10
- })
- }
- },
- openPreview: function (event) {
- wx.previewImage({
- urls: new Array(event.currentTarget.dataset.url),
- })
- }
- })
|