| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- // pages/writeReturnLogistics/writeReturnLogistics.js
- var http = require('../../utils/http.js');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- // 物流公司选择
- deliveryList:[],
- expressId: 0, //物流公司id
- loading:false,
- expressName: '', //物流公司名称
- expressNo: '', //物流单号
- imgs: [], //图片凭证
- mobile: '', //手机号码
- refundSn: '', //退款编号名称
- shopId: '', //店铺id
- senderRemarks: '', //备注信息
- type:'',//编辑模式
- editData:null
- },
- /**
- * 选择物流公司
- */
- chooseLogisticsCompany: function (e) {
- console.log('快递公司',e.detail.value)
- this.setData({
- expressId: e.detail.value
- })
- },
- onExpressNoInput:function(e){
- this.setData({
- expressNo:e.detail.value
- });
- },
- onSenderRemarksInput: function (e) {
- this.setData({
- senderRemarks: e.detail.value
- });
- },
- /**
- * 填写&提交物流信息
- */
- writeLogisticsMsg: function (e) {
- wx.showLoading();
- let that = this
- if(this.loading) return
- if (this.data.expressNo.length == 0) {
- return wx.showToast({
- icon: 'none',
- title: '请填写物流单号',
- })
- } else {
- var pics = '';
- this.data.imgs.forEach(function (item) {
- // pics += item.path + ',';
- pics += item.url + ',';
- });
- if (pics != '') {
- pics = pics.substring(0, pics.length - 1)
- }
- this.loading = true
- var parmas = {
- url:this.data.type == 'edit'?"/refund/delivery/update": "/refund/delivery/save",
- method: this.data.type == 'edit'?"PUT":"POST",
- data: {
- shopId:this.data.shopId,
- deyId: this.data.deliveryList[this.data.expressId].dvyId, //物流公司id
- deyName: this.data.deliveryList[this.data.expressId].dvyName, //物流公司名称
- deyNu: this.data.expressNo, //物流单号
- imgs: pics, //图片凭证
- senderMobile: this.data.mobile, //手机号码
- refundSn: this.data.refundSn, //退款编号名称
- senderRemarks: this.data.senderRemarks, //备注信息
- userId:wx.getStorageSync("loginResult").userId
- },
- callBack: (res) => {
- that.loading = fasle
- wx.hideLoading();
- // 物流填写跳转页面
- wx.navigateTo({
- url: '/pages/DetailsOfRefund/DetailsOfRefund?refundSn=' + this.data.refundSn,
- })
- }
- };
- http.request(parmas);
- }
- },
- /**
- * 上传图片
- */
- getUploadImg: function (e) {
- const idx = e.target.dataset.idx
- console.log(idx);
- var ths = this;
- wx.chooseImage({
- count: 1, // 默认9
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'],
- success: function (res) {
- // 图片的本地临时文件路径列表
- var tempFilePaths = res.tempFilePaths;
- wx.showLoading({
- mask: true
- })
- var params = {
- url: "/p/file/upload",
- filePath: tempFilePaths[0],
- name: 'file',
- callBack: function (res2) {
- wx.hideLoading();
- var img = {};
- img.path = JSON.parse(res2).filePath;
- img.url = JSON.parse(res2).resourcesUrl + JSON.parse(res2).filePath;
- var imgs = ths.data.imgs;
- imgs.push(img);
- ths.setData({
- imgs: imgs
- })
- }
- };
- http.upload(params);
- }
- })
- },
- /**
- * 删除图片
- */
- removeImage: function (e) {
- // const index = e.target.dataset.index
- // const idx = e.target.dataset.idx;
- var idx = e.currentTarget.dataset.idx;
- var imgs = this.data.imgs;
- imgs.splice(idx, 1)
- this.setData({
- imgs: imgs
- });
- console.log('删除图片')
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- refundSn: options.refundSn,
- shopId: options.shopId,
- type:options.type,
- });
- this.loadDeliveryData();
-
- },
- //获取物流公司列表
- loadDeliveryData(){
- wx.showLoading();
- http.request({
- url:"/p/delivery/list",
- method: "get",
- data: {},
- callBack: (res) => {
- wx.hideLoading();
- this.setData({
- deliveryList:res
- });
- console.log(res)
- if(this.data.type == 'edit'){
- this.getByRefundSn()
- }
- }
- });
- console.log(this.data.deliveryList)
- },
- /**
- *
- * 获取退货物流信息
- */
- getByRefundSn(){
- var parmas = {
- url: `/refund/delivery/getByRefundSn/${this.data.refundSn}`,
- method: "GET",
- data: {},
- callBack: (r) => {
- let res = r.data
- let imgs = []
- if(res.imgs){
- imgs = res.imgs.split(',').map(i=>{
- return {url:i,path:i}
- })
- }
- let expressId = 0
- this.data.deliveryList.forEach((i,d)=>{
- if(i.dvyId == res.deyId){
- expressId = d
- }
- })
- this.setData({
- expressId,
- expressNo:res.deyNu,
- imgs,
- senderRemarks:res.senderRemarks,
- })
- }
- };
- http.request(parmas);
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|