1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- const util = require('../utils/util.js');
- const openidStatus = () => {
- return new Promise((resolve, reject) => {
- // if (wx.getStorageSync('openId')) {
- // resolve([wx.getStorageSync('openId'), wx.getStorageSync('sessionKey')]);
- // } else {
- wx.login({
- success: (res) => {
- if (res.code) {
- wx.request({
- url: util.globalData.publicUrl + '/wx/user/wxbfa171fdd4000e03/login',
- method: "GET",
- data: {
- code: res.code
- },
- success: res => {
- console.log(res)
- if (res.statusCode == 200) {
- wx.setStorageSync('openId', res.data.openid)
- wx.setStorageSync('sessionKey', res.data.sessionKey)
- resolve([res.data.openid, res.data.sessionKey]);
- }
- }
- });
- } else {
- reject(res.errMsg);
- }
- }
- })
- })
- };
- function formatTime(date) {
- var year = date.getFullYear()
- return year
- }
- const formDetails = (type) => {
- return new Promise((resolve, reject) => {
- wx.request({
- url: util.globalData.publicUrl + '/wx/member/' + wx.getStorageSync('openId') + '/options',
- method: "GET",
- data: {
- type
- },
- success: res => {
- // console.log(res)
- if (res.data.code == 0) {
- if (res.data.options) {
- let labelArr = res.data.options.map((obj, index) => {
- return obj.dictLabel;
- })
- let valueArr = res.data.options.map((obj, index) => {
- return obj.dictValue;
- })
- resolve([labelArr, valueArr])
- }
- } else {
- reject(res)
- }
- }
- })
- })
- };
- // 判断是否完善个人信息
- const isFinishInfo = () => {
- return new Promise((resolve, reject) => {
- wx.request({
- url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/info',
- method: "get",
- success: (res) => {
- console.log(res)
- if (res.data.code == 0) {
- resolve(res.data.info)
- } else {
- reject(res.code)
- }
- }
- })
- })
- };
- module.exports = {
- openidStatus,
- formDetails,
- formatTime,
- isFinishInfo
- }
|