Commit 5ac16563 authored by lijiongliang's avatar lijiongliang

js重构

parent 4233bce9
unpackage/ unpackage/
.hbuilderx/ .hbuilderx/
.idea/ .idea/
.vscode/ .vscode/
\ No newline at end of file node_modules/
\ No newline at end of file
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
export default { export default {
onLaunch: function () { onLaunch: function () {
uni.hideTabBar() uni.hideTabBar()
// 获取手机系统信息
const info = uni.getSystemInfoSync()
// 设置状态栏高度(H5顶部无状态栏小程序有状态栏需要撑起高度)
uni.setStorageSync('statusBarHeight',info.statusBarHeight)
}, },
onShow: function () { onShow: function () {
uni.hideHomeButton() uni.hideHomeButton()
......
// const baseUrl = 'https://r.ucaret.cn/test-api'; // 开发地 const baseUrl = 'https://r.ucaret.cn/test-api'; // 开发地/
const baseUrl = 'http://4v7u6z.natappfree.cc'; // 开发地址 // const baseUrl = 'http://5thcg5.natappfree.cc'; // 开发地址
// const baseUrl = 'https://jduniapp.uzosp.com'; // 线上地址 // const baseUrl = 'https://jduniapp.uzosp.com'; // 线上地/
const httpRequest = (opts, data) => { const httpRequest = (opts, data) => {
let httpDefaultOpts = { let httpDefaultOpts = {
url: baseUrl + opts.url, url: baseUrl + opts.url,
...@@ -30,6 +30,7 @@ const httpRequest = (opts, data) => { ...@@ -30,6 +30,7 @@ const httpRequest = (opts, data) => {
}) })
return promise return promise
}; };
let requestNumber = 0;
//带Token请求 //带Token请求
const httpTokenRequest = (opts, data) => { const httpTokenRequest = (opts, data) => {
let token = uni.getStorageSync('userToken'); let token = uni.getStorageSync('userToken');
...@@ -61,13 +62,26 @@ const httpTokenRequest = (opts, data) => { ...@@ -61,13 +62,26 @@ const httpTokenRequest = (opts, data) => {
let promise = new Promise(function(resolve, reject) { let promise = new Promise(function(resolve, reject) {
uni.request(httpDefaultOpts).then( uni.request(httpDefaultOpts).then(
(res) => { (res) => {
console.log(33333333333,res[1]) console.log(33333333333,requestNumber,baseUrl,res[1])
if(res[1].data.code == 401){ if(res[1].data.code == 401){
uni.removeStorageSync('userToken') if(requestNumber <= 0){
uni.navigateTo({ requestNumber ++
url:"/pages/login/index/index?failure=401" uni.removeStorageSync('userToken')
}) let returnPage= '/pages/main';
let pageType = "reLaunch"
uni.navigateTo({
url:"/pages/login/index/index?returnPage="+returnPage+'&pageType='+pageType,
success:()=>{
requestNumber = 0
}
})
}
return; return;
}else if(res[1].data.code == 500){
// uni.showToast({
// title:res[1].data.msg,
// icon:"none"
// })
} }
resolve(res[1]) resolve(res[1])
} }
......
import { mergeConfig, dispatchRequest, jsonpRequest} from "./utils.js";
export default class request {
constructor(options) {
//请求公共地址
this.baseUrl = options.baseUrl || "";
//公共文件上传请求地址
this.fileUrl = options.fileUrl || "";
// 超时时间
this.timeout = options.timeout || 6000;
// 服务器上传图片默认url
this.defaultUploadUrl = options.defaultUploadUrl || "";
// 服务器上传文件名称
this.defaultFileName = options.defaultFileName || "";
//默认请求头
this.header = options.header || {};
//默认配置
this.config = options.config || {
isPrompt: true,
load: true,
isFactory: true,
resend: 0
};
}
//post请求
post(url = '', data = {}, options = {}) {
return this.request({
method: "POST",
data: data,
url: url,
...options
});
}
//get请求
get(url = '', data = {}, options = {}) {
return this.request({
method: "GET",
data: data,
url: url,
...options
});
}
//put请求
put(url = '', data = {}, options = {}) {
return this.request({
method: "PUT",
data: data,
url: url,
...options
});
}
//delete请求
delete(url = '', data = {}, options = {}) {
return this.request({
method: "DELETE",
data: data,
url: url,
...options
});
}
//jsonp请求(只限于H5使用)
jsonp(url = '', data = {}, options = {}) {
return this.request({
method: "JSONP",
data: data,
url: url,
...options
});
}
//接口请求方法
async request(data) {
// 请求数据
let requestInfo,
// 是否运行过请求开始钩子
runRequestStart = false;
try {
if (!data.url) {
throw { errMsg: "【request】缺失数据url", statusCode: 0}
}
// 数据合并
requestInfo = mergeConfig(this, data);
// 代表之前运行到这里
runRequestStart = true;
//请求前回调
if (this.requestStart) {
let requestStart = this.requestStart(requestInfo);
if (typeof requestStart == "object") {
let changekeys = ["data", "header", "isPrompt", "load", "isFactory"];
changekeys.forEach(key => {
requestInfo[key] = requestStart[key];
});
} else {
throw {
errMsg: "【request】请求开始拦截器未通过",
statusCode: 0,
data: requestInfo.data,
method: requestInfo.method,
header: requestInfo.header,
url: requestInfo.url,
}
}
}
let requestResult = {};
if(requestInfo.method == "JSONP"){
requestResult = await jsonpRequest(requestInfo);
} else {
requestResult = await dispatchRequest(requestInfo);
}
//是否用外部的数据处理方法
if (requestInfo.isFactory && this.dataFactory) {
//数据处理
let result = await this.dataFactory({
...requestInfo,
response: requestResult
});
return Promise.resolve(result);
} else {
return Promise.resolve(requestResult);
}
} catch (err){
this.requestError && this.requestError(err);
return Promise.reject(err);
} finally {
// 如果请求开始未运行到,请求结束也不运行
if(runRequestStart){
this.requestEnd && this.requestEnd(requestInfo);
}
}
}
}
// 获取合并的数据
export const mergeConfig = function(_this, options) {
//判断url是不是链接
let urlType = /^(http|https):\/\//.test(options.url);
let config = Object.assign({
timeout: _this.timeout
}, _this.config, options);
if (options.method == "FILE") {
config.url = urlType ? options.url : _this.fileUrl + options.url;
} else {
config.url = urlType ? options.url : _this.baseUrl + options.url;
}
//请求头
if (options.header) {
config.header = Object.assign({}, _this.header, options.header);
} else {
config.header = Object.assign({}, _this.header);
}
return config;
}
// 请求
export const dispatchRequest = function(requestInfo) {
return new Promise((resolve, reject) => {
let requestAbort = true;
let requestData = {
url: requestInfo.url,
header: requestInfo.header, //加入请求头
success: (res) => {
requestAbort = false;
resolve(res);
},
fail: (err) => {
requestAbort = false;
if(err.errMsg == "request:fail abort"){
reject({
errMsg: "请求超时,请重新尝试",
statusCode: 0,
});
} else {
reject(err);
}
}
};
//请求类型
if (requestInfo.method) {
requestData.method = requestInfo.method;
}
if (requestInfo.data) {
requestData.data = requestInfo.data;
}
// #ifdef MP-WEIXIN || MP-ALIPAY
if (requestInfo.timeout) {
requestData.timeout = requestInfo.timeout;
}
// #endif
if (requestInfo.dataType) {
requestData.dataType = requestInfo.dataType;
}
// #ifndef APP-PLUS || MP-ALIPAY
if (requestInfo.responseType) {
requestData.responseType = requestInfo.responseType;
}
// #endif
// #ifdef H5
if (requestInfo.withCredentials) {
requestData.withCredentials = requestInfo.withCredentials;
}
// #endif
let requestTask = uni.request(requestData);
setTimeout(() => {
if(requestAbort){
requestTask.abort();
}
}, requestInfo.timeout)
})
}
// jsonp请求
export const jsonpRequest = function(requestInfo) {
return new Promise((resolve, reject) => {
let dataStr = '';
Object.keys(requestInfo.data).forEach(key => {
dataStr += key + '=' + requestInfo.data[key] + '&';
});
//匹配最后一个&并去除
if (dataStr !== '') {
dataStr = dataStr.substr(0, dataStr.lastIndexOf('&'));
}
requestInfo.url = requestInfo.url + '?' + dataStr;
let callbackName = "callback" + Math.ceil(Math.random() * 1000000);
// #ifdef H5
window[callbackName] = function(data) {
resolve(data);
}
let script = document.createElement("script");
script.src = requestInfo.url + "&callback=" + callbackName;
document.head.appendChild(script);
// 及时删除,防止加载过多的JS
document.head.removeChild(script);
// #endif
});
}
\ No newline at end of file
/***************纯粹的数据请求(如果使用这种可以删除掉fileUpload.js)******************/
// import request from "./core/request.js";
// export default request;
/********数据请求同时继承了文件上传(包括七牛云上传)************/
import upload from "./upload/upload.js";
export default upload;
\ No newline at end of file
This diff is collapsed.
const Base64 = {
// private property
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding
encode: function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = Base64._utf8_encode(input);
while (i < input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
}
return output;
},
// public method for decoding
decode: function (input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
output = Base64._utf8_decode(output);
return output;
},
// private method for UTF-8 encoding
_utf8_encode: function (string) {
string = string.replace(/\r\n/g, "\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
} else if ((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
} else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
// private method for UTF-8 decoding
_utf8_decode: function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while (i < utftext.length) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
} else if ((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i + 1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
} else {
c2 = utftext.charCodeAt(i + 1);
c3 = utftext.charCodeAt(i + 2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
}
module.exports = Base64;
\ No newline at end of file
const Base64 = require('./Base64.js');
require('./hmac.js');
require('./sha1.js');
const Crypto = require('./crypto.js');
// 获取policy
const getPolicyBase64 = function (timeout) {
let dateTime = new Date().getTime();
let date = new Date(dateTime + (timeout || 1800000));
let srcT = date.toISOString();
const policyText = {
"expiration": srcT, //设置该Policy的失效时间
"conditions": [
["content-length-range", 0, 100 * 1024 * 1024] // 设置上传文件的大小限制,100mb
]
};
const policyBase64 = Base64.encode(JSON.stringify(policyText));
return policyBase64;
}
// 获取签名
const getSignature = function (policyBase64, AccessKeySecret) {
const bytes = Crypto.HMAC(Crypto.SHA1, policyBase64, AccessKeySecret, {
asBytes: true
});
const signature = Crypto.util.bytesToBase64(bytes);
return signature;
}
// 获取阿里云token信息
const getAliyunOssKey = function (options) {
const policyBase64 = getPolicyBase64(options.timeout);
const signature = getSignature(policyBase64, options.accessKeySecret);
return {
policy: policyBase64,
accessKeyId: options.accessKeyId,
accessKeySecret: options.accessKeySecret,
signature: signature,
success_action_status: '200'
}
}
module.exports = getAliyunOssKey;
\ No newline at end of file
/*!
* Crypto-JS v1.1.0
* http://code.google.com/p/crypto-js/
* Copyright (c) 2009, Jeff Mott. All rights reserved.
* http://code.google.com/p/crypto-js/wiki/License
*/
const Crypto = {};
(function(){
var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
// Crypto utilities
var util = Crypto.util = {
// Bit-wise rotate left
rotl: function (n, b) {
return (n << b) | (n >>> (32 - b));
},
// Bit-wise rotate right
rotr: function (n, b) {
return (n << (32 - b)) | (n >>> b);
},
// Swap big-endian to little-endian and vice versa
endian: function (n) {
// If number given, swap endian
if (n.constructor == Number) {
return util.rotl(n, 8) & 0x00FF00FF |
util.rotl(n, 24) & 0xFF00FF00;
}
// Else, assume array and swap all items
for (var i = 0; i < n.length; i++)
n[i] = util.endian(n[i]);
return n;
},
// Generate an array of any length of random bytes
randomBytes: function (n) {
for (var bytes = []; n > 0; n--)
bytes.push(Math.floor(Math.random() * 256));
return bytes;
},
// Convert a string to a byte array
stringToBytes: function (str) {
var bytes = [];
for (var i = 0; i < str.length; i++)
bytes.push(str.charCodeAt(i));
return bytes;
},
// Convert a byte array to a string
bytesToString: function (bytes) {
var str = [];
for (var i = 0; i < bytes.length; i++)
str.push(String.fromCharCode(bytes[i]));
return str.join("");
},
// Convert a string to big-endian 32-bit words
stringToWords: function (str) {
var words = [];
for (var c = 0, b = 0; c < str.length; c++, b += 8)
words[b >>> 5] |= str.charCodeAt(c) << (24 - b % 32);
return words;
},
// Convert a byte array to big-endian 32-bits words
bytesToWords: function (bytes) {
var words = [];
for (var i = 0, b = 0; i < bytes.length; i++, b += 8)
words[b >>> 5] |= bytes[i] << (24 - b % 32);
return words;
},
// Convert big-endian 32-bit words to a byte array
wordsToBytes: function (words) {
var bytes = [];
for (var b = 0; b < words.length * 32; b += 8)
bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
return bytes;
},
// Convert a byte array to a hex string
bytesToHex: function (bytes) {
var hex = [];
for (var i = 0; i < bytes.length; i++) {
hex.push((bytes[i] >>> 4).toString(16));
hex.push((bytes[i] & 0xF).toString(16));
}
return hex.join("");
},
// Convert a hex string to a byte array
hexToBytes: function (hex) {
var bytes = [];
for (var c = 0; c < hex.length; c += 2)
bytes.push(parseInt(hex.substr(c, 2), 16));
return bytes;
},
// Convert a byte array to a base-64 string
bytesToBase64: function (bytes) {
// Use browser-native function if it exists
// if (typeof btoa == "function") return btoa(util.bytesToString(bytes));
var base64 = [],
overflow;
for (var i = 0; i < bytes.length; i++) {
switch (i % 3) {
case 0:
base64.push(base64map.charAt(bytes[i] >>> 2));
overflow = (bytes[i] & 0x3) << 4;
break;
case 1:
base64.push(base64map.charAt(overflow | (bytes[i] >>> 4)));
overflow = (bytes[i] & 0xF) << 2;
break;
case 2:
base64.push(base64map.charAt(overflow | (bytes[i] >>> 6)));
base64.push(base64map.charAt(bytes[i] & 0x3F));
overflow = -1;
}
}
// Encode overflow bits, if there are any
if (overflow != undefined && overflow != -1)
base64.push(base64map.charAt(overflow));
// Add padding
while (base64.length % 4 != 0) base64.push("=");
return base64.join("");
},
// Convert a base-64 string to a byte array
base64ToBytes: function (base64) {
// Use browser-native function if it exists
if (typeof atob == "function") return util.stringToBytes(atob(base64));
// Remove non-base-64 characters
base64 = base64.replace(/[^A-Z0-9+\/]/ig, "");
var bytes = [];
for (var i = 0; i < base64.length; i++) {
switch (i % 4) {
case 1:
bytes.push((base64map.indexOf(base64.charAt(i - 1)) << 2) |
(base64map.indexOf(base64.charAt(i)) >>> 4));
break;
case 2:
bytes.push(((base64map.indexOf(base64.charAt(i - 1)) & 0xF) << 4) |
(base64map.indexOf(base64.charAt(i)) >>> 2));
break;
case 3:
bytes.push(((base64map.indexOf(base64.charAt(i - 1)) & 0x3) << 6) |
(base64map.indexOf(base64.charAt(i))));
break;
}
}
return bytes;
}
};
// Crypto mode namespace
Crypto.mode = {};
})();
module.exports = Crypto;
\ No newline at end of file
/*!
* Crypto-JS v1.1.0
* http://code.google.com/p/crypto-js/
* Copyright (c) 2009, Jeff Mott. All rights reserved.
* http://code.google.com/p/crypto-js/wiki/License
*/
const Crypto = require('./crypto.js');
(function(){
// Shortcut
var util = Crypto.util;
Crypto.HMAC = function (hasher, message, key, options) {
// Allow arbitrary length keys
key = key.length > hasher._blocksize * 4 ?
hasher(key, { asBytes: true }) :
util.stringToBytes(key);
// XOR keys with pad constants
var okey = key,
ikey = key.slice(0);
for (var i = 0; i < hasher._blocksize * 4; i++) {
okey[i] ^= 0x5C;
ikey[i] ^= 0x36;
}
var hmacbytes = hasher(util.bytesToString(okey) +
hasher(util.bytesToString(ikey) + message, { asString: true }),
{ asBytes: true });
return options && options.asBytes ? hmacbytes :
options && options.asString ? util.bytesToString(hmacbytes) :
util.bytesToHex(hmacbytes);
};
})();
module.exports = Crypto;
\ No newline at end of file
// created by gpake
(function () {
var config = {
qiniuRegion: '',
qiniuImageURLPrefix: '',
qiniuUploadToken: '',
qiniuUploadTokenURL: '',
qiniuUploadTokenFunction: null,
qiniuShouldUseQiniuFileName: false
}
module.exports = {
init: init,
upload: upload,
}
// 在整个程序生命周期中,只需要 init 一次即可
// 如果需要变更参数,再调用 init 即可
function init(options) {
config = {
qiniuRegion: '',
qiniuImageURLPrefix: '',
qiniuUploadToken: '',
qiniuUploadTokenURL: '',
qiniuUploadTokenFunction: null,
qiniuShouldUseQiniuFileName: false
};
updateConfigWithOptions(options);
}
function updateConfigWithOptions(options) {
if (options.region) {
config.qiniuRegion = options.region;
} else {
console.error('qiniu uploader need your bucket region');
}
if (options.uptoken) {
config.qiniuUploadToken = options.uptoken;
} else if (options.uptokenURL) {
config.qiniuUploadTokenURL = options.uptokenURL;
} else if (options.uptokenFunc) {
config.qiniuUploadTokenFunction = options.uptokenFunc;
}
if (options.domain) {
config.qiniuImageURLPrefix = options.domain;
}
config.qiniuShouldUseQiniuFileName = options.shouldUseQiniuFileName
}
function upload(filePath, success, fail, options, progress, cancelTask) {
if (null == filePath) {
console.error('qiniu uploader need filePath to upload');
return;
}
if (options) {
updateConfigWithOptions(options);
}
if (config.qiniuUploadToken) {
doUpload(filePath, success, fail, options, progress, cancelTask);
} else if (config.qiniuUploadTokenURL) {
getQiniuToken(function () {
doUpload(filePath, success, fail, options, progress, cancelTask);
});
} else if (config.qiniuUploadTokenFunction) {
config.qiniuUploadToken = config.qiniuUploadTokenFunction();
if (null == config.qiniuUploadToken && config.qiniuUploadToken.length > 0) {
console.error('qiniu UploadTokenFunction result is null, please check the return value');
return
}
doUpload(filePath, success, fail, options, progress, cancelTask);
} else {
console.error('qiniu uploader need one of [uptoken, uptokenURL, uptokenFunc]');
return;
}
}
function doUpload(filePath, success, fail, options, progress, cancelTask) {
if (null == config.qiniuUploadToken && config.qiniuUploadToken.length > 0) {
console.error('qiniu UploadToken is null, please check the init config or networking');
return
}
var url = uploadURLFromRegionCode(config.qiniuRegion);
var fileName = filePath.split('//')[1];
if (options && options.key) {
fileName = options.key;
}
var formData = {
'token': config.qiniuUploadToken
};
if (!config.qiniuShouldUseQiniuFileName) {
formData['key'] = fileName
}
var uploadTask = wx.uploadFile({
url: url,
filePath: filePath,
name: 'file',
formData: formData,
success: function (res) {
var dataString = res.data
if (res.data.hasOwnProperty('type') && res.data.type === 'Buffer') {
dataString = String.fromCharCode.apply(null, res.data.data)
}
try {
var dataObject = JSON.parse(dataString);
//do something
var imageUrl = config.qiniuImageURLPrefix + '/' + dataObject.key;
dataObject.imageURL = imageUrl;
if (success) {
success(dataObject);
}
} catch (e) {
console.log('parse JSON failed, origin String is: ' + dataString)
if (fail) {
fail(e);
}
}
},
fail: function (error) {
console.error(error);
if (fail) {
fail(error);
}
}
})
uploadTask.onProgressUpdate((res) => {
progress && progress(res)
})
cancelTask && cancelTask(() => {
uploadTask.abort()
})
}
function getQiniuToken(callback) {
wx.request({
url: config.qiniuUploadTokenURL,
success: function (res) {
var token = res.data.uptoken;
if (token && token.length > 0) {
config.qiniuUploadToken = token;
if (callback) {
callback();
}
} else {
console.error('qiniuUploader cannot get your token, please check the uptokenURL or server')
}
},
fail: function (error) {
console.error('qiniu UploadToken is null, please check the init config or networking: ' + error);
}
})
}
function uploadURLFromRegionCode(code) {
var uploadURL = null;
switch (code) {
case 'ECN': uploadURL = 'https://up.qbox.me'; break;
case 'NCN': uploadURL = 'https://up-z1.qbox.me'; break;
case 'SCN': uploadURL = 'https://up-z2.qbox.me'; break;
case 'NA': uploadURL = 'https://up-na0.qbox.me'; break;
case 'ASG': uploadURL = 'https://up-as0.qbox.me'; break;
default: console.error('please make the region is with one of [ECN, SCN, NCN, NA, ASG]');
}
return uploadURL;
}
})();
\ No newline at end of file
/*!
* Crypto-JS v1.1.0
* http://code.google.com/p/crypto-js/
* Copyright (c) 2009, Jeff Mott. All rights reserved.
* http://code.google.com/p/crypto-js/wiki/License
*/
const Crypto = require('./crypto.js');
(function(){
// Shortcut
var util = Crypto.util;
// Public API
var SHA1 = Crypto.SHA1 = function (message, options) {
var digestbytes = util.wordsToBytes(SHA1._sha1(message));
return options && options.asBytes ? digestbytes :
options && options.asString ? util.bytesToString(digestbytes) :
util.bytesToHex(digestbytes);
};
// The core
SHA1._sha1 = function (message) {
var m = util.stringToWords(message),
l = message.length * 8,
w = [],
H0 = 1732584193,
H1 = -271733879,
H2 = -1732584194,
H3 = 271733878,
H4 = -1009589776;
// Padding
m[l >> 5] |= 0x80 << (24 - l % 32);
m[((l + 64 >>> 9) << 4) + 15] = l;
for (var i = 0; i < m.length; i += 16) {
var a = H0,
b = H1,
c = H2,
d = H3,
e = H4;
for (var j = 0; j < 80; j++) {
if (j < 16) w[j] = m[i + j];
else {
var n = w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16];
w[j] = (n << 1) | (n >>> 31);
}
var t = ((H0 << 5) | (H0 >>> 27)) + H4 + (w[j] >>> 0) + (
j < 20 ? (H1 & H2 | ~H1 & H3) + 1518500249 :
j < 40 ? (H1 ^ H2 ^ H3) + 1859775393 :
j < 60 ? (H1 & H2 | H1 & H3 | H2 & H3) - 1894007588 :
(H1 ^ H2 ^ H3) - 899497514);
H4 = H3;
H3 = H2;
H2 = (H1 << 30) | (H1 >>> 2);
H1 = H0;
H0 = t;
}
H0 += a;
H1 += b;
H2 += c;
H3 += d;
H4 += e;
}
return [H0, H1, H2, H3, H4];
};
// Package private blocksize
SHA1._blocksize = 16;
})();
module.exports = Crypto;
\ No newline at end of file
import request from "./../core/request.js";
const {
chooseImage,
chooseVideo,
qiniuUpload,
aliUpload,
urlUpload
} = require("./utils");
import {
mergeConfig
} from "./../core/utils.js";
export default class fileUpload extends request {
constructor(props) {
// 调用实现父类的构造函数
super(props);
}
//七牛云上传图片
async qnImgUpload(options = {}) {
let files;
try {
files = await chooseImage(options);
// 选择完成回调
options.onSelectComplete && options.onSelectComplete(files);
} catch (err) {
this.requestError && this.requestError(err);
return Promise.reject(err);
}
if (files) {
return this.qnFileUpload({
...options,
files: files
});
}
}
//七牛云上传视频
async qnVideoUpload(options = {}) {
let files;
try {
files = await chooseVideo(options);
// 选择完成回调
options.onSelectComplete && options.onSelectComplete(files);
} catch (err) {
this.requestError && this.requestError(err);
return Promise.reject(err);
}
if (files) {
return this.qnFileUpload({
...options,
files: files
});
}
}
//七牛云文件上传(支持多张上传)
async qnFileUpload(options = {}) {
let requestInfo;
try {
// 数据合并
requestInfo = {
...this.config,
...options,
header: {},
method: "FILE"
};
//请求前回调
if (this.requestStart) {
let requestStart = this.requestStart(requestInfo);
if (typeof requestStart == "object") {
let changekeys = ["load", "files"];
changekeys.forEach(key => {
requestInfo[key] = requestStart[key];
});
} else {
throw {
errMsg: "【request】请求开始拦截器未通过",
statusCode: 0,
data: requestInfo.data,
method: requestInfo.method,
header: requestInfo.header,
url: requestInfo.url,
}
}
}
let requestResult = await qiniuUpload(requestInfo, this.getQnToken);
return Promise.resolve(requestResult);
} catch (err) {
this.requestError && this.requestError(err);
return Promise.reject(err);
} finally {
this.requestEnd && this.requestEnd(requestInfo);
}
}
//阿里云上传图片
async aliImgUpload(options = {}) {
let files;
try {
files = await chooseImage(options);
// 选择完成回调
options.onSelectComplete && options.onSelectComplete(files);
} catch (err) {
this.requestError && this.requestError(err);
return Promise.reject(err);
}
if (files) {
return this.aliFileUpload({
...options,
files: files
});
}
}
//阿里云上传视频
async aliVideoUpload(options = {}) {
let files;
try {
files = await chooseVideo(options);
// 选择完成回调
options.onSelectComplete && options.onSelectComplete(files);
} catch (err) {
this.requestError && this.requestError(err);
return Promise.reject(err);
}
if (files) {
return this.aliFileUpload({
...options,
files: files
});
}
}
//阿里云文件上传(支持多张上传)
async aliFileUpload(options = {}) {
let requestInfo;
try {
// 数据合并
requestInfo = {
...this.config,
...options,
header: {},
method: "FILE"
};
//请求前回调
if (this.requestStart) {
let requestStart = this.requestStart(requestInfo);
if (typeof requestStart == "object") {
let changekeys = ["load", "files"];
changekeys.forEach(key => {
requestInfo[key] = requestStart[key];
});
} else {
throw {
errMsg: "【request】请求开始拦截器未通过",
statusCode: 0,
data: requestInfo.data,
method: requestInfo.method,
header: requestInfo.header,
url: requestInfo.url,
}
}
}
let requestResult = await aliUpload(requestInfo, this.getAliToken);
return Promise.resolve(requestResult);
} catch (err) {
this.requestError && this.requestError(err);
return Promise.reject(err);
} finally {
this.requestEnd && this.requestEnd(requestInfo);
}
}
//本地服务器图片上传
async urlImgUpload() {
let options = {};
if (arguments[0]) {
if (typeof(arguments[0]) == "string") {
options.url = arguments[0];
} else if (typeof(arguments[0]) == "object") {
options = Object.assign(options, arguments[0]);
}
}
if (arguments[1] && typeof(arguments[1]) == "object") {
options = Object.assign(options, arguments[1]);
}
try {
options.files = await chooseImage(options);
// 选择完成回调
options.onSelectComplete && options.onSelectComplete(options.files);
} catch (err) {
this.requestError && this.requestError(err);
return Promise.reject(err);
}
if (options.files) {
return this.urlFileUpload(options);
}
}
//本地服务器上传视频
async urlVideoUpload() {
let options = {};
if (arguments[0]) {
if (typeof(arguments[0]) == "string") {
options.url = arguments[0];
} else if (typeof(arguments[0]) == "object") {
options = Object.assign(options, arguments[0]);
}
}
if (arguments[1] && typeof(arguments[1]) == "object") {
options = Object.assign(options, arguments[1]);
}
try {
options.files = await chooseVideo(options);
// 选择完成回调
options.onSelectComplete && options.onSelectComplete(options.files);
} catch (err) {
this.requestError && this.requestError(err);
return Promise.reject(err);
}
if (options.files) {
return this.urlFileUpload(options);
}
}
//本地服务器文件上传方法
async urlFileUpload() {
let requestInfo = {
method: "FILE"
};
if (arguments[0]) {
if (typeof(arguments[0]) == "string") {
requestInfo.url = arguments[0];
} else if (typeof(arguments[0]) == "object") {
requestInfo = Object.assign(requestInfo, arguments[0]);
}
}
if (arguments[1] && typeof(arguments[1]) == "object") {
requestInfo = Object.assign(requestInfo, arguments[1]);
}
if (!requestInfo.url && this.defaultUploadUrl) {
requestInfo.url = this.defaultUploadUrl;
}
if (!requestInfo.name && this.defaultFileName) {
requestInfo.name = this.defaultFileName;
}
// 请求数据
// 是否运行过请求开始钩子
let runRequestStart = false;
try {
if (!requestInfo.url) {
throw {
errMsg: "【request】文件上传缺失数据url",
statusCode: 0,
data: requestInfo.data,
method: requestInfo.method,
header: requestInfo.header,
url: requestInfo.url,
}
}
// 数据合并
requestInfo = mergeConfig(this, requestInfo);
// 代表之前运行到这里
runRequestStart = true;
//请求前回调
if (this.requestStart) {
let requestStart = this.requestStart(requestInfo);
if (typeof requestStart == "object") {
let changekeys = ["data", "header", "isPrompt", "load", "isFactory", "files"];
changekeys.forEach(key => {
requestInfo[key] = requestStart[key];
});
} else {
throw {
errMsg: "【request】请求开始拦截器未通过",
statusCode: 0,
data: requestInfo.data,
method: requestInfo.method,
header: requestInfo.header,
url: requestInfo.url,
}
}
}
let requestResult = await urlUpload(requestInfo, this.dataFactory);
return Promise.resolve(requestResult);
} catch (err) {
this.requestError && this.requestError(err);
return Promise.reject(err);
} finally {
if (runRequestStart) {
this.requestEnd && this.requestEnd(requestInfo);
}
}
}
}
This diff is collapsed.
import request from "./request";
// 全局配置的请求域名
// let baseUrl = 'https://jdorder.uzosp.com/'; // 正式服务域名接口
let baseUrl = 'https://r.ucaret.cn/test-api'; // 测试服务域名接口
//可以new多个request来支持多个域名请求
let $http = new request({
//接口请求地址
baseUrl: baseUrl,
//服务器本地上传文件地址
fileUrl: baseUrl,
// 服务器上传图片默认url
defaultUploadUrl: "api/Upload/upload",
//设置请求头(如果使用报错跨域问题,可能是content-type请求类型和后台那边设置的不一致)
header: {
'Content-Type': 'application/json;charset=UTF-8'
},
timeout: 30000,
// 默认配置(可不写)
config: {
// 是否自动提示错误
isPrompt: true,
// 是否显示加载动画
load: true,
// 是否使用数据工厂
isFactory: true
}
});
// 添加获取七牛云token的方法
$http.getQnToken = function(callback) {
//该地址需要开发者自行配置(每个后台的接口风格都不一样)
$http.get("api/Upload/getoss_parame").then(data => {
//console.log(data);
/*
*接口返回参数:
*visitPrefix:访问文件的域名
*token:七牛云上传token
*folderPath:上传的文件夹
*region: 地区 默认为:SCN
*/
callback({
visitPrefix: data.domain,
token: data.token,
folderPath: 'imgupload/',
region: "SCN"
});
});
}
// 添加获取阿里云token的方法
$http.getAliToken = function(callback) {
//该地址需要开发者自行配置(每个后台的接口风格都不一样)
$http.get("api/open/v1/ali_oss_upload").then(data => {
/*
*接口返回参数:
*visitPrefix: 访问文件的域名
*folderPath: 上传的文件夹
*region: 地区
*bucket: 阿里云的 bucket
*accessKeyId: 阿里云的访问ID
*accessKeySecret: 阿里云的访问密钥
*stsToken: 阿里云的访问token
*/
callback({
accessKeyId: data.accessKeyId,
accessKeySecret: data.accessKeySecret,
bucket: data.bucket,
region: data.region,
visitPrefix: data.visitPrefix,
token: data.token,
folderPath: data.folderPath,
stsToken: data.securityToken,
});
});
}
//当前接口请求数
let requestNum = 0;
//请求开始拦截器
$http.requestStart = function(options) {
if (options.load) {
if (requestNum <= 0) {
//打开加载动画
uni.showLoading({
title: '加载中',
mask: true
});
}
requestNum += 1;
}
// 图片、视频上传大小限制
if (options.method == "FILE") {
// 文件最大字节: options.maxSize 可以在调用方法的时候加入参数
let maxSize = options.maxSize || '';
for (let item of options.files) {
if (item.fileType == 'image') {
if (maxSize && item.size > maxSize) {
setTimeout(() => {
uni.showToast({
title: "图片过大,请重新上传",
icon: "none"
});
}, 500);
return false;
}
} else if (item.fileType == "video") {
if (item.duration < 3) {
setTimeout(() => {
uni.showToast({
title: "视频长度不足3秒,请重新上传",
icon: "none"
});
}, 500);
return false;
}
}
}
}
//请求前加入token
options.header['Authorization'] ='Bearer '+ uni.getStorageSync('userToken');
return options;
}
//请求结束
$http.requestEnd = function(options) {
//判断当前接口是否需要加载动画
if (options.load) {
requestNum = requestNum - 1;
if (requestNum <= 0) {
uni.hideLoading();
}
}
}
//登录弹窗次数
let loginPopupNum = 0;
//所有接口数据处理(可在接口里设置不调用此方法)
//此方法需要开发者根据各自的接口返回类型修改,以下只是模板
$http.dataFactory = async function(res) {
// console.log("接口请求数据", {
// url: res.url,
// resolve: res.response,
// header: res.header,
// data: res.data,
// method: res.method,
// });
uni.hideLoading()
if (res.response.statusCode && res.response.statusCode == 200) {
let httpData = res.response.data;
console.log(httpData,"封装请求响应数据55555");
let currentRoutes = getCurrentPages();
let currentRoute = currentRoutes[currentRoutes.length - 1].route
if (typeof(httpData) == "string") {
httpData = JSON.parse(httpData);
}
//判断数据是否请求成功
if (httpData.code == 200) {
// 返回正确的结果(then接受数据)
return Promise.resolve(httpData.data);
} else if (httpData.code == 101) {
// uni.showToast({
// title: '请重新登录',
// icon: 'none',
// duration: 1000
// })
// #ifdef APP-PLUS
setTimeout(() => {
uni.navigateTo({
url: '/pages/login/login'
})
}, 800)
// #endif
} else if (httpData.code == 401) {
uni.showToast({
title: '登录过期,请重新登录',
icon: 'none',
duration: 1000
})
setTimeout(() => {
if(loginPopupNum <= 0){
loginPopupNum ++
uni.removeStorageSync('userToken')
let returnPage= '/pages/main';
let pageType = "reLaunch"
uni.navigateTo({
url:"/pages/login/index/index?returnPage="+returnPage+'&pageType='+pageType,
})
}
}, 800)
} else { //其他错误提示
if (res.isPrompt) {
uni.showToast({
title: httpData.info || httpData.msg,
icon: "none",
duration: 2000
});
}
// 返回错误的结果(catch接受数据)
return Promise.reject({
statusCode: 0,
errMsg: httpData.info || httpData.msg,
status: httpData.code
});
}
/*********以上只是模板(及共参考),需要开发者根据各自的接口返回类型修改*********/
} else {
// 返回错误的结果(catch接受数据)
return Promise.reject({
statusCode: res.response.statusCode,
errMsg: "【request】数据工厂验证不通过"
});
}
};
// 错误回调
$http.requestError = function(e) {
if (e.statusCode === 0) {
throw e;
} else {
uni.showToast({
title: "网络错误,请检查一下网络",
icon: "none",
duration: 2000
});
}
}
export default $http;
...@@ -5,12 +5,15 @@ import store from "./store"; ...@@ -5,12 +5,15 @@ import store from "./store";
Vue.prototype.$store = store; Vue.prototype.$store = store;
import http from "./common/api/api.js" import http from "./common/api/api.js"
import $http from '@/common/zhouWei-request/requestConfig';
Vue.config.productionTip = false Vue.config.productionTip = false
import ActiveForm from "@/common/active-form/active-form"; import ActiveForm from "@/common/active-form/active-form";
import scrollList from "@/common/scroll-list/scroll-list"; import scrollList from "@/common/scroll-list/scroll-list";
Vue.use(uView); Vue.use(uView);
Vue.prototype.http = http Vue.prototype.http = http
Vue.prototype.$http = $http
// 订阅消息模板id // 订阅消息模板id
Vue.prototype.nc_templateid = '59-hfHg3CnDvgVEnjqxiHRFwpABehc5lZxHQeUctlrg' Vue.prototype.nc_templateid = '59-hfHg3CnDvgVEnjqxiHRFwpABehc5lZxHQeUctlrg'
App.mpType = 'app' App.mpType = 'app'
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
"quickapp" : {}, "quickapp" : {},
/* 小程序特有相关 */ /* 小程序特有相关 */
"mp-weixin" : { "mp-weixin" : {
"appid" : "wx237e45bea2220a37", "appid" : "wx8fd4dc1c4b9f6f41",
"setting" : { "setting" : {
"urlCheck" : false, "urlCheck" : false,
"minified" : true, "minified" : true,
...@@ -67,11 +67,7 @@ ...@@ -67,11 +67,7 @@
"postcss" : false "postcss" : false
}, },
"usingComponents" : true, "usingComponents" : true,
"permission" : { "permission" : {},
"scope.userLocation" : {
"desc" : "你的位置信息将用于定位"
}
},
"plugins" : { "plugins" : {
"loginPlugin" : { "loginPlugin" : {
"version" : "1.5.4", "version" : "1.5.4",
......
...@@ -9,5 +9,8 @@ ...@@ -9,5 +9,8 @@
"表单校验", "表单校验",
"快速生成表单", "快速生成表单",
"全端" "全端"
] ],
} "dependencies": {
\ No newline at end of file "crypto-js": "^4.1.1"
}
}
This diff is collapsed.
...@@ -87,28 +87,18 @@ ...@@ -87,28 +87,18 @@
if (path) { if (path) {
let paths = path.split('?')[1] let paths = path.split('?')[1]
let scene = paths.split("=")[1] let scene = paths.split("=")[1]
let param = { this.$http.request({
code: scene url:'/app/user/check/move/code',
} method:'post',
let opts = { data:{
url: '/app/user/check/move/code', code: scene
method: 'post' },
} }).then(res => {
that.http.httpTokenRequest(opts, param).then(res => {
console.log(res, "扫码通知车主") console.log(res, "扫码通知车主")
if (res.data.code == 200) { if (res.bindFlag) {
if (res.data.data.bindFlag) { that.gotoMoveCar(scene)
that.gotoMoveCar(scene)
} else {
that.gotoBindMoveCar(scene)
}
} else { } else {
uni.showToast({ that.gotoBindMoveCar(scene)
title: res.data.msg,
icon: 'none',
icon: 'error',
})
} }
}) })
} else { } else {
......
...@@ -127,31 +127,22 @@ export default { ...@@ -127,31 +127,22 @@ export default {
}, },
methods: { methods: {
loginOut() { loginOut() {
let opts = { this.$http.request({
url: '/logout', url:'/logout',
method: 'post' method:'post',
}; data:{},
this.http.httpTokenRequest(opts, {}).then(res => { }).then(res => {
if (res.data.code == 200) { this.token = null
this.token = null uni.removeStorageSync('userToken')
uni.removeStorageSync('userToken') uni.removeStorageSync('xcxIndexPath')
uni.removeStorageSync('xcxIndexPath') // uni.removeStorageSync('openid')
// uni.removeStorageSync('openid') plugin.logout().then((res) => {
plugin.logout().then((res) => { console.jdLoginLog(res, 'logoutres');
console.jdLoginLog(res, 'logoutres'); uni.reLaunch({
uni.reLaunch({ url: '/pages/main'
url: '/pages/main'
});
}); });
}else{ });
uni.showToast({ })
title: res.data.msg,
icon: 'none',
duration: 2000
});
}
})
}, },
goOrder(current) { goOrder(current) {
let token = uni.getStorageSync('userToken'); let token = uni.getStorageSync('userToken');
...@@ -226,18 +217,16 @@ export default { ...@@ -226,18 +217,16 @@ export default {
this.logoutFlag = false this.logoutFlag = false
return return
} }
let opts = { await this.$http.request({
url: '/app/user/info', url:'/app/user/info',
method: 'get' method:'get',
}; data:{},
await this.http.httpTokenRequest(opts, {}).then(res => { }).then(res => {
if (res.data.code == 200) { this.userInfo = res || {}
this.userInfo = res.data.data if(this.userInfo.avatar){
if(this.userInfo.avatar){ this.avatar = this.userInfo.avatar
this.avatar = this.userInfo.avatar }
} })
}
})
}, },
openMsg() { openMsg() {
var that = this; var that = this;
......
...@@ -96,64 +96,6 @@ export default { ...@@ -96,64 +96,6 @@ export default {
this.scrollTop = 0 this.scrollTop = 0
}); });
}, },
// 加载数据
load(paging) {
setTimeout(() => {
let opts = {
url: '/app/index/mall/list?pageSize=' + paging.size + '&pageNum=' + paging.page,
method: 'get'
};
this.http.httpRequest(opts, {
classification: "2"
}).then(res => {
if (res.data.code == 200) {
let list = res.data.data.rows || []
this.boutiqueMallList = [...this.boutiqueMallList, ...list];
// 加载成功 参数对象{list: 当前列表,total: 数据总长度(后端查询的total)}
this.$refs.list.loadSuccess({
list: this.boutiqueMallList,
total: res.data.data.total
});
} else {
// 加载失败
this.$refs.list.loadFail()
}
})
}, this.$u.random(100, 1000));
},
// 刷新
refresh(paging) {
setTimeout(() => {
let opts = {
url: '/app/index/mall/list?pageSize=' + paging.size + '&pageNum=' + paging.page,
method: 'get'
};
this.http.httpRequest(opts, {
classification: "2"
}).then(res => {
if (res.data.code == 200) {
let list = res.data.data.rows || []
this.boutiqueMallList = list;
// 加载成功 参数对象{list: 当前列表,total: 数据总长度(后端查询的total)}
this.$refs.list.refreshSuccess({
list: this.boutiqueMallList,
total: res.data.data.total
});
// 加载失败
// this.$refs.list.loadFail()
} else {
this.$refs.list.refreshFail()
uni.showToast({
title: res.data.msg,
icon: 'none',
duration: 2000
});
}
})
}, this.$u.random(100, 1000));
},
goSearch() { goSearch() {
uni.navigateTo({ uni.navigateTo({
url: '/pagesC/pages/shop/search' url: '/pagesC/pages/shop/search'
...@@ -193,79 +135,59 @@ export default { ...@@ -193,79 +135,59 @@ export default {
// }) // })
}, },
getMallList() { getMallList() {
let opts = { this.$http.request({
url: '/app/index/mall/list', url:'/app/index/mall/list',
method: 'get' method:'get',
}; data:{
this.http.httpTokenRequest(opts, { classification: "1"
classification: "1" },
}).then(res => { }).then(res => {
if (res.data.code == 200) { this.mallList = res.rows || []
this.mallList = res.data.data.rows || [] })
}else{
uni.showToast({
title: res.data.msg,
icon: 'none',
duration: 2000
});
}
})
}, },
getBoutiqueMallList() { getBoutiqueMallList() {
let opts = { this.$http.request({
url: '/app/index/mall/list', url:'/app/index/mall/list',
method: 'get' method:'get',
}; data:{
this.http.httpTokenRequest(opts, { classification: "2",
classification: "2", pageSize:10,
pageSize:10, pageNum:this.page
pageNum:this.page },
}).then(res => { }).then(res => {
if (res.data.code == 200) { let data = res.rows || [];
let data = res.data.data.rows || []; data.forEach(elem=>{
data.forEach(elem=>{ this.boutiqueMallList.push(elem)
this.boutiqueMallList.push(elem) })
}) if(data.length < 10){
if(data.length < 10){ uni.setStorageSync('refresh',1)
uni.setStorageSync('refresh',1) this.loading = "nomore"
this.loading = "nomore" }else{
}else{ uni.setStorageSync('refresh',0)
uni.setStorageSync('refresh',0) this.loading = "loadmore"
this.loading = "loadmore"
}
}else{
uni.showToast({
title: res.data.msg,
icon: 'none',
duration: 2000
});
} }
}) })
}, },
getImage(imageUrl) { getImage(imageUrl) {
return imageUrl; return imageUrl;
}, },
getRotationList() { getRotationList() {
this.$http.request({
url:'/app/index/carouse/2',
method:'get',
data:{},
}).then(res => {
let data = res || []
let imgList = []
data.forEach(e => {
imgList.push(e)
})
this.list3 = imgList
})
let opts = { let opts = {
url: '/app/index/carouse/2', url: '/app/index/carouse/2',
method: 'get' method: 'get'
}; };
this.http.httpTokenRequest(opts, {}).then(res => {
if (res.data.code == 200) {
let data = res.data.data || []
let imgList = []
data.forEach(e => {
imgList.push(e)
})
this.list3 = imgList
}else{
uni.showToast({
title: res.data.msg,
icon: 'none',
duration: 2000
});
}
})
}, },
// 轮播跳转其他页面 // 轮播跳转其他页面
goOtherLink(index){ goOtherLink(index){
......
...@@ -71,62 +71,59 @@ ...@@ -71,62 +71,59 @@
}) })
}, },
getApplyMoveLog() { getApplyMoveLog() {
let opts = { this.$http.request({
url: '/app/moveLog/apply/' + this.id, url:'/app/moveLog/apply/' + this.id,
method: 'get' method:'get',
}; data:{},
let that = this }).then(res => {
this.http.httpTokenRequest(opts, {}).then(res => { this.moveLog = res || {}
if (res.data.code == 200) { let moveLogInfo = []
this.moveLog = res.data.data moveLogInfo.push({
let moveLogInfo = [] title: "车主车牌号:",
moveLogInfo.push({ value: this.moveLog.carNo
title: "车主车牌号:", })
value: this.moveLog.carNo moveLogInfo.push({
}) title: "品牌:",
moveLogInfo.push({ value: this.moveLog.brand || ''
title: "品牌:", })
value: this.moveLog.brand || '' moveLogInfo.push({
}) title: "车型:",
value: this.moveLog.carModel || ''
})
if (this.moveLog.confirmType == '1') {
moveLogInfo.push({ moveLogInfo.push({
title: "车:", title: "车主手机号:",
value: this.moveLog.carModel || '' value: this.moveLog.userMobile || ''
}) })
if (this.moveLog.confirmType == '1') { }
moveLogInfo.push({ moveLogInfo.push({
title: "车主手机号:", title: "时间:",
value: this.moveLog.userMobile || '' value: this.moveLog.applyDate
}) })
} moveLogInfo.push({
title: "地点:",
value: this.moveLog.detailInfo
})
if (this.moveLog.confirmType == '1') {
moveLogInfo.push({ moveLogInfo.push({
title: "时间:", title: "申请手机号:",
value: this.moveLog.applyDate value: this.moveLog.applyUserMobile || ''
}) })
moveLogInfo.push({ moveLogInfo.push({
title: "地点:", title: "通知方式:",
value: this.moveLog.detailInfo value: "拨打电话"
}) })
if (this.moveLog.confirmType == '1') { } else {
moveLogInfo.push({
title: "申请手机号:",
value: this.moveLog.applyUserMobile || ''
})
moveLogInfo.push({
title: "通知方式:",
value: "拨打电话"
})
} else {
moveLogInfo.push({
title: "通知方式:",
value: "微信通知"
})
}
moveLogInfo.push({ moveLogInfo.push({
title: "通知类型:", title: "通知方式:",
value: "请求他人挪车" value: "微信通知"
}) })
this.items = moveLogInfo
} }
moveLogInfo.push({
title: "通知类型:",
value: "请求他人挪车"
})
this.items = moveLogInfo
}) })
}, },
}, },
......
...@@ -89,7 +89,7 @@ export default { ...@@ -89,7 +89,7 @@ export default {
}, },
//确认删除车辆 //确认删除车辆
confirmModal(){ confirmModal(){
let opts = { url: '/app/vehicleAdmin/remove/' + this.carId, method: 'delete' }; let opts = { url: '/app/vehicleAdmin/remove/' + this.carId, method: 'delete' };
this.http.httpTokenRequest(opts, {}).then(res => { this.http.httpTokenRequest(opts, {}).then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
uni.showToast({ uni.showToast({
...@@ -110,16 +110,24 @@ export default { ...@@ -110,16 +110,24 @@ export default {
this.deleteShow = false this.deleteShow = false
}, },
getCarList(){ getCarList(){
uni.showLoading({ // uni.showLoading({
title: '加载中', // title: '加载中',
mask:true // mask:true
}); // });
let opts = { url: '/app/vehicleAdmin/list', method: 'get' }; // let opts = { url: '/app/vehicleAdmin/list', method: 'get' };
this.http.httpTokenRequest(opts, {}).then(res => { // this.http.httpTokenRequest(opts, {}).then(res => {
if (res.statusCode == 200) { // if (res.statusCode == 200) {
uni.hideLoading() // uni.hideLoading()
this.carList = res.data || [] // this.carList = res.data || []
} // }
// })
this.$http.request({
url:'/app/vehicleAdmin/list',
method:'get',
data:{},
isFactory:false,
}).then(res => {
this.carList = res.data || []
}) })
}, },
goGetPrice(id){ goGetPrice(id){
......
...@@ -51,54 +51,47 @@ export default { ...@@ -51,54 +51,47 @@ export default {
}) })
}, },
getMoveCode(){ getMoveCode(){
uni.showLoading({ this.$http.request({
title: '加载中', url:'/app/moveCode/' + this.id,
mask:true method:'get',
}); data:{},
let opts = { url: '/app/moveCode/' + this.id, method: 'get' }; }).then(res => {
this.http.httpTokenRequest(opts, {}).then(res => { let data = res || []
uni.hideLoading() let list = []
if (res.data.code == 200) { list.push({title: "挪车码编号", value: data.moveCode})
let data = res.data.data list.push({title: "车牌号", value: data.carNo})
let list = [] if(data.brand){
list.push({title: "挪车码编号", value: data.moveCode}) list.push({title: "品牌", value: data.brand})
list.push({title: "车牌号", value: data.carNo}) }else{
if(data.brand){ list.push({title: "品牌", value: ""})
list.push({title: "品牌", value: data.brand})
}else{
list.push({title: "品牌", value: ""})
}
if(data.carModel){
list.push({title: "车型", value: data.carModel})
}else{
list.push({title: "车型", value: ""})
}
list.push({title: "绑定手机号", value: data.userMobile})
this.items = list
} }
if(data.carModel){
list.push({title: "车型", value: data.carModel})
}else{
list.push({title: "车型", value: ""})
}
list.push({title: "绑定手机号", value: data.userMobile})
this.items = list
}) })
}, },
openUnbindModal(){ openUnbindModal(){
this.unbindShow = true this.unbindShow = true
}, },
unbind(){ unbind(){
let opts = { url: '/app/moveCode/edit/' + this.id, method: 'put' }; this.$http.request({
this.http.httpTokenRequest(opts, {}).then(res => { url:'/app/moveCode/edit/' + this.id,
if (res.data.code == 200) { method:'put',
uni.showToast({ data:{},
title: '解绑成功', }).then(res => {
icon: "success", uni.showToast({
}); title: '解绑成功',
}else{ icon: "success",
uni.showToast({ });
title: res.data.msg, this.unbindShow = false
icon: "error", setTimeout(()=>{
}); this.goBack()
} },500)
this.unbindShow = false })
this.goBack()
})
}, },
cancelModal(){ cancelModal(){
this.unbindShow = false this.unbindShow = false
......
...@@ -54,15 +54,16 @@ ...@@ -54,15 +54,16 @@
load(paging) { load(paging) {
setTimeout(() => { setTimeout(() => {
let list = []; let list = [];
let opts = { this.$http.request({
url: '/app/moveLog/apply/list?pageSize=' + paging.size + '&pageNum=' + paging.page, url: '/app/moveLog/apply/list?pageSize=' + paging.size + '&pageNum=' + paging.page,
method: 'get' method:'get',
}; data:{},
this.http.httpTokenRequest(opts, {}).then(res => { isFactory:false,
}).then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
list = res.data.rows || [] list = res.data.rows || []
this.items = [...this.items, ...list] this.items = [...this.items, ...list]
// 加载成功 参数对象{list: 当前列表,total: 数据总长度(后端查询的total)} // 加载成功 参数对象{list: 当前列表,total: 数据总长度(后端查询的total)}
this.$refs.list.loadSuccess({ this.$refs.list.loadSuccess({
list: this.items, list: this.items,
...@@ -84,15 +85,16 @@ ...@@ -84,15 +85,16 @@
refresh(paging) { refresh(paging) {
setTimeout(() => { setTimeout(() => {
let list = []; let list = [];
let opts = { this.$http.request({
url: '/app/moveLog/apply/list?pageSize=' + paging.size + '&pageNum=' + paging.page, url:'/app/moveLog/apply/list?pageSize=' + paging.size + '&pageNum=' + paging.page,
method: 'get' method:'get',
}; data:{},
this.http.httpTokenRequest(opts, {}).then(res => { isFactory:false,
}).then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
list = res.data.rows || [] list = res.data.rows || []
this.items = list this.items = list
// 加载成功 参数对象{list: 当前列表,total: 数据总长度(后端查询的total)} // 加载成功 参数对象{list: 当前列表,total: 数据总长度(后端查询的total)}
this.$refs.list.refreshSuccess({ this.$refs.list.refreshSuccess({
list: this.items, list: this.items,
......
...@@ -91,9 +91,12 @@ export default { ...@@ -91,9 +91,12 @@ export default {
}) })
}, },
getMyMoveCodeList(){ getMyMoveCodeList(){
this.$http.request({
let opts = { url: '/app/moveCode/list?carNo=' + this.keyword, method: 'get' }; url:'/app/moveCode/list?carNo=' + this.keyword,
this.http.httpTokenRequest(opts, {}).then(res => { method:'get',
data:{},
isFactory:false,
}).then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
this.items = res.data.rows || [] this.items = res.data.rows || []
} else { } else {
...@@ -109,8 +112,12 @@ export default { ...@@ -109,8 +112,12 @@ export default {
this.unbindShow = true this.unbindShow = true
}, },
unbind(){ unbind(){
let opts = { url: '/app/moveCode/edit/' + this.id, method: 'put' }; this.$http.request({
this.http.httpTokenRequest(opts, {}).then(res => { url:'/app/moveCode/edit/' + this.id,
method:'put',
data:{},
isFactory:false,
}).then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
uni.showToast({ uni.showToast({
title: '解绑成功', title: '解绑成功',
......
This diff is collapsed.
...@@ -148,15 +148,15 @@ ...@@ -148,15 +148,15 @@
}, },
call() { call() {
this.appBo.moveCode = this.moveCode this.appBo.moveCode = this.moveCode
let opts = { this.$http.request({
url: '/app/contact/phone/notice', url:'/app/contact/phone/notice',
method: 'post' method:'post',
}; data:this.appBo,
this.http.httpTokenRequest(opts, this.appBo).then(res => { isFactory:false,
}).then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
//请求成功逻辑,修改 //请求成功逻辑,修改
this.noticeResult = res.data.data this.noticeResult = res.data.data
uni.hideLoading()
if (this.noticeResult.allowPhone) { if (this.noticeResult.allowPhone) {
// this.list[0].name = this.noticeResult.secretPhone // this.list[0].name = this.noticeResult.secretPhone
// this.show = true; // this.show = true;
...@@ -166,7 +166,6 @@ ...@@ -166,7 +166,6 @@
} }
} else { } else {
this.noticeResult = res.data.data this.noticeResult = res.data.data
uni.hideLoading()
if (this.noticeResult) { if (this.noticeResult) {
uni.showModal({ uni.showModal({
content: this.noticeResult.notAllowPhoneReason, content: this.noticeResult.notAllowPhoneReason,
...@@ -183,11 +182,12 @@ ...@@ -183,11 +182,12 @@
}, },
wechat() { wechat() {
this.appBo.moveCode = this.moveCode this.appBo.moveCode = this.moveCode
let opts = { this.$http.request({
url: '/app/contact/wechat/notice', url:'/app/contact/wechat/notice',
method: 'post' method:'post',
}; data:this.appBo,
this.http.httpTokenRequest(opts, this.appBo).then(res => { isFactory:false,
}).then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
uni.showModal({ uni.showModal({
content: "微信消息发送成功", content: "微信消息发送成功",
...@@ -232,46 +232,29 @@ ...@@ -232,46 +232,29 @@
}, },
// 获取微信通知次数 // 获取微信通知次数
getMoveCode() { getMoveCode() {
let opts = { this.$http.request({
url: '/app/moveCode/notice/config', url:'/app/moveCode/notice/config',
method: 'get' method:'get',
}; data:{},
this.http.httpTokenRequest(opts, {}).then(res => { }).then(res => {
if (res.data.code == 200) { this.wxMaxNum = res.wxMaxNum
this.wxMaxNum = res.data.data.wxMaxNum
} else{
uni.showToast({
title: res.data.msg,
icon: 'none',
duration: 2000
});
}
}) })
}, },
getCarNumber() { getCarNumber() {
let opts = { this.$http.request({
url: '/app/moveCode/owner/' + this.moveCode, url:'/app/moveCode/owner/' + this.moveCode,
method: 'get' method:'get',
}; data:{},
//let opts = { url: '/app/moveCode/owner/MV123', method: 'get' }; }).then(res => {
this.http.httpTokenRequest(opts, {}).then(res => { if (JSON.stringify(res) != "{}") {
if (res.data.code == 200) { let carData = res
if (JSON.stringify(res.data.data) != "{}") { this.appBo.carNo = carData.carNo
let carData = res.data.data this.appBo.brand = carData.brand
this.appBo.carNo = carData.carNo this.appBo.carModel = carData.carModel
this.appBo.brand = carData.brand
this.appBo.carModel = carData.carModel
} else {
uni.navigateTo({
url: '/pagesB/pages/move-car/scan?moveCode=' + this.moveCode
})
}
} else { } else {
//查询挪车码失败 uni.navigateTo({
uni.showToast({ url: '/pagesB/pages/move-car/scan?moveCode=' + this.moveCode
title: res.data.msg, })
icon: "error",
});
} }
}) })
}, },
......
...@@ -38,68 +38,59 @@ ...@@ -38,68 +38,59 @@
}) })
}, },
getMyMoveLog() { getMyMoveLog() {
let opts = { this.$http.request({
url: '/app/moveLog/my/' + this.id, url:'/app/moveLog/my/' + this.id,
method: 'get' method:'get',
}; data:{},
let that = this }).then(res => {
this.http.httpTokenRequest(opts, {}).then(res => { this.moveLog = res
if (res.data.code == 200) { let moveLogInfo = []
this.moveLog = res.data.data moveLogInfo.push({
let moveLogInfo = [] title: "车主车牌号:",
value: this.moveLog.carNo
})
moveLogInfo.push({
title: "品牌:",
value: this.moveLog.brand || ''
})
moveLogInfo.push({
title: "车型:",
value: this.moveLog.carModel || ''
})
if (this.moveLog.confirmType == '1') {
moveLogInfo.push({ moveLogInfo.push({
title: "车主车牌号:", title: "车主手机号:",
value: this.moveLog.carNo value: this.moveLog.userMobile
}) })
}
moveLogInfo.push({
title: "时间:",
value: this.moveLog.applyDate
})
moveLogInfo.push({
title: "地点:",
value: this.moveLog.detailInfo
})
if (this.moveLog.confirmType == '1') {
moveLogInfo.push({ moveLogInfo.push({
title: "品牌:", title: "申请手机号:",
value: this.moveLog.brand || '' value: this.moveLog.applyUserMobile
})
moveLogInfo.push({
title: "车型:",
value: this.moveLog.carModel || ''
})
if (this.moveLog.confirmType == '1') {
moveLogInfo.push({
title: "车主手机号:",
value: this.moveLog.userMobile
})
}
moveLogInfo.push({
title: "时间:",
value: this.moveLog.applyDate
}) })
moveLogInfo.push({ moveLogInfo.push({
title: "地点:", title: "通知方式:",
value: this.moveLog.detailInfo value: "拨打电话"
}) })
if (this.moveLog.confirmType == '1') { } else {
moveLogInfo.push({
title: "申请手机号:",
value: this.moveLog.applyUserMobile
})
moveLogInfo.push({
title: "通知方式:",
value: "拨打电话"
})
} else {
moveLogInfo.push({
title: "通知方式:",
value: "微信通知"
})
}
moveLogInfo.push({ moveLogInfo.push({
title: "通知类型:", title: "通知方式:",
value: "他人请求挪车" value: "微信通知"
}) })
this.items = moveLogInfo
}else{
uni.showToast({
title: res.data.msg,
icon: 'none',
duration: 2000
});
} }
moveLogInfo.push({
title: "通知类型:",
value: "他人请求挪车"
})
this.items = moveLogInfo
}) })
}, },
}, },
......
...@@ -63,44 +63,7 @@ ...@@ -63,44 +63,7 @@
<car-number class="car__input" v-model="model1.carNo"></car-number> <car-number class="car__input" v-model="model1.carNo"></car-number>
</view> </view>
</view> </view>
<!-- <view class="info_list">
<view class="left">
行驶里程:
</view>
<view class="right">
{{carInfo.mileage || 0}}KM
</view>
</view> -->
<!-- <div class="scan__tips">
<div>请填写以下信息</div>
<div @click="goLoveCar">从爱车选择<span>
<image src="@/static/move-car/scan_right.png" /></span></div>
</div>
<div class="car__num__self">
<div class="car__num">车牌号:</div>
<car-number class="car__input" v-model="model1.carInfo.carNo"></car-number>
</div>
<active-form :formDate.sync="formData"></active-form>
<div class="add__user">
<u-checkbox-group placement="row">
<u-checkbox :checked='checked' @change="changeBtn"></u-checkbox>
</u-checkbox-group>
请先阅读并同意<span @click="goArticle(2)">《京东汽车挪车牌隐私权政策》</span>
</div> -->
</div> </div>
<!-- <view class="no-car-info">
<view class="title">
请完成以下操作
</view>
<image src="../../../static/move-car/none.png"></image>
<view class="no-content">
暂无爱车信息,请先添加爱车
</view>
<view class="no-car-btn" @click="getCarList">
从爱车选择
</view>
</view> -->
<view class="form-data"> <view class="form-data">
<view class="form-item"> <view class="form-item">
...@@ -175,6 +138,7 @@ ...@@ -175,6 +138,7 @@
<script> <script>
import CarNumber from "@/common/codecook-carnumber/codecook-carnumber.vue"; import CarNumber from "@/common/codecook-carnumber/codecook-carnumber.vue";
import tools from "@/static/js/crypto-js.js";
export default { export default {
components: { components: {
CarNumber, CarNumber,
...@@ -189,69 +153,6 @@ export default { ...@@ -189,69 +153,6 @@ export default {
carId:"" carId:""
}, },
carInfo: null, carInfo: null,
formData: [
// {
// id: "kjjns", //id必须唯一 可以是数字
// placeholder: "请输入",
// label: "车牌号", // 提示输入名
// type: "text", //类型
// rules: {
// name: "carNo", //字段名 即提交给后端的字段
// value: "",
// verify: false, //是否开启校验
// errMess: "车牌号未填写", //校验不通过的错误提示
// },
// },
// {
// id: "kjjns", //id必须唯一 可以是数字
// placeholder: "请输入",
// label: "品牌:", // 提示输入名
// type: "text", //类型
// rules: {
// name: "brand", //字段名 即提交给后端的字段
// value: "",
// verify: false, //是否开启校验
// errMess: "品牌未填写", //校验不通过的错误提示
// },
// },
// {
// id: "kjjns", //id必须唯一 可以是数字
// placeholder: "请输入",
// label: "车型:", // 提示输入名
// type: "text", //类型
// rules: {
// name: "carModel", //字段名 即提交给后端的字段
// value: "",
// verify: false, //是否开启校验
// errMess: "车型未填写", //校验不通过的错误提示
// },
// },
{
id: "kjjns", //id必须唯一 可以是数字
placeholder: "请输入",
label: "手机号:", // 提示输入名
type: "text", //类型
rules: {
name: "phone", //字段名 即提交给后端的字段userMobile
value: "",
verify: false, //是否开启校验
errMess: "手机号未填写", //校验不通过的错误提示
},
},
{
id: "uisdfjks",
placeholder: "请输入验证码",
label: "验证码:",
type: "text",
// oneKeyPhone:true,
rules: {
name: "yzm",
value: "", //字段值
verify: false,
errMess: "验证码未填写",
},
},
],
//挪车码 //挪车码
moveCode: '', moveCode: '',
//绑定挪车码信息 //绑定挪车码信息
...@@ -295,17 +196,14 @@ export default { ...@@ -295,17 +196,14 @@ export default {
}, },
// 获取爱车列表 // 获取爱车列表
getCarList(){ getCarList(){
uni.showLoading({ this.$http.request({
title: '加载中', url:'/app/vehicleAdmin/list',
mask:true method:'get',
}); data:{},
let opts = { url: '/app/vehicleAdmin/list', method: 'get' }; isFactory:false,
this.http.httpTokenRequest(opts, {}).then(res => { }).then(res => {
if (res.statusCode == 200) { this.carList = res.data || []
uni.hideLoading() this.selectCar = true
this.carList = res.data || []
this.selectCar = true
}
}) })
}, },
// 添加车辆 // 添加车辆
...@@ -332,19 +230,20 @@ export default { ...@@ -332,19 +230,20 @@ export default {
}); });
return; return;
} }
uni.showLoading({ this.$http.request({
title: '加载中', url:'/app/smsCode/binding',
mask:true method:'post',
}); data:{
let opts = { url: '/app/smsCode/binding/', method: 'post' }; phone: this.model1.userMobile
this.http.httpTokenRequest(opts,{phone: this.model1.userMobile}).then(res => { },
isFactory:false,
}).then(res => {
if (res.statusCode == 200) { if (res.statusCode == 200) {
uni.showToast({ uni.showToast({
title: "别着急!短信已经发送了~", title: "别着急!短信已经发送了~",
icon: 'none', icon: 'none',
duration: 1500 duration: 1500
}); });
uni.hideLoading()
if(this.clickStatus == false){ if(this.clickStatus == false){
this.clickStatus = true this.clickStatus = true
let timer = setInterval(() => { let timer = setInterval(() => {
...@@ -365,7 +264,6 @@ export default { ...@@ -365,7 +264,6 @@ export default {
}) })
}, },
confirmBinding() { confirmBinding() {
console.log(this.model1,22222222222)
if(!this.carInfo){ if(!this.carInfo){
uni.showToast({ uni.showToast({
title: "请选择绑定的爱车!", title: "请选择绑定的爱车!",
...@@ -387,78 +285,48 @@ export default { ...@@ -387,78 +285,48 @@ export default {
}); });
return; return;
} }
uni.showLoading({ this.$http.request({
title: '加载中', url:'/app/moveCode/binding',
mask:true method:'put',
}); data:this.model1,
let opts = { }).then(res => {
url: '/app/moveCode/binding/', uni.showToast({
method: 'put' title: "绑定成功",
}; icon: "success",
this.http.httpTokenRequest(opts, this.model1).then(res => { });
if (res.data.code == 200) { setTimeout(()=>{
//展示绑定成功 uni.navigateTo({
uni.showToast({ url: '/pagesB/pages/move-car/myMoveCar'
title: "绑定成功", })
icon: "success", },500)
}); })
uni.hideLoading()
uni.navigateTo({
url: '/pagesB/pages/move-car/myMoveCar'
})
} else {
//绑定失败,展示失败信息
uni.hideLoading()
uni.showToast({
title: res.data.msg,
icon: "none",
});
}
})
}, },
getCarInfo() { getCarInfo() {
if (this.carId) { if (this.carId) {
uni.showLoading({ this.$http.request({
title:"加载中", url:'/app/vehicleAdmin/' + this.carId,
mask:true method:'get',
}) data:{},
let opts = { isFactory:false,
url: '/app/vehicleAdmin/' + this.carId, }).then(res => {
method: 'get' this.model1.carInfo = res
}; })
this.http.httpTokenRequest(opts, {}).then(res => {
if (res.data.code == 200) {
this.model1.carInfo = res.data.data
uni.hideLoading()
this.formData.forEach(e => {
if (e.label == '品牌:') {
e.rules.value = this.model1.carInfo.brand
} else if (e.label == '车型:') {
e.rules.value = this.model1.carInfo.carModel
}
})
}else{
uni.hideLoading()
uni.showToast({
title: res.data.msg,
icon: "none",
});
}
})
} }
}, },
// 跳转协议政策页面 // 跳转协议政策页面
goArticle(index) { goArticle(index) {
let opts = { let url="";
url: '',
method: 'get'
};
if (index == 1) { if (index == 1) {
opts.url = "/app/user/registerAgreement" url = "/app/user/registerAgreement"
} else { } else {
opts.url = "/app/user/ofPrivacy" url = "/app/user/ofPrivacy"
} }
this.http.httpTokenRequest(opts, {}).then(res => { this.$http.request({
url:url,
method:'get',
data:{},
isFactory:false,
}).then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
let data = res.data.msg let data = res.data.msg
uni.setStorageSync("articelContent", data) uni.setStorageSync("articelContent", data)
...@@ -477,6 +345,9 @@ export default { ...@@ -477,6 +345,9 @@ export default {
onLoad(option) { onLoad(option) {
this.moveCode = option.moveCode this.moveCode = option.moveCode
this.model1.moveCode = option.moveCode this.model1.moveCode = option.moveCode
let datajAes = tools.setAES('69703333');
console.log(datajAes,88888888888888)
}, },
onShow:function(){ onShow:function(){
this.getCarInfo() this.getCarInfo()
......
...@@ -58,18 +58,13 @@ export default { ...@@ -58,18 +58,13 @@ export default {
}) })
}, },
getMallInfo(){ getMallInfo(){
let opts = { url: '/app/index/mall/' + this.id, method: 'get' }; this.$http.request({
this.http.httpRequest(opts, {}).then(res => { url:'/app/index/mall/' + this.id,
if (res.data.code == 200) { method:'get',
this.mallInfo = res.data.data data:{}
this.list6 = this.mallInfo.imageUrls }).then(res => {
}else{ this.mallInfo = res || {}
uni.showToast({ this.list6 = this.mallInfo.imageUrls
title: res.data.msg,
icon: 'none',
duration: 2000
});
}
}) })
}, },
}, },
......
...@@ -3,197 +3,194 @@ ...@@ -3,197 +3,194 @@
* @Description: 搜索商品 * @Description: 搜索商品
--> -->
<template> <template>
<view class="appCotent"> <view class="appCotent">
<div class="myMoveCar"> <div class="myMoveCar">
<div class="my__search"> <div class="my__search">
<u-search placeholder="请输入商品" :showAction='false' bgColor='#ffffff' v-model="keyword" @change="searchCommodity"></u-search> <u-search placeholder="请输入商品" :showAction='false' bgColor='#ffffff' v-model="keyword"
</div> @change="searchCommodity"></u-search>
<div class="list"> </div>
<div class="list__item" v-for="(vo,inx) in items" :key="inx" @click="goDetail(vo.id,vo.link)"> <div class="list">
<div class="list__img"> <div class="list__item" v-for="(vo,inx) in items" :key="inx" @click="goDetail(vo.id,vo.link)">
<!-- <image :src="vo.img" /> --> <div class="list__img">
<image :src="vo.mainImgUrl" style="width: 160rpx;height: 160rpx;border-radius:10rpx;"></image> <!-- <image :src="vo.img" /> -->
</div> <image :src="vo.mainImgUrl" style="width: 160rpx;height: 160rpx;border-radius:10rpx;"></image>
<div class="list__money"> </div>
<div class="money__title"> <div class="list__money">
<text>{{vo.title}}</text> <div class="money__title">
</div> <text>{{vo.title}}</text>
<div class="code__tips"> </div>
<text>{{vo.spec}}</text> <div class="code__tips">
</div> <text>{{vo.spec}}</text>
<div class="money__num"> </div>
<text class="num__one">¥{{vo.currentPrice/100}}</text> <div class="money__num">
<text class="num__two">¥{{vo.originalPrice/100}}</text> <text class="num__one">¥{{vo.currentPrice/100}}</text>
</div> <text class="num__two">¥{{vo.originalPrice/100}}</text>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</view> </div>
</view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
keyword: '', keyword: '',
items: [], items: [],
timer:null timer: null
}; };
}, },
methods: { methods: {
goView() { goView() {
uni.navigateTo({
url: '/pagesB/pages/move-car/moveCarDetail'
})
},
searchCommodity(){
if (this.timer) {
clearTimeout(this.timer);
}
this.timer = setTimeout(() => {
let searchCondition = {
searchVal: this.keyword
}
console.log(searchCondition,222222222)
let opts = { url: '/app/index/mall/list', method: 'get' };
this.http.httpRequest(opts, searchCondition).then(res => {
if (res.data.code == 200) {
this.items = res.data.data.rows
}else{
uni.showToast({
title: res.data.msg,
icon: 'none',
duration: 2000
});
}
})
}, 300)
},
goDetail(id,link) {
let token = uni.getStorageSync('userToken');
if(!token){
let returnPage= '/pages/main';
let pageType = "reLaunch"
uni.navigateTo({ uni.navigateTo({
url:"/pages/login/index/index?returnPage="+returnPage+'&pageType='+pageType url: '/pagesB/pages/move-car/moveCarDetail'
}) })
return; },
} searchCommodity() {
if(link){ if (this.timer) {
clearTimeout(this.timer);
}
this.timer = setTimeout(() => {
let searchCondition = {
searchVal: this.keyword
}
console.log(searchCondition, 222222222)
this.$http.request({
url: '/app/index/mall/list',
method: 'get',
data: searchCondition,
}).then(res => {
this.items = res.rows
})
}, 300)
},
goDetail(id, link) {
let token = uni.getStorageSync('userToken');
if (!token) {
let returnPage = '/pages/main';
let pageType = "reLaunch"
uni.navigateTo({
url: "/pages/login/index/index?returnPage=" + returnPage + '&pageType=' + pageType
})
return;
}
if (link) {
// uni.navigateTo({
// url: '/pages/webview/webview?url=' + link
// })
uni.navigateToMiniProgram({
appId: 'wx91d27dbf599dff74', // 跳转目标小程序的id
path: link, // 目标小程序的页面路径
extraData: { // 需要携带的参数
},
success(res) { // 打开成功
}
})
return
}
uni.showToast({
title: "该商品暂无链接!",
icon: 'none',
duration: 1500,
});
// uni.navigateTo({ // uni.navigateTo({
// url: '/pages/webview/webview?url=' + link // url: '/pagesC/pages/shop/detail?id=' + id
// }) // })
uni.navigateToMiniProgram({ },
appId: 'wx91d27dbf599dff74', // 跳转目标小程序的id },
path: link, // 目标小程序的页面路径 }
extraData: { // 需要携带的参数
},
success(res) {// 打开成功
}
})
return
}
uni.showToast({
title: "该商品暂无链接!",
icon: 'none',
duration: 1500,
});
// uni.navigateTo({
// url: '/pagesC/pages/shop/detail?id=' + id
// })
},
},
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.myMoveCar { .myMoveCar {
padding: 40rpx 30rpx; padding: 40rpx 30rpx;
.list { .list {
position: relative; position: relative;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: flex-end; justify-content: flex-end;
padding-top: 30rpx; padding-top: 30rpx;
.list__item {
padding: 28rpx;
box-sizing: border-box;
width: 640rpx;
height: 220rpx;
background: #ffffff;
box-shadow: 0rpx 0rpx 28rpx 1rpx rgba(232, 232, 232, 0.16);
border-radius: 20rpx;
display: flex;
align-items: center;
position: relative;
margin-bottom: 20rpx;
.list__img { .list__item {
width: 160rpx; padding: 28rpx;
height: 160rpx; box-sizing: border-box;
background: #3699ff; width: 640rpx;
border-radius: 10rpx; height: 220rpx;
position: absolute; background: #ffffff;
left: -50rpx; box-shadow: 0rpx 0rpx 28rpx 1rpx rgba(232, 232, 232, 0.16);
border-radius: 20rpx; border-radius: 20rpx;
} display: flex;
align-items: center;
position: relative;
margin-bottom: 20rpx;
.list__money { .list__img {
margin: 0 20rpx; width: 160rpx;
margin-left: 100rpx; height: 160rpx;
background: #3699ff;
border-radius: 10rpx;
position: absolute;
left: -50rpx;
border-radius: 20rpx;
}
.money__title { .list__money {
font-size: 32rpx; margin: 0 20rpx;
font-family: PingFang SC; margin-left: 100rpx;
font-weight: bold;
color: #333333;
line-height: 42rpx; .money__title {
font-size: 32rpx;
font-family: PingFang SC;
font-weight: bold;
color: #333333;
.code__tips { line-height: 42rpx;
font-size: 26rpx;
font-family: PingFang SC;
font-weight: 500;
color: #666666;
line-height: 42rpx;
}
}
.money__num { .code__tips {
.num__one { font-size: 26rpx;
font-size: 26rpx; font-family: PingFang SC;
font-family: PingFang SC; font-weight: 500;
font-weight: 500; color: #666666;
color: #e1251b; line-height: 42rpx;
line-height: 42rpx; }
margin-right: 20rpx; }
}
.money__num {
.num__one {
font-size: 26rpx;
font-family: PingFang SC;
font-weight: 500;
color: #e1251b;
line-height: 42rpx;
margin-right: 20rpx;
}
.num__two { .num__two {
font-size: 22rpx; font-size: 22rpx;
font-family: PingFang SC; font-family: PingFang SC;
font-weight: 500; font-weight: 500;
color: #999999; color: #999999;
line-height: 42rpx; line-height: 42rpx;
} }
} }
} }
.list__add { .list__add {
position: absolute; position: absolute;
right: 30rpx; right: 30rpx;
bottom: 30rpx; bottom: 30rpx;
width: 44rpx; width: 44rpx;
height: 44rpx; height: 44rpx;
image { image {
width: 44rpx; width: 44rpx;
height: 44rpx; height: 44rpx;
} }
} }
} }
} }
} }
</style> </style>
...@@ -55,23 +55,26 @@ export default { ...@@ -55,23 +55,26 @@ export default {
}) })
return; return;
} }
let opts = { this.$http.request({
url: '/app/user/feedback', url:'/app/user/feedback',
method: 'post' method:'post',
}; data:this.feedback,
this.http.httpTokenRequest(opts, this.feedback).then(res => { isFactory:false,
if (res.data.code == 200) { }).then(res => {
uni.showToast({ if (res.data.code == 200) {
title: '提交成功', uni.showToast({
icon: 'success', title: '提交成功',
}) icon: 'success',
} else { })
uni.showToast({ this.feedback.fbContent = ""
title: '提交失败', this.feedback.contact = ""
icon: 'error', } else {
}) uni.showToast({
} title: '提交失败',
}) icon: 'error',
})
}
})
} }
}, },
} }
......
...@@ -41,11 +41,12 @@ export default { ...@@ -41,11 +41,12 @@ export default {
}, },
methods: { methods: {
getAskingList(){ getAskingList(){
let opts = { url: '/app/user/problem/list', method: 'get' }; this.$http.request({
this.http.httpTokenRequest(opts, {}).then(res => { url:'/app/user/problem/list',
if (res.data.code == 200) { method:'get',
this.askingList = res.data.data data:{}
} }).then(res => {
this.askingList = res || []
}) })
}, },
}, },
......
This diff is collapsed.
...@@ -173,20 +173,21 @@ export default { ...@@ -173,20 +173,21 @@ export default {
this.formData.forEach(element => { this.formData.forEach(element => {
if (element.label === '性别') { if (element.label === '性别') {
element.rules.label = val element.rules.label = val
let opts = {
url: '/app/user/update',
method: 'post'
};
let sex = (val == '男' ? "0" : "1") let sex = (val == '男' ? "0" : "1")
let userInfoItem = { let userInfoItem = {
type: 3, type: 3,
val: sex val: sex
}; };
this.http.httpTokenRequest(opts, userInfoItem).then(response => { this.$http.request({
if (response.data.code == 200) { url:'/app/user/update',
method:'post',
} data:userInfoItem,
}) }).then(res => {
uni.showToast({
title: '修改成功',
icon: 'success',
})
})
} }
}); });
...@@ -197,19 +198,21 @@ export default { ...@@ -197,19 +198,21 @@ export default {
this.formData.forEach(element => { this.formData.forEach(element => {
if (element.label === '昵称') { if (element.label === '昵称') {
element.rules.value = this.user__nikename element.rules.value = this.user__nikename
let opts = {
url: '/app/user/update',
method: 'post'
};
let userInfoItem = { let userInfoItem = {
type: 2, type: 2,
val: this.user__nikename val: this.user__nikename
}; };
that.http.httpTokenRequest(opts, userInfoItem).then(response => { this.$http.request({
if (response.data.code == 200) { url:'/app/user/update',
this.getUserInfo() method:'post',
} data:userInfoItem,
}) }).then(res => {
uni.showToast({
title: '修改成功',
icon: 'success',
})
this.getUserInfo()
})
} }
}); });
this.show = false this.show = false
......
import CryptoJS from "crypto-js";
import $http from '@/common/zhouWei-request/requestConfig';
// import CryptoJS from "../../node_modules/crypto-js/crypto-js.js";//一般npm以后都是这个位置
let KEY = '自己的key'
let IV = '';//我感觉可以不写,反正我没有写(看你们需求)
let tools = {
/*aes加密*/
setAES(str) {
const data = CryptoJS.enc.Hex.parse(str);
const key = CryptoJS.enc.Hex.parse(KEY);
const iv = CryptoJS.enc.Hex.parse(IV);
var option = {
iv: iv,
mode: CryptoJS.mode['CBC'],//看需求变“CBC”
padding: CryptoJS.pad['ZeroPadding']//看需求变“ZeroPadding”
};
var encrypted = CryptoJS.AES.encrypt(data, key, option);
const words = encrypted.ciphertext;
var hex = CryptoJS.enc.Hex.stringify(words);
return hex
},
/*aes解密*/
decryptAES(str) {
console.log("str", str)
let data = CryptoJS.enc.Hex.parse(str);
const key = CryptoJS.enc.Hex.parse(KEY);
const iv = CryptoJS.enc.Hex.parse(IV);
var option = {
iv: iv,
mode: CryptoJS.mode['CBC'],//看需求变“CBC”
padding: CryptoJS.pad['ZeroPadding']//看需求变“ZeroPadding”
};
data = CryptoJS.enc.Base64.stringify(data);
const words = CryptoJS.AES.decrypt(data, key, option);
var hex = CryptoJS.enc.Hex.stringify(words);
return hex
}
};
export default tools;
\ 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 to comment