utils/getsign.js
var utilmd5 = require('md5.js')function getSign(time, datapar) { var key = '*********='; var str = key + time + datapar; var sign = ''; sign = utilmd5.hexMD5(str); return sign;}function getSignwx(datapar) { var appid = '*********'; var key = '**********'; var str = 'appId=' + appid + datapar + '&key=' + key; var sign = ''; sign = utilmd5.hexMD5(str); return sign;}module.exports = { getSign: getSign, getSignwx: getSignwx}var utiltime = require('utils/time.js')var utilsign = require('utils/getsign.js')var imgUrl = ''App({globalData: { canvas:{}, version:null, loginsatus: false, userInfo: null, userid: null, pageUrl:'', // APIUrl: '', APIUrl: '', //测试接口地址 // APIUrl: '', //正式接口地址 imgUrl:'', //图片地址 tabBar: { "color": "#666666", "selectedColor": "#fa2422", "backgroundColor": "#fff", "borderStyle": "#efefef", "list": [ { "pagePath": "/pages/homePage/productsIndex/index/index", "text": "首页", "iconPath": imgUrl +"indexDxyp.png", "selectedIconPath": imgUrl +"indexDxyp.png", "clas": "menu-item", "selectedColor": "#fa2422", active: true }, { "pagePath": "/pages/find/find", "text": "发现", "iconPath": imgUrl +"findDxyp.png", "selectedIconPath": imgUrl +"findDxyp.png", "selectedColor": "#fa2422", "clas": "menu-item", active: false }, { "pagePath": "/pages/classify/classify", "text": "分类", "iconPath": imgUrl +"classifyDxyp.png", "selectedIconPath": imgUrl +"classifyDxyp.png", "selectedColor": "#fa2422", "clas": "menu-item", active: false }, { "pagePath": "/pages/userPage/myInfo/my/my", "text": "我的", "iconPath": imgUrl +"mineDxyp.png", "selectedIconPath": imgUrl +"mineDxyp.png", "selectedColor": "#fa2422", "clas": "menu-item", active: false } ], "position": "bottom" }, tabBar2: { "color": "#666666", "selectedColor": "#fa2422", "backgroundColor": "#fff", "borderStyle": "#efefef", "list": [ { "pagePath": "/pages/homePage/productsIndex/index/index", "text": "首页", "iconPath": imgUrl +"indexDxyp.png", "selectedIconPath": imgUrl +"indexDxyp.png", "clas": "menu-item2", "selectedColor": "#fa2422", active: true }, { "pagePath": "/pages/find/find", "text": "发现", "iconPath": imgUrl +"findDxyp.png", "selectedIconPath": imgUrl +"findDxyp.png", "selectedColor": "#fa2422", "clas": "menu-item2", active: false }, { "pagePath": "/pages/classify/classify", "text": "分类", "iconPath": imgUrl +"classifyDxyp.png", "selectedIconPath": imgUrl +"classifyDxyp.png", "selectedColor": "#fa2422", "clas": "menu-item2", active: false }, { "pagePath": "/pages/orderPage/cartInfo/car/car", "text": "购物车", "iconPath": imgUrl +"cartDxyp.png", "selectedIconPath": imgUrl +"cartDxyp.png", "selectedColor": "#fa2422", "clas": "menu-item2", active: false, carNum:0 }, { "pagePath": "/pages/userPage/myInfo/my/my", "text": "我的", "iconPath": imgUrl +"mineDxyp.png", "selectedIconPath": imgUrl +"mineDxyp.png", "selectedColor": "#fa2422", "clas": "menu-item2", active: false } ], "position": "bottom" }, "networkTimeout": { "request": 3000, }, }, onLaunch: function () { //检查是否存在新版本 wx.getUpdateManager().onCheckForUpdate(function (res) { // 请求完新版本信息的回调 console.log("是否有新版本:" + res.hasUpdate); if (res.hasUpdate) {//如果有新版本 wx.clearStorageSync() // 小程序有新版本,会主动触发下载操作(无需开发者触发) wx.getUpdateManager().onUpdateReady(function () {//当新版本下载完成,会进行回调 wx.showModal({ title: '更新提示', content: '新版本已经准备好,单击确定重启应用', showCancel: false, success: function (res) { if (res.confirm) { // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 wx.getUpdateManager().applyUpdate(); } } }) }) // 小程序有新版本,会主动触发下载操作(无需开发者触发) wx.getUpdateManager().onUpdateFailed(function () {//当新版本下载失败,会进行回调 wx.showModal({ title: '提示', content: '检查到有新版本,但下载失败,请检查网络设置', showCancel: false, }) }) } }) //用户静默登录 that.auth_login() },auth_login:function(){ // 静默获取用户信息 var that = this; if (wx.getStorageSync('wxuserid')) { wx.setStorageSync('oldUsers', false) return false } wx.login({ success: function (res) { var arys = { 'code': res.code }; that.doRequestService('/svc/api/user/getUserByCode', arys, function (res) { console.log(res) // return if (res.status == 'SUCCESS') { console.log(res.userBaseInfo) if (res.userBaseInfo && res.userBaseInfo.phone && res.userId) { wx.setStorageSync('wxuserid', res.userId) wx.setStorageSync('userinfo', res.userBaseInfo) } wx.setStorageSync('oldUsers', false) } }, null, null) } }) }, // 分享 onShare:function(obj){ if(!obj) var obj = {}; var shareObj={}; var userName = wx.getStorageSync('userinfo').nickName;//用户名 shareObj.path = obj.path || 'pages/homePage/productsIndex/index/index'; shareObj.title = obj.title ||
版权声明
即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。













