锶源昆仑会员+体验官

This commit is contained in:
2023-07-22 19:04:56 +08:00
commit 5a6b3517e6
439 changed files with 20654 additions and 0 deletions

54
api/err.js Normal file
View File

@@ -0,0 +1,54 @@
/**
* 处理错误信息
* @property {Object} errInfo
*/
const errInfo = (obj) =>{
if(obj.status_code == 401){
wx.showModal({
title : "登录提示",
content : "长时间未操作,登录已过期,请重新登录",
showCancel : false,
confirmColor: "#0b0041",
confirmText : "确定",
success : ()=>{
// 清理客户端登录缓存
wx.removeStorageSync("token")
// 返回首页
wx.redirectTo({
url: "/pages/login/index",
})
}
})
}else if(obj.status_code == 422){
wx.showToast({
title: obj.message,
icon : "none"
})
}else if(obj.status_code == 400 || obj.status_code == 0){
wx.showToast({
title: obj.message,
icon : "none"
})
}else if(obj.status_code == 404){
wx.showToast({
title: "接口地址不存在,请联系系统管理员",
icon : "none"
})
}else if(obj.status_code == 500){
wx.showToast({
title: "服务端:" + obj.message,
icon : "none"
})
}else {
wx.showToast({
title: "code:" + obj.status_code + ", msg:" + obj.message,
icon : "none"
})
}
}
module.exports = {
errInfo
}

35
api/index.js Normal file
View File

@@ -0,0 +1,35 @@
/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
// 体验官
import index from "./interfaces/index"
// 商城
import mall from "./interfaces/mall"
// 锶人中心
import user from "./interfaces/user"
// 授权登录
import auth from "./interfaces/auth"
// 图片上传
import file from "./interfaces/file"
// 库存
import stock from "./interfaces/stock"
// 档案
import member from "./interfaces/member"
export default{
index,
mall,
user,
auth,
file,
stock,
member
}

21
api/interfaces/auth.js Normal file
View File

@@ -0,0 +1,21 @@
/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
import {req} from "../request"
//验证码登录
const smsAuth = data => req({url: "user/auth/sms", method: "POST", data: data})
//获取验证码
const getSms = data => req({url: "user/auth/verify", method: "POST", data: data})
//隐私+协议
const registeragree = (website) => req({url: "cms/pages/" + website})
export default({
smsAuth,
getSms,
registeragree
})

11
api/interfaces/file.js Normal file
View File

@@ -0,0 +1,11 @@
/*
* 图图片上传公用接口
*/
import {upload} from "../request"
//图上传
const uploadImg = (imgPaht, data) => upload({url: "storage/upload", method: "POST", key: "upload", path: imgPaht, data: data})
export default({
uploadImg
})

45
api/interfaces/index.js Normal file
View File

@@ -0,0 +1,45 @@
/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
import {req} from "../request"
//首页
const home = () => req({url: "gout"})
//商品详情
const goods = (activity_id) => req({url: "mall/activities/" + activity_id})
//打卡海报背景
const poster = () => req({url: "user/sign/backgrounds"})
//喝水打卡
const sign = () => req({url: "user/sign", method: 'POST'})
//喝水补卡
const replenish = (data) => req({url: "user/sign/replenish", method: 'POST', data: data})
//喝水打卡日历
const calendar = () => req({url: "user/sign"})
//反馈列表
const surveys = (data) => req({url: "gout/surveys", data: data})
//反馈列表
const surveysForm = (data) => req({url: "gout/surveys", method: 'POST', data: data})
//我的反馈前置
const feedback = () => req({url: "gout/result/" + user_case_id + "/logs"})
export default({
home,
goods,
poster,
sign,
replenish,
calendar,
surveys,
surveysForm,
feedback
})

49
api/interfaces/mall.js Normal file
View File

@@ -0,0 +1,49 @@
/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
import {req} from "../request"
//商城首页
const index = () => req({url: "mall"})
//商品详情
const goodsShow = (goods) => req({url: "mall/goods/" + goods})
//创建订单
const foundOrder = (data) => req({url: "mall/buy/goods", data: data})
//确认订单
const affirmOrder = (data) => req({url: "mall/buy/goods", method: 'POST', data: data})
//水滴支付
const affirmPay = (order_no) => req({url: "mall/pay/" + order_no + "/score", method: 'POST'})
//文章详情
const articlesSee = (article_id) => req({url: "cms/articles/" + article_id})
// //文章列表
const articlesList = (data) => req({url: "cms/articles", data: data})
//收藏
const favorite = (article_id) => req({url: "cms/articles/favorite/" + article_id})
//点赞
const subscribe = (article_id) => req({url: "cms/articles/subscribe/" + article_id})
//文章列表-全部分类
const classifysAll = () => req({url: "cms/categories"})
//文章列表-全部
const favorites = (data) => req({url: "cms/articles", data: data})
export default({
index,
goodsShow,
foundOrder,
affirmOrder,
affirmPay,
articlesSee,
articlesList,
favorite,
subscribe,
classifysAll,
favorites
})

61
api/interfaces/member.js Normal file
View File

@@ -0,0 +1,61 @@
/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
import {req} from "../request"
//添加病例-前置
const goutCreate = () => req({url: "gout/result/create"})
//添加病例
const goutAdd = (data) => req({url: "gout/result", method: 'POST', data: data})
// 查看病例
const goutSee = () => req({url: "gout/result"})
// 添加报告
const AddlastLog = (user_case_id, data) => req({url: "gout/result/" + user_case_id + "/logs", method: 'POST', data: data})
// 报告记录
const ListLog = (user_case_id, data) => req({url: "gout/result/" + user_case_id + "/logs", data: data})
// 健康记录时间轴
const timelSee = (data) => req({url: "gout/result/timelines", data: data})
// 会员权益信息
const identitySee = (identity) => req({url: "user/identities/" + identity})
// 确认开通身份
const identityOpen = (identity_id) => req({url: "user/identities/create/" + identity_id, method: 'POST'})
// 确认开通身份
const identityPay = (order_id, data) => req({url: "user/identities/pay/" + order_id + "/wechat", data: data})
// 激活码支付
const codePay = (order_id, data) => req({url: "user/identities/pay/" + order_id + "/invite", method: 'POST', data: data})
// 体检报告数据
const lastLog = (order_id, data) => req({url: "gout/result/last_log"})
// 开通会员身份
const openIndex = (identity_id, data) => req({url: "user/identities/create/" + identity_id, method: 'POST', data: data})
// 获取小程序openid
const openid = (data) => req({url: "user/auth/mini_openid", data: data})
export default({
goutCreate,
goutAdd,
goutSee,
AddlastLog,
ListLog,
timelSee,
identitySee,
identityOpen,
identityPay,
codePay,
lastLog,
openIndex,
openid
})

42
api/interfaces/stock.js Normal file
View File

@@ -0,0 +1,42 @@
/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
* 库存
*/
import {req} from "../request"
//提货前置
const pick = () => req({url: "user/stock/pick"})
//提货列表-记录
const list = (data) => req({url: "user/stock", data: data})
//账变记录
const logs = (data) => req({url: "user/stock/logs", data: data})
//提货提交
const pickTake = (data) => req({url: "user/stock/pick", method: 'POST', data: data})
//省市区-获取
const create = (data) => req({url: "mall/addresses/create", data: data})
//新增地址
const siteAdd = (data) => req({url: "mall/addresses", method: 'POST', data: data})
//地址列表
const siteList = () => req({url: "mall/addresses"})
// 删除地址
const siteDel = (address) => req({url: "mall/addresses/" + address, method: 'DELETE'})
export default({
pick,
list,
logs,
pickTake,
create,
siteAdd,
siteList,
siteDel
})

149
api/interfaces/user.js Normal file
View File

@@ -0,0 +1,149 @@
/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
import {req} from "../request"
//首页
const userIndex = () => req({url: "user"})
//订单
const orders = (data) => req({url: "mall/orders", data: data})
//订单详情
const goodsDet = (order_no) => req({url: "mall/orders/" + order_no})
//订单签收
const goodsSign = (order_no) => req({url: "mall/orders/" + order_no + "/sign", method: 'PUT'})
//我的抵值券
const coupon = (data) => req({url: "coupons/user/coupons", data: data})
//我的抵值券列表
const couponList = (coupon_id, data) => req({url: "coupons/user/coupons/" + coupon_id + "/list", data: data})
//现金账户
const account = (data) => req({url: "user/account/balance", data: data})
//我的提现记录
const bankList = (data) => req({url: "withdraws/index", data: data})
//提现前置
const createUser = () => req({url: "withdraws/index/create"})
//提现提交
const bankCash = (data) => req({url: "withdraws/index",method: 'POST', data: data})
//添加账户前置
const create = () => req({url: "withdraws/accounts/create"})
//添加账户
const createAdd = (data) => req({url: "withdraws/accounts", method: 'POST', data: data})
//账户编辑提交
const bankPut = (bank_account_id,data) => req({url: "withdraws/accounts/" + bank_account_id, method: 'PUT', data: data})
//我的银行卡列表
const createList = (data) => req({url: "withdraws/accounts", data: data})
//我的银行卡账户编辑
const bankEdit = (bank_account_id) => req({url: "withdraws/accounts/" + bank_account_id + "/edit"})
//删除银行卡
const bankDel = (bank_account_id) => req({url: "withdraws/accounts/" + bank_account_id, method: 'DELETE'})
//我的伙伴
const relations = (data) => req({url: "user/relations", data: data})
//消息
const notice = () => req({url: "notifications"})
//消息列表
const noticeList = (type,data) => req({url: "notifications/" + type + "/list", data: data})
//消息详情
const noticeShow = (notification_id) => req({url: "notifications/" + notification_id})
//上传头像
const setting = (key,data) => req({url: "user/setting/" + key, method: 'PUT', data: data})
//我的推广码
const invite = () => req({url: "user/invite"})
//水滴账户
const score = (data) => req({url: "user/account/score", data: data})
//激活码管理
const invites = (data) => req({url: "user/invites", data: data})
//微信授权
const authFollow = (data) => req({url: "user/auth/get_auth_url", data: data})
//小程序入库用户数据(微信授权)
const wechatMini = (data) => req({url: "user/socialite/login/wechat/mini/add", method: 'POST', data: data})
//我的推广码
const invitesCode = () => req({url: "user/invite"})
//小开通前置
const identitiesee = (identity_id) => req({url: "user/identities/create/" + identity_id})
//小程序码
const miniShare = (data) => req({url: "user/mini_share", data: data})
//我的收藏
const favorites = (data) => req({url: "user/favorites", data: data})
//产品中心-分类
const mallCategories = (data) => req({url: "mall/categories", data: data})
//产品中心-列表
const mallGoods = (data) => req({url: "mall/goods", data: data})
//任务分类
const taskIndex = () => req({url: "tasks/categories"})
//任务列表
const taskList = (data) => req({url: "tasks", data: data})
//微信运动
const wechatStep = (data) => req({url: "tasks/wechat_step", data: data})
export default({
userIndex,
orders,
goodsDet,
goodsSign,
coupon,
couponList,
account,
bankList,
createUser,
bankCash,
create,
createAdd,
bankPut,
createList,
bankEdit,
bankDel,
relations,
notice,
noticeList,
noticeShow,
setting,
invite,
score,
invites,
authFollow,
wechatMini,
invitesCode,
identitiesee,
miniShare,
favorites,
mallCategories,
mallGoods,
taskIndex,
taskList,
wechatStep
})

136
api/request.js Normal file
View File

@@ -0,0 +1,136 @@
/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
import {errInfo} from './err'
import {updToken} from './updateToken'
// 请求方式配置
// https://api.water.shangkelian.cn //测试地址
// https://api.siyuankunlun.com //正式地址
// wxecf8786d25af47b3 正式appid
const api = "https://api.siyuankunlun.com/api/"
const header = {
"Accept" : "application/json"
}
let isToken = true
/**
* 请求
* @property {Object} req
*/
const req = (obj, noToken) => {
// 检查是否无需要token
if(noToken != undefined){
isToken = noToken
}
// header
if(obj.token){
header.Authorization = obj.token || ''
} else {
header.Authorization = wx.getStorageSync("token") || ""
}
// 处理请求信息
return new Promise((resolve, reject) => {
// 组合header
obj.header = {
"Accept" : "application/json",
"Authorization" : wx.getStorageSync("token") || ""
}
if(!isToken){
obj.header.Authorization = ''
}
wx.request({
url : api + obj.url,
header : obj.header || {},
method : obj.method || 'GET',
data : obj.data || {},
success : res => {
// 更新token
if (res.header.Authorization) updToken(res.header.Authorization)
// 处理信息
if (res.data.status_code == 200) {
resolve(res.data)
} else {
if (res.data.status_code == 401 || res.data.status_code == 400) {
reject({
login : false,
codeBeen: false
})
}
errInfo(res.data)
}
},
fail: err => {
wx.showToast({
title : err.errMsg,
icon : "none"
})
reject(err)
},
complete(){
if(!isToken) isToken = true
}
})
})
}
/**
* 上传
* @property {Object} upload
*/
const upload = (obj) => {
// header
header.Authorization = wx.getStorageSync("token") || ""
// 处理上传信息
return new Promise((resolve, reject) => {
wx.showLoading({
title: "上传中..",
mask: true
})
wx.uploadFile({
url : api + obj.url,
header : header,
name : obj.key || "",
filePath: obj.path || "",
formData: obj.data || {},
success : res=>{
wx.hideLoading();
// 处理返回值
let jsonData = JSON.parse(res.data)
// 更新token
if (res.header.Authorization) updToken(res.header.Authorization)
// 处理信息
if (jsonData.status_code == 200) {
resolve(jsonData.data)
} else {
if (jsonData.status_code == 401) {
reject({
login: false
})
}
errInfo(jsonData)
}
},
fail : err=>{
wx.showToast({
title : err.errMsg,
icon : "none"
})
reject(err)
}
})
})
}
module.exports = {
req,
upload
}

21
api/updateToken.js Normal file
View File

@@ -0,0 +1,21 @@
/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
/**
* 更新token
* @property {String} updToken
*/
const updToken = (token) =>{
// 更新全局存储器
getApp().globalData.token = token
// 更新客户端登录缓存
wx.setStorageSync('token', token)
}
module.exports = {
updToken
}