|
- var app = getApp();
- const config = require('../../../config/config.js')
- const util = require('../../../utils/util.js')
- const Http = require('../../../utils/HttpBasics.js')
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- receiptUrl:null,
- id:"",
- newPrice:'',
- },
- goBack(){
- wx.navigateBack({
- delta: 1
- })
- },
- // setNewPrice(e){
- // this.setData({
- // newPrice: e.detail.value
- // })
- // },
- uploadImg() {
-
- let that = this;
- wx.chooseImage({
- success(res) {
- const tempFilePaths = res.tempFilePaths
- wx.showLoading({
- title: '上传中...',
- })
- wx.uploadFile({
- url: config.api.imgUpload, // 仅为示例,非真实的接口地址
- filePath: tempFilePaths[0],
- name: 'file',
- header: {
- 'token': app.globalData.token
- },
- success(res) {
- const data = res.data
- that.setData({
- receiptUrl: JSON.parse(res.data).data.url
- })
- wx.hideLoading()
- // do something
- },
- fail() {
- wx.hideLoading()
- }
- })
-
- },
- })
-
- },
- submit(){
- let this_ = this;
- if (!this.data.receiptUrl){
- wx.showToast({
- title: `请先上传凭证在提交!`,
- icon: "none",
- duration: 1000,
- })
- return true
- }else{
- Http.post({
- url: config.api.finishBill,
- data:{
- id:this.data.id,
- payImg:this.data.receiptUrl,
- billTypeValue: this.data.billTypeValue,
- newPrice: this.data.newPrice
- }
- }).then(res=>{
- wx.showToast({
- title: "上传成功!",
- icon: 'none',
- duration: 2000,
- mask: false,
- success(res){
- setTimeout(function () {
- this_.goBack()
- }, 2000);
- },
-
- });
- }).catch(err=>{
- wx.showToast({
- title: err.message,
- icon: 'none',
- duration: 2000,
- mask: false
- });
- })
- }
-
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- console.log(options.id)
- this.setData({
- id : options.id,
- billTypeValue: options.billTypeValue,
- newPrice: options.newPrice
- })
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- }
- })
|