123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import * as requestAPI from '../../models/dataModel'
- Page({
- data: {
- contractList: [],
- sscCode: '',
- pCode: '',
- current: 1,
- size: 5,
- total: 0
- },
- onLoad: function (options) {
- this.setData({
- pCode: options?options.pCode:this.data.pCode,
- sscCode: options?options.sscCode:this.data.sscCode
- })
- this.getContractList()
- },
- // 获取样品单列表
- getContractList() {
- wx.showLoading({title: '加载中', icon: 'loading'});
- let form = {
- current: this.data.current,
- size: this.data.size,
- sscCode: this.data.sscCode,
- pCode: this.data.pCode
- }
- requestAPI.getContractList(form).then(res => {
- for (let i of res.data.data.records) {
- i.productImgUrl = i.pictures[0].bigPicture
- }
- this.setData({
- contractList: res.data.data.records,
- total: res.data.data.total
- })
- })
- },
- // 获取样品单详情
- getDetail: function (event) {
- wx.navigateTo({
- url: `/pages/contract/detail?sscId=${event.currentTarget.dataset.sscid}&pId=${event.currentTarget.dataset.pid}`,
- })
- },
- // 下拉刷新
- 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.getContractList();
- this.setData({
- size: this.data.size+10
- })
- }
- },
- openPreview: function (event) {
- wx.previewImage({
- urls: new Array(event.currentTarget.dataset.url),
- })
- }
- })
|