| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- export default {
- shopId: function() {
- return "10108575743725";
- },
- clearUri(url){
- var userInfo = uni.getStorageSync("user_data");
- if(!userInfo){
- uni.showLoading({
- title:"加载中..."
- });
- setTimeout(function(){
- uni.hideLoading();
- uni.$u.route({
- url:'/pages/user/user',
- type:"switchTab",
- animationType:"slide-in-bottom"
- });
- },800);
- return ;
- }
- uni.$u.route({
- url:url,
- animationType:"slide-in-bottom",
- animationDuration:300
- });
- },
- jumpUri(url,type){
- var userInfo = uni.getStorageSync("user_token");
- if(!userInfo){
- setTimeout(function(){
- uni.hideLoading();
- uni.navigateTo({
- url:'/pages/auth/login',
- animationType:"slide-in-bottom"
- });
- },800);
- return false;
- }
- if(type == 1 && !userInfo){
- uni.showToast({
- title:"请先登录",
- icon:"none"
- });
- return true;
- }
- uni.navigateTo({
- url:url
- })
- },
- //判断是否登录
- navTo: function(url,param) {
- uni.$u.route(url,param);
- },
- //判断是否登录
- isLogin: function() {
- return uni.getStorageSync("user") ? true : false
- },
-
- /**
- * 操作成功提示框
- * @param {*} msg
- * @param {*} callback
- * @param {*} icon
- */
- showSuccess(msg,icon,callback){
- uni.showToast({
- title: msg,
- icon: icon?icon:'none',
- mask: true,
- duration: 1500,
- success() {
- callback && (setTimeout(function() {
- callback();
- }, 1500));
- }
- });
- },
- /**
- * 操作错误提示
- * @param {*} msg
- * @param {*} showCancel
- * @param {*} callback
- * @param {*} title
- */
- showError(msg,callback,title = "友情提示",showCancel = true){
- uni.showModal({
- title: title,
- content: msg,
- showCancel: showCancel,
- success(res) {
- callback && callback(res);
- }
- });
- },
-
- showConfirm(msg,callback,title,yes,cancel){
- plus.nativeUI.confirm(msg, function(e){
- callback && callback(e);
- },
- {"title":title,"buttons":[yes?yes:"确定",cancel?cancel:"取消"]}
- );
- },
-
- showSysAlert(msg,callback,title,showCancel){
- plus.nativeUI.alert(msg,callback,title,showCancel);
- },
- showSysMsg(msg){
- plus.nativeUI.toast(msg);
- },
- /**
- * loading
- * @param {Object} msg
- * @param {Object} callback
- */
- loading(msg,callback){
- uni.showLoading({
- title:msg ?? '请求中...',
- mask:true,
- success(res) {
- callback && callback(res);
- }
- })
- },
- hideLoad(){
- uni.hideLoading();
- },
- formatDate(value) {
- const data = new Date(value);
- const month = data.getMonth() + 1;
- const day = data.getDate();
- const year = data.getFullYear();
- const hours = data.getHours();
- const minutes = data.getMinutes();
- const seconds = data.getSeconds();
- const formattedTime = `${year}-${month}-${day}`;
- // const formattedTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
- return formattedTime;
- },
- formatMoney(num,double = false) {
- if (num == 0) return "¥0.00";
- if (!double) {
- return "¥"+num.toFixed(2);
- }
- return "¥"+(num / 100).toFixed(2);
- // return Intl.NumberFormat("zh-CN", {
- // style: "currency",
- // currency: "CNY",
- // minimumFractionDigits: 2,
- // maximumFractionDigits: 2,
- // }).format(num / 100);
- },
- disFormat(num,num2) {
- if (!num) return "0";
- if (!num2) return "0";
- var total = ((num*100)/(num2*100)*10)
- return total.toFixed(1)
- },
- dateFormat(date, fmt='yyyy-MM-dd hh:mm:ss') {
- date = new Date(date)
- var o = {
- "M+" : date.getMonth()+1, //月份
- "d+" : date.getDate(), //日
- "h+" : date.getHours(), //小时
- "m+" : date.getMinutes(), //分
- "s+" : date.getSeconds(), //秒
- "q+" : Math.floor((date.getMonth()+3)/3), //季度
- "S" : date.getMilliseconds() //毫秒
- };
- if(/(y+)/.test(fmt)) {
- fmt=fmt.replace(RegExp.$1, (date.getFullYear()+"").substr(4 - RegExp.$1.length));
- }
- for(var k in o) {
- if(new RegExp("("+ k +")").test(fmt)){
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
- }
- }
- return fmt;
- }
- }
|