123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- function sendRequest(url, type, data, success) {
- //可能直接传递option
- var optionIn = {};
- var contentType = null;
- if ($.isPlainObject(url)) {
- optionIn = url;
- url = optionIn.url;
- type = optionIn.type;
- data = optionIn.data;
- contentType = optionIn.contentType;
- success = optionIn.success;
- }
- var requestUrl = url;
- if (url.indexOf("/") !== 0) {
- requestUrl = "/user/" + url;
- }
- var option = {
- url: requestUrl,
- type: type,
- dataType: "json",
- data: data,
- success: function (result) {
- if (result.result == 0) {
- msgPopup("温馨提示", result.description, "我知道了");
- return false;
- } else {
- if (success) {
- success(result)
- }
- }
- },
- error: function (res) {
- if (res.status == 401) {
- goScanFor401()
- } else {
- var Prompt = "温馨提示",
- desc = "获取数据失败,请检查网络",
- btnText = "我知道了";
- msgPopup(Prompt, desc, btnText);
- }
- },
- complete: function () {
- }
- };
- if (contentType != null) {
- option.contentType = contentType
- }
- myAjax(option);
- }
- var goScanFor401HasDialog = false;
- function goScanFor401() {
- if (goScanFor401HasDialog) {
- return true;
- }
- goScanFor401HasDialog = true;
- function goScan() {
- mui.confirm("您的登录已过期,是否要扫码设备登录?", "温馨提示", null, function (btnObj) {
- if (btnObj.index == 1) {
- scanQRCodeGoDevice();
- }
- goScanFor401HasDialog = false;
- });
- }
- if (window.mui) {
- goScan()
- } else {
- // 使用缓存获取,避免刷新后重新向服务器请求
- $.ajaxSetup({
- cache: true
- });
- $.getScript("/components/lib/mui.min.js", function () {
- $('<link>').appendTo('head').attr({
- rel: "stylesheet",
- type: 'text/css',
- href: '/components/lib/mui.min.css',
- });
- goScan()
- });
- }
- }
- //页面居中的黑色文字小提示
- function toast(e) {
- var t = ($("body").append('<div class="toast"></div>'), $(".toast")), n = '<div class="toast-msg"><div class="toast-text">' + e + "</div></div>";
- t.on("touchmove", function (e) {
- e.preventDefault()
- }), $("body").append(n), setTimeout(function () {
- t.remove(), $(".toast-msg").remove()
- }, 3000)
- }
- //设备离线需要获取扫码权限
- function offline(data) {
- var showDevice = getQueryString("showDevice"); //强制展示设备,无论是否离线
- if (!showDevice && !data.payload.online) {
- var errorPage = '<div class="error-page"><div class="remind-panel"><div class="remind-pic"></div><div class="text-item">设备(' + data.payload.logicalCode + ')离线</div><div class="text-sub-item">请重新选择设备扫码支付或现金支付</div></div><ul class="btn-list flexbox"><li class="flex"><a href="javascript:;" class="btn-skin scan-btn">重新扫码</a></li></ul></div>';
- $("body").append(errorPage);
- var scanBtn = $(".scan-btn");
- scanBtn.tap(function () {
- scanQRCodeGoDevice()
- })
- }
- }
- // 扫码事件-去查看设备
- function scanQRCodeGoDevice() {
- ScanResult(function (resultStr) {
- goPage(resultStr);
- })
- }
- var Server_Url = {
- equipmentPara: "/user/message/equipmentPara",
- Task_List: "/ad/taskList"
- };
|