打印地址
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
</view>
|
||||
<view class="zd_wrapper">
|
||||
<view class="input-wrap">
|
||||
<view class="input-label" style="margin-right: 20upx;">打印机选择</view>
|
||||
<view class="input-label" style="margin-right: 20upx;">客户标签打印</view>
|
||||
<uni-data-select v-model="index" :localdata="options" @change="selectChange"></uni-data-select>
|
||||
</view>
|
||||
</view>
|
||||
@@ -58,7 +58,7 @@
|
||||
},
|
||||
/** 打印机类型下拉框查询 */
|
||||
async _virtualprintType () {
|
||||
let res = await virtualprintType()
|
||||
let res = await virtualprintType(this.addrip)
|
||||
this.options = [...res.data]
|
||||
// if (this.$store.getters.setPrintName !== '') {
|
||||
// this.index = this.$store.getters.setPrintName
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import request from './request.js'
|
||||
import request1 from './request1.js'
|
||||
|
||||
// 版本更新测试
|
||||
// export const getAppInfo = () => {
|
||||
@@ -276,7 +277,7 @@ export const customerPrint = (box_no, ptype) => request({
|
||||
}
|
||||
})
|
||||
// 1.3打印机类型
|
||||
export const virtualprintType = () => request({
|
||||
url:'api/pda/virtual/printType',
|
||||
export const virtualprintType = (url) => request1({
|
||||
url: `${url}/` + 'api/pda/virtual/printType',
|
||||
data: {}
|
||||
})
|
||||
126
utils/request1.js
Normal file
126
utils/request1.js
Normal file
@@ -0,0 +1,126 @@
|
||||
import store from '@/vuex/store'
|
||||
const request1 = (params) => {
|
||||
let _self = this;
|
||||
let url = params.url;
|
||||
let method = params.method || 'POST';
|
||||
let data = params.data || {};
|
||||
// data.token = "default-access_token"
|
||||
// if (!params.token) {
|
||||
// let token = uni.getStorageSync('token');
|
||||
// if (!token) {
|
||||
// uni.navigateTo({
|
||||
// url: '/pages/login/login'
|
||||
// });
|
||||
// } else {
|
||||
// data.token = '179509245-9c91827e0224bdc18d0b118b8be1b5af';
|
||||
// }
|
||||
// }
|
||||
let token = ''
|
||||
if (store.getters.saveToken !== '') {
|
||||
token = store.getters.saveToken
|
||||
}
|
||||
let defaultOpot = {
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Terminal-Type': 'innerH5',
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
}
|
||||
let header = {}
|
||||
method = method.toUpperCase()
|
||||
if (method == 'POST') {
|
||||
header = {
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
'Authorization': token
|
||||
}
|
||||
// data = qs.stringify(data)
|
||||
}
|
||||
const requestUrl = url;
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: requestUrl,
|
||||
method: method,
|
||||
header: Object.assign({}, defaultOpot, header),
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
})
|
||||
.then(res => { // 成功
|
||||
if (res.length === 1) {
|
||||
uni.showModal({
|
||||
content: 'request:fail',
|
||||
showCancel: false
|
||||
})
|
||||
reject('request:fail')
|
||||
} else if (res[1] && res[1].statusCode === 400) {
|
||||
uni.showModal({
|
||||
content: res[1].data.message,
|
||||
showCancel: false
|
||||
})
|
||||
reject(res[1].data.message)
|
||||
} else if (res[1] && res[1].statusCode === 401) {
|
||||
uni.showModal({
|
||||
content: res[1].data.message,
|
||||
showCancel: false
|
||||
})
|
||||
store.dispatch('delUserInfo')
|
||||
uni.redirectTo({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
} else if (res[1] && res[1].statusCode === 200) {
|
||||
let {
|
||||
data: dataType
|
||||
} = res[1]
|
||||
resolve(dataType)
|
||||
// switch (dataType.code * 1) { // 拦截返回参数
|
||||
// case 0:
|
||||
// resolve(dataType)
|
||||
// break;
|
||||
// case 1003:
|
||||
// uni.showModal({
|
||||
// title: '登录已过期',
|
||||
// content: '很抱歉,登录已过期,请重新登录',
|
||||
// confirmText: '重新登录',
|
||||
// success: function(res) {
|
||||
// if (res.confirm) {
|
||||
// uni.navigateTo({
|
||||
// // 切记这儿需要哈pages.json保持一致;不能有.vue后缀
|
||||
// url: '/pages/login/login'
|
||||
// });
|
||||
// } else if (res.cancel) {
|
||||
// console.log('用户点击取消');
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// break;
|
||||
// case -1:
|
||||
// uni.showModal({
|
||||
// title: '请求数据失败',
|
||||
// content: '获取数据失败!',
|
||||
// confirmText: '确定',
|
||||
// showCancel: false,
|
||||
// success: function(res) {
|
||||
// if (res.confirm) {} else if (res.cancel) {
|
||||
// console.log('用户点击取消');
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// break
|
||||
// }
|
||||
}else {
|
||||
uni.showModal({
|
||||
content: res[1].data.message,
|
||||
showCancel: false
|
||||
})
|
||||
reject(res[1].data.message)
|
||||
}
|
||||
})
|
||||
.catch(err => { // 错误
|
||||
reject(err)
|
||||
})
|
||||
.finally(() => {
|
||||
uni.hideLoading();
|
||||
})
|
||||
})
|
||||
}
|
||||
export default request1
|
||||
Reference in New Issue
Block a user