Commit 73ebf580 by 施宇

1111

parent 0e478a9a
{"ignoreds":["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"],"folderInfo":{"./":{"mtimeMs":1587696289558.8054,"children":["app.js","app.json","app.wxss","project.config.json","sitemap.json"]},"pages/":{"mtimeMs":1587696395511.2776,"children":[]},"res/":{"mtimeMs":1587468629426.3813,"children":[]},"res/css/":{"mtimeMs":1587468648224.7944,"children":["res/css/base.wxss"]},"res/img/":{"mtimeMs":1587693859514.1584,"children":["res/img/arrow-left.png","res/img/arrow-right.png","res/img/ck-icon-a.png","res/img/ck-icon.png","res/img/close-icon.png","res/img/kc-icon-a.png","res/img/kc-icon.png","res/img/login-img.png","res/img/login-text.png","res/img/nav-arrow-down.png","res/img/question-icon.png","res/img/search-icon.png","res/img/sh-icon-a.png","res/img/sh-icon.png","res/img/sj-icon-a.png","res/img/sj-icon.png","res/img/sz-icon-a.png","res/img/sz-icon.png","res/img/warn-icon.png"]},"utils/":{"mtimeMs":1587468231280.8867,"children":["utils/util.js"]},".git/":{"mtimeMs":1587696329501.2468,"children":[]},".wechatide/":{"mtimeMs":1587519550088.0625,"children":[".wechatide/fileCache.cfg"]},"pages/home/":{"mtimeMs":1587536014892.4702,"children":["pages/home/home.js","pages/home/home.json","pages/home/home.wxml","pages/home/home.wxss"]},"pages/login/":{"mtimeMs":1587535974795.0686,"children":["pages/login/login.js","pages/login/login.json","pages/login/login.wxml","pages/login/login.wxss"]},"components/":{"mtimeMs":1587538211879.0247,"children":[]},"components/navC/":{"mtimeMs":1587538221287.4016,"children":["components/navC/navC.js","components/navC/navC.json","components/navC/navC.wxml","components/navC/navC.wxss"]},"pages/receivinggoods/":{"mtimeMs":1587538742321.587,"children":["pages/receivinggoods/receivinggoods.js","pages/receivinggoods/receivinggoods.json","pages/receivinggoods/receivinggoods.wxml","pages/receivinggoods/receivinggoods.wxss"]},"pages/upperShelf/":{"mtimeMs":1587622056930.153,"children":["pages/upperShelf/upperShelf.js","pages/upperShelf/upperShelf.json","pages/upperShelf/upperShelf.wxml","pages/upperShelf/upperShelf.wxss"]},"pages/outbound/":{"mtimeMs":1587626008346.8442,"children":["pages/outbound/outbound.js","pages/outbound/outbound.json","pages/outbound/outbound.wxml","pages/outbound/outbound.wxss"]},"pages/scanDelivery/":{"mtimeMs":1587627596586.3196,"children":["pages/scanDelivery/scanDelivery.js","pages/scanDelivery/scanDelivery.json","pages/scanDelivery/scanDelivery.wxml","pages/scanDelivery/scanDelivery.wxss"]},"pages/picking/":{"mtimeMs":1587631234329.3645,"children":["pages/picking/picking.js","pages/picking/picking.json","pages/picking/picking.wxml","pages/picking/picking.wxss"]},"pages/cardBoard/":{"mtimeMs":1587632724321.1174,"children":["pages/cardBoard/cardBoard.js","pages/cardBoard/cardBoard.json","pages/cardBoard/cardBoard.wxml","pages/cardBoard/cardBoard.wxss"]},"pages/changeWarehouse/":{"mtimeMs":1587635396534.957,"children":["pages/changeWarehouse/changeWarehouse.js","pages/changeWarehouse/changeWarehouse.json","pages/changeWarehouse/changeWarehouse.wxml","pages/changeWarehouse/changeWarehouse.wxss"]},"pages/systemSettings/":{"mtimeMs":1587637181028.4365,"children":["pages/systemSettings/systemSettings.js","pages/systemSettings/systemSettings.json","pages/systemSettings/systemSettings.wxml","pages/systemSettings/systemSettings.wxss"]},"pages/printer/":{"mtimeMs":1587637593187.5686,"children":["pages/printer/printer.js","pages/printer/printer.json","pages/printer/printer.wxml","pages/printer/printer.wxss"]},"pages/inventoryQuery/":{"mtimeMs":1587639536186.8396,"children":["pages/inventoryQuery/inventoryQuery.js","pages/inventoryQuery/inventoryQuery.json","pages/inventoryQuery/inventoryQuery.wxml","pages/inventoryQuery/inventoryQuery.wxss"]},"miniprogram_npm/":{"mtimeMs":1587696277856.0212,"children":[]},"miniprogram_npm/text-encoding/":{"mtimeMs":1587696277883.9749,"children":["miniprogram_npm/text-encoding/index.js","miniprogram_npm/text-encoding/index.js.map"]},"printer/":{"mtimeMs":1587696289579.8447,"children":["printer/commands.js","printer/printerjobs.js","printer/printerutil.js"]},"pages/index/":{"mtimeMs":1587696395532.241,"children":["pages/index/index.js","pages/index/index.json","pages/index/index.wxml","pages/index/index.wxss"]}},"cacheVersion":1}
\ No newline at end of file
{"ignoreds":["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"],"folderInfo":{"./":{"mtimeMs":1588039958728.2603,"children":["app.js","app.json","app.wxss","project.config.json","sitemap.json"]},"pages/":{"mtimeMs":1588045516900.1838,"children":[]},"res/":{"mtimeMs":1587987929535.54,"children":[]},"res/css/":{"mtimeMs":1587468648224.7944,"children":["res/css/base.wxss"]},"res/img/":{"mtimeMs":1587693859514.1584,"children":["res/img/arrow-left.png","res/img/arrow-right.png","res/img/ck-icon-a.png","res/img/ck-icon.png","res/img/close-icon.png","res/img/kc-icon-a.png","res/img/kc-icon.png","res/img/login-img.png","res/img/login-text.png","res/img/nav-arrow-down.png","res/img/question-icon.png","res/img/search-icon.png","res/img/sh-icon-a.png","res/img/sh-icon.png","res/img/sj-icon-a.png","res/img/sj-icon.png","res/img/sz-icon-a.png","res/img/sz-icon.png","res/img/warn-icon.png"]},"utils/":{"mtimeMs":1588040145835.5574,"children":["utils/api.js","utils/axios.js","utils/md5.js","utils/util.js"]},".git/":{"mtimeMs":1588045754162.6826,"children":[]},".wechatide/":{"mtimeMs":1587519550088.0625,"children":[".wechatide/fileCache.cfg"]},"pages/home/":{"mtimeMs":1587536014892.4702,"children":["pages/home/home.js","pages/home/home.json","pages/home/home.wxml","pages/home/home.wxss"]},"pages/login/":{"mtimeMs":1587535974795.0686,"children":["pages/login/login.js","pages/login/login.json","pages/login/login.wxml","pages/login/login.wxss"]},"components/":{"mtimeMs":1587538211879.0247,"children":[]},"components/navC/":{"mtimeMs":1587538221287.4016,"children":["components/navC/navC.js","components/navC/navC.json","components/navC/navC.wxml","components/navC/navC.wxss"]},"pages/receivinggoods/":{"mtimeMs":1587538742321.587,"children":["pages/receivinggoods/receivinggoods.js","pages/receivinggoods/receivinggoods.json","pages/receivinggoods/receivinggoods.wxml","pages/receivinggoods/receivinggoods.wxss"]},"pages/upperShelf/":{"mtimeMs":1587622056930.153,"children":["pages/upperShelf/upperShelf.js","pages/upperShelf/upperShelf.json","pages/upperShelf/upperShelf.wxml","pages/upperShelf/upperShelf.wxss"]},"pages/outbound/":{"mtimeMs":1587626008346.8442,"children":["pages/outbound/outbound.js","pages/outbound/outbound.json","pages/outbound/outbound.wxml","pages/outbound/outbound.wxss"]},"pages/scanDelivery/":{"mtimeMs":1587627596586.3196,"children":["pages/scanDelivery/scanDelivery.js","pages/scanDelivery/scanDelivery.json","pages/scanDelivery/scanDelivery.wxml","pages/scanDelivery/scanDelivery.wxss"]},"pages/picking/":{"mtimeMs":1587631234329.3645,"children":["pages/picking/picking.js","pages/picking/picking.json","pages/picking/picking.wxml","pages/picking/picking.wxss"]},"pages/cardBoard/":{"mtimeMs":1587632724321.1174,"children":["pages/cardBoard/cardBoard.js","pages/cardBoard/cardBoard.json","pages/cardBoard/cardBoard.wxml","pages/cardBoard/cardBoard.wxss"]},"pages/changeWarehouse/":{"mtimeMs":1587635396534.957,"children":["pages/changeWarehouse/changeWarehouse.js","pages/changeWarehouse/changeWarehouse.json","pages/changeWarehouse/changeWarehouse.wxml","pages/changeWarehouse/changeWarehouse.wxss"]},"pages/systemSettings/":{"mtimeMs":1587637181028.4365,"children":["pages/systemSettings/systemSettings.js","pages/systemSettings/systemSettings.json","pages/systemSettings/systemSettings.wxml","pages/systemSettings/systemSettings.wxss"]},"pages/printer/":{"mtimeMs":1587637593187.5686,"children":["pages/printer/printer.js","pages/printer/printer.json","pages/printer/printer.wxml","pages/printer/printer.wxss"]},"pages/inventoryQuery/":{"mtimeMs":1587639536186.8396,"children":["pages/inventoryQuery/inventoryQuery.js","pages/inventoryQuery/inventoryQuery.json","pages/inventoryQuery/inventoryQuery.wxml","pages/inventoryQuery/inventoryQuery.wxss"]},"pages/startPage/":{"mtimeMs":1588045543126.067,"children":["pages/startPage/startPage.js","pages/startPage/startPage.json","pages/startPage/startPage.wxml","pages/startPage/startPage.wxss"]}},"cacheVersion":1}
\ No newline at end of file
//app.js
App({
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
},
globalData: {
userInfo: null
userInfo: null,
}
})
\ No newline at end of file
{
"pages": [
"pages/index/index",
"pages/inventoryQuery/inventoryQuery",
"pages/receivinggoods/receivinggoods",
"pages/startPage/startPage",
"pages/home/home",
"pages/login/login",
"pages/inventoryQuery/inventoryQuery",
"pages/printer/printer",
"pages/systemSettings/systemSettings",
"pages/changeWarehouse/changeWarehouse",
......@@ -10,9 +13,7 @@
"pages/picking/picking",
"pages/scanDelivery/scanDelivery",
"pages/outbound/outbound",
"pages/upperShelf/upperShelf",
"pages/home/home",
"pages/login/login"
"pages/upperShelf/upperShelf"
],
"window": {
"backgroundTextStyle": "light",
......
// components/navC/navC.js
import {
getData
} from '../../utils/axios.js';
import {
apis
} from '../../utils/api.js';
Component({
/**
* 组件的属性列表
*/
properties: {
title: { // 页面标题
type: String,
value: '供应链仓储管理系统'
},
},
/**
* 组件的初始数据
*/
data: {
userInfo:wx.getStorageSync('userInfo'),
drop1:false,
drop2:false,
index:0,
},
attached: function() {
// 在组件实例进入页面节点树时执行
let me = this;
me.judgePagePath()
if(me.data.userInfo){
me.triggerEvent('getInfo', me.data.userInfo.engName)
return
};
this.getUserData();
},
/**
* 组件的方法列表
*/
methods: {
judgePagePath:function(){
let pages = getCurrentPages();
let currPage = null;
let route = null;
let index = 0;
// console.log(pages) 的到一个数组
if (pages.length) {
// 获取当前页面的前以页面的对象
currPage = pages[pages.length - 1];
// 获取当前页面的前一页面的路由
route = currPage.route;
}
switch(route){
case 'pages/receivinggoods/receivinggoods':
index = 1;
break;
case 'pages/upperShelf/upperShelf':
index = 2;
break;
case 'pages/outbound/outbound':
index = 3;
break;
case 'pages/inventoryQuery/inventoryQuery':
index = 4;
break;
case 'pages/systemSettings/systemSettings':
index = 5;
break;
default:
index = 0;
break
}
this.setData({
index:index
})
},
pageFun:function(){
this.setData({
drop1:false,
drop2:false
})
},
test:function(){
console.log(111)
},
drop1Fun:function(){
this.setData({
drop1:true,
drop2:false
})
},
drop2Fun:function(){
this.setData({
drop1:false,
drop2:true
})
},
drop1Operation:function(){
this.setData({
drop1:false,
drop2:false
});
console.log('退出')
},
drop2Operation:function(e){
let url = e.currentTarget.dataset.url;
this.setData({
drop1:false,
drop2:false
});
wx.navigateTo({
url: url
})
},
getUserData:function(){
let me = this;
getData(apis.me, 'post', {}, function(res) {
if (res.errcode === 0) {
let data = res.data;
me.setData({
userInfo:res.data
});
wx.setStorage({
key: "userInfo",
data: data
});
wx.setStorage({
key: "userId",
data: data.userId
});
me.triggerEvent('getInfo', data.engName)
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, false,true)
}
}
})
<!--components/navC/navC.wxml-->
<view class="page-wrapper" bindtap="pageFun">
<view class="nav-top Bflex aic">
<view class="nav-left Bflex">
<view class="user-name Bflex aic">
<text class="ellipsis">lqj@ichunt.com</text>
<view class="user-name Bflex aic" catchtap="drop1Fun">
<text class="ellipsis">{{userInfo.email}}</text>
<image class="arrow-down" src="../../res/img/nav-arrow-down.png"></image>
<view class="drop-down1 borderBox">
<view class="item">切换</view>
<view class="item">退出</view>
<view class="drop-down1 borderBox " wx:if="{{drop1}}">
<view class="item" catchtap="drop1Operation">切换</view>
<view class="item" catchtap="drop1Operation">退出</view>
</view>
</view>
<view class="zq Bflex aic">
<view class="zq Bflex aic" catchtap="drop2Fun">
<text>专区</text>
<image class="arrow-down" src="../../res/img/nav-arrow-down.png"></image>
<view class="drop-down2 borderBox">
<view class="item Bflex aic">
<view class="drop-down2 borderBox" wx:if="{{drop2}}">
<view class="item Bflex aic {{index == 1?'active':'' }}" catchtap="drop2Operation" data-url="/pages/receivinggoods/receivinggoods">
<image src="../../res/img/sh-icon.png" class="icon icon1"></image>
<image src="../../res/img/sh-icon-a.png" class="icon icon2"></image>
<text>收货管理</text>
</view>
<view class="item Bflex aic">
<view class="item Bflex aic {{index == 2?'active':'' }}" catchtap="drop2Operation" data-url="/pages/upperShelf/upperShelf">
<image src="../../res/img/sj-icon.png" class="icon icon1"></image>
<image src="../../res/img/sj-icon-a.png" class="icon icon2"></image>
<text>上架</text>
</view>
<view class="item Bflex aic">
<view class="item Bflex aic {{index == 3?'active':'' }}" catchtap="drop2Operation" data-url="/pages/outbound/outbound">
<image src="../../res/img/ck-icon.png" class="icon icon1"></image>
<image src="../../res/img/ck-icon-a.png" class="icon icon2"></image>
<text>出库管理</text>
</view>
<view class="item Bflex aic">
<view class="item Bflex aic {{index == 4?'active':'' }}" catchtap="drop2Operation" data-url="/pages/inventoryQuery/inventoryQuery">
<image src="../../res/img/kc-icon.png" class="icon icon1"></image>
<image src="../../res/img/kc-icon-a.png" class="icon icon2"></image>
<text>库存查询</text>
</view>
<view class="item Bflex aic">
<view class="item Bflex aic {{index == 5?'active':'' }}" catchtap="drop2Operation" data-url="/pages/systemSettings/systemSettings">
<image src="../../res/img/sz-icon.png" class="icon icon1"></image>
<image src="../../res/img/sz-icon-a.png" class="icon icon2"></image>
<text>系统设定</text>
......@@ -42,6 +43,8 @@
</view>
</view>
</view>
<view class="html-title ellipsis">供应链仓储管理系统</view>
<view class="nav-right">当前仓库:A仓</view>
<view class="html-title ellipsis">{{title}}</view>
<view class="nav-right">当前仓库:{{userInfo.engName}}</view>
</view>
<slot></slot>
</view>
\ No newline at end of file
/* components/navC/navC.wxss */
@import '/res/css/base.wxss';
.page-wrapper{
height: 100%;
}
.nav-top {
height: 33px;
background: #fff;
......@@ -52,7 +54,6 @@
text-align: center;
right: -23px;
top: 20px;
display: none;
}
.drop-down1 .item {
......@@ -77,7 +78,6 @@
padding-left: 17px;
top:20px;
right:-60px;
display: none;
}
.drop-down2 .item {
......@@ -92,19 +92,9 @@
display: none;
}
.drop-down2 .item.active,
.drop-down2 .item:hover {
.drop-down2 .item.active {
color: #1969F9
}
.drop-down2 .item:hover .icon1 {
display: none;
}
.drop-down2 .item:hover .icon2 {
display: block;
}
.drop-down2 .item.active .icon1 {
display: none;
}
......
This diff could not be displayed because it is too large.
......@@ -5,7 +5,7 @@ Page({
* 页面的初始数据
*/
data: {
warehouseName:""
},
/**
......@@ -62,5 +62,10 @@ Page({
*/
onShareAppMessage: function () {
},
onGetInfo:function(e){
this.setData({
warehouseName:e.detail
})
}
})
\ No newline at end of file
<nav-c bind:getInfo="onGetInfo">
<view class="home-view width-854px nav-view borderBox">
<nav-c></nav-c>
<view class="items clr borderBox">
<view class="item fl noMarginLeft borderBox FFD2AC Bflex jcc aic">
<navigator class="item fl noMarginLeft borderBox FFD2AC Bflex jcc aic" url="/pages/receivinggoods/receivinggoods">
<text class="h3">收货管理</text>
<text class="p">Receiving goods</text>
</view>
<view class="item fl borderBox D3F3A0 Bflex jcc aic">
</navigator>
<navigator class="item fl borderBox D3F3A0 Bflex jcc aic" url="/pages/upperShelf/upperShelf">
<text class="h3">上架</text>
<text class="p">Upper shelf</text>
</view>
<view class="item fl borderBox D2F0FB Bflex jcc aic">
</navigator>
<navigator class="item fl borderBox D2F0FB Bflex jcc aic" url="/pages/outbound/outbound">
<text class="h3">出库管理</text>
<text class="p">Out of stock</text>
</view>
<view class="item fl noMarginLeft borderBox D3F0E6 Bflex jcc aic">
</navigator>
<navigator class="item fl noMarginLeft borderBox D3F0E6 Bflex jcc aic" url="/pages/inventoryQuery/inventoryQuery">
<text class="h3">库存查询</text>
<text class="p">Stock inquiry</text>
</view>
<view class="item fl borderBox DADDF5 Bflex jcc aic">
</navigator>
<navigator class="item fl borderBox DADDF5 Bflex jcc aic" url="/pages/systemSettings/systemSettings">
<text class="h3">系统设定</text>
<text class="p">Set up</text>
</view>
<view class="item fl borderBox F8F8F8 Bflex jcc aic">
<text class="h3">A仓</text>
</navigator>
<navigator class="item fl borderBox F8F8F8 Bflex jcc aic" url="/pages/changeWarehouse/changeWarehouse">
<text class="h3">{{warehouseName}}仓</text>
<text class="p">当前仓库</text>
</view>
</navigator>
</view>
</view>
\ No newline at end of file
</view>
</nav-c>
\ No newline at end of file
<wxs module="utils">
module.exports.max = function(n1, n2) {
return Math.max(n1, n2)
}
module.exports.len = function(arr) {
arr = arr || [];
return arr.length;
}
</wxs>
<view class="container">
<view class="page-section">
<view class="devices-summary">已发现 {{devices.length}} 个外围设备:</view>
<scroll-view class="device-list" scroll-y scroll-with-animation>
<view wx:for="{{devices}}" wx:key="index" data-device-id="{{item.deviceId}}" data-name="{{item.name || item.localName}}" bindtap="createBLEConnection" class="device-item" hover-class="device-item-hover">
<view style="font-size: 16px; color: #333;">{{item.name}}</view>
<view style="font-size: 10px">信号强度: {{item.RSSI}}dBm ({{utils.max(0, item.RSSI + 100)}}%)</view>
<view style="font-size: 10px">UUID: {{item.deviceId}}</view>
<view style="font-size: 10px">Service数量: {{utils.len(item.advertisServiceUUIDs)}}</view>
</view>
</scroll-view>
<view class="btn-area">
<button type="primary" bindtap="openBluetoothAdapter">开始扫描</button>
<button bindtap="stopBluetoothDevicesDiscovery" style="margin-top: 10px;">停止扫描</button>
</view>
</view>
<view class="page-section connected-area" wx:if="{{lastDevice}}">
<text style="font-size: 30rpx">最近连接的设备</text>
<view>{{lastDevice}}</view>
<view class="btn-area">
<button type="primary" bindtap="createBLEConnectionWithDeviceId">直接连接</button>
</view>
</view>
<view class="page-section connected-area" wx:if="{{connected}}">
<view class="connected-info">
<text style="font-size: 30rpx">已连接到 {{name}}</text>
<view wx:for="{{chs}}" wx:key="index">
<view>特性UUID: {{item.uuid}}</view>
<view>特性值: {{item.value}}</view>
</view>
</view>
<view class="btn-area">
<button wx:if="{{canWrite}}" type="primary" bindtap="writeBLECharacteristicValue" style="margin-bottom: 10px;">
写数据
</button>
<button bindtap="closeBLEConnection">断开连接</button>
</view>
</view>
</view>
\ No newline at end of file
.page-section {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
box-sizing: border-box;
border-bottom: 2rpx solid #EEE;
padding: 30rpx 0;
}
.devices-summary {
padding: 10rpx;
font-size: 30rpx;
}
.device-list {
height: 300rpx;
}
.device-item {
border-bottom: 1rpx solid #EEE;
padding: 10rpx;
color: #666;
}
.device-item-hover {
background-color: rgba(0, 0, 0, .1);
}
.btn-area {
box-sizing: border-box;
width: 100%;
padding: 0 30rpx;
margin: 30rpx 0;
}
.connected-area {
font-size: 22rpx;
}
.connected-info {}
.input-area {
background: #fff;
margin-top: 10rpx;
width: 100%;
}
.input {
font-size: 28rpx;
height: 2.58823529em;
min-height: 2.58823529em;
line-height: 2.58823529em;
padding: 10rpx;
}
\ No newline at end of file
//index.js
//获取应用实例
const app = getApp()
import {
getData
} from '../../utils/axios.js';
import {
apis
} from '../../utils/api.js';
import { hexMD5 } from "../../utils/md5.js"
Page({
data: {
user:"",
password:"",
errorText:""
},
onLoad: function () {
wx.getSystemInfo({
success (res) {
console.log(res)
}
})
},
userInput:function(e){
let {value} = e.detail;
this.setData({
user:value
})
},
passwordInput:function(e){
let {value} = e.detail;
this.setData({
password:value
})
},
login:function(){
let user = this.data.user;
let password = this.data.password;
let errorText = ""
if(!user){
errorText = "用户名错误"
}else if(!password){
errorText = "密码错误"
}else{
this.loginFun()
}
this.setData({
errorText:errorText
})
},
loginFun:function(){
let me = this;
getData(apis.login, 'post', {
name:me.data.user,
passwd:hexMD5(me.data.password)
}, function(res) {
if (res.errcode === 0) {
wx.setStorage({
key: "access_token",
data: res.access_token
});
wx.redirectTo({
url: '/pages/home/home'
});
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, true)
}
})
......@@ -5,11 +5,11 @@
<image class="login-text" src="../../res/img/login-text.png"></image>
<view class="login-form">
<view class="lable">用户名</view>
<view><input class="input" placeholder-class="ph" placeholder="请输入用户名"></input></view>
<view><input class="input" placeholder-class="ph" placeholder="请输入用户名" bindinput="userInput" value="{{user}}"></input></view>
<view class="lable password-lable">密码</view>
<view><input class="input" placeholder-class="ph" placeholder="请输入密码"></input></view>
<view class="error-text">* 登录密码错误</view>
<view><input class="input" placeholder-class="ph" placeholder="请输入密码" password="{{true}}" bindinput="passwordInput" value="{{password}}"></input></view>
<view class="error-text" wx:if="{{errorText}}">* {{errorText}}</view>
</view>
<view class="btn blue-btn login-btn">登录</view>
<view class="btn blue-btn login-btn" bindtap="login">登录</view>
</view>
</view>
// pages/receivinggoods/receivinggoods.js
import {
getData
} from '../../utils/axios.js';
import {
apis
} from '../../utils/api.js';
Page({
/**
* 页面的初始数据
*/
data: {
chooseOrder:null,//单个入仓号的数据
maskList:[],//弹窗的数据填充(选择入仓号)
isShowMask:false,//是否展示弹窗(入仓表格)
index:-1,//初始选中位置(入仓表格)
isShowMask1:false,//是否展示弹窗(城市弹窗)
errorText:false,//是否显示错误信息(入仓号不存在)
list1:[],//头部的表格数据
formData:{
wldy:2,//物料打印 1为允许 2为禁止
jlpc:2,//记录批次/DC 1为允许 2为禁止
tm:"",//条码
xh:"",//型号
sl:"",//数量
pdx:"",//盘/袋/箱
pc:"",//批次
pp:"",//品牌
cd:"",//产地
dc:""//dc
},
searchByXh:"",//通过输入型号去获取单个入仓数据
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getMaskList()
},
/**
......@@ -62,5 +87,184 @@ Page({
*/
onShareAppMessage: function () {
},
addScan:function(e){
//加入扫描
let data = e.currentTarget.dataset;
this.setData({
chooseOrder:data.info,
});
this.getList1()
},
closeMask:function(){
//关闭入仓数据选择弹窗
if(!this.data.chooseOrder){
this.setData({
errorText:true,
isShowMask:false
})
}
},
changeIndex:function(e){
//改变弹窗的选择数据状态(入库数据弹窗)
let data = e.currentTarget.dataset;
this.setData({
index:data.index,
chooseOrder:data.info,
isShowMask:false,
});
this.getList1()
},
getMaskList:function(){
//获取弹窗数据(入仓)
let me = this;
getData(apis.get_in_store_warehousing_sn, 'post', {"warehousing_sn":"69025143"}, function(res) {
if (res.errcode === 0) {
let data = res.data;
let errorText = false;
if(data.data){
let len = data.data.length;
if(!len){
errorText = true
}else{
errorText = false;
if(data.data.length == 1){
me.setData({
chooseOrder:data.data[0]
});
me.getList1()
}else{
me.setData({
maskList:data.data,
isShowMask:true
})
}
}
}else{
errorText = true
}
me.setData({
errorText:errorText
})
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, false,true)
},
getList1:function(){
//获取头部的第一个列表数据
let me = this;
let chooseOrder = me.data.chooseOrder;
getData(apis.in_store_detail_list, 'post', {"in_store_id":chooseOrder.in_store_id,"page":"1","limit":"10"}, function(res) {
if (res.errcode === 0) {
let data = res.data;
let dataArr = [];
if(data.data){
let len = data.data.length;
if(!len){
dataArr = []
}else{
dataArr = data.data
}
}else{
dataArr = []
};
me.setData({
list1:dataArr
})
console.log(dataArr)
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, true,true)
},
formtmInput:function(e){
//监听条码的input
let {value} = e.detail ;
let formData = this.data.formData;
if(formData.xh){
//型号已经扫描了
if(formData.sl){
//数量已经扫描了
}else{
this.scanNumber(value)
}
}else{
this.scanXh(value)
}
},
scanNumber:function(val){
//通过条形码扫描数量
if((typeof(Number(val))).toLowerCase()!=="number"){
wx.showToast({
title:'数量格式错误',
icon: 'none',
duration: 2000
});
}else{
if(Number(val)>Number(this.data.searchByXh.number)){
wx.showToast({
title:'实际收货量超出计划收货量',
icon: 'none',
duration: 2000
});
}else{
this.setData({
["formData.sl"]:val
})
}
}
},
scanXh:function(val){
//通过条形码查询型号
let me = this;
let chooseOrder = me.data.chooseOrder;
getData(apis.in_store_detail_list, 'post', {"in_store_id":chooseOrder.in_store_id,"goods_name":val}, function(res) {
if (res.errcode === 0) {
let data = res.data;
let dataObj = "";
if(data.data){
let len = data.data.length;
if(!len){
dataObj = ""
}else{
dataObj = data.data[0];
me.setData({
["formData.xh"]:dataObj.goods_name,
["formData.pp"]:dataObj.brand_name,
["formData.cd"]:dataObj.country_name,
["formData.tm"]:dataObj.val,
["formData.wldy"]:dataObj.is_print,
["formData.jlpc"]:dataObj.is_record_batch_dc,
searchByXh:dataObj
})
}
}else{
dataObj = ""
};
me.setData({
searchByXh:dataObj
})
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, true,true)
}
})
\ No newline at end of file
......@@ -365,9 +365,6 @@ page {
/**选择城市的ui弹窗**/
.mask{
display: none;
}
.city-content {
font-size: 14px;
......@@ -486,4 +483,13 @@ page {
.puchase-table .box-icon {
margin: 0;
}
.no-data-td {
text-align: center;
flex:1;
padding: 6px 0;
color:#666;
}
.input.disabled{
background-color:#F8F8F8 ;
}
\ No newline at end of file
// pages/startPage/startPage.js
Page({
/**
* 页面的初始数据
*/
data: {
token: wx.getStorageSync('access_token')
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (this.data.token) {
//登入
// wx.reLaunch({
// url: '/pages/login/login'
// });
wx.navigateTo({
url: '/pages/home/home'
});
}else{
//未登入
// wx.reLaunch({
// url: '/pages/login/login'
// });
wx.navigateTo({
url: '/pages/login/login'
});
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"navigationBarTitleText": "蓝牙打印"
}
\ No newline at end of file
{
"usingComponents": {},
"pageOrientation":"landscape",
"navigationBarBackgroundColor":"#fff"
}
/* pages/startPage/startPage.wxss */
\ No newline at end of file
/**
* 修改自https://github.com/song940/node-escpos/blob/master/commands.js
* ESC/POS _ (Constants)
*/
var _ = {
LF: [0x0a],
FS: [0x1c],
FF: [0x0c],
GS: [0x1d],
DLE: [0x10],
EOT: [0x04],
NUL: [0x00],
ESC: [0x1b],
EOL: '\n',
};
/**
* [FEED_CONTROL_SEQUENCES Feed control sequences]
* @type {Object}
*/
_.FEED_CONTROL_SEQUENCES = {
CTL_LF: [0x0a], // Print and line feed
CTL_GLF: [0x4a, 0x00], // Print and feed paper (without spaces between lines)
CTL_FF: [0x0c], // Form feed
CTL_CR: [0x0d], // Carriage return
CTL_HT: [0x09], // Horizontal tab
CTL_VT: [0x0b], // Vertical tab
};
_.CHARACTER_SPACING = {
CS_DEFAULT: [0x1b, 0x20, 0x00],
CS_SET: [0x1b, 0x20]
};
_.LINE_SPACING = {
LS_DEFAULT: [0x1b, 0x32],
LS_SET: [0x1b, 0x33]
};
/**
* [HARDWARE Printer hardware]
* @type {Object}
*/
_.HARDWARE = {
HW_INIT: [0x1b, 0x40], // Clear data in buffer and reset modes
HW_SELECT: [0x1b, 0x3d, 0x01], // Printer select
HW_RESET: [0x1b, 0x3f, 0x0a, 0x00], // Reset printer hardware
};
/**
* [CASH_DRAWER Cash Drawer]
* @type {Object}
*/
_.CASH_DRAWER = {
CD_KICK_2: [0x1b, 0x70, 0x00], // Sends a pulse to pin 2 []
CD_KICK_5: [0x1b, 0x70, 0x01], // Sends a pulse to pin 5 []
};
/**
* [MARGINS Margins sizes]
* @type {Object}
*/
_.MARGINS = {
BOTTOM: [0x1b, 0x4f], // Fix bottom size
LEFT: [0x1b, 0x6c], // Fix left size
RIGHT: [0x1b, 0x51], // Fix right size
};
/**
* [PAPER Paper]
* @type {Object}
*/
_.PAPER = {
PAPER_FULL_CUT: [0x1d, 0x56, 0x00], // Full cut paper
PAPER_PART_CUT: [0x1d, 0x56, 0x01], // Partial cut paper
PAPER_CUT_A: [0x1d, 0x56, 0x41], // Partial cut paper
PAPER_CUT_B: [0x1d, 0x56, 0x42], // Partial cut paper
};
/**
* [TEXT_FORMAT Text format]
* @type {Object}
*/
_.TEXT_FORMAT = {
TXT_NORMAL: [0x1b, 0x21, 0x00], // Normal text
TXT_2HEIGHT: [0x1b, 0x21, 0x10], // Double height text
TXT_2WIDTH: [0x1b, 0x21, 0x20], // Double width text
TXT_4SQUARE: [0x1b, 0x21, 0x30], // Double width & height text
TXT_UNDERL_OFF: [0x1b, 0x2d, 0x00], // Underline font OFF
TXT_UNDERL_ON: [0x1b, 0x2d, 0x01], // Underline font 1-dot ON
TXT_UNDERL2_ON: [0x1b, 0x2d, 0x02], // Underline font 2-dot ON
TXT_BOLD_OFF: [0x1b, 0x45, 0x00], // Bold font OFF
TXT_BOLD_ON: [0x1b, 0x45, 0x01], // Bold font ON
TXT_ITALIC_OFF: [0x1b, 0x35], // Italic font ON
TXT_ITALIC_ON: [0x1b, 0x34], // Italic font ON
TXT_FONT_A: [0x1b, 0x4d, 0x00], // Font type A
TXT_FONT_B: [0x1b, 0x4d, 0x01], // Font type B
TXT_FONT_C: [0x1b, 0x4d, 0x02], // Font type C
TXT_ALIGN_LT: [0x1b, 0x61, 0x00], // Left justification
TXT_ALIGN_CT: [0x1b, 0x61, 0x01], // Centering
TXT_ALIGN_RT: [0x1b, 0x61, 0x02], // Right justification
};
/**
* [BARCODE_FORMAT Barcode format]
* @type {Object}
*/
_.BARCODE_FORMAT = {
BARCODE_TXT_OFF: [0x1d, 0x48, 0x00], // HRI barcode chars OFF
BARCODE_TXT_ABV: [0x1d, 0x48, 0x01], // HRI barcode chars above
BARCODE_TXT_BLW: [0x1d, 0x48, 0x02], // HRI barcode chars below
BARCODE_TXT_BTH: [0x1d, 0x48, 0x03], // HRI barcode chars both above and below
BARCODE_FONT_A: [0x1d, 0x66, 0x00], // Font type A for HRI barcode chars
BARCODE_FONT_B: [0x1d, 0x66, 0x01], // Font type B for HRI barcode chars
BARCODE_HEIGHT: function (height) { // Barcode Height [1-255]
return [0x1d, 0x68, height];
},
BARCODE_WIDTH: function (width) { // Barcode Width [2-6]
return [0x1d, 0x77, width];
},
BARCODE_HEIGHT_DEFAULT: [0x1d, 0x68, 0x64], // Barcode height default:100
BARCODE_WIDTH_DEFAULT: [0x1d, 0x77, 0x01], // Barcode width default:1
BARCODE_UPC_A: [0x1d, 0x6b, 0x00], // Barcode type UPC-A
BARCODE_UPC_E: [0x1d, 0x6b, 0x01], // Barcode type UPC-E
BARCODE_EAN13: [0x1d, 0x6b, 0x02], // Barcode type EAN13
BARCODE_EAN8: [0x1d, 0x6b, 0x03], // Barcode type EAN8
BARCODE_CODE39: [0x1d, 0x6b, 0x04], // Barcode type CODE39
BARCODE_ITF: [0x1d, 0x6b, 0x05], // Barcode type ITF
BARCODE_NW7: [0x1d, 0x6b, 0x06], // Barcode type NW7
BARCODE_CODE93: [0x1d, 0x6b, 0x48], // Barcode type CODE93
BARCODE_CODE128: [0x1d, 0x6b, 0x49], // Barcode type CODE128
};
/**
* [IMAGE_FORMAT Image format]
* @type {Object}
*/
_.IMAGE_FORMAT = {
S_RASTER_N: [0x1d, 0x76, 0x30, 0x00], // Set raster image normal size
S_RASTER_2W: [0x1d, 0x76, 0x30, 0x01], // Set raster image double width
S_RASTER_2H: [0x1d, 0x76, 0x30, 0x02], // Set raster image double height
S_RASTER_Q: [0x1d, 0x76, 0x30, 0x03], // Set raster image quadruple
};
/**
* [BITMAP_FORMAT description]
* @type {Object}
*/
_.BITMAP_FORMAT = {
BITMAP_S8: [0x1b, 0x2a, 0x00],
BITMAP_D8: [0x1b, 0x2a, 0x01],
BITMAP_S24: [0x1b, 0x2a, 0x20],
BITMAP_D24: [0x1b, 0x2a, 0x21]
};
/**
* [GSV0_FORMAT description]
* @type {Object}
*/
_.GSV0_FORMAT = {
GSV0_NORMAL: [0x1d, 0x76, 0x30, 0x00],
GSV0_DW: [0x1d, 0x76, 0x30, 0x01],
GSV0_DH: [0x1d, 0x76, 0x30, 0x02],
GSV0_DWDH: [0x1d, 0x76, 0x30, 0x03]
};
/**
* [BEEP description]
* @type {string}
*/
_.BEEP = [0x1b, 0x42]; // Printer Buzzer pre hex
/**
* [COLOR description]
* @type {Object}
*/
_.COLOR = {
0: [0x1b, 0x72, 0x00], // black
1: [0x1b, 0x72, 0x01] // red
};
/**
* [exports description]
* @type {[type]}
*/
module.exports = _;
\ No newline at end of file
const commands = require('commands');
const TextEncoder = require('text-encoding/index').TextEncoder;
const printerJobs = function () {
this._queue = Array.from(commands.HARDWARE.HW_INIT);
this._encoder = new TextEncoder("gb2312", {NONSTANDARD_allowLegacyEncoding: true});
this._enqueue = function (cmd) {
this._queue.push.apply(this._queue, cmd);
}
};
/**
* 增加打印内容
* @param {string} content 文字内容
*/
printerJobs.prototype.text = function (content) {
if (content) {
let uint8Array = this._encoder.encode(content);
let encoded = Array.from(uint8Array);
this._enqueue(encoded);
}
return this;
};
/**
* 打印文字
* @param {string} content 文字内容
*/
printerJobs.prototype.print = function (content) {
this.text(content);
this._enqueue(commands.LF);
return this;
};
/**
* 打印文字并换行
* @param {string} content 文字内容
*/
printerJobs.prototype.println = function (content = '') {
return this.print(content + commands.EOL);
};
/**
* 设置对齐方式
* @param {string} align 对齐方式 LT/CT/RT
*/
printerJobs.prototype.setAlign = function (align) {
this._enqueue(commands.TEXT_FORMAT['TXT_ALIGN_' + align.toUpperCase()]);
return this;
};
/**
* 设置字体
* @param {string} family A/B/C
*/
printerJobs.prototype.setFont = function (family) {
this._enqueue(commands.TEXT_FORMAT['TXT_FONT_' + family.toUpperCase()]);
return this;
};
/**
* 设定字体尺寸
* @param {number} width 字体宽度 1~2
* @param {number} height 字体高度 1~2
*/
printerJobs.prototype.setSize = function (width, height) {
if (2 >= width && 2 >= height) {
this._enqueue(commands.TEXT_FORMAT.TXT_NORMAL);
if (2 === width && 2 === height) {
this._enqueue(commands.TEXT_FORMAT.TXT_4SQUARE);
} else if (1 === width && 2 === height) {
this._enqueue(commands.TEXT_FORMAT.TXT_2HEIGHT);
} else if (2 === width && 1 === height) {
this._enqueue(commands.TEXT_FORMAT.TXT_2WIDTH);
}
}
return this;
};
/**
* 设定字体是否加粗
* @param {boolean} bold
*/
printerJobs.prototype.setBold = function (bold) {
if (typeof bold !== 'boolean') {
bold = true;
}
this._enqueue(bold ? commands.TEXT_FORMAT.TXT_BOLD_ON : commands.TEXT_FORMAT.TXT_BOLD_OFF);
return this;
};
/**
* 设定是否开启下划线
* @param {boolean} underline
*/
printerJobs.prototype.setUnderline = function (underline) {
if (typeof underline !== 'boolean') {
underline = true;
}
this._enqueue(underline ? commands.TEXT_FORMAT.TXT_UNDERL_ON : commands.TEXT_FORMAT.TXT_UNDERL_OFF);
return this;
};
/**
* 设置行间距为 n 点行,默认值行间距是 30 点
* @param {number} n 0≤n≤255
*/
printerJobs.prototype.setLineSpacing = function (n) {
if (n === undefined || n === null) {
this._enqueue(commands.LINE_SPACING.LS_DEFAULT);
} else {
this._enqueue(commands.LINE_SPACING.LS_SET);
this._enqueue([n]);
}
return this;
};
/**
* 打印空行
* @param {number} n
*/
printerJobs.prototype.lineFeed = function (n = 1) {
return this.print(new Array(n).fill(commands.EOL).join(''));
};
/**
* 设置字体颜色,需要打印机支持
* @param {number} color - 0 默认颜色黑色 1 红色
*/
printerJobs.prototype.setColor = function (color) {
this._enqueue(commands.COLOR[color === 1 ? 1 : 0]);
return this;
};
/**
* https://support.loyverse.com/hardware/printers/use-the-beeper-in-a-escpos-printers
* 蜂鸣警报,需要打印机支持
* @param {number} n 蜂鸣次数,1-9
* @param {number} t 蜂鸣长短,1-9
*/
printerJobs.prototype.beep = function (n, t) {
this._enqueue(commands.BEEP);
this._enqueue([n, t]);
return this;
};
/**
* 清空任务
*/
printerJobs.prototype.clear = function () {
this._queue = Array.from(commands.HARDWARE.HW_INIT);
return this;
};
/**
* 返回ArrayBuffer
*/
printerJobs.prototype.buffer = function () {
return new Uint8Array(this._queue).buffer;
};
module.exports = printerJobs;
\ No newline at end of file
// 打印机纸宽58mm,页的宽度384,字符宽度为1,每行最多盛放32个字符
const PAGE_WIDTH = 384;
const MAX_CHAR_COUNT_EACH_LINE = 32;
/**
* @param str
* @returns {boolean} str是否全是中文
*/
function isChinese(str) {
return /^[\u4e00-\u9fa5]$/.test(str);
}
/**
* 返回字符串宽度(1个中文=2个英文字符)
* @param str
* @returns {number}
*/
function getStringWidth(str) {
let width = 0;
for (let i = 0, len = str.length; i < len; i++) {
width += isChinese(str.charAt(i)) ? 2 : 1;
}
return width;
}
/**
* 同一行输出str1, str2,str1居左, str2居右
* @param {string} str1 内容1
* @param {string} str2 内容2
* @param {number} fontWidth 字符宽度 1/2
* @param {string} fillWith str1 str2之间的填充字符
*
*/
function inline(str1, str2, fillWith = ' ', fontWidth = 1) {
const lineWidth = MAX_CHAR_COUNT_EACH_LINE / fontWidth;
// 需要填充的字符数量
let fillCount = lineWidth - (getStringWidth(str1) + getStringWidth(str2)) % lineWidth;
let fillStr = new Array(fillCount).fill(fillWith.charAt(0)).join('');
return str1 + fillStr + str2;
}
/**
* 用字符填充一整行
* @param {string} fillWith 填充字符
* @param {number} fontWidth 字符宽度 1/2
*/
function fillLine(fillWith = '-', fontWidth = 1) {
const lineWidth = MAX_CHAR_COUNT_EACH_LINE / fontWidth;
return new Array(lineWidth).fill(fillWith.charAt(0)).join('');
}
/**
* 文字内容居中,左右用字符填充
* @param {string} str 文字内容
* @param {number} fontWidth 字符宽度 1/2
* @param {string} fillWith str1 str2之间的填充字符
*/
function fillAround(str, fillWith = '-', fontWidth = 1) {
const lineWidth = MAX_CHAR_COUNT_EACH_LINE / fontWidth;
let strWidth = getStringWidth(str);
// 内容已经超过一行了,没必要填充
if (strWidth >= lineWidth) {
return str;
}
// 需要填充的字符数量
let fillCount = lineWidth - strWidth;
// 左侧填充的字符数量
let leftCount = Math.round(fillCount / 2);
// 两侧的填充字符,需要考虑左边需要填充,右边不需要填充的情况
let fillStr = new Array(leftCount).fill(fillWith.charAt(0)).join('');
return fillStr + str + fillStr.substr(0, fillCount - leftCount);
}
module.exports = {
inline: inline,
fillLine: fillLine,
fillAround: fillAround,
};
\ No newline at end of file
......@@ -4,16 +4,25 @@
"ignore": []
},
"setting": {
"urlCheck": true,
"urlCheck": false,
"es6": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": true,
"autoAudits": false,
"coverView": true,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false
"scopeDataCheck": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"useCompilerModule": true
},
"compileType": "miniprogram",
"libVersion": "2.10.4",
......
......@@ -128,4 +128,12 @@ page {
.box-icon.checked {
background-color: #1969F9;
border: 1px solid #1969F9
}
.box-icon.disabled {
background-color: #F6F6F6;
border: 1px solid #F6F6F6
}
.underline-text{
text-decoration:underline
}
\ No newline at end of file
const user_url = 'http://user.liexin.net';
const in_store_url = 'http://scm.in.store.liexin.net';
export const apis = {
login:user_url+'/pwd/login',//登入
me:user_url+'/pwd/me',//获取用户信息
get_in_store_warehousing_sn:in_store_url+"/in_store/get_in_store_warehousing_sn",//根据入仓单号查找入库单
in_store_detail_list:in_store_url+'/in_store/in_store_detail_list',//获取入库单详情
}
\ No newline at end of file
const axios = (url, type, params, callBack, loading, header) => {
let tokenInvalid;
wx.request({
url: url,
data: params,
header: header,
method: type,
success: (res) => {
wx.hideNavigationBarLoading();
if (loading) {
wx.hideLoading();
}
//处理token失效的情况
if (res.data.hasOwnProperty('data')) {
if (res.data.errcode == 501) {
tokenInvalid = true
} else {
typeof callBack == "function" && callBack(res.data);
}
} else {
if (res.data.errcode == 501) {
tokenInvalid = true
} else {
typeof callBack == "function" && callBack(res.data);
}
}
if (tokenInvalid) {
wx.removeStorageSync('access_token');
wx.removeStorageSync('userInfo');
wx.removeStorageSync('userId');
wx.reLaunch({
url: '/pages/login/login'
});
}
},
fail: () => {
wx.hideNavigationBarLoading();
if (loading) {
wx.hideLoading();
}
wx.showToast({
title: '服务器异常',
icon: 'none',
duration: 2000
});
}
})
};
//数据请求(get,post)
const getData = (url, type, param, callBack, loading, istoken,isheader) => {
wx.showNavigationBarLoading();
var token, header,params;
//获取token
token = wx.getStorageSync('access_token');
//参数字段追加来源字段,token字段
if (istoken) {
params = Object.assign({}, param, {
// source: 1,
token: token
});
} else {
params = param
// var params = Object.assign({}, param, {
// source: 1
// });
}
//是否启用loading加载效果
if (loading) {
wx.showLoading({
mask:true
});
}
//是否启用请求头token
if (isheader) {
header = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": 'Bearer ' + token
}
} else {
header = {
"Content-Type": "application/x-www-form-urlencoded"
}
}
wx.getNetworkType({
success(res) {
const networkType = res.networkType;
if (networkType !='none'){
//有网络
axios(url, type, params, callBack, loading, header)
}else{
wx.hideNavigationBarLoading();
if (loading) {
wx.hideLoading();
}
wx.showToast({
title: '网络出现异常',
icon: 'none',
duration: 2000
});
}
},
fail:function(){
axios(url, type, params, callBack, loading, header)
}
})
};
module.exports = {
getData: getData
}
\ No newline at end of file
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 1.1 Copyright (C) Paul Johnston 1999 - 2002.
* Code also contributed by Greg Holt
* See http://pajhome.org.uk/site/legal.html for details.
*/
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF)
var msw = (x >> 16) + (y >> 16) + (lsw >> 16)
return (msw << 16) | (lsw & 0xFFFF)
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt))
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function cmn(q, a, b, x, s, t)
{
return safe_add(rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b)
}
function ff(a, b, c, d, x, s, t)
{
return cmn((b & c) | ((~b) & d), a, b, x, s, t)
}
function gg(a, b, c, d, x, s, t)
{
return cmn((b & d) | (c & (~d)), a, b, x, s, t)
}
function hh(a, b, c, d, x, s, t)
{
return cmn(b ^ c ^ d, a, b, x, s, t)
}
function ii(a, b, c, d, x, s, t)
{
return cmn(c ^ (b | (~d)), a, b, x, s, t)
}
/*
* Calculate the MD5 of an array of little-endian words, producing an array
* of little-endian words.
*/
function coreMD5(x)
{
var a = 1732584193
var b = -271733879
var c = -1732584194
var d = 271733878
for(var i = 0; i < x.length; i += 16)
{
var olda = a
var oldb = b
var oldc = c
var oldd = d
a = ff(a, b, c, d, x[i+ 0], 7 , -680876936)
d = ff(d, a, b, c, x[i+ 1], 12, -389564586)
c = ff(c, d, a, b, x[i+ 2], 17, 606105819)
b = ff(b, c, d, a, x[i+ 3], 22, -1044525330)
a = ff(a, b, c, d, x[i+ 4], 7 , -176418897)
d = ff(d, a, b, c, x[i+ 5], 12, 1200080426)
c = ff(c, d, a, b, x[i+ 6], 17, -1473231341)
b = ff(b, c, d, a, x[i+ 7], 22, -45705983)
a = ff(a, b, c, d, x[i+ 8], 7 , 1770035416)
d = ff(d, a, b, c, x[i+ 9], 12, -1958414417)
c = ff(c, d, a, b, x[i+10], 17, -42063)
b = ff(b, c, d, a, x[i+11], 22, -1990404162)
a = ff(a, b, c, d, x[i+12], 7 , 1804603682)
d = ff(d, a, b, c, x[i+13], 12, -40341101)
c = ff(c, d, a, b, x[i+14], 17, -1502002290)
b = ff(b, c, d, a, x[i+15], 22, 1236535329)
a = gg(a, b, c, d, x[i+ 1], 5 , -165796510)
d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632)
c = gg(c, d, a, b, x[i+11], 14, 643717713)
b = gg(b, c, d, a, x[i+ 0], 20, -373897302)
a = gg(a, b, c, d, x[i+ 5], 5 , -701558691)
d = gg(d, a, b, c, x[i+10], 9 , 38016083)
c = gg(c, d, a, b, x[i+15], 14, -660478335)
b = gg(b, c, d, a, x[i+ 4], 20, -405537848)
a = gg(a, b, c, d, x[i+ 9], 5 , 568446438)
d = gg(d, a, b, c, x[i+14], 9 , -1019803690)
c = gg(c, d, a, b, x[i+ 3], 14, -187363961)
b = gg(b, c, d, a, x[i+ 8], 20, 1163531501)
a = gg(a, b, c, d, x[i+13], 5 , -1444681467)
d = gg(d, a, b, c, x[i+ 2], 9 , -51403784)
c = gg(c, d, a, b, x[i+ 7], 14, 1735328473)
b = gg(b, c, d, a, x[i+12], 20, -1926607734)
a = hh(a, b, c, d, x[i+ 5], 4 , -378558)
d = hh(d, a, b, c, x[i+ 8], 11, -2022574463)
c = hh(c, d, a, b, x[i+11], 16, 1839030562)
b = hh(b, c, d, a, x[i+14], 23, -35309556)
a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060)
d = hh(d, a, b, c, x[i+ 4], 11, 1272893353)
c = hh(c, d, a, b, x[i+ 7], 16, -155497632)
b = hh(b, c, d, a, x[i+10], 23, -1094730640)
a = hh(a, b, c, d, x[i+13], 4 , 681279174)
d = hh(d, a, b, c, x[i+ 0], 11, -358537222)
c = hh(c, d, a, b, x[i+ 3], 16, -722521979)
b = hh(b, c, d, a, x[i+ 6], 23, 76029189)
a = hh(a, b, c, d, x[i+ 9], 4 , -640364487)
d = hh(d, a, b, c, x[i+12], 11, -421815835)
c = hh(c, d, a, b, x[i+15], 16, 530742520)
b = hh(b, c, d, a, x[i+ 2], 23, -995338651)
a = ii(a, b, c, d, x[i+ 0], 6 , -198630844)
d = ii(d, a, b, c, x[i+ 7], 10, 1126891415)
c = ii(c, d, a, b, x[i+14], 15, -1416354905)
b = ii(b, c, d, a, x[i+ 5], 21, -57434055)
a = ii(a, b, c, d, x[i+12], 6 , 1700485571)
d = ii(d, a, b, c, x[i+ 3], 10, -1894986606)
c = ii(c, d, a, b, x[i+10], 15, -1051523)
b = ii(b, c, d, a, x[i+ 1], 21, -2054922799)
a = ii(a, b, c, d, x[i+ 8], 6 , 1873313359)
d = ii(d, a, b, c, x[i+15], 10, -30611744)
c = ii(c, d, a, b, x[i+ 6], 15, -1560198380)
b = ii(b, c, d, a, x[i+13], 21, 1309151649)
a = ii(a, b, c, d, x[i+ 4], 6 , -145523070)
d = ii(d, a, b, c, x[i+11], 10, -1120210379)
c = ii(c, d, a, b, x[i+ 2], 15, 718787259)
b = ii(b, c, d, a, x[i+ 9], 21, -343485551)
a = safe_add(a, olda)
b = safe_add(b, oldb)
c = safe_add(c, oldc)
d = safe_add(d, oldd)
}
return [a, b, c, d]
}
/*
* Convert an array of little-endian words to a hex string.
*/
function binl2hex(binarray)
{
var hex_tab = "0123456789abcdef"
var str = ""
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8)) & 0xF)
}
return str
}
/*
* Convert an array of little-endian words to a base64 encoded string.
*/
function binl2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
var str = ""
for(var i = 0; i < binarray.length * 32; i += 6)
{
str += tab.charAt(((binarray[i>>5] << (i%32)) & 0x3F) |
((binarray[i>>5+1] >> (32-i%32)) & 0x3F))
}
return str
}
/*
* Convert an 8-bit character string to a sequence of 16-word blocks, stored
* as an array, and append appropriate padding for MD4/5 calculation.
* If any of the characters are >255, the high byte is silently ignored.
*/
function str2binl(str)
{
var nblk = ((str.length + 8) >> 6) + 1 // number of 16-word blocks
var blks = new Array(nblk * 16)
for(var i = 0; i < nblk * 16; i++) blks[i] = 0
for(var i = 0; i < str.length; i++)
blks[i>>2] |= (str.charCodeAt(i) & 0xFF) << ((i%4) * 8)
blks[i>>2] |= 0x80 << ((i%4) * 8)
blks[nblk*16-2] = str.length * 8
return blks
}
/*
* Convert a wide-character string to a sequence of 16-word blocks, stored as
* an array, and append appropriate padding for MD4/5 calculation.
*/
function strw2binl(str)
{
var nblk = ((str.length + 4) >> 5) + 1 // number of 16-word blocks
var blks = new Array(nblk * 16)
for(var i = 0; i < nblk * 16; i++) blks[i] = 0
for(var i = 0; i < str.length; i++)
blks[i>>1] |= str.charCodeAt(i) << ((i%2) * 16)
blks[i>>1] |= 0x80 << ((i%2) * 16)
blks[nblk*16-2] = str.length * 16
return blks
}
/*
* External interface
*/
function hexMD5 (str) { return binl2hex(coreMD5( str2binl(str))) }
function hexMD5w(str) { return binl2hex(coreMD5(strw2binl(str))) }
function b64MD5 (str) { return binl2b64(coreMD5( str2binl(str))) }
function b64MD5w(str) { return binl2b64(coreMD5(strw2binl(str))) }
/* Backward compatibility */
function calcMD5(str) { return binl2hex(coreMD5( str2binl(str))) }
module.exports = {
hexMD5: hexMD5
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment