123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- const app = getApp();
- const CONFIG = require('../../config.js')
- const WXAPI = require('apifm-wxapi')
- import wxbarcode from 'wxbarcode'
- Page({
- data:{
- orderId:0,
- goodsList:[]
- },
- onLoad:function(e){
- // e.id = 478785
- var orderId = e.id;
- this.data.orderId = orderId;
- this.setData({
- orderId: orderId
- });
- },
- onShow : function () {
- var that = this;
- WXAPI.orderDetail(wx.getStorageSync('token'), that.data.orderId).then(function (res) {
- if (res.code != 0) {
- wx.showModal({
- title: '错误',
- content: res.msg,
- showCancel: false
- })
- return;
- }
- // 绘制核销码
- if (res.data.orderInfo.hxNumber && res.data.orderInfo.status > 0) {
- wxbarcode.qrcode('qrcode', res.data.orderInfo.hxNumber, 650, 650);
- }
- // 子快递单信息
- if (res.data.orderLogisticsShippers) {
- res.data.orderLogisticsShippers.forEach(ele => {
- if (ele.traces) {
- ele.tracesArray = JSON.parse (ele.traces)
- if (ele.tracesArray && ele.tracesArray.length > 0) {
- ele.tracesLast = ele.tracesArray[ele.tracesArray.length - 1].AcceptStation + '\n' + ele.tracesArray[ele.tracesArray.length - 1].AcceptTime
- }
- }
- })
- }
- that.setData({
- orderDetail: res.data
- });
- })
- },
- wuliuDetailsTap:function(e){
- var orderId = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: "/pages/wuliu/index?id=" + orderId
- })
- },
- confirmBtnTap:function(e){
- let that = this;
- let orderId = this.data.orderId;
- wx.showModal({
- title: '确认您已收到商品?',
- content: '',
- success: function(res) {
- if (res.confirm) {
- WXAPI.orderDelivery(wx.getStorageSync('token'), orderId).then(function (res) {
- if (res.code == 0) {
- that.onShow();
- }
- })
- }
- }
- })
- },
- async submitReputation(e) {
- let that = this;
- let postJsonString = {};
- postJsonString.token = wx.getStorageSync('token');
- postJsonString.orderId = this.data.orderId;
- let reputations = [];
- let i = 0;
- while (e.detail.value["orderGoodsId" + i]) {
- let orderGoodsId = e.detail.value["orderGoodsId" + i];
- let goodReputation = e.detail.value["goodReputation" + i];
- let goodReputationRemark = e.detail.value["goodReputationRemark" + i];
- if (!goodReputation) {
- goodReputation = 0
- } else if(goodReputation <= 1) {
- goodReputation = 0
- } else if(goodReputation <= 4) {
- goodReputation = 1
- } else {
- goodReputation = 2
- }
- let reputations_json = {};
- reputations_json.id = orderGoodsId;
- reputations_json.reputation = goodReputation;
- reputations_json.remark = goodReputationRemark;
- if (this.data.picsList && this.data.picsList[i] && this.data.picsList[i].length > 0) {
- reputations_json.pics = []
- for (let index = 0; index < this.data.picsList[i].length; index++) {
- const pic = this.data.picsList[i][index];
- const res = await WXAPI.uploadFile(wx.getStorageSync('token'), pic.url)
- if (res.code == 0) {
- reputations_json.pics.push(res.data.url)
- }
- }
- }
- reputations.push(reputations_json);
- i++;
- }
- postJsonString.reputations = reputations;
- WXAPI.orderReputation({
- postJsonString: JSON.stringify(postJsonString)
- }).then(function (res) {
- if (res.code == 0) {
- that.onShow();
- }
- })
- },
- afterPicRead(e) {
- const idx = e.currentTarget.dataset.idx
- let picsList = this.data.picsList
- if (!picsList) {
- picsList = []
- for (let index = 0; index < this.data.orderDetail.goods.length; index++) {
- picsList[index] = []
- }
- }
- picsList[idx] = picsList[idx].concat(e.detail.file)
- this.setData({
- picsList
- })
- },
- afterPicDel(e) {
- const idx = e.currentTarget.dataset.idx
- let picsList = this.data.picsList
- picsList[idx].splice(e.detail.index, 1)
- this.setData({
- picsList
- })
- }
- })
|