一、微信收款码

<view class="margin-top-xs padding-xs code-box" hidden="{{ withdraw_type != 3}}">
<view class="margin-bottom-xs cu-form-group">
<view style="margin-right: 26rpx;" class="title">姓名:</view>
<input name='{{ withdraw_type == 3 ? "wx_account_name" : "zfb_account_name" }}' value='{{ withdraw_type == 3 ? userInfo.wx_account_name : userInfo.zfb_account_name }}' placeholder="您的姓名"></input>
</view>
<view class="padding-top cu-form-group">
<view class="title">收款码:</view>
<image class='cu-avatar xl' src='{{ withdraw_type == 3 ? userInfo.wx_account_qrcode : userInfo.zfb_account_qrcode }}' bindtap="previewImage" data-key="{{ withdraw_type == 3 ? 'wx_account_qrcode' : 'zfb_account_qrcode' }}"></image>
<view class="padding-left flex-sub" bindtap='chooseImage' data-key="{{ withdraw_type == 3 ? 'wx_account_qrcode' : 'zfb_account_qrcode' }}">
<button class='cu-btn line-green radius-20'>上传收款码</button>
</view>
<input type="text" hidden="true" name='{{ withdraw_type == 3 ? "wx_account_qrcode" : "zfb_account_qrcode" }}' value='{{ withdraw_type == 3 ? userInfo.wx_account_qrcode : userInfo.zfb_account_qrcode }}' />
</view>
</view>
import { chooseImageTap } from '../../../utils/util.js'
/**
* 上传收款码
*/
chooseImage(e){
let key = e.currentTarget.dataset.key
chooseImageTap().then(res => {
this.setData({
[`userInfo.${key}`]: res.url
})
wx.showToast({
title: '上传成功',
icon: 'success',
duration: 2000
})
}).catch(error=>{
wx.showToast({
title: '上传失败',
icon:"none",
duration:2000
})
})
},
/**
* 选择图片路径
*/
function chooseImageTap() {
return new Promise((resolve, reject) => {
wx.showActionSheet({
itemList: ['从相册中选择', '拍照'],
itemColor: "#00000",
success(res) {
if (!res.cancel) {
let type = res.tapIndex == 0 ? 'album' : 'camera';
chooseWxImage(type).then(res => {
resolve(res);
})
}
}
})
});
}
/**
* 选择图片
*/
function chooseWxImage(type) {
return new Promise((resolve, reject) => {
wx.chooseImage({
sizeType: ['original', 'compressed'],
sourceType: [type],
success(res) {
let name = res.tempFilePaths[0];
name.replace("http://tmp/", "");
wx.showLoading({
title: '上传中',
});
uploadFile({
file: res.tempFilePaths[0],
name: name
}).then(url => {
resolve({
url: url,
type: 1
});
});
},
fail(err) {
wx.showToast({
title: err.errMsg,
icon: 'none',
duration: 2500
})
}
})
});
}
/**
* 上传文件
*/
function uploadFile(query) {
const that = this, app = getApp(),
formData = {};
formData.file = query.file
formData.token = wx.getStorageSync('token')
return new Promise((resolve, reject) => {
wx.uploadFile({
url: `${app.globalData.requestUrl}Image/uploadImage`,
filePath: query.file,
name: 'file',
formData: formData,
header: {
"Content-Type": "multipart/form-data",
'accept': 'application/json',
},
success(res) {
console.log(res);
wx.hideLoading();
if (res.statusCode == 200) {
wx.showToast({
title: '上传成功'
});
let info = JSON.parse(res.data);
console.log(info);
wx.showToast({
title: '上传成功' + info.data.file_url,
});
resolve(info.data.file_url);
} else {
wx.showToast({
title: res.errMsg,
icon: 'none'
});
}
},
fail(res) {
wx.hideLoading();
wx.showToast({
title: '网络连接错误',
icon: 'none'
});
}
})
})
}
post(方法)
{
"code":0,
"data":{
"detail":{
"server":"AliyunOSS",
"date":"Fri, 25 Aug 2023 03:41:20 GMT",
"content-length":"0",
"connection":"keep-alive",
"x-oss-request-id":"64E822E01344D13733B94BC7",
"etag":"\"92D7B021F462E7309B0F0A4BAD6464A1\"",
"x-oss-hash-crc64ecma":"10646956825584657952",
"content-md5":"ktewIfRi5zCbDwpLrWRkoQ==",
"x-oss-server-time":"43",
"info":{
"url":"http://fangda-rs.oss-cn-shenzhen.aliyuncs.com/pwd/2023-08-25/114158004.png",
"content_type":null,
"http_code":200,
"header_size":335,
"request_size":445,
"filetime":-1,
"ssl_verify_result":0,
"redirect_count":0,
"total_time":0.056783,
"namelookup_time":0.000543,
"connect_time":0.006869,
"pretransfer_time":0.006889,
"size_upload":11301,
"size_download":0,
"speed_download":0,
"speed_upload":201803,
"download_content_length":0,
"upload_content_length":11301,
"starttransfer_time":0.013379,
"redirect_time":0,
"redirect_url":"",
"primary_ip":"120.77.166.11",
"certinfo":[
],
"primary_port":80,
"local_ip":"172.18.166.111",
"local_port":54962,
"http_version":2,
"protocol":1,
"ssl_verifyresult":0,
"scheme":"HTTP",
"appconnect_time_us":0,
"connect_time_us":6869,
"namelookup_time_us":543,
"pretransfer_time_us":6889,
"redirect_time_us":0,
"starttransfer_time_us":13379,
"total_time_us":56783,
"method":"PUT"
},
"oss-request-url":"http://fangda-rs.oss-cn-shenzhen.aliyuncs.com/pwd/2023-08-25/114158004.png",
"oss-redirects":0,
"oss-stringtosign":"PUT\n\nimage/png\nFri, 25 Aug 2023 03:41:20 GMT\n/fangda-rs/pwd/2023-08-25/114158004.png",
"oss-requestheaders":{
"Accept-Encoding":"",
"Content-Type":"image/png",
"Date":"Fri, 25 Aug 2023 03:41:20 GMT",
"Host":"fangda-rs.oss-cn-shenzhen.aliyuncs.com",
"Authorization":"OSS LTAI5tJvzrWBnkiJrXk9czHk:auGKVwQx0clcZXBI65+aVqRPMKo="
},
"body":""
},
"file_url":"https://fangda-rs.oss-cn-shenzhen.aliyuncs.com/pwd/2023-08-25/114158004.png",
"file_name":"114158004.png"
},
"msg":"上传成功"
}
二、去问驱蚊器