| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- var _request = require('../../../../utils/request.js')
- var validator = require('../../../../utils/validator.js')
- var rid
- var fomlds = []
- Page({
- data: {
- order: {},
- company: '',
- express: '',
- company1: '',
- express1: '',
- company2: '',
- express2: '',
- secondshow: false,
- thirdshow: false,
- },
- bindCompany (e) {
- this.setData({
- company: e.detail.value
- })
- },
- bindExpress (e) {
- this.setData({
- express: e.detail.value
- })
- },
- bindCompany1 (e) {
- this.setData({
- company1: e.detail.value
- })
- },
- bindExpress1 (e) {
- this.setData({
- express1: e.detail.value
- })
- },
- bindCompany2 (e) {
- this.setData({
- company2: e.detail.value
- })
- },
- bindExpress2 (e) {
- this.setData({
- express2: e.detail.value
- })
- },
- onLoad: function (options) {
- rid = options.id
- this.getRadish()
- },
- onHide: function (val) {
- this.sendFomlds()
- },
- getRadish () {
- var that = this
- var url = 'v1/merchant/order/detail/' + rid
- var params = {
- }
- var success = function (res) {
- var data = res.data
- that.setData({
- order: data
- })
- if (that.data.order.ex_company_array.length === 1 && that.data.order.ex_order_no_array.length === 1) {
- that.setData({
- company: data.ex_company_array[0],
- express: data.ex_order_no_array[0]
- })
- }
- else if (that.data.order.ex_company_array.length === 2 && that.data.order.ex_order_no_array.length === 2) {
- that.setData({
- secondshow: true,
- company: data.ex_company_array[0],
- express: data.ex_order_no_array[0],
- company1: data.ex_company_array[1],
- express1: data.ex_order_no_array[1]
- })
- }
- else if (that.data.order.ex_company_array.length === 3 && that.data.order.ex_order_no_array.length === 3) {
- that.setData({
- secondshow: true,
- thirdshow: true,
- company: data.ex_company_array[0],
- express: data.ex_order_no_array[0],
- company1: data.ex_company_array[1],
- express1: data.ex_order_no_array[1],
- company2: data.ex_company_array[2],
- express2: data.ex_order_no_array[2],
- })
- }
- else if (getApp().globalData.merchant) {
- that.setData({
- company: getApp().globalData.merchant
- })
- }
- }
- _request.$get(url, params, success)
- },
- setExpressRequest: function () {
- var id = this.data.order.order_id
- var that = this
- var url = 'v1/merchant/order/' + id
- var company = that.data.company
- var express = that.data.express
- if (that.data.secondshow === true) {
- company = that.data.company + '/' + that.data.company1
- express = that.data.express + '/' + that.data.express1
- }
- if (that.data.thirdshow === true) {
- company = that.data.company + '/' + that.data.company1 + '/' + that.data.company2
- express = that.data.express + '/' + that.data.express1 + '/' + that.data.express2
- }
- var params = {
- express_company: company,
- express_order_no: express,
- status: 'dispatch'
- }
- var success = function (res) {
- getApp().globalData.order = true
- getApp().globalData.merchant = that.data.company
- wx.navigateBack()
- }
- _request.$put(url, params, success)
- },
- putExpressRequest: function () {
- var id = this.data.order.order_id
- var that = this
- var url = 'v1/merchant/order/' + id
- var company = that.data.company
- var express = that.data.express
- if (that.data.secondshow === true) {
- company = that.data.company + '/' + that.data.company1
- express = that.data.express + '/' + that.data.express1
- }
- if (that.data.thirdshow === true) {
- company = that.data.company + '/' + that.data.company1 + '/' + that.data.company2
- express = that.data.express + '/' + that.data.express1 + '/' + that.data.express2
- }
- var params = {
- express_company: company,
- express_order_no: express
- }
- var success = function (res) {
- getApp().globalData.order = true
- getApp().globalData.merchant = that.data.company
- wx.navigateBack()
- }
- _request.$put(url, params, success)
- },
- jstext (val) {
- var strshow = val.indexOf('/')
- if (strshow >= 0) {
- return false
- }
- if (strshow < 0) {
- return true
- }
- },
- validate () {
- var msg
- if (!validator.required(this.data.company)) {
- msg = '物流公司不能为空'
- } else if (!validator.required(this.data.express)) {
- msg = '物流号不能为空'
- } else if (!this.jstext(this.data.company) || !this.jstext(this.data.express)) {
- msg = '请不要输入"/"等特殊字符'
- } else if (this.data.secondshow === true && !validator.required(this.data.company1)) {
- msg = '物流公司不能为空'
- } else if (this.data.secondshow === true && !validator.required(this.data.express1)) {
- msg = '物流号不能为空'
- } else if (this.data.secondshow === true && (!this.jstext(this.data.company1) || !this.jstext(this.data.express1))) {
- msg = '请不要输入"/"等特殊字符'
- } else if (this.data.thirdshow === true && !validator.required(this.data.company2)) {
- msg = '物流公司不能为空'
- } else if (this.data.thirdshow === true && !validator.required(this.data.express2)) {
- msg = '物流号不能为空'
- } else if (this.data.secondshow === true && (!this.jstext(this.data.company2) || !this.jstext(this.data.express2))) {
- msg = '请不要输入"/"等特殊字符'
- }
- return { isOk: !msg, msg }
- },
- setExpress: function (e) {
- this.formSubmit(e)
- var { isOk, msg } = this.validate()
- if (isOk) {
- this.setExpressRequest()
- } else {
- wx.showToast({
- title: msg,
- icon: 'none',
- duration: 2000
- })
- }
- },
- putExpress: function (e) {
- this.formSubmit(e)
- var { isOk, msg } = this.validate()
- if (isOk) {
- this.putExpressRequest()
- } else {
- wx.showToast({
- title: msg,
- icon: 'none',
- duration: 2000
- })
- }
- },
- getqcode: function () {
- var that = this
- wx.scanCode({
- success: (res) => {
- that.setData({
- express: res.result
- })
- }
- })
- },
- getqcode1: function () {
- var that = this
- wx.scanCode({
- success: (res) => {
- that.setData({
- express1: res.result
- })
- }
- })
- },
- getqcode2: function () {
- var that = this
- wx.scanCode({
- success: (res) => {
- that.setData({
- express2: res.result
- })
- }
- })
- },
- formSubmit: function (e) {
- fomlds = e.detail.formId
- this.sendFomlds()
- },
- sendFomlds: function () {
- var that = this
- var url = 'v1/formid'
- var params = {
- formIds: fomlds
- }
- var success = function (res) {
- console.log(res)
- }
- _request.$post(url, params, success)
- },
- pluslist () {
- var that = this
- if (that.data.secondshow === false) {
- that.setData({
- secondshow: true
- })
- } else {
- that.setData({
- thirdshow: true
- })
- }
- },
- miuslist () {
- var that = this
- if (that.data.secondshow === true && that.data.thirdshow === false) {
- that.setData({
- secondshow: false,
- express1: '',
- company1: '',
- })
- } else if (that.data.secondshow === true && that.data.thirdshow === true) {
- that.setData({
- thirdshow: false,
- express2: '',
- company2: '',
- })
- }
- }
- })
|