From 3382462036dd84d1e6a59de99beb3111a5c4d3a4 Mon Sep 17 00:00:00 2001 From: Strange <3304393868@qq.com> Date: Sun, 16 Jun 2024 09:04:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/api.js | 17 ++ main.js | 3 + manifest.json | 2 +- pages.json | 7 + pages/user/login.vue | 52 +++++ pages/user/user.vue | 31 ++- unpackage/dist/dev/mp-weixin/app.js | 1 + unpackage/dist/dev/mp-weixin/app.json | 3 +- unpackage/dist/dev/mp-weixin/comm/api.js | 17 ++ unpackage/dist/dev/mp-weixin/common/vendor.js | 221 ++++++++++++++++-- .../components/u-button/u-button.js | 199 ++++++++++++++++ .../components/u-button/u-button.json | 7 + .../components/u-button/u-button.wxml | 1 + .../components/u-button/u-button.wxss | 188 +++++++++++++++ .../uview-plus/components/u-icon/u-icon.js | 2 +- .../uview-plus/components/u-line/u-line.js | 2 +- .../uview-plus/components/u-link/u-link.js | 2 +- .../u-loading-icon/u-loading-icon.js | 2 +- .../u-swiper-indicator/u-swiper-indicator.js | 2 +- .../dist/dev/mp-weixin/pages/user/login.js | 57 +++++ .../dist/dev/mp-weixin/pages/user/login.json | 7 + .../dist/dev/mp-weixin/pages/user/login.wxml | 1 + .../dist/dev/mp-weixin/pages/user/login.wxss | 6 + .../dist/dev/mp-weixin/pages/user/user.js | 28 ++- .../dist/dev/mp-weixin/project.config.json | 5 +- unpackage/dist/dev/mp-weixin/utils/Auth.js | 15 ++ unpackage/dist/dev/mp-weixin/utils/http.js | 37 +++ utils/Auth.js | 14 ++ utils/http.js | 60 +++++ utils/location.js | 24 ++ utils/msg.js | 13 ++ 31 files changed, 982 insertions(+), 44 deletions(-) create mode 100644 comm/api.js create mode 100644 pages/user/login.vue create mode 100644 unpackage/dist/dev/mp-weixin/comm/api.js create mode 100644 unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.js create mode 100644 unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.json create mode 100644 unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.wxml create mode 100644 unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.wxss create mode 100644 unpackage/dist/dev/mp-weixin/pages/user/login.js create mode 100644 unpackage/dist/dev/mp-weixin/pages/user/login.json create mode 100644 unpackage/dist/dev/mp-weixin/pages/user/login.wxml create mode 100644 unpackage/dist/dev/mp-weixin/pages/user/login.wxss create mode 100644 unpackage/dist/dev/mp-weixin/utils/Auth.js create mode 100644 unpackage/dist/dev/mp-weixin/utils/http.js create mode 100644 utils/Auth.js create mode 100644 utils/http.js create mode 100644 utils/location.js create mode 100644 utils/msg.js diff --git a/comm/api.js b/comm/api.js new file mode 100644 index 0000000..712a613 --- /dev/null +++ b/comm/api.js @@ -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' + }) +} \ No newline at end of file diff --git a/main.js b/main.js index b6db895..4c32b33 100644 --- a/main.js +++ b/main.js @@ -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 }) diff --git a/manifest.json b/manifest.json index 79505cf..2f92ccf 100644 --- a/manifest.json +++ b/manifest.json @@ -50,7 +50,7 @@ "quickapp" : {}, /* 小程序特有相关 */ "mp-weixin" : { - "appid" : "", + "appid" : "wx0beef2b22e05d3d1", "setting" : { "urlCheck" : false }, diff --git a/pages.json b/pages.json index c95a15a..4719ebe 100644 --- a/pages.json +++ b/pages.json @@ -28,6 +28,13 @@ "navigationStyle": "custom", "disableScroll": false } + }, + { + "path": "pages/user/login", + "style": { + "navigationBarTitleText": "登录", + "navigationStyle": "default" + } } ], "globalStyle": { diff --git a/pages/user/login.vue b/pages/user/login.vue new file mode 100644 index 0000000..665ff59 --- /dev/null +++ b/pages/user/login.vue @@ -0,0 +1,52 @@ + + + + + \ No newline at end of file diff --git a/pages/user/user.vue b/pages/user/user.vue index 4bd8480..f2e4064 100644 --- a/pages/user/user.vue +++ b/pages/user/user.vue @@ -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(() => { - }) @@ -36,13 +51,13 @@ 我的 - + - {{user.nickName}} + {{user.username}} - {{user.phonenumber}} + {{user.phoneNumber}} diff --git a/unpackage/dist/dev/mp-weixin/app.js b/unpackage/dist/dev/mp-weixin/app.js index e773c07..d137b92 100644 --- a/unpackage/dist/dev/mp-weixin/app.js +++ b/unpackage/dist/dev/mp-weixin/app.js @@ -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() { diff --git a/unpackage/dist/dev/mp-weixin/app.json b/unpackage/dist/dev/mp-weixin/app.json index 1ef0c15..2bba785 100644 --- a/unpackage/dist/dev/mp-weixin/app.json +++ b/unpackage/dist/dev/mp-weixin/app.json @@ -2,7 +2,8 @@ "pages": [ "pages/index/index", "pages/news/news", - "pages/user/user" + "pages/user/user", + "pages/user/login" ], "window": { "navigationBarTextStyle": "black", diff --git a/unpackage/dist/dev/mp-weixin/comm/api.js b/unpackage/dist/dev/mp-weixin/comm/api.js new file mode 100644 index 0000000..64ddf19 --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/comm/api.js @@ -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; diff --git a/unpackage/dist/dev/mp-weixin/common/vendor.js b/unpackage/dist/dev/mp-weixin/common/vendor.js index 664c81d..32af752 100644 --- a/unpackage/dist/dev/mp-weixin/common/vendor.js +++ b/unpackage/dist/dev/mp-weixin/common/vendor.js @@ -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 + }, + // 按钮的预置样式,info,primary,error,warning,success + type: { + type: String, + default: () => defProps.button.type + }, + // 按钮尺寸,large,normal,small,mini + 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 + }, + // 用于
组件,点击分别会触发 组件的 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; diff --git a/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.js b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.js new file mode 100644 index 0000000..87aae7a --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.js @@ -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); diff --git a/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.json b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.json new file mode 100644 index 0000000..9d49dfb --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "u-loading-icon": "../u-loading-icon/u-loading-icon", + "u-icon": "../u-icon/u-icon" + } +} \ No newline at end of file diff --git a/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.wxml b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.wxml new file mode 100644 index 0000000..fc2a9b8 --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.wxss b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.wxss new file mode 100644 index 0000000..ceeb9c7 --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-button/u-button.wxss @@ -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; +} \ No newline at end of file diff --git a/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-icon/u-icon.js b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-icon/u-icon.js index 75c44e5..6ea89fe 100644 --- a/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-icon/u-icon.js +++ b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-icon/u-icon.js @@ -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 = []; diff --git a/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-line/u-line.js b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-line/u-line.js index afbbfc8..7a8daf3 100644 --- a/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-line/u-line.js +++ b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-line/u-line.js @@ -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 = {}; diff --git a/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-link/u-link.js b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-link/u-link.js index de0f57a..b9a0548 100644 --- a/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-link/u-link.js +++ b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-link/u-link.js @@ -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 = { diff --git a/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-loading-icon/u-loading-icon.js b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-loading-icon/u-loading-icon.js index 22625f5..9965db1 100644 --- a/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-loading-icon/u-loading-icon.js +++ b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-loading-icon/u-loading-icon.js @@ -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可以通过一个伪数组对象创建指定长度的数组 diff --git a/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-swiper-indicator/u-swiper-indicator.js b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-swiper-indicator/u-swiper-indicator.js index 596c626..934af58 100644 --- a/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-swiper-indicator/u-swiper-indicator.js +++ b/unpackage/dist/dev/mp-weixin/node-modules/uview-plus/components/u-swiper-indicator/u-swiper-indicator.js @@ -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 diff --git a/unpackage/dist/dev/mp-weixin/pages/user/login.js b/unpackage/dist/dev/mp-weixin/pages/user/login.js new file mode 100644 index 0000000..01764e0 --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/pages/user/login.js @@ -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); diff --git a/unpackage/dist/dev/mp-weixin/pages/user/login.json b/unpackage/dist/dev/mp-weixin/pages/user/login.json new file mode 100644 index 0000000..20020ef --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/pages/user/login.json @@ -0,0 +1,7 @@ +{ + "navigationBarTitleText": "登录", + "navigationStyle": "default", + "usingComponents": { + "up-button": "../../node-modules/uview-plus/components/u-button/u-button" + } +} \ No newline at end of file diff --git a/unpackage/dist/dev/mp-weixin/pages/user/login.wxml b/unpackage/dist/dev/mp-weixin/pages/user/login.wxml new file mode 100644 index 0000000..7005fee --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/pages/user/login.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/unpackage/dist/dev/mp-weixin/pages/user/login.wxss b/unpackage/dist/dev/mp-weixin/pages/user/login.wxss new file mode 100644 index 0000000..5fc24f1 --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/pages/user/login.wxss @@ -0,0 +1,6 @@ + +.main { + height: 100vh; + display: flex; + align-items: center; +} diff --git a/unpackage/dist/dev/mp-weixin/pages/user/user.js b/unpackage/dist/dev/mp-weixin/pages/user/user.js index 414ce88..a489ac0 100644 --- a/unpackage/dist/dev/mp-weixin/pages/user/user.js +++ b/unpackage/dist/dev/mp-weixin/pages/user/user.js @@ -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), diff --git a/unpackage/dist/dev/mp-weixin/project.config.json b/unpackage/dist/dev/mp-weixin/project.config.json index 7de7e62..a35d5bd 100644 --- a/unpackage/dist/dev/mp-weixin/project.config.json +++ b/unpackage/dist/dev/mp-weixin/project.config.json @@ -15,11 +15,12 @@ "ignore": [], "disablePlugins": [], "outputPath": "" - } + }, + "ignoreUploadUnusedFiles": false }, "compileType": "miniprogram", "libVersion": "3.4.6", - "appid": "touristappid", + "appid": "wx0beef2b22e05d3d1", "projectname": "greenStu", "condition": {}, "editorSetting": { diff --git a/unpackage/dist/dev/mp-weixin/utils/Auth.js b/unpackage/dist/dev/mp-weixin/utils/Auth.js new file mode 100644 index 0000000..a489b41 --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/utils/Auth.js @@ -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; diff --git a/unpackage/dist/dev/mp-weixin/utils/http.js b/unpackage/dist/dev/mp-weixin/utils/http.js new file mode 100644 index 0000000..3ecaf3c --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/utils/http.js @@ -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; diff --git a/utils/Auth.js b/utils/Auth.js new file mode 100644 index 0000000..b3a8292 --- /dev/null +++ b/utils/Auth.js @@ -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 +} \ No newline at end of file diff --git a/utils/http.js b/utils/http.js new file mode 100644 index 0000000..751be04 --- /dev/null +++ b/utils/http.js @@ -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); + } + }); + }); +} diff --git a/utils/location.js b/utils/location.js new file mode 100644 index 0000000..9785482 --- /dev/null +++ b/utils/location.js @@ -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) + } + }) + }) +} \ No newline at end of file diff --git a/utils/msg.js b/utils/msg.js new file mode 100644 index 0000000..28a68b1 --- /dev/null +++ b/utils/msg.js @@ -0,0 +1,13 @@ + +const showtitle =(msg)=>{ + uni.showToast({ + icon:"none", + title:msg + }) +} + + + +export default{ + showtitle +} \ No newline at end of file