123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- // pages/control/order/order.js
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- fileList: [],
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- wash_code:options.wash_code
- })
- this.getdesc()
- },
- toResult(){
- var that = this;
- var fileList=this.data.fileList;
- var images=[]
- fileList.map((item, index) => {
- images[index]=item.url
- })
- if(images=="" || images==[]){
- wx.showLoading({
- title: "你忘记拍照了",
- })
- setTimeout(function () {
- wx.hideLoading();
- }, 1000);
- return false;
- }
- app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/hand/hand_up", {
- wash_code:this.data.wash_code,
- images:images
- }, "post").then(function (res) {
- console.log(res);
- if (res.code != 200) {
- wx.showLoading({
- title: res.message.msg,
- })
- setTimeout(function () {
- wx.hideLoading();
- }, 1000);
-
- } else {
- wx.hideLoading();
- var data = res.message.data
- wx.showLoading({
- title: res.message.msg,
- })
- setTimeout(function () {
- wx.hideLoading();
- wx.navigateTo({
- url: '../result/result?data='+JSON.stringify(data),
- })
- }, 1000);
-
-
- }
- }).catch(function (err) {
-
- console.log(222);
- })
-
- },
- getdesc(){
- var that = this;
- app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/entry/desc", {
- wash_code:this.data.wash_code,
- }, "get").then(function (res) {
- console.log(res);
- if (res.code != 200) {
- wx.showLoading({
- title: res.message.msg,
- })
- setTimeout(function () {
- wx.hideLoading();
- wx.navigateBack({
- delta: 1 //想要返回的层级
- })
- }, 1000);
-
- } else {
- wx.hideLoading();
- let data = res.message.data
- that.setData({
- data
- })
-
- }
- }).catch(function (err) {
-
- console.log(222);
- })
- },
- afterRead(event) {
- var that=this;
- const { file } = event.detail;
- // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
- wx.uploadFile({
- url: app.globalData.baseAppUrl + 'api/common/uploadImg', // 仅为示例,非真实的接口地址
- filePath: file.url,
- header: {
- "Content-Type": "multipart/form-data",
- 'accept': 'application/json',
- },
- name: 'file',
- formData: { user: 'test' },
- success(res) {
- var datas = JSON.parse(res.data)
- console.log(datas);
- if(datas.code==200){
- // 上传完成需要更新 fileList
- const { fileList = [] } = that.data;
- fileList.push({ ...file, url: datas.message.data.path });
- that.setData({ fileList });
- }else{
- wx.showLoading({
- title: datas.message.msg,
- })
- setTimeout(function () {
- wx.hideLoading();
- }, 1000);
-
- }
- },
- });
- },
- oncloes(){
- wx.navigateBack({
- delta: 1 //想要返回的层级
- })
- }
-
- })
|