123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- var urls = function() {
- //var host = "http://192.168.100.3:7979";
- var host = "http://192.168.5.104:7979";
- //var host = "http://app.biboacgn.com";
- var url = {
- "path": host,
- "sendMessage": host + "/app/user/sendMessage", //发送短信
- "login": host + "/app/user/login", //用户登录
- "userInfo": host + "/app/user/userInfo", //用户信息
- "edit_info": host + "/app/user/edit", //编辑用户信息
- "user_upload": host + "/app/user/uploadHeader", //用户上传头像
- "main": host + "/app/main", //首页加载数据
- "feedback": host + "/app/other/feedback", //意见反馈
- "agreement": host + "/app/other/agreement", //服务条款
- "guide": host + "/app/other/guide/", //萌新必读
- };
- return url;
- }
- /**
- *一些常用参数
- */
- function getConstant() {
- var str = {
- "qq": 2060514344,
- "group": 642999141,
- "phone": "13541009237"
- }
- return str;
- }
- /**
- * i
- * @param 窗口id
- * @param 窗口地址url
- * @param 传递参数
- * @param 跳转动画
- */
- function open(id, url, para, anim) {
- anim == null || undefined ? 'pop-in' : anim;
- mui.openWindow({
- id: id,
- url: url,
- show: {
- aniShow: anim
- },
- styles: {
- popGesture: 'hide'
- },
- waiting: {
- autoShow: true,
- title: '正在加载...',
- },
- extras: {
- param: para
- },
- createNew: true,
- hardwareAccelerated: true
- });
- }
- /**
- *判断是否登录
- */
- var hasLogin = function() {
- var user = localStorage.getItem("user");
- return user == null || user == '' ? false : true;
- }
- /**
- *软件第一次运行
- */
- var first = function() {
- var f = localStorage.getItem("first");
- return f == null || f == '' ? true : false;
- }
- /**
- *获取用户信息
- */
- var getUser = function() {
- var user = localStorage.getItem("user");
- return JSON.parse(user);
- }
- var getToken = function() {
- return localStorage.getItem("token");
- }
- /**
- *
- * @param 请求url
- * @param 请求参数
- * @param 回调回调
- */
- function request(url, param, callback) {
- //plus.nativeUI.showWaiting("正在加载...");
- mui.ajax(url, {
- data: param,
- dataType: 'json', //服务器返回json格式数据
- type: 'post', //HTTP请求类型
- contentType: "application/x-www-form-urlencoded; charset=utf-8",
- beforeSend: function(req) {
- if(hasLogin()) {
- req.setRequestHeader("token", getToken());
- req.setRequestHeader("phone", getUser().account);
- }
- },
- success: callback,
- error: function(xhr, type, errorThrown) {
- //plus.nativeUI.closeWaiting();
- }
- });
- }
- //获取订单状态
- var getState = function(index) {
- if(index == 0) {
- return '等待发货';
- }
- if(index == 1) {
- return '等待收货';
- }
- if(index == 2) {
- return '已确认收货 等待归还衣服';
- }
- if(index == 3) {
- return '等待客服收货';
- }
- if(index == 4) {
- return '客服已确认收货 等待退款';
- }
- if(index == 5) {
- return '交易完成';
- }
- if(index == 6) {
- return '申请取消订单中 等待同意';
- }
- if(index == 7) {
- return '订单已取消';
- }
- }
- //手机格式验证
- function isPhone(phone) {
- var reg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
- if(reg.test(phone)) {
- return true;
- } else {
- return false;
- }
- return false;
- }
- /**
- * 切换到指定qq联系人
- * @param {Object} qq
- */
- function callqq(qq) {
- if(plus.os.name == "Android") {
- var main = plus.android.runtimeMainActivity();
- var Intent = plus.android.importClass('android.content.Intent');
- var Uri = plus.android.importClass('android.net.Uri');
- var intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mqqwpa://im/chat?chat_type=wpa&uin=" + qq));
- main.startActivity(intent);
- } else {
- plus.runtime.launchApplication({
- action: "mqq://im/chat?chat_type=wpa&uin=" + qq + "&version=1&src_type=web"
- }, function(e) {
- plus.nativeUI.confirm("检查到您未安装qq,请先到appstore搜索下载?", function(i) {
- if(i.index == 0) {
- iosAppstore("itunes.apple.com/cn/app/mqq/");
- }
- });
- });
- }
- }
- //当月小于10时,后面加个0;
- function p(s) {
- return s < 10 ? '0' + s : s;
- }
- /**
- * 复制文本到剪贴板
- * @param {Object} copy_content
- */
- function copy(copy_content) {
- //判断是安卓还是ios
- if(mui.os.ios) {
- //ios
- var UIPasteboard = plus.ios.importClass("UIPasteboard");
- var generalPasteboard = UIPasteboard.generalPasteboard();
- //设置/获取文本内容:
- generalPasteboard.plusCallMethod({
- setValue: ""+copy_content,
- forPasteboardType: "public.utf8-plain-text"
- });
- generalPasteboard.plusCallMethod({
- valueForPasteboardType: "public.utf8-plain-text"
- });
- } else {
- //安卓
- var Context = plus.android.importClass("android.content.Context");
- var main = plus.android.runtimeMainActivity();
- var clip = main.getSystemService(Context.CLIPBOARD_SERVICE);
- plus.android.invoke(clip, "setText", "" + copy_content);
- }
- }
- /**
- * 初始化剪裁
- * @param {Object} ratio 裁剪框比例1是正方形,0NaN是无限制,16:9/4:3/2:3
- * @param {Object} path 剪裁图像路径
- */
- function getClipper(ratio, path) {
- var cropper = null;
- document.getElementById("clipp").style.display = 'block';
- document.getElementById("image").src = path;
- var image = document.getElementById("image");
- cropper = new Cropper(image, {
- aspectRatio: ratio,
- viewMode: 1,
- });
- return cropper;
- }
|