This commit is contained in:
Strange 2024-06-16 09:04:56 +08:00
parent 73b4a0e3ef
commit 3382462036
31 changed files with 982 additions and 44 deletions

17
comm/api.js Normal file
View File

@ -0,0 +1,17 @@
import {http} from "../utils/http.js"
export function loginByCode(data){
return http({
url:"/api/wxLogin",
data,
method:'post'
})
}
export function userInfo(){
return http({
url:"/api/getUserInfo",
method:'get'
})
}

View File

@ -3,10 +3,13 @@ import App from './App'
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
import msg from "./utils/msg.js"
Vue.config.productionTip = false
App.mpType = 'app'
Vue.prototype.$msg = msg
import uviewPlus from 'uview-plus'
const app = new Vue({
...App
})

View File

@ -50,7 +50,7 @@
"quickapp" : {},
/* */
"mp-weixin" : {
"appid" : "",
"appid" : "wx0beef2b22e05d3d1",
"setting" : {
"urlCheck" : false
},

View File

@ -28,6 +28,13 @@
"navigationStyle": "custom",
"disableScroll": false
}
},
{
"path": "pages/user/login",
"style": {
"navigationBarTitleText": "登录",
"navigationStyle": "default"
}
}
],
"globalStyle": {

52
pages/user/login.vue Normal file
View File

@ -0,0 +1,52 @@
<template>
<view class="main">
<view class="" style="width: 80%;margin: 0 auto;">
<up-button type="primary" @click="login" text="登录"></up-button>
</view>
</view>
</template>
<script setup>
import {
loginByCode
} from "@/comm/api.js"
import {setToken} from "@/utils/Auth.js"
async function login() {
const __this = this
uni.login({
provider: "weixin",
async success(e) {
try {
const resp = await loginByCode({
code: e.code
})
console.log(resp)
uni.showToast({
icon:"none",
title:"登录成功"
})
setToken(resp.token)
setTimeout(()=>{
uni.switchTab({
url:"/pages/user/user"
})
},800)
}catch(err){
uni.showToast({
icon:"none",
title:"登录失败"
})
}
}
})
}
</script>
<style>
.main {
height: 100vh;
display: flex;
align-items: center;
}
</style>

View File

@ -4,10 +4,10 @@
reactive
} from 'vue';
import {
onLoad
onLoad,onShow
} from "@dcloudio/uni-app"
import {isLogin,getToken} from "../../utils/Auth.js"
import {loginByCode,userInfo} from "@/comm/api.js"
const serviceList = reactive([{
title: "个人信息",
thumb: '/static/icon/icon_wdgrxx.png',
@ -25,9 +25,24 @@
avatar: "/static/icon/tx.png",
nickName: "点击登录"
})
function gologin(){
console.log(getToken())
if(isLogin()){
return
}
uni.navigateTo({
url:"/pages/user/login"
})
}
async function getUserInfo(){
const resp = await userInfo()
console.log(resp)
user.value = resp.data
}
onShow(()=>{
getUserInfo()
})
onLoad(() => {
})
</script>
@ -36,13 +51,13 @@
<view class="top-back">
<text class="page-title">我的</text>
<view class="info-box" @click="gologin">
<image :src="user.avatar||'/static/icon/tx.png'" mode="scaleToFill"></image>
<image :src="user.profilePicture||'/static/icon/tx.png'" mode="scaleToFill"></image>
<view class="text-box">
<text class="nick-name">
{{user.nickName}}
{{user.username}}
</text>
<view class="tag">
{{user.phonenumber}}
{{user.phoneNumber}}
</view>
</view>
</view>

View File

@ -5,6 +5,7 @@ if (!Math) {
"./pages/index/index.js";
"./pages/news/news.js";
"./pages/user/user.js";
"./pages/user/login.js";
}
const _sfc_main = {
onLaunch: function() {

View File

@ -2,7 +2,8 @@
"pages": [
"pages/index/index",
"pages/news/news",
"pages/user/user"
"pages/user/user",
"pages/user/login"
],
"window": {
"navigationBarTextStyle": "black",

View File

@ -0,0 +1,17 @@
"use strict";
const utils_http = require("../utils/http.js");
function loginByCode(data) {
return utils_http.http({
url: "/api/wxLogin",
data,
method: "post"
});
}
function userInfo() {
return utils_http.http({
url: "/api/getUserInfo",
method: "get"
});
}
exports.loginByCode = loginByCode;
exports.userInfo = userInfo;

View File

@ -6872,6 +6872,7 @@ const createSubpackageApp = initCreateSubpackageApp();
const createHook = (lifecycle) => (hook, target = getCurrentInstance()) => {
!isInSSRComponentSetup && injectHook(lifecycle, hook, target);
};
const onShow = /* @__PURE__ */ createHook(ON_SHOW);
const onLoad = /* @__PURE__ */ createHook(ON_LOAD);
const version = "3";
{
@ -8416,7 +8417,7 @@ const defProps = {
...Transition,
...Upload
};
const props$d = {
const props$e = {
props: {
// 搜索框形状round-圆形square-方形
shape: {
@ -9275,7 +9276,7 @@ const mixin = {
}
}
};
const props$c = {
const props$d = {
props: {
// 列表数组元素可为字符串如为对象可通过keyName指定目标属性名
list: {
@ -9400,7 +9401,7 @@ const props$c = {
}
}
};
const props$b = {
const props$c = {
props: {
// 宫格的name
name: {
@ -9414,7 +9415,7 @@ const props$b = {
}
}
};
const props$a = {
const props$b = {
props: {
// 分成几列
col: {
@ -9433,7 +9434,7 @@ const props$a = {
}
}
};
const props$9 = {
const props$a = {
props: {
// 主题颜色
type: {
@ -9655,7 +9656,7 @@ const openType = {
}
}
};
const props$8 = {
const props$9 = {
props: {
// 头像图片路径(不能为相对路径)
src: {
@ -9733,7 +9734,7 @@ const props$8 = {
}
}
};
const props$7 = {
const props$8 = {
props: {
// 标题
title: {
@ -9843,7 +9844,7 @@ const props$7 = {
}
}
};
const props$6 = {
const props$7 = {
props: {
// 用于滚动到指定item
anchor: {
@ -9852,7 +9853,7 @@ const props$6 = {
}
}
};
const props$5 = {
const props$6 = {
props: {
// 控制是否出现滚动条仅nvue有效
showScrollbar: {
@ -9951,6 +9952,176 @@ const props$5 = {
}
}
};
const props$5 = {
props: {
// 是否细边框
hairline: {
type: Boolean,
default: () => defProps.button.hairline
},
// 按钮的预置样式infoprimaryerrorwarningsuccess
type: {
type: String,
default: () => defProps.button.type
},
// 按钮尺寸largenormalsmallmini
size: {
type: String,
default: () => defProps.button.size
},
// 按钮形状circle两边为半圆square带圆角
shape: {
type: String,
default: () => defProps.button.shape
},
// 按钮是否镂空
plain: {
type: Boolean,
default: () => defProps.button.plain
},
// 是否禁止状态
disabled: {
type: Boolean,
default: () => defProps.button.disabled
},
// 是否加载中
loading: {
type: Boolean,
default: () => defProps.button.loading
},
// 加载中提示文字
loadingText: {
type: [String, Number],
default: () => defProps.button.loadingText
},
// 加载状态图标类型
loadingMode: {
type: String,
default: () => defProps.button.loadingMode
},
// 加载图标大小
loadingSize: {
type: [String, Number],
default: () => defProps.button.loadingSize
},
// 开放能力具体请看uniapp稳定关于button组件部分说明
// https://uniapp.dcloud.io/component/button
openType: {
type: String,
default: () => defProps.button.openType
},
// 用于 <form> 组件,点击分别会触发 <form> 组件的 submit/reset 事件
// 取值为submit提交表单reset重置表单
formType: {
type: String,
default: () => defProps.button.formType
},
// 打开 APP 时,向 APP 传递的参数open-type=launchApp时有效
// 只微信小程序、QQ小程序有效
appParameter: {
type: String,
default: () => defProps.button.appParameter
},
// 指定是否阻止本节点的祖先节点出现点击态,微信小程序有效
hoverStopPropagation: {
type: Boolean,
default: () => defProps.button.hoverStopPropagation
},
// 指定返回用户信息的语言zh_CN 简体中文zh_TW 繁体中文en 英文。只微信小程序有效
lang: {
type: String,
default: () => defProps.button.lang
},
// 会话来源open-type="contact"时有效。只微信小程序有效
sessionFrom: {
type: String,
default: () => defProps.button.sessionFrom
},
// 会话内消息卡片标题open-type="contact"时有效
// 默认当前标题,只微信小程序有效
sendMessageTitle: {
type: String,
default: () => defProps.button.sendMessageTitle
},
// 会话内消息卡片点击跳转小程序路径open-type="contact"时有效
// 默认当前分享路径,只微信小程序有效
sendMessagePath: {
type: String,
default: () => defProps.button.sendMessagePath
},
// 会话内消息卡片图片open-type="contact"时有效
// 默认当前页面截图,只微信小程序有效
sendMessageImg: {
type: String,
default: () => defProps.button.sendMessageImg
},
// 是否显示会话内消息卡片,设置此参数为 true用户进入客服会话会在右下角显示"可能要发送的小程序"提示,
// 用户点击后可以快速发送小程序消息open-type="contact"时有效
showMessageCard: {
type: Boolean,
default: () => defProps.button.showMessageCard
},
// 额外传参参数用于小程序的data-xxx属性通过target.dataset.name获取
dataName: {
type: String,
default: () => defProps.button.dataName
},
// 节流,一定时间内只能触发一次
throttleTime: {
type: [String, Number],
default: () => defProps.button.throttleTime
},
// 按住后多久出现点击态,单位毫秒
hoverStartTime: {
type: [String, Number],
default: () => defProps.button.hoverStartTime
},
// 手指松开后点击态保留时间,单位毫秒
hoverStayTime: {
type: [String, Number],
default: () => defProps.button.hoverStayTime
},
// 按钮文字之所以通过props传入是因为slot传入的话
// nvue中无法控制文字的样式
text: {
type: [String, Number],
default: () => defProps.button.text
},
// 按钮图标
icon: {
type: String,
default: () => defProps.button.icon
},
// 按钮图标
iconColor: {
type: String,
default: () => defProps.button.icon
},
// 按钮颜色支持传入linear-gradient渐变色
color: {
type: String,
default: () => defProps.button.color
}
}
};
let flag;
function throttle(func2, wait = 500, immediate = true) {
if (immediate) {
if (!flag) {
flag = true;
typeof func2 === "function" && func2();
setTimeout(() => {
flag = false;
}, wait);
}
} else if (!flag) {
flag = true;
setTimeout(() => {
flag = false;
typeof func2 === "function" && func2();
}, wait);
}
}
const icons = {
"uicon-level": "",
"uicon-column-line": "",
@ -10502,6 +10673,7 @@ exports._export_sfc = _export_sfc;
exports.addStyle = addStyle;
exports.addUnit = addUnit;
exports.button = button;
exports.color = color;
exports.colorGradient = colorGradient;
exports.config = config;
exports.createSSRApp = createSSRApp;
@ -10517,22 +10689,24 @@ exports.mpMixin = mpMixin;
exports.n = n;
exports.o = o;
exports.onLoad = onLoad;
exports.onShow = onShow;
exports.openType = openType;
exports.p = p;
exports.props = props$d;
exports.props$1 = props$c;
exports.props$10 = props$3;
exports.props$11 = props$2;
exports.props$12 = props$1;
exports.props$13 = props;
exports.props$2 = props$b;
exports.props$3 = props$a;
exports.props$4 = props$9;
exports.props$5 = props$8;
exports.props$6 = props$7;
exports.props$7 = props$6;
exports.props$8 = props$5;
exports.props$9 = props$4;
exports.props = props$e;
exports.props$1 = props$d;
exports.props$10 = props$4;
exports.props$11 = props$3;
exports.props$12 = props$2;
exports.props$13 = props$1;
exports.props$14 = props;
exports.props$2 = props$c;
exports.props$3 = props$b;
exports.props$4 = props$a;
exports.props$5 = props$9;
exports.props$6 = props$8;
exports.props$7 = props$7;
exports.props$8 = props$6;
exports.props$9 = props$5;
exports.random = random;
exports.reactive = reactive;
exports.ref = ref;
@ -10542,5 +10716,6 @@ exports.sleep = sleep;
exports.sys = sys;
exports.t = t;
exports.test = test;
exports.throttle = throttle;
exports.toast = toast;
exports.value = value;

View File

@ -0,0 +1,199 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "u-button",
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.button, common_vendor.openType, common_vendor.props$9],
data() {
return {};
},
computed: {
// 生成bem风格的类名
bemClass() {
if (!this.color) {
return this.bem(
"button",
["type", "shape", "size"],
["disabled", "plain", "hairline"]
);
} else {
return this.bem(
"button",
["shape", "size"],
["disabled", "plain", "hairline"]
);
}
},
loadingColor() {
if (this.plain) {
return this.color ? this.color : common_vendor.color[`u-${this.type}`];
}
if (this.type === "info") {
return "#c9c9c9";
}
return "rgb(200, 200, 200)";
},
iconColorCom() {
if (this.iconColor)
return this.iconColor;
if (this.plain) {
return this.color ? this.color : this.type;
} else {
return this.type === "info" ? "#000000" : "#ffffff";
}
},
baseColor() {
let style = {};
if (this.color) {
style.color = this.plain ? this.color : "white";
if (!this.plain) {
style["background-color"] = this.color;
}
if (this.color.indexOf("gradient") !== -1) {
style.borderTopWidth = 0;
style.borderRightWidth = 0;
style.borderBottomWidth = 0;
style.borderLeftWidth = 0;
if (!this.plain) {
style.backgroundImage = this.color;
}
} else {
style.borderColor = this.color;
style.borderWidth = "1px";
style.borderStyle = "solid";
}
}
return style;
},
// nvue版本按钮的字体不会继承父组件的颜色需要对每一个text组件进行单独的设置
nvueTextStyle() {
let style = {};
if (this.type === "info") {
style.color = "#323233";
}
if (this.color) {
style.color = this.plain ? this.color : "white";
}
style.fontSize = this.textSize + "px";
return style;
},
// 字体大小
textSize() {
let fontSize = 14, { size } = this;
if (size === "large")
fontSize = 16;
if (size === "normal")
fontSize = 14;
if (size === "small")
fontSize = 12;
if (size === "mini")
fontSize = 10;
return fontSize;
}
},
emits: [
"click",
"getphonenumber",
"getuserinfo",
"error",
"opensetting",
"launchapp",
"agreeprivacyauthorization"
],
methods: {
addStyle: common_vendor.addStyle,
clickHandler() {
if (!this.disabled && !this.loading) {
common_vendor.throttle(() => {
this.$emit("click");
}, this.throttleTime);
}
},
// 下面为对接uniapp官方按钮开放能力事件回调的对接
getphonenumber(res) {
this.$emit("getphonenumber", res);
},
getuserinfo(res) {
this.$emit("getuserinfo", res);
},
error(res) {
this.$emit("error", res);
},
opensetting(res) {
this.$emit("opensetting", res);
},
launchapp(res) {
this.$emit("launchapp", res);
},
agreeprivacyauthorization(res) {
this.$emit("agreeprivacyauthorization", res);
}
}
};
if (!Array) {
const _easycom_u_loading_icon2 = common_vendor.resolveComponent("u-loading-icon");
const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
(_easycom_u_loading_icon2 + _easycom_u_icon2)();
}
const _easycom_u_loading_icon = () => "../u-loading-icon/u-loading-icon.js";
const _easycom_u_icon = () => "../u-icon/u-icon.js";
if (!Math) {
(_easycom_u_loading_icon + _easycom_u_icon)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: _ctx.loading
}, _ctx.loading ? {
b: common_vendor.p({
mode: _ctx.loadingMode,
size: _ctx.loadingSize * 1.15,
color: $options.loadingColor
}),
c: common_vendor.t(_ctx.loadingText || _ctx.text),
d: common_vendor.s({
fontSize: $options.textSize + "px"
})
} : common_vendor.e({
e: _ctx.icon
}, _ctx.icon ? {
f: common_vendor.p({
name: _ctx.icon,
color: $options.iconColorCom,
size: $options.textSize * 1.35,
customStyle: {
marginRight: "2px"
}
})
} : {}, {
g: common_vendor.t(_ctx.text),
h: common_vendor.s({
fontSize: $options.textSize + "px"
})
}), {
i: Number(_ctx.hoverStartTime),
j: Number(_ctx.hoverStayTime),
k: _ctx.formType,
l: _ctx.openType,
m: _ctx.appParameter,
n: _ctx.hoverStopPropagation,
o: _ctx.sendMessageTitle,
p: _ctx.sendMessagePath,
q: _ctx.lang,
r: _ctx.dataName,
s: _ctx.sessionFrom,
t: _ctx.sendMessageImg,
v: _ctx.showMessageCard,
w: common_vendor.o((...args) => $options.getphonenumber && $options.getphonenumber(...args)),
x: common_vendor.o((...args) => $options.getuserinfo && $options.getuserinfo(...args)),
y: common_vendor.o((...args) => $options.error && $options.error(...args)),
z: common_vendor.o((...args) => $options.opensetting && $options.opensetting(...args)),
A: common_vendor.o((...args) => $options.launchapp && $options.launchapp(...args)),
B: common_vendor.o((...args) => $options.agreeprivacyauthorization && $options.agreeprivacyauthorization(...args)),
C: !_ctx.disabled && !_ctx.loading ? "u-button--active" : "",
D: common_vendor.s($options.baseColor),
E: common_vendor.s($options.addStyle(_ctx.customStyle)),
F: common_vendor.o((...args) => $options.clickHandler && $options.clickHandler(...args)),
G: common_vendor.n($options.bemClass)
});
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-461e713c"], ["__file", "C:/Users/33043/Desktop/文件/work/newStud学习/greenStu/node_modules/uview-plus/components/u-button/u-button.vue"]]);
wx.createComponent(Component);

View File

@ -0,0 +1,7 @@
{
"component": true,
"usingComponents": {
"u-loading-icon": "../u-loading-icon/u-loading-icon",
"u-icon": "../u-icon/u-icon"
}
}

View File

@ -0,0 +1 @@
<button hover-start-time="{{i}}" hover-stay-time="{{j}}" form-type="{{k}}" open-type="{{l}}" app-parameter="{{m}}" hover-stop-propagation="{{n}}" send-message-title="{{o}}" send-message-path="{{p}}" lang="{{q}}" data-name="{{r}}" session-from="{{s}}" send-message-img="{{t}}" show-message-card="{{v}}" bindgetphonenumber="{{w}}" bindgetuserinfo="{{x}}" binderror="{{y}}" bindopensetting="{{z}}" bindlaunchapp="{{A}}" bindagreeprivacyauthorization="{{B}}" hover-class="{{C}}" style="{{D + ';' + E}}" bindtap="{{F}}" class="{{['u-button', 'u-reset-button', 'data-v-461e713c', G]}}"><block wx:if="{{a}}"><u-loading-icon wx:if="{{b}}" class="data-v-461e713c" u-i="461e713c-0" bind:__l="__l" u-p="{{b}}"></u-loading-icon><text class="u-button__loading-text data-v-461e713c" style="{{d}}">{{c}}</text></block><block wx:else><u-icon wx:if="{{e}}" class="data-v-461e713c" u-i="461e713c-1" bind:__l="__l" u-p="{{f}}"></u-icon><block wx:if="{{$slots.d}}"><slot></slot></block><block wx:else><text class="u-button__text data-v-461e713c" style="{{h}}">{{g}}</text></block></block></button>

View File

@ -0,0 +1,188 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场https://ext.dcloud.net.cn上很多三方插件均使用了这些样式变量
* 如果你是插件开发者建议你使用scss预处理并在插件代码中直接使用这些变量无需 import 这个文件方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者插件使用者你可以通过修改这些变量来定制自己的插件主题实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.u-empty.data-v-461e713c,
.u-empty__wrap.data-v-461e713c,
.u-tabs.data-v-461e713c,
.u-tabs__wrapper.data-v-461e713c,
.u-tabs__wrapper__scroll-view-wrapper.data-v-461e713c,
.u-tabs__wrapper__scroll-view.data-v-461e713c,
.u-tabs__wrapper__nav.data-v-461e713c,
.u-tabs__wrapper__nav__line.data-v-461e713c {
display: flex;
flex-direction: column;
flex-shrink: 0;
flex-grow: 0;
flex-basis: auto;
align-items: stretch;
align-content: flex-start;
}
.u-button.data-v-461e713c {
width: 100%;
white-space: nowrap;
}
.u-button__text.data-v-461e713c {
white-space: nowrap;
line-height: 1;
}
.u-button.data-v-461e713c:before {
position: absolute;
top: 50%;
left: 50%;
width: 100%;
height: 100%;
border: inherit;
border-radius: inherit;
transform: translate(-50%, -50%);
opacity: 0;
content: " ";
background-color: #000;
border-color: #000;
}
.u-button--active.data-v-461e713c:before {
opacity: 0.15;
}
.u-button__icon + .u-button__text.data-v-461e713c:not(:empty), .u-button__loading-text.data-v-461e713c {
margin-left: 4px;
}
.u-button--plain.u-button--primary.data-v-461e713c {
color: #3c9cff;
}
.u-button--plain.u-button--info.data-v-461e713c {
color: #909399;
}
.u-button--plain.u-button--success.data-v-461e713c {
color: #5ac725;
}
.u-button--plain.u-button--error.data-v-461e713c {
color: #f56c6c;
}
.u-button--plain.u-button--warning.data-v-461e713c {
color: #f56c6c;
}
.u-button.data-v-461e713c {
height: 40px;
position: relative;
align-items: center;
justify-content: center;
display: flex;
flex-direction: row;
box-sizing: border-box;
flex-direction: row;
}
.u-button__text.data-v-461e713c {
font-size: 15px;
}
.u-button__loading-text.data-v-461e713c {
font-size: 15px;
margin-left: 4px;
}
.u-button--large.data-v-461e713c {
width: 100%;
height: 50px;
padding: 0 15px;
}
.u-button--normal.data-v-461e713c {
padding: 0 12px;
font-size: 14px;
}
.u-button--small.data-v-461e713c {
min-width: 60px;
height: 30px;
padding: 0px 8px;
font-size: 12px;
}
.u-button--mini.data-v-461e713c {
height: 22px;
font-size: 10px;
min-width: 50px;
padding: 0px 8px;
}
.u-button--disabled.data-v-461e713c {
opacity: 0.5;
}
.u-button--info.data-v-461e713c {
color: #323233;
background-color: #fff;
border-color: #ebedf0;
border-width: 1px;
border-style: solid;
}
.u-button--success.data-v-461e713c {
color: #fff;
background-color: #5ac725;
border-color: #5ac725;
border-width: 1px;
border-style: solid;
}
.u-button--primary.data-v-461e713c {
color: #fff;
background-color: #3c9cff;
border-color: #3c9cff;
border-width: 1px;
border-style: solid;
}
.u-button--error.data-v-461e713c {
color: #fff;
background-color: #f56c6c;
border-color: #f56c6c;
border-width: 1px;
border-style: solid;
}
.u-button--warning.data-v-461e713c {
color: #fff;
background-color: #f9ae3d;
border-color: #f9ae3d;
border-width: 1px;
border-style: solid;
}
.u-button--block.data-v-461e713c {
display: flex;
flex-direction: row;
width: 100%;
}
.u-button--circle.data-v-461e713c {
border-top-right-radius: 100px;
border-top-left-radius: 100px;
border-bottom-left-radius: 100px;
border-bottom-right-radius: 100px;
}
.u-button--square.data-v-461e713c {
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
.u-button__icon.data-v-461e713c {
min-width: 1em;
line-height: inherit !important;
vertical-align: top;
}
.u-button--plain.data-v-461e713c {
background-color: #fff;
}
.u-button--hairline.data-v-461e713c {
border-width: 0.5px !important;
}

View File

@ -6,7 +6,7 @@ const _sfc_main = {
return {};
},
emits: ["click"],
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$9],
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$10],
computed: {
uClasses() {
let classes = [];

View File

@ -2,7 +2,7 @@
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "u-line",
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$13],
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$14],
computed: {
lineStyle() {
const style = {};

View File

@ -2,7 +2,7 @@
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "u-link",
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$12],
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$13],
computed: {
linkStyle() {
const style = {

View File

@ -2,7 +2,7 @@
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "u-loading-icon",
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$10],
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$11],
data() {
return {
// Array.form可以通过一个伪数组对象创建指定长度的数组

View File

@ -2,7 +2,7 @@
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "u-swiper-indicator",
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$11],
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$12],
data() {
return {
lineWidth: 22

View File

@ -0,0 +1,57 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const comm_api = require("../../comm/api.js");
const utils_Auth = require("../../utils/Auth.js");
require("../../utils/http.js");
if (!Array) {
const _easycom_up_button2 = common_vendor.resolveComponent("up-button");
_easycom_up_button2();
}
const _easycom_up_button = () => "../../node-modules/uview-plus/components/u-button/u-button.js";
if (!Math) {
_easycom_up_button();
}
const _sfc_main = {
__name: "login",
setup(__props) {
async function login() {
common_vendor.index.login({
provider: "weixin",
async success(e) {
try {
const resp = await comm_api.loginByCode({
code: e.code
});
console.log(resp);
common_vendor.index.showToast({
icon: "none",
title: "登录成功"
});
utils_Auth.setToken(resp.token);
setTimeout(() => {
common_vendor.index.switchTab({
url: "/pages/user/user"
});
}, 800);
} catch (err) {
common_vendor.index.showToast({
icon: "none",
title: "登录失败"
});
}
}
});
}
return (_ctx, _cache) => {
return {
a: common_vendor.o(login),
b: common_vendor.p({
type: "primary",
text: "登录"
})
};
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "C:/Users/33043/Desktop/文件/work/newStud学习/greenStu/pages/user/login.vue"]]);
wx.createPage(MiniProgramPage);

View File

@ -0,0 +1,7 @@
{
"navigationBarTitleText": "登录",
"navigationStyle": "default",
"usingComponents": {
"up-button": "../../node-modules/uview-plus/components/u-button/u-button"
}
}

View File

@ -0,0 +1 @@
<view class="main"><view class="" style="width:80%;margin:0 auto"><up-button wx:if="{{b}}" bindclick="{{a}}" u-i="35531eb2-0" bind:__l="__l" u-p="{{b}}"></up-button></view></view>

View File

@ -0,0 +1,6 @@
.main {
height: 100vh;
display: flex;
align-items: center;
}

View File

@ -1,5 +1,8 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_Auth = require("../../utils/Auth.js");
const comm_api = require("../../comm/api.js");
require("../../utils/http.js");
if (!Array) {
const _easycom_up_avatar2 = common_vendor.resolveComponent("up-avatar");
const _easycom_up_cell2 = common_vendor.resolveComponent("up-cell");
@ -33,14 +36,31 @@ const _sfc_main = {
avatar: "/static/icon/tx.png",
nickName: "点击登录"
});
function gologin() {
console.log(utils_Auth.getToken());
if (utils_Auth.isLogin()) {
return;
}
common_vendor.index.navigateTo({
url: "/pages/user/login"
});
}
async function getUserInfo() {
const resp = await comm_api.userInfo();
console.log(resp);
user.value = resp.data;
}
common_vendor.onShow(() => {
getUserInfo();
});
common_vendor.onLoad(() => {
});
return (_ctx, _cache) => {
return {
a: user.value.avatar || "/static/icon/tx.png",
b: common_vendor.t(user.value.nickName),
c: common_vendor.t(user.value.phonenumber),
d: common_vendor.o((...args) => _ctx.gologin && _ctx.gologin(...args)),
a: user.value.profilePicture || "/static/icon/tx.png",
b: common_vendor.t(user.value.username),
c: common_vendor.t(user.value.phoneNumber),
d: common_vendor.o(gologin),
e: common_vendor.f(serviceList, (item, index, i0) => {
return {
a: "0f7520f0-3-" + i0 + "," + ("0f7520f0-2-" + i0),

View File

@ -15,11 +15,12 @@
"ignore": [],
"disablePlugins": [],
"outputPath": ""
}
},
"ignoreUploadUnusedFiles": false
},
"compileType": "miniprogram",
"libVersion": "3.4.6",
"appid": "touristappid",
"appid": "wx0beef2b22e05d3d1",
"projectname": "greenStu",
"condition": {},
"editorSetting": {

View File

@ -0,0 +1,15 @@
"use strict";
const common_vendor = require("../common/vendor.js");
var Admin = "token";
function setToken(token) {
common_vendor.index.setStorageSync(Admin, token);
}
function getToken() {
return common_vendor.index.getStorageSync(Admin);
}
function isLogin() {
return common_vendor.index.getStorageSync(Admin) ? true : false;
}
exports.getToken = getToken;
exports.isLogin = isLogin;
exports.setToken = setToken;

View File

@ -0,0 +1,37 @@
"use strict";
const common_vendor = require("../common/vendor.js");
const utils_Auth = require("./Auth.js");
const baseUrl = "http://127.0.0.1:8085";
const http = (option) => {
if (!option instanceof Object) {
throw "参数非法";
}
const { url, data } = option;
const token = utils_Auth.getToken();
return new Promise((resolve, reject) => {
common_vendor.index.request({
header: {
Authorization: token,
...option.header
},
url: baseUrl + url,
data,
method: option.method,
success(res) {
resolve(res.data);
if (res.data.code == 401) {
common_vendor.index.showToast({
icon: "none",
title: "请登录后使用该功能"
});
common_vendor.index.removeStorageSync("token");
}
},
fail(err) {
console.log(err);
reject(err);
}
});
});
};
exports.http = http;

14
utils/Auth.js Normal file
View File

@ -0,0 +1,14 @@
var Admin = "token"
export function setToken(token){
uni.setStorageSync(Admin,token)
}
export function getToken(){
return uni.getStorageSync(Admin)
}
export function isLogin(){
return uni.getStorageSync(Admin)?true:false
}

60
utils/http.js Normal file
View File

@ -0,0 +1,60 @@
// export const baseUrl = "https://9miao.fun/prod-api/"
import {getToken} from "./Auth.js"
export const baseUrl = "http://127.0.0.1:8085"
export const http = (option) =>{
if (!option instanceof Object){
throw "参数非法"
}
const {url,data} = option
const token = getToken()
return new Promise((resolve,reject)=>{
uni.request({
header:{
Authorization:token,
...option.header
},
url:baseUrl+url,
data,
method:option.method,
success(res) {
resolve(res.data)
if(res.data.code==401){
uni.showToast({
icon:"none",
title:"请登录后使用该功能"
})
uni.removeStorageSync("token")
}
},
fail(err) {
console.log(err)
reject(err)
}
})
})
}
export function uploadFile(file) {
const token = uni.getStorageSync("token");
return new Promise((resolve, reject) => {
uni.uploadFile({
url: `${baseUrl}/common/alibabaUpload`,
filePath: file,
name: 'file',
header: {
Authorization: token,
},
success: (res) => {
setTimeout(() => {
resolve(res.data);
}, 1000);
},
fail: (err) => {
console.log(err);
reject(err);
}
});
});
}

24
utils/location.js Normal file
View File

@ -0,0 +1,24 @@
import {
http
} from "./http.js"
const key = "ae9fa14b945ed3a3ff054e5a189a7478"
export function coordinateToLocation(longitude, latitude) {
return new Promise((resolve,reject)=>{
uni.request({
url: "https://restapi.amap.com/v3/geocode/regeo",
method: "get",
data: {
key: key,
location: `${longitude},${latitude}`
// coordsys: "gps"
},
success(res) {
console.log(res)
resolve(res)
},
fail(err) {
reject(err)
}
})
})
}

13
utils/msg.js Normal file
View File

@ -0,0 +1,13 @@
const showtitle =(msg)=>{
uni.showToast({
icon:"none",
title:msg
})
}
export default{
showtitle
}