// pages/shipOwnerManage/shipOwnerList/shipOwnerList.js import { uploadFile } from "../../../utils/upload" import { postApi } from "../../../apis/api" Page({ data: { shipOwnerList: [], term: '', currentLetter: '', }, async getShipOwnerList(type) { if (!wx.getStorageSync('loginAccountId')) { this.setData({ shipOwnerList: [], currentLetter: '' }) wx.showToast({ title: '尚未登录', icon: "error" }) return } let res = await postApi('/ship/wx/list', { loginAccountId: wx.getStorageSync('loginAccountId'), term: this.data.term }) if (type) wx.stopPullDownRefresh() if (res.data.status == 0) { if (res.data.result.length == 0) { wx.showToast({ title: '暂无数据', icon: "error" }) return } let shipOwnerList = res.data.result shipOwnerList[0].letter = "#" shipOwnerList.push(shipOwnerList.shift()) this.setData({ shipOwnerList }) } else { this.setData({ shipOwnerList: [] }) } }, call(e) { wx.makePhoneCall({ phoneNumber: e.currentTarget.dataset.phone }) }, addShipOwner() { if (!wx.getStorageSync('loginAccountId')) { wx.showToast({ title: '尚未登录', icon: "error" }) return } wx.navigateTo({ url: '../addShipOnwer/addShipOnwer', }) }, tapLetter(e) { this.setData({ currentLetter: e.currentTarget.dataset.letter }) }, createVoyage(e) { console.log(e) let { shipId, shipName } = e.currentTarget.dataset.shipowner wx.showModal({ title: '是否创建航次?', content: shipName, success(res) { if (res.confirm) { wx.navigateTo({ url: `/pages/voyageManage/createVoyage/createVoyage?shipId=${shipId}&shipName=${shipName}`, }) } else if (res.cancel) { console.log('用户点击取消') } }, fail: e => { console.log(e) } }) }, onLoad() { }, onPullDownRefresh() { this.setData({ term: '' }) this.getShipOwnerList(1) }, onShow() { this.getShipOwnerList() } })