// 请求token const app = getApp() const shareLogo = require('./shareLogo.js'); const formatTime = date => { const year = date.getFullYear() const month = date.getMonth() + 1 const day = date.getDate() const hour = date.getHours() const minute = date.getMinutes() const second = date.getSeconds() return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') } const formatNumber = n => { n = n.toString() return n[1] ? n : '0' + n } const getShareInfo = (opts) => { return { onShareAppMessage: () => { let title = opts && opts.title ? opts.title : 'WX-RUI小程序示例'; let path = opts && opts.path ? opts.path : '/pages/index/index'; let imageUrl = opts && opts.imageUrl ? opts.imageUrl : shareLogo[Math.floor(Math.random() * shareLogo.length)]; return { title: title, path: path, imageUrl: imageUrl } } } } function token(){ wx.request({ url: app.globalData.url + '/device/CouponWechat/getToken', data: { uid:wx.getStorageSync('uid'), phone: wx.getStorageSync('phone') }, method: 'POST', header: { 'content-type': 'application/x-www-form-urlencoded' }, success(res) { // console.log(res.data.token) if (res.data.result.erro == 0) { app.globalData.token=res.data.result.token wx.setStorageSync('token', res.data.result.token) return res.data.token } } }) } module.exports = { token:token, getShareInfo: getShareInfo }