methods.js
925 字节
"use strict";const t=require("../common/vendor.js"),c={upload(e,a){let o={};t.index.chooseImage({success:s=>{const n=s.tempFilePaths;o.avatar=n[0],t.index.uploadFile({url:e,filePath:n[0],name:"file",formData:{user:"test",token:t.index.getStorageSync("token")},success:i=>{console.log(JSON.parse(i.data),"图片路径"),o.upImg=JSON.parse(i.data).data.url,a(o)}})}})},pay(e){e.appId&&t.index.requestPayment({provider:"wxpay",timeStamp:e.timeStamp,nonceStr:e.nonceStr,package:e.package,signType:e.signType,appid:e.appId,paySign:e.paySign,success(a){console.log("支付成功"),t.index.showToast({title:"支付成功~"}),setTimeout(()=>{t.index.navigateBack()},1500)},fail(a){console.log("支付失败",a),t.index.showToast({title:"支付取消~",icon:"none"}),setTimeout(()=>{t.index.navigateBack()},1500)}})},showTN(e){t.index.showToast({title:e,icon:"none"}),setTimeout(()=>{t.index.navigateBack()},1e3)}};exports.methods=c;