|
|
@ -1,4 +1,7 @@
|
|
|
|
import http from '../common/http.js'
|
|
|
|
import http from '../common/http.js'
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
|
|
|
userStore
|
|
|
|
|
|
|
|
} from '../store/user.js'
|
|
|
|
//获取code
|
|
|
|
//获取code
|
|
|
|
export const getCode = () => {
|
|
|
|
export const getCode = () => {
|
|
|
|
const promise = new Promise((resolve, reject) => {
|
|
|
|
const promise = new Promise((resolve, reject) => {
|
|
|
@ -24,6 +27,9 @@ export const getCode = () => {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return promise;
|
|
|
|
return promise;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getUserInfoApi = (parm) => {
|
|
|
|
|
|
|
|
return http.get("/wxapi/wxUser/getUserInfo", parm)
|
|
|
|
|
|
|
|
}
|
|
|
|
//小程序登录
|
|
|
|
//小程序登录
|
|
|
|
export const wxLoginApi = (code) => {
|
|
|
|
export const wxLoginApi = (code) => {
|
|
|
|
return http.post('/wxapi/user/wxLogin', {
|
|
|
|
return http.post('/wxapi/user/wxLogin', {
|
|
|
@ -32,6 +38,7 @@ export const wxLoginApi = (code) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//封装登录
|
|
|
|
//封装登录
|
|
|
|
export const userLogin = async () => {
|
|
|
|
export const userLogin = async () => {
|
|
|
|
|
|
|
|
const store = userStore()
|
|
|
|
//获取code
|
|
|
|
//获取code
|
|
|
|
let res = await getCode()
|
|
|
|
let res = await getCode()
|
|
|
|
//登录: 调用我们自己的后端接口
|
|
|
|
//登录: 调用我们自己的后端接口
|
|
|
@ -45,28 +52,40 @@ export const userLogin = async () => {
|
|
|
|
uni.setStorageSync('openid', data.openid)
|
|
|
|
uni.setStorageSync('openid', data.openid)
|
|
|
|
uni.setStorageSync('sessionkey', data.sessionKey)
|
|
|
|
uni.setStorageSync('sessionkey', data.sessionKey)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let result = await getUserInfoApi({
|
|
|
|
|
|
|
|
openid: data.openid
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
console.log(result.data)
|
|
|
|
|
|
|
|
if (result.data && result.data.avatarUrl) {
|
|
|
|
|
|
|
|
store.avatarUrl = result.data.avatarUrl
|
|
|
|
|
|
|
|
uni.setStorageSync('avatarUrl', result.data.avatarUrl)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result.data && result.data.nickName) {
|
|
|
|
|
|
|
|
store.nickName = result.data.nickName
|
|
|
|
|
|
|
|
uni.setStorageSync('nickName', result.data.nickName)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//新增地址
|
|
|
|
//新增地址
|
|
|
|
export const addAddressApi = (parm) => {
|
|
|
|
export const addAddressApi = (parm) => {
|
|
|
|
console.log("新增地址成功")
|
|
|
|
|
|
|
|
return http.post("/wxapi/address", parm)
|
|
|
|
return http.post("/wxapi/address", parm)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//地址列表
|
|
|
|
//地址列表
|
|
|
|
export const addressListApi = (parm) => {
|
|
|
|
export const addressListApi = (parm) => {
|
|
|
|
console.log("查询地址列表成功")
|
|
|
|
|
|
|
|
return http.get("/wxapi/address/list", parm)
|
|
|
|
return http.get("/wxapi/address/list", parm)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//编辑地址
|
|
|
|
//编辑地址
|
|
|
|
export const editAddressApi = (parm) => {
|
|
|
|
export const editAddressApi = (parm) => {
|
|
|
|
console.log("编辑地址成功")
|
|
|
|
|
|
|
|
return http.put("/wxapi/address", parm)
|
|
|
|
return http.put("/wxapi/address", parm)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//默认地址查询
|
|
|
|
//默认地址查询
|
|
|
|
export const getAddressApi = (parm) => {
|
|
|
|
export const getAddressApi = (parm) => {
|
|
|
|
console.log("查询默认地址成功")
|
|
|
|
|
|
|
|
return http.get("/wxapi/address/getAddress", parm)
|
|
|
|
return http.get("/wxapi/address/getAddress", parm)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//头像上传
|
|
|
|
//头像上传
|
|
|
|
export const uploadImageApi = (parm) => {
|
|
|
|
export const uploadImageApi = (parm) => {
|
|
|
|
return http.upload(parm)
|
|
|
|
return http.upload(parm)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//头像昵称更新
|
|
|
|
|
|
|
|
export const saveOrUpdateApi = (parm) => {
|
|
|
|
|
|
|
|
return http.post("/wxapi/wxUser/saveOrUpdate", parm)
|
|
|
|
|
|
|
|
}
|