first commit

This commit is contained in:
PC-202306242200\Administrator
2026-03-28 23:27:25 +08:00
commit 85b89ccea7
1694 changed files with 168292 additions and 0 deletions

36
com/auth.js Normal file
View File

@@ -0,0 +1,36 @@
export const getUserProfile() {
uni.getUserProfile({
desc: '完善个人信息',
async success({
userInfo
}) {
const {
code
} = await getUserLoginCode();
const {
data,
status,
message
} = await login(code, userInfo);
} else {
}
}
});
}
// 获取用户登录code值
export const getUserLoginCode = () => {
return new Promise((resolve, reject) => {
uni.login({
success(code) {
resolve(code);
},
fail(err) {
reject(err);
}
})
})
}

127
com/http.js Normal file
View File

@@ -0,0 +1,127 @@
import store from '../store'
let authStatus = 0;
import {
API_URL,
STATIC_URL
} from '@/env'
const request = (options = {}) => {
const token = store.state.auth.token;
const location = store.state.location.current;
// 在这里可以对请求头进行一些设置
// 例如:
options.header = {
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
"Authorization": token.token_type + ' ' + token.access_token,
}
return new Promise((resolve, reject) => {
if (authStatus == 401) {
authStatus = 0
}
// uni.showLoading({
// title: '',
// mask: true
// });
let url = options.url;
if (options.url.indexOf('https://') == -1) {
url = API_URL + options.url;
}
uni.request({
url: url || '',
method: options.type || 'GET',
data: {
...options.data
} || {},
timeout: 50000,
header: options.header || {},
success: (res) => {
if (res != undefined && res.statusCode == 401) {
if (authStatus == 0) {
// uni.navigateTo({
// url: '/pages/me/login'
// })
store.commit('auth/resetUser');
store.commit('auth/resetToken');
uni.clearStorageSync();
uni.showModal({
title: '提示',
content: '为提供更好的服务,请登录后继续',
//showCancel:false,
confirmText: '立即登录',
cancelText: '随便逛逛',
success: function(res) {
if (res.confirm) {
uni.navigateTo({
url: '/pages/me/login'
});
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
authStatus = 401
}
if (res != undefined && res.statusCode == 429) {
uni.showToast({
icon: 'none',
title: res.data.msg,
duration: 3000
});
}
if (res != undefined && res.statusCode == 200 && !res.data.success) {
uni.showToast({
icon: 'none',
title: res.data.msg,
duration: 3000
});
}
if (res.statusCode == 200 && res.data.success && res.data.show == 1) {
uni.showToast({
icon: 'none',
title: res.data.msg,
duration: 3000
});
}
//uni.hideLoading();
resolve(res.data);
},
fail: (err) => {
uni.showToast({
title: err.errMsg,
icon: 'error'
})
//uni.hideLoading();
reject(err);
}
})
});
}
const get = (url, data, options = {}) => {
options.type = 'GET';
options.data = data;
options.url = url;
return request(options)
}
const post = (url, data, options = {}) => {
options.type = 'POST';
options.data = data;
options.url = url;
return request(options)
}
export default {
request,
get,
post
}

314
com/index.scss Normal file
View File

@@ -0,0 +1,314 @@
view {
box-sizing: border-box;
color: #333;
}
// button {
// all: unset;
// }
button::after {
border: none;
all: unset;
}
page {
background-color: #f5f5f5;
}
.p-30 {
padding: 0 30rpx;
}
.p-t20 {
padding: 20rpx 0rpx;
}
.bgf {
background-color: #fff;
}
.br10 {
border-radius: 10rpx;
}
.br20 {
border-radius: 20rpx;
}
.mt30 {
margin-top: 30rpx;
}
.flex {
display: flex;
}
.flex-ac {
display: flex;
align-items: center;
}
.fs28 {
font-size: 28rpx;
}
.top-backgroup {
height: 450rpx;
z-index: -1;
}
.backgroud-image {
width: 100%;
height: 450rpx;
z-index: -1;
}
/* 页面阴影 start*/
.wallpaper-shadow {
border-radius: 15rpx;
box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
background-color: #fff;
margin-top: 30rpx;
padding: 20rpx 0;
}
.xkl-com-bg{
padding: 0 30rpx;
}
.shadow_img {
// box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.1);
}
// flex布局
.u-flex,
.u-flex-row,
.u-flex-x {
display: flex;
flex-direction: row;
}
.u-flex-y,
.u-flex-column {
display: flex;
flex-direction: column;
}
.u-flex-x-center {
display: flex;
flex-direction: row;
justify-content: center;
}
.u-flex-xy-center {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.u-flex-y-center {
display: flex;
flex-direction: row;
align-items: center;
}
.u-flex-x-left {
display: flex;
flex-direction: row;
}
.u-flex-x-reverse,
.u-flex-row-reverse {
flex-direction: row-reverse;
}
.u-flex-y-reverse,
.u-flex-column-reverse {
flex-direction: column-reverse;
}
/* #ifndef APP-NVUE */
// 此处为vue版本的简写因为nvue不支持同时作用于两个类名的样式写法
// nvue下只能写成class="u-flex-x u-flex-x-reverse的形式"
.u-flex.u-flex-reverse,
.u-flex-row.u-flex-reverse,
.u-flex-x.u-flex-reverse {
flex-direction: row-reverse;
}
.u-flex-column.u-flex-reverse,
.u-flex-y.u-flex-reverse {
flex-direction: column-reverse;
}
// 自动伸缩
.u-flex-fill {
flex: 1 1 auto;
}
// 边界自动伸缩
.u-margin-top-auto,
.u-m-t-auto {
margin-top: auto !important;
}
.u-margin-right-auto,
.u-m-r-auto {
margin-right: auto !important;
}
.u-margin-bottom-auto,
.u-m-b-auto {
margin-bottom: auto !important;
}
.u-margin-left-auto,
.u-m-l-auto {
margin-left: auto !important;
}
.u-margin-center-auto,
.u-m-c-auto {
margin-left: auto !important;
margin-right: auto !important;
}
.u-margin-middle-auto,
.u-m-m-auto {
margin-top: auto !important;
margin-bottom: auto !important;
}
/* #endif */
// 换行
.u-flex-wrap {
flex-wrap: wrap;
}
// 反向换行
.u-flex-wrap-reverse {
flex-wrap: wrap-reverse;
}
// 主轴起点对齐
.u-flex-start {
justify-content: flex-start;
}
// 主轴中间对齐
.u-flex-center {
justify-content: center;
}
// 主轴终点对齐
.u-flex-end {
justify-content: flex-end;
}
// 主轴等比间距
.u-flex-between {
justify-content: space-between;
}
// 主轴均分间距
.u-flex-around {
justify-content: space-around;
}
// 交叉轴起点对齐
.u-flex-items-start {
align-items: flex-start;
}
// 交叉轴中间对齐
.u-flex-items-center {
align-items: center;
}
// 交叉轴终点对齐
.u-flex-items-end {
align-items: flex-end;
}
// 交叉轴第一行文字基线对齐
.u-flex-items-baseline {
align-items: baseline;
}
// 交叉轴方向拉伸对齐
.u-flex-items-stretch {
align-items: stretch;
}
// 以下属于项目(子元素)的类
// 子元素交叉轴起点对齐
.u-flex-self-start {
align-self: flex-start;
}
// 子元素交叉轴居中对齐
.u-flex-self-center {
align-self: center;
}
// 子元素交叉轴终点对齐
.u-flex-self-end {
align-self: flex-end;
}
// 子元素交叉轴第一行文字基线对齐
.u-flex-self-baseline {
align-self: baseline;
}
// 子元素交叉轴方向拉伸对齐
.u-flex-self-stretch {
align-self: stretch;
}
// 多轴交叉时的对齐方式
// 起点对齐
.u-flex-content-start {
align-content: flex-start;
}
// 居中对齐
.u-flex-content-center {
align-content: center;
}
// 终点对齐
.u-flex-content-end {
align-content: flex-end;
}
// 两端对齐
.u-flex-content-between {
align-content: space-between;
}
// 均分间距
.u-flex-content-around {
align-content: space-around;
}
// 全部居中对齐
.u-flex-middle {
justify-content: center;
align-items: center;
align-self: center;
align-content: center;
}
// 是否可以放大
.u-flex-grow {
flex-grow: 1;
}
// 是否可以缩小
.u-flex-shrink {
flex-shrink: 1;
}

140
com/jssdk.js Normal file
View File

@@ -0,0 +1,140 @@
import wx from 'weixin-js-sdk';
import request from "./http.js";
export default {
/* 判断是否在微信中 */
isWechat: function() {
var ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/micromessenger/i) == 'micromessenger') {
//console.log('是微信客户端')
return true;
} else {
//console.log('不是微信客户端')
//以下是我项目中所需要的操作其他,可以自定义
uni.showModal({
title: '提示',
content: '请在微信浏览器中打开',
showCancel: false,
confirmColor: '#00875a',
success: function(res) {
if (res.confirm) {
// console.log('用户点击确定');
} else if (res.cancel) {
// console.log('用户点击取消');
}
}
});
return false;
}
},
/* 获取sdk初始化配置 */
initJssdk: async function(callback) {
//获取当前url然后传递给后台获取授权和签名信息
var url = encodeURIComponent(window.location.href.split('#')[0]); //当前网页的URL不包含#及其后面部分
console.log(window.location.href.split('#')[0]);
//这里调用的是后端的接口后端去获取签名以及config里面所需的信息
const {
data
} = await request.get('/com/wechat/jssdk', {
url: ''
})
//返回需要的参数appId,timestamp,noncestr,signature等
//注入config权限配置
const {
appId,
timestamp,
nonceStr,
signature,
debug,
jsApiList
} = data;
wx.config({
debug: debug, // 开启调试模式,调用的所有api的返回值会在客户端alert出来若要查看传入的参数可以在pc端打开参数信息会通过log打出仅在pc端时才会打印。
// beta: true, // 文档没有这个参数这个参数需设为true才能调用那些微信还没有正式开放的新接口比如wx.invoke
appId: appId, // 必填,公众号的唯一标识
timestamp: timestamp, // 必填,生成签名的时间戳
nonceStr: nonceStr, // 必填,生成签名的随机串
signature: signature, // 必填,签名
jsApiList: jsApiList
});
// 本地环境测试使用里面信息是测试号的appid和签名
// jWeixin.config({
// debug: true,
// appId: 'wx451eff21c6c0d938',
// timestamp: 1659065946,
// nonceStr: 'dzklsf',
// signature: 'd2ada1c92409e14c9e720ed58056dcd3800ab0a7',
// jsApiList: ['scanQRCode']
// })
// 本地环境测试结束
if (callback) {
callback(data);
}
},
//选择图片
chooseImage: function(callback) {
if (!this.isWechat()) {
//console.log('不是微信客户端')
return;
}
//console.log(data);
this.initJssdk(function(res) {
wx.ready(function() {
wx.chooseImage({
count: 1,
sizeType: ['compressed'],
sourceType: ['album'],
success: function(rs) {
callback(rs)
}
})
});
});
},
//微信支付
wxpay: function(data, callback) {
if (!this.isWechat()) {
//console.log('不是微信客户端')
return;
}
this.initJssdk(function(res) {
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
appId: 'wxcf948c7b5a0863b1',
timeStamp: data.timeStamp, // 支付签名时间戳注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
nonceStr: data.nonceStr, // 支付签名随机串,不长于 32 位
package: data.package, // 统一支付接口返回的prepay_id参数值提交格式如prepay_id=\*\*\*
signType: data.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
paySign: data.paySign, // 支付签名
},
function(res) {
callback(res)
}
);
// wx.ready(function() {
// wx.chooseWXPay({
// timeStamp: data
// .timeStamp, // 支付签名时间戳注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
// nonceStr: data.nonceStr, // 支付签名随机串,不长于 32 位
// package: data
// .package, // 统一支付接口返回的prepay_id参数值提交格式如prepay_id=\*\*\*
// signType: data.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
// paySign: data.paySign, // 支付签名
// success: function(res) {
// // console.log(res);
// callback(res)
// },
// fail: function(res) {
// callback(res)
// },
// });
// });
});
},
}

33
com/share.js Normal file
View File

@@ -0,0 +1,33 @@
module.exports = {
onLoad(options) {
if (options && options.invite_code) {
uni.setStorageSync('invite_code', options.invite_code);
}
//设置默认的转发参数
uni.$u.mpShare = {
title: '羿充电', // 默认为小程序名称
path: '', // 默认为当前页面路径
imageUrl: '' // 默认为当前页面的截图
}
},
// #ifdef MP-WEIXIN
onShareAppMessage() {
let user = uni.getStorageSync('user');
let invite_code = user ? user.invite_code : '';
uni.$u.mpShare.path = uni.$u.page() + '?invite_code=' + invite_code; // 默认为当前页面路径
return uni.$u.mpShare
},
// #endif
// #ifdef MP-WEIXIN
onShareTimeline() {
let user = uni.getStorageSync('user');
let invite_code = user ? user.invite_code : '';
uni.$u.mpShare.path = uni.$u.page() + '?invite_code=' + invite_code; // 默认为当前页面路径
return uni.$u.mpShare
}
// #endif
}

34
com/storage/auth.js Normal file
View File

@@ -0,0 +1,34 @@
const token = 'token';
const user = 'user';
export function getAuth() {
return {
token: uni.getStorageSync(token),
user: uni.getStorageSync(user),
};
}
export function getToken() {
return uni.getStorageSync(token);
}
export function getUser() {
return uni.getStorageSync(user);
}
// 设置value
export function setAuth(value) {
uni.setStorageSync(token, value.token);
uni.setStorageSync(user, value.user);
}
// 设置value
export function setUser(value) {
uni.setStorageSync(user, value);
}
export function setToken(value) {
uni.setStorageSync(token, value);
}
// 清除WxUserInfo
export function removeAuth() {
uni.removeStorageSync(token);
uni.removeStorageSync(user);
}