133 lines
4.4 KiB
JavaScript
133 lines
4.4 KiB
JavaScript
const util=require('./utils/js/util')
|
|
import { postRequest, getRequest } from "./utils/js/request"
|
|
import { platformInfo, queryInfo, signIn } from "./utils/js/locales"
|
|
App({
|
|
onLaunch(query) {
|
|
// 展示本地存储能力
|
|
const logs = wx.getStorageSync('logs') || []
|
|
logs.unshift(Date.now())
|
|
wx.setStorageSync('logs', logs)
|
|
let scene = '';
|
|
if (query.query.q) {
|
|
let url = decodeURIComponent(query.query.q)
|
|
scene = util.getQueryString(url,'bind')
|
|
wx.setStorageSync('bind', scene)
|
|
}
|
|
// 获取用户信息
|
|
// wx.getSetting({
|
|
// success: res => {
|
|
// if (res.authSetting['scope.userInfo']) {
|
|
// // 已经授权,可以直接调用 getUserProfile 获取头像昵称,不会弹框
|
|
// wx.getUserProfile({
|
|
// desc: '用于展示头像',
|
|
// success: (res) => {
|
|
// // 可以将 res 发送给后台解码出 unionId
|
|
// this.globalData.userInfo = res.userInfo
|
|
// }
|
|
// })
|
|
// }
|
|
// }
|
|
// })
|
|
},
|
|
|
|
onShow() {
|
|
this.upDataApp();
|
|
},
|
|
// 存储公共信息
|
|
globalData: {
|
|
uploadUrl: "https://office-ssl.iilink.cn/coconut", // 开发环境
|
|
// uploadUrl: "https://office-ssl.iilink.cn/coconut-uat", // 测试环境
|
|
// uploadUrl: 'https://cherry.amtcloud.cn/cherry-api', // 生产
|
|
systemConfiguration: {
|
|
backgroundColor: '#01ae42'
|
|
},
|
|
id: '', // 商铺id shop_id
|
|
actor: '', // 用户身份 代采buyer 销售seller 游客visitor
|
|
platformInfo: {}, // 平台信息
|
|
buyerItem: { // 买家信息
|
|
gmtOrder: '',
|
|
memberId: '',
|
|
name: ''
|
|
},
|
|
info: {}, // login获取的数据
|
|
userInfo: {}, // 授权的昵称和logo
|
|
user_info: {}, // 信息里的昵称和logo
|
|
member_info: {}, // 认证信息
|
|
operator_info: {}, //
|
|
behaviorRecord: 0, // 认证 操作记录
|
|
authentication: { // 认证信息缓存
|
|
personal: {
|
|
name: '',
|
|
card_number: '',
|
|
id_main: '',
|
|
id_extra: '',
|
|
id_card: [],
|
|
},
|
|
enterprise: {
|
|
corporation_name: '',
|
|
unified_tax_code: '',
|
|
business_licence: '',
|
|
enterprise: [],
|
|
}
|
|
}
|
|
},
|
|
// 小程序登录
|
|
loginCloudBird: function (scene) {
|
|
let app = this
|
|
// wx.login({
|
|
// success: res => {
|
|
// let data = {
|
|
// code: res.code,
|
|
// }
|
|
// postRequest('/v1/p/login', data).then(res => {
|
|
// wx.setStorageSync('tokenKey', res.data.token);
|
|
//用户类型 代采buyer 销售seller 游客visitor
|
|
// wx.setStorageSync('actor', res.data.info.actor); // res.data.actor buyer seller
|
|
// app.globalData.actor = res.data.info.actor;
|
|
// app.globalData.info = res.data.info;
|
|
// platformInfo(app);
|
|
wx.reLaunch({
|
|
url: '/pages/home/home',
|
|
})
|
|
// }).catch(err => {
|
|
// signIn(err);
|
|
// })
|
|
// }
|
|
// })
|
|
},
|
|
//版本更新
|
|
upDataApp: function () {
|
|
if (wx.canIUse('getUpdateManager')) { //判断当前微信版本是否支持版本更新
|
|
const updateManager = wx.getUpdateManager();
|
|
updateManager.onCheckForUpdate(function (res) {
|
|
if (res.hasUpdate) { // 请求完新版本信息的回调
|
|
updateManager.onUpdateReady(function () {
|
|
wx.showModal({
|
|
title: '更新提示',
|
|
content: '新版本已经准备好,是否重启应用?',
|
|
success: function (res) {
|
|
// res: {errMsg: "showModal: ok", cancel: false, confirm: true}
|
|
if (res.confirm) {
|
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
updateManager.applyUpdate()
|
|
}
|
|
}
|
|
})
|
|
});
|
|
updateManager.onUpdateFailed(function () {
|
|
// 新的版本下载失败
|
|
wx.showModal({
|
|
title: '已经有新版本了哟~',
|
|
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
|
|
})
|
|
})
|
|
}
|
|
})
|
|
} else {
|
|
wx.showModal({ // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
|
|
title: '提示',
|
|
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
|
|
})
|
|
}
|
|
}
|
|
}) |