CRMEB/view/crmebN/app.js
sugar1569 af7cfc8967 修复商城首页默认的是“商城首页”,改为后台小程序名称为标题
修改产品列表页标题为产品列表
修复收货地址标题错别字
修复首页分享显示“小程序”改为显示小程序名称
修复会员详情积分余额数据错误bug
修复会员详情积分记录和余额纪录bug
去掉load授权页面
修复小程序推广二维码页面默认显示CRMEB小程序,改为后台小程序名字
修复推广人订单时间未格式化bug
2019-04-02 17:40:17 +08:00

184 lines
5.3 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var app = getApp();
// var wxh = require('../../utils/wxh.js');
App({
onLaunch: function (option) {
// 展示本地存储能力
var that = this;
if (option.query.hasOwnProperty('scene')) {
var sceneCode = option.query.scene.split('-');
if (sceneCode.length == 1) { //分享链接进入获取推广人二维码ID
that.globalData.spreadid = sceneCode[0];
} else if (sceneCode.length == 2) { //扫码进入进入获取推广人二维码ID
that.globalData.spreadid = sceneCode[0];
if (sceneCode[1]){
wx.reLaunch({ url: option.path + '?id=' + sceneCode[1] });
}
}
}
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
that.getRoutineConfig();
},
globalData: {
config:null,//小程序相关配置
uid: null,
uidShare:null,//我的推广二维码ID
openid:'',
openPages:'',//记录要访问的页面
spreadid: 0,//推广人二维码ID 2.5.36
spid:0,//推广人二维码ID
urlImages: '',
url: 'https://shop.crmeb.net/',
},
//获取小程序配置
getRoutineConfig:function(){
var that = this;
wx.request({
url: that.globalData.url + '/routine/logins/get_routine_config',
method: 'post',
dataType  : 'json',
success: function (res) {
if(res.data.code == 200 ){
that.globalData.config = res.data.data.routine_config;
that.setBarColor('#FFFFFF');
}else{
wx.showToast({
title: '请求接口错误',
icon: 'none',
duration: 1500,
})
}
},
fail:function(){
wx.showToast({
title: '配置信息获取失败',
icon: 'none',
duration: 1500,
})
}
})
},
setBarColor: function (routine_style = '#FFFFFF'){
var that = this;
wx.setNavigationBarColor({
frontColor: '#000000',
backgroundColor: routine_style,
})
},
setUserInfo : function(){
var that = this;
if (that.globalData.uid == null) {//是否存在用户信息,如果不存在跳转到首页
setTimeout(function () {
wx.navigateTo({
url: '/pages/loading/loading',
})
}, 1500)
}
},
rp: function (n) {
var cnum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
var s = '';
n = '' + n; // 数字转为字符串
for (var i = 0; i < n.length; i++) {
s += cnum[parseInt(n.charAt(i))];
}
return s;
},
U: function (opt) {
var m = opt.m || 'routine', c = opt.c || 'auth_api', a = opt.a || 'index', q = opt.q || '',
p = opt.p || {}, params = '', gets = '';
params = Object.keys(p).map(function (key) {
return key + '/' + p[key];
}).join('/');
gets = Object.keys(q).map(function (key) {
return key + '=' + q[key];
}).join('&');
return this.globalData.url + '/' + m + '/' + c + '/' + a + '/uid/' + this.globalData.uid + (params == '' ? '' : '/' + params) + (gets == '' ? '' : '?' + gets) + '&uid='+this.globalData.uid;
},
baseGet: function (url, successCallback, errorCallback) {
var that = this;
var header = {
'content-type': 'application/x-www-form-urlencoded'
};
wx.request({
url: url,
method: 'get',
header: header,
success: function (res) {
if (res.data.code == 200) {
successCallback && successCallback(res.data);
} else {
errorCallback && errorCallback(res.data);
that.Tips({ title: res.data.msg });
}
}, fail: function (res) {
console.log('submit fail');
},
complete: function (res) {
}
});
},
Tips: function (opt, to_url) {
var title = opt.title || '', icon = opt.icon || 'none', endtime = opt.endtime || 2000;
wx.showToast({
title: title,
icon: 'none',
duration: endtime,
})
if (to_url != undefined) {
if (typeof to_url == 'object') {
var tab = to_url.tab || 1, url = to_url.url || '';
switch (tab) {
case 1:
//一定时间后跳转至 table
setTimeout(function () {
wx.switchTab({
url: url
})
}, endtime);
break;
case 2:
//跳转至非table页面
setTimeout(function () {
wx.navigateTo({
url: url,
})
}, endtime);
break;
case 3:
//返回上页面
setTimeout(function () {
wx.navigateBack({
delta: parseInt(url),
})
}, endtime);
break;
case 4:
//关闭当前所有页面跳转至非table页面
setTimeout(function () {
wx.reLaunch({
url: url,
})
}, endtime);
break;
case 5:
//关闭当前页面跳转至非table页面
setTimeout(function () {
wx.redirectTo({
url: url,
})
}, endtime);
break;
}
} else {
setTimeout(function () {
wx.navigateTo({
url: to_url,
})
}, endtime);
}
}
},
})