Commit 6a287b22 authored by pengguangpu's avatar pengguangpu

添加登录页逻辑交互;自测通过

parent 3a05fea7
{"tinyType":"alipayiot","tinyCnName":"支付宝 IoT","tinyProjectType":"xpaas-mini","alipayiot:xpaas-mini:tinyIcon":"https://gw.alipayobjects.com/mdn/rms_c763d8/afts/img/A*vNMFT7X_u3sAAAAAAAAAAABkARQnAQ","alipayiot:xpaas-mini:auditLink":null,"alipayiot:xpaas-mini:whiteListLink":null,"alipayiot:xpaas-mini:createLink":null,"alipayiot:xpaas-mini:component2":false,"alipayiot:xpaas-mini:_enableAutoPush":false,"alipayiot:xpaas-mini:_appIdList":[],"alipayiot:xpaas-mini:uploadTime":"","alipayiot:xpaas-mini:packageSize":0,"alipayiot:xpaas-mini:lastDeviceName":"蜻蜓F4","isSimulatorOpen":true,"isNotFirstToggleSimulator":true,"storageVersion":"1.5.7"} {"tinyType":"alipayiot","tinyCnName":"支付宝 IoT","tinyProjectType":"xpaas-mini","alipayiot:xpaas-mini:tinyIcon":"https://gw.alipayobjects.com/mdn/rms_c763d8/afts/img/A*vNMFT7X_u3sAAAAAAAAAAABkARQnAQ","alipayiot:xpaas-mini:auditLink":null,"alipayiot:xpaas-mini:whiteListLink":null,"alipayiot:xpaas-mini:createLink":null,"alipayiot:xpaas-mini:component2":false,"alipayiot:xpaas-mini:_enableAutoPush":false,"alipayiot:xpaas-mini:_appIdList":[],"alipayiot:xpaas-mini:uploadTime":"","alipayiot:xpaas-mini:packageSize":0,"alipayiot:xpaas-mini:lastDeviceName":"蜻蜓F4","isSimulatorOpen":true,"isNotFirstToggleSimulator":true,"alipayiot:xpaas-mini:MockStore":{"localLoginInfo":{"name":"ywxadmin","password":"1234567a","sn":""},"localAccountInfo":{"accountId":126,"actType":1,"agreement":1,"isShopCart":0,"merchantId":"2088222276054714","merchantName":"一网鲜(杭州)信息科技有限公司","realName":"力拔山兮气盖世时不利兮骓不逝","storeList":[{"address":"杭州市江干区科技园路2号","hasStoreManager":1,"storeId":"001","storeName":"一网鲜"}],"token":"431145114888654848","userName":"ywxadmin","userPhone":"13858057743"}},"storageVersion":"1.5.7"}
\ No newline at end of file \ No newline at end of file
{"layout":{"left":{"currentId":"scm_container","size":310},"right":{"currentId":""},"bottom":{"currentId":""}},"storageVersion":"1.5.7"} {"layout":{"left":{"currentId":"scm_container","size":310},"right":{"currentId":""},"bottom":{"currentId":"","size":307}},"storageVersion":"1.5.7"}
\ No newline at end of file \ No newline at end of file
App({ App({
globalData: {
version: "1.0.0.20200203",
//是否使用测试支付数据
useTestPayInfo: false,
printerId: null,
printerName: null,
TEST_URL: "https://cashier.test.miyahub.net/",
RELEASE_URL: "https://cashier.miyahub.com/",
BASE_URL: null,
appId:"1542075029346",
//小程序容器版本
containerVersionCode: null
},
onLaunch(options) { onLaunch(options) {
// 第一次打开 // 第一次打开
// options.query == {number:1} // options.query == {number:1}
console.info('App onLaunch'); console.info('App onLaunch');
//初始化baseUrl
this.globalData.BASE_URL = this.globalData.TEST_URL;
}, },
onShow(options) { onShow(options) {
// 从后台被 scheme 重新打开 // 从后台被 scheme 重新打开
......
...@@ -116,9 +116,10 @@ Page({ ...@@ -116,9 +116,10 @@ Page({
var loginCallbackTemp = this.loginCallback.bind(this); var loginCallbackTemp = this.loginCallback.bind(this);
api.login({ api.login({
baseUrl: getApp().globalData.BASE_URL, baseUrl: getApp().globalData.BASE_URL,
appId:getApp().globalData.appId,
name: this.data.name, name: this.data.name,
password: this.data.password, password: this.data.password,
sn: this.data.sn, sn: this.data.sn+"xx",
callback: loginCallbackTemp callback: loginCallbackTemp
}); });
}, },
......
//login //login
var API_LOGIN = "verify/auth/token"; var API_LOGIN = "store/cashier/login";
//返回的数据都为code、data的形式 //返回的数据都为code、data的形式
function login({ baseUrl,name, password, sn, callback }) { function login({ baseUrl, appId, name, password, sn, callback }) {
var loginRequest = { var loginRequest = createCommonRequest(appId,null,sn);
username: name, loginRequest.username = name;
password: password, loginRequest.password = password;
serialNo: sn loginRequest.loginType = "1";
};
console.log("login request==>" + JSON.stringify(loginRequest)); console.log("login request==>" + JSON.stringify(loginRequest));
var loginResponse = { code: {}, data: {} }; var loginResponse = { code: {}, data: {} };
my.request({ my.request({
...@@ -22,10 +23,10 @@ function login({ baseUrl,name, password, sn, callback }) { ...@@ -22,10 +23,10 @@ function login({ baseUrl,name, password, sn, callback }) {
console.log("login success==>" + JSON.stringify(res)); console.log("login success==>" + JSON.stringify(res));
if (callback != null) { if (callback != null) {
if (res.data.code != "200") { if (res.data.success != true) {
loginResponse.code = -1; loginResponse.code = -1;
//重置data内容 //重置data内容
loginResponse.data = res.data.msg; loginResponse.data = res.data.errorMsg;
} else { } else {
loginResponse.code = 0; loginResponse.code = 0;
loginResponse.data = res.data.data; loginResponse.data = res.data.data;
...@@ -45,6 +46,37 @@ function login({ baseUrl,name, password, sn, callback }) { ...@@ -45,6 +46,37 @@ function login({ baseUrl,name, password, sn, callback }) {
}); });
} }
function createCommonRequest(appId, token, deviceNo) {
var commonRequest = {
};
commonRequest.appId = appId;
commonRequest.token = token;
commonRequest.deviceNo = deviceNo;
commonRequest.batchNo = "";
commonRequest.timestamp = timestampToTime();
commonRequest.format = "JSON";
commonRequest.charset = "utf-8";
commonRequest.signType = "RSA2";
commonRequest.version = "1.0";
commonRequest.sign = "qt-pos";
return commonRequest;
}
function timestampToTime() {
var date = new Date();
var Y = date.getFullYear() + '-';
var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
var D = date.getDate() < 10 ? '0'+date.getDate()+ ' ' : date.getDate()+ ' ';
var h = date.getHours() + ':';
var m = date.getMinutes() + ':';
var s = date.getSeconds();
return Y + M + D + h + m + s;
}
function decodeErrorMessage(error) { function decodeErrorMessage(error) {
if (error == null) { if (error == null) {
return "请求失败"; return "请求失败";
......
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 to comment